summaryrefslogtreecommitdiffstats
path: root/helpers
diff options
context:
space:
mode:
authorOlivier Hallot <olivier.hallot@libreoffice.org>2019-04-04 17:40:02 -0300
committerOlivier Hallot <olivier.hallot@libreoffice.org>2019-04-06 16:05:06 +0200
commit12aff9b55df5cfc0282ec9ee7d359fb843291a79 (patch)
tree17864c0a147e3954263fd498fc104240a6019559 /helpers
parentCreate XSLT replacement table for missing icons (diff)
downloadhelp-12aff9b55df5cfc0282ec9ee7d359fb843291a79.tar.gz
help-12aff9b55df5cfc0282ec9ee7d359fb843291a79.zip
Add info on convert-to filter names
command line --convert-to option miss description of the internal names of the filters. The xhp file is generated by the python script based on the filter xcd's. P2: fix typo, Fix <filename>, Put modules in upercase. P3: reduce L10n workload with <embedvar> P4: Make xmllint happy again Change-Id: I455491b1f6a141688308d768b2822f051566ae53 Reviewed-on: https://gerrit.libreoffice.org/70273 Tested-by: Jenkins Reviewed-by: Olivier Hallot <olivier.hallot@libreoffice.org>
Diffstat (limited to 'helpers')
-rw-r--r--helpers/convertfilters.py108
1 files changed, 108 insertions, 0 deletions
diff --git a/helpers/convertfilters.py b/helpers/convertfilters.py
new file mode 100644
index 0000000000..85b8df7344
--- /dev/null
+++ b/helpers/convertfilters.py
@@ -0,0 +1,108 @@
+#!/usr/bin/env python3
+#
+# This file is part of the LibreOffice project.
+#
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+#
+# Run this in instdir/share/registry/
+# Requires Python 3.6 or greater.
+
+import sys
+import random
+import time
+from math import floor
+from lxml import etree
+
+modules = ["writer.xcd","calc.xcd","impress.xcd","draw.xcd","math.xcd","base.xcd","graphicfilter.xcd"]
+
+def rdm(prefix):
+ return prefix + "_id" + str(floor(random.random() * 1000) + 1) + str(int(time.time()))
+
+output = ""
+output += f'<?xml version="1.0" encoding="UTF-8"?>\n'
+output += f'<helpdocument version="1.0">\n'
+output += f'<!--\n'
+output += f' * This file is part of the LibreOffice project.\n *\n'
+output += f' * This Source Code Form is subject to the terms of the Mozilla Public\n'
+output += f' * License, v. 2.0. If a copy of the MPL was not distributed with this\n'
+output += f' * file, You can obtain one at http://mozilla.org/MPL/2.0/.\n'
+output += f' *\n'
+output += f' -->\n'
+output += f'<meta>\n'
+output += f'<topic id="convertfilters" indexer="include" status="PUBLISH">\n'
+output += f'<title id="tit" xml-lang="en-US">File Conversion Filters Tables</title>\n'
+output += f'<filename>/text/shared/guide/convertfilters.xhp</filename>\n'
+output += f'</topic>\n</meta>\n<body>\n'
+output += f'<section id="convertfilters01">\n'
+output += f'<bookmark xml-lang="en-US" branch="index" id="bm_id541554406270299">\n'
+output += f'<bookmark_value>filters;document conversion</bookmark_value>\n'
+output += f'<bookmark_value>document conversion;filters</bookmark_value>\n'
+output += f'<bookmark_value>convert-to;filters</bookmark_value>\n'
+output += f'<bookmark_value>command line document conversion;filters</bookmark_value>\n'
+output += f'<bookmark_value>module file filters</bookmark_value>\n'
+output += f'</bookmark>\n'
+output += f'<h1 id="hd_id771554399002497"><link href="text/shared/guide/convertfilters.xhp" name="conversion filter names">File Conversion Filter Names</link></h1>\n'
+output += f'<paragraph id="par_id581554399002498" role="paragraph" xml-lang="en-US"><variable id="variable name"><ahelp hid=".">Tables with filter names for command line document conversion.</ahelp></variable></paragraph>\n'
+output += f'</section>\n'
+output += f'<paragraph role="paragraph" id="par_id00tablehead"><ahelp hid="." visibility="hidden"><variable visibility="hidden" id="filtername">Filter name</variable><variable visibility="hidden" id="mediatype">Media type</variable><variable visibility="hidden" id="fileextensions">File name extensions</variable></ahelp></paragraph>\n'
+
+for module in modules:
+ tree = etree.parse(module)
+ namespaces = tree.getroot().nsmap
+ typenodes = tree.findall('oor:component-data/node[@oor:name="Types"]/node', namespaces)
+ filters = []
+
+ for type in typenodes:
+ uiname = str(type.findtext('prop[@oor:name="UIName"]/value', namespaces=namespaces))
+ mediatype = str(type.findtext('prop[@oor:name="MediaType"]/value', namespaces=namespaces))
+ extensions = str(type.findtext('prop[@oor:name="Extensions"]/value', namespaces=namespaces))
+ filters.append([uiname,mediatype,extensions])
+
+ st = sorted(filters, key=lambda x: x[0])
+ output += f'<section id="filters{module[:-4]}">\n'
+ output += f'<bookmark xml-lang="en-US" branch="index" id="bm_000{module[:-4]}">\n'
+ output += f'<bookmark_value>command line document conversion; filters for {module[:-4].upper()}</bookmark_value>\n'
+ output += f'</bookmark>\n'
+ output += f'<h2 id="hd_000{module[:-4]}">Filters for {module[:-4].upper()}</h2>\n'
+ output += f' <table id="{rdm("tbl")}">\n'
+ output += ' <tablerow>\n'
+ output += ' <tablecell>\n'
+ output += f' <paragraph role="tablehead" id="hd_111{module[:-4]}"><embedvar href="text/shared/guide/convertfilters.xhp#filtername" markup="ignore"/>'
+ output += '</paragraph>\n'
+ output += ' </tablecell>\n'
+ output += ' <tablecell>\n'
+ output += f' <paragraph role="tablehead" id="hd_222{module[:-4]}"><embedvar href="text/shared/guide/convertfilters.xhp#mediatype" markup="ignore"/>'
+ output += '</paragraph>\n'
+ output += ' </tablecell>\n'
+ output += ' <tablecell>\n'
+ output += f' <paragraph role="tablehead" id="hd_333{module[:-4]}"><embedvar href="text/shared/guide/convertfilters.xhp#fileextensions" markup="ignore"/>'
+ output += '</paragraph>\n'
+ output += ' </tablecell>\n'
+ output += ' </tablerow>\n'
+
+ for item in st:
+ output += ' <tablerow>\n'
+ output += ' <tablecell>\n'
+ output += f' <paragraph role="paragraph" id="{rdm("par")}" localize="false">'
+ output += f'{item[0]}'
+ output += '</paragraph>\n'
+ output += ' </tablecell>\n'
+ output += ' <tablecell>\n'
+ output += f' <paragraph role="paragraph" id="{rdm("par")}" localize="false">'
+ output += f'{item[1]}'
+ output += '</paragraph>\n'
+ output += ' </tablecell>\n'
+ output += ' <tablecell>\n'
+ output += f' <paragraph role="paragraph" id="{rdm("par")}" localize="false">'
+ output += f'{item[2]}'
+ output += '</paragraph>\n'
+ output += ' </tablecell>\n'
+ output += ' </tablerow>\n'
+
+ output += ' </table>\n'
+ output += '</section>\n'
+
+output += f'</body>\n</helpdocument>'
+print(output)