Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 : : * This file incorporates work covered by the following license notice:
10 : : *
11 : : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : : * contributor license agreements. See the NOTICE file distributed
13 : : * with this work for additional information regarding copyright
14 : : * ownership. The ASF licenses this file to you under the Apache
15 : : * License, Version 2.0 (the "License"); you may not use this file
16 : : * except in compliance with the License. You may obtain a copy of
17 : : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : : */
19 : :
20 : : #ifndef INCLUDED_CONFIGMGR_SOURCE_XCUPARSER_HXX
21 : : #define INCLUDED_CONFIGMGR_SOURCE_XCUPARSER_HXX
22 : :
23 : : #include "sal/config.h"
24 : :
25 : : #include <stack>
26 : :
27 : : #include "rtl/ref.hxx"
28 : : #include "rtl/ustring.hxx"
29 : : #include "xmlreader/xmlreader.hxx"
30 : :
31 : : #include "additions.hxx"
32 : : #include "node.hxx"
33 : : #include "nodemap.hxx"
34 : : #include "parser.hxx"
35 : : #include "path.hxx"
36 : : #include "type.hxx"
37 : : #include "valueparser.hxx"
38 : : #include "xmldata.hxx"
39 : :
40 : : namespace xmlreader { struct Span; }
41 : :
42 : : namespace configmgr {
43 : :
44 : : class GroupNode;
45 : : class LocalizedPropertyNode;
46 : : class Modifications;
47 : : class Partial;
48 : : class PropertyNode;
49 : : class SetNode;
50 : : struct Data;
51 : :
52 : : class XcuParser: public Parser {
53 : : public:
54 : : XcuParser(
55 : : int layer, Data & data, Partial const * partial,
56 : : Modifications * broadcastModifications, Additions * additions);
57 : :
58 : : private:
59 : : virtual ~XcuParser();
60 : :
61 : : virtual xmlreader::XmlReader::Text getTextMode();
62 : :
63 : : virtual bool startElement(
64 : : xmlreader::XmlReader & reader, int nsId, xmlreader::Span const & name);
65 : :
66 : : virtual void endElement(xmlreader::XmlReader const & reader);
67 : :
68 : : virtual void characters(xmlreader::Span const & span);
69 : :
70 : : enum Operation {
71 : : OPERATION_MODIFY, OPERATION_REPLACE, OPERATION_FUSE, OPERATION_REMOVE };
72 : :
73 : : static Operation parseOperation(xmlreader::Span const & text);
74 : :
75 : : void handleComponentData(xmlreader::XmlReader & reader);
76 : :
77 : : void handleItem(xmlreader::XmlReader & reader);
78 : :
79 : : void handlePropValue(xmlreader::XmlReader & reader, PropertyNode * prop);
80 : :
81 : : void handleLocpropValue(
82 : : xmlreader::XmlReader & reader, LocalizedPropertyNode * locprop);
83 : :
84 : : void handleGroupProp(xmlreader::XmlReader & reader, GroupNode * group);
85 : :
86 : : void handleUnknownGroupProp(
87 : : xmlreader::XmlReader const & reader, GroupNode * group,
88 : : rtl::OUString const & name, Type type, Operation operation,
89 : : bool finalized);
90 : :
91 : : void handlePlainGroupProp(
92 : : xmlreader::XmlReader const & reader, GroupNode * group,
93 : : NodeMap::iterator const & propertyIndex, rtl::OUString const & name,
94 : : Type type, Operation operation, bool finalized);
95 : :
96 : : void handleLocalizedGroupProp(
97 : : xmlreader::XmlReader const & reader, LocalizedPropertyNode * property,
98 : : rtl::OUString const & name, Type type, Operation operation,
99 : : bool finalized);
100 : :
101 : : void handleGroupNode(
102 : : xmlreader::XmlReader & reader, rtl::Reference< Node > const & group);
103 : :
104 : : void handleSetNode(xmlreader::XmlReader & reader, SetNode * set);
105 : :
106 : : void recordModification(bool addition);
107 : :
108 : 27580404 : struct State {
109 : : rtl::Reference< Node > node; // empty iff ignore or <items>
110 : : rtl::OUString name; // empty and ignored if !insert
111 : : bool ignore;
112 : : bool insert;
113 : : bool locked;
114 : : bool pop;
115 : :
116 : 8791 : inline State(bool thePop):
117 : 8791 : ignore(true), insert(false), locked(false), pop(thePop)
118 : 8791 : {}
119 : :
120 : 6597582 : inline State(rtl::Reference< Node > const & theNode, bool theLocked):
121 : : node(theNode), ignore(false), insert(false), locked(theLocked),
122 : 6597582 : pop(true)
123 : 6597582 : {}
124 : :
125 : 2587095 : inline State(
126 : : rtl::Reference< Node > const & theNode,
127 : : rtl::OUString const & theName, bool theLocked):
128 : : node(theNode), name(theName), ignore(false), insert(true),
129 : 2587095 : locked(theLocked), pop(true)
130 : 2587095 : {}
131 : : };
132 : :
133 : : typedef std::stack< State > StateStack;
134 : :
135 : : ValueParser valueParser_;
136 : : Data & data_;
137 : : Partial const * partial_;
138 : : Modifications * broadcastModifications_;
139 : : Additions * additions_;
140 : : bool recordModifications_;
141 : : bool trackPath_;
142 : : rtl::OUString componentName_;
143 : : StateStack state_;
144 : : Path path_;
145 : : };
146 : :
147 : : }
148 : :
149 : : #endif
150 : :
151 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|