forked from openlp/openlp
Presentation tidyups
This commit is contained in:
parent
4ba065a338
commit
fe01718d46
@ -331,7 +331,10 @@ class ImpressDocument(PresentationDocument):
|
||||
|
||||
def stop_presentation(self):
|
||||
log.debug(u'stop presentation OpenOffice')
|
||||
self.control.deactivate()
|
||||
# deactivate should hide the screen according to docs, but doesn't
|
||||
#self.control.deactivate()
|
||||
self.presentation.end()
|
||||
self.control = None
|
||||
|
||||
def start_presentation(self):
|
||||
log.debug(u'start presentation OpenOffice')
|
||||
|
@ -41,31 +41,31 @@ class Controller(object):
|
||||
log.info(u'Controller loaded')
|
||||
|
||||
def __init__(self, live):
|
||||
self.isLive = live
|
||||
self.is_live = live
|
||||
self.doc = None
|
||||
log.info(u'%s controller loaded' % live)
|
||||
|
||||
def addHandler(self, controller, file, isBlank):
|
||||
log.debug(u'Live = %s, addHandler %s' % (self.isLive, file))
|
||||
def add_handler(self, controller, file, is_blank):
|
||||
log.debug(u'Live = %s, add_handler %s' % (self.is_live, file))
|
||||
self.controller = controller
|
||||
if self.doc is not None:
|
||||
self.shutdown()
|
||||
self.doc = self.controller.add_doc(file)
|
||||
self.doc.load_presentation()
|
||||
if self.isLive:
|
||||
if self.is_live:
|
||||
self.doc.start_presentation()
|
||||
if isBlank:
|
||||
if is_blank:
|
||||
self.blank()
|
||||
Receiver.send_message(u'maindisplay_hide', HideMode.Screen)
|
||||
self.doc.slidenumber = 0
|
||||
|
||||
def activate(self):
|
||||
log.debug(u'Live = %s, activate' % self.isLive)
|
||||
log.debug(u'Live = %s, activate' % self.is_live)
|
||||
if self.doc.is_active():
|
||||
return
|
||||
if not self.doc.is_loaded():
|
||||
self.doc.load_presentation()
|
||||
if self.isLive:
|
||||
if self.is_live:
|
||||
self.doc.start_presentation()
|
||||
if self.doc.slidenumber > 1:
|
||||
self.doc.goto_slide(self.doc.slidenumber)
|
||||
@ -85,36 +85,36 @@ class Controller(object):
|
||||
"""
|
||||
Based on the handler passed at startup triggers the first slide
|
||||
"""
|
||||
log.debug(u'Live = %s, first' % self.isLive)
|
||||
if not self.isLive:
|
||||
log.debug(u'Live = %s, first' % self.is_live)
|
||||
if not self.is_live:
|
||||
return
|
||||
if self.doc.is_blank():
|
||||
self.doc.slidenumber = 1
|
||||
return
|
||||
self.activate()
|
||||
self.doc.start_presentation()
|
||||
self.doc.poll_slidenumber(self.isLive)
|
||||
self.doc.poll_slidenumber(self.is_live)
|
||||
|
||||
def last(self):
|
||||
"""
|
||||
Based on the handler passed at startup triggers the first slide
|
||||
"""
|
||||
log.debug(u'Live = %s, last' % self.isLive)
|
||||
if not self.isLive:
|
||||
log.debug(u'Live = %s, last' % self.is_live)
|
||||
if not self.is_live:
|
||||
return
|
||||
if self.doc.is_blank():
|
||||
self.doc.slidenumber = self.doc.get_slide_count()
|
||||
return
|
||||
self.activate()
|
||||
self.doc.goto_slide(self.doc.get_slide_count())
|
||||
self.doc.poll_slidenumber(self.isLive)
|
||||
self.doc.poll_slidenumber(self.is_live)
|
||||
|
||||
def next(self):
|
||||
"""
|
||||
Based on the handler passed at startup triggers the next slide event
|
||||
"""
|
||||
log.debug(u'Live = %s, next' % self.isLive)
|
||||
if not self.isLive:
|
||||
log.debug(u'Live = %s, next' % self.is_live)
|
||||
if not self.is_live:
|
||||
return
|
||||
if self.doc.is_blank():
|
||||
if self.doc.slidenumber < self.doc.get_slide_count():
|
||||
@ -122,14 +122,14 @@ class Controller(object):
|
||||
return
|
||||
self.activate()
|
||||
self.doc.next_step()
|
||||
self.doc.poll_slidenumber(self.isLive)
|
||||
self.doc.poll_slidenumber(self.is_live)
|
||||
|
||||
def previous(self):
|
||||
"""
|
||||
Based on the handler passed at startup triggers the previous slide event
|
||||
"""
|
||||
log.debug(u'Live = %s, previous' % self.isLive)
|
||||
if not self.isLive:
|
||||
log.debug(u'Live = %s, previous' % self.is_live)
|
||||
if not self.is_live:
|
||||
return
|
||||
if self.doc.is_blank():
|
||||
if self.doc.slidenumber > 1:
|
||||
@ -137,14 +137,14 @@ class Controller(object):
|
||||
return
|
||||
self.activate()
|
||||
self.doc.previous_step()
|
||||
self.doc.poll_slidenumber(self.isLive)
|
||||
self.doc.poll_slidenumber(self.is_live)
|
||||
|
||||
def shutdown(self):
|
||||
"""
|
||||
Based on the handler passed at startup triggers slide show to shut down
|
||||
"""
|
||||
log.debug(u'Live = %s, shutdown' % self.isLive)
|
||||
if self.isLive:
|
||||
log.debug(u'Live = %s, shutdown' % self.is_live)
|
||||
if self.is_live:
|
||||
Receiver.send_message(u'maindisplay_show')
|
||||
self.doc.close_presentation()
|
||||
self.doc = None
|
||||
@ -152,8 +152,8 @@ class Controller(object):
|
||||
#self.timer.stop()
|
||||
|
||||
def blank(self):
|
||||
log.debug(u'Live = %s, blank' % self.isLive)
|
||||
if not self.isLive:
|
||||
log.debug(u'Live = %s, blank' % self.is_live)
|
||||
if not self.is_live:
|
||||
return
|
||||
if not self.doc.is_loaded():
|
||||
return
|
||||
@ -162,8 +162,8 @@ class Controller(object):
|
||||
self.doc.blank_screen()
|
||||
|
||||
def stop(self):
|
||||
log.debug(u'Live = %s, stop' % self.isLive)
|
||||
if not self.isLive:
|
||||
log.debug(u'Live = %s, stop' % self.is_live)
|
||||
if not self.is_live:
|
||||
return
|
||||
if not self.doc.is_loaded():
|
||||
return
|
||||
@ -172,8 +172,8 @@ class Controller(object):
|
||||
self.doc.stop_presentation()
|
||||
|
||||
def unblank(self):
|
||||
log.debug(u'Live = %s, unblank' % self.isLive)
|
||||
if not self.isLive:
|
||||
log.debug(u'Live = %s, unblank' % self.is_live)
|
||||
if not self.is_live:
|
||||
return
|
||||
self.activate()
|
||||
if self.doc.slidenumber and \
|
||||
@ -183,7 +183,7 @@ class Controller(object):
|
||||
Receiver.send_message(u'maindisplay_hide', HideMode.Screen)
|
||||
|
||||
def poll(self):
|
||||
self.doc.poll_slidenumber(self.isLive)
|
||||
self.doc.poll_slidenumber(self.is_live)
|
||||
|
||||
class MessageListener(object):
|
||||
"""
|
||||
@ -195,8 +195,8 @@ class MessageListener(object):
|
||||
def __init__(self, mediaitem):
|
||||
self.controllers = mediaitem.controllers
|
||||
self.mediaitem = mediaitem
|
||||
self.previewHandler = Controller(False)
|
||||
self.liveHandler = Controller(True)
|
||||
self.preview_handler = Controller(False)
|
||||
self.live_handler = Controller(True)
|
||||
# messages are sent from core.ui.slidecontroller
|
||||
QtCore.QObject.connect(Receiver.get_receiver(),
|
||||
QtCore.SIGNAL(u'presentations_start'), self.startup)
|
||||
@ -228,9 +228,10 @@ class MessageListener(object):
|
||||
Start of new presentation
|
||||
Save the handler as any new presentations start here
|
||||
"""
|
||||
isLive, item = self.decode_message(message)
|
||||
is_live = message[1]
|
||||
item = message[0]
|
||||
log.debug(u'Startup called with message %s' % message)
|
||||
isBlank = message[2]
|
||||
is_blank = message[2]
|
||||
file = os.path.join(item.get_frame_path(),
|
||||
item.get_frame_title())
|
||||
self.handler = item.title
|
||||
@ -238,75 +239,71 @@ class MessageListener(object):
|
||||
self.handler = self.mediaitem.findControllerByType(file)
|
||||
if not self.handler:
|
||||
return
|
||||
if isLive:
|
||||
controller = self.liveHandler
|
||||
if is_live:
|
||||
controller = self.live_handler
|
||||
else:
|
||||
controller = self.previewHandler
|
||||
controller.addHandler(self.controllers[self.handler], file, isBlank)
|
||||
|
||||
def decode_message(self, message):
|
||||
if len(message) == 3:
|
||||
return message[1], message[0], message[2]
|
||||
else:
|
||||
return message[1], message[0]
|
||||
controller = self.preview_handler
|
||||
controller.add_handler(self.controllers[self.handler], file, is_blank)
|
||||
|
||||
def slide(self, message):
|
||||
isLive, item, slide = self.decode_message(message)
|
||||
if isLive:
|
||||
self.liveHandler.slide(slide, isLive)
|
||||
is_live = message[1]
|
||||
slide = message[2]
|
||||
item = message[0]
|
||||
if is_live:
|
||||
self.live_handler.slide(slide, item)
|
||||
else:
|
||||
self.previewHandler.slide(slide, isLive)
|
||||
self.preview_handler.slide(slide, item)
|
||||
|
||||
def first(self, message):
|
||||
isLive = self.decode_message(message)[0]
|
||||
if isLive:
|
||||
self.liveHandler.first()
|
||||
is_live = message[1]
|
||||
if is_live:
|
||||
self.live_handler.first()
|
||||
else:
|
||||
self.previewHandler.first()
|
||||
self.preview_handler.first()
|
||||
|
||||
def last(self, message):
|
||||
isLive = self.decode_message(message)[0]
|
||||
if isLive:
|
||||
self.liveHandler.last()
|
||||
is_live = message[1]
|
||||
if is_live:
|
||||
self.live_handler.last()
|
||||
else:
|
||||
self.previewHandler.last()
|
||||
self.preview_handler.last()
|
||||
|
||||
def next(self, message):
|
||||
isLive = self.decode_message(message)[0]
|
||||
if isLive:
|
||||
self.liveHandler.next()
|
||||
is_live = message[1]
|
||||
if is_live:
|
||||
self.live_handler.next()
|
||||
else:
|
||||
self.previewHandler.next()
|
||||
self.preview_handler.next()
|
||||
|
||||
def previous(self, message):
|
||||
isLive = self.decode_message(message)[0]
|
||||
if isLive:
|
||||
self.liveHandler.previous()
|
||||
is_live = message[1]
|
||||
if is_live:
|
||||
self.live_handler.previous()
|
||||
else:
|
||||
self.previewHandler.previous()
|
||||
self.preview_handler.previous()
|
||||
|
||||
def shutdown(self, message):
|
||||
isLive = self.decode_message(message)[0]
|
||||
if isLive:
|
||||
is_live = message[1]
|
||||
if is_live:
|
||||
Receiver.send_message(u'maindisplay_show')
|
||||
self.liveHandler.shutdown()
|
||||
self.live_handler.shutdown()
|
||||
else:
|
||||
self.previewHandler.shutdown()
|
||||
self.preview_handler.shutdown()
|
||||
|
||||
def hide(self, message):
|
||||
isLive = self.decode_message(message)[0]
|
||||
if isLive:
|
||||
self.liveHandler.stop()
|
||||
is_live = message[1]
|
||||
if is_live:
|
||||
self.live_handler.stop()
|
||||
|
||||
def blank(self, message):
|
||||
isLive = self.decode_message(message)[0]
|
||||
if isLive:
|
||||
self.liveHandler.blank()
|
||||
is_live = message[1]
|
||||
if is_live:
|
||||
self.live_handler.blank()
|
||||
|
||||
def unblank(self, message):
|
||||
isLive = self.decode_message(message)[0]
|
||||
if isLive:
|
||||
self.liveHandler.unblank()
|
||||
is_live = message[1]
|
||||
if is_live:
|
||||
self.live_handler.unblank()
|
||||
|
||||
def timeout(self):
|
||||
self.liveHandler.poll()
|
||||
self.live_handler.poll()
|
||||
|
@ -30,6 +30,7 @@ if os.name == u'nt':
|
||||
from win32com.client import Dispatch
|
||||
import _winreg
|
||||
import win32ui
|
||||
import pywintypes
|
||||
|
||||
from presentationcontroller import PresentationController, PresentationDocument
|
||||
|
||||
@ -65,7 +66,7 @@ class PowerpointController(PresentationController):
|
||||
_winreg.OpenKey(_winreg.HKEY_CLASSES_ROOT,
|
||||
u'PowerPoint.Application').Close()
|
||||
return True
|
||||
except:
|
||||
except WindowsError:
|
||||
pass
|
||||
return False
|
||||
|
||||
@ -91,7 +92,7 @@ class PowerpointController(PresentationController):
|
||||
return
|
||||
try:
|
||||
self.process.Quit()
|
||||
except:
|
||||
except pywintypes.com_error:
|
||||
pass
|
||||
self.process = None
|
||||
|
||||
@ -121,11 +122,8 @@ class PowerpointDocument(PresentationDocument):
|
||||
log.debug(u'LoadPresentation')
|
||||
if not self.controller.process.Visible:
|
||||
self.controller.start_process()
|
||||
#try:
|
||||
self.controller.process.Presentations.Open(self.filepath, False, False,
|
||||
True)
|
||||
#except:
|
||||
# return
|
||||
self.presentation = self.controller.process.Presentations(
|
||||
self.controller.process.Presentations.Count)
|
||||
self.create_thumbnails()
|
||||
@ -154,7 +152,7 @@ class PowerpointDocument(PresentationDocument):
|
||||
if self.presentation:
|
||||
try:
|
||||
self.presentation.Close()
|
||||
except:
|
||||
except pywintypes.com_error:
|
||||
pass
|
||||
self.presentation = None
|
||||
self.controller.remove_doc(self)
|
||||
@ -170,7 +168,9 @@ class PowerpointDocument(PresentationDocument):
|
||||
return False
|
||||
if self.controller.process.Presentations.Count == 0:
|
||||
return False
|
||||
except:
|
||||
except AttributeError:
|
||||
return False
|
||||
except pywintypes.com_error:
|
||||
return False
|
||||
return True
|
||||
|
||||
@ -186,7 +186,9 @@ class PowerpointDocument(PresentationDocument):
|
||||
return False
|
||||
if self.presentation.SlideShowWindow.View is None:
|
||||
return False
|
||||
except:
|
||||
except AttributeError:
|
||||
return False
|
||||
except pywintypes.com_error:
|
||||
return False
|
||||
return True
|
||||
|
||||
@ -208,7 +210,10 @@ class PowerpointDocument(PresentationDocument):
|
||||
"""
|
||||
Returns true if screen is blank
|
||||
"""
|
||||
return self.presentation.SlideShowWindow.View.State == 3
|
||||
try:
|
||||
return self.presentation.SlideShowWindow.View.State == 3
|
||||
except pywintypes.com_error:
|
||||
return False
|
||||
|
||||
def stop_presentation(self):
|
||||
"""
|
||||
@ -224,11 +229,11 @@ class PowerpointDocument(PresentationDocument):
|
||||
#SlideShowWindow measures its size/position by points, not pixels
|
||||
try:
|
||||
dpi = win32ui.GetActiveWindow().GetDC().GetDeviceCaps(88)
|
||||
except:
|
||||
except win32ui.error:
|
||||
try:
|
||||
dpi = \
|
||||
win32ui.GetForegroundWindow().GetDC().GetDeviceCaps(88)
|
||||
except:
|
||||
except win32ui.error:
|
||||
dpi = 96
|
||||
self.presentation.SlideShowSettings.Run()
|
||||
self.presentation.SlideShowWindow.View.GotoSlide(1)
|
||||
|
@ -72,7 +72,7 @@ class PptviewController(PresentationController):
|
||||
try:
|
||||
self.start_process()
|
||||
return self.process.CheckInstalled()
|
||||
except:
|
||||
except WindowsError:
|
||||
return False
|
||||
|
||||
def start_process(self):
|
||||
@ -84,6 +84,7 @@ class PptviewController(PresentationController):
|
||||
log.debug(u'start PPTView')
|
||||
self.process = cdll.LoadLibrary(
|
||||
r'openlp\plugins\presentations\lib\pptviewlib\pptviewlib.dll')
|
||||
#self.process.SetDebug(1)
|
||||
|
||||
def kill(self):
|
||||
"""
|
||||
@ -106,6 +107,7 @@ class PptviewDocument(PresentationDocument):
|
||||
self.presentation = None
|
||||
self.pptid = None
|
||||
self.blanked = False
|
||||
self.hidden = False
|
||||
|
||||
def load_presentation(self):
|
||||
"""
|
||||
@ -123,13 +125,11 @@ class PptviewDocument(PresentationDocument):
|
||||
rect = rendermanager.screens.current[u'size']
|
||||
rect = RECT(rect.x(), rect.y(), rect.right(), rect.bottom())
|
||||
filepath = str(self.filepath.replace(u'/', u'\\'))
|
||||
try:
|
||||
self.pptid = self.controller.process.OpenPPT(filepath, None, rect,
|
||||
str(os.path.join(self.thumbnailpath,
|
||||
self.controller.thumbnailprefix)))
|
||||
self.pptid = self.controller.process.OpenPPT(filepath, None, rect,
|
||||
str(os.path.join(self.thumbnailpath,
|
||||
self.controller.thumbnailprefix)))
|
||||
if self.pptid:
|
||||
self.stop_presentation()
|
||||
except:
|
||||
log.exception(u'Failed to load presentation')
|
||||
|
||||
def close_presentation(self):
|
||||
"""
|
||||
@ -156,7 +156,7 @@ class PptviewDocument(PresentationDocument):
|
||||
"""
|
||||
Returns true if a presentation is currently active
|
||||
"""
|
||||
return self.is_loaded()
|
||||
return self.is_loaded() and not self.hidden
|
||||
|
||||
def blank_screen(self):
|
||||
"""
|
||||
@ -183,13 +183,18 @@ class PptviewDocument(PresentationDocument):
|
||||
"""
|
||||
Stops the current presentation and hides the output
|
||||
"""
|
||||
self.hidden = True
|
||||
self.controller.process.Stop(self.pptid)
|
||||
|
||||
def start_presentation(self):
|
||||
"""
|
||||
Starts a presentation from the beginning
|
||||
"""
|
||||
self.controller.process.RestartShow(self.pptid)
|
||||
if self.hidden:
|
||||
self.hidden = False
|
||||
self.controller.process.Resume(self.pptid)
|
||||
else:
|
||||
self.controller.process.RestartShow(self.pptid)
|
||||
|
||||
def get_slide_number(self):
|
||||
"""
|
||||
|
@ -23,6 +23,8 @@ This README.TXT must be distributed with the pptviewlib.dll
|
||||
|
||||
This library has a limit of 50 PowerPoints which can be opened simultaneously.
|
||||
|
||||
This project can be built with the free Microsoft Visual C++ 2008 Express Edition.
|
||||
|
||||
USAGE
|
||||
-----
|
||||
BOOL CheckInstalled(void);
|
||||
|
@ -150,7 +150,7 @@ DllExport int OpenPPT(char *filename, HWND hParentWnd, RECT rect, char *previewp
|
||||
pptviewobj[id].rect.bottom = rect.bottom;
|
||||
pptviewobj[id].rect.right = rect.right;
|
||||
}
|
||||
strcat_s(cmdline, MAX_PATH * 2, "/S \"");
|
||||
strcat_s(cmdline, MAX_PATH * 2, "/F /S \"");
|
||||
strcat_s(cmdline, MAX_PATH * 2, filename);
|
||||
strcat_s(cmdline, MAX_PATH * 2, "\"");
|
||||
memset(&si, 0, sizeof(si));
|
||||
@ -211,7 +211,7 @@ DllExport int OpenPPT(char *filename, HWND hParentWnd, RECT rect, char *previewp
|
||||
}
|
||||
DEBUG("OpenPPT: Steps %d, first slide steps %d\n",pptviewobj[id].steps,pptviewobj[id].firstSlideSteps);
|
||||
SavePPTInfo(id);
|
||||
if(pptviewobj[id].state==PPT_CLOSING){
|
||||
if(pptviewobj[id].state==PPT_CLOSING||pptviewobj[id].slideCount<=0){
|
||||
ClosePPT(id);
|
||||
id=-1;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user