forked from openlp/openlp
Jons Presentation merge with hack to fix conflicts
bzr-revno: 575
This commit is contained in:
commit
bf6a744722
@ -22,12 +22,10 @@
|
|||||||
# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
|
# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
|
||||||
###############################################################################
|
###############################################################################
|
||||||
|
|
||||||
import os
|
from presentationcontroller import PresentationController
|
||||||
|
|
||||||
from impresscontroller import ImpressController
|
from impresscontroller import ImpressController
|
||||||
if os.name == u'nt':
|
from powerpointcontroller import PowerpointController
|
||||||
#from powerpointcontroller import PowerpointController
|
from pptviewcontroller import PptviewController
|
||||||
from pptviewcontroller import PptviewController
|
|
||||||
from messagelistener import MessageListener
|
from messagelistener import MessageListener
|
||||||
from mediaitem import PresentationMediaItem
|
from mediaitem import PresentationMediaItem
|
||||||
from presentationtab import PresentationTab
|
from presentationtab import PresentationTab
|
||||||
|
@ -36,7 +36,10 @@ else:
|
|||||||
|
|
||||||
from PyQt4 import QtCore
|
from PyQt4 import QtCore
|
||||||
|
|
||||||
class ImpressController(object):
|
from presentationcontroller import PresentationController
|
||||||
|
|
||||||
|
|
||||||
|
class ImpressController(PresentationController):
|
||||||
"""
|
"""
|
||||||
Class to control interactions with Impress presentations.
|
Class to control interactions with Impress presentations.
|
||||||
It creates the runtime environment, loads and closes the presentation as
|
It creates the runtime environment, loads and closes the presentation as
|
||||||
@ -45,14 +48,29 @@ class ImpressController(object):
|
|||||||
global log
|
global log
|
||||||
log = logging.getLogger(u'ImpressController')
|
log = logging.getLogger(u'ImpressController')
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self, plugin):
|
||||||
|
"""
|
||||||
|
Initialise the class
|
||||||
|
"""
|
||||||
log.debug(u'Initialising')
|
log.debug(u'Initialising')
|
||||||
|
PresentationController.__init__(self, plugin, u'Impress')
|
||||||
self.process = None
|
self.process = None
|
||||||
self.document = None
|
self.document = None
|
||||||
self.presentation = None
|
self.presentation = None
|
||||||
self.startOpenoffice()
|
self.controller = None
|
||||||
|
|
||||||
def startOpenoffice(self):
|
def is_available(self):
|
||||||
|
"""
|
||||||
|
PPT Viewer is able to run on this machine
|
||||||
|
"""
|
||||||
|
log.debug(u'is_available')
|
||||||
|
try:
|
||||||
|
self.start_process()
|
||||||
|
return True
|
||||||
|
except:
|
||||||
|
return False
|
||||||
|
|
||||||
|
def start_process(self):
|
||||||
"""
|
"""
|
||||||
Loads a running version of OpenOffice in the background.
|
Loads a running version of OpenOffice in the background.
|
||||||
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
|
||||||
@ -71,9 +89,9 @@ class ImpressController(object):
|
|||||||
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')
|
||||||
self.closePresentation()
|
self.close_presentation()
|
||||||
|
|
||||||
def loadPresentation(self, presentation):
|
def load_presentation(self, presentation):
|
||||||
"""
|
"""
|
||||||
Called when a presentation is added to the SlideController.
|
Called when a presentation is added to the SlideController.
|
||||||
It builds the environment, starts communcations with the background
|
It builds the environment, starts communcations with the background
|
||||||
@ -86,10 +104,10 @@ class ImpressController(object):
|
|||||||
"""
|
"""
|
||||||
log.debug(u'LoadPresentation')
|
log.debug(u'LoadPresentation')
|
||||||
if os.name == u'nt':
|
if os.name == u'nt':
|
||||||
desktop = self.getCOMDesktop()
|
desktop = self.get_com_desktop()
|
||||||
url = u'file:///' + presentation.replace(u'\\', u'/').replace(u':', u'|').replace(u' ', u'%20')
|
url = u'file:///' + presentation.replace(u'\\', u'/').replace(u':', u'|').replace(u' ', u'%20')
|
||||||
else:
|
else:
|
||||||
desktop = self.getUNODesktop()
|
desktop = self.get_uno_desktop()
|
||||||
url = uno.systemPathToFileUrl(presentation)
|
url = uno.systemPathToFileUrl(presentation)
|
||||||
if desktop is None:
|
if desktop is None:
|
||||||
return
|
return
|
||||||
@ -100,12 +118,12 @@ class ImpressController(object):
|
|||||||
url, "_blank", 0, properties)
|
url, "_blank", 0, properties)
|
||||||
self.presentation = self.document.getPresentation()
|
self.presentation = self.document.getPresentation()
|
||||||
self.presentation.start()
|
self.presentation.start()
|
||||||
self.xSlideShowController = \
|
self.controller = \
|
||||||
desktop.getCurrentComponent().Presentation.getController()
|
desktop.getCurrentComponent().Presentation.getController()
|
||||||
except:
|
except:
|
||||||
log.exception(u'Failed to load presentation')
|
log.exception(u'Failed to load presentation')
|
||||||
|
|
||||||
def getUNODesktop(self):
|
def get_uno_desktop(self):
|
||||||
log.debug(u'getUNODesktop')
|
log.debug(u'getUNODesktop')
|
||||||
ctx = None
|
ctx = None
|
||||||
loop = 0
|
loop = 0
|
||||||
@ -127,7 +145,7 @@ class ImpressController(object):
|
|||||||
log.exception(u'Failed to get UNO desktop')
|
log.exception(u'Failed to get UNO desktop')
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def getCOMDesktop(self):
|
def get_com_desktop(self):
|
||||||
log.debug(u'getCOMDesktop')
|
log.debug(u'getCOMDesktop')
|
||||||
try:
|
try:
|
||||||
smgr = Dispatch("com.sun.star.ServiceManager")
|
smgr = Dispatch("com.sun.star.ServiceManager")
|
||||||
@ -137,7 +155,7 @@ class ImpressController(object):
|
|||||||
log.exception(u'Failed to get COM desktop')
|
log.exception(u'Failed to get COM desktop')
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def closePresentation(self):
|
def close_presentation(self):
|
||||||
"""
|
"""
|
||||||
Close presentation and clean up objects
|
Close presentation and clean up objects
|
||||||
Triggerent by new object being added to SlideController orOpenLP
|
Triggerent by new object being added to SlideController orOpenLP
|
||||||
@ -150,43 +168,45 @@ class ImpressController(object):
|
|||||||
self.document.dispose()
|
self.document.dispose()
|
||||||
self.document = None
|
self.document = None
|
||||||
|
|
||||||
def isActive(self):
|
def is_loaded(self):
|
||||||
|
return self.presentation is not None and self.document is not None
|
||||||
|
|
||||||
|
def is_active(self):
|
||||||
|
if not self.is_loaded():
|
||||||
|
return False
|
||||||
return self.presentation.isRunning() and self.presentation.isActive()
|
return self.presentation.isRunning() and self.presentation.isActive()
|
||||||
|
|
||||||
def resume(self):
|
def unblank_screen(self):
|
||||||
return self.presentation.resume()
|
return self.presentation.resume()
|
||||||
|
|
||||||
def pause(self):
|
def blank_screen(self):
|
||||||
return self.presentation.pause()
|
|
||||||
|
|
||||||
def blankScreen(self):
|
|
||||||
self.presentation.blankScreen(0)
|
self.presentation.blankScreen(0)
|
||||||
|
|
||||||
def stop(self):
|
def stop_presentation(self):
|
||||||
self.presentation.deactivate()
|
self.presentation.deactivate()
|
||||||
# self.presdoc.end()
|
# self.presdoc.end()
|
||||||
|
|
||||||
def go(self):
|
def start_presentation(self):
|
||||||
self.presentation.activate()
|
self.presentation.activate()
|
||||||
# self.presdoc.start()
|
# self.presdoc.start()
|
||||||
|
|
||||||
def getSlideNumber(self):
|
def get_slide_number(self):
|
||||||
return self.presentation.getCurrentSlideIndex
|
return self.presentation.getCurrentSlideIndex
|
||||||
|
|
||||||
def setSlideNumber(self, slideno):
|
def goto_slide(self, slideno):
|
||||||
self.presentation.gotoSlideIndex(slideno)
|
self.presentation.gotoSlideIndex(slideno)
|
||||||
|
|
||||||
slideNumber = property(getSlideNumber, setSlideNumber)
|
def next_step(self):
|
||||||
|
|
||||||
def nextStep(self):
|
|
||||||
"""
|
"""
|
||||||
Triggers the next effect of slide on the running presentation
|
Triggers the next effect of slide on the running presentation
|
||||||
"""
|
"""
|
||||||
self.xSlideShowController.gotoNextEffect()
|
self.controller.gotoNextEffect()
|
||||||
|
|
||||||
def previousStep(self):
|
def previous_step(self):
|
||||||
"""
|
"""
|
||||||
Triggers the previous slide on the running presentation
|
Triggers the previous slide on the running presentation
|
||||||
"""
|
"""
|
||||||
self.xSlideShowController.gotoPreviousSlide()
|
self.controller.gotoPreviousSlide()
|
||||||
|
|
||||||
|
# def get_slide_preview_file(self, slide_no):
|
||||||
|
|
||||||
|
@ -56,25 +56,25 @@ class MessageListener(object):
|
|||||||
Save the handler as any new presentations start here
|
Save the handler as any new presentations start here
|
||||||
"""
|
"""
|
||||||
self.handler, file = self.decodeMessage(message)
|
self.handler, file = self.decodeMessage(message)
|
||||||
self.controllers[self.handler].loadPresentation(file)
|
self.controllers[self.handler].load_presentation(file)
|
||||||
|
|
||||||
def next(self, message):
|
def next(self, message):
|
||||||
"""
|
"""
|
||||||
Based on the handler passed at startup triggers the next slide event
|
Based on the handler passed at startup triggers the next slide event
|
||||||
"""
|
"""
|
||||||
self.controllers[self.handler].nextStep()
|
self.controllers[self.handler].next_step()
|
||||||
|
|
||||||
def previous(self, message):
|
def previous(self, message):
|
||||||
"""
|
"""
|
||||||
Based on the handler passed at startup triggers the previous slide event
|
Based on the handler passed at startup triggers the previous slide event
|
||||||
"""
|
"""
|
||||||
self.controllers[self.handler].previousStep()
|
self.controllers[self.handler].previous_step()
|
||||||
|
|
||||||
def shutDown(self, message):
|
def shutDown(self, message):
|
||||||
"""
|
"""
|
||||||
Based on the handler passed at startup triggers slide show to shut down
|
Based on the handler passed at startup triggers slide show to shut down
|
||||||
"""
|
"""
|
||||||
self.controllers[self.handler].closePresentation()
|
self.controllers[self.handler].close_presentation()
|
||||||
|
|
||||||
def decodeMessage(self, message):
|
def decodeMessage(self, message):
|
||||||
"""
|
"""
|
||||||
|
@ -21,147 +21,157 @@
|
|||||||
# with this program; if not, write to the Free Software Foundation, Inc., 59 #
|
# with this program; if not, write to the Free Software Foundation, Inc., 59 #
|
||||||
# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
|
# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
|
||||||
###############################################################################
|
###############################################################################
|
||||||
try:
|
|
||||||
|
import os
|
||||||
|
import logging
|
||||||
|
|
||||||
|
if os.name == u'nt':
|
||||||
from win32com.client import Dispatch
|
from win32com.client import Dispatch
|
||||||
except:
|
|
||||||
pass
|
from presentationcontroller import PresentationController
|
||||||
|
|
||||||
# PPT API documentation:
|
# PPT API documentation:
|
||||||
# http://msdn.microsoft.com/en-us/library/aa269321(office.10).aspx
|
# http://msdn.microsoft.com/en-us/library/aa269321(office.10).aspx
|
||||||
|
|
||||||
class PowerPointApp(object):
|
class PowerpointController(PresentationController):
|
||||||
def __init__(self):
|
"""
|
||||||
|
Class to control interactions with PowerPoint Presentations
|
||||||
|
It creates the runtime Environment , Loads the and Closes the Presentation
|
||||||
|
As well as triggering the correct activities based on the users input
|
||||||
|
"""
|
||||||
|
global log
|
||||||
|
log = logging.getLogger(u'PowerpointController')
|
||||||
|
|
||||||
|
def __init__(self, plugin):
|
||||||
|
"""
|
||||||
|
Initialise the class
|
||||||
|
"""
|
||||||
log.debug(u'Initialising')
|
log.debug(u'Initialising')
|
||||||
|
PresentationController.__init__(self, plugin, u'Powerpoint')
|
||||||
self.process = None
|
self.process = None
|
||||||
self.document = None
|
|
||||||
self.presentation = None
|
self.presentation = None
|
||||||
self.startPowerpoint()
|
|
||||||
|
|
||||||
def startPowerpoint(self):
|
def is_available(self):
|
||||||
|
"""
|
||||||
|
PowerPoint is able to run on this machine
|
||||||
|
"""
|
||||||
|
log.debug(u'is_available')
|
||||||
|
if os.name != u'nt':
|
||||||
|
return False
|
||||||
try:
|
try:
|
||||||
self._app = Dispatch(u'PowerPoint.Application')
|
self.start_process()
|
||||||
|
return True
|
||||||
except:
|
except:
|
||||||
self._app = None
|
|
||||||
return
|
|
||||||
self._app.Visible = True
|
|
||||||
self._app.WindowState = 2
|
|
||||||
|
|
||||||
def getApp(self):
|
|
||||||
if self._app is None:
|
|
||||||
self.createApp()
|
|
||||||
if self._app is None:
|
|
||||||
return None
|
|
||||||
if self._app.Windows.Count == 0:
|
|
||||||
self.createApp()
|
|
||||||
return self._app
|
|
||||||
|
|
||||||
app = property(getApp)
|
|
||||||
|
|
||||||
def quit(self):
|
|
||||||
self._app.Quit()
|
|
||||||
self._app = None
|
|
||||||
|
|
||||||
class PowerPointPres(object):
|
|
||||||
|
|
||||||
def __init__(self, pptApp, filename):
|
|
||||||
self.pptApp = pptApp
|
|
||||||
self.filename = filename
|
|
||||||
self.open()
|
|
||||||
|
|
||||||
def getPres(self):
|
|
||||||
if self._pres is None:
|
|
||||||
for p in self.pptApp.app.Presentations:
|
|
||||||
if p.FullName == self.filename:
|
|
||||||
self._pres = p
|
|
||||||
break
|
|
||||||
if self._pres is not None:
|
|
||||||
try:
|
|
||||||
x = self._pres.Name
|
|
||||||
except:
|
|
||||||
self._pres = None
|
|
||||||
if self._pres is None:
|
|
||||||
self.openPres()
|
|
||||||
return self._pres
|
|
||||||
|
|
||||||
pres = property(getPres)
|
|
||||||
|
|
||||||
def open(self):
|
|
||||||
self.pptApp.app.Presentations.Open(self.filename, False, False, True)
|
|
||||||
self._pres = self.pptApp.app.Presentations(ppt.app.Presentations.Count)
|
|
||||||
|
|
||||||
def close(self):
|
|
||||||
self.pres.Close()
|
|
||||||
self._pres = None
|
|
||||||
|
|
||||||
def isActive(self):
|
|
||||||
if self.pres.SlideShowWindow is None:
|
|
||||||
return False
|
return False
|
||||||
if self.pres.SlideShowWindow.View is None:
|
|
||||||
return False
|
|
||||||
return True
|
|
||||||
|
|
||||||
def resume(self):
|
if os.name == u'nt':
|
||||||
self.pres.SlideShowSettings.Run()
|
def start_process(self):
|
||||||
self.pres.SlideShowWindow.View.State = 1
|
"""
|
||||||
self.pres.SlideShowWindow.Activate()
|
Loads PowerPoint process
|
||||||
|
"""
|
||||||
|
self.process = Dispatch(u'PowerPoint.Application')
|
||||||
|
self.process.Visible = True
|
||||||
|
self.process.WindowState = 2
|
||||||
|
|
||||||
def pause(self):
|
def is_loaded(self):
|
||||||
if self.isActive():
|
"""
|
||||||
self.pres.SlideShowWindow.View.State = 2
|
Returns true if a presentation is loaded
|
||||||
|
"""
|
||||||
|
if self.process is None:
|
||||||
|
return False
|
||||||
|
if self.process.Windows.Count == 0:
|
||||||
|
return False
|
||||||
|
|
||||||
def blankScreen(self):
|
def kill(self):
|
||||||
if self.isActive():
|
self.process.Quit()
|
||||||
self.pres.SlideShowWindow.View.State = 3
|
self.process = None
|
||||||
|
|
||||||
def stop(self):
|
def load_presentation(self, presentation):
|
||||||
if self.isActive():
|
"""
|
||||||
self.pres.SlideShowWindow.View.Exit()
|
Called when a presentation is added to the SlideController.
|
||||||
|
It builds the environment, starts communcations with the background
|
||||||
|
OpenOffice task started earlier. If OpenOffice is not present is is
|
||||||
|
started. Once the environment is available the presentation is loaded
|
||||||
|
and started.
|
||||||
|
|
||||||
def go(self):
|
``presentation``
|
||||||
self.pres.SlideShowSettings.Run()
|
The file name of the presentations to run.
|
||||||
|
"""
|
||||||
|
self.filename = presentation
|
||||||
|
self.process.Presentations.Open(presentation, False, False, True)
|
||||||
|
self.presentation = self.process.Presentations(self.process.Presentations.Count)
|
||||||
|
self.start_presentation()
|
||||||
|
|
||||||
def getCurrentSlideIndex(self):
|
def close_presentation(self):
|
||||||
if self.isActive():
|
"""
|
||||||
return self.pres.SlideShowWindow.View.CurrentShowPosition
|
Close presentation and clean up objects
|
||||||
else:
|
Triggerent by new object being added to SlideController orOpenLP
|
||||||
return -1
|
being shut down
|
||||||
|
"""
|
||||||
|
self.presentation.Close()
|
||||||
|
self.presentation = None
|
||||||
|
|
||||||
def setCurrentSlideIndex(self, slideno):
|
def is_active(self):
|
||||||
if not self.isActive():
|
"""
|
||||||
self.resume()
|
Returns true if a presentation is currently active
|
||||||
self.pres.SlideShowWindow.View.GotoSlide(slideno)
|
"""
|
||||||
|
if not self.is_loaded():
|
||||||
|
return False
|
||||||
|
if self.presentation.SlideShowWindow == None:
|
||||||
|
return False
|
||||||
|
if self.presentation.SlideShowWindow.View == None:
|
||||||
|
return False
|
||||||
|
return True
|
||||||
|
|
||||||
#currentSlideIndex = property(getSlideNumber, setSlideNumber)
|
def unblank_screen(self):
|
||||||
|
"""
|
||||||
|
Unblanks (restores) the presentationn
|
||||||
|
"""
|
||||||
|
self.presentation.SlideShowSettings.Run()
|
||||||
|
self.presentation.SlideShowWindow.View.State = 1
|
||||||
|
self.presentation.SlideShowWindow.Activate()
|
||||||
|
|
||||||
def nextStep(self):
|
def blank_screen(self):
|
||||||
if not self.isActive():
|
"""
|
||||||
self.resume()
|
Blanks the screen
|
||||||
self.pres.SlideShowWindow.View.Next()
|
"""
|
||||||
|
self.presentation.SlideShowWindow.View.State = 3
|
||||||
|
|
||||||
def prevStep(self):
|
def stop_presentation(self):
|
||||||
if not self.isActive():
|
"""
|
||||||
self.resume()
|
Stops the current presentation and hides the output
|
||||||
self.pres.SlideShowWindow.View.Previous()
|
"""
|
||||||
|
self.presentation.SlideShowWindow.View.Exit()
|
||||||
|
|
||||||
def moveWindow(self, top, height, left, width):
|
def start_presentation(self):
|
||||||
if not self.isActive():
|
"""
|
||||||
self.resume()
|
Starts a presentation from the beginning
|
||||||
self.pres.SlideShowWindow.Top = top / 20
|
"""
|
||||||
self.pres.SlideShowWindow.Height = height / 20
|
self.presentation.SlideShowSettings.Run()
|
||||||
self.pres.SlideShowWindow.Left = left / 20
|
rendermanager = self.plugin.render_manager
|
||||||
self.pres.SlideShowWindow.Width = width / 20
|
rect = rendermanager.screen_list[rendermanager.current_display][u'size']
|
||||||
|
self.presentation.SlideShowWindow.Top = rect.y() / 20
|
||||||
|
self.presentation.SlideShowWindow.Height = rect.height() / 20
|
||||||
|
self.presentation.SlideShowWindow.Left = rect.x() / 20
|
||||||
|
self.presentation.SlideShowWindow.Width = rect.width() / 20
|
||||||
|
|
||||||
class PowerPointSlide(object):
|
def get_slide_number(self):
|
||||||
def __init__(self, pres, index):
|
"""
|
||||||
self.pres = pres
|
Returns the current slide number
|
||||||
self.slide = pres.Slides[index]
|
"""
|
||||||
|
return self.presentation.SlideShowWindow.View.CurrentShowPosition
|
||||||
|
|
||||||
def preview(self):
|
def get_slide_count(self):
|
||||||
if self.preview is None:
|
"""
|
||||||
self.slide.Copy
|
Returns total number of slides
|
||||||
# import win32clipboard as w
|
"""
|
||||||
# import win32con
|
return self.presentation.Slides.Count
|
||||||
# w.OpenClipboard()
|
|
||||||
# self.preview = w.GetClipboardData.GetData(win32con.CF_BITMAP)
|
def goto_slide(self, slideno):
|
||||||
# w.CloseClipboard()
|
self.presentation.SlideShowWindow.View.GotoSlide(slideno)
|
||||||
return self.preview
|
|
||||||
|
def next_step(self):
|
||||||
|
self.presentation.SlideShowWindow.View.Next()
|
||||||
|
|
||||||
|
def previous_step(self):
|
||||||
|
self.presentation.SlideShowWindow.View.Previous()
|
||||||
|
@ -22,160 +22,170 @@
|
|||||||
# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
|
# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
|
||||||
###############################################################################
|
###############################################################################
|
||||||
|
|
||||||
|
import os
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
from ctypes import *
|
if os.name == u'nt':
|
||||||
from ctypes.wintypes import RECT
|
from ctypes import *
|
||||||
|
from ctypes.wintypes import RECT
|
||||||
|
|
||||||
class PptviewController(object):
|
from presentationcontroller import PresentationController
|
||||||
|
|
||||||
|
class PptviewController(PresentationController):
|
||||||
"""
|
"""
|
||||||
Class to control interactions with PowerPOint Viewer Presentations
|
Class to control interactions with PowerPOint Viewer Presentations
|
||||||
It creates the runtime Environment , Loads the and Closes the Presentation
|
It creates the runtime Environment , Loads the and Closes the Presentation
|
||||||
As well as trigggering the correct activities based on the users input
|
As well as triggering the correct activities based on the users input
|
||||||
"""
|
"""
|
||||||
global log
|
global log
|
||||||
log = logging.getLogger(u'PptviewController')
|
log = logging.getLogger(u'PptviewController')
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self, plugin):
|
||||||
|
"""
|
||||||
|
Initialise the class
|
||||||
|
"""
|
||||||
log.debug(u'Initialising')
|
log.debug(u'Initialising')
|
||||||
|
PresentationController.__init__(self, plugin, u'Powerpoint Viewer')
|
||||||
self.process = None
|
self.process = None
|
||||||
self.document = None
|
|
||||||
self.presentation = None
|
|
||||||
self.pptid = None
|
self.pptid = None
|
||||||
self.startPPTView()
|
self.thumbnailpath = os.path.join(plugin.config.get_data_path(),
|
||||||
|
u'pptview', u'thumbnails')
|
||||||
|
self.thumbprefix = u'slide'
|
||||||
|
|
||||||
def startPPTView(self):
|
def is_available(self):
|
||||||
"""
|
"""
|
||||||
Loads the PPTVIEWLIB library
|
PPT Viewer is able to run on this machine
|
||||||
"""
|
"""
|
||||||
log.debug(u'start PPTView')
|
log.debug(u'is_available')
|
||||||
self.presentation = cdll.LoadLibrary(r'openlp\plugins\presentations\lib\pptviewlib\pptviewlib.dll')
|
if os.name != u'nt':
|
||||||
|
return False
|
||||||
def kill(self):
|
|
||||||
"""
|
|
||||||
Called at system exit to clean up any running presentations
|
|
||||||
"""
|
|
||||||
log.debug(u'Kill')
|
|
||||||
self.closePresentation()
|
|
||||||
|
|
||||||
def loadPresentation(self, presentation):
|
|
||||||
"""
|
|
||||||
Called when a presentation is added to the SlideController.
|
|
||||||
It builds the environment, starts communcations with the background
|
|
||||||
OpenOffice task started earlier. If OpenOffice is not present is is
|
|
||||||
started. Once the environment is available the presentation is loaded
|
|
||||||
and started.
|
|
||||||
|
|
||||||
``presentation``
|
|
||||||
The file name of the presentations to run.
|
|
||||||
"""
|
|
||||||
log.debug(u'LoadPresentation')
|
|
||||||
if self.pptid >= 0:
|
|
||||||
self.closePresentation()
|
|
||||||
rect = RECT(0, 0, 800, 600) # until such time I can get screen info
|
|
||||||
filename = str(presentation.replace(u'/', u'\\'));
|
|
||||||
try:
|
try:
|
||||||
tempfolder = None #r'c:\temp\pptviewlib\' + filename.split('u\\')[-1]
|
self.start_process()
|
||||||
self.pptid = self.presentation.OpenPPT(filename, None, rect, tempfolder)
|
return True
|
||||||
except:
|
except:
|
||||||
log.exception(u'Failed to load presentation')
|
return False
|
||||||
#self.slidecount = pptdll.GetSlideCount(self.pptid)
|
|
||||||
|
|
||||||
def closePresentation(self):
|
if os.name == u'nt':
|
||||||
"""
|
def start_process(self):
|
||||||
Close presentation and clean up objects
|
"""
|
||||||
Triggerent by new object being added to SlideController orOpenLP
|
Loads the PPTVIEWLIB library
|
||||||
being shut down
|
"""
|
||||||
"""
|
log.debug(u'start PPTView')
|
||||||
if self.pptid < 0:
|
self.process = cdll.LoadLibrary(r'openlp\plugins\presentations\lib\pptviewlib\pptviewlib.dll')
|
||||||
return
|
|
||||||
self.presentation.ClosePPT(self.pptid)
|
|
||||||
self.pptid = -1
|
|
||||||
|
|
||||||
def nextStep(self):
|
def kill(self):
|
||||||
"""
|
"""
|
||||||
Triggers the next effect of slide on the running presentation
|
Called at system exit to clean up any running presentations
|
||||||
"""
|
"""
|
||||||
if self.pptid < 0:
|
log.debug(u'Kill')
|
||||||
return
|
self.close_presentation()
|
||||||
self.presentation.NextStep(self.pptid)
|
|
||||||
|
|
||||||
def previousStep(self):
|
def load_presentation(self, presentation):
|
||||||
"""
|
"""
|
||||||
Triggers the previous slide on the running presentation
|
Called when a presentation is added to the SlideController.
|
||||||
"""
|
It builds the environment, starts communcations with the background
|
||||||
if self.pptid < 0:
|
OpenOffice task started earlier. If OpenOffice is not present is is
|
||||||
return
|
started. Once the environment is available the presentation is loaded
|
||||||
self.presentation.PrevStep(self.pptid)
|
and started.
|
||||||
|
|
||||||
def isActive(self):
|
``presentation``
|
||||||
"""
|
The file name of the presentations to run.
|
||||||
Returns true if a presentation is currently active
|
"""
|
||||||
"""
|
log.debug(u'LoadPresentation')
|
||||||
return self.pptid >= 0
|
if self.pptid >= 0:
|
||||||
|
self.close_presentation()
|
||||||
|
rendermanager = self.plugin.render_manager
|
||||||
|
rect = rendermanager.screen_list[rendermanager.current_display][u'size']
|
||||||
|
rect = RECT(rect.x(), rect.y(), rect.right(), rect.bottom())
|
||||||
|
filename = str(presentation.replace(u'/', u'\\'));
|
||||||
|
try:
|
||||||
|
self.pptid = self.process.OpenPPT(filename, None, rect,
|
||||||
|
str(self.thumbnailpath))
|
||||||
|
except:
|
||||||
|
log.exception(u'Failed to load presentation')
|
||||||
|
|
||||||
def resume(self):
|
def close_presentation(self):
|
||||||
"""
|
"""
|
||||||
Resumes a previously paused presentation
|
Close presentation and clean up objects
|
||||||
"""
|
Triggerent by new object being added to SlideController orOpenLP
|
||||||
if self.pptid < 0:
|
being shut down
|
||||||
return
|
"""
|
||||||
self.presentation.Resume(self.pptid)
|
self.process.ClosePPT(self.pptid)
|
||||||
|
self.pptid = -1
|
||||||
|
|
||||||
def pause(self):
|
def is_loaded(self):
|
||||||
"""
|
"""
|
||||||
Not implemented (pauses a presentation)
|
Returns true if a presentation is loaded
|
||||||
"""
|
"""
|
||||||
return
|
return self.pptid >= 0
|
||||||
|
|
||||||
def blankScreen(self):
|
def is_active(self):
|
||||||
"""
|
"""
|
||||||
Blanks the screen
|
Returns true if a presentation is currently active
|
||||||
"""
|
"""
|
||||||
if self.pptid < 0:
|
return self.pptid >= 0
|
||||||
return
|
|
||||||
self.presentation.Blank(self.pptid)
|
|
||||||
|
|
||||||
def unblankScreen(self):
|
def blank_screen(self):
|
||||||
"""
|
"""
|
||||||
Unblanks (restores) the presentationn
|
Blanks the screen
|
||||||
"""
|
"""
|
||||||
if self.pptid < 0:
|
self.process.Blank(self.pptid)
|
||||||
return
|
|
||||||
self.presentation.Unblank(self.pptid)
|
|
||||||
|
|
||||||
def stop(self):
|
def unblank_screen(self):
|
||||||
"""
|
"""
|
||||||
Stops the current presentation and hides the output
|
Unblanks (restores) the presentationn
|
||||||
"""
|
"""
|
||||||
if self.pptid < 0:
|
self.process.Unblank(self.pptid)
|
||||||
return
|
|
||||||
self.presentation.Stop(self.pptid)
|
|
||||||
|
|
||||||
def go(self):
|
def stop_presentation(self):
|
||||||
"""
|
"""
|
||||||
Starts a presentation from the beginning
|
Stops the current presentation and hides the output
|
||||||
"""
|
"""
|
||||||
if self.pptid < 0:
|
self.process.Stop(self.pptid)
|
||||||
return
|
|
||||||
self.presentation.RestartShow(self.pptid)
|
|
||||||
|
|
||||||
def getSlideNumber(self):
|
def start_presentation(self):
|
||||||
"""
|
"""
|
||||||
Returns the current slide number
|
Starts a presentation from the beginning
|
||||||
"""
|
"""
|
||||||
if self.pptid < 0:
|
self.process.RestartShow(self.pptid)
|
||||||
return -1
|
|
||||||
return self.presentation.GetCurrentSlide(self.pptid)
|
|
||||||
|
|
||||||
def setSlideNumber(self, slideno):
|
def get_slide_number(self):
|
||||||
"""
|
"""
|
||||||
Moves to a specific slide in the presentation
|
Returns the current slide number
|
||||||
"""
|
"""
|
||||||
if self.pptid < 0:
|
return self.process.GetCurrentSlide(self.pptid)
|
||||||
return
|
|
||||||
self.presentation.GotoSlide(self.pptid, slideno)
|
|
||||||
|
|
||||||
slideNumber = property(getSlideNumber, setSlideNumber)
|
def get_slide_count(self):
|
||||||
|
"""
|
||||||
|
Returns total number of slides
|
||||||
|
"""
|
||||||
|
return self.process.GetSlideCount(self.pptid)
|
||||||
|
|
||||||
|
def goto_slide(self, slideno):
|
||||||
|
"""
|
||||||
|
Moves to a specific slide in the presentation
|
||||||
|
"""
|
||||||
|
self.process.GotoSlide(self.pptid, slideno)
|
||||||
|
|
||||||
|
def next_step(self):
|
||||||
|
"""
|
||||||
|
Triggers the next effect of slide on the running presentation
|
||||||
|
"""
|
||||||
|
self.process.NextStep(self.pptid)
|
||||||
|
|
||||||
|
def previous_step(self):
|
||||||
|
"""
|
||||||
|
Triggers the previous slide on the running presentation
|
||||||
|
"""
|
||||||
|
self.process.PrevStep(self.pptid)
|
||||||
|
|
||||||
|
def get_slide_preview_file(self, slide_no):
|
||||||
|
"""
|
||||||
|
Returns an image path containing a preview for the requested slide
|
||||||
|
|
||||||
|
``slide_no``
|
||||||
|
The slide an image is required for, starting at 1
|
||||||
|
"""
|
||||||
|
return os.path.join(self.thumbnailpath,
|
||||||
|
self.thumbprefix + slide_no + u'.bmp')
|
||||||
|
|
||||||
|
227
openlp/plugins/presentations/lib/presentationcontroller.py
Normal file
227
openlp/plugins/presentations/lib/presentationcontroller.py
Normal file
@ -0,0 +1,227 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
|
||||||
|
"""
|
||||||
|
OpenLP - Open Source Lyrics Projection
|
||||||
|
Copyright (c) 2008 Raoul Snyman
|
||||||
|
Portions copyright (c) 2008-2009 Martin Thompson, Tim Bentley
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or modify it under
|
||||||
|
the terms of the GNU General Public License as published by the Free Software
|
||||||
|
Foundation; version 2 of the License.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||||
|
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
||||||
|
PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License along with
|
||||||
|
this program; if not, write to the Free Software Foundation, Inc., 59 Temple
|
||||||
|
Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
"""
|
||||||
|
|
||||||
|
import logging
|
||||||
|
|
||||||
|
class PresentationController(object):
|
||||||
|
"""
|
||||||
|
Base class for presentation controllers to inherit from
|
||||||
|
Class to control interactions with presentations.
|
||||||
|
It creates the runtime environment, loads and closes the presentation as
|
||||||
|
well as triggering the correct activities based on the users input
|
||||||
|
|
||||||
|
**Basic Attributes**
|
||||||
|
|
||||||
|
``name``
|
||||||
|
The name that appears in the options and the media manager
|
||||||
|
|
||||||
|
``plugin``
|
||||||
|
The presentationplugin object
|
||||||
|
|
||||||
|
**Hook Functions**
|
||||||
|
|
||||||
|
``kill()``
|
||||||
|
Called at system exit to clean up any running presentations
|
||||||
|
|
||||||
|
``is_available()``
|
||||||
|
Returns True if presentation application is installed/can run on this machine
|
||||||
|
|
||||||
|
``load_presentation(presentation)``
|
||||||
|
Load a presentation file
|
||||||
|
|
||||||
|
``close_presentation()``
|
||||||
|
Close presentation and clean up objects
|
||||||
|
|
||||||
|
``presentation_loaded()``
|
||||||
|
Returns True if presentation is currently loaded
|
||||||
|
|
||||||
|
``is_active()``
|
||||||
|
Returns True if a presentation is currently running
|
||||||
|
|
||||||
|
``blank_screen()``
|
||||||
|
Blanks the screen, making it black.
|
||||||
|
|
||||||
|
``unblank_screen()``
|
||||||
|
Unblanks the screen, restoring the output
|
||||||
|
|
||||||
|
``stop_presentation()``
|
||||||
|
Stops the presentation, removing it from the output display
|
||||||
|
|
||||||
|
``start_presentation()``
|
||||||
|
Starts the presentation from the beginning
|
||||||
|
|
||||||
|
``get_slide_number()``
|
||||||
|
Returns the current slide number, from 1
|
||||||
|
|
||||||
|
``get_slide_count()``
|
||||||
|
Returns total number of slides
|
||||||
|
|
||||||
|
``goto_slide(slide_no)``
|
||||||
|
Jumps directly to the requested slide.
|
||||||
|
|
||||||
|
``next_step()``
|
||||||
|
Triggers the next effect of slide on the running presentation
|
||||||
|
|
||||||
|
``previous_step()``
|
||||||
|
Triggers the previous slide on the running presentation
|
||||||
|
|
||||||
|
``get_slide_preview_file(slide_no)``
|
||||||
|
Returns a path to an image containing a preview for the requested slide
|
||||||
|
|
||||||
|
"""
|
||||||
|
global log
|
||||||
|
log = logging.getLogger(u'PresentationController')
|
||||||
|
log.info(u'loaded')
|
||||||
|
|
||||||
|
def __init__(self, plugin=None, name=u'PresentationController'):
|
||||||
|
"""
|
||||||
|
This is the constructor for the presentationcontroller object.
|
||||||
|
This provides an easy way for descendent plugins to populate common data.
|
||||||
|
This method *must* be overridden, like so::
|
||||||
|
|
||||||
|
class MyPresentationController(PresentationController):
|
||||||
|
def __init__(self, plugin):
|
||||||
|
PresentationController.__init(self, plugin, u'My Presenter App')
|
||||||
|
|
||||||
|
``plugin``
|
||||||
|
Defaults to *None*. The presentationplugin object
|
||||||
|
|
||||||
|
``name``
|
||||||
|
Name of the application, to appear in the application
|
||||||
|
"""
|
||||||
|
self.plugin = plugin
|
||||||
|
self.name = name
|
||||||
|
self.start_process()
|
||||||
|
|
||||||
|
def is_available(self):
|
||||||
|
"""
|
||||||
|
Presentation app is able to run on this machine
|
||||||
|
"""
|
||||||
|
return False
|
||||||
|
|
||||||
|
def start_process(self):
|
||||||
|
"""
|
||||||
|
Loads a running version of the presentation application in the background.
|
||||||
|
"""
|
||||||
|
pass
|
||||||
|
|
||||||
|
def kill(self):
|
||||||
|
"""
|
||||||
|
Called at system exit to clean up any running presentations and
|
||||||
|
close the application
|
||||||
|
"""
|
||||||
|
log.debug(u'Kill')
|
||||||
|
self.close_presentation()
|
||||||
|
|
||||||
|
def load_presentation(self, presentation):
|
||||||
|
"""
|
||||||
|
Called when a presentation is added to the SlideController.
|
||||||
|
Loads the presentation and starts it
|
||||||
|
|
||||||
|
``presentation``
|
||||||
|
The file name of the presentatios to the run.
|
||||||
|
"""
|
||||||
|
pass
|
||||||
|
|
||||||
|
def close_presentation(self):
|
||||||
|
"""
|
||||||
|
Close presentation and clean up objects
|
||||||
|
Triggered by new object being added to SlideController
|
||||||
|
"""
|
||||||
|
pass
|
||||||
|
|
||||||
|
def is_active(self):
|
||||||
|
"""
|
||||||
|
Returns True if a presentation is currently running
|
||||||
|
"""
|
||||||
|
return False
|
||||||
|
|
||||||
|
def is_loaded(self):
|
||||||
|
"""
|
||||||
|
Returns true if a presentation is loaded
|
||||||
|
"""
|
||||||
|
return False
|
||||||
|
|
||||||
|
def blank_screen(self):
|
||||||
|
"""
|
||||||
|
Blanks the screen, making it black.
|
||||||
|
"""
|
||||||
|
pass
|
||||||
|
|
||||||
|
def unblank_screen(self):
|
||||||
|
"""
|
||||||
|
Unblanks (restores) the presentationn
|
||||||
|
"""
|
||||||
|
pass
|
||||||
|
|
||||||
|
def stop_presentation(self):
|
||||||
|
"""
|
||||||
|
Stops the presentation, removing it from the output display
|
||||||
|
"""
|
||||||
|
pass
|
||||||
|
|
||||||
|
def start_presentation(self):
|
||||||
|
"""
|
||||||
|
Starts the presentation from the beginning
|
||||||
|
"""
|
||||||
|
pass
|
||||||
|
|
||||||
|
def get_slide_number(self):
|
||||||
|
"""
|
||||||
|
Returns the current slide number, from 1
|
||||||
|
"""
|
||||||
|
return 0
|
||||||
|
|
||||||
|
def get_slide_count(self):
|
||||||
|
"""
|
||||||
|
Returns total number of slides
|
||||||
|
"""
|
||||||
|
return 0
|
||||||
|
|
||||||
|
def goto_slide(self, slide_no):
|
||||||
|
"""
|
||||||
|
Jumps directly to the requested slide.
|
||||||
|
|
||||||
|
``slide_no``
|
||||||
|
The slide to jump to, starting at 1
|
||||||
|
"""
|
||||||
|
pass
|
||||||
|
|
||||||
|
def next_step(self):
|
||||||
|
"""
|
||||||
|
Triggers the next effect of slide on the running presentation
|
||||||
|
This might be the next animation on the current slide, or the next slide
|
||||||
|
"""
|
||||||
|
pass
|
||||||
|
|
||||||
|
def previous_step(self):
|
||||||
|
"""
|
||||||
|
Triggers the previous slide on the running presentation
|
||||||
|
"""
|
||||||
|
pass
|
||||||
|
|
||||||
|
def get_slide_preview_file(self, slide_no):
|
||||||
|
"""
|
||||||
|
Returns an image path containing a preview for the requested slide
|
||||||
|
|
||||||
|
``slide_no``
|
||||||
|
The slide an image is required for, starting at 1
|
||||||
|
"""
|
||||||
|
return None
|
@ -31,7 +31,8 @@ class PresentationTab(SettingsTab):
|
|||||||
"""
|
"""
|
||||||
PresentationsTab is the Presentations settings tab in the settings dialog.
|
PresentationsTab is the Presentations settings tab in the settings dialog.
|
||||||
"""
|
"""
|
||||||
def __init__(self):
|
def __init__(self, controllers):
|
||||||
|
self.controllers = controllers
|
||||||
SettingsTab.__init__(self,
|
SettingsTab.__init__(self,
|
||||||
translate(u'PresentationTab', u'Presentation'), u'Presentations')
|
translate(u'PresentationTab', u'Presentation'), u'Presentations')
|
||||||
|
|
||||||
|
@ -28,14 +28,7 @@ import logging
|
|||||||
from PyQt4 import QtCore, QtGui
|
from PyQt4 import QtCore, QtGui
|
||||||
|
|
||||||
from openlp.core.lib import Plugin
|
from openlp.core.lib import Plugin
|
||||||
from openlp.plugins.presentations.lib import PresentationMediaItem, \
|
from openlp.plugins.presentations.lib import *
|
||||||
PresentationTab, ImpressController
|
|
||||||
if os.name == u'nt':
|
|
||||||
try:
|
|
||||||
from openlp.plugins.presentations.lib import PowerpointController
|
|
||||||
except:
|
|
||||||
pass
|
|
||||||
from openlp.plugins.presentations.lib import PptviewController
|
|
||||||
|
|
||||||
class PresentationPlugin(Plugin):
|
class PresentationPlugin(Plugin):
|
||||||
|
|
||||||
@ -57,7 +50,7 @@ class PresentationPlugin(Plugin):
|
|||||||
"""
|
"""
|
||||||
Create the settings Tab
|
Create the settings Tab
|
||||||
"""
|
"""
|
||||||
self.presentation_tab = PresentationTab()
|
self.presentation_tab = PresentationTab(self.controllers)
|
||||||
return self.presentation_tab
|
return self.presentation_tab
|
||||||
|
|
||||||
def get_media_manager_item(self):
|
def get_media_manager_item(self):
|
||||||
@ -68,8 +61,8 @@ class PresentationPlugin(Plugin):
|
|||||||
self, self.icon, u'Presentations', self.controllers)
|
self, self.icon, u'Presentations', self.controllers)
|
||||||
return self.media_item
|
return self.media_item
|
||||||
|
|
||||||
def registerControllers(self, handle, controller):
|
def registerControllers(self, controller):
|
||||||
self.controllers[handle] = controller
|
self.controllers[controller.name] = controller
|
||||||
|
|
||||||
def check_pre_conditions(self):
|
def check_pre_conditions(self):
|
||||||
"""
|
"""
|
||||||
@ -77,39 +70,24 @@ class PresentationPlugin(Plugin):
|
|||||||
If Not do not install the plugin.
|
If Not do not install the plugin.
|
||||||
"""
|
"""
|
||||||
log.debug('check_pre_conditions')
|
log.debug('check_pre_conditions')
|
||||||
#Lets see if Impress is required (Default is Not wanted)
|
#Lets see if Powerpoint is required (Default is Not wanted)
|
||||||
|
controller = PowerpointController(self)
|
||||||
if int(self.config.get_config(
|
if int(self.config.get_config(
|
||||||
u'Impress', QtCore.Qt.Unchecked)) == QtCore.Qt.Checked:
|
controller.name, QtCore.Qt.Unchecked)) == QtCore.Qt.Checked:
|
||||||
try:
|
if controller.is_available():
|
||||||
if os.name == u'nt':
|
self.registerControllers(controller)
|
||||||
#Check to see if we are Win32
|
#Lets see if Impress is required (Default is Not wanted)
|
||||||
from win32com.client import Dispatch
|
controller = ImpressController(self)
|
||||||
else:
|
if int(self.config.get_config(
|
||||||
#Check to see if we have uno installed
|
controller.name, QtCore.Qt.Unchecked)) == QtCore.Qt.Checked:
|
||||||
import uno
|
if controller.is_available():
|
||||||
openoffice = ImpressController()
|
self.registerControllers(controller)
|
||||||
self.registerControllers(u'Impress', openoffice)
|
#Lets see if Powerpoint Viewer is required (Default is Not wanted)
|
||||||
except:
|
controller = PptviewController(self)
|
||||||
log.exception(u'Failed to set up plugin for Impress')
|
if int(self.config.get_config(
|
||||||
if os.name == u'nt':
|
controller.name, QtCore.Qt.Unchecked)) == QtCore.Qt.Checked:
|
||||||
#Lets see if Powerpoint is required (Default is Not wanted)
|
if controller.is_available():
|
||||||
if int(self.config.get_config(
|
self.registerControllers(controller)
|
||||||
u'Powerpoint', QtCore.Qt.Unchecked)) == QtCore.Qt.Checked:
|
|
||||||
try:
|
|
||||||
#Check to see if we are Win32
|
|
||||||
from win32com.client import Dispatch
|
|
||||||
powerpoint = PowerpointController()
|
|
||||||
self.registerControllers(u'Powerpoint', powerpoint)
|
|
||||||
except:
|
|
||||||
log.exception(u'Failed to set up plugin for Powerpoint')
|
|
||||||
#Lets see if Powerpoint Viewer is required (Default is Not wanted)
|
|
||||||
if int(self.config.get_config(
|
|
||||||
u'Powerpoint Viewer', QtCore.Qt.Unchecked)) == QtCore.Qt.Checked:
|
|
||||||
try:
|
|
||||||
pptview = PptviewController()
|
|
||||||
self.registerControllers(u'Powerpoint Viewer', pptview)
|
|
||||||
except:
|
|
||||||
log.exception(u'Failed to set up plugin for Powerpoint Viewer')
|
|
||||||
#If we have no available controllers disable plugin
|
#If we have no available controllers disable plugin
|
||||||
if len(self.controllers) > 0:
|
if len(self.controllers) > 0:
|
||||||
return True
|
return True
|
||||||
|
Loading…
Reference in New Issue
Block a user