LibreOffice Module configmgr (master) 1
xcuparser.hxx
Go to the documentation of this file.
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 <set>
25#include <stack>
26#include <string_view>
27
28#include <rtl/ref.hxx>
29#include <rtl/ustring.hxx>
30#include <utility>
32
33#include "additions.hxx"
34#include "node.hxx"
35#include "nodemap.hxx"
36#include "parser.hxx"
37#include "type.hxx"
38#include "valueparser.hxx"
39
40namespace xmlreader { struct Span; }
41
42namespace configmgr {
43
44class GroupNode;
45class LocalizedPropertyNode;
46class Modifications;
47class Partial;
48class PropertyNode;
49class SetNode;
50struct Data;
51
52class XcuParser: public Parser {
53public:
55 int layer, Data & data, Partial const * partial,
56 Modifications * broadcastModifications, Additions * additions);
57
58private:
59 virtual ~XcuParser() override;
60
61 virtual xmlreader::XmlReader::Text getTextMode() override;
62
63 virtual bool startElement(
64 xmlreader::XmlReader & reader, int nsId, xmlreader::Span const & name,
65 std::set< OUString > const * existingDependencies) override;
66
67 virtual void endElement(xmlreader::XmlReader const & reader) override;
68
69 virtual void characters(xmlreader::Span const & span) override;
70
71 enum Operation {
73
74 static Operation parseOperation(xmlreader::Span const & text);
75
77
78 void handleItem(xmlreader::XmlReader & reader);
79
81
84
85 void handleGroupProp(xmlreader::XmlReader & reader, GroupNode * group);
86
88 xmlreader::XmlReader const & reader, GroupNode const * group,
89 OUString const & name, Type type, Operation operation,
90 bool finalized);
91
93 xmlreader::XmlReader const & reader, GroupNode * group,
94 NodeMap::iterator const & propertyIndex, std::u16string_view name,
95 Type type, Operation operation, bool finalized);
96
99 OUString const & name, Type type, Operation operation,
100 bool finalized);
101
102 void handleGroupNode(
103 xmlreader::XmlReader & reader, rtl::Reference< Node > const & group);
104
105 void handleSetNode(xmlreader::XmlReader & reader, SetNode * set);
106
107 void recordModification(bool addition);
108
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;
115
116 static State Ignore(bool thePop) { return State(thePop); }
117
118 static State Modify(rtl::Reference< Node > const & theNode)
119 { return State(theNode); }
120
121 static State Insert(
122 rtl::Reference< Node > const & theNode, OUString const & theName)
123 { return State(theNode, theName); }
124
125 private:
126 explicit State(bool thePop): ignore(true), insert(false), pop(thePop) {}
127
128 explicit State(rtl::Reference< Node > theNode):
129 node(std::move(theNode)), ignore(false), insert(false), pop(true)
130 {}
131
133 rtl::Reference< Node > theNode, OUString theName):
134 node(std::move(theNode)), name(std::move(theName)), ignore(false), insert(true), pop(true)
135 {}
136 };
137
146 std::stack< State > state_;
147 std::vector<OUString> path_;
148};
149
150}
151
152/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
NodeMapImpl::iterator iterator
Definition: nodemap.hxx:37
ValueParser valueParser_
Definition: xcuparser.hxx:138
void handleLocpropValue(xmlreader::XmlReader &reader, LocalizedPropertyNode *locprop)
Definition: xcuparser.cxx:441
void handlePropValue(xmlreader::XmlReader &reader, PropertyNode *prop)
Definition: xcuparser.cxx:377
void recordModification(bool addition)
Definition: xcuparser.cxx:954
virtual void endElement(xmlreader::XmlReader const &reader) override
Definition: xcuparser.cxx:175
Partial const * partial_
Definition: xcuparser.hxx:140
void handlePlainGroupProp(xmlreader::XmlReader const &reader, GroupNode *group, NodeMap::iterator const &propertyIndex, std::u16string_view name, Type type, Operation operation, bool finalized)
Definition: xcuparser.cxx:652
void handleSetNode(xmlreader::XmlReader &reader, SetNode *set)
Definition: xcuparser.cxx:812
virtual bool startElement(xmlreader::XmlReader &reader, int nsId, xmlreader::Span const &name, std::set< OUString > const *existingDependencies) override
Definition: xcuparser.cxx:69
virtual xmlreader::XmlReader::Text getTextMode() override
Definition: xcuparser.cxx:65
void handleGroupProp(xmlreader::XmlReader &reader, GroupNode *group)
Definition: xcuparser.cxx:548
Additions * additions_
Definition: xcuparser.hxx:142
void handleComponentData(xmlreader::XmlReader &reader)
Definition: xcuparser.cxx:222
XcuParser(int layer, Data &data, Partial const *partial, Modifications *broadcastModifications, Additions *additions)
Definition: xcuparser.cxx:52
void handleUnknownGroupProp(xmlreader::XmlReader const &reader, GroupNode const *group, OUString const &name, Type type, Operation operation, bool finalized)
Definition: xcuparser.cxx:616
void handleItem(xmlreader::XmlReader &reader)
Definition: xcuparser.cxx:315
Modifications * broadcastModifications_
Definition: xcuparser.hxx:141
void handleLocalizedGroupProp(xmlreader::XmlReader const &reader, LocalizedPropertyNode *property, OUString const &name, Type type, Operation operation, bool finalized)
Definition: xcuparser.cxx:698
virtual void characters(xmlreader::Span const &span) override
Definition: xcuparser.cxx:200
void handleGroupNode(xmlreader::XmlReader &reader, rtl::Reference< Node > const &group)
Definition: xcuparser.cxx:744
std::vector< OUString > path_
Definition: xcuparser.hxx:147
std::stack< State > state_
Definition: xcuparser.hxx:146
virtual ~XcuParser() override
Definition: xcuparser.cxx:63
static Operation parseOperation(xmlreader::Span const &text)
Definition: xcuparser.cxx:204
OUString name
Definition: components.cxx:85
std::vector< std::vector< OUString > > Additions
Definition: additions.hxx:31
static State Modify(rtl::Reference< Node > const &theNode)
Definition: xcuparser.hxx:118
State(rtl::Reference< Node > theNode, OUString theName)
Definition: xcuparser.hxx:132
rtl::Reference< Node > node
Definition: xcuparser.hxx:110
static State Insert(rtl::Reference< Node > const &theNode, OUString const &theName)
Definition: xcuparser.hxx:121
static State Ignore(bool thePop)
Definition: xcuparser.hxx:116
State(rtl::Reference< Node > theNode)
Definition: xcuparser.hxx:128