Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
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/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
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 .
18 : */
19 :
20 : #ifndef INCLUDED_UNOXML_SOURCE_DOM_DOCUMENTBUILDER_HXX
21 : #define INCLUDED_UNOXML_SOURCE_DOM_DOCUMENTBUILDER_HXX
22 :
23 : #include <sal/types.h>
24 :
25 : #include <cppuhelper/implbase2.hxx>
26 :
27 : #include <com/sun/star/uno/Reference.h>
28 : #include <com/sun/star/uno/Sequence.h>
29 :
30 : #include <com/sun/star/uno/XInterface.hpp>
31 : #include <com/sun/star/xml/dom/XDocumentBuilder.hpp>
32 : #include <com/sun/star/xml/dom/XDocument.hpp>
33 : #include <com/sun/star/xml/dom/XDOMImplementation.hpp>
34 : #include <com/sun/star/xml/sax/XEntityResolver.hpp>
35 : #include <com/sun/star/xml/sax/XErrorHandler.hpp>
36 : #include <com/sun/star/xml/sax/SAXParseException.hpp>
37 : #include <com/sun/star/io/XInputStream.hpp>
38 : #include <com/sun/star/io/IOException.hpp>
39 : #include <com/sun/star/lang/XServiceInfo.hpp>
40 : #include <com/sun/star/lang/XMultiServiceFactory.hpp>
41 :
42 : namespace DOM
43 : {
44 : typedef ::cppu::WeakImplHelper2
45 : < css::xml::dom::XDocumentBuilder
46 : , css::lang::XServiceInfo
47 : > CDocumentBuilder_Base;
48 :
49 460 : class CDocumentBuilder
50 : : public CDocumentBuilder_Base
51 : {
52 : private:
53 : ::osl::Mutex m_Mutex;
54 : css::uno::Reference< css::lang::XMultiServiceFactory > const
55 : m_xFactory;
56 : css::uno::Reference< css::xml::sax::XEntityResolver > m_xEntityResolver;
57 : css::uno::Reference< css::xml::sax::XErrorHandler > m_xErrorHandler;
58 :
59 : public:
60 :
61 : // ctor
62 : CDocumentBuilder(
63 : css::uno::Reference< css::lang::XMultiServiceFactory > const&
64 : xFactory);
65 :
66 : // call for factory
67 : static css::uno::Reference< XInterface > getInstance(
68 : css::uno::Reference< css::lang::XMultiServiceFactory > const&
69 : xFactory);
70 :
71 : // static helpers for service info and component management
72 : static const char* aImplementationName;
73 : static const char* aSupportedServiceNames[];
74 : static OUString _getImplementationName();
75 : static css::uno::Sequence< OUString > _getSupportedServiceNames();
76 : static css::uno::Reference< XInterface > _getInstance(
77 : css::uno::Reference< css::lang::XMultiServiceFactory > const&
78 : rSMgr);
79 :
80 : // XServiceInfo
81 : virtual OUString SAL_CALL getImplementationName()
82 : throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
83 : virtual sal_Bool SAL_CALL supportsService(const OUString& ServiceName)
84 : throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
85 : virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames ()
86 : throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
87 :
88 : /**
89 : Obtain an instance of a DOMImplementation object.
90 : */
91 : virtual css::uno::Reference< css::xml::dom::XDOMImplementation > SAL_CALL getDOMImplementation()
92 : throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
93 :
94 : /**
95 : Indicates whether or not this parser is configured to understand
96 : namespaces.
97 : */
98 : virtual sal_Bool SAL_CALL isNamespaceAware()
99 : throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
100 :
101 : /**
102 : Indicates whether or not this parser is configured to validate XML
103 : documents.
104 : */
105 : virtual sal_Bool SAL_CALL isValidating()
106 : throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
107 :
108 : /**
109 : Obtain a new instance of a DOM Document object to build a DOM tree
110 : with.
111 : */
112 : virtual css::uno::Reference< css::xml::dom::XDocument > SAL_CALL newDocument()
113 : throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
114 :
115 : /**
116 : Parse the content of the given InputStream as an XML document and
117 : return a new DOM Document object.
118 : */
119 : virtual css::uno::Reference< css::xml::dom::XDocument > SAL_CALL parse(const css::uno::Reference< css::io::XInputStream >& is)
120 : throw (css::uno::RuntimeException, css::xml::sax::SAXParseException, css::io::IOException, std::exception) SAL_OVERRIDE;
121 :
122 : /**
123 : Parse the content of the given URI as an XML document and return
124 : a new DOM Document object.
125 : */
126 : virtual css::uno::Reference< css::xml::dom::XDocument > SAL_CALL parseURI(const OUString& uri)
127 : throw (css::uno::RuntimeException, css::xml::sax::SAXParseException, css::io::IOException, std::exception) SAL_OVERRIDE;
128 :
129 : /**
130 : Specify the EntityResolver to be used to resolve entities present
131 : in the XML document to be parsed.
132 : */
133 : virtual void SAL_CALL setEntityResolver(const css::uno::Reference< css::xml::sax::XEntityResolver >& er)
134 : throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
135 :
136 : virtual css::uno::Reference< css::xml::sax::XEntityResolver > SAL_CALL getEntityResolver()
137 : throw (css::uno::RuntimeException);
138 :
139 :
140 : /**
141 : Specify the ErrorHandler to be used to report errors present in
142 : the XML document to be parsed.
143 : */
144 : virtual void SAL_CALL setErrorHandler(const css::uno::Reference< css::xml::sax::XErrorHandler >& eh)
145 : throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
146 : };
147 : }
148 :
149 : #endif
150 :
151 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|