1*a2faadffSAndrew Rist /************************************************************** 2*a2faadffSAndrew Rist * 3*a2faadffSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*a2faadffSAndrew Rist * or more contributor license agreements. See the NOTICE file 5*a2faadffSAndrew Rist * distributed with this work for additional information 6*a2faadffSAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*a2faadffSAndrew Rist * to you under the Apache License, Version 2.0 (the 8*a2faadffSAndrew Rist * "License"); you may not use this file except in compliance 9*a2faadffSAndrew Rist * with the License. You may obtain a copy of the License at 10*a2faadffSAndrew Rist * 11*a2faadffSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12*a2faadffSAndrew Rist * 13*a2faadffSAndrew Rist * Unless required by applicable law or agreed to in writing, 14*a2faadffSAndrew Rist * software distributed under the License is distributed on an 15*a2faadffSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*a2faadffSAndrew Rist * KIND, either express or implied. See the License for the 17*a2faadffSAndrew Rist * specific language governing permissions and limitations 18*a2faadffSAndrew Rist * under the License. 19*a2faadffSAndrew Rist * 20*a2faadffSAndrew Rist *************************************************************/ 21*a2faadffSAndrew Rist 22*a2faadffSAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir #ifndef INCLUDED_CONFIGMGR_SOURCE_XCUPARSER_HXX 25cdf0e10cSrcweir #define INCLUDED_CONFIGMGR_SOURCE_XCUPARSER_HXX 26cdf0e10cSrcweir 27cdf0e10cSrcweir #include "sal/config.h" 28cdf0e10cSrcweir 29cdf0e10cSrcweir #include <stack> 30cdf0e10cSrcweir 31cdf0e10cSrcweir #include "rtl/ref.hxx" 32cdf0e10cSrcweir #include "rtl/ustring.hxx" 33cdf0e10cSrcweir #include "xmlreader/xmlreader.hxx" 34cdf0e10cSrcweir 35cdf0e10cSrcweir #include "additions.hxx" 36cdf0e10cSrcweir #include "node.hxx" 37cdf0e10cSrcweir #include "nodemap.hxx" 38cdf0e10cSrcweir #include "parser.hxx" 39cdf0e10cSrcweir #include "path.hxx" 40cdf0e10cSrcweir #include "type.hxx" 41cdf0e10cSrcweir #include "valueparser.hxx" 42cdf0e10cSrcweir #include "xmldata.hxx" 43cdf0e10cSrcweir 44cdf0e10cSrcweir namespace xmlreader { struct Span; } 45cdf0e10cSrcweir 46cdf0e10cSrcweir namespace configmgr { 47cdf0e10cSrcweir 48cdf0e10cSrcweir class GroupNode; 49cdf0e10cSrcweir class LocalizedPropertyNode; 50cdf0e10cSrcweir class Modifications; 51cdf0e10cSrcweir class Partial; 52cdf0e10cSrcweir class PropertyNode; 53cdf0e10cSrcweir class SetNode; 54cdf0e10cSrcweir struct Data; 55cdf0e10cSrcweir 56cdf0e10cSrcweir class XcuParser: public Parser { 57cdf0e10cSrcweir public: 58cdf0e10cSrcweir XcuParser( 59cdf0e10cSrcweir int layer, Data & data, Partial const * partial, 60cdf0e10cSrcweir Modifications * broadcastModifications, Additions * additions); 61cdf0e10cSrcweir 62cdf0e10cSrcweir private: 63cdf0e10cSrcweir virtual ~XcuParser(); 64cdf0e10cSrcweir 65cdf0e10cSrcweir virtual xmlreader::XmlReader::Text getTextMode(); 66cdf0e10cSrcweir 67cdf0e10cSrcweir virtual bool startElement( 68cdf0e10cSrcweir xmlreader::XmlReader & reader, int nsId, xmlreader::Span const & name); 69cdf0e10cSrcweir 70cdf0e10cSrcweir virtual void endElement(xmlreader::XmlReader const & reader); 71cdf0e10cSrcweir 72cdf0e10cSrcweir virtual void characters(xmlreader::Span const & span); 73cdf0e10cSrcweir 74cdf0e10cSrcweir enum Operation { 75cdf0e10cSrcweir OPERATION_MODIFY, OPERATION_REPLACE, OPERATION_FUSE, OPERATION_REMOVE }; 76cdf0e10cSrcweir 77cdf0e10cSrcweir static Operation parseOperation(xmlreader::Span const & text); 78cdf0e10cSrcweir 79cdf0e10cSrcweir void handleComponentData(xmlreader::XmlReader & reader); 80cdf0e10cSrcweir 81cdf0e10cSrcweir void handleItem(xmlreader::XmlReader & reader); 82cdf0e10cSrcweir 83cdf0e10cSrcweir void handlePropValue(xmlreader::XmlReader & reader, PropertyNode * prop); 84cdf0e10cSrcweir 85cdf0e10cSrcweir void handleLocpropValue( 86cdf0e10cSrcweir xmlreader::XmlReader & reader, LocalizedPropertyNode * locprop); 87cdf0e10cSrcweir 88cdf0e10cSrcweir void handleGroupProp(xmlreader::XmlReader & reader, GroupNode * group); 89cdf0e10cSrcweir 90cdf0e10cSrcweir void handleUnknownGroupProp( 91cdf0e10cSrcweir xmlreader::XmlReader const & reader, GroupNode * group, 92cdf0e10cSrcweir rtl::OUString const & name, Type type, Operation operation, 93cdf0e10cSrcweir bool finalized); 94cdf0e10cSrcweir 95cdf0e10cSrcweir void handlePlainGroupProp( 96cdf0e10cSrcweir xmlreader::XmlReader const & reader, GroupNode * group, 97cdf0e10cSrcweir NodeMap::iterator const & propertyIndex, rtl::OUString const & name, 98cdf0e10cSrcweir Type type, Operation operation, bool finalized); 99cdf0e10cSrcweir 100cdf0e10cSrcweir void handleLocalizedGroupProp( 101cdf0e10cSrcweir xmlreader::XmlReader const & reader, LocalizedPropertyNode * property, 102cdf0e10cSrcweir rtl::OUString const & name, Type type, Operation operation, 103cdf0e10cSrcweir bool finalized); 104cdf0e10cSrcweir 105cdf0e10cSrcweir void handleGroupNode( 106cdf0e10cSrcweir xmlreader::XmlReader & reader, rtl::Reference< Node > const & group); 107cdf0e10cSrcweir 108cdf0e10cSrcweir void handleSetNode(xmlreader::XmlReader & reader, SetNode * set); 109cdf0e10cSrcweir 110cdf0e10cSrcweir void recordModification(bool addition); 111cdf0e10cSrcweir 112cdf0e10cSrcweir struct State { 113cdf0e10cSrcweir rtl::Reference< Node > node; // empty iff ignore or <items> 114cdf0e10cSrcweir rtl::OUString name; // empty and ignored if !insert 115cdf0e10cSrcweir bool ignore; 116cdf0e10cSrcweir bool insert; 117cdf0e10cSrcweir bool locked; 118cdf0e10cSrcweir bool pop; 119cdf0e10cSrcweir Stateconfigmgr::XcuParser::State120cdf0e10cSrcweir inline State(bool thePop): 121cdf0e10cSrcweir ignore(true), insert(false), locked(false), pop(thePop) 122cdf0e10cSrcweir {} 123cdf0e10cSrcweir Stateconfigmgr::XcuParser::State124cdf0e10cSrcweir inline State(rtl::Reference< Node > const & theNode, bool theLocked): 125cdf0e10cSrcweir node(theNode), ignore(false), insert(false), locked(theLocked), 126cdf0e10cSrcweir pop(true) 127cdf0e10cSrcweir {} 128cdf0e10cSrcweir Stateconfigmgr::XcuParser::State129cdf0e10cSrcweir inline State( 130cdf0e10cSrcweir rtl::Reference< Node > const & theNode, 131cdf0e10cSrcweir rtl::OUString const & theName, bool theLocked): 132cdf0e10cSrcweir node(theNode), name(theName), ignore(false), insert(true), 133cdf0e10cSrcweir locked(theLocked), pop(true) 134cdf0e10cSrcweir {} 135cdf0e10cSrcweir }; 136cdf0e10cSrcweir 137cdf0e10cSrcweir typedef std::stack< State > StateStack; 138cdf0e10cSrcweir 139cdf0e10cSrcweir ValueParser valueParser_; 140cdf0e10cSrcweir Data & data_; 141cdf0e10cSrcweir Partial const * partial_; 142cdf0e10cSrcweir Modifications * broadcastModifications_; 143cdf0e10cSrcweir Additions * additions_; 144cdf0e10cSrcweir bool recordModifications_; 145cdf0e10cSrcweir bool trackPath_; 146cdf0e10cSrcweir rtl::OUString componentName_; 147cdf0e10cSrcweir StateStack state_; 148cdf0e10cSrcweir Path path_; 149cdf0e10cSrcweir }; 150cdf0e10cSrcweir 151cdf0e10cSrcweir } 152cdf0e10cSrcweir 153cdf0e10cSrcweir #endif 154