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 #
|
||||
###############################################################################
|
||||
|
||||
import os
|
||||
|
||||
from presentationcontroller import PresentationController
|
||||
from impresscontroller import ImpressController
|
||||
if os.name == u'nt':
|
||||
#from powerpointcontroller import PowerpointController
|
||||
from pptviewcontroller import PptviewController
|
||||
from powerpointcontroller import PowerpointController
|
||||
from pptviewcontroller import PptviewController
|
||||
from messagelistener import MessageListener
|
||||
from mediaitem import PresentationMediaItem
|
||||
from presentationtab import PresentationTab
|
||||
|
|
|
@ -36,7 +36,10 @@ else:
|
|||
|
||||
from PyQt4 import QtCore
|
||||
|
||||
class ImpressController(object):
|
||||
from presentationcontroller import PresentationController
|
||||
|
||||
|
||||
class ImpressController(PresentationController):
|
||||
"""
|
||||
Class to control interactions with Impress presentations.
|
||||
It creates the runtime environment, loads and closes the presentation as
|
||||
|
@ -45,14 +48,29 @@ class ImpressController(object):
|
|||
global log
|
||||
log = logging.getLogger(u'ImpressController')
|
||||
|
||||
def __init__(self):
|
||||
def __init__(self, plugin):
|
||||
"""
|
||||
Initialise the class
|
||||
"""
|
||||
log.debug(u'Initialising')
|
||||
PresentationController.__init__(self, plugin, u'Impress')
|
||||
self.process = None
|
||||
self.document = 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.
|
||||
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
|
||||
"""
|
||||
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.
|
||||
It builds the environment, starts communcations with the background
|
||||
|
@ -86,10 +104,10 @@ class ImpressController(object):
|
|||
"""
|
||||
log.debug(u'LoadPresentation')
|
||||
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')
|
||||
else:
|
||||
desktop = self.getUNODesktop()
|
||||
desktop = self.get_uno_desktop()
|
||||
url = uno.systemPathToFileUrl(presentation)
|
||||
if desktop is None:
|
||||
return
|
||||
|
@ -100,12 +118,12 @@ class ImpressController(object):
|
|||
url, "_blank", 0, properties)
|
||||
self.presentation = self.document.getPresentation()
|
||||
self.presentation.start()
|
||||
self.xSlideShowController = \
|
||||
self.controller = \
|
||||
desktop.getCurrentComponent().Presentation.getController()
|
||||
except:
|
||||
log.exception(u'Failed to load presentation')
|
||||
|
||||
def getUNODesktop(self):
|
||||
def get_uno_desktop(self):
|
||||
log.debug(u'getUNODesktop')
|
||||
ctx = None
|
||||
loop = 0
|
||||
|
@ -127,7 +145,7 @@ class ImpressController(object):
|
|||
log.exception(u'Failed to get UNO desktop')
|
||||
return None
|
||||
|
||||
def getCOMDesktop(self):
|
||||
def get_com_desktop(self):
|
||||
log.debug(u'getCOMDesktop')
|
||||
try:
|
||||
smgr = Dispatch("com.sun.star.ServiceManager")
|
||||
|
@ -137,7 +155,7 @@ class ImpressController(object):
|
|||
log.exception(u'Failed to get COM desktop')
|
||||
return None
|
||||
|
||||
def closePresentation(self):
|
||||
def close_presentation(self):
|
||||
"""
|
||||
Close presentation and clean up objects
|
||||
Triggerent by new object being added to SlideController orOpenLP
|
||||
|
@ -150,43 +168,45 @@ class ImpressController(object):
|
|||
self.document.dispose()
|
||||
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()
|
||||
|
||||
def resume(self):
|
||||
def unblank_screen(self):
|
||||
return self.presentation.resume()
|
||||
|
||||
def pause(self):
|
||||
return self.presentation.pause()
|
||||
|
||||
def blankScreen(self):
|
||||
def blank_screen(self):
|
||||
self.presentation.blankScreen(0)
|
||||
|
||||
def stop(self):
|
||||
def stop_presentation(self):
|
||||
self.presentation.deactivate()
|
||||
# self.presdoc.end()
|
||||
|
||||
def go(self):
|
||||
def start_presentation(self):
|
||||
self.presentation.activate()
|
||||
# self.presdoc.start()
|
||||
|
||||
def getSlideNumber(self):
|
||||
def get_slide_number(self):
|
||||
return self.presentation.getCurrentSlideIndex
|
||||
|
||||
def setSlideNumber(self, slideno):
|
||||
def goto_slide(self, slideno):
|
||||
self.presentation.gotoSlideIndex(slideno)
|
||||
|
||||
slideNumber = property(getSlideNumber, setSlideNumber)
|
||||
|
||||
def nextStep(self):
|
||||
def next_step(self):
|
||||
"""
|
||||
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
|
||||
"""
|
||||
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
|
||||
"""
|
||||
self.handler, file = self.decodeMessage(message)
|
||||
self.controllers[self.handler].loadPresentation(file)
|
||||
self.controllers[self.handler].load_presentation(file)
|
||||
|
||||
def next(self, message):
|
||||
"""
|
||||
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):
|
||||
"""
|
||||
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):
|
||||
"""
|
||||
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):
|
||||
"""
|
||||
|
|
|
@ -21,147 +21,157 @@
|
|||
# with this program; if not, write to the Free Software Foundation, Inc., 59 #
|
||||
# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
|
||||
###############################################################################
|
||||
try:
|
||||
|
||||
import os
|
||||
import logging
|
||||
|
||||
if os.name == u'nt':
|
||||
from win32com.client import Dispatch
|
||||
except:
|
||||
pass
|
||||
|
||||
from presentationcontroller import PresentationController
|
||||
|
||||
# PPT API documentation:
|
||||
# http://msdn.microsoft.com/en-us/library/aa269321(office.10).aspx
|
||||
|
||||
class PowerPointApp(object):
|
||||
def __init__(self):
|
||||
class PowerpointController(PresentationController):
|
||||
"""
|
||||
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')
|
||||
PresentationController.__init__(self, plugin, u'Powerpoint')
|
||||
self.process = None
|
||||
self.document = None
|
||||
self.presentation = None
|
||||
self.startPowerpoint()
|
||||
|
||||
def startPowerpoint(self):
|
||||
try:
|
||||
self._app = Dispatch(u'PowerPoint.Application')
|
||||
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:
|
||||
def is_available(self):
|
||||
"""
|
||||
PowerPoint is able to run on this machine
|
||||
"""
|
||||
log.debug(u'is_available')
|
||||
if os.name != u'nt':
|
||||
return False
|
||||
if self.pres.SlideShowWindow.View is None:
|
||||
try:
|
||||
self.start_process()
|
||||
return True
|
||||
except:
|
||||
return False
|
||||
|
||||
if os.name == u'nt':
|
||||
def start_process(self):
|
||||
"""
|
||||
Loads PowerPoint process
|
||||
"""
|
||||
self.process = Dispatch(u'PowerPoint.Application')
|
||||
self.process.Visible = True
|
||||
self.process.WindowState = 2
|
||||
|
||||
def is_loaded(self):
|
||||
"""
|
||||
Returns true if a presentation is loaded
|
||||
"""
|
||||
if self.process is None:
|
||||
return False
|
||||
if self.process.Windows.Count == 0:
|
||||
return False
|
||||
|
||||
def kill(self):
|
||||
self.process.Quit()
|
||||
self.process = None
|
||||
|
||||
def load_presentation(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.
|
||||
"""
|
||||
self.filename = presentation
|
||||
self.process.Presentations.Open(presentation, False, False, True)
|
||||
self.presentation = self.process.Presentations(self.process.Presentations.Count)
|
||||
self.start_presentation()
|
||||
|
||||
def close_presentation(self):
|
||||
"""
|
||||
Close presentation and clean up objects
|
||||
Triggerent by new object being added to SlideController orOpenLP
|
||||
being shut down
|
||||
"""
|
||||
self.presentation.Close()
|
||||
self.presentation = None
|
||||
|
||||
def is_active(self):
|
||||
"""
|
||||
Returns true if a presentation is currently active
|
||||
"""
|
||||
if not self.is_loaded():
|
||||
return False
|
||||
if self.presentation.SlideShowWindow == None:
|
||||
return False
|
||||
if self.presentation.SlideShowWindow.View == None:
|
||||
return False
|
||||
return True
|
||||
|
||||
def resume(self):
|
||||
self.pres.SlideShowSettings.Run()
|
||||
self.pres.SlideShowWindow.View.State = 1
|
||||
self.pres.SlideShowWindow.Activate()
|
||||
def unblank_screen(self):
|
||||
"""
|
||||
Unblanks (restores) the presentationn
|
||||
"""
|
||||
self.presentation.SlideShowSettings.Run()
|
||||
self.presentation.SlideShowWindow.View.State = 1
|
||||
self.presentation.SlideShowWindow.Activate()
|
||||
|
||||
def pause(self):
|
||||
if self.isActive():
|
||||
self.pres.SlideShowWindow.View.State = 2
|
||||
def blank_screen(self):
|
||||
"""
|
||||
Blanks the screen
|
||||
"""
|
||||
self.presentation.SlideShowWindow.View.State = 3
|
||||
|
||||
def blankScreen(self):
|
||||
if self.isActive():
|
||||
self.pres.SlideShowWindow.View.State = 3
|
||||
def stop_presentation(self):
|
||||
"""
|
||||
Stops the current presentation and hides the output
|
||||
"""
|
||||
self.presentation.SlideShowWindow.View.Exit()
|
||||
|
||||
def stop(self):
|
||||
if self.isActive():
|
||||
self.pres.SlideShowWindow.View.Exit()
|
||||
def start_presentation(self):
|
||||
"""
|
||||
Starts a presentation from the beginning
|
||||
"""
|
||||
self.presentation.SlideShowSettings.Run()
|
||||
rendermanager = self.plugin.render_manager
|
||||
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
|
||||
|
||||
def go(self):
|
||||
self.pres.SlideShowSettings.Run()
|
||||
def get_slide_number(self):
|
||||
"""
|
||||
Returns the current slide number
|
||||
"""
|
||||
return self.presentation.SlideShowWindow.View.CurrentShowPosition
|
||||
|
||||
def getCurrentSlideIndex(self):
|
||||
if self.isActive():
|
||||
return self.pres.SlideShowWindow.View.CurrentShowPosition
|
||||
else:
|
||||
return -1
|
||||
def get_slide_count(self):
|
||||
"""
|
||||
Returns total number of slides
|
||||
"""
|
||||
return self.presentation.Slides.Count
|
||||
|
||||
def setCurrentSlideIndex(self, slideno):
|
||||
if not self.isActive():
|
||||
self.resume()
|
||||
self.pres.SlideShowWindow.View.GotoSlide(slideno)
|
||||
def goto_slide(self, slideno):
|
||||
self.presentation.SlideShowWindow.View.GotoSlide(slideno)
|
||||
|
||||
#currentSlideIndex = property(getSlideNumber, setSlideNumber)
|
||||
def next_step(self):
|
||||
self.presentation.SlideShowWindow.View.Next()
|
||||
|
||||
def nextStep(self):
|
||||
if not self.isActive():
|
||||
self.resume()
|
||||
self.pres.SlideShowWindow.View.Next()
|
||||
|
||||
def prevStep(self):
|
||||
if not self.isActive():
|
||||
self.resume()
|
||||
self.pres.SlideShowWindow.View.Previous()
|
||||
|
||||
def moveWindow(self, top, height, left, width):
|
||||
if not self.isActive():
|
||||
self.resume()
|
||||
self.pres.SlideShowWindow.Top = top / 20
|
||||
self.pres.SlideShowWindow.Height = height / 20
|
||||
self.pres.SlideShowWindow.Left = left / 20
|
||||
self.pres.SlideShowWindow.Width = width / 20
|
||||
|
||||
class PowerPointSlide(object):
|
||||
def __init__(self, pres, index):
|
||||
self.pres = pres
|
||||
self.slide = pres.Slides[index]
|
||||
|
||||
def preview(self):
|
||||
if self.preview is None:
|
||||
self.slide.Copy
|
||||
# import win32clipboard as w
|
||||
# import win32con
|
||||
# w.OpenClipboard()
|
||||
# self.preview = w.GetClipboardData.GetData(win32con.CF_BITMAP)
|
||||
# w.CloseClipboard()
|
||||
return self.preview
|
||||
def previous_step(self):
|
||||
self.presentation.SlideShowWindow.View.Previous()
|
||||
|
|
|
@ -22,43 +22,65 @@
|
|||
# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
|
||||
###############################################################################
|
||||
|
||||
import os
|
||||
import logging
|
||||
|
||||
from ctypes import *
|
||||
from ctypes.wintypes import RECT
|
||||
if os.name == u'nt':
|
||||
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
|
||||
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
|
||||
log = logging.getLogger(u'PptviewController')
|
||||
|
||||
def __init__(self):
|
||||
def __init__(self, plugin):
|
||||
"""
|
||||
Initialise the class
|
||||
"""
|
||||
log.debug(u'Initialising')
|
||||
PresentationController.__init__(self, plugin, u'Powerpoint Viewer')
|
||||
self.process = None
|
||||
self.document = None
|
||||
self.presentation = 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):
|
||||
"""
|
||||
PPT Viewer is able to run on this machine
|
||||
"""
|
||||
log.debug(u'is_available')
|
||||
if os.name != u'nt':
|
||||
return False
|
||||
try:
|
||||
self.start_process()
|
||||
return True
|
||||
except:
|
||||
return False
|
||||
|
||||
if os.name == u'nt':
|
||||
def start_process(self):
|
||||
"""
|
||||
Loads the PPTVIEWLIB library
|
||||
"""
|
||||
log.debug(u'start PPTView')
|
||||
self.presentation = cdll.LoadLibrary(r'openlp\plugins\presentations\lib\pptviewlib\pptviewlib.dll')
|
||||
self.process = cdll.LoadLibrary(r'openlp\plugins\presentations\lib\pptviewlib\pptviewlib.dll')
|
||||
|
||||
def kill(self):
|
||||
"""
|
||||
Called at system exit to clean up any running presentations
|
||||
"""
|
||||
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.
|
||||
It builds the environment, starts communcations with the background
|
||||
|
@ -71,111 +93,99 @@ class PptviewController(object):
|
|||
"""
|
||||
log.debug(u'LoadPresentation')
|
||||
if self.pptid >= 0:
|
||||
self.closePresentation()
|
||||
rect = RECT(0, 0, 800, 600) # until such time I can get screen info
|
||||
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:
|
||||
tempfolder = None #r'c:\temp\pptviewlib\' + filename.split('u\\')[-1]
|
||||
self.pptid = self.presentation.OpenPPT(filename, None, rect, tempfolder)
|
||||
self.pptid = self.process.OpenPPT(filename, None, rect,
|
||||
str(self.thumbnailpath))
|
||||
except:
|
||||
log.exception(u'Failed to load presentation')
|
||||
#self.slidecount = pptdll.GetSlideCount(self.pptid)
|
||||
|
||||
def closePresentation(self):
|
||||
def close_presentation(self):
|
||||
"""
|
||||
Close presentation and clean up objects
|
||||
Triggerent by new object being added to SlideController orOpenLP
|
||||
being shut down
|
||||
"""
|
||||
if self.pptid < 0:
|
||||
return
|
||||
self.presentation.ClosePPT(self.pptid)
|
||||
self.process.ClosePPT(self.pptid)
|
||||
self.pptid = -1
|
||||
|
||||
def nextStep(self):
|
||||
def is_loaded(self):
|
||||
"""
|
||||
Triggers the next effect of slide on the running presentation
|
||||
Returns true if a presentation is loaded
|
||||
"""
|
||||
if self.pptid < 0:
|
||||
return
|
||||
self.presentation.NextStep(self.pptid)
|
||||
return self.pptid >= 0
|
||||
|
||||
def previousStep(self):
|
||||
"""
|
||||
Triggers the previous slide on the running presentation
|
||||
"""
|
||||
if self.pptid < 0:
|
||||
return
|
||||
self.presentation.PrevStep(self.pptid)
|
||||
|
||||
def isActive(self):
|
||||
def is_active(self):
|
||||
"""
|
||||
Returns true if a presentation is currently active
|
||||
"""
|
||||
return self.pptid >= 0
|
||||
|
||||
def resume(self):
|
||||
"""
|
||||
Resumes a previously paused presentation
|
||||
"""
|
||||
if self.pptid < 0:
|
||||
return
|
||||
self.presentation.Resume(self.pptid)
|
||||
|
||||
def pause(self):
|
||||
"""
|
||||
Not implemented (pauses a presentation)
|
||||
"""
|
||||
return
|
||||
|
||||
def blankScreen(self):
|
||||
def blank_screen(self):
|
||||
"""
|
||||
Blanks the screen
|
||||
"""
|
||||
if self.pptid < 0:
|
||||
return
|
||||
self.presentation.Blank(self.pptid)
|
||||
self.process.Blank(self.pptid)
|
||||
|
||||
def unblankScreen(self):
|
||||
def unblank_screen(self):
|
||||
"""
|
||||
Unblanks (restores) the presentationn
|
||||
"""
|
||||
if self.pptid < 0:
|
||||
return
|
||||
self.presentation.Unblank(self.pptid)
|
||||
self.process.Unblank(self.pptid)
|
||||
|
||||
def stop(self):
|
||||
def stop_presentation(self):
|
||||
"""
|
||||
Stops the current presentation and hides the output
|
||||
"""
|
||||
if self.pptid < 0:
|
||||
return
|
||||
self.presentation.Stop(self.pptid)
|
||||
self.process.Stop(self.pptid)
|
||||
|
||||
def go(self):
|
||||
def start_presentation(self):
|
||||
"""
|
||||
Starts a presentation from the beginning
|
||||
"""
|
||||
if self.pptid < 0:
|
||||
return
|
||||
self.presentation.RestartShow(self.pptid)
|
||||
self.process.RestartShow(self.pptid)
|
||||
|
||||
def getSlideNumber(self):
|
||||
def get_slide_number(self):
|
||||
"""
|
||||
Returns the current slide number
|
||||
"""
|
||||
if self.pptid < 0:
|
||||
return -1
|
||||
return self.presentation.GetCurrentSlide(self.pptid)
|
||||
return self.process.GetCurrentSlide(self.pptid)
|
||||
|
||||
def setSlideNumber(self, slideno):
|
||||
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
|
||||
"""
|
||||
if self.pptid < 0:
|
||||
return
|
||||
self.presentation.GotoSlide(self.pptid, slideno)
|
||||
self.process.GotoSlide(self.pptid, slideno)
|
||||
|
||||
slideNumber = property(getSlideNumber, setSlideNumber)
|
||||
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')
|
||||
|
||||
|
|
|
@ -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.
|
||||
"""
|
||||
def __init__(self):
|
||||
def __init__(self, controllers):
|
||||
self.controllers = controllers
|
||||
SettingsTab.__init__(self,
|
||||
translate(u'PresentationTab', u'Presentation'), u'Presentations')
|
||||
|
||||
|
|
|
@ -28,14 +28,7 @@ import logging
|
|||
from PyQt4 import QtCore, QtGui
|
||||
|
||||
from openlp.core.lib import Plugin
|
||||
from openlp.plugins.presentations.lib import PresentationMediaItem, \
|
||||
PresentationTab, ImpressController
|
||||
if os.name == u'nt':
|
||||
try:
|
||||
from openlp.plugins.presentations.lib import PowerpointController
|
||||
except:
|
||||
pass
|
||||
from openlp.plugins.presentations.lib import PptviewController
|
||||
from openlp.plugins.presentations.lib import *
|
||||
|
||||
class PresentationPlugin(Plugin):
|
||||
|
||||
|
@ -57,7 +50,7 @@ class PresentationPlugin(Plugin):
|
|||
"""
|
||||
Create the settings Tab
|
||||
"""
|
||||
self.presentation_tab = PresentationTab()
|
||||
self.presentation_tab = PresentationTab(self.controllers)
|
||||
return self.presentation_tab
|
||||
|
||||
def get_media_manager_item(self):
|
||||
|
@ -68,8 +61,8 @@ class PresentationPlugin(Plugin):
|
|||
self, self.icon, u'Presentations', self.controllers)
|
||||
return self.media_item
|
||||
|
||||
def registerControllers(self, handle, controller):
|
||||
self.controllers[handle] = controller
|
||||
def registerControllers(self, controller):
|
||||
self.controllers[controller.name] = controller
|
||||
|
||||
def check_pre_conditions(self):
|
||||
"""
|
||||
|
@ -77,39 +70,24 @@ class PresentationPlugin(Plugin):
|
|||
If Not do not install the plugin.
|
||||
"""
|
||||
log.debug('check_pre_conditions')
|
||||
#Lets see if Impress is required (Default is Not wanted)
|
||||
if int(self.config.get_config(
|
||||
u'Impress', QtCore.Qt.Unchecked)) == QtCore.Qt.Checked:
|
||||
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
|
||||
import uno
|
||||
openoffice = ImpressController()
|
||||
self.registerControllers(u'Impress', openoffice)
|
||||
except:
|
||||
log.exception(u'Failed to set up plugin for Impress')
|
||||
if os.name == u'nt':
|
||||
#Lets see if Powerpoint is required (Default is Not wanted)
|
||||
controller = PowerpointController(self)
|
||||
if int(self.config.get_config(
|
||||
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')
|
||||
controller.name, QtCore.Qt.Unchecked)) == QtCore.Qt.Checked:
|
||||
if controller.is_available():
|
||||
self.registerControllers(controller)
|
||||
#Lets see if Impress is required (Default is Not wanted)
|
||||
controller = ImpressController(self)
|
||||
if int(self.config.get_config(
|
||||
controller.name, QtCore.Qt.Unchecked)) == QtCore.Qt.Checked:
|
||||
if controller.is_available():
|
||||
self.registerControllers(controller)
|
||||
#Lets see if Powerpoint Viewer is required (Default is Not wanted)
|
||||
controller = PptviewController(self)
|
||||
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')
|
||||
controller.name, QtCore.Qt.Unchecked)) == QtCore.Qt.Checked:
|
||||
if controller.is_available():
|
||||
self.registerControllers(controller)
|
||||
#If we have no available controllers disable plugin
|
||||
if len(self.controllers) > 0:
|
||||
return True
|
||||
|
|
Loading…
Reference in New Issue