Bump version to 6.4-15
[LibreOffice.git] / include / sax / tools / documenthandleradapter.hxx
blob0296abfd669e829e8c7b64d6e154fe2ffd9c6e5d
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 /*
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/.
9 */
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>
17 namespace sax
19 /**
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
28 public:
29 // XDocumentHandler
30 virtual void SAL_CALL
31 startDocument() override
33 m_handler->startDocument();
36 virtual void SAL_CALL
37 endDocument() override
39 m_handler->endDocument();
42 virtual void SAL_CALL
43 startElement(const OUString& aName,
44 const css::uno::Reference< css::xml::sax::XAttributeList > & xAttribs) override
46 m_handler->startElement(aName, xAttribs);
49 virtual void SAL_CALL
50 endElement(const OUString& aName) override
52 m_handler->endElement(aName);
55 virtual void SAL_CALL
56 characters(const OUString& aChars) override
58 m_handler->characters(aChars);
61 virtual void SAL_CALL
62 ignorableWhitespace(const OUString& aWhitespaces) override
64 m_handler->ignorableWhitespace(aWhitespaces);
66 virtual void SAL_CALL
67 processingInstruction(const OUString& aTarget, const OUString& aData) override
69 m_handler->processingInstruction(aTarget, aData);
71 virtual void SAL_CALL
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))
82 protected:
83 void
84 setDelegate(const css::uno::Reference< css::xml::sax::XDocumentHandler >& delegate)
86 m_handler = delegate;
88 const css::uno::Reference< css::xml::sax::XDocumentHandler >&
89 getDelegate() const
91 return m_handler;
93 virtual
94 ~DocumentHandlerAdapter()
99 private:
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
113 public:
114 // XDocumentHandler
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
168 endCDATA() override
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();
187 protected:
188 ExtendedDocumentHandlerAdapter() :
189 m_handler(css::uno::Reference< css::xml::sax::XExtendedDocumentHandler > (nullptr, css::uno::UNO_QUERY))
193 void
194 setDelegate(const css::uno::Reference< css::xml::sax::XExtendedDocumentHandler >& delegate)
196 m_handler = delegate;
198 const css::uno::Reference< css::xml::sax::XExtendedDocumentHandler >&
199 getDelegate() const
201 return m_handler;
203 virtual
204 ~ExtendedDocumentHandlerAdapter()
209 private:
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: */