From a33a6d53ca7e23b58ed1cd6b0a4e5771d095eed0 Mon Sep 17 00:00:00 2001 From: Jonathan Corwin Date: Fri, 5 Mar 2010 22:10:53 +0000 Subject: [PATCH 1/5] coding standards --- openlp/plugins/presentations/lib/messagelistener.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/openlp/plugins/presentations/lib/messagelistener.py b/openlp/plugins/presentations/lib/messagelistener.py index 2b2375912..62f5df56c 100644 --- a/openlp/plugins/presentations/lib/messagelistener.py +++ b/openlp/plugins/presentations/lib/messagelistener.py @@ -189,8 +189,7 @@ class MessageListener(object): """ log.debug(u'Startup called with message %s' % message) self.handler, file, isLive = self.decodeMessage(message) - filetype = os.path.splitext(file)[1][1:] - if self.handler==u'Automatic': + if self.handler == u'Automatic': self.handler = self.mediaitem.findControllerByType(file) if not self.handler: return From 714135a94f1046792c9b35ae64bd3602052dcfe6 Mon Sep 17 00:00:00 2001 From: Jonathan Corwin Date: Sat, 6 Mar 2010 23:33:10 +0000 Subject: [PATCH 2/5] presentation text/notes routines. blanking issues --- openlp/core/ui/slidecontroller.py | 4 +- .../presentations/lib/impresscontroller.py | 37 +++++++++- openlp/plugins/presentations/lib/mediaitem.py | 8 ++- .../presentations/lib/messagelistener.py | 14 ++-- .../presentations/lib/powerpointcontroller.py | 68 +++++++++++++------ .../lib/presentationcontroller.py | 18 +++++ 6 files changed, 118 insertions(+), 31 deletions(-) diff --git a/openlp/core/ui/slidecontroller.py b/openlp/core/ui/slidecontroller.py index ff8507f5d..7221e9a21 100644 --- a/openlp/core/ui/slidecontroller.py +++ b/openlp/core/ui/slidecontroller.py @@ -415,7 +415,7 @@ class SlideController(QtGui.QWidget): elif item.is_command(): Receiver.send_message(u'%s_start' % item.name.lower(), \ [item.title, item.service_item_path, - item.get_frame_title(), slideno, self.isLive]) + item.get_frame_title(), slideno, self.isLive, self.blankButton.isChecked()]) self.displayServiceManagerItems(item, slideno) def displayServiceManagerItems(self, serviceItem, slideno): @@ -678,7 +678,7 @@ class SlideController(QtGui.QWidget): if self.isLive: Receiver.send_message(u'%s_start' % item.name.lower(), \ [item.title, item.service_item_path, - item.get_frame_title(), self.isLive]) + item.get_frame_title(), self.isLive, self.blankButton.isChecked()]) else: self.mediaObject.stop() self.mediaObject.clearQueue() diff --git a/openlp/plugins/presentations/lib/impresscontroller.py b/openlp/plugins/presentations/lib/impresscontroller.py index 196763cce..56a223f06 100644 --- a/openlp/plugins/presentations/lib/impresscontroller.py +++ b/openlp/plugins/presentations/lib/impresscontroller.py @@ -214,7 +214,7 @@ class ImpressDocument(PresentationDocument): self.presentation.Display = self.controller.plugin.render_manager.screens.current_display + 1 self.control = None self.create_thumbnails() - + def create_thumbnails(self): """ Create thumbnail images for presentation @@ -356,3 +356,38 @@ class ImpressDocument(PresentationDocument): return path else: return None + + def get_slide_text(self, slide_no): + """ + Returns the text on the slide + + ``slide_no`` + The slide the text is required for, starting at 1 + """ + doc = self.document + pages = doc.getDrawPages() + text = '' + page = pages.getByIndex(slide_no - 1) + for idx in range(page.getCount()): + shape = page.getByIndex(idx) + if shape.supportsService("com.sun.star.drawing.Text"): + text += shape.getString() + '\n' + return text + + def get_slide_notes(self, slide_no): + """ + Returns the text on the slide + + ``slide_no`` + The slide the notes are required for, starting at 1 + """ + doc = self.document + pages = doc.getDrawPages() + text = '' + page = pages.getByIndex(slide_no - 1) + notes = page.getNotesPage() + for idx in range(notes.getCount()): + shape = notes.getByIndex(idx) + if shape.supportsService("com.sun.star.drawing.Text"): + text += shape.getString() + '\n' + return text diff --git a/openlp/plugins/presentations/lib/mediaitem.py b/openlp/plugins/presentations/lib/mediaitem.py index 7fed27145..37d50d01c 100644 --- a/openlp/plugins/presentations/lib/mediaitem.py +++ b/openlp/plugins/presentations/lib/mediaitem.py @@ -52,17 +52,19 @@ class PresentationMediaItem(MediaManagerItem): self.PluginNameShort = u'Presentation' self.ConfigSection = title self.IconPath = u'presentations/presentation' + self.Automatic = u'' # this next is a class, not an instance of a class - it will # be instanced by the base MediaManagerItem self.ListViewWithDnD_class = PresentationListView MediaManagerItem.__init__(self, parent, icon, title) self.message_listener = MessageListener(self) - + def initPluginNameVisible(self): self.PluginNameVisible = self.trUtf8('Presentation') def retranslateUi(self): self.OnNewPrompt = self.trUtf8('Select Presentation(s)') + self.Automatic = self.trUtf8('Automatic') fileType = u'' for controller in self.controllers: if self.controllers[controller].enabled: @@ -108,7 +110,7 @@ class PresentationMediaItem(MediaManagerItem): if self.controllers[item].enabled: self.DisplayTypeComboBox.addItem(item) if self.DisplayTypeComboBox.count() > 1: - self.DisplayTypeComboBox.insertItem(0, u'Automatic') + self.DisplayTypeComboBox.insertItem(0, self.Automatic) self.DisplayTypeComboBox.setCurrentIndex(0) def loadList(self, list): @@ -154,7 +156,7 @@ class PresentationMediaItem(MediaManagerItem): for item in items: bitem = self.ListView.item(item.row()) filename = unicode((bitem.data(QtCore.Qt.UserRole)).toString()) - if shortname==u'Automatic': + if shortname == self.Automatic: service_item.shortname = self.findControllerByType(filename) if not service_item.shortname: return False diff --git a/openlp/plugins/presentations/lib/messagelistener.py b/openlp/plugins/presentations/lib/messagelistener.py index 62f5df56c..17a2492ea 100644 --- a/openlp/plugins/presentations/lib/messagelistener.py +++ b/openlp/plugins/presentations/lib/messagelistener.py @@ -44,7 +44,7 @@ class Controller(object): self.doc = None log.info(u'%s controller loaded' % live) - def addHandler(self, controller, file): + def addHandler(self, controller, file, isBlank): log.debug(u'Live = %s, addHandler %s' % (self.isLive, file)) self.controller = controller if self.doc is not None: @@ -53,6 +53,8 @@ class Controller(object): self.doc.load_presentation() if self.isLive: self.doc.start_presentation() + if isBlank: + self.blank() Receiver.send_message(u'live_slide_hide') self.doc.slidenumber = 0 @@ -130,6 +132,7 @@ class Controller(object): #self.timer.stop() def blank(self): + log.debug(u'Live = %s, blank' % self.isLive) if not self.isLive: return if not self.doc.is_loaded(): @@ -139,6 +142,7 @@ class Controller(object): self.doc.blank_screen() def unblank(self): + log.debug(u'Live = %s, unblank' % self.isLive) if not self.isLive: return self.activate() @@ -188,14 +192,14 @@ class MessageListener(object): Save the handler as any new presentations start here """ log.debug(u'Startup called with message %s' % message) - self.handler, file, isLive = self.decodeMessage(message) - if self.handler == u'Automatic': + self.handler, file, isLive, isBlank = self.decodeMessage(message) + if self.handler == self.mediaitem.Automatic: self.handler = self.mediaitem.findControllerByType(file) if not self.handler: return if isLive: - self.liveHandler.addHandler(self.controllers[self.handler], file) + self.liveHandler.addHandler(self.controllers[self.handler], file, isBlank) else: self.previewHandler.addHandler(self.controllers[self.handler], file) @@ -263,7 +267,7 @@ class MessageListener(object): Message containing Presentaion handler name and file to be presented. """ file = os.path.join(message[1], message[2]) - return message[0], file, message[4] + return message[0], file, message[4], message[5] def timeout(self): self.liveHandler.poll() diff --git a/openlp/plugins/presentations/lib/powerpointcontroller.py b/openlp/plugins/presentations/lib/powerpointcontroller.py index bbd2c528a..838ab6c8c 100644 --- a/openlp/plugins/presentations/lib/powerpointcontroller.py +++ b/openlp/plugins/presentations/lib/powerpointcontroller.py @@ -77,21 +77,6 @@ class PowerpointController(PresentationController): self.process.Visible = True self.process.WindowState = 2 - def is_loaded(self): - """ - Returns true if a presentation is loaded - """ - 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 @@ -134,11 +119,8 @@ class PowerpointDocument(PresentationDocument): The file name of the presentations to run. """ log.debug(u'LoadPresentation') - #try: if not self.controller.process.Visible: self.controller.start_process() - #except: - # self.controller.start_process() #try: self.controller.process.Presentations.Open(self.filepath, False, False, True) #except: @@ -159,7 +141,7 @@ class PowerpointDocument(PresentationDocument): if self.check_thumbnails(): return self.presentation.Export(os.path.join(self.thumbnailpath, '') - , 'png', 600, 480) + , 'png', 640, 480) def close_presentation(self): """ @@ -168,7 +150,7 @@ class PowerpointDocument(PresentationDocument): being shut down """ if self.presentation == None: - return + return try: self.presentation.Close() except: @@ -176,6 +158,22 @@ class PowerpointDocument(PresentationDocument): self.presentation = None self.controller.remove_doc(self) + def is_loaded(self): + """ + Returns true if a presentation is loaded + """ + try: + if not self.controller.process.Visible: + return False + if self.controller.process.Windows.Count == 0: + return False + if self.controller.process.Presentations.Count == 0: + return False + except: + return False + return True + + def is_active(self): """ Returns true if a presentation is currently active @@ -276,3 +274,33 @@ class PowerpointDocument(PresentationDocument): return path else: return None + + def get_slide_text(self, slide_no): + """ + Returns the text on the slide + + ``slide_no`` + The slide the text is required for, starting at 1 + """ + text = '' + shapes = self.presentation.Slides(slide_no).Shapes + for idx in range(shapes.Count): + shape = shapes(idx + 1) + if shape.HasTextFrame: + text += shape.TextFrame.TextRange.Text + '\n' + return text + + def get_slide_notes(self, slide_no): + """ + Returns the text on the slide + + ``slide_no`` + The slide the notes are required for, starting at 1 + """ + text = '' + shapes = self.presentation.Slides(slide_no).NotesPage.Shapes + for idx in range(shapes.Count): + shape = shapes(idx + 1) + if shape.HasTextFrame: + text += shape.TextFrame.TextRange.Text + '\n' + return text diff --git a/openlp/plugins/presentations/lib/presentationcontroller.py b/openlp/plugins/presentations/lib/presentationcontroller.py index 0783d40f4..5a914e1cc 100644 --- a/openlp/plugins/presentations/lib/presentationcontroller.py +++ b/openlp/plugins/presentations/lib/presentationcontroller.py @@ -350,3 +350,21 @@ class PresentationDocument(object): prefix = u'preview' Receiver.send_message(u'%s_slidecontroller_change' % prefix, self.slidenumber - 1) + + def get_slide_text(self, slide_no): + """ + Returns the text on the slide + + ``slide_no`` + The slide the text is required for, starting at 1 + """ + return '' + + def get_slide_notes(self, slide_no): + """ + Returns the text on the slide + + ``slide_no`` + The slide the notes are required for, starting at 1 + """ + return '' From d48046c0c349d9cc2d864c2676a2b67574989593 Mon Sep 17 00:00:00 2001 From: Jonathan Corwin Date: Wed, 10 Mar 2010 22:24:09 +0000 Subject: [PATCH 3/5] Blanking issues --- .../presentations/lib/impresscontroller.py | 11 ++++++++++ .../presentations/lib/messagelistener.py | 21 +++++++++++++++++++ .../presentations/lib/powerpointcontroller.py | 8 ++++++- .../presentations/lib/pptviewcontroller.py | 10 +++++++++ .../lib/presentationcontroller.py | 9 ++++++++ 5 files changed, 58 insertions(+), 1 deletion(-) diff --git a/openlp/plugins/presentations/lib/impresscontroller.py b/openlp/plugins/presentations/lib/impresscontroller.py index 56a223f06..2756f718e 100644 --- a/openlp/plugins/presentations/lib/impresscontroller.py +++ b/openlp/plugins/presentations/lib/impresscontroller.py @@ -102,11 +102,14 @@ class ImpressController(PresentationController): log.debug(u'get UNO Desktop Openoffice') ctx = None loop = 0 + log.debug(u'get UNO Desktop Openoffice - getComponentContext') context = uno.getComponentContext() + log.debug(u'get UNO Desktop Openoffice - createInstaneWithContext - UnoUrlResolver') resolver = context.ServiceManager.createInstanceWithContext( u'com.sun.star.bridge.UnoUrlResolver', context) while ctx is None and loop < 3: try: + log.debug(u'get UNO Desktop Openoffice - resolve') ctx = resolver.resolve(u'uno:socket,host=localhost,port=2002;urp;StarOffice.ComponentContext') except: log.exception(u'Unable to find running instance ') @@ -114,6 +117,7 @@ class ImpressController(PresentationController): loop += 1 try: self.manager = ctx.ServiceManager + log.debug(u'get UNO Desktop Openoffice - createInstanceWithContext - Desktop') desktop = self.manager.createInstanceWithContext( "com.sun.star.frame.Desktop", ctx ) return desktop @@ -303,6 +307,13 @@ class ImpressDocument(PresentationDocument): def blank_screen(self): log.debug(u'blank screen OpenOffice') self.control.blankScreen(0) + + def is_blank(self): + """ + Returns true if screen is blank + """ + log.debug(u'is blank OpenOffice') + return self.control.isPaused() def stop_presentation(self): log.debug(u'stop presentation OpenOffice') diff --git a/openlp/plugins/presentations/lib/messagelistener.py b/openlp/plugins/presentations/lib/messagelistener.py index 17a2492ea..c3c9a91f5 100644 --- a/openlp/plugins/presentations/lib/messagelistener.py +++ b/openlp/plugins/presentations/lib/messagelistener.py @@ -73,6 +73,9 @@ class Controller(object): log.debug(u'Live = %s, slide' % live) if not live: return + if self.doc.is_blank(): + self.doc.slidenumber = int(slide) + 1 + return self.activate() self.doc.goto_slide(int(slide) + 1) self.doc.poll_slidenumber(live) @@ -84,6 +87,9 @@ class Controller(object): log.debug(u'Live = %s, first' % self.isLive) if not self.isLive: return + if self.doc.is_blank(): + self.doc.slidenumber = 1 + return self.activate() self.doc.start_presentation() self.doc.poll_slidenumber(self.isLive) @@ -95,6 +101,9 @@ class Controller(object): log.debug(u'Live = %s, last' % self.isLive) if not self.isLive: return + if self.doc.is_blank(): + self.doc.slidenumber = self.doc.get_slide_count() + return self.activate() self.doc.goto_slide(self.doc.get_slide_count()) self.doc.poll_slidenumber(self.isLive) @@ -106,6 +115,10 @@ class Controller(object): log.debug(u'Live = %s, next' % self.isLive) if not self.isLive: return + if self.doc.is_blank(): + if self.doc.slidenumber < self.doc.get_slide_count(): + self.doc.slidenumber = self.doc.slidenumber + 1 + return self.activate() self.doc.next_step() self.doc.poll_slidenumber(self.isLive) @@ -117,6 +130,10 @@ class Controller(object): log.debug(u'Live = %s, previous' % self.isLive) if not self.isLive: return + if self.doc.is_blank(): + if self.doc.slidenumber > 1: + self.doc.slidenumber = self.doc.slidenumber - 1 + return self.activate() self.doc.previous_step() self.doc.poll_slidenumber(self.isLive) @@ -126,6 +143,8 @@ class Controller(object): Based on the handler passed at startup triggers slide show to shut down """ log.debug(u'Live = %s, shutdown' % self.isLive) + if self.isLive: + Receiver.send_message(u'live_slide_show') self.doc.close_presentation() self.doc = None #self.doc.slidenumber = 0 @@ -146,6 +165,8 @@ class Controller(object): if not self.isLive: return self.activate() + if self.doc.slidenumber and self.doc.slidenumber != self.doc.get_slide_number(): + self.doc.goto_slide(self.doc.slidenumber) self.doc.unblank_screen() def poll(self): diff --git a/openlp/plugins/presentations/lib/powerpointcontroller.py b/openlp/plugins/presentations/lib/powerpointcontroller.py index 838ab6c8c..909a8439b 100644 --- a/openlp/plugins/presentations/lib/powerpointcontroller.py +++ b/openlp/plugins/presentations/lib/powerpointcontroller.py @@ -178,7 +178,7 @@ class PowerpointDocument(PresentationDocument): """ Returns true if a presentation is currently active """ - if not self.controller.is_loaded(): + if not self.is_loaded(): return False try: if self.presentation.SlideShowWindow == None: @@ -203,6 +203,12 @@ class PowerpointDocument(PresentationDocument): """ self.presentation.SlideShowWindow.View.State = 3 + def is_blank(self): + """ + Returns true if screen is blank + """ + return self.presentation.SlideShowWindow.View.State == 3 + def stop_presentation(self): """ Stops the current presentation and hides the output diff --git a/openlp/plugins/presentations/lib/pptviewcontroller.py b/openlp/plugins/presentations/lib/pptviewcontroller.py index d3332f68c..3780d1225 100644 --- a/openlp/plugins/presentations/lib/pptviewcontroller.py +++ b/openlp/plugins/presentations/lib/pptviewcontroller.py @@ -104,6 +104,7 @@ class PptviewDocument(PresentationDocument): log.debug(u'Init Presentation PowerPoint') self.presentation = None self.pptid = None + self.blanked = False self.controller = controller self.store_filename(presentation) @@ -161,12 +162,21 @@ class PptviewDocument(PresentationDocument): Blanks the screen """ self.controller.process.Blank(self.pptid) + self.blanked = True def unblank_screen(self): """ Unblanks (restores) the presentationn """ self.controller.process.Unblank(self.pptid) + self.blanked = False + + def is_blank(self): + """ + Returns true if screen is blank + """ + log.debug(u'is blank OpenOffice') + return self.blanked def stop_presentation(self): """ diff --git a/openlp/plugins/presentations/lib/presentationcontroller.py b/openlp/plugins/presentations/lib/presentationcontroller.py index 5a914e1cc..ae41a56b1 100644 --- a/openlp/plugins/presentations/lib/presentationcontroller.py +++ b/openlp/plugins/presentations/lib/presentationcontroller.py @@ -172,6 +172,9 @@ class PresentationDocument(object): ``unblank_screen()`` Unblanks the screen, restoring the output + ``is_blank`` + Returns true if screen is blank + ``stop_presentation()`` Stops the presentation, removing it from the output display @@ -279,6 +282,12 @@ class PresentationDocument(object): """ pass + def is_blank(self): + """ + Returns true if screen is blank + """ + return False + def stop_presentation(self): """ Stops the presentation, removing it from the output display From 1613610853e7a0eca145a181228fcaefeef521fb Mon Sep 17 00:00:00 2001 From: Jonathan Corwin Date: Wed, 10 Mar 2010 22:32:27 +0000 Subject: [PATCH 4/5] Good idea to test conflict resolutions before committing --- openlp/plugins/presentations/lib/powerpointcontroller.py | 1 - 1 file changed, 1 deletion(-) diff --git a/openlp/plugins/presentations/lib/powerpointcontroller.py b/openlp/plugins/presentations/lib/powerpointcontroller.py index c6683fb20..2137496a5 100644 --- a/openlp/plugins/presentations/lib/powerpointcontroller.py +++ b/openlp/plugins/presentations/lib/powerpointcontroller.py @@ -310,4 +310,3 @@ class PowerpointDocument(PresentationDocument): if shape.HasTextFrame: text += shape.TextFrame.TextRange.Text + '\n' return text -s \ No newline at end of file From bfee664c94b3daa5cbf1483aae5bbaca534358ec Mon Sep 17 00:00:00 2001 From: Jonathan Corwin Date: Wed, 10 Mar 2010 23:00:48 +0000 Subject: [PATCH 5/5] fixes --- openlp/core/ui/slidecontroller.py | 6 +++++- openlp/plugins/presentations/lib/messagelistener.py | 7 ++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/openlp/core/ui/slidecontroller.py b/openlp/core/ui/slidecontroller.py index 0143be4cf..a8f33baea 100644 --- a/openlp/core/ui/slidecontroller.py +++ b/openlp/core/ui/slidecontroller.py @@ -412,9 +412,13 @@ class SlideController(QtGui.QWidget): if item.is_media(): self.onMediaStart(item) elif item.is_command(): + if self.isLive: + blanked = self.blankButton.isChecked() + else: + blanked = False Receiver.send_message(u'%s_start' % item.name.lower(), \ [item.title, item.service_item_path, - item.get_frame_title(), slideno, self.isLive, self.blankButton.isChecked()]) + item.get_frame_title(), slideno, self.isLive, blanked]) self.displayServiceManagerItems(item, slideno) def displayServiceManagerItems(self, serviceItem, slideno): diff --git a/openlp/plugins/presentations/lib/messagelistener.py b/openlp/plugins/presentations/lib/messagelistener.py index c3c9a91f5..08aa7e73a 100644 --- a/openlp/plugins/presentations/lib/messagelistener.py +++ b/openlp/plugins/presentations/lib/messagelistener.py @@ -218,11 +218,12 @@ class MessageListener(object): self.handler = self.mediaitem.findControllerByType(file) if not self.handler: return - + if isLive: - self.liveHandler.addHandler(self.controllers[self.handler], file, isBlank) + controller = self.liveHandler else: - self.previewHandler.addHandler(self.controllers[self.handler], file) + controller = self.previewHandler + controller.addHandler(self.controllers[self.handler], file, isBlank) def slide(self, message): slide, live = self.splitMessage(message)