xref: /aoo41x/main/configmgr/source/xcuparser.hxx (revision cdf0e10c)
1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir *
3*cdf0e10cSrcweir * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir *
5*cdf0e10cSrcweir * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir *
7*cdf0e10cSrcweir * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir *
9*cdf0e10cSrcweir * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir *
11*cdf0e10cSrcweir * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir *
15*cdf0e10cSrcweir * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir *
21*cdf0e10cSrcweir * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir *
26*cdf0e10cSrcweir ************************************************************************/
27*cdf0e10cSrcweir 
28*cdf0e10cSrcweir #ifndef INCLUDED_CONFIGMGR_SOURCE_XCUPARSER_HXX
29*cdf0e10cSrcweir #define INCLUDED_CONFIGMGR_SOURCE_XCUPARSER_HXX
30*cdf0e10cSrcweir 
31*cdf0e10cSrcweir #include "sal/config.h"
32*cdf0e10cSrcweir 
33*cdf0e10cSrcweir #include <stack>
34*cdf0e10cSrcweir 
35*cdf0e10cSrcweir #include "rtl/ref.hxx"
36*cdf0e10cSrcweir #include "rtl/ustring.hxx"
37*cdf0e10cSrcweir #include "xmlreader/xmlreader.hxx"
38*cdf0e10cSrcweir 
39*cdf0e10cSrcweir #include "additions.hxx"
40*cdf0e10cSrcweir #include "node.hxx"
41*cdf0e10cSrcweir #include "nodemap.hxx"
42*cdf0e10cSrcweir #include "parser.hxx"
43*cdf0e10cSrcweir #include "path.hxx"
44*cdf0e10cSrcweir #include "type.hxx"
45*cdf0e10cSrcweir #include "valueparser.hxx"
46*cdf0e10cSrcweir #include "xmldata.hxx"
47*cdf0e10cSrcweir 
48*cdf0e10cSrcweir namespace xmlreader { struct Span; }
49*cdf0e10cSrcweir 
50*cdf0e10cSrcweir namespace configmgr {
51*cdf0e10cSrcweir 
52*cdf0e10cSrcweir class GroupNode;
53*cdf0e10cSrcweir class LocalizedPropertyNode;
54*cdf0e10cSrcweir class Modifications;
55*cdf0e10cSrcweir class Partial;
56*cdf0e10cSrcweir class PropertyNode;
57*cdf0e10cSrcweir class SetNode;
58*cdf0e10cSrcweir struct Data;
59*cdf0e10cSrcweir 
60*cdf0e10cSrcweir class XcuParser: public Parser {
61*cdf0e10cSrcweir public:
62*cdf0e10cSrcweir     XcuParser(
63*cdf0e10cSrcweir         int layer, Data & data, Partial const * partial,
64*cdf0e10cSrcweir         Modifications * broadcastModifications, Additions * additions);
65*cdf0e10cSrcweir 
66*cdf0e10cSrcweir private:
67*cdf0e10cSrcweir     virtual ~XcuParser();
68*cdf0e10cSrcweir 
69*cdf0e10cSrcweir     virtual xmlreader::XmlReader::Text getTextMode();
70*cdf0e10cSrcweir 
71*cdf0e10cSrcweir     virtual bool startElement(
72*cdf0e10cSrcweir         xmlreader::XmlReader & reader, int nsId, xmlreader::Span const & name);
73*cdf0e10cSrcweir 
74*cdf0e10cSrcweir     virtual void endElement(xmlreader::XmlReader const & reader);
75*cdf0e10cSrcweir 
76*cdf0e10cSrcweir     virtual void characters(xmlreader::Span const & span);
77*cdf0e10cSrcweir 
78*cdf0e10cSrcweir     enum Operation {
79*cdf0e10cSrcweir         OPERATION_MODIFY, OPERATION_REPLACE, OPERATION_FUSE, OPERATION_REMOVE };
80*cdf0e10cSrcweir 
81*cdf0e10cSrcweir     static Operation parseOperation(xmlreader::Span const & text);
82*cdf0e10cSrcweir 
83*cdf0e10cSrcweir     void handleComponentData(xmlreader::XmlReader & reader);
84*cdf0e10cSrcweir 
85*cdf0e10cSrcweir     void handleItem(xmlreader::XmlReader & reader);
86*cdf0e10cSrcweir 
87*cdf0e10cSrcweir     void handlePropValue(xmlreader::XmlReader & reader, PropertyNode * prop);
88*cdf0e10cSrcweir 
89*cdf0e10cSrcweir     void handleLocpropValue(
90*cdf0e10cSrcweir         xmlreader::XmlReader & reader, LocalizedPropertyNode * locprop);
91*cdf0e10cSrcweir 
92*cdf0e10cSrcweir     void handleGroupProp(xmlreader::XmlReader & reader, GroupNode * group);
93*cdf0e10cSrcweir 
94*cdf0e10cSrcweir     void handleUnknownGroupProp(
95*cdf0e10cSrcweir         xmlreader::XmlReader const & reader, GroupNode * group,
96*cdf0e10cSrcweir         rtl::OUString const & name, Type type, Operation operation,
97*cdf0e10cSrcweir         bool finalized);
98*cdf0e10cSrcweir 
99*cdf0e10cSrcweir     void handlePlainGroupProp(
100*cdf0e10cSrcweir         xmlreader::XmlReader const & reader, GroupNode * group,
101*cdf0e10cSrcweir         NodeMap::iterator const & propertyIndex, rtl::OUString const & name,
102*cdf0e10cSrcweir         Type type, Operation operation, bool finalized);
103*cdf0e10cSrcweir 
104*cdf0e10cSrcweir     void handleLocalizedGroupProp(
105*cdf0e10cSrcweir         xmlreader::XmlReader const & reader, LocalizedPropertyNode * property,
106*cdf0e10cSrcweir         rtl::OUString const & name, Type type, Operation operation,
107*cdf0e10cSrcweir         bool finalized);
108*cdf0e10cSrcweir 
109*cdf0e10cSrcweir     void handleGroupNode(
110*cdf0e10cSrcweir         xmlreader::XmlReader & reader, rtl::Reference< Node > const & group);
111*cdf0e10cSrcweir 
112*cdf0e10cSrcweir     void handleSetNode(xmlreader::XmlReader & reader, SetNode * set);
113*cdf0e10cSrcweir 
114*cdf0e10cSrcweir     void recordModification(bool addition);
115*cdf0e10cSrcweir 
116*cdf0e10cSrcweir     struct State {
117*cdf0e10cSrcweir         rtl::Reference< Node > node; // empty iff ignore or <items>
118*cdf0e10cSrcweir         rtl::OUString name; // empty and ignored if !insert
119*cdf0e10cSrcweir         bool ignore;
120*cdf0e10cSrcweir         bool insert;
121*cdf0e10cSrcweir         bool locked;
122*cdf0e10cSrcweir         bool pop;
123*cdf0e10cSrcweir 
124*cdf0e10cSrcweir         inline State(bool thePop):
125*cdf0e10cSrcweir             ignore(true), insert(false), locked(false), pop(thePop)
126*cdf0e10cSrcweir         {}
127*cdf0e10cSrcweir 
128*cdf0e10cSrcweir         inline State(rtl::Reference< Node > const & theNode, bool theLocked):
129*cdf0e10cSrcweir             node(theNode), ignore(false), insert(false), locked(theLocked),
130*cdf0e10cSrcweir             pop(true)
131*cdf0e10cSrcweir         {}
132*cdf0e10cSrcweir 
133*cdf0e10cSrcweir         inline State(
134*cdf0e10cSrcweir             rtl::Reference< Node > const & theNode,
135*cdf0e10cSrcweir             rtl::OUString const & theName, bool theLocked):
136*cdf0e10cSrcweir             node(theNode), name(theName), ignore(false), insert(true),
137*cdf0e10cSrcweir             locked(theLocked), pop(true)
138*cdf0e10cSrcweir         {}
139*cdf0e10cSrcweir     };
140*cdf0e10cSrcweir 
141*cdf0e10cSrcweir     typedef std::stack< State > StateStack;
142*cdf0e10cSrcweir 
143*cdf0e10cSrcweir     ValueParser valueParser_;
144*cdf0e10cSrcweir     Data & data_;
145*cdf0e10cSrcweir     Partial const * partial_;
146*cdf0e10cSrcweir     Modifications * broadcastModifications_;
147*cdf0e10cSrcweir     Additions * additions_;
148*cdf0e10cSrcweir     bool recordModifications_;
149*cdf0e10cSrcweir     bool trackPath_;
150*cdf0e10cSrcweir     rtl::OUString componentName_;
151*cdf0e10cSrcweir     StateStack state_;
152*cdf0e10cSrcweir     Path path_;
153*cdf0e10cSrcweir };
154*cdf0e10cSrcweir 
155*cdf0e10cSrcweir }
156*cdf0e10cSrcweir 
157*cdf0e10cSrcweir #endif
158