Merge branch 'ppt-fixes' into 'master'

Powerpoint fixes

See merge request openlp/openlp!250
This commit is contained in:
Raoul Snyman 2020-10-02 04:49:49 +00:00
commit ae7ac7bf35

View File

@ -156,6 +156,16 @@ class PowerpointDocument(PresentationDocument):
trace_error_handler(log) trace_error_handler(log)
return False return False
def check_thumbnails(self):
"""
This is an overwritten method of the method in the PresentationDocument class. It adds a check for content
in self.index_map.
:return: If the thumbnail is valid
:rtype: bool
"""
return super().check_thumbnails() and bool(self.index_map)
def create_thumbnails(self): def create_thumbnails(self):
""" """
Create the thumbnail images for the current presentation. Create the thumbnail images for the current presentation.
@ -169,7 +179,7 @@ class PowerpointDocument(PresentationDocument):
""" """
log.debug('create_thumbnails') log.debug('create_thumbnails')
generate_thumbs = True generate_thumbs = True
if self.check_thumbnails(): if super().check_thumbnails():
# No need for thumbnails but we still need the index # No need for thumbnails but we still need the index
generate_thumbs = False generate_thumbs = False
key = 1 key = 1
@ -206,7 +216,7 @@ class PowerpointDocument(PresentationDocument):
""" """
log.debug('is_loaded') log.debug('is_loaded')
try: try:
if self.controller.process.Presentations.Count == 0: if self.presentation is None or self.presentation.FullName != str(self.file_path):
return False return False
except (AttributeError, pywintypes.com_error): except (AttributeError, pywintypes.com_error):
log.exception('Caught exception while in is_loaded') log.exception('Caught exception while in is_loaded')
@ -395,7 +405,7 @@ class PowerpointDocument(PresentationDocument):
# SlideShowWindow.View.CurrentShowPosition returns 0 when called when a transition is executing (in 2013) # SlideShowWindow.View.CurrentShowPosition returns 0 when called when a transition is executing (in 2013)
# So we use SlideShowWindow.View.Slide.SlideIndex unless the state is done (ppSlideShowDone = 5) # So we use SlideShowWindow.View.Slide.SlideIndex unless the state is done (ppSlideShowDone = 5)
if self.presentation.SlideShowWindow.View.State != 5: if self.presentation.SlideShowWindow.View.State != 5:
ret = self.presentation.SlideShowWindow.View.Slide.SlideNumber ret = self.presentation.SlideShowWindow.View.Slide.SlideIndex
# Do reverse lookup in the index_map to find the slide number to return # Do reverse lookup in the index_map to find the slide number to return
ret = next((key for key, slidenum in self.index_map.items() if slidenum == ret), None) ret = next((key for key, slidenum in self.index_map.items() if slidenum == ret), None)
else: else: