1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: basicparser.hxx,v $
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"
37 #ifndef CONFIGMGR_LOGGER_HXX_
40 #include <com/sun/star/xml/sax/XDocumentHandler.hpp>
41 #include <cppuhelper/implbase1.hxx>
43 namespace com
{ namespace sun
{ namespace star
{ namespace script
{
49 // -----------------------------------------------------------------------------
52 // -----------------------------------------------------------------------------
53 namespace uno
= ::com::sun::star::uno
;
54 namespace lang
= ::com::sun::star::lang
;
56 namespace sax
= ::com::sun::star::xml::sax
;
57 // -----------------------------------------------------------------------------
60 : public cppu::WeakImplHelper1
<sax::XDocumentHandler
>
64 uno::Reference
< com::sun::star::script::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
;
75 #if OSL_DEBUG_LEVEL > 0
77 rtl::OUString dbgPublicId
, dbgSystemId
;
78 sal_Int32 dbgLineNo
, dbgColumnNo
;
80 void dbgUpdateLocation();
81 #endif // OSL_DEBUG_LEVEL
84 explicit BasicParser(uno::Reference
< uno::XComponentContext
> const & _xContext
);
85 virtual ~BasicParser();
91 throw (sax::SAXException
, uno::RuntimeException
);
94 endDocument( ) throw (sax::SAXException
, uno::RuntimeException
);
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
);
113 ElementParser
const & getDataParser() const { return m_aDataParser
; }
115 Logger
const & getLogger() { return m_aDataParser
.logger(); }
118 void startNode( ElementInfo
const & aInfo
, const uno::Reference
< sax::XAttributeList
>& xAttribs
);
119 /// are we in the content of a node ?
121 /// are we in the content of node for which no content was started yet ?
123 /// make sure we are in the content of a node ?
125 /// get the info about of the node currently being processed
126 ElementInfo
const & getActiveNodeInfo();
131 void startProperty( ElementInfo
const & aInfo
, const uno::Reference
< sax::XAttributeList
>& xAttribs
);
132 /// are we in the content of a property node ?
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();
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
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 ?
158 /// ending a node: was this skipped ?
159 bool wasSkipping( const rtl::OUString
& aTag
);
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 // -----------------------------------------------------------------------------
171 // -----------------------------------------------------------------------------
173 } // namespace configmgr