1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
4 * This file is part of the LibreOffice project.
6 * This Source Code Form is subject to the terms of the Mozilla Public
7 * License, v. 2.0. If a copy of the MPL was not distributed with this
8 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
11 #ifndef INCLUDED_SAX_TOOLS_DOCUMENTHANDLERADAPTER_HXX
12 #define INCLUDED_SAX_TOOLS_DOCUMENTHANDLERADAPTER_HXX
14 #include <com/sun/star/xml/sax/XDocumentHandler.hpp>
15 #include <com/sun/star/xml/sax/XExtendedDocumentHandler.hpp>
20 * DocumentHandlerAdapter provides a base class for simple decorators to XDocumentHandlers.
21 * It forwards all method calls to a delegate. An inheriting class only needs to override the
22 * methods it actually wants to modify.
24 * See filters/source/odfflatxml/FlatXml.cxx for an example.
26 class DocumentHandlerAdapter
: public css::xml::sax::XDocumentHandler
31 startDocument() override
33 m_handler
->startDocument();
37 endDocument() override
39 m_handler
->endDocument();
43 startElement(const OUString
& aName
,
44 const css::uno::Reference
< css::xml::sax::XAttributeList
> & xAttribs
) override
46 m_handler
->startElement(aName
, xAttribs
);
50 endElement(const OUString
& aName
) override
52 m_handler
->endElement(aName
);
56 characters(const OUString
& aChars
) override
58 m_handler
->characters(aChars
);
62 ignorableWhitespace(const OUString
& aWhitespaces
) override
64 m_handler
->ignorableWhitespace(aWhitespaces
);
67 processingInstruction(const OUString
& aTarget
, const OUString
& aData
) override
69 m_handler
->processingInstruction(aTarget
, aData
);
72 setDocumentLocator(const css::uno::Reference
< css::xml::sax::XLocator
> & xLocator
) override
74 m_handler
->setDocumentLocator(xLocator
);
76 DocumentHandlerAdapter() :
77 m_handler(css::uno::Reference
< css::xml::sax::XDocumentHandler
> (nullptr, css::uno::UNO_QUERY
))
84 setDelegate(const css::uno::Reference
< css::xml::sax::XDocumentHandler
>& delegate
)
88 const css::uno::Reference
< css::xml::sax::XDocumentHandler
>&
94 ~DocumentHandlerAdapter()
100 css::uno::Reference
< css::xml::sax::XDocumentHandler
> m_handler
;
105 * ExtendedDocumentHandlerAdapter provides a base class for simple decorators to XExtendedDocumentHandlers.
106 * It forwards all method calls to a delegate. An inheriting class only needs to override the
107 * methods it actually wants to modify.
109 class ExtendedDocumentHandlerAdapter
: public css::xml::sax::XExtendedDocumentHandler
115 virtual void SAL_CALL
116 startDocument() override
118 m_handler
->startDocument();
121 virtual void SAL_CALL
122 endDocument() override
124 m_handler
->endDocument();
127 virtual void SAL_CALL
128 startElement(const OUString
& aName
,
129 const css::uno::Reference
< css::xml::sax::XAttributeList
> & xAttribs
) override
131 m_handler
->startElement(aName
, xAttribs
);
134 virtual void SAL_CALL
135 endElement(const OUString
& aName
) override
137 m_handler
->endElement(aName
);
140 virtual void SAL_CALL
141 characters(const OUString
& aChars
) override
143 m_handler
->characters(aChars
);
146 virtual void SAL_CALL
147 ignorableWhitespace(const OUString
& aWhitespaces
) override
149 m_handler
->ignorableWhitespace(aWhitespaces
);
151 virtual void SAL_CALL
152 processingInstruction(const OUString
& aTarget
, const OUString
& aData
) override
154 m_handler
->processingInstruction(aTarget
, aData
);
156 virtual void SAL_CALL
157 setDocumentLocator(const css::uno::Reference
< css::xml::sax::XLocator
> & xLocator
) override
159 m_handler
->setDocumentLocator(xLocator
);
161 // XExtendedDocumentHandler
162 virtual void SAL_CALL
163 startCDATA() override
165 m_handler
->startCDATA();
167 virtual void SAL_CALL
170 m_handler
->endCDATA();
172 virtual void SAL_CALL
173 comment(const OUString
& sComment
) override
175 m_handler
->comment(sComment
);
177 virtual void SAL_CALL
178 unknown(const OUString
& sString
) override
180 m_handler
->unknown(sString
);
182 virtual void SAL_CALL
183 allowLineBreak() override
185 m_handler
->allowLineBreak();
188 ExtendedDocumentHandlerAdapter() :
189 m_handler(css::uno::Reference
< css::xml::sax::XExtendedDocumentHandler
> (nullptr, css::uno::UNO_QUERY
))
194 setDelegate(const css::uno::Reference
< css::xml::sax::XExtendedDocumentHandler
>& delegate
)
196 m_handler
= delegate
;
198 const css::uno::Reference
< css::xml::sax::XExtendedDocumentHandler
>&
204 ~ExtendedDocumentHandlerAdapter()
210 css::uno::Reference
< css::xml::sax::XExtendedDocumentHandler
> m_handler
;
213 #endif // INCLUDED_SAX_TOOLS_DOCUMENTHANDLERADAPTER_HXX
214 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */