openlp-core team mailing list archive
-
openlp-core team
-
Mailing list archive
-
Message #00539
[Merge] lp:~j-corwin/openlp/present into lp:openlp
Jonathan Corwin has proposed merging lp:~j-corwin/openlp/present into lp:openlp.
Requested reviews:
OpenLP Core (openlp-core)
Attempt to handle silly user errors, like shutting down powerpoint or the viewer halfway through a presentation.
(Impress still to do.)
--
https://code.launchpad.net/~j-corwin/openlp/present/+merge/13190
Your team OpenLP Core is subscribed to branch lp:openlp.
=== modified file 'openlp/plugins/presentations/lib/impresscontroller.py'
--- openlp/plugins/presentations/lib/impresscontroller.py 2009-10-08 23:24:26 +0000
+++ openlp/plugins/presentations/lib/impresscontroller.py 2009-10-11 21:40:24 +0000
@@ -79,7 +79,11 @@
when required.
"""
log.debug(u'start Openoffice')
- if os.name != u'nt':
+ if os.name == u'nt':
+ self.manager = self.get_com_servicemanager()
+ self.manager._FlagAsMethod(u'Bridge_GetStruct')
+ self.manager._FlagAsMethod(u'Bridge_GetValueObject')
+ else:
# -headless
cmd = u'openoffice.org -nologo -norestore -minimized -invisible ' + u'"' + u'-accept=socket,host=localhost,port=2002;urp;'+ u'"'
self.process = QtCore.QProcess()
@@ -108,6 +112,9 @@
self.store_filename(presentation)
if os.name == u'nt':
desktop = self.get_com_desktop()
+ if desktop is None:
+ self.start_process()
+ desktop = self.get_com_desktop()
url = u'file:///' + presentation.replace(u'\\', u'/').replace(u':', u'|').replace(u' ', u'%20')
else:
desktop = self.get_uno_desktop()
@@ -169,7 +176,7 @@
try:
ctx = resolver.resolve(u'uno:socket,host=localhost,port=2002;urp;StarOffice.ComponentContext')
except:
- self.startOpenoffice()
+ self.start_process()
loop += 1
try:
self.manager = ctx.ServiceManager
@@ -183,14 +190,11 @@
def get_com_desktop(self):
log.debug(u'getCOMDesktop')
try:
- self.manager = self.get_com_servicemanager()
- self.manager._FlagAsMethod(u'Bridge_GetStruct')
- self.manager._FlagAsMethod(u'Bridge_GetValueObject')
desktop = self.manager.createInstance(u'com.sun.star.frame.Desktop')
return desktop
except:
log.exception(u'Failed to get COM desktop')
- return None
+ return None
def get_com_servicemanager(self):
log.debug(u'get_com_servicemanager')
=== modified file 'openlp/plugins/presentations/lib/messagelistener.py'
--- openlp/plugins/presentations/lib/messagelistener.py 2009-10-03 19:18:59 +0000
+++ openlp/plugins/presentations/lib/messagelistener.py 2009-10-11 21:40:24 +0000
@@ -64,74 +64,74 @@
self.handler, file = self.decodeMessage(message)
self.controller = self.controllers[self.handler]
if self.controller.is_loaded():
- self.shutdown()
+ self.shutdown(None)
self.controller.load_presentation(file)
+ self.controller.slidenumber = 0
+ def activate(self):
+ if self.controller.is_active():
+ return
+ if not self.controller.is_loaded():
+ self.controller.load_presentation(self.controller.filepath)
+ else:
+ self.controller.start_presentation()
+ if self.controller.slidenumber > 1:
+ self.controller.goto_slide(self.controller.slidenumber)
+
def slide(self, message):
- #if not self.controller.is_loaded():
- # return
- #if not self.controller.is_active():
- # self.controller.start_presentation()
- self.controller.goto_slide(message[0])
+ self.activate()
+ if message is not None:
+ self.controller.goto_slide(message[0])
+ self.controller.slidenumber = self.controller.get_slide_number()
def first(self, message):
"""
Based on the handler passed at startup triggers the first slide
"""
- #if not self.controller.is_loaded():
- # return
+ self.activate()
self.controller.start_presentation()
+ self.controller.slidenumber = self.controller.get_slide_number()
def last(self, message):
"""
Based on the handler passed at startup triggers the first slide
"""
- #if not self.controller.is_loaded():
- # return
- #if not self.controller.is_active():
- # self.controller.start_presentation()
+ self.activate()
self.controller.goto_slide(self.controller.get_slide_count())
+ self.controller.slidenumber = self.controller.get_slide_number()
def next(self, message):
"""
Based on the handler passed at startup triggers the next slide event
"""
- #if not self.controller.is_loaded():
- # return
- #if not self.controller.is_active():
- # self.controller.start_presentation()
- # self.controller.goto_slide(self.controller.current_slide)
+ self.activate()
self.controller.next_step()
+ self.controller.slidenumber = self.controller.get_slide_number()
def previous(self, message):
"""
Based on the handler passed at startup triggers the previous slide event
"""
- #if not self.controller.is_loaded():
- # return
- #if not self.controller.is_active():
- # self.controller.start_presentation()
- # self.controller.goto_slide(self.controller.current_slide)
+ self.activate()
self.controller.previous_step()
+ self.controller.slidenumber = self.controller.get_slide_number()
def shutdown(self, message):
"""
Based on the handler passed at startup triggers slide show to shut down
"""
self.controller.close_presentation()
+ self.controller.slidenumber = 0
def blank(self):
- #if not self.controller.is_loaded():
- # return
- #if not self.controller.is_active():
- # self.controller.start_presentation()
+ if not self.controller.is_loaded():
+ return
+ if not self.controller.is_active():
+ return
self.controller.blank_screen()
def unblank(self):
- #if not self.controller.is_loaded():
- # return
- #if not self.controller.is_active():
- # self.controller.start_presentation()
+ self.activate()
self.controller.unblank_screen()
def decodeMessage(self, message):
=== modified file 'openlp/plugins/presentations/lib/powerpointcontroller.py'
--- openlp/plugins/presentations/lib/powerpointcontroller.py 2009-10-08 23:24:26 +0000
+++ openlp/plugins/presentations/lib/powerpointcontroller.py 2009-10-11 21:40:24 +0000
@@ -80,16 +80,27 @@
"""
Returns true if a presentation is loaded
"""
- if self.process is None:
- return False
- if self.process.Windows.Count == 0:
- return False
+ try:
+ if not self.process.Visible:
+ return False
+ if self.process.Windows.Count == 0:
+ return False
+ if self.process.Presentations.Count == 0:
+ return False
+ except:
+ return False
+ return True
def kill(self):
"""
Called at system exit to clean up any running presentations
- """
- self.process.Quit()
+ """
+ if self.process is None:
+ return
+ try:
+ self.process.Quit()
+ except:
+ pass
self.process = None
def load_presentation(self, presentation):
@@ -105,7 +116,15 @@
"""
log.debug(u'LoadPresentation')
self.store_filename(presentation)
- self.process.Presentations.Open(presentation, False, False, True)
+ try:
+ if not self.process.Visible:
+ self.start_process()
+ except:
+ self.start_process()
+ try:
+ self.process.Presentations.Open(presentation, False, False, True)
+ except:
+ return
self.presentation = self.process.Presentations(self.process.Presentations.Count)
self.create_thumbnails()
self.start_presentation()
@@ -124,15 +143,18 @@
self.presentation.Export(os.path.join(self.thumbnailpath, '')
, 'png', 600, 480)
-
-
def close_presentation(self):
"""
Close presentation and clean up objects
Triggerent by new object being added to SlideController orOpenLP
being shut down
"""
- self.presentation.Close()
+ if self.presentation == None:
+ return
+ try:
+ self.presentation.Close()
+ except:
+ pass
self.presentation = None
def is_active(self):
@@ -141,9 +163,12 @@
"""
if not self.is_loaded():
return False
- if self.presentation.SlideShowWindow == None:
- return False
- if self.presentation.SlideShowWindow.View == None:
+ try:
+ if self.presentation.SlideShowWindow == None:
+ return False
+ if self.presentation.SlideShowWindow.View == None:
+ return False
+ except:
return False
return True
@@ -171,12 +196,18 @@
"""
Starts a presentation from the beginning
"""
+ #SlideShowWindow measures its size/position by points, not pixels
+ try:
+ dpi = win32ui.GetActiveWindow().GetDC().GetDeviceCaps(88)
+ except:
+ try:
+ dpi = win32ui.GetForegroundWindow().GetDC().GetDeviceCaps(88)
+ except:
+ dpi = 96
self.presentation.SlideShowSettings.Run()
self.presentation.SlideShowWindow.View.GotoSlide(1)
rendermanager = self.plugin.render_manager
rect = rendermanager.screen_list[rendermanager.current_display][u'size']
- #SlideShowWindow measures its size/position by points, not pixels
- dpi = win32ui.GetActiveWindow().GetDC().GetDeviceCaps(88)
self.presentation.SlideShowWindow.Top = rect.y() * 72 / dpi
self.presentation.SlideShowWindow.Height = rect.height() * 72 / dpi
self.presentation.SlideShowWindow.Left = rect.x() * 72 / dpi
@@ -221,3 +252,4 @@
"""
return os.path.join(self.thumbnailpath,
self.thumbnailprefix + unicode(slide_no) + u'.png')
+\
=== modified file 'openlp/plugins/presentations/lib/pptviewcontroller.py'
--- openlp/plugins/presentations/lib/pptviewcontroller.py 2009-10-08 23:24:26 +0000
+++ openlp/plugins/presentations/lib/pptviewcontroller.py 2009-10-11 21:40:24 +0000
@@ -128,13 +128,17 @@
"""
Returns true if a presentation is loaded
"""
- return self.pptid >= 0
+ if self.pptid < 0:
+ return False
+ if self.get_slide_count() < 0:
+ return False
+ return True
def is_active(self):
"""
Returns true if a presentation is currently active
"""
- return self.pptid >= 0
+ return self.is_loaded()
def blank_screen(self):
"""
=== modified file 'openlp/plugins/presentations/lib/presentationcontroller.py'
--- openlp/plugins/presentations/lib/presentationcontroller.py 2009-10-08 23:24:26 +0000
+++ openlp/plugins/presentations/lib/presentationcontroller.py 2009-10-11 21:40:24 +0000
@@ -132,6 +132,7 @@
self.plugin = plugin
self.name = name
self.available = self.check_available()
+ self.slidenumber = 0
if self.available:
self.enabled = int(plugin.config.get_config(
name, QtCore.Qt.Unchecked)) == QtCore.Qt.Checked
Follow ups