android: Update app-specific/MIME type icons
[LibreOffice.git] / writerfilter / source / ooxml / qnametostr.py
blobe09a985701116192ebc005cc92d06390d6bac4d8
1 #!/usr/bin/env python
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/.
10 import xml.sax
11 import sys
14 class ContentHandler(xml.sax.handler.ContentHandler):
15 def __init__(self):
16 self.tokens = []
18 def startDocument(self):
19 print("""
20 #include "ooxml/resourceids.hxx"
21 #include "ooxml/QNameToString.hxx"
22 #include "unordered_map"
24 namespace writerfilter
27 #ifdef DBG_UTIL
29 /* ooxml */
30 static const std::unordered_map<Id, const char*> g_QNameToStringMap {
31 """)
33 def endDocument(self):
34 print("""
37 std::string QNameToString(Id qName)
39 auto it = g_QNameToStringMap.find(qName);
40 if (it == g_QNameToStringMap.end())
41 return std::string();
43 return it->second;
46 #endif
48 """)
50 def startElement(self, name, attrs):
51 for k, v in list(attrs.items()):
52 if k == "tokenid":
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: