diff options
author | Michael Stahl <michael.stahl@allotropia.de> | 2023-06-28 17:17:26 +0200 |
---|---|---|
committer | Michael Stahl <michael.stahl@allotropia.de> | 2023-06-28 18:33:22 +0200 |
commit | 695dac86a6862a031060793b65052fbd20f2ba7d (patch) | |
tree | 4c47da7b97881b52e66447c399c78eb530583ee6 /bin | |
parent | 52831bbdd39f37750ecb1bebb99d3cdfe4b3d315 (diff) |
flat-odf-cleanup.py: remove unused user field decls
Change-Id: I5271f975ee8bae558dc00bcf8ea778a3203bbc18
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/153719
Tested-by: Jenkins
Reviewed-by: Michael Stahl <michael.stahl@allotropia.de>
Diffstat (limited to 'bin')
-rw-r--r-- | bin/flat-odf-cleanup.py | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/bin/flat-odf-cleanup.py b/bin/flat-odf-cleanup.py index 59b0a2af16b1..39916cde3cad 100644 --- a/bin/flat-odf-cleanup.py +++ b/bin/flat-odf-cleanup.py @@ -134,7 +134,7 @@ def remove_unused(root): # 3) unused list styles - keep referenced from still used paragraph styles usedliststyles = set() for style in root.findall(".//*[@{urn:oasis:names:tc:opendocument:xmlns:style:1.0}list-style-name]"): - usedliststyles.add(style.get("{urn:oasis:names:tc:opendocument:xmlns:style:1.0}list-style-name)")) + usedliststyles.add(style.get("{urn:oasis:names:tc:opendocument:xmlns:style:1.0}list-style-name")) for list_ in root.findall(".//{urn:oasis:names:tc:opendocument:xmlns:text:1.0}list[@{urn:oasis:names:tc:opendocument:xmlns:text:1.0}style-name]"): usedliststyles.add(list_.get("{urn:oasis:names:tc:opendocument:xmlns:text:1.0}style-name")) for listitem in root.findall(".//{urn:oasis:names:tc:opendocument:xmlns:text:1.0}list-item[@{urn:oasis:names:tc:opendocument:xmlns:text:1.0}style-override]"): @@ -277,6 +277,17 @@ def remove_unused(root): print("removing paragraph-rsid from " + style.get("{urn:oasis:names:tc:opendocument:xmlns:style:1.0}name")) del tp.attrib["{http://openoffice.org/2009/office}paragraph-rsid"] + # 15) unused user field decls + useduserfields = set() + for field in root.findall(".//{urn:oasis:names:tc:opendocument:xmlns:text:1.0}user-field-get"): + useduserfields.add(field.get("{urn:oasis:names:tc:opendocument:xmlns:text:1.0}name")) + for field in root.findall(".//{urn:oasis:names:tc:opendocument:xmlns:text:1.0}user-field-input"): + useduserfields.add(field.get("{urn:oasis:names:tc:opendocument:xmlns:text:1.0}name")) + for field in root.findall(".//{urn:oasis:names:tc:opendocument:xmlns:text:1.0}user-field-decl"): + if not(field.get("{urn:oasis:names:tc:opendocument:xmlns:text:1.0}name") in useduserfields): + print("removing unused user-field-decl " + field.get("{urn:oasis:names:tc:opendocument:xmlns:text:1.0}name")) + root.find(".//{urn:oasis:names:tc:opendocument:xmlns:text:1.0}user-field-decls").remove(field) + # remove office:settings settings = root.find(".//{urn:oasis:names:tc:opendocument:xmlns:office:1.0}settings") if settings is not None: |