Version 6.4.0.3, tag libreoffice-6.4.0.3
[LibreOffice.git] / writerfilter / source / ooxml / resourceids.py
blobc66a3367b5e09a01c337a92bdf2d35dcc266dc24
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 = []
18 self.counter = 90001
20 def startDocument(self):
21 print("""
24 THIS FILE IS GENERATED AUTOMATICALLY! DO NOT EDIT!
29 #ifndef INCLUDED_OOXML_RESOURCEIDS_HXX
30 #define INCLUDED_OOXML_RESOURCEIDS_HXX
32 #include <dmapper/resourcemodel.hxx>
34 namespace writerfilter {
36 namespace NS_ooxml
37 {""")
39 def endDocument(self):
40 print("""}
44 #endif // INCLUDED_OOXML_RESOURCEIDS_HXX""")
46 def startElement(self, name, attrs):
47 for k, v in attrs.items():
48 if k in ("tokenid", "sendtokenid"):
49 if v.startswith("ooxml:"):
50 token = v.replace('ooxml:', '')
51 if token not in self.tokens:
52 print(" const Id LN_%s = %s;" % (token, self.counter))
53 self.tokens.append(token)
54 self.counter += 1
57 parser = xml.sax.make_parser()
58 parser.setContentHandler(ContentHandler())
59 parser.parse(sys.argv[1])
61 # vim:set shiftwidth=4 softtabstop=4 expandtab: