1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
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/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
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 .
18  */
19 
20 #ifndef INCLUDED_WRITERFILTER_SOURCE_OOXML_OOXMLFASTDOCUMENTHANDLER_HXX
21 #define INCLUDED_WRITERFILTER_SOURCE_OOXML_OOXMLFASTDOCUMENTHANDLER_HXX
22 
23 #include <com/sun/star/uno/XComponentContext.hpp>
24 #include <cppuhelper/implbase.hxx>
25 #include <com/sun/star/xml/sax/XFastDocumentHandler.hpp>
26 #include <dmapper/resourcemodel.hxx>
27 #include <ooxml/OOXMLDocument.hxx>
28 #include <rtl/ref.hxx>
29 #include "OOXMLParserState.hxx"
30 
31 namespace writerfilter {
32 namespace ooxml
33 {
34 
35 class OOXMLFastContextHandler;
36 
37 class OOXMLFastDocumentHandler : public cppu::WeakImplHelper<css::xml::sax::XFastDocumentHandler>
38 {
39 public:
40     OOXMLFastDocumentHandler(
41         css::uno::Reference< css::uno::XComponentContext > const & context,
42         Stream* pStream,
43         OOXMLDocumentImpl* pDocument,
44         sal_Int32 nXNoteId );
45     virtual ~OOXMLFastDocumentHandler() override;
46 
47     // css::xml::sax::XFastDocumentHandler:
48     virtual void SAL_CALL startDocument() override;
49     virtual void SAL_CALL endDocument() override;
50     virtual void SAL_CALL processingInstruction( const OUString& rTarget, const OUString& rData ) override;
51     virtual void SAL_CALL setDocumentLocator
52     (const css::uno::Reference< css::xml::sax::XLocator > & xLocator) override;
53 
54     // css::xml::sax::XFastContextHandler:
55     virtual void SAL_CALL startFastElement
56     (::sal_Int32 Element,
57      const css::uno::Reference< css::xml::sax::XFastAttributeList > & Attribs) override;
58     virtual void SAL_CALL startUnknownElement
59     (const OUString & Namespace,
60      const OUString & Name,
61      const css::uno::Reference< css::xml::sax::XFastAttributeList > & Attribs) override;
62     virtual void SAL_CALL endFastElement(::sal_Int32 Element) override;
63     virtual void SAL_CALL endUnknownElement
64     (const OUString & Namespace,
65      const OUString & Name) override;
66     virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL
67     createFastChildContext
68     (::sal_Int32 Element,
69      const css::uno::Reference< css::xml::sax::XFastAttributeList > & Attribs) override;
70     virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL
71     createUnknownChildContext
72     (const OUString & Namespace,
73      const OUString & Name,
74      const css::uno::Reference< css::xml::sax::XFastAttributeList > & Attribs) override;
75     virtual void SAL_CALL characters(const OUString & aChars) override;
76 
77     void setIsSubstream( bool bSubstream );
78 
79 private:
80     OOXMLFastDocumentHandler(OOXMLFastDocumentHandler const &) = delete;
81     void operator =(OOXMLFastDocumentHandler const &) = delete;
82 
83     css::uno::Reference< css::uno::XComponentContext > m_xContext;
84 
85     Stream * const mpStream;
86     OOXMLDocumentImpl* const mpDocument;
87     sal_Int32 const mnXNoteId;
88     mutable rtl::Reference<OOXMLFastContextHandler> mxContextHandler;
89     rtl::Reference<OOXMLFastContextHandler> const & getContextHandler() const;
90 };
91 }}
92 
93 #endif // INCLUDED_WRITERFILTER_SOURCE_OOXML_OOXMLFASTDOCUMENTHANDLER_HXX
94 
95 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
96