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 .
25 #include <sal/types.h>
26 #include <cppuhelper/implbase.hxx>
27 #include <com/sun/star/uno/Reference.h>
28 #include <com/sun/star/uno/Sequence.h>
30 #include <com/sun/star/xml/dom/XSAXDocumentBuilder2.hpp>
31 #include <com/sun/star/xml/dom/SAXDocumentBuilderState.hpp>
32 #include <com/sun/star/xml/dom/XDocument.hpp>
33 #include <com/sun/star/xml/dom/XDocumentFragment.hpp>
34 #include <com/sun/star/xml/sax/XLocator.hpp>
35 #include <com/sun/star/lang/XServiceInfo.hpp>
36 #include <com/sun/star/uno/XComponentContext.hpp>
40 class CSAXDocumentBuilder
41 : public ::cppu::WeakImplHelper
< css::xml::dom::XSAXDocumentBuilder2
, css::lang::XServiceInfo
>
46 const css::uno::Reference
< css::uno::XComponentContext
> m_xContext
;
48 css::xml::dom::SAXDocumentBuilderState m_aState
;
49 std::stack
< css::uno::Reference
< css::xml::dom::XNode
> > m_aNodeStack
;
51 css::uno::Reference
< css::xml::dom::XDocument
> m_aDocument
;
52 css::uno::Reference
< css::xml::dom::XDocumentFragment
> m_aFragment
;
56 explicit CSAXDocumentBuilder(const css::uno::Reference
< css::uno::XComponentContext
>& );
57 static void setElementFastAttributes(const css::uno::Reference
< css::xml::dom::XElement
>& aElement
, const css::uno::Reference
< css::xml::sax::XFastAttributeList
>& xAttribs
);
61 virtual OUString SAL_CALL
getImplementationName() override
;
62 virtual sal_Bool SAL_CALL
supportsService(const OUString
& ServiceName
) override
;
63 virtual css::uno::Sequence
< OUString
> SAL_CALL
getSupportedServiceNames () override
;
65 // XFastDocumentHandler
66 virtual void SAL_CALL
startDocument() override
;
67 virtual void SAL_CALL
endDocument() override
;
68 virtual void SAL_CALL
processingInstruction( const OUString
& rTarget
, const OUString
& rData
) override
;
69 virtual void SAL_CALL
setDocumentLocator( const css::uno::Reference
< css::xml::sax::XLocator
>& xLocator
) override
;
71 // XFastContextHandler
72 virtual void SAL_CALL
startFastElement( sal_Int32 nElement
, const css::uno::Reference
< css::xml::sax::XFastAttributeList
>& Attribs
) override
;
73 virtual void SAL_CALL
startUnknownElement( const OUString
& Namespace
, const OUString
& Name
, const css::uno::Reference
< css::xml::sax::XFastAttributeList
>& Attribs
) override
;
74 virtual void SAL_CALL
endFastElement( sal_Int32 Element
) override
;
75 virtual void SAL_CALL
endUnknownElement( const OUString
& Namespace
, const OUString
& Name
) override
;
76 virtual css::uno::Reference
< XFastContextHandler
> SAL_CALL
createFastChildContext( sal_Int32 nElement
, const css::uno::Reference
< css::xml::sax::XFastAttributeList
>& Attribs
) override
;
77 virtual css::uno::Reference
< XFastContextHandler
> SAL_CALL
createUnknownChildContext( const OUString
& Namespace
, const OUString
& Name
, const css::uno::Reference
< css::xml::sax::XFastAttributeList
>& Attribs
) override
;
78 virtual void SAL_CALL
characters( const OUString
& aChars
) override
;
80 // XSAXDocumentBuilder
81 virtual css::xml::dom::SAXDocumentBuilderState SAL_CALL
getState() override
;
82 virtual void SAL_CALL
reset() override
;
83 virtual css::uno::Reference
< css::xml::dom::XDocument
> SAL_CALL
getDocument() override
;
84 virtual css::uno::Reference
< css::xml::dom::XDocumentFragment
> SAL_CALL
getDocumentFragment() override
;
85 virtual void SAL_CALL
startDocumentFragment(const css::uno::Reference
< css::xml::dom::XDocument
>& ownerDoc
) override
;
86 virtual void SAL_CALL
endDocumentFragment() override
;
92 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */