forked from openlp/openlp
Presentations:
- Close presentation app down correctly - Add mode to automatically detect file type bzr-revno: 724
This commit is contained in:
commit
0baec0fd2f
@ -25,6 +25,7 @@
|
|||||||
|
|
||||||
# OOo API documentation:
|
# OOo API documentation:
|
||||||
# http://api.openoffice.org/docs/common/ref/com/sun/star/presentation/XSlideShowController.html
|
# http://api.openoffice.org/docs/common/ref/com/sun/star/presentation/XSlideShowController.html
|
||||||
|
# http://wiki.services.openoffice.org/wiki/Documentation/DevGuide/ProUNO/Basic/Getting_Information_about_UNO_Objects#Inspecting_interfaces_during_debugging
|
||||||
# http://docs.go-oo.org/sd/html/classsd_1_1SlideShow.html
|
# http://docs.go-oo.org/sd/html/classsd_1_1SlideShow.html
|
||||||
# http://www.oooforum.org/forum/viewtopic.phtml?t=5252
|
# http://www.oooforum.org/forum/viewtopic.phtml?t=5252
|
||||||
# http://wiki.services.openoffice.org/wiki/Documentation/DevGuide/Working_with_Presentations
|
# http://wiki.services.openoffice.org/wiki/Documentation/DevGuide/Working_with_Presentations
|
||||||
@ -62,7 +63,8 @@ class ImpressController(PresentationController):
|
|||||||
"""
|
"""
|
||||||
log.debug(u'Initialising')
|
log.debug(u'Initialising')
|
||||||
PresentationController.__init__(self, plugin, u'Impress')
|
PresentationController.__init__(self, plugin, u'Impress')
|
||||||
self.supports = [u'.odp', u'.ppt', u'.pps', u'.pptx', u'.ppsx']
|
self.supports = [u'.odp']
|
||||||
|
self.alsosupports = [u'.ppt', u'.pps', u'.pptx', u'.ppsx']
|
||||||
self.process = None
|
self.process = None
|
||||||
self.desktop = None
|
self.desktop = None
|
||||||
|
|
||||||
@ -145,10 +147,17 @@ class ImpressController(PresentationController):
|
|||||||
doc.close_presentation()
|
doc.close_presentation()
|
||||||
if os.name != u'nt':
|
if os.name != u'nt':
|
||||||
desktop = self.get_uno_desktop()
|
desktop = self.get_uno_desktop()
|
||||||
|
else:
|
||||||
|
desktop = self.get_com_desktop()
|
||||||
|
docs = desktop.getComponents()
|
||||||
|
if docs.hasElements():
|
||||||
|
log.debug(u'OpenOffice not terminated')
|
||||||
|
else:
|
||||||
try:
|
try:
|
||||||
desktop.terminate()
|
desktop.terminate()
|
||||||
|
log.debug(u'OpenOffice killed')
|
||||||
except:
|
except:
|
||||||
pass
|
log.exception(u'Failed to terminate OpenOffice')
|
||||||
|
|
||||||
def add_doc(self, name):
|
def add_doc(self, name):
|
||||||
log.debug(u'Add Doc OpenOffice')
|
log.debug(u'Add Doc OpenOffice')
|
||||||
|
@ -56,7 +56,7 @@ class PresentationMediaItem(MediaManagerItem):
|
|||||||
# be instanced by the base MediaManagerItem
|
# be instanced by the base MediaManagerItem
|
||||||
self.ListViewWithDnD_class = PresentationListView
|
self.ListViewWithDnD_class = PresentationListView
|
||||||
MediaManagerItem.__init__(self, parent, icon, title)
|
MediaManagerItem.__init__(self, parent, icon, title)
|
||||||
self.message_listener = MessageListener(controllers)
|
self.message_listener = MessageListener(self)
|
||||||
|
|
||||||
def initPluginNameVisible(self):
|
def initPluginNameVisible(self):
|
||||||
self.PluginNameVisible = self.trUtf8('Presentation')
|
self.PluginNameVisible = self.trUtf8('Presentation')
|
||||||
@ -66,7 +66,8 @@ class PresentationMediaItem(MediaManagerItem):
|
|||||||
fileType = u''
|
fileType = u''
|
||||||
for controller in self.controllers:
|
for controller in self.controllers:
|
||||||
if self.controllers[controller].enabled:
|
if self.controllers[controller].enabled:
|
||||||
for type in self.controllers[controller].supports:
|
types = self.controllers[controller].supports + self.controllers[controller].alsosupports
|
||||||
|
for type in types:
|
||||||
if fileType.find(type) == -1:
|
if fileType.find(type) == -1:
|
||||||
fileType += u'*%s ' % type
|
fileType += u'*%s ' % type
|
||||||
self.OnNewFileMasks = self.trUtf8('Presentations (%s)' % fileType)
|
self.OnNewFileMasks = self.trUtf8('Presentations (%s)' % fileType)
|
||||||
@ -106,6 +107,9 @@ class PresentationMediaItem(MediaManagerItem):
|
|||||||
#load the drop down selection
|
#load the drop down selection
|
||||||
if self.controllers[item].enabled:
|
if self.controllers[item].enabled:
|
||||||
self.DisplayTypeComboBox.addItem(item)
|
self.DisplayTypeComboBox.addItem(item)
|
||||||
|
if self.DisplayTypeComboBox.count() > 1:
|
||||||
|
self.DisplayTypeComboBox.insertItem(0, u'Automatic')
|
||||||
|
self.DisplayTypeComboBox.setCurrentIndex(0)
|
||||||
|
|
||||||
def loadList(self, list):
|
def loadList(self, list):
|
||||||
currlist = self.getFileList()
|
currlist = self.getFileList()
|
||||||
@ -145,10 +149,16 @@ class PresentationMediaItem(MediaManagerItem):
|
|||||||
return False
|
return False
|
||||||
service_item.title = unicode(self.DisplayTypeComboBox.currentText())
|
service_item.title = unicode(self.DisplayTypeComboBox.currentText())
|
||||||
service_item.shortname = unicode(self.DisplayTypeComboBox.currentText())
|
service_item.shortname = unicode(self.DisplayTypeComboBox.currentText())
|
||||||
controller = self.controllers[service_item.shortname]
|
shortname = service_item.shortname
|
||||||
|
|
||||||
for item in items:
|
for item in items:
|
||||||
bitem = self.ListView.item(item.row())
|
bitem = self.ListView.item(item.row())
|
||||||
filename = unicode((bitem.data(QtCore.Qt.UserRole)).toString())
|
filename = unicode((bitem.data(QtCore.Qt.UserRole)).toString())
|
||||||
|
if shortname==u'Automatic':
|
||||||
|
service_item.shortname = self.findControllerByType(filename)
|
||||||
|
if not service_item.shortname:
|
||||||
|
return False
|
||||||
|
controller = self.controllers[service_item.shortname]
|
||||||
(path, name) = os.path.split(filename)
|
(path, name) = os.path.split(filename)
|
||||||
doc = controller.add_doc(filename)
|
doc = controller.add_doc(filename)
|
||||||
if doc.get_slide_preview_file(1) is None:
|
if doc.get_slide_preview_file(1) is None:
|
||||||
@ -159,5 +169,19 @@ class PresentationMediaItem(MediaManagerItem):
|
|||||||
service_item.add_from_command(path, name, img)
|
service_item.add_from_command(path, name, img)
|
||||||
i = i + 1
|
i = i + 1
|
||||||
img = doc.get_slide_preview_file(i)
|
img = doc.get_slide_preview_file(i)
|
||||||
controller.remove_doc(doc)
|
controller.remove_doc(doc)
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
def findControllerByType(self, filename):
|
||||||
|
filetype = os.path.splitext(filename)[1]
|
||||||
|
if not filetype:
|
||||||
|
return None
|
||||||
|
for controller in self.controllers:
|
||||||
|
if self.controllers[controller].enabled:
|
||||||
|
if filetype in self.controllers[controller].supports:
|
||||||
|
return controller
|
||||||
|
for controller in self.controllers:
|
||||||
|
if self.controllers[controller].enabled:
|
||||||
|
if filetype in self.controllers[controller].alsosupports:
|
||||||
|
return controller
|
||||||
|
return None
|
||||||
|
@ -154,8 +154,9 @@ class MessageListener(object):
|
|||||||
"""
|
"""
|
||||||
log.info(u'Message Listener loaded')
|
log.info(u'Message Listener loaded')
|
||||||
|
|
||||||
def __init__(self, controllers):
|
def __init__(self, mediaitem):
|
||||||
self.controllers = controllers
|
self.controllers = mediaitem.controllers
|
||||||
|
self.mediaitem = mediaitem
|
||||||
self.previewHandler = Controller(False)
|
self.previewHandler = Controller(False)
|
||||||
self.liveHandler = Controller(True)
|
self.liveHandler = Controller(True)
|
||||||
# messages are sent from core.ui.slidecontroller
|
# messages are sent from core.ui.slidecontroller
|
||||||
@ -188,6 +189,12 @@ class MessageListener(object):
|
|||||||
"""
|
"""
|
||||||
log.debug(u'Startup called with message %s' % message)
|
log.debug(u'Startup called with message %s' % message)
|
||||||
self.handler, file, isLive = self.decodeMessage(message)
|
self.handler, file, isLive = self.decodeMessage(message)
|
||||||
|
filetype = os.path.splitext(file)[1][1:]
|
||||||
|
if self.handler==u'Automatic':
|
||||||
|
self.handler = self.mediaitem.findControllerByType(file)
|
||||||
|
if not self.handler:
|
||||||
|
return
|
||||||
|
|
||||||
if isLive:
|
if isLive:
|
||||||
self.liveHandler.addHandler(self.controllers[self.handler], file)
|
self.liveHandler.addHandler(self.controllers[self.handler], file)
|
||||||
else:
|
else:
|
||||||
|
@ -52,7 +52,7 @@ class PowerpointController(PresentationController):
|
|||||||
"""
|
"""
|
||||||
log.debug(u'Initialising')
|
log.debug(u'Initialising')
|
||||||
PresentationController.__init__(self, plugin, u'Powerpoint')
|
PresentationController.__init__(self, plugin, u'Powerpoint')
|
||||||
self.supports = [u'.ppt', u'.pps']
|
self.supports = [u'.ppt', u'.pps', u'.pptx', u'.ppsx']
|
||||||
self.process = None
|
self.process = None
|
||||||
|
|
||||||
def check_available(self):
|
def check_available(self):
|
||||||
@ -100,6 +100,8 @@ class PowerpointController(PresentationController):
|
|||||||
doc.close_presentation()
|
doc.close_presentation()
|
||||||
if self.process is None:
|
if self.process is None:
|
||||||
return
|
return
|
||||||
|
if self.process.Presentations.Count > 0:
|
||||||
|
return
|
||||||
try:
|
try:
|
||||||
self.process.Quit()
|
self.process.Quit()
|
||||||
except:
|
except:
|
||||||
|
@ -49,7 +49,7 @@ class PptviewController(PresentationController):
|
|||||||
log.debug(u'Initialising')
|
log.debug(u'Initialising')
|
||||||
self.process = None
|
self.process = None
|
||||||
PresentationController.__init__(self, plugin, u'Powerpoint Viewer')
|
PresentationController.__init__(self, plugin, u'Powerpoint Viewer')
|
||||||
self.supports = [u'.ppt', u'.pps']
|
self.supports = [u'.ppt', u'.pps', u'.pptx', u'.ppsx']
|
||||||
|
|
||||||
def check_available(self):
|
def check_available(self):
|
||||||
"""
|
"""
|
||||||
|
@ -93,6 +93,7 @@ class PresentationController(object):
|
|||||||
Name of the application, to appear in the application
|
Name of the application, to appear in the application
|
||||||
"""
|
"""
|
||||||
self.supports = []
|
self.supports = []
|
||||||
|
self.alsosupports = []
|
||||||
self.docs = []
|
self.docs = []
|
||||||
self.plugin = plugin
|
self.plugin = plugin
|
||||||
self.name = name
|
self.name = name
|
||||||
|
Loading…
Reference in New Issue
Block a user