This commit is contained in:
Tim Bentley 2009-09-18 11:36:32 +01:00
commit 66ec702dec
5 changed files with 55 additions and 21 deletions

View File

@ -63,7 +63,7 @@ class RenderManager(object):
else: else:
self.current_display = screen_number self.current_display = screen_number
self.renderer = Renderer() self.renderer = Renderer()
#self.calculate_default(self.screen_list[self.current_display][u'size']) self.calculate_default(self.screen_list[self.current_display][u'size'])
self.theme = u'' self.theme = u''
self.service_theme = u'' self.service_theme = u''
self.global_style = u'' self.global_style = u''

View File

@ -254,7 +254,7 @@ class SlideController(QtGui.QWidget):
self.enableToolBar(item) self.enableToolBar(item)
if item.service_item_type == ServiceType.Command: if item.service_item_type == ServiceType.Command:
Receiver().send_message(u'%s_start'%item.name.lower(), \ Receiver().send_message(u'%s_start'%item.name.lower(), \
u'%s:%s:%s' % (item.shortname, item.service_item_path, item.service_frames[0][u'title'])) [item.shortname, item.service_item_path, item.service_frames[0][u'title']])
else: else:
self.displayServiceManagerItems(item, 0) self.displayServiceManagerItems(item, 0)
@ -272,7 +272,7 @@ class SlideController(QtGui.QWidget):
self.enableToolBar(item) self.enableToolBar(item)
if item.service_item_type == ServiceType.Command: if item.service_item_type == ServiceType.Command:
Receiver().send_message(u'%s_start'%item.name.lower(), \ Receiver().send_message(u'%s_start'%item.name.lower(), \
u'%s:%s:%s' % (item.shortname, item.service_item_path, item.service_frames[0][u'title'])) [item.shortname, item.service_item_path, item.service_frames[0][u'title']])
else: else:
self.displayServiceManagerItems(item, slideno) self.displayServiceManagerItems(item, slideno)

View File

@ -29,9 +29,14 @@ Place, Suite 330, Boston, MA 02111-1307 USA
import logging import logging
import os , subprocess import os , subprocess
import time import time
import uno
import sys import sys
if os.name == u'nt':
from win32com.client import Dispatch
else:
import uno
from PyQt4 import QtCore from PyQt4 import QtCore
class ImpressController(object): class ImpressController(object):
@ -57,6 +62,7 @@ class ImpressController(object):
when required. when required.
""" """
log.debug(u'start Openoffice') log.debug(u'start Openoffice')
if os.name != u'nt':
# -headless # -headless
cmd = u'openoffice.org -nologo -norestore -minimized -invisible ' + u'"' + u'-accept=socket,host=localhost,port=2002;urp;'+ u'"' cmd = u'openoffice.org -nologo -norestore -minimized -invisible ' + u'"' + u'-accept=socket,host=localhost,port=2002;urp;'+ u'"'
self.process = QtCore.QProcess() self.process = QtCore.QProcess()
@ -81,6 +87,26 @@ class ImpressController(object):
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'LoadPresentation')
if os.name == u'nt':
desktop = self.getCOMDesktop()
url = u'file:///' + presentation.replace(u'\\', u'/').replace(u':', u'|').replace(u' ', u'%20')
else:
desktop = self.getUNODesktop()
url = uno.systemPathToFileUrl(presentation)
if desktop==None:
return
try:
properties = []
properties = tuple(properties)
self.document = desktop.loadComponentFromURL(url, "_blank", 0, properties)
self.presentation = self.document.getPresentation()
self.presentation.start()
self.xSlideShowController = desktop.getCurrentComponent().Presentation.getController()
except:
log.error(u'Failed reason %s' % sys.exc_info())
def getUNODesktop(self):
log.debug(u'getUNODesktop')
ctx = None ctx = None
loop = 0 loop = 0
context = uno.getComponentContext() context = uno.getComponentContext()
@ -94,15 +120,20 @@ class ImpressController(object):
try: try:
smgr = ctx.ServiceManager smgr = ctx.ServiceManager
desktop = smgr.createInstanceWithContext( "com.sun.star.frame.Desktop", ctx ) desktop = smgr.createInstanceWithContext( "com.sun.star.frame.Desktop", ctx )
url = uno.systemPathToFileUrl(presentation) return desktop
properties = []
properties = tuple(properties)
self.document = desktop.loadComponentFromURL(url, "_blank", 0, properties)
self.presentation = self.document.getPresentation()
self.presentation.start()
self.xSlideShowController = desktop.getCurrentComponent().Presentation.getController()
except: except:
log.error(u'Failed reason %s' % sys.exc_info()) log.error(u'Failed reason %s' % sys.exc_info())
return None
def getCOMDesktop(self):
log.debug(u'getCOMDesktop')
try:
smgr = Dispatch("com.sun.star.ServiceManager")
desktop = smgr.createInstance( "com.sun.star.frame.Desktop")
return desktop
except:
log.error(u'Failed reason %s' % sys.exc_info())
return None
def closePresentation(self): def closePresentation(self):
""" """

View File

@ -83,6 +83,5 @@ class MessageListener(object):
``message`` ``message``
Message containing Presentaion handler name and file to be presented. Message containing Presentaion handler name and file to be presented.
""" """
bits = message.split(u':') file = os.path.join(message[1], message[2])
file = os.path.join(bits[1], bits[2]) return message[0], file
return bits[0], file

View File

@ -79,6 +79,10 @@ class PresentationPlugin(Plugin):
#Lets see if Impress is required (Default is Not wanted) #Lets see if Impress is required (Default is Not wanted)
if int(self.config.get_config(u'Impress', QtCore.Qt.Unchecked)) == QtCore.Qt.Checked: if int(self.config.get_config(u'Impress', QtCore.Qt.Unchecked)) == QtCore.Qt.Checked:
try: try:
if os.name == u'nt':
#Check to see if we are Win32
from win32com.client import Dispatch
else:
#Check to see if we have uno installed #Check to see if we have uno installed
import uno import uno
openoffice = ImpressController() openoffice = ImpressController()