This commit is contained in:
Tim Bentley 2010-03-11 12:48:19 +00:00
commit dde75e2288
8 changed files with 186 additions and 34 deletions

View File

@ -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])
item.get_frame_title(), slideno, self.isLive, blanked])
self.displayServiceManagerItems(item, slideno)
def displayServiceManagerItems(self, serviceItem, slideno):
@ -679,7 +683,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()

View File

@ -223,6 +223,10 @@ class CWExtract(BibleCommon):
for part in verse.contents:
if str(part)[0] != u'<':
versetext = versetext + part
elif part and part.attrMap and part.attrMap[u'class'] == u'WordsOfChrist':
for subpart in part.contents:
if str(subpart)[0] != '<':
versetext = versetext + subpart
versetext = versetext.strip(u'\n\r\t ')
verses[versenumber] = versetext
return SearchResults(bookname, chapter, verses)

View File

@ -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
@ -214,7 +218,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
@ -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')
@ -356,3 +367,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

View File

@ -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

View File

@ -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
@ -71,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)
@ -82,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)
@ -93,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)
@ -104,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)
@ -115,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)
@ -124,12 +143,15 @@ 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
#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 @@ 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()
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 @@ 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)
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 @@ 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()

View File

@ -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):
"""
@ -176,11 +158,27 @@ 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
"""
if not self.controller.is_loaded():
if not self.is_loaded():
return False
try:
if self.presentation.SlideShowWindow is None:
@ -205,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
@ -276,3 +280,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

View File

@ -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):
"""

View File

@ -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
@ -350,3 +359,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 ''