From ebf5777a02b29c79aa863f13703710fdcbffcc42 Mon Sep 17 00:00:00 2001 From: Jonathan Corwin Date: Fri, 29 Apr 2011 09:58:10 +0100 Subject: [PATCH 1/4] Fix bug 773036 --- openlp/plugins/presentations/lib/mediaitem.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/openlp/plugins/presentations/lib/mediaitem.py b/openlp/plugins/presentations/lib/mediaitem.py index 74ff3fea8..6428ae535 100644 --- a/openlp/plugins/presentations/lib/mediaitem.py +++ b/openlp/plugins/presentations/lib/mediaitem.py @@ -285,7 +285,7 @@ class PresentationMediaItem(MediaManagerItem): "supports" the extension. If none found, then look for a controller which "also supports" it instead. """ - filetype = filename.split(u'.')[1] + filetype = filename.split(u'.')[-1] if not filetype: return None for controller in self.controllers: @@ -296,4 +296,4 @@ class PresentationMediaItem(MediaManagerItem): if self.controllers[controller].enabled(): if filetype in self.controllers[controller].alsosupports: return controller - return None \ No newline at end of file + return None From a9df8468aa6f6b6c2a0d0cb1416204703f30f6d4 Mon Sep 17 00:00:00 2001 From: Jonathan Corwin Date: Fri, 29 Apr 2011 23:29:29 +0100 Subject: [PATCH 2/4] Minimized impress troubles --- .../presentations/lib/impresscontroller.py | 20 +++++++++++-------- openlp/plugins/presentations/lib/mediaitem.py | 2 +- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/openlp/plugins/presentations/lib/impresscontroller.py b/openlp/plugins/presentations/lib/impresscontroller.py index c84f0ff1e..74ebb5672 100644 --- a/openlp/plugins/presentations/lib/impresscontroller.py +++ b/openlp/plugins/presentations/lib/impresscontroller.py @@ -38,6 +38,8 @@ import logging import os import time +from openlp.core.lib import Receiver + if os.name == u'nt': from win32com.client import Dispatch import pywintypes @@ -219,7 +221,6 @@ class ImpressDocument(PresentationDocument): The file name of the presentatios to the run. """ log.debug(u'Load Presentation OpenOffice') - #print "s.dsk1 ", self.desktop if os.name == u'nt': desktop = self.controller.get_com_desktop() if desktop is None: @@ -234,7 +235,6 @@ class ImpressDocument(PresentationDocument): return False self.desktop = desktop properties = [] - properties.append(self.create_property(u'Minimized', True)) properties = tuple(properties) try: self.document = desktop.loadComponentFromURL(url, u'_blank', @@ -242,6 +242,9 @@ class ImpressDocument(PresentationDocument): except: log.exception(u'Failed to load presentation %s' % url) return False + window = self.document.getCurrentController().getFrame() \ + .getContainerWindow() + window.setPosSize(0, 0, 200, 400, 12) self.presentation = self.document.getPresentation() self.presentation.Display = \ self.controller.plugin.renderer.screens.current_display + 1 @@ -387,14 +390,15 @@ class ImpressDocument(PresentationDocument): log.debug(u'start presentation OpenOffice') if self.control is None or not self.control.isRunning(): self.presentation.start() - # start() returns before the getCurrentComponent is ready. - # Try for 5 seconds + self.control = self.presentation.getController() + # start() returns before the Component is ready. + # Try for 30 seconds i = 1 - while self.desktop.getCurrentComponent() is None and i < 50: + while not self.control and i < 300: + Receiver.send_message(u'openlp_process_events') time.sleep(0.1) i = i + 1 - self.control = \ - self.desktop.getCurrentComponent().Presentation.getController() + self.control = self.presentation.getController() else: self.control.activate() self.goto_slide(1) @@ -463,4 +467,4 @@ class ImpressDocument(PresentationDocument): shape = page.getByIndex(idx) if shape.supportsService("com.sun.star.drawing.Text"): text += shape.getString() + '\n' - return text \ No newline at end of file + return text diff --git a/openlp/plugins/presentations/lib/mediaitem.py b/openlp/plugins/presentations/lib/mediaitem.py index 6428ae535..a00fe1879 100644 --- a/openlp/plugins/presentations/lib/mediaitem.py +++ b/openlp/plugins/presentations/lib/mediaitem.py @@ -285,7 +285,7 @@ class PresentationMediaItem(MediaManagerItem): "supports" the extension. If none found, then look for a controller which "also supports" it instead. """ - filetype = filename.split(u'.')[-1] + filetype = os.path.splitext(filename)[1] if not filetype: return None for controller in self.controllers: From 6584e6a1eda537f461be40e08e8fb4661fcca8be Mon Sep 17 00:00:00 2001 From: Jonathan Corwin Date: Fri, 29 Apr 2011 23:31:39 +0100 Subject: [PATCH 3/4] process events not required --- openlp/plugins/presentations/lib/impresscontroller.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/openlp/plugins/presentations/lib/impresscontroller.py b/openlp/plugins/presentations/lib/impresscontroller.py index 74ebb5672..6d8643611 100644 --- a/openlp/plugins/presentations/lib/impresscontroller.py +++ b/openlp/plugins/presentations/lib/impresscontroller.py @@ -38,8 +38,6 @@ import logging import os import time -from openlp.core.lib import Receiver - if os.name == u'nt': from win32com.client import Dispatch import pywintypes @@ -392,10 +390,9 @@ class ImpressDocument(PresentationDocument): self.presentation.start() self.control = self.presentation.getController() # start() returns before the Component is ready. - # Try for 30 seconds + # Try for 15 seconds i = 1 - while not self.control and i < 300: - Receiver.send_message(u'openlp_process_events') + while not self.control and i < 150: time.sleep(0.1) i = i + 1 self.control = self.presentation.getController() From 8bec30cf9c79bdf185ccd0655d6a9dc32b82a255 Mon Sep 17 00:00:00 2001 From: Jonathan Corwin Date: Sat, 30 Apr 2011 08:31:03 +0100 Subject: [PATCH 4/4] Make Impress changes windows specific --- .../plugins/presentations/lib/impresscontroller.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/openlp/plugins/presentations/lib/impresscontroller.py b/openlp/plugins/presentations/lib/impresscontroller.py index 6d8643611..a67d8f818 100644 --- a/openlp/plugins/presentations/lib/impresscontroller.py +++ b/openlp/plugins/presentations/lib/impresscontroller.py @@ -233,6 +233,10 @@ class ImpressDocument(PresentationDocument): return False self.desktop = desktop properties = [] + if os.name != u'nt': + # Recent versions of Impress on Windows won't start the presentation + # if it starts as minimized. It seems OK on Linux though. + properties.append(self.create_property(u'Minimized', True)) properties = tuple(properties) try: self.document = desktop.loadComponentFromURL(url, u'_blank', @@ -240,9 +244,12 @@ class ImpressDocument(PresentationDocument): except: log.exception(u'Failed to load presentation %s' % url) return False - window = self.document.getCurrentController().getFrame() \ - .getContainerWindow() - window.setPosSize(0, 0, 200, 400, 12) + if os.name == u'nt': + # As we can't start minimized the Impress window gets in the way. + # Either window.setPosSize(0, 0, 200, 400, 12) or .setVisible(False) + window = self.document.getCurrentController().getFrame() \ + .getContainerWindow() + window.setVisible(False) self.presentation = self.document.getPresentation() self.presentation.Display = \ self.controller.plugin.renderer.screens.current_display + 1