Merge from trunk

This commit is contained in:
Raoul Snyman 2010-02-06 15:39:14 +02:00
commit c1f5a78290
9 changed files with 71 additions and 20 deletions

View File

@ -159,7 +159,7 @@ def main():
help="Set the Qt4 style (passed directly to Qt4).") help="Set the Qt4 style (passed directly to Qt4).")
# Set up logging # Set up logging
filename = u'openlp.log' filename = u'openlp.log'
logfile = FileHandler(filename) logfile = FileHandler(filename, u'w')
logfile.setFormatter(logging.Formatter( logfile.setFormatter(logging.Formatter(
u'%(asctime)s %(name)-15s %(levelname)-8s %(message)s')) u'%(asctime)s %(name)-15s %(levelname)-8s %(message)s'))
log.addHandler(logfile) log.addHandler(logfile)

View File

@ -104,6 +104,9 @@ class EventReceiver(QtCore.QObject):
``remote_edit_clear`` ``remote_edit_clear``
Informs all components that remote edit has been aborted. Informs all components that remote edit has been aborted.
``presentation types``
Informs all components of the presentation types supported.
""" """
global log global log
log = logging.getLogger(u'EventReceiver') log = logging.getLogger(u'EventReceiver')

View File

@ -225,12 +225,17 @@ class ServiceManager(QtGui.QWidget):
QtCore.SIGNAL(u'update_themes'), self.updateThemeList) QtCore.SIGNAL(u'update_themes'), self.updateThemeList)
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.QObject.connect(Receiver.get_receiver(),
QtCore.SIGNAL(u'remote_edit_clear'), self.onRemoteEditClear) QtCore.SIGNAL(u'remote_edit_clear'), self.onRemoteEditClear)
QtCore.QObject.connect(Receiver.get_receiver(),
QtCore.SIGNAL(u'presentation types'), self.onPresentationTypes)
# Last little bits of setting up # Last little bits of setting up
self.config = PluginConfig(u'ServiceManager') self.config = PluginConfig(u'ServiceManager')
self.servicePath = self.config.get_data_path() self.servicePath = self.config.get_data_path()
self.service_theme = unicode( self.service_theme = unicode(
self.config.get_config(u'service theme', u'')) self.config.get_config(u'service theme', u''))
def onPresentationTypes(self, presentation_types):
self.presentation_types = presentation_types
def onMoveSelectionUp(self): def onMoveSelectionUp(self):
""" """
Moves the selection up the window Moves the selection up the window
@ -433,10 +438,10 @@ class ServiceManager(QtGui.QWidget):
for item in self.serviceItems: for item in self.serviceItems:
service.append({u'serviceitem':item[u'service_item'].get_service_repr()}) service.append({u'serviceitem':item[u'service_item'].get_service_repr()})
if item[u'service_item'].uses_file(): if item[u'service_item'].uses_file():
for frame in item[u'service_item'].get_frames: for frame in item[u'service_item'].get_frames():
path_from = unicode(os.path.join( path_from = unicode(os.path.join(
item[u'service_item'].service_item_path, item[u'service_item'].service_item_path,
frame.get_frame_title())) frame[u'title']))
zip.write(path_from) zip.write(path_from)
file = open(servicefile, u'wb') file = open(servicefile, u'wb')
cPickle.dump(service, file) cPickle.dump(service, file)
@ -499,7 +504,8 @@ class ServiceManager(QtGui.QWidget):
serviceitem = ServiceItem() serviceitem = ServiceItem()
serviceitem.RenderManager = self.parent.RenderManager serviceitem.RenderManager = self.parent.RenderManager
serviceitem.set_from_service(item, self.servicePath) serviceitem.set_from_service(item, self.servicePath)
self.addServiceItem(serviceitem) if self.validateItem(serviceitem):
self.addServiceItem(serviceitem)
try: try:
if os.path.isfile(p_file): if os.path.isfile(p_file):
os.remove(p_file) os.remove(p_file)
@ -516,6 +522,14 @@ class ServiceManager(QtGui.QWidget):
self.serviceName = name[len(name) - 1] self.serviceName = name[len(name) - 1]
self.parent.serviceChanged(True, self.serviceName) self.parent.serviceChanged(True, self.serviceName)
def validateItem(self, serviceItem):
# print "---"
# print serviceItem.name
# print serviceItem.title
# print serviceItem.service_item_path
# print serviceItem.service_item_type
return True
def cleanUp(self): def cleanUp(self):
""" """
Empties the servicePath of temporary files Empties the servicePath of temporary files
@ -617,7 +631,7 @@ class ServiceManager(QtGui.QWidget):
else: else:
pos = parentitem.data(0, QtCore.Qt.UserRole).toInt()[0] pos = parentitem.data(0, QtCore.Qt.UserRole).toInt()[0]
count = item.data(0, QtCore.Qt.UserRole).toInt()[0] count = item.data(0, QtCore.Qt.UserRole).toInt()[0]
#adjuest for zero based arrays #adjust for zero based arrays
pos = pos - 1 pos = pos - 1
return pos, count return pos, count

