1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #ifndef INCLUDED_OOXML_FAST_DOCUMENT_HANDLER_HXX
25 #define INCLUDED_OOXML_FAST_DOCUMENT_HANDLER_HXX
26 
27 #include <sal/config.h>
28 #include <com/sun/star/uno/XComponentContext.hpp>
29 #include <cppuhelper/implbase1.hxx>
30 #include <com/sun/star/xml/sax/XFastDocumentHandler.hpp>
31 #include <resourcemodel/WW8ResourceModel.hxx>
32 #include <ooxml/OOXMLDocument.hxx>
33 #include "OOXMLParserState.hxx"
34 
35 namespace writerfilter {
36 namespace ooxml
37 {
38 using namespace ::com::sun::star;
39 
40 class OOXMLFastContextHandler;
41 
42 class OOXMLFastDocumentHandler:
43     public ::cppu::WeakImplHelper1<
44         xml::sax::XFastDocumentHandler>
45 {
46 public:
47     OOXMLFastDocumentHandler(
48         uno::Reference< uno::XComponentContext > const & context,
49         Stream* pStream,
50         OOXMLDocument* pDocument );
51 
~OOXMLFastDocumentHandler()52     virtual ~OOXMLFastDocumentHandler() {}
53 
54     // ::com::sun::star::xml::sax::XFastDocumentHandler:
55     virtual void SAL_CALL startDocument()
56         throw (uno::RuntimeException, xml::sax::SAXException);
57     virtual void SAL_CALL endDocument()
58         throw (uno::RuntimeException, xml::sax::SAXException);
59     virtual void SAL_CALL setDocumentLocator
60     (const uno::Reference< xml::sax::XLocator > & xLocator)
61         throw (uno::RuntimeException, xml::sax::SAXException);
62 
63     // ::com::sun::star::xml::sax::XFastContextHandler:
64     virtual void SAL_CALL startFastElement
65     (::sal_Int32 Element,
66      const uno::Reference< xml::sax::XFastAttributeList > & Attribs)
67         throw (uno::RuntimeException, xml::sax::SAXException);
68     virtual void SAL_CALL startUnknownElement
69     (const ::rtl::OUString & Namespace,
70      const ::rtl::OUString & Name,
71      const uno::Reference< xml::sax::XFastAttributeList > & Attribs)
72         throw (uno::RuntimeException, xml::sax::SAXException);
73     virtual void SAL_CALL endFastElement(::sal_Int32 Element)
74         throw (uno::RuntimeException, xml::sax::SAXException);
75     virtual void SAL_CALL endUnknownElement
76     (const ::rtl::OUString & Namespace,
77      const ::rtl::OUString & Name)
78         throw (uno::RuntimeException, xml::sax::SAXException);
79     virtual uno::Reference< xml::sax::XFastContextHandler > SAL_CALL
80     createFastChildContext
81     (::sal_Int32 Element,
82      const uno::Reference< xml::sax::XFastAttributeList > & Attribs)
83         throw (uno::RuntimeException, xml::sax::SAXException);
84     virtual uno::Reference< xml::sax::XFastContextHandler > SAL_CALL
85     createUnknownChildContext
86     (const ::rtl::OUString & Namespace,
87      const ::rtl::OUString & Name,
88      const uno::Reference< xml::sax::XFastAttributeList > & Attribs)
89         throw (uno::RuntimeException, xml::sax::SAXException);
90     virtual void SAL_CALL characters(const ::rtl::OUString & aChars)
91         throw (uno::RuntimeException, xml::sax::SAXException);
92 
93     void setIsSubstream( bool bSubstream );
94 
95 private:
96     OOXMLFastDocumentHandler(OOXMLFastDocumentHandler &); // not defined
97     void operator =(OOXMLFastDocumentHandler &); // not defined
98 
99     uno::Reference< uno::XComponentContext > m_xContext;
100 
101     Stream * mpStream;
102 #ifdef DEBUG_ELEMENT
103     Stream::Pointer_t mpTmpStream;
104 #endif
105     OOXMLDocument * mpDocument;
106     mutable boost::shared_ptr<OOXMLFastContextHandler> mpContextHandler;
107     boost::shared_ptr<OOXMLFastContextHandler> getContextHandler() const;
108 };
109 }}
110 
111 #endif // INCLUDED_OOXML_FAST_DOCUMENT_HANDLER_HXX
112