nss: upgrade to release 3.73
[LibreOffice.git] / configmgr / source / xcuparser.hxx
blob9bec6a26081a5101b6187f08b2e02625ad370d09
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 #pragma once
22 #include <sal/config.h>
24 #include <set>
25 #include <stack>
27 #include <rtl/ref.hxx>
28 #include <rtl/ustring.hxx>
29 #include <xmlreader/xmlreader.hxx>
31 #include "additions.hxx"
32 #include "node.hxx"
33 #include "nodemap.hxx"
34 #include "parser.hxx"
35 #include "type.hxx"
36 #include "valueparser.hxx"
38 namespace xmlreader { struct Span; }
40 namespace configmgr {
42 class GroupNode;
43 class LocalizedPropertyNode;
44 class Modifications;
45 class Partial;
46 class PropertyNode;
47 class SetNode;
48 struct Data;
50 class XcuParser: public Parser {
51 public:
52 XcuParser(
53 int layer, Data & data, Partial const * partial,
54 Modifications * broadcastModifications, Additions * additions);
56 private:
57 virtual ~XcuParser() override;
59 virtual xmlreader::XmlReader::Text getTextMode() override;
61 virtual bool startElement(
62 xmlreader::XmlReader & reader, int nsId, xmlreader::Span const & name,
63 std::set< OUString > const * existingDependencies) override;
65 virtual void endElement(xmlreader::XmlReader const & reader) override;
67 virtual void characters(xmlreader::Span const & span) override;
69 enum Operation {
70 OPERATION_MODIFY, OPERATION_REPLACE, OPERATION_FUSE, OPERATION_REMOVE };
72 static Operation parseOperation(xmlreader::Span const & text);
74 void handleComponentData(xmlreader::XmlReader & reader);
76 void handleItem(xmlreader::XmlReader & reader);
78 void handlePropValue(xmlreader::XmlReader & reader, PropertyNode * prop);
80 void handleLocpropValue(
81 xmlreader::XmlReader & reader, LocalizedPropertyNode * locprop);
83 void handleGroupProp(xmlreader::XmlReader & reader, GroupNode * group);
85 void handleUnknownGroupProp(
86 xmlreader::XmlReader const & reader, GroupNode const * group,
87 OUString const & name, Type type, Operation operation,
88 bool finalized);
90 void handlePlainGroupProp(
91 xmlreader::XmlReader const & reader, GroupNode * group,
92 NodeMap::iterator const & propertyIndex, OUString const & name,
93 Type type, Operation operation, bool finalized);
95 void handleLocalizedGroupProp(
96 xmlreader::XmlReader const & reader, LocalizedPropertyNode * property,
97 OUString const & name, Type type, Operation operation,
98 bool finalized);
100 void handleGroupNode(
101 xmlreader::XmlReader & reader, rtl::Reference< Node > const & group);
103 void handleSetNode(xmlreader::XmlReader & reader, SetNode * set);
105 void recordModification(bool addition);
107 struct State {
108 rtl::Reference< Node > node; // empty if ignore or <items>
109 OUString name; // empty and ignored if !insert
110 bool ignore;
111 bool insert;
112 bool pop;
114 static State Ignore(bool thePop) { return State(thePop); }
116 static State Modify(rtl::Reference< Node > const & theNode)
117 { return State(theNode); }
119 static State Insert(
120 rtl::Reference< Node > const & theNode, OUString const & theName)
121 { return State(theNode, theName); }
123 private:
124 explicit State(bool thePop): ignore(true), insert(false), pop(thePop) {}
126 explicit State(rtl::Reference< Node > const & theNode):
127 node(theNode), ignore(false), insert(false), pop(true)
130 State(
131 rtl::Reference< Node > const & theNode, OUString const & theName):
132 node(theNode), name(theName), ignore(false), insert(true), pop(true)
136 ValueParser valueParser_;
137 Data & data_;
138 Partial const * partial_;
139 Modifications * broadcastModifications_;
140 Additions * additions_;
141 bool recordModifications_;
142 bool trackPath_;
143 OUString componentName_;
144 std::stack< State > state_;
145 std::vector<OUString> path_;
150 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */