openlp-core team mailing list archive
-
openlp-core team
-
Mailing list archive
-
Message #00509
[Merge] lp:~j-corwin/openlp/present into lp:openlp
Jonathan Corwin has proposed merging lp:~j-corwin/openlp/present into lp:openlp.
Requested reviews:
OpenLP Core (openlp-core)
Create images for each presentation slide, for display in the slide controller.
(Note currently created each time ppt is loaded, I will make only create as necessary in a future commit)
--
https://code.launchpad.net/~j-corwin/openlp/present/+merge/13030
Your team OpenLP Core is subscribed to branch lp:openlp.
=== modified file 'openlp/plugins/presentations/lib/impresscontroller.py'
--- openlp/plugins/presentations/lib/impresscontroller.py 2009-10-03 19:18:59 +0000
+++ openlp/plugins/presentations/lib/impresscontroller.py 2009-10-07 23:20:22 +0000
@@ -33,6 +33,7 @@
from win32com.client import Dispatch
else:
import uno
+ from com.sun.star.beans import PropertyValue
from PyQt4 import QtCore
@@ -104,19 +105,23 @@
The file name of the presentatios to the run.
"""
log.debug(u'LoadPresentation')
+ self.store_filename(presentation)
if os.name == u'nt':
desktop = self.get_com_desktop()
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:
desktop = self.get_uno_desktop()
url = uno.systemPathToFileUrl(presentation)
+ thumbdir = uno.systemPathToFileUrl(self.thumbnailpath)
if desktop is None:
return
try:
properties = []
- properties = tuple(properties)
- self.document = desktop.loadComponentFromURL(
- url, "_blank", 0, properties)
+ properties = tuple(properties)
+ doc = desktop.loadComponentFromURL(url, u'_blank', 0, properties)
+ self.document = doc
self.presentation = self.document.getPresentation()
self.presentation.Display = self.plugin.render_manager.current_display + 1
self.presentation.start()
@@ -124,6 +129,22 @@
desktop.getCurrentComponent().Presentation.getController()
except:
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):
log.debug(u'getUNODesktop')
@@ -139,8 +160,8 @@
self.startOpenoffice()
loop += 1
try:
- smgr = ctx.ServiceManager
- desktop = smgr.createInstanceWithContext(
+ self.manager = ctx.ServiceManager
+ desktop = self.manager.createInstanceWithContext(
"com.sun.star.frame.Desktop", ctx )
return desktop
except:
@@ -150,8 +171,10 @@
def get_com_desktop(self):
log.debug(u'getCOMDesktop')
try:
- smgr = self.get_com_servicemanager()
- desktop = smgr.createInstance( "com.sun.star.frame.Desktop")
+ self.manager = self.get_com_servicemanager()
+ self.manager._FlagAsMethod(u'Bridge_GetStruct')
+ self.manager._FlagAsMethod(u'Bridge_GetValueObject')
+ desktop = self.manager.createInstance(u'com.sun.star.frame.Desktop')
return desktop
except:
log.exception(u'Failed to get COM desktop')
@@ -160,7 +183,7 @@
def get_com_servicemanager(self):
log.debug(u'get_com_servicemanager')
try:
- return Dispatch("com.sun.star.ServiceManager")
+ return Dispatch(u'com.sun.star.ServiceManager')
except:
log.exception(u'Failed to get COM service manager')
return None
@@ -224,5 +247,12 @@
"""
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')
=== modified file 'openlp/plugins/presentations/lib/powerpointcontroller.py'
--- openlp/plugins/presentations/lib/powerpointcontroller.py 2009-10-03 19:18:59 +0000
+++ openlp/plugins/presentations/lib/powerpointcontroller.py 2009-10-07 23:20:22 +0000
@@ -28,6 +28,7 @@
if os.name == u'nt':
from win32com.client import Dispatch
import _winreg
+ import win32ui
from presentationcontroller import PresentationController
@@ -52,7 +53,7 @@
PresentationController.__init__(self, plugin, u'Powerpoint')
self.process = None
self.presentation = None
-
+
def check_available(self):
"""
PowerPoint is able to run on this machine
@@ -102,9 +103,14 @@
``presentation``
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.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()
def close_presentation(self):
@@ -156,8 +162,8 @@
self.presentation.SlideShowWindow.View.GotoSlide(1)
rendermanager = self.plugin.render_manager
rect = rendermanager.screen_list[rendermanager.current_display][u'size']
- dpi = 96 # This assumption is good some of the time, but not
- # all, but I don't know how to get the screen DPI yet
+ #SlideShowWindow measures its size/position by points, not pixels
+ dpi = win32ui.GetActiveWindow().GetDC().GetDeviceCaps(88)
self.presentation.SlideShowWindow.Top = rect.y() * 72 / dpi
self.presentation.SlideShowWindow.Height = rect.height() * 72 / dpi
self.presentation.SlideShowWindow.Left = rect.x() * 72 / dpi
@@ -192,3 +198,13 @@
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
+
+ ``slide_no``
+ The slide an image is required for, starting at 1
+ """
+ return os.path.join(self.thumbnailpath,
+ self.thumbnailprefix + slide_no + u'.png')
=== modified file 'openlp/plugins/presentations/lib/pptviewcontroller.py'
--- openlp/plugins/presentations/lib/pptviewcontroller.py 2009-09-30 19:26:51 +0000
+++ openlp/plugins/presentations/lib/pptviewcontroller.py 2009-10-07 23:20:22 +0000
@@ -49,9 +49,6 @@
self.process = None
PresentationController.__init__(self, plugin, u'Powerpoint Viewer')
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):
"""
@@ -105,15 +102,16 @@
The file name of the presentations to run.
"""
log.debug(u'LoadPresentation')
+ self.store_filename(presentation)
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'\\'));
+ filepath = str(presentation.replace(u'/', u'\\'));
try:
- self.pptid = self.process.OpenPPT(filename, None, rect,
- str(self.thumbnailpath))
+ self.pptid = self.process.OpenPPT(filepath, None, rect,
+ str(os.path.join(self.thumbnailpath, self.thumbnailprefix)))
except:
log.exception(u'Failed to load presentation')
@@ -200,5 +198,5 @@
The slide an image is required for, starting at 1
"""
return os.path.join(self.thumbnailpath,
- self.thumbprefix + slide_no + u'.bmp')
+ self.thumbnailprefix + slide_no + u'.bmp')
=== modified file 'openlp/plugins/presentations/lib/presentationcontroller.py'
--- openlp/plugins/presentations/lib/presentationcontroller.py 2009-10-03 19:18:59 +0000
+++ openlp/plugins/presentations/lib/presentationcontroller.py 2009-10-07 23:20:22 +0000
@@ -19,6 +19,7 @@
"""
import logging
+import os
from PyQt4 import QtCore
@@ -132,6 +133,14 @@
name, QtCore.Qt.Unchecked)) == QtCore.Qt.Checked
else:
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):
"""
@@ -159,10 +168,22 @@
Loads the presentation and starts it
``presentation``
- The file name of the presentatios to the run.
+ The file name of the presentations to the run.
"""
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):
"""
Close presentation and clean up objects
Follow ups