Merge lp:~j-corwin/openlp/presentations into lp:openlp

Proposed by Jonathan Corwin
Status: Merged
Merged at revision: not available
Proposed branch: lp:~j-corwin/openlp/presentations
Merge into: lp:openlp
Diff against target: None lines
To merge this branch: bzr merge lp:~j-corwin/openlp/presentations
Reviewer Review Type Date Requested Status
Tim Bentley Approve
Jon Tibble (community) Approve
Review via email: mp+12005@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Jonathan Corwin (j-corwin) wrote :

If on Windows, use COM rather than PyUNO for controlling Impress.

Revision history for this message
Jon Tibble (meths) wrote :

Approved: Works allowing me to view presentations.

Two issues thrown up by testing but not due to this patch so not requiring "Needs Fixing":
- The file/path handling in messagelistener.py is broken on Windows
- logging %s sys.exc_info() without an array [] entry is incorrect

review: Approve
Revision history for this message
Tim Bentley (trb143) wrote :

Approved

review: Approve
lp:~j-corwin/openlp/presentations updated
547. By Jonathan Corwin

for jonathan

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'openlp/plugins/presentations/lib/impresscontroller.py'
--- openlp/plugins/presentations/lib/impresscontroller.py 2009-09-11 19:29:57 +0000
+++ openlp/plugins/presentations/lib/impresscontroller.py 2009-09-17 07:28:47 +0000
@@ -29,9 +29,14 @@
29import logging29import logging
30import os , subprocess30import os , subprocess
31import time31import time
32import uno
33import sys32import sys
3433
34if os.name == u'nt':
35 from win32com.client import Dispatch
36else:
37 import uno
38
39
35from PyQt4 import QtCore40from PyQt4 import QtCore
3641
37class ImpressController(object):42class ImpressController(object):
@@ -57,11 +62,12 @@
57 when required.62 when required.
58 """63 """
59 log.debug(u'start Openoffice')64 log.debug(u'start Openoffice')
60 # -headless65 if os.name != u'nt':
61 cmd = u'openoffice.org -nologo -norestore -minimized -invisible ' + u'"' + u'-accept=socket,host=localhost,port=2002;urp;'+ u'"'66 # -headless
62 self.process = QtCore.QProcess()67 cmd = u'openoffice.org -nologo -norestore -minimized -invisible ' + u'"' + u'-accept=socket,host=localhost,port=2002;urp;'+ u'"'
63 self.process.startDetached(cmd)68 self.process = QtCore.QProcess()
64 self.process.waitForStarted()69 self.process.startDetached(cmd)
70 self.process.waitForStarted()
6571
66 def kill(self):72 def kill(self):
67 """73 """
@@ -81,6 +87,26 @@
81 The file name of the presentatios to the run.87 The file name of the presentatios to the run.
82 """88 """
83 log.debug(u'LoadPresentation')89 log.debug(u'LoadPresentation')
90 if os.name == u'nt':
91 desktop = self.getCOMDesktop()
92 url = u'file:///' + presentation.replace(u'\\', u'/').replace(u':', u'|').replace(u' ', u'%20')
93 else:
94 desktop = self.getUNODesktop()
95 url = uno.systemPathToFileUrl(presentation)
96 if(desktop==None):
97 return
98 try:
99 properties = []
100 properties = tuple(properties)
101 self.document = desktop.loadComponentFromURL(url, "_blank", 0, properties)
102 self.presentation = self.document.getPresentation()
103 self.presentation.start()
104 self.xSlideShowController = desktop.getCurrentComponent().Presentation.getController()
105 except:
106 log.error(u'Failed reason %s' % sys.exc_info())
107
108 def getUNODesktop(self):
109 log.debug(u'getUNODesktop')
84 ctx = None110 ctx = None
85 loop = 0111 loop = 0
86 context = uno.getComponentContext()112 context = uno.getComponentContext()
@@ -94,15 +120,20 @@
94 try:120 try:
95 smgr = ctx.ServiceManager121 smgr = ctx.ServiceManager
96 desktop = smgr.createInstanceWithContext( "com.sun.star.frame.Desktop", ctx )122 desktop = smgr.createInstanceWithContext( "com.sun.star.frame.Desktop", ctx )
97 url = uno.systemPathToFileUrl(presentation)123 return desktop
98 properties = []124 except:
99 properties = tuple(properties)125 log.error(u'Failed reason %s' % sys.exc_info())
100 self.document = desktop.loadComponentFromURL(url, "_blank", 0, properties)126 return None
101 self.presentation = self.document.getPresentation()127
102 self.presentation.start()128 def getCOMDesktop(self):
103 self.xSlideShowController = desktop.getCurrentComponent().Presentation.getController()129 log.debug(u'getCOMDesktop')
104 except:130 try:
105 log.error(u'Failed reason %s' % sys.exc_info())131 smgr = Dispatch("com.sun.star.ServiceManager")
132 desktop = smgr.createInstance( "com.sun.star.frame.Desktop")
133 return desktop
134 except:
135 log.error(u'Failed reason %s' % sys.exc_info())
136 return None
106137
107 def closePresentation(self):138 def closePresentation(self):
108 """139 """
109140
=== modified file 'openlp/plugins/presentations/presentationplugin.py'
--- openlp/plugins/presentations/presentationplugin.py 2009-09-13 07:39:48 +0000
+++ openlp/plugins/presentations/presentationplugin.py 2009-09-17 07:28:47 +0000
@@ -79,8 +79,12 @@
79 #Lets see if Impress is required (Default is Not wanted)79 #Lets see if Impress is required (Default is Not wanted)
80 if int(self.config.get_config(u'Impress', QtCore.Qt.Unchecked)) == QtCore.Qt.Checked:80 if int(self.config.get_config(u'Impress', QtCore.Qt.Unchecked)) == QtCore.Qt.Checked:
81 try:81 try:
82 #Check to see if we have uno installed82 if os.name == u'nt':
83 import uno83 #Check to see if we are Win32
84 from win32com.client import Dispatch
85 else:
86 #Check to see if we have uno installed
87 import uno
84 openoffice = ImpressController()88 openoffice = ImpressController()
85 self.registerControllers(u'Impress', openoffice)89 self.registerControllers(u'Impress', openoffice)
86 except:90 except: