merge the formfield patch from ooo-build
[ooovba.git] / configmgr / source / xml / basicparser.hxx
blobf8bb218520adab2675d972eb1fdeb097830c282d
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: basicparser.hxx,v $
10 * $Revision: 1.10 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef CONFIGMGR_XML_BASICPARSER_HXX
32 #define CONFIGMGR_XML_BASICPARSER_HXX
34 #include "elementparser.hxx"
35 #include "utility.hxx"
36 #include "stack.hxx"
37 #ifndef CONFIGMGR_LOGGER_HXX_
38 #include "logger.hxx"
39 #endif
40 #include <com/sun/star/xml/sax/XDocumentHandler.hpp>
41 #include <cppuhelper/implbase1.hxx>
43 namespace com { namespace sun { namespace star { namespace script {
44 class XTypeConverter;
45 } } } }
47 namespace configmgr
49 // -----------------------------------------------------------------------------
50 namespace xml
52 // -----------------------------------------------------------------------------
53 namespace uno = ::com::sun::star::uno;
54 namespace lang = ::com::sun::star::lang;
56 namespace sax = ::com::sun::star::xml::sax;
57 // -----------------------------------------------------------------------------
59 class BasicParser
60 : public cppu::WeakImplHelper1<sax::XDocumentHandler>
62 struct ValueData;
64 uno::Reference< com::sun::star::script::XTypeConverter >
65 m_xTypeConverter;
66 uno::Reference< sax::XLocator > m_xLocator;
67 ElementParser m_aDataParser;
68 Stack< ElementInfo > m_aNodes;
69 uno::Type m_aValueType;
70 ValueData * m_pValueData;
71 sal_uInt16 m_nSkipLevels;
72 bool m_bEmpty;
73 bool m_bInProperty;
75 #if OSL_DEBUG_LEVEL > 0
76 #ifdef DBG_UTIL
77 rtl::OUString dbgPublicId, dbgSystemId;
78 sal_Int32 dbgLineNo, dbgColumnNo;
79 #endif // DBG_UTIL
80 void dbgUpdateLocation();
81 #endif // OSL_DEBUG_LEVEL
83 public:
84 explicit BasicParser(uno::Reference< uno::XComponentContext > const & _xContext);
85 virtual ~BasicParser();
87 // XDocumentHandler
88 public:
89 virtual void SAL_CALL
90 startDocument( )
91 throw (sax::SAXException, uno::RuntimeException);
93 virtual void SAL_CALL
94 endDocument( ) throw (sax::SAXException, uno::RuntimeException);
96 virtual void SAL_CALL
97 characters( const rtl::OUString& aChars )
98 throw (sax::SAXException, uno::RuntimeException);
100 virtual void SAL_CALL
101 ignorableWhitespace( const rtl::OUString& aWhitespaces )
102 throw (sax::SAXException, uno::RuntimeException);
104 virtual void SAL_CALL
105 processingInstruction( const rtl::OUString& aTarget, const rtl::OUString& aData )
106 throw (sax::SAXException, uno::RuntimeException);
108 virtual void SAL_CALL
109 setDocumentLocator( const uno::Reference< sax::XLocator >& xLocator )
110 throw (sax::SAXException, uno::RuntimeException);
112 protected:
113 ElementParser const & getDataParser() const { return m_aDataParser; }
115 Logger const & getLogger() { return m_aDataParser.logger(); }
117 /// start an node
118 void startNode( ElementInfo const & aInfo, const uno::Reference< sax::XAttributeList >& xAttribs );
119 /// are we in the content of a node ?
120 bool isInNode();
121 /// are we in the content of node for which no content was started yet ?
122 bool isEmptyNode();
123 /// make sure we are in the content of a node ?
124 void ensureInNode();
125 /// get the info about of the node currently being processed
126 ElementInfo const & getActiveNodeInfo();
127 /// end a node
128 void endNode();
130 /// start a property
131 void startProperty( ElementInfo const & aInfo, const uno::Reference< sax::XAttributeList >& xAttribs );
132 /// are we in the content of a property node ?
133 bool isInProperty();
134 /// are we in the content of a property node (and there has been no value for that property) ?
135 bool isInUnhandledProperty();
136 /// get the data type of the active property ?
137 uno::Type getActivePropertyType();
138 /// end a property
139 void endProperty();
141 /// start collecting data for a value - returns the locale of the value (property must have been started)
142 void startValueData(const uno::Reference< sax::XAttributeList >& xAttribs);
143 /// are we in the content of a property node ?
144 bool isInValueData();
145 /// check if the current value data has a locale set
146 bool isValueDataLocalized();
147 /// get the locale of the current value data, if localized
148 rtl::OUString getValueDataLocale();
149 /// return the collected value
150 uno::Any getCurrentValue();
151 /// end collecting data for a value
152 void endValueData();
154 /// start a node to be skipped
155 void startSkipping( const rtl::OUString& aTag, const uno::Reference< sax::XAttributeList >& xAttribs );
156 /// are we inside a skipped node ?
157 bool isSkipping( );
158 /// ending a node: was this skipped ?
159 bool wasSkipping( const rtl::OUString& aTag );
161 protected:
162 void raiseParseException( uno::Any const & _aTargetException, sal_Char const * _pMsg = NULL)
163 SAL_THROW((sax::SAXException, uno::RuntimeException));
164 void raiseParseException( sal_Char const * _pMsg )
165 SAL_THROW((sax::SAXException, uno::RuntimeException));
166 void raiseParseException( rtl::OUString const & aMsg )
167 SAL_THROW((sax::SAXException, uno::RuntimeException));
169 // -----------------------------------------------------------------------------
170 } // namespace xml
171 // -----------------------------------------------------------------------------
173 } // namespace configmgr
174 #endif