build fix: no comphelper/profilezone.hxx in this branch
[LibreOffice.git] / unoxml / source / dom / saxbuilder.hxx
blobad3e7ce4dca67f78b4012381a30919a5f655364a
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #ifndef INCLUDED_UNOXML_SOURCE_DOM_SAXBUILDER_HXX
21 #define INCLUDED_UNOXML_SOURCE_DOM_SAXBUILDER_HXX
23 #include <stack>
24 #include <map>
26 #include <sal/types.h>
27 #include <osl/mutex.hxx>
28 #include <cppuhelper/implbase.hxx>
29 #include <com/sun/star/uno/Reference.h>
30 #include <com/sun/star/uno/Sequence.h>
32 #include <com/sun/star/uno/XInterface.hpp>
33 #include <com/sun/star/uno/Exception.hpp>
34 #include <com/sun/star/xml/dom/XSAXDocumentBuilder2.hpp>
35 #include <com/sun/star/xml/dom/SAXDocumentBuilderState.hpp>
36 #include <com/sun/star/xml/dom/XDocument.hpp>
37 #include <com/sun/star/xml/dom/XDocumentFragment.hpp>
38 #include <com/sun/star/xml/sax/XLocator.hpp>
39 #include <com/sun/star/xml/sax/XAttributeList.hpp>
40 #include <com/sun/star/lang/XServiceInfo.hpp>
41 #include <com/sun/star/lang/XSingleServiceFactory.hpp>
42 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
44 namespace DOM
47 typedef std::stack< css::uno::Reference< css::xml::dom::XNode > > NodeStack;
48 typedef std::map< OUString, OUString > NSMap;
49 typedef std::map< OUString, OUString > AttrMap;
50 typedef std::stack< NSMap > NSStack;
52 class CSAXDocumentBuilder
53 : public ::cppu::WeakImplHelper< css::xml::dom::XSAXDocumentBuilder2, css::lang::XServiceInfo >
56 private:
57 ::osl::Mutex m_Mutex;
58 const css::uno::Reference< css::lang::XMultiServiceFactory > m_aServiceManager;
60 css::xml::dom::SAXDocumentBuilderState m_aState;
61 NodeStack m_aNodeStack;
62 NSStack m_aNSStack;
64 css::uno::Reference< css::xml::dom::XDocument > m_aDocument;
65 css::uno::Reference< css::xml::dom::XDocumentFragment > m_aFragment;
66 css::uno::Reference< css::xml::sax::XLocator > m_aLocator;
69 public:
70 // static helpers for service info and component management
71 static const char* aImplementationName;
72 static const char* aSupportedServiceNames[];
73 static OUString _getImplementationName();
74 static css::uno::Sequence< OUString > _getSupportedServiceNames();
75 static css::uno::Reference< XInterface > _getInstance(const css::uno::Reference< css::lang::XMultiServiceFactory >& rSMgr);
77 explicit CSAXDocumentBuilder(const css::uno::Reference< css::lang::XMultiServiceFactory >& mgr);
79 // XServiceInfo
80 virtual OUString SAL_CALL getImplementationName()
81 throw (css::uno::RuntimeException, std::exception) override;
82 virtual sal_Bool SAL_CALL supportsService(const OUString& ServiceName)
83 throw (css::uno::RuntimeException, std::exception) override;
84 virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames ()
85 throw (css::uno::RuntimeException, std::exception) override;
87 // XDocumentHandler
88 virtual void SAL_CALL startDocument()
89 throw( css::uno::RuntimeException, css::xml::sax::SAXException, std::exception ) override;
90 virtual void SAL_CALL endDocument()
91 throw( css::uno::RuntimeException, css::xml::sax::SAXException, std::exception ) override;
92 virtual void SAL_CALL startElement( const OUString& aName,
93 const css::uno::Reference< css::xml::sax::XAttributeList >& xAttribs )
94 throw( css::uno::RuntimeException, css::xml::sax::SAXException, std::exception ) override;
95 virtual void SAL_CALL endElement( const OUString& aName )
96 throw( css::uno::RuntimeException, css::xml::sax::SAXException, std::exception ) override;
97 virtual void SAL_CALL characters( const OUString& aChars )
98 throw( css::uno::RuntimeException, css::xml::sax::SAXException, std::exception ) override;
99 virtual void SAL_CALL ignorableWhitespace( const OUString& aWhitespaces )
100 throw( css::uno::RuntimeException, css::xml::sax::SAXException, std::exception ) override;
101 virtual void SAL_CALL processingInstruction( const OUString& aTarget,
102 const OUString& aData )
103 throw( css::uno::RuntimeException, css::xml::sax::SAXException, std::exception ) override;
104 virtual void SAL_CALL setDocumentLocator( const css::uno::Reference< css::xml::sax::XLocator >& xLocator )
105 throw( css::uno::RuntimeException, css::xml::sax::SAXException, std::exception ) override;
108 // XSAXDocumentBuilder
109 virtual css::xml::dom::SAXDocumentBuilderState SAL_CALL getState()
110 throw (css::uno::RuntimeException, std::exception) override;
111 virtual void SAL_CALL reset()
112 throw (css::uno::RuntimeException, std::exception) override;
113 virtual css::uno::Reference< css::xml::dom::XDocument > SAL_CALL getDocument()
114 throw (css::uno::RuntimeException, std::exception) override;
115 virtual css::uno::Reference< css::xml::dom::XDocumentFragment > SAL_CALL getDocumentFragment()
116 throw (css::uno::RuntimeException, std::exception) override;
117 virtual void SAL_CALL startDocumentFragment(const css::uno::Reference< css::xml::dom::XDocument >& ownerDoc)
118 throw (css::uno::RuntimeException, std::exception) override;
119 virtual void SAL_CALL endDocumentFragment()
120 throw (css::uno::RuntimeException, std::exception) override;
126 #endif
128 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */