Update ooo320-m1
[ooovba.git] / unoxml / source / dom / saxbuilder.hxx
blobcac51aaee275e15b568b8eda52f049e98ab9c17d
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: saxbuilder.hxx,v $
10 * $Revision: 1.7 $
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 _SAXBUILDER_HXX
32 #define _SAXBUILDER_HXX
34 #include <stack>
35 #include <map>
37 #include <sal/types.h>
38 #include <cppuhelper/implbase3.hxx>
39 #include <com/sun/star/uno/Reference.h>
40 #include <com/sun/star/uno/Sequence.h>
42 #include <com/sun/star/uno/XInterface.hpp>
43 #include <com/sun/star/uno/Exception.hpp>
44 #include <com/sun/star/xml/dom/XSAXDocumentBuilder.hpp>
45 #include <com/sun/star/xml/dom/SAXDocumentBuilderState.hpp>
46 #include <com/sun/star/xml/dom/XDocument.hpp>
47 #include <com/sun/star/xml/dom/XDocumentFragment.hpp>
48 #include <com/sun/star/xml/sax/XDocumentHandler.hpp>
49 #include <com/sun/star/xml/sax/XLocator.hpp>
50 #include <com/sun/star/xml/sax/XAttributeList.hpp>
51 #include <com/sun/star/lang/XServiceInfo.hpp>
52 #include <com/sun/star/lang/XSingleServiceFactory.hpp>
53 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
55 #include "libxml/tree.h"
57 using ::rtl::OUString;
58 using namespace com::sun::star::uno;
59 using namespace com::sun::star::xml::dom;
60 using namespace com::sun::star::xml::sax;
62 using com::sun::star::lang::XServiceInfo;
63 using com::sun::star::lang::XSingleServiceFactory;
64 using com::sun::star::lang::XMultiServiceFactory;
66 namespace DOM
69 typedef std::stack< Reference< XNode > > NodeStack;
70 typedef std::map< OUString, OUString > NSMap;
71 typedef std::map< OUString, OUString > AttrMap;
72 typedef std::stack< NSMap > NSStack;
74 class CSAXDocumentBuilder
75 : public ::cppu::WeakImplHelper3< XDocumentHandler, XSAXDocumentBuilder, XServiceInfo >
78 private:
79 const Reference< XMultiServiceFactory > m_aServiceManager;
81 SAXDocumentBuilderState m_aState;
82 NodeStack m_aNodeStack;
83 NSStack m_aNSStack;
85 OUString resolvePrefix(const OUString& aPrefix);
87 Reference< XDocument > m_aDocument;
88 Reference< XDocumentFragment > m_aFragment;
89 Reference< XLocator > m_aLocator;
92 public:
94 // call for factory
95 static Reference< XInterface > getInstance(const Reference < XMultiServiceFactory >& xFactory);
97 // static helpers for service info and component management
98 static const char* aImplementationName;
99 static const char* aSupportedServiceNames[];
100 static OUString _getImplementationName();
101 static Sequence< OUString > _getSupportedServiceNames();
102 static Reference< XInterface > _getInstance(const Reference< XMultiServiceFactory >& rSMgr);
104 CSAXDocumentBuilder(const Reference< XMultiServiceFactory >& mgr);
106 // XServiceInfo
107 virtual OUString SAL_CALL getImplementationName()
108 throw (RuntimeException);
109 virtual sal_Bool SAL_CALL supportsService(const OUString& ServiceName)
110 throw (RuntimeException);
111 virtual Sequence< OUString > SAL_CALL getSupportedServiceNames ()
112 throw (RuntimeException);
114 // XDocumentHandler
115 virtual void SAL_CALL startDocument()
116 throw( RuntimeException, com::sun::star::xml::sax::SAXException );
117 virtual void SAL_CALL endDocument()
118 throw( RuntimeException, com::sun::star::xml::sax::SAXException );
119 virtual void SAL_CALL startElement( const OUString& aName,
120 const Reference< XAttributeList >& xAttribs )
121 throw( RuntimeException, com::sun::star::xml::sax::SAXException );
122 virtual void SAL_CALL endElement( const OUString& aName )
123 throw( RuntimeException, com::sun::star::xml::sax::SAXException );
124 virtual void SAL_CALL characters( const OUString& aChars )
125 throw( RuntimeException, com::sun::star::xml::sax::SAXException );
126 virtual void SAL_CALL ignorableWhitespace( const OUString& aWhitespaces )
127 throw( RuntimeException, com::sun::star::xml::sax::SAXException );
128 virtual void SAL_CALL processingInstruction( const OUString& aTarget,
129 const OUString& aData )
130 throw( RuntimeException, com::sun::star::xml::sax::SAXException );
131 virtual void SAL_CALL setDocumentLocator( const Reference< XLocator >& xLocator )
132 throw( RuntimeException, com::sun::star::xml::sax::SAXException );
135 // XSAXDocumentBuilder
136 virtual SAXDocumentBuilderState SAL_CALL getState()
137 throw (RuntimeException);
138 virtual void SAL_CALL reset()
139 throw (RuntimeException);
140 virtual Reference< XDocument > SAL_CALL getDocument()
141 throw (RuntimeException);
142 virtual Reference< XDocumentFragment > SAL_CALL getDocumentFragment()
143 throw (RuntimeException);
144 virtual void SAL_CALL startDocumentFragment(const Reference< XDocument >& ownerDoc)
145 throw (RuntimeException);
146 virtual void SAL_CALL endDocumentFragment()
147 throw (RuntimeException);
153 #endif