3 # This file is part of the LibreOffice project.
5 # This Source Code Form is subject to the terms of the Mozilla Public
6 # License, v. 2.0. If a copy of the MPL was not distributed with this
7 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
14 class ContentHandler(xml
.sax
.handler
.ContentHandler
):
18 def startDocument(self
):
20 #include "ooxml/resourceids.hxx"
21 #include "ooxml/QNameToString.hxx"
22 #include "unordered_map"
24 namespace writerfilter
30 static const std::unordered_map<Id, const char*> g_QNameToStringMap {
33 def endDocument(self
):
37 std::string QNameToString(Id qName)
39 auto it = g_QNameToStringMap.find(qName);
40 if (it == g_QNameToStringMap.end())
50 def startElement(self
, name
, attrs
):
51 for k
, v
in list(attrs
.items()):
53 if v
.startswith("ooxml:"):
54 token
= v
.replace('ooxml:', '')
55 if token
not in self
.tokens
:
56 print(""" { NS_ooxml::LN_%s, "ooxml:%s" },""" % (token
, token
))
57 self
.tokens
.append(token
)
60 parser
= xml
.sax
.make_parser()
61 parser
.setContentHandler(ContentHandler())
62 parser
.parse(sys
.argv
[1])
64 # vim:set shiftwidth=4 softtabstop=4 expandtab: