1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 #ifndef INCLUDED_CONFIGMGR_SOURCE_XCSPARSER_HXX 29 #define INCLUDED_CONFIGMGR_SOURCE_XCSPARSER_HXX 30 31 #include "sal/config.h" 32 33 #include <stack> 34 35 #include "rtl/ref.hxx" 36 #include "rtl/ustring.hxx" 37 #include "xmlreader/xmlreader.hxx" 38 39 #include "node.hxx" 40 #include "parser.hxx" 41 #include "valueparser.hxx" 42 43 namespace xmlreader { struct Span; } 44 45 namespace configmgr { 46 47 class SetNode; 48 struct Data; 49 50 class XcsParser: public Parser { 51 public: 52 XcsParser(int layer, Data & data); 53 54 private: 55 virtual ~XcsParser(); 56 57 virtual xmlreader::XmlReader::Text getTextMode(); 58 59 virtual bool startElement( 60 xmlreader::XmlReader & reader, int nsId, xmlreader::Span const & name); 61 62 virtual void endElement(xmlreader::XmlReader const & reader); 63 64 virtual void characters(xmlreader::Span const & text); 65 66 void handleComponentSchema(xmlreader::XmlReader & reader); 67 68 void handleNodeRef(xmlreader::XmlReader & reader); 69 70 void handleProp(xmlreader::XmlReader & reader); 71 72 void handlePropValue( 73 xmlreader::XmlReader & reader, rtl::Reference< Node > const & property); 74 75 void handleGroup(xmlreader::XmlReader & reader, bool isTemplate); 76 77 void handleSet(xmlreader::XmlReader & reader, bool isTemplate); 78 79 void handleSetItem(xmlreader::XmlReader & reader, SetNode * set); 80 81 enum State { 82 STATE_START, STATE_COMPONENT_SCHEMA, STATE_TEMPLATES, 83 STATE_TEMPLATES_DONE, STATE_COMPONENT, STATE_COMPONENT_DONE }; 84 85 struct Element { 86 rtl::Reference< Node > node; 87 rtl::OUString name; 88 89 inline Element( 90 rtl::Reference< Node > const & theNode, 91 rtl::OUString const & theName): 92 node(theNode), name(theName) {} 93 }; 94 95 typedef std::stack< Element > ElementStack; 96 97 ValueParser valueParser_; 98 Data & data_; 99 rtl::OUString componentName_; 100 State state_; 101 long ignoring_; 102 ElementStack elements_; 103 }; 104 105 } 106 107 #endif 108