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 <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 {
72 
73  static Operation parseOperation(xmlreader::Span const & text);
74 
76 
77  void handleItem(xmlreader::XmlReader & reader);
78 
79  void handlePropValue(xmlreader::XmlReader & reader, PropertyNode * prop);
80 
81  void handleLocpropValue(
82  xmlreader::XmlReader & reader, LocalizedPropertyNode * locprop);
83 
84  void handleGroupProp(xmlreader::XmlReader & reader, GroupNode * group);
85 
87  xmlreader::XmlReader const & reader, GroupNode const * group,
88  OUString const & name, Type type, Operation operation,
89  bool finalized);
90 
92  xmlreader::XmlReader const & reader, GroupNode * group,
93  NodeMap::iterator const & propertyIndex, std::u16string_view name,
94  Type type, Operation operation, bool finalized);
95 
98  OUString const & name, Type type, Operation operation,
99  bool finalized);
100 
101  void handleGroupNode(
102  xmlreader::XmlReader & reader, rtl::Reference< Node > const & group);
103 
104  void handleSetNode(xmlreader::XmlReader & reader, SetNode * set);
105 
106  void recordModification(bool addition);
107 
108  struct State {
109  rtl::Reference< Node > node; // empty if ignore or <items>
110  OUString name; // empty and ignored if !insert
111  bool ignore;
112  bool insert;
113  bool pop;
114 
115  static State Ignore(bool thePop) { return State(thePop); }
116 
117  static State Modify(rtl::Reference< Node > const & theNode)
118  { return State(theNode); }
119 
120  static State Insert(
121  rtl::Reference< Node > const & theNode, OUString const & theName)
122  { return State(theNode, theName); }
123 
124  private:
125  explicit State(bool thePop): ignore(true), insert(false), pop(thePop) {}
126 
127  explicit State(rtl::Reference< Node > const & theNode):
128  node(theNode), ignore(false), insert(false), pop(true)
129  {}
130 
132  rtl::Reference< Node > const & theNode, OUString const & theName):
133  node(theNode), name(theName), ignore(false), insert(true), pop(true)
134  {}
135  };
136 
139  Partial const * partial_;
144  OUString componentName_;
145  std::stack< State > state_;
146  std::vector<OUString> path_;
147 };
148 
149 }
150 
151 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
static State Modify(rtl::Reference< Node > const &theNode)
Definition: xcuparser.hxx:117
void handleGroupProp(xmlreader::XmlReader &reader, GroupNode *group)
Definition: xcuparser.cxx:548
void handleItem(xmlreader::XmlReader &reader)
Definition: xcuparser.cxx:315
static State Insert(rtl::Reference< Node > const &theNode, OUString const &theName)
Definition: xcuparser.hxx:120
void handleGroupNode(xmlreader::XmlReader &reader, rtl::Reference< Node > const &group)
Definition: xcuparser.cxx:744
void handlePropValue(xmlreader::XmlReader &reader, PropertyNode *prop)
Definition: xcuparser.cxx:377
std::stack< State > state_
Definition: xcuparser.hxx:145
ValueParser valueParser_
Definition: xcuparser.hxx:137
Modifications * broadcastModifications_
Definition: xcuparser.hxx:140
Additions * additions_
Definition: xcuparser.hxx:141
void handleLocpropValue(xmlreader::XmlReader &reader, LocalizedPropertyNode *locprop)
Definition: xcuparser.cxx:441
void handleComponentData(xmlreader::XmlReader &reader)
Definition: xcuparser.cxx:222
Partial const * partial_
Definition: xcuparser.hxx:139
std::vector< OUString > path_
Definition: xcuparser.hxx:146
std::vector< std::vector< OUString > > Additions
Definition: additions.hxx:31
static Operation parseOperation(xmlreader::Span const &text)
Definition: xcuparser.cxx:204
virtual void characters(xmlreader::Span const &span) override
Definition: xcuparser.cxx:200
void recordModification(bool addition)
Definition: xcuparser.cxx:954
exports com.sun.star.chart2. data
NodeMapImpl::iterator iterator
Definition: nodemap.hxx:37
virtual xmlreader::XmlReader::Text getTextMode() override
Definition: xcuparser.cxx:65
virtual ~XcuParser() override
Definition: xcuparser.cxx:63
void handleUnknownGroupProp(xmlreader::XmlReader const &reader, GroupNode const *group, OUString const &name, Type type, Operation operation, bool finalized)
Definition: xcuparser.cxx:616
virtual bool startElement(xmlreader::XmlReader &reader, int nsId, xmlreader::Span const &name, std::set< OUString > const *existingDependencies) override
Definition: xcuparser.cxx:69
void handleSetNode(xmlreader::XmlReader &reader, SetNode *set)
Definition: xcuparser.cxx:812
State(rtl::Reference< Node > const &theNode, OUString const &theName)
Definition: xcuparser.hxx:131
void handleLocalizedGroupProp(xmlreader::XmlReader const &reader, LocalizedPropertyNode *property, OUString const &name, Type type, Operation operation, bool finalized)
Definition: xcuparser.cxx:698
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
State(rtl::Reference< Node > const &theNode)
Definition: xcuparser.hxx:127
OUString name
Definition: components.cxx:83
static State Ignore(bool thePop)
Definition: xcuparser.hxx:115
rtl::Reference< Node > node
Definition: xcuparser.hxx:109
virtual void endElement(xmlreader::XmlReader const &reader) override
Definition: xcuparser.cxx:175
XcuParser(int layer, Data &data, Partial const *partial, Modifications *broadcastModifications, Additions *additions)
Definition: xcuparser.cxx:52