def test_get_uno_command_connection_type(self): """ Test the ``get_uno_command`` function when the connection type is anything other than pipe. :return: """ # GIVEN: A patched 'which' method which returns 'libreoffice' with patch('openlp.core.common.which', **{'return_value': 'libreoffice'}): # WHEN: Calling get_uno_command with a connection type other than pipe result = get_uno_command('socket') # THEN: The connection parameters should be set for socket assert result == 'libreoffice --nologo --norestore --minimized --nodefault --nofirststartwizard' \ ' "--accept=socket,host=localhost,port=2002;urp;"'
def test_get_uno_command_connection_type(self): """ Test the ``get_uno_command`` function when the connection type is anything other than pipe. :return: """ # GIVEN: A patched 'which' method which returns 'libreoffice' with patch('openlp.core.common.which', **{'return_value': 'libreoffice'}): # WHEN: Calling get_uno_command with a connection type other than pipe result = get_uno_command('socket') # THEN: The connection parameters should be set for socket self.assertEqual(result, 'libreoffice --nologo --norestore --minimized --nodefault --nofirststartwizard' ' "--accept=socket,host=localhost,port=2002;urp;"')
def start_process(self): """ Loads a running version of OpenOffice in the background. It is not displayed to the user but is available to the UNO interface when required. """ log.debug('start process Openoffice') if is_win(): self.manager = self.get_com_servicemanager() self.manager._FlagAsMethod('Bridge_GetStruct') self.manager._FlagAsMethod('Bridge_GetValueObject') else: # -headless cmd = get_uno_command() self.process = QtCore.QProcess() self.process.startDetached(cmd)
def test_get_uno_command_libreoffice_command_exists(self): """ Test the ``get_uno_command`` function uses the libreoffice command when available. :return: """ # GIVEN: A patched 'which' method which returns a path when called with 'libreoffice' with patch('openlp.core.common.which', **{'side_effect': lambda command: {'libreoffice': '/usr/bin/libreoffice'}[command]}): # WHEN: Calling get_uno_command result = get_uno_command() # THEN: The command 'libreoffice' should be called with the appropriate parameters assert result == 'libreoffice --nologo --norestore --minimized --nodefault --nofirststartwizard' \ ' "--accept=pipe,name=openlp_pipe;urp;"'
def start_ooo_process(self): """ Start the OO Process """ try: if is_win(): self.ooo_manager = Dispatch('com.sun.star.ServiceManager') self.ooo_manager._FlagAsMethod('Bridge_GetStruct') self.ooo_manager._FlagAsMethod('Bridge_GetValueObject') else: cmd = get_uno_command() process = QtCore.QProcess() process.startDetached(cmd) self.process_started = True except: log.exception("start_ooo_process failed")
def test_get_uno_command_libreoffice_command_exists(self): """ Test the ``get_uno_command`` function uses the libreoffice command when available. :return: """ # GIVEN: A patched 'which' method which returns a path when called with 'libreoffice' with patch('openlp.core.common.which', **{'side_effect': lambda command: {'libreoffice': '/usr/bin/libreoffice'}[command]}): # WHEN: Calling get_uno_command result = get_uno_command() # THEN: The command 'libreoffice' should be called with the appropriate parameters self.assertEquals(result, 'libreoffice --nologo --norestore --minimized --nodefault --nofirststartwizard' ' "--accept=pipe,name=openlp_pipe;urp;"')