← Back to team overview

openlp-core team mailing list archive

[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)


Fix issues regarding the blank button for presentations
-- 
https://code.launchpad.net/~j-corwin/openlp/present/+merge/21097
Your team OpenLP Core is subscribed to branch lp:openlp.
=== modified file 'openlp/core/ui/slidecontroller.py'
--- openlp/core/ui/slidecontroller.py	2010-03-10 13:45:26 +0000
+++ openlp/core/ui/slidecontroller.py	2010-03-10 23:03:16 +0000
@@ -412,9 +412,13 @@
         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])
+                item.get_frame_title(), slideno, self.isLive, blanked])
         self.displayServiceManagerItems(item, slideno)
 
     def displayServiceManagerItems(self, serviceItem, slideno):
@@ -677,7 +681,7 @@
         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()

=== modified file 'openlp/plugins/presentations/lib/impresscontroller.py'
--- openlp/plugins/presentations/lib/impresscontroller.py	2010-03-05 19:39:30 +0000
+++ openlp/plugins/presentations/lib/impresscontroller.py	2010-03-10 23:03:16 +0000
@@ -102,11 +102,14 @@
         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 @@
                 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
@@ -214,7 +218,7 @@
         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
@@ -303,6 +307,13 @@
     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')
@@ -356,3 +367,38 @@
             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

=== modified file 'openlp/plugins/presentations/lib/mediaitem.py'
--- openlp/plugins/presentations/lib/mediaitem.py	2010-03-05 19:50:51 +0000
+++ openlp/plugins/presentations/lib/mediaitem.py	2010-03-10 23:03:16 +0000
@@ -52,17 +52,19 @@
         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 @@
             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 @@
         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

=== modified file 'openlp/plugins/presentations/lib/messagelistener.py'
--- openlp/plugins/presentations/lib/messagelistener.py	2010-03-05 19:39:30 +0000
+++ openlp/plugins/presentations/lib/messagelistener.py	2010-03-10 23:03:16 +0000
@@ -44,7 +44,7 @@
         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 @@
         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
 
@@ -71,6 +73,9 @@
         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)
@@ -82,6 +87,9 @@
         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)
@@ -93,6 +101,9 @@
         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)
@@ -104,6 +115,10 @@
         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)
@@ -115,6 +130,10 @@
         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)
@@ -124,12 +143,15 @@
         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
         #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,9 +161,12 @@
         self.doc.blank_screen()
 
     def unblank(self):
+        log.debug(u'Live = %s, unblank' % self.isLive)        
         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):
@@ -188,17 +213,17 @@
         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)
-        filetype = os.path.splitext(file)[1][1:]
-        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)
+            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)
@@ -264,7 +289,7 @@
         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()

=== modified file 'openlp/plugins/presentations/lib/powerpointcontroller.py'
--- openlp/plugins/presentations/lib/powerpointcontroller.py	2010-03-05 21:54:29 +0000
+++ openlp/plugins/presentations/lib/powerpointcontroller.py	2010-03-10 23:03:16 +0000
@@ -77,21 +77,6 @@
             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 @@
         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 @@
         if self.check_thumbnails():
             return
         self.presentation.Export(os.path.join(self.thumbnailpath, '')
-                                 , 'png', 600, 480)
+                                 , 'png', 640, 480)
 
     def close_presentation(self):
         """
@@ -176,11 +158,27 @@
         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
         """
-        if not self.controller.is_loaded():
+        if not self.is_loaded():
             return False
         try:
             if self.presentation.SlideShowWindow is None:
@@ -205,6 +203,12 @@
         """
         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
@@ -276,3 +280,33 @@
             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

=== modified file 'openlp/plugins/presentations/lib/pptviewcontroller.py'
--- openlp/plugins/presentations/lib/pptviewcontroller.py	2010-03-08 19:43:37 +0000
+++ openlp/plugins/presentations/lib/pptviewcontroller.py	2010-03-10 23:03:16 +0000
@@ -104,6 +104,7 @@
         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 @@
         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):
         """

=== modified file 'openlp/plugins/presentations/lib/presentationcontroller.py'
--- openlp/plugins/presentations/lib/presentationcontroller.py	2010-03-05 19:39:30 +0000
+++ openlp/plugins/presentations/lib/presentationcontroller.py	2010-03-10 23:03:16 +0000
@@ -172,6 +172,9 @@
     ``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 @@
         """
         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
@@ -350,3 +359,21 @@
             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 ''


Follow ups