View File

@ -62,10 +62,12 @@ class ImpressController(PresentationController):
""" """
log.debug(u'Initialising') log.debug(u'Initialising')
PresentationController.__init__(self, plugin, u'Impress') PresentationController.__init__(self, plugin, u'Impress')
self.supports= [u'.odp', u'.ppt', u'.pps', u'.pptx', u'.ppsx']
self.process = None self.process = None
self.document = None self.document = None
self.presentation = None self.presentation = None
self.controller = None self.controller = None
self.desktop = None
def check_available(self): def check_available(self):
""" """
@ -85,7 +87,7 @@ class ImpressController(PresentationController):
It is not displayed to the user but is available to the UNO interface It is not displayed to the user but is available to the UNO interface
when required. when required.
""" """
log.debug(u'start Openoffice') log.debug(u'start process Openoffice')
if os.name == u'nt': if os.name == u'nt':
self.manager = self.get_com_servicemanager() self.manager = self.get_com_servicemanager()
self.manager._FlagAsMethod(u'Bridge_GetStruct') self.manager._FlagAsMethod(u'Bridge_GetStruct')
@ -101,7 +103,7 @@ class ImpressController(PresentationController):
""" """
Called at system exit to clean up any running presentations Called at system exit to clean up any running presentations
""" """
log.debug(u'Kill') log.debug(u'Kill OpenOffice')
self.close_presentation() self.close_presentation()
if os.name != u'nt': if os.name != u'nt':
desktop = self.get_uno_desktop() desktop = self.get_uno_desktop()
@ -121,8 +123,9 @@ class ImpressController(PresentationController):
``presentation`` ``presentation``
The file name of the presentatios to the run. The file name of the presentatios to the run.
""" """
log.debug(u'LoadPresentation') log.debug(u'Load Presentation OpenOffice')
self.store_filename(presentation) self.store_filename(presentation)
#print "s.dsk1 ", self.desktop
if os.name == u'nt': if os.name == u'nt':
desktop = self.get_com_desktop() desktop = self.get_com_desktop()
if desktop is None: if desktop is None:
@ -135,6 +138,7 @@ class ImpressController(PresentationController):
if desktop is None: if desktop is None:
return return
self.desktop = desktop self.desktop = desktop
#print "s.dsk2 ", self.desktop
properties = [] properties = []
properties.append(self.create_property(u'Minimized', True)) properties.append(self.create_property(u'Minimized', True))
properties = tuple(properties) properties = tuple(properties)
@ -153,9 +157,9 @@ class ImpressController(PresentationController):
""" """
Create thumbnail images for presentation Create thumbnail images for presentation
""" """
log.debug(u'create thumbnails OpenOffice')
if self.check_thumbnails(): if self.check_thumbnails():
return return
if os.name == u'nt': if os.name == u'nt':
thumbdir = u'file:///' + self.thumbnailpath.replace( thumbdir = u'file:///' + self.thumbnailpath.replace(
u'\\', u'/').replace(u':', u'|').replace(u' ', u'%20') u'\\', u'/').replace(u':', u'|').replace(u' ', u'%20')
@ -170,13 +174,14 @@ class ImpressController(PresentationController):
page = pages.getByIndex(idx) page = pages.getByIndex(idx)
doc.getCurrentController().setCurrentPage(page) doc.getCurrentController().setCurrentPage(page)
path = u'%s/%s%s.png'% (thumbdir, self.thumbnailprefix, path = u'%s/%s%s.png'% (thumbdir, self.thumbnailprefix,
unicode(idx+1)) unicode(idx + 1))
try: try:
doc.storeToURL(path , props) doc.storeToURL(path , props)
except: except:
log.exception(u'%s\nUnable to store preview' % path) log.exception(u'%s\nUnable to store preview' % path)
def create_property(self, name, value): def create_property(self, name, value):
log.debug(u'create property OpenOffice')
if os.name == u'nt': if os.name == u'nt':
prop = self.manager.Bridge_GetStruct(u'com.sun.star.beans.PropertyValue') prop = self.manager.Bridge_GetStruct(u'com.sun.star.beans.PropertyValue')
else: else:
@ -186,7 +191,7 @@ class ImpressController(PresentationController):
return prop return prop
def get_uno_desktop(self): def get_uno_desktop(self):
log.debug(u'getUNODesktop') log.debug(u'get UNO Desktop Openoffice')
ctx = None ctx = None
loop = 0 loop = 0
context = uno.getComponentContext() context = uno.getComponentContext()
@ -196,6 +201,7 @@ class ImpressController(PresentationController):
try: try:
ctx = resolver.resolve(u'uno:socket,host=localhost,port=2002;urp;StarOffice.ComponentContext') ctx = resolver.resolve(u'uno:socket,host=localhost,port=2002;urp;StarOffice.ComponentContext')
except: except:
log.exception(u'Unable to fine running instance ')
self.start_process() self.start_process()
loop += 1 loop += 1
try: try:
@ -208,7 +214,7 @@ class ImpressController(PresentationController):
return None return None
def get_com_desktop(self): def get_com_desktop(self):
log.debug(u'getCOMDesktop') log.debug(u'get COM Desktop OpenOffice')
try: try:
desktop = self.manager.createInstance(u'com.sun.star.frame.Desktop') desktop = self.manager.createInstance(u'com.sun.star.frame.Desktop')
return desktop return desktop
@ -217,7 +223,7 @@ class ImpressController(PresentationController):
return None return None
def get_com_servicemanager(self): def get_com_servicemanager(self):
log.debug(u'get_com_servicemanager') log.debug(u'get_com_servicemanager openoffice')
try: try:
return Dispatch(u'com.sun.star.ServiceManager') return Dispatch(u'com.sun.star.ServiceManager')
except: except:
@ -230,6 +236,7 @@ class ImpressController(PresentationController):
Triggerent by new object being added to SlideController orOpenLP Triggerent by new object being added to SlideController orOpenLP
being shut down being shut down
""" """
log.debug(u'close Presentation OpenOffice')
if self.document: if self.document:
if self.presentation: if self.presentation:
try: try:
@ -242,32 +249,44 @@ class ImpressController(PresentationController):
self.document = None self.document = None
def is_loaded(self): def is_loaded(self):
log.debug(u'is loaded OpenOffice')
#print "is_loaded "
if self.presentation is None or self.document is None: if self.presentation is None or self.document is None:
#print "no present or document"
return False return False
try: try:
if self.document.getPresentation() is None: if self.document.getPresentation() is None:
#print "no getPresentation"
return False return False
except: except:
return False return False
return True return True
def is_active(self): def is_active(self):
log.debug(u'is active OpenOffice')
#print "is_active "
if not self.is_loaded(): if not self.is_loaded():
#print "False "
return False return False
#print "self.con ", self.controller
if self.controller is None: if self.controller is None:
return False return False
return True return True
def unblank_screen(self): def unblank_screen(self):
log.debug(u'unblank screen OpenOffice')
return self.controller.resume() return self.controller.resume()
def blank_screen(self): def blank_screen(self):
log.debug(u'blank screen OpenOffice')
self.controller.blankScreen(0) self.controller.blankScreen(0)
def stop_presentation(self): def stop_presentation(self):
log.debug(u'stop presentation OpenOffice')
self.controller.deactivate() self.controller.deactivate()
def start_presentation(self): def start_presentation(self):
log.debug(u'start presentation OpenOffice')
if self.controller is None or not self.controller.isRunning(): if self.controller is None or not self.controller.isRunning():
self.presentation.start() self.presentation.start()
# start() returns before the getCurrentComponent is ready. Try for 5 seconds # start() returns before the getCurrentComponent is ready. Try for 5 seconds

