1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 .
22 #include <sal/config.h>
26 #include <string_view>
28 #include <rtl/ref.hxx>
29 #include <rtl/ustring.hxx>
30 #include <xmlreader/xmlreader.hxx>
32 #include "additions.hxx"
34 #include "nodemap.hxx"
37 #include "valueparser.hxx"
39 namespace xmlreader
{ struct Span
; }
44 class LocalizedPropertyNode
;
51 class XcuParser
: public Parser
{
54 int layer
, Data
& data
, Partial
const * partial
,
55 Modifications
* broadcastModifications
, Additions
* additions
);
58 virtual ~XcuParser() override
;
60 virtual xmlreader::XmlReader::Text
getTextMode() override
;
62 virtual bool startElement(
63 xmlreader::XmlReader
& reader
, int nsId
, xmlreader::Span
const & name
,
64 std::set
< OUString
> const * existingDependencies
) override
;
66 virtual void endElement(xmlreader::XmlReader
const & reader
) override
;
68 virtual void characters(xmlreader::Span
const & span
) override
;
71 OPERATION_MODIFY
, OPERATION_REPLACE
, OPERATION_FUSE
, OPERATION_REMOVE
};
73 static Operation
parseOperation(xmlreader::Span
const & text
);
75 void handleComponentData(xmlreader::XmlReader
& reader
);
77 void handleItem(xmlreader::XmlReader
& reader
);
79 void handlePropValue(xmlreader::XmlReader
& reader
, PropertyNode
* prop
);
81 void handleLocpropValue(
82 xmlreader::XmlReader
& reader
, LocalizedPropertyNode
* locprop
);
84 void handleGroupProp(xmlreader::XmlReader
& reader
, GroupNode
* group
);
86 void handleUnknownGroupProp(
87 xmlreader::XmlReader
const & reader
, GroupNode
const * group
,
88 OUString
const & name
, Type type
, Operation operation
,
91 void handlePlainGroupProp(
92 xmlreader::XmlReader
const & reader
, GroupNode
* group
,
93 NodeMap::iterator
const & propertyIndex
, std::u16string_view name
,
94 Type type
, Operation operation
, bool finalized
);
96 void handleLocalizedGroupProp(
97 xmlreader::XmlReader
const & reader
, LocalizedPropertyNode
* property
,
98 OUString
const & name
, Type type
, Operation operation
,
101 void handleGroupNode(
102 xmlreader::XmlReader
& reader
, rtl::Reference
< Node
> const & group
);
104 void handleSetNode(xmlreader::XmlReader
& reader
, SetNode
* set
);
106 void recordModification(bool addition
);
109 rtl::Reference
< Node
> node
; // empty if ignore or <items>
110 OUString name
; // empty and ignored if !insert
115 static State
Ignore(bool thePop
) { return State(thePop
); }
117 static State
Modify(rtl::Reference
< Node
> const & theNode
)
118 { return State(theNode
); }
121 rtl::Reference
< Node
> const & theNode
, OUString
const & theName
)
122 { return State(theNode
, theName
); }
125 explicit State(bool thePop
): ignore(true), insert(false), pop(thePop
) {}
127 explicit State(rtl::Reference
< Node
> const & theNode
):
128 node(theNode
), ignore(false), insert(false), pop(true)
132 rtl::Reference
< Node
> const & theNode
, OUString
const & theName
):
133 node(theNode
), name(theName
), ignore(false), insert(true), pop(true)
137 ValueParser valueParser_
;
139 Partial
const * partial_
;
140 Modifications
* broadcastModifications_
;
141 Additions
* additions_
;
142 bool recordModifications_
;
144 OUString componentName_
;
145 std::stack
< State
> state_
;
146 std::vector
<OUString
> path_
;
151 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */