blob: 087f00c83f862d13b19015c4886a9dd4c51c6f8a (
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
48
49
50
51
52
53
54
55
56
57
58
59
60
|
#!/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 = []
self.counter = 90001
def startDocument(self):
print("""
/*
THIS FILE IS GENERATED AUTOMATICALLY! DO NOT EDIT!
*/
#ifndef INCLUDED_OOXML_RESOURCEIDS_HXX
#define INCLUDED_OOXML_RESOURCEIDS_HXX
#include <dmapper/resourcemodel.hxx>
namespace writerfilter {
namespace NS_ooxml
{""")
def endDocument(self):
print("""}
}
#endif // INCLUDED_OOXML_RESOURCEIDS_HXX""")
def startElement(self, name, attrs):
for k, v in attrs.items():
if k in ("tokenid", "sendtokenid"):
if v.startswith("ooxml:"):
token = v.replace('ooxml:', '')
if token not in self.tokens:
print(" const Id LN_%s = %s;" % (token, self.counter))
self.tokens.append(token)
self.counter += 1
parser = xml.sax.make_parser()
parser.setContentHandler(ContentHandler())
parser.parse(sys.argv[1])
# vim:set shiftwidth=4 softtabstop=4 expandtab:
|