summaryrefslogtreecommitdiff
path: root/libmat2/office.py
diff options
context:
space:
mode:
Diffstat (limited to 'libmat2/office.py')
-rw-r--r--libmat2/office.py33
1 files changed, 0 insertions, 33 deletions
diff --git a/libmat2/office.py b/libmat2/office.py
index fc83a20..f796932 100644
--- a/libmat2/office.py
+++ b/libmat2/office.py
@@ -355,39 +355,6 @@ class MSOfficeParser(ZipParser):
355 tree.write(full_path, xml_declaration=True, encoding='utf-8') 355 tree.write(full_path, xml_declaration=True, encoding='utf-8')
356 return True 356 return True
357 357
358 @staticmethod
359 def __remove_document_comment_meta(full_path: str) -> bool:
360 try:
361 tree, namespace = _parse_xml(full_path)
362 except ET.ParseError as e: # pragma: no cover
363 logging.error("Unable to parse %s: %s", full_path, e)
364 return False
365
366 # search the docs to see if we can bail early
367 range_start = tree.find('.//w:commentRangeStart', namespace)
368 range_end = tree.find('.//w:commentRangeEnd', namespace)
369 references = tree.find('.//w:commentReference', namespace)
370 if range_start is None and range_end is None and references is None:
371 return True # No comment meta tags are present
372
373 parent_map = {c:p for p in tree.iter() for c in p}
374
375 # iterate over the elements and add them to list
376 elements_del = list()
377 for element in tree.iterfind('.//w:commentRangeStart', namespace):
378 elements_del.append(element)
379 for element in tree.iterfind('.//w:commentRangeEnd', namespace):
380 elements_del.append(element)
381 for element in tree.iterfind('.//w:commentReference', namespace):
382 elements_del.append(element)
383
384 # remove the elements
385 for element in elements_del:
386 parent_map[element].remove(element)
387
388 tree.write(full_path, xml_declaration=True, encoding='utf-8')
389 return True
390
391 def __remove_content_type_members(self, full_path: str) -> bool: 358 def __remove_content_type_members(self, full_path: str) -> bool:
392 """ The method will remove the dangling references 359 """ The method will remove the dangling references
393 form the [Content_Types].xml file, since MS office doesn't like them 360 form the [Content_Types].xml file, since MS office doesn't like them