1*ec61c6edSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*ec61c6edSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*ec61c6edSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*ec61c6edSAndrew Rist  * distributed with this work for additional information
6*ec61c6edSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*ec61c6edSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*ec61c6edSAndrew Rist  * "License"); you may not use this file except in compliance
9*ec61c6edSAndrew Rist  * with the License.  You may obtain a copy of the License at
10*ec61c6edSAndrew Rist  *
11*ec61c6edSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*ec61c6edSAndrew Rist  *
13*ec61c6edSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*ec61c6edSAndrew Rist  * software distributed under the License is distributed on an
15*ec61c6edSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*ec61c6edSAndrew Rist  * KIND, either express or implied.  See the License for the
17*ec61c6edSAndrew Rist  * specific language governing permissions and limitations
18*ec61c6edSAndrew Rist  * under the License.
19*ec61c6edSAndrew Rist  *
20*ec61c6edSAndrew Rist  *************************************************************/
21*ec61c6edSAndrew Rist 
22*ec61c6edSAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir #ifndef _SAXHELPER_HXX
25cdf0e10cSrcweir #define _SAXHELPER_HXX
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include "libxml/tree.h"
28cdf0e10cSrcweir 
29cdf0e10cSrcweir #include <com/sun/star/xml/sax/SAXException.hpp>
30cdf0e10cSrcweir #include <com/sun/star/xml/sax/XAttributeList.hpp>
31cdf0e10cSrcweir #include <com/sun/star/xml/sax/XLocator.hpp>
32cdf0e10cSrcweir #include <com/sun/star/lang/XServiceInfo.hpp>
33cdf0e10cSrcweir #include <com/sun/star/xml/csax/XMLAttribute.hpp>
34cdf0e10cSrcweir 
35cdf0e10cSrcweir /** This class represents a SAX handler which simply forwards to
36cdf0e10cSrcweir     the corresponding libxml API and translates parameter if necessary.
37cdf0e10cSrcweir */
38cdf0e10cSrcweir class SAXHelper
39cdf0e10cSrcweir {
40cdf0e10cSrcweir 	private :
41cdf0e10cSrcweir 		xmlParserCtxtPtr m_pParserCtxt ;
42cdf0e10cSrcweir 		xmlSAXHandlerPtr m_pSaxHandler ;
43cdf0e10cSrcweir 
44cdf0e10cSrcweir 	public:
45cdf0e10cSrcweir 		SAXHelper( ) ;
46cdf0e10cSrcweir 		virtual ~SAXHelper() ;
47cdf0e10cSrcweir 
48cdf0e10cSrcweir 		xmlNodePtr getCurrentNode();
49cdf0e10cSrcweir 		void setCurrentNode(const xmlNodePtr pNode);
50cdf0e10cSrcweir 		xmlDocPtr getDocument();
51cdf0e10cSrcweir 
52cdf0e10cSrcweir 		void startDocument( void )
53cdf0e10cSrcweir 			throw( ::com::sun::star::xml::sax::SAXException , ::com::sun::star::uno::RuntimeException ) ;
54cdf0e10cSrcweir 
55cdf0e10cSrcweir 		void endDocument( void )
56cdf0e10cSrcweir 			throw( ::com::sun::star::xml::sax::SAXException , ::com::sun::star::uno::RuntimeException ) ;
57cdf0e10cSrcweir 
58cdf0e10cSrcweir 		void startElement(
59cdf0e10cSrcweir 			const ::rtl::OUString& aName ,
60cdf0e10cSrcweir 			const com::sun::star::uno::Sequence<
61cdf0e10cSrcweir 				com::sun::star::xml::csax::XMLAttribute >& aAttributes )
62cdf0e10cSrcweir 			throw( ::com::sun::star::xml::sax::SAXException , ::com::sun::star::uno::RuntimeException ) ;
63cdf0e10cSrcweir 
64cdf0e10cSrcweir 		void endElement( const ::rtl::OUString& aName )
65cdf0e10cSrcweir 			throw( ::com::sun::star::xml::sax::SAXException , ::com::sun::star::uno::RuntimeException ) ;
66cdf0e10cSrcweir 
67cdf0e10cSrcweir 		void characters( const ::rtl::OUString& aChars )
68cdf0e10cSrcweir 			throw( ::com::sun::star::xml::sax::SAXException , ::com::sun::star::uno::RuntimeException ) ;
69cdf0e10cSrcweir 
70cdf0e10cSrcweir 		void ignorableWhitespace( const ::rtl::OUString& aWhitespaces )
71cdf0e10cSrcweir 			throw( ::com::sun::star::xml::sax::SAXException , ::com::sun::star::uno::RuntimeException ) ;
72cdf0e10cSrcweir 
73cdf0e10cSrcweir 		void processingInstruction(
74cdf0e10cSrcweir 			const ::rtl::OUString& aTarget ,
75cdf0e10cSrcweir 			const ::rtl::OUString& aData )
76cdf0e10cSrcweir 			throw( ::com::sun::star::xml::sax::SAXException , ::com::sun::star::uno::RuntimeException ) ;
77cdf0e10cSrcweir 
78cdf0e10cSrcweir 		void setDocumentLocator( const ::com::sun::star::uno::Reference<
79cdf0e10cSrcweir 			::com::sun::star::xml::sax::XLocator > & xLocator )
80cdf0e10cSrcweir 			throw( ::com::sun::star::xml::sax::SAXException , ::com::sun::star::uno::RuntimeException ) ;
81cdf0e10cSrcweir } ;
82cdf0e10cSrcweir 
83cdf0e10cSrcweir #endif
84cdf0e10cSrcweir 
85