blob: c201e7af1a62a9dd42a374540cbfdaa53a3dc444 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
#!/usr/bin/env python
#
# 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/.
#
from __future__ import print_function
import xml.sax
import sys
class ContentHandler(xml.sax.handler.ContentHandler):
def __init__(self):
self.tokens = {}
def startDocument(self):
print("""
#ifndef INCLUDED_OOXML_NAMESPACESIDS_HXX
#define INCLUDED_OOXML_NAMESPACESIDS_HXX
#include <sal/types.h>
namespace writerfilter {
namespace ooxml {
""")
def endDocument(self):
for alias in sorted(self.tokens.keys()):
print(self.tokens[alias])
print("""
}}
#endif //INCLUDED_OOXML_NAMESPACESIDS_HXX""")
def startElement(self, name, attrs):
if name == "namespace-alias":
token = """const sal_Int32 NMSP_%s = %s;""" % (attrs["alias"], attrs["id"])
if token not in self.tokens:
self.tokens[attrs["alias"]] = token
parser = xml.sax.make_parser()
parser.setContentHandler(ContentHandler())
parser.parse(sys.argv[1])
# vim:set shiftwidth=4 softtabstop=4 expandtab:
|