pptview/impress fixes to thumbnails on Windows

This commit is contained in:
Jonathan Corwin 2010-07-11 21:22:53 +01:00
parent fb4faf0dbb
commit fe5b3e6771
3 changed files with 505 additions and 493 deletions

View File

@ -74,6 +74,7 @@ class ImpressController(PresentationController):
self.alsosupports = [u'.ppt', u'.pps', u'.pptx', u'.ppsx']
self.process = None
self.desktop = None
self.manager = None
def check_available(self):
"""
@ -143,6 +144,8 @@ class ImpressController(PresentationController):
will be used to manage Impress
"""
log.debug(u'get COM Desktop OpenOffice')
if not self.manager:
return None
return self.manager.createInstance(u'com.sun.star.frame.Desktop')
def get_com_servicemanager(self):
@ -264,6 +267,8 @@ class ImpressDocument(PresentationDocument):
props = tuple(props)
doc = self.document
pages = doc.getDrawPages()
if not os.path.isdir(self.get_temp_folder()):
os.makedirs(self.get_temp_folder())
for idx in range(pages.getCount()):
page = pages.getByIndex(idx)
doc.getCurrentController().setCurrentPage(page)
@ -272,7 +277,7 @@ class ImpressDocument(PresentationDocument):
unicode(idx + 1) + u'.png')
try:
doc.storeToURL(urlpath, props)
self.convert_thumbnail(path, idx)
self.convert_thumbnail(path, idx + 1)
if os.path.exists(path):
os.remove(path)
except:

View File

@ -131,7 +131,7 @@ class PresentationMediaItem(MediaManagerItem):
self.listView.setIconSize(QtCore.QSize(88, 50))
list = SettingsManager.load_list(
self.settingsSection, u'presentations')
self.loadList(list)
self.loadList(list, True)
for item in self.controllers:
#load the drop down selection
if self.controllers[item].enabled:
@ -140,7 +140,7 @@ class PresentationMediaItem(MediaManagerItem):
self.DisplayTypeComboBox.insertItem(0, self.Automatic)
self.DisplayTypeComboBox.setCurrentIndex(0)
def loadList(self, list):
def loadList(self, list, initialLoad=False):
"""
Add presentations into the media manager
This is called both on initial load of the plugin to populate with
@ -155,6 +155,7 @@ class PresentationMediaItem(MediaManagerItem):
continue
filename = os.path.split(unicode(file))[1]
if titles.count(filename) > 0:
if not initialLoad:
QtGui.QMessageBox.critical(
self, translate('PresentationPlugin.MediaItem',
'File exists'),
@ -163,19 +164,12 @@ class PresentationMediaItem(MediaManagerItem):
QtGui.QMessageBox.Ok)
continue
controller_name = self.findControllerByType(filename)
if not controller_name:
QtGui.QMessageBox.critical(
self, translate('PresentationPlugin.MediaItem',
'Unsupported file'),
translate('PresentationPlugin.MediaItem',
'This type of presentation is not supported'),
QtGui.QMessageBox.Ok)
continue
if controller_name:
controller = self.controllers[controller_name]
doc = controller.add_doc(unicode(file))
thumb = os.path.join(doc.get_thumbnail_folder(), u'icon.png')
preview = doc.get_thumbnail_path(1, True)
if not preview:
if not preview and not initialLoad:
doc.load_presentation()
preview = doc.get_thumbnail_path(1, True)
doc.close_presentation()
@ -183,6 +177,17 @@ class PresentationMediaItem(MediaManagerItem):
icon = build_icon(thumb)
else:
icon = build_icon(u':/general/general_delete.png')
else:
if initialLoad:
icon = build_icon(u':/general/general_delete.png')
else:
QtGui.QMessageBox.critical(
self, translate('PresentationPlugin.MediaItem',
'Unsupported file'),
translate('PresentationPlugin.MediaItem',
'This type of presentation is not supported'),
QtGui.QMessageBox.Ok)
continue
item_name = QtGui.QListWidgetItem(filename)
item_name.setData(QtCore.Qt.UserRole, QtCore.QVariant(file))
item_name.setIcon(icon)

View File

@ -130,9 +130,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'\\'))
if not os.path.isdir(self.get_temp_folder()):
os.makedirs(self.get_temp_folder())
self.pptid = self.controller.process.OpenPPT(filepath, None, rect,
str(self.get_temp_folder()) + '\\')
if self.pptid:
str(self.get_temp_folder()) + '\\slide')
if self.pptid >= 0:
self.create_thumbnails()
self.stop_presentation()
return True
@ -147,8 +149,8 @@ class PptviewDocument(PresentationDocument):
if self.check_thumbnails():
return
for idx in range(self.get_slide_count()):
path = u'%s\\%s.bmp' % (self.get_temp_folder(), unicode(idx + 1))
self.convert_image(path, idx)
path = u'%s\\slide%s.bmp' % (self.get_temp_folder(), unicode(idx + 1))
self.convert_thumbnail(path, idx + 1)
def close_presentation(self):
"""