View File

@ -63,7 +63,13 @@ class PresentationMediaItem(MediaManagerItem):
def retranslateUi(self): def retranslateUi(self):
self.OnNewPrompt = self.trUtf8('Select Presentation(s)') self.OnNewPrompt = self.trUtf8('Select Presentation(s)')
self.OnNewFileMasks = self.trUtf8('Presentations (*.ppt *.pps *.odp)') fileType = u''
for controller in self.controllers:
if self.controllers[controller].enabled:
for type in self.controllers[controller].supports:
if fileType.find(type) == -1:
fileType += type + u' '
self.OnNewFileMasks = self.trUtf8('Presentations (%s)' % fileType)
def requiredIcons(self): def requiredIcons(self):
MediaManagerItem.requiredIcons(self) MediaManagerItem.requiredIcons(self)

View File

@ -52,6 +52,7 @@ class PowerpointController(PresentationController):
""" """
log.debug(u'Initialising') log.debug(u'Initialising')
PresentationController.__init__(self, plugin, u'Powerpoint') PresentationController.__init__(self, plugin, u'Powerpoint')
self.supports= [u'.ppt', u'.pps']
self.process = None self.process = None
self.presentation = None self.presentation = None

View File

@ -49,6 +49,7 @@ class PptviewController(PresentationController):
log.debug(u'Initialising') log.debug(u'Initialising')
self.process = None self.process = None
PresentationController.__init__(self, plugin, u'Powerpoint Viewer') PresentationController.__init__(self, plugin, u'Powerpoint Viewer')
self.supports= [u'.ppt', u'.pps']
self.pptid = None self.pptid = None
def check_available(self): def check_available(self):

