Compress Impress previews

This commit is contained in:
Tim Bentley 2010-04-05 12:06:37 +01:00
parent f5a9f9ed89
commit e934c7e623
5 changed files with 24 additions and 12 deletions

View File

@ -387,7 +387,7 @@ class MediaManagerItem(QtGui.QWidget):
raise NotImplementedError(u'MediaManagerItem.onDeleteClick needs to ' raise NotImplementedError(u'MediaManagerItem.onDeleteClick needs to '
u'be defined by the plugin') u'be defined by the plugin')
def generateSlideData(self, item, item1): def generateSlideData(self, service_item, item):
raise NotImplementedError(u'MediaManagerItem.generateSlideData needs ' raise NotImplementedError(u'MediaManagerItem.generateSlideData needs '
u'to be defined by the plugin') u'to be defined by the plugin')

View File

@ -121,7 +121,6 @@ class ImageMediaItem(MediaManagerItem):
def loadList(self, list): def loadList(self, list):
for file in list: for file in list:
print file
(path, filename) = os.path.split(unicode(file)) (path, filename) = os.path.split(unicode(file))
thumb = os.path.join(self.servicePath, filename) thumb = os.path.join(self.servicePath, filename)
if os.path.exists(thumb): if os.path.exists(thumb):

View File

@ -37,6 +37,8 @@ import logging
import os import os
import time import time
from openlp.core.lib import resize_image
if os.name == u'nt': if os.name == u'nt':
from win32com.client import Dispatch from win32com.client import Dispatch
else: else:
@ -239,17 +241,22 @@ class ImpressDocument(PresentationDocument):
for idx in range(pages.getCount()): for idx in range(pages.getCount()):
page = pages.getByIndex(idx) page = pages.getByIndex(idx)
doc.getCurrentController().setCurrentPage(page) doc.getCurrentController().setCurrentPage(page)
path = u'%s/%s%s.png'% (thumbdir, self.controller.thumbnailprefix, path = u'%s/%s%s.png' % (thumbdir, self.controller.thumbnailprefix,
unicode(idx + 1)) unicode(idx + 1))
try: try:
doc.storeToURL(path , props) doc.storeToURL(path , props)
preview = resize_image(path, 640, 480)
if os.path.exists(path):
os.remove(path)
preview.save(path, u'png')
except: except:
log.exception(u'%s\nUnable to store preview' % path) log.exception(u'%s - Unable to store openoffice preview' % path)
def create_property(self, name, value): def create_property(self, name, value):
log.debug(u'create property OpenOffice') log.debug(u'create property OpenOffice')
if os.name == u'nt': if os.name == u'nt':
prop = self.controller.manager.Bridge_GetStruct(u'com.sun.star.beans.PropertyValue') prop = self.controller.manager.\
Bridge_GetStruct(u'com.sun.star.beans.PropertyValue')
else: else:
prop = PropertyValue() prop = PropertyValue()
prop.Name = name prop.Name = name
@ -356,7 +363,8 @@ class ImpressDocument(PresentationDocument):
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 Returns an image path containing a preview for theimpresscontroller.py
requested slide
``slide_no`` ``slide_no``
The slide an image is required for, starting at 1 The slide an image is required for, starting at 1

View File

@ -140,10 +140,13 @@ class PresentationMediaItem(MediaManagerItem):
self.parent.config.set_list( self.parent.config.set_list(
self.ConfigSection, self.getFileList()) self.ConfigSection, self.getFileList())
filepath = unicode((item.data(QtCore.Qt.UserRole)).toString()) filepath = unicode((item.data(QtCore.Qt.UserRole)).toString())
#not sure of this has errors
#John please can you look at .
for cidx in self.controllers: for cidx in self.controllers:
doc = self.controllers[cidx].add_doc(filepath) if self.controllers[cidx].enabled:
doc.presentation_deleted() self.controllers[cidx].remove_doc(filepath)
doc.close_presentation() self.controllers[cidx].presentation_deleted()
self.controllers[cidx].close_presentation()
def generateSlideData(self, service_item, item=None): def generateSlideData(self, service_item, item=None):
items = self.ListView.selectedIndexes() items = self.ListView.selectedIndexes()

View File

@ -138,13 +138,15 @@ class PresentationController(object):
self.docs.append(doc) self.docs.append(doc)
return doc return doc
def remove_doc(self, doc): def remove_doc(self, doc=None):
""" """
Called to remove an open document from the collection Called to remove an open document from the collection
""" """
log.debug(u'remove_doc Presentation') log.debug(u'remove_doc Presentation')
self.docs.remove(doc) if doc is None:
return
if doc in self.docs:
self.docs.remove(doc)
class PresentationDocument(object): class PresentationDocument(object):
""" """