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

View File

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

View File

@ -130,9 +130,11 @@ class PptviewDocument(PresentationDocument):
rect = rendermanager.screens.current[u'size'] rect = rendermanager.screens.current[u'size']
rect = RECT(rect.x(), rect.y(), rect.right(), rect.bottom()) rect = RECT(rect.x(), rect.y(), rect.right(), rect.bottom())
filepath = str(self.filepath.replace(u'/', u'\\')) 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, self.pptid = self.controller.process.OpenPPT(filepath, None, rect,
str(self.get_temp_folder()) + '\\') str(self.get_temp_folder()) + '\\slide')
if self.pptid: if self.pptid >= 0:
self.create_thumbnails() self.create_thumbnails()
self.stop_presentation() self.stop_presentation()
return True return True
@ -147,8 +149,8 @@ class PptviewDocument(PresentationDocument):
if self.check_thumbnails(): if self.check_thumbnails():
return return
for idx in range(self.get_slide_count()): for idx in range(self.get_slide_count()):
path = u'%s\\%s.bmp' % (self.get_temp_folder(), unicode(idx + 1)) path = u'%s\\slide%s.bmp' % (self.get_temp_folder(), unicode(idx + 1))
self.convert_image(path, idx) self.convert_thumbnail(path, idx + 1)
def close_presentation(self): def close_presentation(self):
""" """