bump product version to 6.3.0.0.beta1
[LibreOffice.git] / configmgr / source / xcuparser.hxx
blobbd74d434c61225256cc93f55b0a907ae8cc736f0
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #ifndef INCLUDED_CONFIGMGR_SOURCE_XCUPARSER_HXX
21 #define INCLUDED_CONFIGMGR_SOURCE_XCUPARSER_HXX
23 #include <sal/config.h>
25 #include <set>
26 #include <stack>
28 #include <rtl/ref.hxx>
29 #include <rtl/ustring.hxx>
30 #include <xmlreader/xmlreader.hxx>
32 #include "additions.hxx"
33 #include "node.hxx"
34 #include "nodemap.hxx"
35 #include "parser.hxx"
36 #include "type.hxx"
37 #include "valueparser.hxx"
38 #include "xmldata.hxx"
40 namespace xmlreader { struct Span; }
42 namespace configmgr {
44 class GroupNode;
45 class LocalizedPropertyNode;
46 class Modifications;
47 class Partial;
48 class PropertyNode;
49 class SetNode;
50 struct Data;
52 class XcuParser: public Parser {
53 public:
54 XcuParser(
55 int layer, Data & data, Partial const * partial,
56 Modifications * broadcastModifications, Additions * additions);
58 private:
59 virtual ~XcuParser() override;
61 virtual xmlreader::XmlReader::Text getTextMode() override;
63 virtual bool startElement(
64 xmlreader::XmlReader & reader, int nsId, xmlreader::Span const & name,
65 std::set< OUString > const * existingDependencies) override;
67 virtual void endElement(xmlreader::XmlReader const & reader) override;
69 virtual void characters(xmlreader::Span const & span) override;
71 enum Operation {
72 OPERATION_MODIFY, OPERATION_REPLACE, OPERATION_FUSE, OPERATION_REMOVE };
74 static Operation parseOperation(xmlreader::Span const & text);
76 void handleComponentData(xmlreader::XmlReader & reader);
78 void handleItem(xmlreader::XmlReader & reader);
80 void handlePropValue(xmlreader::XmlReader & reader, PropertyNode * prop);
82 void handleLocpropValue(
83 xmlreader::XmlReader & reader, LocalizedPropertyNode * locprop);
85 void handleGroupProp(xmlreader::XmlReader & reader, GroupNode * group);
87 void handleUnknownGroupProp(
88 xmlreader::XmlReader const & reader, GroupNode const * group,
89 OUString const & name, Type type, Operation operation,
90 bool finalized);
92 void handlePlainGroupProp(
93 xmlreader::XmlReader const & reader, GroupNode * group,
94 NodeMap::iterator const & propertyIndex, OUString const & name,
95 Type type, Operation operation, bool finalized);
97 void handleLocalizedGroupProp(
98 xmlreader::XmlReader const & reader, LocalizedPropertyNode * property,
99 OUString const & name, Type type, Operation operation,
100 bool finalized);
102 void handleGroupNode(
103 xmlreader::XmlReader & reader, rtl::Reference< Node > const & group);
105 void handleSetNode(xmlreader::XmlReader & reader, SetNode * set);
107 void recordModification(bool addition);
109 struct State {
110 rtl::Reference< Node > node; // empty if ignore or <items>
111 OUString name; // empty and ignored if !insert
112 bool ignore;
113 bool insert;
114 bool pop;
116 static State Ignore(bool thePop) { return State(thePop); }
118 static State Modify(rtl::Reference< Node > const & theNode)
119 { return State(theNode); }
121 static State Insert(
122 rtl::Reference< Node > const & theNode, OUString const & theName)
123 { return State(theNode, theName); }
125 private:
126 explicit State(bool thePop): ignore(true), insert(false), pop(thePop) {}
128 explicit State(rtl::Reference< Node > const & theNode):
129 node(theNode), ignore(false), insert(false), pop(true)
132 State(
133 rtl::Reference< Node > const & theNode, OUString const & theName):
134 node(theNode), name(theName), ignore(false), insert(true), pop(true)
138 ValueParser valueParser_;
139 Data & data_;
140 Partial const * partial_;
141 Modifications * broadcastModifications_;
142 Additions * additions_;
143 bool recordModifications_;
144 bool trackPath_;
145 OUString componentName_;
146 std::stack< State > state_;
147 std::vector<OUString> path_;
152 #endif
154 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */