forked from openlp/openlp
Presentations add code but leave for now - Angels fear to tread
This commit is contained in:
commit
05fe475db0
@ -33,6 +33,7 @@ if os.name == u'nt':
|
|||||||
from win32com.client import Dispatch
|
from win32com.client import Dispatch
|
||||||
else:
|
else:
|
||||||
import uno
|
import uno
|
||||||
|
from com.sun.star.beans import PropertyValue
|
||||||
|
|
||||||
from PyQt4 import QtCore
|
from PyQt4 import QtCore
|
||||||
|
|
||||||
@ -104,19 +105,23 @@ class ImpressController(PresentationController):
|
|||||||
The file name of the presentatios to the run.
|
The file name of the presentatios to the run.
|
||||||
"""
|
"""
|
||||||
log.debug(u'LoadPresentation')
|
log.debug(u'LoadPresentation')
|
||||||
|
self.store_filename(presentation)
|
||||||
if os.name == u'nt':
|
if os.name == u'nt':
|
||||||
desktop = self.get_com_desktop()
|
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')
|
||||||
|
thumbdir = u'file:///' + self.thumbnailpath.replace(
|
||||||
|
u'\\', u'/').replace(u':', u'|').replace(u' ', u'%20')
|
||||||
else:
|
else:
|
||||||
desktop = self.get_uno_desktop()
|
desktop = self.get_uno_desktop()
|
||||||
url = uno.systemPathToFileUrl(presentation)
|
url = uno.systemPathToFileUrl(presentation)
|
||||||
|
thumbdir = uno.systemPathToFileUrl(self.thumbnailpath)
|
||||||
if desktop is None:
|
if desktop is None:
|
||||||
return
|
return
|
||||||
try:
|
try:
|
||||||
properties = []
|
properties = []
|
||||||
properties = tuple(properties)
|
properties = tuple(properties)
|
||||||
self.document = desktop.loadComponentFromURL(
|
doc = desktop.loadComponentFromURL(url, u'_blank', 0, properties)
|
||||||
url, "_blank", 0, properties)
|
self.document = doc
|
||||||
self.presentation = self.document.getPresentation()
|
self.presentation = self.document.getPresentation()
|
||||||
self.presentation.Display = self.plugin.render_manager.current_display + 1
|
self.presentation.Display = self.plugin.render_manager.current_display + 1
|
||||||
self.presentation.start()
|
self.presentation.start()
|
||||||
@ -124,6 +129,22 @@ class ImpressController(PresentationController):
|
|||||||
desktop.getCurrentComponent().Presentation.getController()
|
desktop.getCurrentComponent().Presentation.getController()
|
||||||
except:
|
except:
|
||||||
log.exception(u'Failed to load presentation')
|
log.exception(u'Failed to load presentation')
|
||||||
|
return
|
||||||
|
props = []
|
||||||
|
if os.name == u'nt':
|
||||||
|
prop = self.manager.Bridge_GetStruct(u'com.sun.star.beans.PropertyValue')
|
||||||
|
else:
|
||||||
|
prop = PropertyValue()
|
||||||
|
prop.Name = u'FilterName'
|
||||||
|
prop.Value = u'impress_png_Export'
|
||||||
|
props.append(prop)
|
||||||
|
props = tuple(props)
|
||||||
|
pages = doc.getDrawPages()
|
||||||
|
for idx in range(pages.getCount()):
|
||||||
|
page = pages.getByIndex(idx)
|
||||||
|
doc.getCurrentController().setCurrentPage(page)
|
||||||
|
doc.storeToURL(thumbdir + u'/' + self.thumbnailprefix +
|
||||||
|
unicode(idx+1) + u'.png', props)
|
||||||
|
|
||||||
def get_uno_desktop(self):
|
def get_uno_desktop(self):
|
||||||
log.debug(u'getUNODesktop')
|
log.debug(u'getUNODesktop')
|
||||||
@ -139,8 +160,8 @@ class ImpressController(PresentationController):
|
|||||||
self.startOpenoffice()
|
self.startOpenoffice()
|
||||||
loop += 1
|
loop += 1
|
||||||
try:
|
try:
|
||||||
smgr = ctx.ServiceManager
|
self.manager = ctx.ServiceManager
|
||||||
desktop = smgr.createInstanceWithContext(
|
desktop = self.manager.createInstanceWithContext(
|
||||||
"com.sun.star.frame.Desktop", ctx )
|
"com.sun.star.frame.Desktop", ctx )
|
||||||
return desktop
|
return desktop
|
||||||
except:
|
except:
|
||||||
@ -150,8 +171,10 @@ class ImpressController(PresentationController):
|
|||||||
def get_com_desktop(self):
|
def get_com_desktop(self):
|
||||||
log.debug(u'getCOMDesktop')
|
log.debug(u'getCOMDesktop')
|
||||||
try:
|
try:
|
||||||
smgr = self.get_com_servicemanager()
|
self.manager = self.get_com_servicemanager()
|
||||||
desktop = smgr.createInstance( "com.sun.star.frame.Desktop")
|
self.manager._FlagAsMethod(u'Bridge_GetStruct')
|
||||||
|
self.manager._FlagAsMethod(u'Bridge_GetValueObject')
|
||||||
|
desktop = self.manager.createInstance(u'com.sun.star.frame.Desktop')
|
||||||
return desktop
|
return desktop
|
||||||
except:
|
except:
|
||||||
log.exception(u'Failed to get COM desktop')
|
log.exception(u'Failed to get COM desktop')
|
||||||
@ -160,7 +183,7 @@ class ImpressController(PresentationController):
|
|||||||
def get_com_servicemanager(self):
|
def get_com_servicemanager(self):
|
||||||
log.debug(u'get_com_servicemanager')
|
log.debug(u'get_com_servicemanager')
|
||||||
try:
|
try:
|
||||||
return Dispatch("com.sun.star.ServiceManager")
|
return Dispatch(u'com.sun.star.ServiceManager')
|
||||||
except:
|
except:
|
||||||
log.exception(u'Failed to get COM service manager')
|
log.exception(u'Failed to get COM service manager')
|
||||||
return None
|
return None
|
||||||
@ -224,5 +247,12 @@ class ImpressController(PresentationController):
|
|||||||
"""
|
"""
|
||||||
self.controller.gotoPreviousSlide()
|
self.controller.gotoPreviousSlide()
|
||||||
|
|
||||||
# def get_slide_preview_file(self, slide_no):
|
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.thumbnailprefix + slide_no + u'.png')
|
||||||
|
@ -28,6 +28,7 @@ import logging
|
|||||||
if os.name == u'nt':
|
if os.name == u'nt':
|
||||||
from win32com.client import Dispatch
|
from win32com.client import Dispatch
|
||||||
import _winreg
|
import _winreg
|
||||||
|
import win32ui
|
||||||
|
|
||||||
from presentationcontroller import PresentationController
|
from presentationcontroller import PresentationController
|
||||||
|
|
||||||
@ -102,9 +103,14 @@ class PowerpointController(PresentationController):
|
|||||||
``presentation``
|
``presentation``
|
||||||
The file name of the presentations to run.
|
The file name of the presentations to run.
|
||||||
"""
|
"""
|
||||||
self.filename = presentation
|
log.debug(u'LoadPresentation')
|
||||||
|
self.store_filename(presentation)
|
||||||
self.process.Presentations.Open(presentation, False, False, True)
|
self.process.Presentations.Open(presentation, False, False, True)
|
||||||
self.presentation = self.process.Presentations(self.process.Presentations.Count)
|
self.presentation = self.process.Presentations(self.process.Presentations.Count)
|
||||||
|
self.presentation.Export(os.path.join(self.thumbnailpath, '')
|
||||||
|
, 'png', 600, 480)
|
||||||
|
# self.presentation.Slides[n].Copy()
|
||||||
|
# thumbnail = QClipboard.image()
|
||||||
self.start_presentation()
|
self.start_presentation()
|
||||||
|
|
||||||
def close_presentation(self):
|
def close_presentation(self):
|
||||||
@ -156,8 +162,8 @@ class PowerpointController(PresentationController):
|
|||||||
self.presentation.SlideShowWindow.View.GotoSlide(1)
|
self.presentation.SlideShowWindow.View.GotoSlide(1)
|
||||||
rendermanager = self.plugin.render_manager
|
rendermanager = self.plugin.render_manager
|
||||||
rect = rendermanager.screen_list[rendermanager.current_display][u'size']
|
rect = rendermanager.screen_list[rendermanager.current_display][u'size']
|
||||||
dpi = 96 # This assumption is good some of the time, but not
|
#SlideShowWindow measures its size/position by points, not pixels
|
||||||
# all, but I don't know how to get the screen DPI yet
|
dpi = win32ui.GetActiveWindow().GetDC().GetDeviceCaps(88)
|
||||||
self.presentation.SlideShowWindow.Top = rect.y() * 72 / dpi
|
self.presentation.SlideShowWindow.Top = rect.y() * 72 / dpi
|
||||||
self.presentation.SlideShowWindow.Height = rect.height() * 72 / dpi
|
self.presentation.SlideShowWindow.Height = rect.height() * 72 / dpi
|
||||||
self.presentation.SlideShowWindow.Left = rect.x() * 72 / dpi
|
self.presentation.SlideShowWindow.Left = rect.x() * 72 / dpi
|
||||||
@ -192,3 +198,13 @@ class PowerpointController(PresentationController):
|
|||||||
Triggers the previous slide on the running presentation
|
Triggers the previous slide on the running presentation
|
||||||
"""
|
"""
|
||||||
self.presentation.SlideShowWindow.View.Previous()
|
self.presentation.SlideShowWindow.View.Previous()
|
||||||
|
|
||||||
|
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.thumbnailprefix + slide_no + u'.png')
|
||||||
|
@ -49,9 +49,6 @@ class PptviewController(PresentationController):
|
|||||||
self.process = None
|
self.process = None
|
||||||
PresentationController.__init__(self, plugin, u'Powerpoint Viewer')
|
PresentationController.__init__(self, plugin, u'Powerpoint Viewer')
|
||||||
self.pptid = None
|
self.pptid = None
|
||||||
self.thumbnailpath = os.path.join(plugin.config.get_data_path(),
|
|
||||||
u'pptview', u'thumbnails')
|
|
||||||
self.thumbprefix = u'slide'
|
|
||||||
|
|
||||||
def check_available(self):
|
def check_available(self):
|
||||||
"""
|
"""
|
||||||
@ -105,15 +102,16 @@ class PptviewController(PresentationController):
|
|||||||
The file name of the presentations to run.
|
The file name of the presentations to run.
|
||||||
"""
|
"""
|
||||||
log.debug(u'LoadPresentation')
|
log.debug(u'LoadPresentation')
|
||||||
|
self.store_filename(presentation)
|
||||||
if self.pptid >= 0:
|
if self.pptid >= 0:
|
||||||
self.close_presentation()
|
self.close_presentation()
|
||||||
rendermanager = self.plugin.render_manager
|
rendermanager = self.plugin.render_manager
|
||||||
rect = rendermanager.screen_list[rendermanager.current_display][u'size']
|
rect = rendermanager.screen_list[rendermanager.current_display][u'size']
|
||||||
rect = RECT(rect.x(), rect.y(), rect.right(), rect.bottom())
|
rect = RECT(rect.x(), rect.y(), rect.right(), rect.bottom())
|
||||||
filename = str(presentation.replace(u'/', u'\\'));
|
filepath = str(presentation.replace(u'/', u'\\'));
|
||||||
try:
|
try:
|
||||||
self.pptid = self.process.OpenPPT(filename, None, rect,
|
self.pptid = self.process.OpenPPT(filepath, None, rect,
|
||||||
str(self.thumbnailpath))
|
str(os.path.join(self.thumbnailpath, self.thumbnailprefix)))
|
||||||
except:
|
except:
|
||||||
log.exception(u'Failed to load presentation')
|
log.exception(u'Failed to load presentation')
|
||||||
|
|
||||||
@ -200,5 +198,5 @@ class PptviewController(PresentationController):
|
|||||||
The slide an image is required for, starting at 1
|
The slide an image is required for, starting at 1
|
||||||
"""
|
"""
|
||||||
return os.path.join(self.thumbnailpath,
|
return os.path.join(self.thumbnailpath,
|
||||||
self.thumbprefix + slide_no + u'.bmp')
|
self.thumbnailprefix + slide_no + u'.bmp')
|
||||||
|
|
||||||
|
@ -19,6 +19,7 @@ Place, Suite 330, Boston, MA 02111-1307 USA
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
|
import os
|
||||||
|
|
||||||
from PyQt4 import QtCore
|
from PyQt4 import QtCore
|
||||||
|
|
||||||
@ -132,6 +133,14 @@ class PresentationController(object):
|
|||||||
name, QtCore.Qt.Unchecked)) == QtCore.Qt.Checked
|
name, QtCore.Qt.Unchecked)) == QtCore.Qt.Checked
|
||||||
else:
|
else:
|
||||||
self.enabled = False
|
self.enabled = False
|
||||||
|
self.thumbnailroot = os.path.join(plugin.config.get_data_path(),
|
||||||
|
name, u'thumbnails')
|
||||||
|
self.thumbnailprefix = u'slide'
|
||||||
|
try:
|
||||||
|
os.makedirs(self.thumbnailroot)
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
def check_available(self):
|
def check_available(self):
|
||||||
"""
|
"""
|
||||||
@ -159,10 +168,22 @@ class PresentationController(object):
|
|||||||
Loads the presentation and starts it
|
Loads the presentation and starts it
|
||||||
|
|
||||||
``presentation``
|
``presentation``
|
||||||
The file name of the presentatios to the run.
|
The file name of the presentations to the run.
|
||||||
"""
|
"""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
def store_filename(self, presentation):
|
||||||
|
"""
|
||||||
|
Set properties for the filename and thumbnail paths
|
||||||
|
"""
|
||||||
|
self.filepath = presentation
|
||||||
|
self.filename = os.path.split(presentation)[1]
|
||||||
|
self.thumbnailpath = os.path.join(self.thumbnailroot, self.filename)
|
||||||
|
try:
|
||||||
|
os.mkdir(self.thumbnailpath)
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
|
||||||
def close_presentation(self):
|
def close_presentation(self):
|
||||||
"""
|
"""
|
||||||
Close presentation and clean up objects
|
Close presentation and clean up objects
|
||||||
|
@ -51,6 +51,19 @@ class PresentationPlugin(Plugin):
|
|||||||
Create the settings Tab
|
Create the settings Tab
|
||||||
"""
|
"""
|
||||||
return PresentationTab(self.controllers)
|
return PresentationTab(self.controllers)
|
||||||
|
#
|
||||||
|
# def can_be_disabled(self):
|
||||||
|
# return True
|
||||||
|
#
|
||||||
|
# def initialise(self):
|
||||||
|
# log.info(u'Presentations Initialising')
|
||||||
|
# Plugin.initialise(self)
|
||||||
|
# self.insert_toolbox_item()
|
||||||
|
#
|
||||||
|
# def finalise(self):
|
||||||
|
# log.info(u'Plugin Finalise')
|
||||||
|
# Plugin.finalise(self)
|
||||||
|
# self.remove_toolbox_item()
|
||||||
|
|
||||||
def get_media_manager_item(self):
|
def get_media_manager_item(self):
|
||||||
"""
|
"""
|
||||||
|
Loading…
Reference in New Issue
Block a user