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
1=== modified file 'openlp/plugins/presentations/lib/impresscontroller.py'
2--- openlp/plugins/presentations/lib/impresscontroller.py 2009-09-11 19:29:57 +0000
3+++ openlp/plugins/presentations/lib/impresscontroller.py 2009-09-17 07:28:47 +0000
4@@ -29,9 +29,14 @@
5 import logging
6 import os , subprocess
7 import time
8-import uno
9 import sys
10
11+if os.name == u'nt':
12+ from win32com.client import Dispatch
13+else:
14+ import uno
15+
16+
17 from PyQt4 import QtCore
18
19 class ImpressController(object):
20@@ -57,11 +62,12 @@
21 when required.
22 """
23 log.debug(u'start Openoffice')
24- # -headless
25- cmd = u'openoffice.org -nologo -norestore -minimized -invisible ' + u'"' + u'-accept=socket,host=localhost,port=2002;urp;'+ u'"'
26- self.process = QtCore.QProcess()
27- self.process.startDetached(cmd)
28- self.process.waitForStarted()
29+ if os.name != u'nt':
30+ # -headless
31+ cmd = u'openoffice.org -nologo -norestore -minimized -invisible ' + u'"' + u'-accept=socket,host=localhost,port=2002;urp;'+ u'"'
32+ self.process = QtCore.QProcess()
33+ self.process.startDetached(cmd)
34+ self.process.waitForStarted()
35
36 def kill(self):
37 """
38@@ -81,6 +87,26 @@
39 The file name of the presentatios to the run.
40 """
41 log.debug(u'LoadPresentation')
42+ if os.name == u'nt':
43+ desktop = self.getCOMDesktop()
44+ url = u'file:///' + presentation.replace(u'\\', u'/').replace(u':', u'|').replace(u' ', u'%20')
45+ else:
46+ desktop = self.getUNODesktop()
47+ url = uno.systemPathToFileUrl(presentation)
48+ if(desktop==None):
49+ return
50+ try:
51+ properties = []
52+ properties = tuple(properties)
53+ self.document = desktop.loadComponentFromURL(url, "_blank", 0, properties)
54+ self.presentation = self.document.getPresentation()
55+ self.presentation.start()
56+ self.xSlideShowController = desktop.getCurrentComponent().Presentation.getController()
57+ except:
58+ log.error(u'Failed reason %s' % sys.exc_info())
59+
60+ def getUNODesktop(self):
61+ log.debug(u'getUNODesktop')
62 ctx = None
63 loop = 0
64 context = uno.getComponentContext()
65@@ -94,15 +120,20 @@
66 try:
67 smgr = ctx.ServiceManager
68 desktop = smgr.createInstanceWithContext( "com.sun.star.frame.Desktop", ctx )
69- url = uno.systemPathToFileUrl(presentation)
70- properties = []
71- properties = tuple(properties)
72- self.document = desktop.loadComponentFromURL(url, "_blank", 0, properties)
73- self.presentation = self.document.getPresentation()
74- self.presentation.start()
75- self.xSlideShowController = desktop.getCurrentComponent().Presentation.getController()
76- except:
77- log.error(u'Failed reason %s' % sys.exc_info())
78+ return desktop
79+ except:
80+ log.error(u'Failed reason %s' % sys.exc_info())
81+ return None
82+
83+ def getCOMDesktop(self):
84+ log.debug(u'getCOMDesktop')
85+ try:
86+ smgr = Dispatch("com.sun.star.ServiceManager")
87+ desktop = smgr.createInstance( "com.sun.star.frame.Desktop")
88+ return desktop
89+ except:
90+ log.error(u'Failed reason %s' % sys.exc_info())
91+ return None
92
93 def closePresentation(self):
94 """
95
96=== modified file 'openlp/plugins/presentations/presentationplugin.py'
97--- openlp/plugins/presentations/presentationplugin.py 2009-09-13 07:39:48 +0000
98+++ openlp/plugins/presentations/presentationplugin.py 2009-09-17 07:28:47 +0000
99@@ -79,8 +79,12 @@
100 #Lets see if Impress is required (Default is Not wanted)
101 if int(self.config.get_config(u'Impress', QtCore.Qt.Unchecked)) == QtCore.Qt.Checked:
102 try:
103- #Check to see if we have uno installed
104- import uno
105+ if os.name == u'nt':
106+ #Check to see if we are Win32
107+ from win32com.client import Dispatch
108+ else:
109+ #Check to see if we have uno installed
110+ import uno
111 openoffice = ImpressController()
112 self.registerControllers(u'Impress', openoffice)
113 except: