LibreOffice Module writerfilter (master) 1
factoryinc.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
10from xml.dom import minidom
11import sys
12
13
14def createInclude(model):
15 print("""
16#ifndef INCLUDED_OOXML_FACTORY_GENERATED_HXX
17#define INCLUDED_OOXML_FACTORY_GENERATED_HXX
18
19namespace writerfilter {
20namespace ooxml {
21
22/// @cond GENERATED
23 """)
24
25 # Create namespaces.
26 counter = 1
27 for namespace in sorted([ns.getAttribute("name") for ns in model.getElementsByTagName("namespace")]):
28 print("const Id NN_%s = %s << 16;" % (namespace.replace('-', '_'), counter))
29 counter += 1
30
31 # Create defines.
32 counter = 1
33 defines = []
34 for define in sorted([ns.getAttribute("name") for ns in model.getElementsByTagName("define")]):
35 if define not in defines:
36 print("const Id DEFINE_%s = %s;" % (define, counter))
37 defines.append(define)
38 counter += 1
39 print("""/// @endcond
40}}
41
42#endif // INCLUDED_OOXML_FACTORY_GENERATED_HXX""")
43
44
45modelPath = sys.argv[1]
46model = minidom.parse(modelPath)
47createInclude(model)
48
49# vim:set shiftwidth=4 softtabstop=4 expandtab:
def createInclude(model)
Definition: factoryinc.py:14