Branch libreoffice-5-0-4
[LibreOffice.git] / include / sax / tools / documenthandleradapter.hxx
blob74c3df92640a4d40209ce8a7bb15a40f211e6a72
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/SAXException.hpp>
15 #include <com/sun/star/xml/sax/XDocumentHandler.hpp>
16 #include <com/sun/star/xml/sax/XExtendedDocumentHandler.hpp>
18 namespace sax
20 /**
21 * DocumentHandlerAdapter provides a base class for simple decorators to XDocumentHandlers.
22 * It forwards all method calls to a delegate. An inheriting class only needs to override the
23 * methods it actually wants to modify.
25 * See filters/source/odfflatxml/FlatXml.cxx for an example.
27 class DocumentHandlerAdapter : public ::com::sun::star::xml::sax::XDocumentHandler
29 public:
30 // XDocumentHandler
31 virtual void SAL_CALL
32 startDocument() throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE
34 m_handler->startDocument();
37 virtual void SAL_CALL
38 endDocument() throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE
40 m_handler->endDocument();
43 virtual void SAL_CALL
44 startElement(const OUString& aName,
45 const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList > & xAttribs)
46 throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE
48 m_handler->startElement(aName, xAttribs);
51 virtual void SAL_CALL
52 endElement(const OUString& aName) throw (::com::sun::star::xml::sax::SAXException,
53 ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE
55 m_handler->endElement(aName);
58 virtual void SAL_CALL
59 characters(const OUString& aChars) throw (::com::sun::star::xml::sax::SAXException,
60 ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE
62 m_handler->characters(aChars);
65 virtual void SAL_CALL
66 ignorableWhitespace(const OUString& aWhitespaces) throw (::com::sun::star::xml::sax::SAXException,
67 ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE
69 m_handler->ignorableWhitespace(aWhitespaces);
71 virtual void SAL_CALL
72 processingInstruction(const OUString& aTarget, const OUString& aData)
73 throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE
75 m_handler->processingInstruction(aTarget, aData);
77 virtual void SAL_CALL
78 setDocumentLocator(const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XLocator > & xLocator)
79 throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE
81 m_handler->setDocumentLocator(xLocator);
83 DocumentHandlerAdapter(const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XDocumentHandler >& delegate);
84 DocumentHandlerAdapter() :
85 m_handler(::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XDocumentHandler > (0, ::com::sun::star::uno::UNO_QUERY))
90 protected:
91 virtual void SAL_CALL
92 setDelegate(const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XDocumentHandler >& delegate)
94 m_handler = delegate;
96 virtual ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XDocumentHandler > SAL_CALL
97 getDelegate()
99 return m_handler;
101 virtual
102 ~DocumentHandlerAdapter()
107 private:
108 ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XDocumentHandler > m_handler;
113 * ExtendedDocumentHandlerAdapter provides a base class for simple decorators to XExtendedDocumentHandlers.
114 * It forwards all method calls to a delegate. An inheriting class only needs to override the
115 * methods it actually wants to modify.
117 class ExtendedDocumentHandlerAdapter : public ::com::sun::star::xml::sax::XExtendedDocumentHandler
121 public:
122 // XDocumentHandler
123 virtual void SAL_CALL
124 startDocument() throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE
126 m_handler->startDocument();
129 virtual void SAL_CALL
130 endDocument() throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE
132 m_handler->endDocument();
135 virtual void SAL_CALL
136 startElement(const OUString& aName,
137 const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList > & xAttribs)
138 throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE
140 m_handler->startElement(aName, xAttribs);
143 virtual void SAL_CALL
144 endElement(const OUString& aName) throw (::com::sun::star::xml::sax::SAXException,
145 ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE
147 m_handler->endElement(aName);
150 virtual void SAL_CALL
151 characters(const OUString& aChars) throw (::com::sun::star::xml::sax::SAXException,
152 ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE
154 m_handler->characters(aChars);
157 virtual void SAL_CALL
158 ignorableWhitespace(const OUString& aWhitespaces) throw (::com::sun::star::xml::sax::SAXException,
159 ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE
161 m_handler->ignorableWhitespace(aWhitespaces);
163 virtual void SAL_CALL
164 processingInstruction(const OUString& aTarget, const OUString& aData)
165 throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE
167 m_handler->processingInstruction(aTarget, aData);
169 virtual void SAL_CALL
170 setDocumentLocator(const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XLocator > & xLocator)
171 throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE
173 m_handler->setDocumentLocator(xLocator);
175 // XExtendedDocumentHandler
176 virtual void SAL_CALL
177 startCDATA() throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE
179 m_handler->startCDATA();
181 virtual void SAL_CALL
182 endCDATA() throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE
184 m_handler->endCDATA();
186 virtual void SAL_CALL
187 comment(const OUString& sComment) throw (::com::sun::star::xml::sax::SAXException,
188 ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE
190 m_handler->comment(sComment);
192 virtual void SAL_CALL
193 unknown(const OUString& sString) throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE
195 m_handler->unknown(sString);
197 virtual void SAL_CALL
198 allowLineBreak() throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE
200 m_handler->allowLineBreak();
202 protected:
203 ExtendedDocumentHandlerAdapter() :
204 m_handler(::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XExtendedDocumentHandler > (0, ::com::sun::star::uno::UNO_QUERY))
207 ExtendedDocumentHandlerAdapter(
208 const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XExtendedDocumentHandler >& delegate) :
209 m_handler(delegate)
213 virtual void SAL_CALL
214 setDelegate(const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XExtendedDocumentHandler >& delegate)
216 m_handler = delegate;
218 virtual ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XExtendedDocumentHandler > SAL_CALL
219 getDelegate()
221 return m_handler;
223 virtual
224 ~ExtendedDocumentHandlerAdapter()
229 private:
230 ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XExtendedDocumentHandler > m_handler;
233 #endif // INCLUDED_SAX_TOOLS_DOCUMENTHANDLERADAPTER_HXX
234 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */