xref: /aoo4110/main/configmgr/source/xcuparser.hxx (revision b1cdbd2c)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #ifndef INCLUDED_CONFIGMGR_SOURCE_XCUPARSER_HXX
25 #define INCLUDED_CONFIGMGR_SOURCE_XCUPARSER_HXX
26 
27 #include "sal/config.h"
28 
29 #include <stack>
30 
31 #include "rtl/ref.hxx"
32 #include "rtl/ustring.hxx"
33 #include "xmlreader/xmlreader.hxx"
34 
35 #include "additions.hxx"
36 #include "node.hxx"
37 #include "nodemap.hxx"
38 #include "parser.hxx"
39 #include "path.hxx"
40 #include "type.hxx"
41 #include "valueparser.hxx"
42 #include "xmldata.hxx"
43 
44 namespace xmlreader { struct Span; }
45 
46 namespace configmgr {
47 
48 class GroupNode;
49 class LocalizedPropertyNode;
50 class Modifications;
51 class Partial;
52 class PropertyNode;
53 class SetNode;
54 struct Data;
55 
56 class XcuParser: public Parser {
57 public:
58     XcuParser(
59         int layer, Data & data, Partial const * partial,
60         Modifications * broadcastModifications, Additions * additions);
61 
62 private:
63     virtual ~XcuParser();
64 
65     virtual xmlreader::XmlReader::Text getTextMode();
66 
67     virtual bool startElement(
68         xmlreader::XmlReader & reader, int nsId, xmlreader::Span const & name);
69 
70     virtual void endElement(xmlreader::XmlReader const & reader);
71 
72     virtual void characters(xmlreader::Span const & span);
73 
74     enum Operation {
75         OPERATION_MODIFY, OPERATION_REPLACE, OPERATION_FUSE, OPERATION_REMOVE };
76 
77     static Operation parseOperation(xmlreader::Span const & text);
78 
79     void handleComponentData(xmlreader::XmlReader & reader);
80 
81     void handleItem(xmlreader::XmlReader & reader);
82 
83     void handlePropValue(xmlreader::XmlReader & reader, PropertyNode * prop);
84 
85     void handleLocpropValue(
86         xmlreader::XmlReader & reader, LocalizedPropertyNode * locprop);
87 
88     void handleGroupProp(xmlreader::XmlReader & reader, GroupNode * group);
89 
90     void handleUnknownGroupProp(
91         xmlreader::XmlReader const & reader, GroupNode * group,
92         rtl::OUString const & name, Type type, Operation operation,
93         bool finalized);
94 
95     void handlePlainGroupProp(
96         xmlreader::XmlReader const & reader, GroupNode * group,
97         NodeMap::iterator const & propertyIndex, rtl::OUString const & name,
98         Type type, Operation operation, bool finalized);
99 
100     void handleLocalizedGroupProp(
101         xmlreader::XmlReader const & reader, LocalizedPropertyNode * property,
102         rtl::OUString const & name, Type type, Operation operation,
103         bool finalized);
104 
105     void handleGroupNode(
106         xmlreader::XmlReader & reader, rtl::Reference< Node > const & group);
107 
108     void handleSetNode(xmlreader::XmlReader & reader, SetNode * set);
109 
110     void recordModification(bool addition);
111 
112     struct State {
113         rtl::Reference< Node > node; // empty iff ignore or <items>
114         rtl::OUString name; // empty and ignored if !insert
115         bool ignore;
116         bool insert;
117         bool locked;
118         bool pop;
119 
Stateconfigmgr::XcuParser::State120         inline State(bool thePop):
121             ignore(true), insert(false), locked(false), pop(thePop)
122         {}
123 
Stateconfigmgr::XcuParser::State124         inline State(rtl::Reference< Node > const & theNode, bool theLocked):
125             node(theNode), ignore(false), insert(false), locked(theLocked),
126             pop(true)
127         {}
128 
Stateconfigmgr::XcuParser::State129         inline State(
130             rtl::Reference< Node > const & theNode,
131             rtl::OUString const & theName, bool theLocked):
132             node(theNode), name(theName), ignore(false), insert(true),
133             locked(theLocked), pop(true)
134         {}
135     };
136 
137     typedef std::stack< State > StateStack;
138 
139     ValueParser valueParser_;
140     Data & data_;
141     Partial const * partial_;
142     Modifications * broadcastModifications_;
143     Additions * additions_;
144     bool recordModifications_;
145     bool trackPath_;
146     rtl::OUString componentName_;
147     StateStack state_;
148     Path path_;
149 };
150 
151 }
152 
153 #endif
154