Added support for odp for powerpoint 2007 and newer.

This commit is contained in:
Tomas Groth 2015-05-08 16:47:02 +02:00
parent b52a4e640c
commit a07b8a8f49

View File

@ -73,8 +73,18 @@ class PowerpointController(PresentationController):
if is_win(): if is_win():
try: try:
winreg.OpenKey(winreg.HKEY_CLASSES_ROOT, 'PowerPoint.Application').Close() winreg.OpenKey(winreg.HKEY_CLASSES_ROOT, 'PowerPoint.Application').Close()
try:
# Try to detect if the version is 12 (2007) or above, and if so add 'odp' as a support filetype
version_key = winreg.OpenKey(winreg.HKEY_CLASSES_ROOT, 'PowerPoint.Application\\CurVer')
tmp1, app_version_string, tmp2 = winreg.EnumValue(version_key, 0)
version_key.Close()
app_version = int(app_version_string[-2:])
if app_version >= 12:
self.also_supports = ['odp']
except (OSError, ValueError):
log.warning('Detection of powerpoint version using registry failed.')
return True return True
except WindowsError: except OSError:
pass pass
return False return False
@ -511,8 +521,12 @@ def _get_text_from_shapes(shapes):
:param shapes: A set of shapes to search for text. :param shapes: A set of shapes to search for text.
""" """
text = '' text = ''
for shape in shapes: try:
if shape.PlaceholderFormat.Type == 2: # 2 from is enum PpPlaceholderType.ppPlaceholderBody for shape in shapes:
if shape.HasTextFrame and shape.TextFrame.HasText: if shape.PlaceholderFormat.Type == 2: # 2 from is enum PpPlaceholderType.ppPlaceholderBody
text += shape.TextFrame.TextRange.Text + '\n' if shape.HasTextFrame and shape.TextFrame.HasText:
text += shape.TextFrame.TextRange.Text + '\n'
except pywintypes.com_error as e:
log.warning('Failed to extract text from powerpoint slide')
log.warning(e)
return text return text