Live/Preview presentation changes for Windows

This commit is contained in:
Jonathan Corwin 2010-03-02 23:15:13 +00:00
parent 743ae230a8
commit aa5f21b50d
4 changed files with 237 additions and 235 deletions

View File

@ -180,7 +180,7 @@ class ImpressDocument(PresentationDocument):
log.debug(u'Load Presentation OpenOffice')
#print "s.dsk1 ", self.desktop
if os.name == u'nt':
desktop = self.get_com_desktop()
desktop = self.controller.get_com_desktop()
if desktop is None:
self.controller.start_process()
desktop = self.controller.get_com_desktop()
@ -226,7 +226,7 @@ class ImpressDocument(PresentationDocument):
for idx in range(pages.getCount()):
page = pages.getByIndex(idx)
doc.getCurrentController().setCurrentPage(page)
path = u'%s/%s%s.png'% (thumbdir, self.thumbnailprefix,
path = u'%s/%s%s.png'% (thumbdir, self.controller.thumbnailprefix,
unicode(idx + 1))
try:
doc.storeToURL(path , props)
@ -236,7 +236,7 @@ class ImpressDocument(PresentationDocument):
def create_property(self, name, value):
log.debug(u'create property OpenOffice')
if os.name == u'nt':
prop = self.manager.Bridge_GetStruct(u'com.sun.star.beans.PropertyValue')
prop = self.controller.manager.Bridge_GetStruct(u'com.sun.star.beans.PropertyValue')
else:
prop = PropertyValue()
prop.Name = name

View File

@ -94,7 +94,7 @@ class Controller(object):
if not self.isLive:
return
self.activate()
self.doc.goto_slide(self.controller.get_slide_count())
self.doc.goto_slide(self.doc.get_slide_count())
self.doc.poll_slidenumber(self.isLive)
def next(self):

View File

@ -108,106 +108,108 @@ class PowerpointController(PresentationController):
def add_doc(self, name):
log.debug(u'Add Doc PowerPoint')
doc = PowerPointDocument(self, name)
doc = PowerpointDocument(self, name)
self.docs.append(doc)
return doc
class PowerPointDocument(PresentationDocument):
class PowerpointDocument(PresentationDocument):
def __init__(self, controller, presentation):
log.debug(u'Init Presentation PowerPoint')
self.presentation = None
self.controller = controller
self.store_filename(presentation)
def __init__(self, controller, presentation):
log.debug(u'Init Presentation Powerpoint')
self.presentation = None
self.controller = controller
self.store_filename(presentation)
def load_presentation(self):
"""
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 load_presentation(self):
"""
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')
try:
if not self.controller.process.Visible:
self.controller.start_process()
except:
self.controller.start_process()
try:
self.controller.process.Presentations.Open(self.filepath, False, False, True)
except:
return
self.presentation = self.controller.process.Presentations(self.process.Presentations.Count)
self.create_thumbnails()
``presentation``
The file name of the presentations to run.
"""
log.debug(u'LoadPresentation')
#try:
if not self.controller.process.Visible:
self.controller.start_process()
#except:
# 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()
def create_thumbnails(self):
"""
Create the thumbnail images for the current presentation.
Note an alternative and quicker method would be do
self.presentation.Slides[n].Copy()
thumbnail = QApplication.clipboard.image()
But for now we want a physical file since it makes
life easier elsewhere
"""
if self.check_thumbnails():
return
self.presentation.Export(os.path.join(self.thumbnailpath, '')
, 'png', 600, 480)
def create_thumbnails(self):
"""
Create the thumbnail images for the current presentation.
Note an alternative and quicker method would be do
self.presentation.Slides[n].Copy()
thumbnail = QApplication.clipboard.image()
But for now we want a physical file since it makes
life easier elsewhere
"""
if self.check_thumbnails():
return
self.presentation.Export(os.path.join(self.thumbnailpath, '')
, 'png', 600, 480)
def close_presentation(self):
"""
Close presentation and clean up objects
Triggerent by new object being added to SlideController orOpenLP
being shut down
"""
if self.presentation == None:
return
try:
self.presentation.Close()
except:
pass
self.presentation = None
self.controller.remove_doc(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.presentation == None:
return
try:
self.presentation.Close()
except:
pass
self.presentation = None
self.controller.remove_doc(self)
def is_active(self):
"""
Returns true if a presentation is currently active
"""
if not self.is_loaded():
def is_active(self):
"""
Returns true if a presentation is currently active
"""
if not self.controller.is_loaded():
return False
try:
if self.presentation.SlideShowWindow == None:
return False
try:
if self.presentation.SlideShowWindow == None:
return False
if self.presentation.SlideShowWindow.View == None:
return False
except:
if self.presentation.SlideShowWindow.View == None:
return False
return True
except:
return False
return True
def unblank_screen(self):
"""
Unblanks (restores) the presentationn
"""
self.presentation.SlideShowSettings.Run()
self.presentation.SlideShowWindow.View.State = 1
self.presentation.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 blank_screen(self):
"""
Blanks the screen
"""
self.presentation.SlideShowWindow.View.State = 3
def blank_screen(self):
"""
Blanks the screen
"""
self.presentation.SlideShowWindow.View.State = 3
def stop_presentation(self):
"""
Stops the current presentation and hides the output
"""
self.presentation.SlideShowWindow.View.Exit()
def stop_presentation(self):
"""
Stops the current presentation and hides the output
"""
self.presentation.SlideShowWindow.View.Exit()
if os.name == u'nt':
def start_presentation(self):
"""
Starts a presentation from the beginning
@ -222,53 +224,53 @@ class PowerpointController(PresentationController):
dpi = 96
self.presentation.SlideShowSettings.Run()
self.presentation.SlideShowWindow.View.GotoSlide(1)
rendermanager = self.plugin.render_manager
rendermanager = self.controller.plugin.render_manager
rect = rendermanager.screens.current[u'size']
self.presentation.SlideShowWindow.Top = rect.y() * 72 / dpi
self.presentation.SlideShowWindow.Height = rect.height() * 72 / dpi
self.presentation.SlideShowWindow.Left = rect.x() * 72 / dpi
self.presentation.SlideShowWindow.Width = rect.width() * 72 / dpi
def get_slide_number(self):
"""
Returns the current slide number
"""
return self.presentation.SlideShowWindow.View.CurrentShowPosition
def get_slide_number(self):
"""
Returns the current slide number
"""
return self.presentation.SlideShowWindow.View.CurrentShowPosition
def get_slide_count(self):
"""
Returns total number of slides
"""
return self.presentation.Slides.Count
def get_slide_count(self):
"""
Returns total number of slides
"""
return self.presentation.Slides.Count
def goto_slide(self, slideno):
"""
Moves to a specific slide in the presentation
"""
self.presentation.SlideShowWindow.View.GotoSlide(slideno)
def goto_slide(self, slideno):
"""
Moves to a specific slide in the presentation
"""
self.presentation.SlideShowWindow.View.GotoSlide(slideno)
def next_step(self):
"""
Triggers the next effect of slide on the running presentation
"""
self.presentation.SlideShowWindow.View.Next()
def next_step(self):
"""
Triggers the next effect of slide on the running presentation
"""
self.presentation.SlideShowWindow.View.Next()
def previous_step(self):
"""
Triggers the previous slide on the running presentation
"""
self.presentation.SlideShowWindow.View.Previous()
def previous_step(self):
"""
Triggers the previous slide on the running presentation
"""
self.presentation.SlideShowWindow.View.Previous()
def get_slide_preview_file(self, slide_no):
"""
Returns an image path containing a preview for the requested slide
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
"""
path = os.path.join(self.thumbnailpath,
self.controller.thumbnailprefix + unicode(slide_no) + u'.png')
if os.path.isfile(path):
return path
else:
return None
``slide_no``
The slide an image is required for, starting at 1
"""
path = os.path.join(self.thumbnailpath,
self.controller.thumbnailprefix + unicode(slide_no) + u'.png')
if os.path.isfile(path):
return path
else:
return None

View File

@ -98,128 +98,128 @@ class PptviewController(PresentationController):
self.docs.append(doc)
return doc
class PptViewDocument(PresentationDocument):
class PptviewDocument(PresentationDocument):
def __init__(self, controller, presentation):
log.debug(u'Init Presentation PowerPoint')
self.presentation = None
self.pptid = None
self.controller = controller
self.store_filename(presentation)
def __init__(self, controller, presentation):
log.debug(u'Init Presentation PowerPoint')
self.presentation = None
self.pptid = None
self.controller = controller
self.store_filename(presentation)
def load_presentation(self):
"""
Called when a presentation is added to the SlideController.
It builds the environment, starts communcations with the background
PptView task started earlier.
def load_presentation(self):
"""
Called when a presentation is added to the SlideController.
It builds the environment, starts communcations with the background
PptView task started earlier.
``presentation``
The file name of the presentations to run.
"""
log.debug(u'LoadPresentation')
#if self.pptid >= 0:
# self.close_presentation()
rendermanager = self.plugin.render_manager
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.thumbnailprefix)))
self.stop_presentation()
except:
log.exception(u'Failed to load presentation')
``presentation``
The file name of the presentations to run.
"""
log.debug(u'LoadPresentation')
#if self.pptid >= 0:
# self.close_presentation()
rendermanager = self.controller.plugin.render_manager
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.stop_presentation()
except:
log.exception(u'Failed to load presentation')
def close_presentation(self):
"""
Close presentation and clean up objects
Triggerent by new object being added to SlideController orOpenLP
being shut down
"""
self.process.ClosePPT(self.pptid)
self.pptid = -1
self.controller.remove_doc(self)
def close_presentation(self):
"""
Close presentation and clean up objects
Triggerent by new object being added to SlideController orOpenLP
being shut down
"""
self.controller.process.ClosePPT(self.pptid)
self.pptid = -1
self.controller.remove_doc(self)
def is_loaded(self):
"""
Returns true if a presentation is loaded
"""
if self.pptid < 0:
return False
if self.get_slide_count() < 0:
return False
return True
def is_loaded(self):
"""
Returns true if a presentation is loaded
"""
if self.pptid < 0:
return False
if self.get_slide_count() < 0:
return False
return True
def is_active(self):
"""
Returns true if a presentation is currently active
"""
return self.is_loaded()
def is_active(self):
"""
Returns true if a presentation is currently active
"""
return self.is_loaded()
def blank_screen(self):
"""
Blanks the screen
"""
self.process.Blank(self.pptid)
def blank_screen(self):
"""
Blanks the screen
"""
self.controller.process.Blank(self.pptid)
def unblank_screen(self):
"""
Unblanks (restores) the presentationn
"""
self.process.Unblank(self.pptid)
def unblank_screen(self):
"""
Unblanks (restores) the presentationn
"""
self.controller.process.Unblank(self.pptid)
def stop_presentation(self):
"""
Stops the current presentation and hides the output
"""
self.process.Stop(self.pptid)
def stop_presentation(self):
"""
Stops the current presentation and hides the output
"""
self.controller.process.Stop(self.pptid)
def start_presentation(self):
"""
Starts a presentation from the beginning
"""
self.process.RestartShow(self.pptid)
def start_presentation(self):
"""
Starts a presentation from the beginning
"""
self.controller.process.RestartShow(self.pptid)
def get_slide_number(self):
"""
Returns the current slide number
"""
return self.process.GetCurrentSlide(self.pptid)
def get_slide_number(self):
"""
Returns the current slide number
"""
return self.controller.process.GetCurrentSlide(self.pptid)
def get_slide_count(self):
"""
Returns total number of slides
"""
return self.process.GetSlideCount(self.pptid)
def get_slide_count(self):
"""
Returns total number of slides
"""
return self.controller.process.GetSlideCount(self.pptid)
def goto_slide(self, slideno):
"""
Moves to a specific slide in the presentation
"""
self.process.GotoSlide(self.pptid, slideno)
def goto_slide(self, slideno):
"""
Moves to a specific slide in the presentation
"""
self.controller.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 next_step(self):
"""
Triggers the next effect of slide on the running presentation
"""
self.controller.process.NextStep(self.pptid)
def previous_step(self):
"""
Triggers the previous slide on the running presentation
"""
self.process.PrevStep(self.pptid)
def previous_step(self):
"""
Triggers the previous slide on the running presentation
"""
self.controller.process.PrevStep(self.pptid)
def get_slide_preview_file(self, slide_no):
"""
Returns an image path containing a preview for the requested slide
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
"""
path = os.path.join(self.thumbnailpath,
self.controller.thumbnailprefix + unicode(slide_no) + u'.bmp')
if os.path.isfile(path):
return path
else:
return None
``slide_no``
The slide an image is required for, starting at 1
"""
path = os.path.join(self.thumbnailpath,
self.controller.thumbnailprefix + unicode(slide_no) + u'.bmp')
if os.path.isfile(path):
return path
else:
return None