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 .
20 #ifndef INCLUDED_CONFIGMGR_SOURCE_XCUPARSER_HXX
21 #define INCLUDED_CONFIGMGR_SOURCE_XCUPARSER_HXX
23 #include <sal/config.h>
28 #include <rtl/ref.hxx>
29 #include <rtl/ustring.hxx>
30 #include <xmlreader/xmlreader.hxx>
32 #include "additions.hxx"
34 #include "nodemap.hxx"
38 #include "valueparser.hxx"
39 #include "xmldata.hxx"
41 namespace xmlreader
{ struct Span
; }
46 class LocalizedPropertyNode
;
53 class XcuParser
: public Parser
{
56 int layer
, Data
& data
, Partial
const * partial
,
57 Modifications
* broadcastModifications
, Additions
* additions
);
62 virtual xmlreader::XmlReader::Text
getTextMode() SAL_OVERRIDE
;
64 virtual bool startElement(
65 xmlreader::XmlReader
& reader
, int nsId
, xmlreader::Span
const & name
,
66 std::set
< OUString
> const * existingDependencies
) SAL_OVERRIDE
;
68 virtual void endElement(xmlreader::XmlReader
const & reader
) SAL_OVERRIDE
;
70 virtual void characters(xmlreader::Span
const & span
) SAL_OVERRIDE
;
73 OPERATION_MODIFY
, OPERATION_REPLACE
, OPERATION_FUSE
, OPERATION_REMOVE
};
75 static Operation
parseOperation(xmlreader::Span
const & text
);
77 void handleComponentData(xmlreader::XmlReader
& reader
);
79 void handleItem(xmlreader::XmlReader
& reader
);
81 void handlePropValue(xmlreader::XmlReader
& reader
, PropertyNode
* prop
);
83 void handleLocpropValue(
84 xmlreader::XmlReader
& reader
, LocalizedPropertyNode
* locprop
);
86 void handleGroupProp(xmlreader::XmlReader
& reader
, GroupNode
* group
);
88 void handleUnknownGroupProp(
89 xmlreader::XmlReader
const & reader
, GroupNode
* group
,
90 OUString
const & name
, Type type
, Operation operation
,
93 void handlePlainGroupProp(
94 xmlreader::XmlReader
const & reader
, GroupNode
* group
,
95 NodeMap::iterator
const & propertyIndex
, OUString
const & name
,
96 Type type
, Operation operation
, bool finalized
);
98 void handleLocalizedGroupProp(
99 xmlreader::XmlReader
const & reader
, LocalizedPropertyNode
* property
,
100 OUString
const & name
, Type type
, Operation operation
,
103 void handleGroupNode(
104 xmlreader::XmlReader
& reader
, rtl::Reference
< Node
> const & group
);
106 void handleSetNode(xmlreader::XmlReader
& reader
, SetNode
* set
);
108 void recordModification(bool addition
);
111 rtl::Reference
< Node
> node
; // empty if ignore or <items>
112 OUString name
; // empty and ignored if !insert
117 static State
Ignore(bool thePop
) { return State(thePop
); }
119 static State
Modify(rtl::Reference
< Node
> const & theNode
)
120 { return State(theNode
); }
123 rtl::Reference
< Node
> const & theNode
, OUString
const & theName
)
124 { return State(theNode
, theName
); }
127 explicit State(bool thePop
): ignore(true), insert(false), pop(thePop
) {}
129 explicit State(rtl::Reference
< Node
> const & theNode
):
130 node(theNode
), ignore(false), insert(false), pop(true)
134 rtl::Reference
< Node
> const & theNode
, OUString
const & theName
):
135 node(theNode
), name(theName
), ignore(false), insert(true), pop(true)
139 typedef std::stack
< State
> StateStack
;
141 ValueParser valueParser_
;
143 Partial
const * partial_
;
144 Modifications
* broadcastModifications_
;
145 Additions
* additions_
;
146 bool recordModifications_
;
148 OUString componentName_
;
157 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */