/src/libreoffice/configmgr/source/xcuparser.hxx
Line | Count | Source |
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 | | #pragma once |
21 | | |
22 | | #include <sal/config.h> |
23 | | |
24 | | #include <stack> |
25 | | #include <string_view> |
26 | | |
27 | | #include <rtl/ref.hxx> |
28 | | #include <rtl/ustring.hxx> |
29 | | #include <utility> |
30 | | #include <xmlreader/xmlreader.hxx> |
31 | | |
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 | | |
39 | | namespace xmlreader { struct Span; } |
40 | | |
41 | | namespace configmgr { |
42 | | |
43 | | class GroupNode; |
44 | | class LocalizedPropertyNode; |
45 | | class Modifications; |
46 | | class Partial; |
47 | | class PropertyNode; |
48 | | class SetNode; |
49 | | struct Data; |
50 | | |
51 | | class XcuParser: public Parser { |
52 | | public: |
53 | | XcuParser( |
54 | | int layer, Data & data, Partial const * partial, |
55 | | Modifications * broadcastModifications, Additions * additions); |
56 | | |
57 | | private: |
58 | | virtual ~XcuParser() override; |
59 | | |
60 | | virtual xmlreader::XmlReader::Text getTextMode() override; |
61 | | |
62 | | virtual bool startElement( |
63 | | xmlreader::XmlReader & reader, int nsId, xmlreader::Span const & name, |
64 | | std::set< OUString > const * existingDependencies) override; |
65 | | |
66 | | virtual void endElement(xmlreader::XmlReader const & reader) override; |
67 | | |
68 | | virtual void characters(xmlreader::Span const & span) override; |
69 | | |
70 | | enum Operation { |
71 | | OPERATION_MODIFY, OPERATION_REPLACE, OPERATION_FUSE, OPERATION_REMOVE }; |
72 | | |
73 | | static Operation parseOperation(xmlreader::Span const & text); |
74 | | |
75 | | bool isAlreadyFinalized(int finalizedLayer) const; |
76 | | |
77 | | void handleComponentData(xmlreader::XmlReader & reader); |
78 | | |
79 | | void handleItem(xmlreader::XmlReader & reader); |
80 | | |
81 | | void handlePropValue(xmlreader::XmlReader & reader, PropertyNode * prop); |
82 | | |
83 | | void handleLocpropValue( |
84 | | xmlreader::XmlReader & reader, LocalizedPropertyNode * locprop); |
85 | | |
86 | | void handleGroupProp(xmlreader::XmlReader & reader, GroupNode * group); |
87 | | |
88 | | void handleUnknownGroupProp( |
89 | | xmlreader::XmlReader const & reader, GroupNode const * group, |
90 | | OUString const & name, Type type, Operation operation, |
91 | | bool finalized); |
92 | | |
93 | | void handlePlainGroupProp( |
94 | | xmlreader::XmlReader const & reader, GroupNode * group, |
95 | | NodeMap::iterator const & propertyIndex, std::u16string_view name, |
96 | | Type type, Operation operation, bool finalized); |
97 | | |
98 | | void handleLocalizedGroupProp( |
99 | | xmlreader::XmlReader const & reader, LocalizedPropertyNode * property, |
100 | | OUString const & name, Type type, Operation operation, |
101 | | bool finalized); |
102 | | |
103 | | void handleGroupNode( |
104 | | xmlreader::XmlReader & reader, rtl::Reference< Node > const & group); |
105 | | |
106 | | void handleSetNode(xmlreader::XmlReader & reader, SetNode * set); |
107 | | |
108 | | void recordModification(bool addition); |
109 | | |
110 | | struct State { |
111 | | rtl::Reference< Node > node; // empty if ignore or <items> |
112 | | OUString name; // empty and ignored if !insert |
113 | | bool ignore; |
114 | | bool insert; |
115 | | bool pop; |
116 | | |
117 | 0 | static State Ignore(bool thePop) { return State(thePop); } |
118 | | |
119 | | static State Modify(rtl::Reference< Node > const & theNode) |
120 | 0 | { return State(theNode); } |
121 | | |
122 | | static State Insert( |
123 | | rtl::Reference< Node > const & theNode, OUString const & theName) |
124 | 0 | { return State(theNode, theName); } |
125 | | |
126 | | private: |
127 | 0 | explicit State(bool thePop): ignore(true), insert(false), pop(thePop) {} |
128 | | |
129 | | explicit State(rtl::Reference< Node > theNode): |
130 | 0 | node(std::move(theNode)), ignore(false), insert(false), pop(true) |
131 | 0 | {} |
132 | | |
133 | | State( |
134 | | rtl::Reference< Node > theNode, OUString theName): |
135 | 0 | node(std::move(theNode)), name(std::move(theName)), ignore(false), insert(true), pop(true) |
136 | 0 | {} |
137 | | }; |
138 | | |
139 | | ValueParser valueParser_; |
140 | | Data & data_; |
141 | | Partial const * partial_; |
142 | | Modifications * broadcastModifications_; |
143 | | Additions * additions_; |
144 | | bool recordModifications_; |
145 | | bool trackPath_; |
146 | | OUString componentName_; |
147 | | std::stack< State > state_; |
148 | | std::vector<OUString> path_; |
149 | | }; |
150 | | |
151 | | } |
152 | | |
153 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |