add pipe using for soffice

This commit is contained in:
rimach 2010-09-15 22:51:01 +02:00
parent 988b7506df
commit ea1321ef20
2 changed files with 20 additions and 6 deletions

View File

@ -98,7 +98,12 @@ class ImpressController(PresentationController):
self.manager._FlagAsMethod(u'Bridge_GetValueObject') self.manager._FlagAsMethod(u'Bridge_GetValueObject')
else: else:
# -headless # -headless
cmd = u'openoffice.org -nologo -norestore -minimized -invisible -nofirststartwizard -accept="socket,host=localhost,port=2002;urp;"' #connection_type = u'socket'
connection_type = u'pipe,name=openlp_pipe:'
cmd = u'openoffice.org -nologo -norestore -minimized ' \
+ u'-invisible -nofirststartwizard ' \
+ '-accept="' + connection_type \
+ u'socket,host=localhost,port=2002;urp;"'
self.process = QtCore.QProcess() self.process = QtCore.QProcess()
self.process.startDetached(cmd) self.process.startDetached(cmd)
self.process.waitForStarted() self.process.waitForStarted()
@ -117,11 +122,14 @@ class ImpressController(PresentationController):
u'UnoUrlResolver') u'UnoUrlResolver')
resolver = context.ServiceManager.createInstanceWithContext( resolver = context.ServiceManager.createInstanceWithContext(
u'com.sun.star.bridge.UnoUrlResolver', context) u'com.sun.star.bridge.UnoUrlResolver', context)
#connection_type = u'socket'
connection_type = u'pipe,name=openlp_pipe:'
while ctx is None and loop < 3: while ctx is None and loop < 3:
try: try:
log.debug(u'get UNO Desktop Openoffice - resolve') log.debug(u'get UNO Desktop Openoffice - resolve')
ctx = resolver.resolve(u'uno:socket,host=localhost,port=2002;' ctx = resolver.resolve(u'uno:' + connection_type \
u'urp;StarOffice.ComponentContext') + u',host=localhost,' \
+ u'port=2002;urp;StarOffice.ComponentContext')
except: except:
log.exception(u'Unable to find running instance ') log.exception(u'Unable to find running instance ')
self.start_process() self.start_process()

View File

@ -94,6 +94,8 @@ class OooImport(SongImport):
Start OpenOffice.org process Start OpenOffice.org process
TODO: The presentation/Impress plugin may already have it running TODO: The presentation/Impress plugin may already have it running
""" """
#connection_type = u'socket'
connection_type = u'pipe,name=openlp_pipe:'
if os.name == u'nt': if os.name == u'nt':
self.start_ooo_process() self.start_ooo_process()
self.desktop = self.manager.createInstance( self.desktop = self.manager.createInstance(
@ -106,8 +108,9 @@ class OooImport(SongImport):
loop = 0 loop = 0
while ctx is None and loop < 5: while ctx is None and loop < 5:
try: try:
ctx = resolver.resolve(u'uno:socket,host=localhost,' \ ctx = resolver.resolve(u'uno:' + connection_type \
+ 'port=2002;urp;StarOffice.ComponentContext') + u',host=localhost,' \
+ u'port=2002;urp;StarOffice.ComponentContext')
except: except:
pass pass
self.start_ooo_process() self.start_ooo_process()
@ -117,6 +120,8 @@ class OooImport(SongImport):
"com.sun.star.frame.Desktop", ctx) "com.sun.star.frame.Desktop", ctx)
def start_ooo_process(self): def start_ooo_process(self):
#connection_type = u'socket'
connection_type = u'pipe,name=openlp_pipe:'
try: try:
if os.name == u'nt': if os.name == u'nt':
self.manager = Dispatch(u'com.sun.star.ServiceManager') self.manager = Dispatch(u'com.sun.star.ServiceManager')
@ -125,7 +130,8 @@ class OooImport(SongImport):
else: else:
cmd = u'openoffice.org -nologo -norestore -minimized ' \ cmd = u'openoffice.org -nologo -norestore -minimized ' \
+ u'-invisible -nofirststartwizard ' \ + u'-invisible -nofirststartwizard ' \
+ '-accept="socket,host=localhost,port=2002;urp;"' + '-accept="' + connection_type \
+ u'socket,host=localhost,port=2002;urp;"'
process = QtCore.QProcess() process = QtCore.QProcess()
process.startDetached(cmd) process.startDetached(cmd)
process.waitForStarted() process.waitForStarted()