View File

@ -118,7 +118,7 @@ class PresentationController(object):
""" """
global log global log
log = logging.getLogger(u'PresentationController') log = logging.getLogger(u'PresentationController')
log.info(u'loaded') log.info(u'PresentationController loaded')
def __init__(self, plugin=None, name=u'PresentationController'): def __init__(self, plugin=None, name=u'PresentationController'):
""" """
@ -136,6 +136,7 @@ class PresentationController(object):
``name`` ``name``
Name of the application, to appear in the application Name of the application, to appear in the application
""" """
self.supports = []
self.plugin = plugin self.plugin = plugin
self.name = name self.name = name
self.available = self.check_available() self.available = self.check_available()

View File

@ -26,7 +26,7 @@
import os import os
import logging import logging
from openlp.core.lib import Plugin, build_icon from openlp.core.lib import Plugin, build_icon, Receiver
from openlp.plugins.presentations.lib import * from openlp.plugins.presentations.lib import *
class PresentationPlugin(Plugin): class PresentationPlugin(Plugin):
@ -51,6 +51,12 @@ class PresentationPlugin(Plugin):
log.info(u'Presentations Initialising') log.info(u'Presentations Initialising')
Plugin.initialise(self) Plugin.initialise(self)
self.insert_toolbox_item() self.insert_toolbox_item()
presentation_types = []
for controller in self.controllers:
if self.controllers[controller].enabled:
presentation_types.append({u'%s' % controller : self.controllers[controller].supports})
Receiver.send_message(
u'presentation types', presentation_types)
def finalise(self): def finalise(self):
log.info(u'Plugin Finalise') log.info(u'Plugin Finalise')