1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 .
22 #include <sal/types.h>
24 #include <cppuhelper/implbase.hxx>
26 #include <com/sun/star/uno/Reference.h>
27 #include <com/sun/star/uno/Sequence.h>
29 #include <com/sun/star/xml/dom/XDocumentBuilder.hpp>
30 #include <com/sun/star/xml/dom/XDocument.hpp>
31 #include <com/sun/star/xml/dom/XDOMImplementation.hpp>
32 #include <com/sun/star/xml/sax/XEntityResolver.hpp>
33 #include <com/sun/star/xml/sax/XErrorHandler.hpp>
34 #include <com/sun/star/io/XInputStream.hpp>
35 #include <com/sun/star/lang/XServiceInfo.hpp>
40 typedef ::cppu::WeakImplHelper
41 < css::xml::dom::XDocumentBuilder
42 , css::lang::XServiceInfo
43 > CDocumentBuilder_Base
;
45 class CDocumentBuilder
46 : public CDocumentBuilder_Base
49 std::recursive_mutex m_Mutex
;
50 css::uno::Reference
< css::xml::sax::XEntityResolver
> m_xEntityResolver
;
51 css::uno::Reference
< css::xml::sax::XErrorHandler
> m_xErrorHandler
;
56 explicit CDocumentBuilder();
59 virtual OUString SAL_CALL
getImplementationName() override
;
60 virtual sal_Bool SAL_CALL
supportsService(const OUString
& ServiceName
) override
;
61 virtual css::uno::Sequence
< OUString
> SAL_CALL
getSupportedServiceNames () override
;
64 Obtain an instance of a DOMImplementation object.
66 virtual css::uno::Reference
< css::xml::dom::XDOMImplementation
> SAL_CALL
getDOMImplementation() override
;
69 Indicates whether or not this parser is configured to understand
72 virtual sal_Bool SAL_CALL
isNamespaceAware() override
;
75 Indicates whether or not this parser is configured to validate XML
78 virtual sal_Bool SAL_CALL
isValidating() override
;
81 Obtain a new instance of a DOM Document object to build a DOM tree
84 virtual css::uno::Reference
< css::xml::dom::XDocument
> SAL_CALL
newDocument() override
;
87 Parse the content of the given InputStream as an XML document and
88 return a new DOM Document object.
90 virtual css::uno::Reference
< css::xml::dom::XDocument
> SAL_CALL
parse(const css::uno::Reference
< css::io::XInputStream
>& is
) override
;
93 Parse the content of the given URI as an XML document and return
94 a new DOM Document object.
96 virtual css::uno::Reference
< css::xml::dom::XDocument
> SAL_CALL
parseURI(const OUString
& uri
) override
;
99 Specify the EntityResolver to be used to resolve entities present
100 in the XML document to be parsed.
102 virtual void SAL_CALL
setEntityResolver(const css::uno::Reference
< css::xml::sax::XEntityResolver
>& er
) override
;
104 /// @throws css::uno::RuntimeException
105 css::uno::Reference
< css::xml::sax::XEntityResolver
> getEntityResolver();
109 Specify the ErrorHandler to be used to report errors present in
110 the XML document to be parsed.
112 virtual void SAL_CALL
setErrorHandler(const css::uno::Reference
< css::xml::sax::XErrorHandler
>& eh
) override
;
115 Get the ErrorHandler to be used to report errors present in
116 the XML document to be parsed.
119 const css::uno::Reference
< css::xml::sax::XErrorHandler
>& getErrorHandler() const
121 return m_xErrorHandler
;
127 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */