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 :
43 : using namespace com::sun::star::uno;
44 : using namespace com::sun::star::lang;
45 : using namespace com::sun::star::xml::dom;
46 : using namespace com::sun::star::xml::sax;
47 : using namespace com::sun::star::io;
48 :
49 : namespace DOM
50 : {
51 : typedef ::cppu::WeakImplHelper2
52 : < XDocumentBuilder
53 : , ::com::sun::star::lang::XServiceInfo
54 : > CDocumentBuilder_Base;
55 :
56 0 : class CDocumentBuilder
57 : : public CDocumentBuilder_Base
58 : {
59 : private:
60 : ::osl::Mutex m_Mutex;
61 : Reference< ::com::sun::star::lang::XMultiServiceFactory > const
62 : m_xFactory;
63 : Reference< XEntityResolver > m_xEntityResolver;
64 : Reference< XErrorHandler > m_xErrorHandler;
65 :
66 : public:
67 :
68 : // ctor
69 : CDocumentBuilder(
70 : Reference< ::com::sun::star::lang::XMultiServiceFactory > const&
71 : xFactory);
72 :
73 : // call for factory
74 : static Reference< XInterface > getInstance(
75 : Reference< ::com::sun::star::lang::XMultiServiceFactory > const&
76 : xFactory);
77 :
78 : // static helpers for service info and component management
79 : static const char* aImplementationName;
80 : static const char* aSupportedServiceNames[];
81 : static OUString _getImplementationName();
82 : static Sequence< OUString > _getSupportedServiceNames();
83 : static Reference< XInterface > _getInstance(
84 : Reference< ::com::sun::star::lang::XMultiServiceFactory > const&
85 : rSMgr);
86 :
87 : // XServiceInfo
88 : virtual OUString SAL_CALL getImplementationName()
89 : throw (RuntimeException, std::exception) SAL_OVERRIDE;
90 : virtual sal_Bool SAL_CALL supportsService(const OUString& ServiceName)
91 : throw (RuntimeException, std::exception) SAL_OVERRIDE;
92 : virtual Sequence< OUString > SAL_CALL getSupportedServiceNames ()
93 : throw (RuntimeException, std::exception) SAL_OVERRIDE;
94 :
95 : /**
96 : Obtain an instance of a DOMImplementation object.
97 : */
98 : virtual Reference< XDOMImplementation > SAL_CALL getDOMImplementation()
99 : throw (RuntimeException, std::exception) SAL_OVERRIDE;
100 :
101 : /**
102 : Indicates whether or not this parser is configured to understand
103 : namespaces.
104 : */
105 : virtual sal_Bool SAL_CALL isNamespaceAware()
106 : throw (RuntimeException, std::exception) SAL_OVERRIDE;
107 :
108 : /**
109 : Indicates whether or not this parser is configured to validate XML
110 : documents.
111 : */
112 : virtual sal_Bool SAL_CALL isValidating()
113 : throw (RuntimeException, std::exception) SAL_OVERRIDE;
114 :
115 : /**
116 : Obtain a new instance of a DOM Document object to build a DOM tree
117 : with.
118 : */
119 : virtual Reference< XDocument > SAL_CALL newDocument()
120 : throw (RuntimeException, std::exception) SAL_OVERRIDE;
121 :
122 : /**
123 : Parse the content of the given InputStream as an XML document and
124 : return a new DOM Document object.
125 : */
126 : virtual Reference< XDocument > SAL_CALL parse(const Reference< XInputStream >& is)
127 : throw (RuntimeException, SAXParseException, IOException, std::exception) SAL_OVERRIDE;
128 :
129 : /**
130 : Parse the content of the given URI as an XML document and return
131 : a new DOM Document object.
132 : */
133 : virtual Reference< XDocument > SAL_CALL parseURI(const OUString& uri)
134 : throw (RuntimeException, SAXParseException, IOException, std::exception) SAL_OVERRIDE;
135 :
136 : /**
137 : Specify the EntityResolver to be used to resolve entities present
138 : in the XML document to be parsed.
139 : */
140 : virtual void SAL_CALL setEntityResolver(const Reference< XEntityResolver >& er)
141 : throw (RuntimeException, std::exception) SAL_OVERRIDE;
142 :
143 : virtual Reference< XEntityResolver > SAL_CALL getEntityResolver()
144 : throw (RuntimeException);
145 :
146 :
147 : /**
148 : Specify the ErrorHandler to be used to report errors present in
149 : the XML document to be parsed.
150 : */
151 : virtual void SAL_CALL setErrorHandler(const Reference< XErrorHandler >& eh)
152 : throw (RuntimeException, std::exception) SAL_OVERRIDE;
153 : };
154 : }
155 :
156 : #endif
157 :
158 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|