lok: vcl: fix multiple floatwin removal case more robustly.
[LibreOffice.git] / writerfilter / source / ooxml / qnametostr.py
blob6e02d2c69f9832716efe66dd329588872b3fc85f
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 from __future__ import print_function
11 import xml.sax
12 import sys
15 class ContentHandler(xml.sax.handler.ContentHandler):
16 def __init__(self):
17 self.tokens = []
19 def startDocument(self):
20 print("""
21 #include "ooxml/resourceids.hxx"
22 #include "ooxml/QNameToString.hxx"
24 namespace writerfilter
27 void QNameToString::init()
29 #ifdef DEBUG_WRITERFILTER
30 /* ooxml */
31 """)
33 def endDocument(self):
34 print("""#endif
38 """)
40 def startElement(self, name, attrs):
41 for k, v in list(attrs.items()):
42 if k == "tokenid":
43 if v.startswith("ooxml:"):
44 token = v.replace('ooxml:', '')
45 if token not in self.tokens:
46 print(""" mMap[NS_ooxml::LN_%s] = "ooxml:%s";""" % (token, token))
47 self.tokens.append(token)
50 parser = xml.sax.make_parser()
51 parser.setContentHandler(ContentHandler())
52 parser.parse(sys.argv[1])
54 # vim:set shiftwidth=4 softtabstop=4 expandtab: