LibreOffice Module writerfilter (master) 1
resourceids.py
Go to the documentation of this file.
1#!/usr/bin/env python
2#
3# This file is part of the LibreOffice project.
4#
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/.
8#
9
10import xml.sax
11import sys
12
13
14class ContentHandler(xml.sax.handler.ContentHandler):
15 def __init__(self):
16 self.tokens = []
17 self.counter = 90001
18
19 def startDocument(self):
20 print("""
21/*
22
23 THIS FILE IS GENERATED AUTOMATICALLY! DO NOT EDIT!
24
25*/
26
27
28#ifndef INCLUDED_OOXML_RESOURCEIDS_HXX
29#define INCLUDED_OOXML_RESOURCEIDS_HXX
30
31#include <dmapper/resourcemodel.hxx>
32
33namespace writerfilter {
34
35namespace NS_ooxml
36{""")
37
38 def endDocument(self):
39 print("""}
40
41
42}
43#endif // INCLUDED_OOXML_RESOURCEIDS_HXX""")
44
45 def startElement(self, name, attrs):
46 for k, v in attrs.items():
47 if k in ("tokenid", "sendtokenid"):
48 if v.startswith("ooxml:"):
49 token = v.replace('ooxml:', '')
50 if token not in self.tokens:
51 print(" const Id LN_%s = %s;" % (token, self.counter))
52 self.tokens.append(token)
53 self.counter += 1
54
55
56parser = xml.sax.make_parser()
57parser.setContentHandler(ContentHandler())
58parser.parse(sys.argv[1])
59
60# vim:set shiftwidth=4 softtabstop=4 expandtab:
def startElement(self, name, attrs)
Definition: resourceids.py:45