summaryrefslogtreecommitdiff
path: root/libmat2/office.py
diff options
context:
space:
mode:
authorjvoisin2020-03-07 05:22:36 -0800
committerjvoisin2020-03-07 05:22:36 -0800
commitf93df85d0386ffcca524df14619f8f4e9b570e9b (patch)
tree33829a948ba697fdc0a8116a637fbd27e727b166 /libmat2/office.py
parente5b1068ed6ef304138d962b8356370ec25db2f38 (diff)
Improve a bit ppt support
Diffstat (limited to 'libmat2/office.py')
-rw-r--r--libmat2/office.py10
1 files changed, 9 insertions, 1 deletions
diff --git a/libmat2/office.py b/libmat2/office.py
index 1765896..d945f6a 100644
--- a/libmat2/office.py
+++ b/libmat2/office.py
@@ -1,3 +1,4 @@
1import uuid
1import logging 2import logging
2import os 3import os
3import re 4import re
@@ -82,7 +83,7 @@ class MSOfficeParser(ZipParser):
82 r'^(?:word|ppt)/_rels/header[0-9]*\.xml\.rels$', 83 r'^(?:word|ppt)/_rels/header[0-9]*\.xml\.rels$',
83 r'^ppt/slideLayouts/_rels/slideLayout[0-9]+\.xml\.rels$', 84 r'^ppt/slideLayouts/_rels/slideLayout[0-9]+\.xml\.rels$',
84 r'^ppt/slideLayouts/slideLayout[0-9]+\.xml$', 85 r'^ppt/slideLayouts/slideLayout[0-9]+\.xml$',
85 86 r'^(?:word|ppt)/tableStyles\.xml$',
86 # https://msdn.microsoft.com/en-us/library/dd908153(v=office.12).aspx 87 # https://msdn.microsoft.com/en-us/library/dd908153(v=office.12).aspx
87 r'^(?:word|ppt)/stylesWithEffects\.xml$', 88 r'^(?:word|ppt)/stylesWithEffects\.xml$',
88 })) 89 }))
@@ -302,6 +303,13 @@ class MSOfficeParser(ZipParser):
302 f.write(b'<?xml version="1.0" encoding="UTF-8" standalone="yes"?>') 303 f.write(b'<?xml version="1.0" encoding="UTF-8" standalone="yes"?>')
303 f.write(b'<cp:coreProperties xmlns:cp="http://schemas.openxmlformats.org/package/2006/metadata/core-properties">') 304 f.write(b'<cp:coreProperties xmlns:cp="http://schemas.openxmlformats.org/package/2006/metadata/core-properties">')
304 f.write(b'</cp:coreProperties>') 305 f.write(b'</cp:coreProperties>')
306 elif full_path.endswith('/ppt/tableStyles.xml'): # pragma: no cover
307 # This file must be present and valid,
308 # so we're removing as much as we can.
309 with open(full_path, 'wb') as f:
310 f.write(b'<?xml version="1.0">')
311 uid = str(uuid.uuid4()).encode('utf-8')
312 f.write(b'<a:tblStyleLst def="{%s}" xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main"/>' % uid)
305 313
306 if self.__remove_rsid(full_path) is False: 314 if self.__remove_rsid(full_path) is False:
307 return False 315 return False