lok: vcl: fix multiple floatwin removal case more robustly.
[LibreOffice.git] / writerfilter / source / ooxml / OOXMLFastDocumentHandler.cxx
blob19e6656f128f27a5c2526c740cc68228530825ee
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include <iostream>
21 #include "OOXMLFastDocumentHandler.hxx"
22 #include "OOXMLFastContextHandler.hxx"
23 #include "OOXMLFactory.hxx"
25 namespace writerfilter {
26 namespace ooxml
28 using namespace ::com::sun::star;
29 using namespace ::std;
32 OOXMLFastDocumentHandler::OOXMLFastDocumentHandler(
33 uno::Reference< uno::XComponentContext > const & context,
34 Stream* pStream,
35 OOXMLDocumentImpl* pDocument,
36 sal_Int32 nXNoteId )
37 : m_xContext(context)
38 , mpStream( pStream )
39 , mpDocument( pDocument )
40 , mnXNoteId( nXNoteId )
41 , mxContextHandler()
45 OOXMLFastDocumentHandler::~OOXMLFastDocumentHandler() {}
47 // css::xml::sax::XFastContextHandler:
48 void SAL_CALL OOXMLFastDocumentHandler::startFastElement
49 (::sal_Int32
50 #ifdef DEBUG_WRITERFILTER
51 Element
52 #endif
53 , const uno::Reference< xml::sax::XFastAttributeList > & /*Attribs*/)
55 #ifdef DEBUG_WRITERFILTER
56 clog << this << ":start element:"
57 << fastTokenToId(Element)
58 << endl;
59 #endif
62 void SAL_CALL OOXMLFastDocumentHandler::startUnknownElement
63 (const OUString &
64 #ifdef DEBUG_WRITERFILTER
65 Namespace
66 #endif
67 , const OUString &
68 #ifdef DEBUG_WRITERFILTER
69 Name
70 #endif
72 const uno::Reference< xml::sax::XFastAttributeList > & /*Attribs*/)
74 #ifdef DEBUG_WRITERFILTER
75 clog << this << ":start unknown element:"
76 << Namespace << ":" << Name << endl;
77 #endif
80 void SAL_CALL OOXMLFastDocumentHandler::endFastElement(::sal_Int32
81 #ifdef DEBUG_WRITERFILTER
82 Element
83 #endif
86 #ifdef DEBUG_WRITERFILTER
87 clog << this << ":end element:"
88 << fastTokenToId(Element)
89 << endl;
90 #endif
93 void SAL_CALL OOXMLFastDocumentHandler::endUnknownElement
94 (const OUString &
95 #ifdef DEBUG_WRITERFILTER
96 Namespace
97 #endif
98 , const OUString &
99 #ifdef DEBUG_WRITERFILTER
100 Name
101 #endif
104 #ifdef DEBUG_WRITERFILTER
105 clog << this << ":end unknown element:"
106 << Namespace << ":" << Name
107 << endl;
108 #endif
111 rtl::Reference< OOXMLFastContextHandler > const &
112 OOXMLFastDocumentHandler::getContextHandler() const
114 if (!mxContextHandler.is())
116 mxContextHandler = new OOXMLFastContextHandler(m_xContext);
117 mxContextHandler->setStream(mpStream);
118 mxContextHandler->setDocument(mpDocument);
119 mxContextHandler->setXNoteId(mnXNoteId);
120 mxContextHandler->setForwardEvents(true);
123 return mxContextHandler;
126 uno::Reference< xml::sax::XFastContextHandler > SAL_CALL
127 OOXMLFastDocumentHandler::createFastChildContext
128 (::sal_Int32 Element,
129 const uno::Reference< xml::sax::XFastAttributeList > & /*Attribs*/)
131 if ( mpStream == nullptr && mpDocument == nullptr )
133 // document handler has been created as unknown child - see <OOXMLFastDocumentHandler::createUnknownChildContext(..)>
134 // --> do not provide a child context
135 return nullptr;
138 return OOXMLFactory::createFastChildContextFromStart(getContextHandler().get(), Element);
141 uno::Reference< xml::sax::XFastContextHandler > SAL_CALL
142 OOXMLFastDocumentHandler::createUnknownChildContext
143 (const OUString &
144 #ifdef DEBUG_WRITERFILTER
145 Namespace
146 #endif
148 const OUString &
149 #ifdef DEBUG_WRITERFILTER
150 Name
151 #endif
152 , const uno::Reference< xml::sax::XFastAttributeList > & /*Attribs*/)
154 #ifdef DEBUG_WRITERFILTER
155 clog << this << ":createUnknownChildContext:"
156 << Namespace << ":"<< Name
157 << endl;
158 #endif
160 return uno::Reference< xml::sax::XFastContextHandler >
161 ( new OOXMLFastDocumentHandler( m_xContext, nullptr, nullptr, 0 ) );
164 void SAL_CALL OOXMLFastDocumentHandler::characters(const OUString & /*aChars*/)
168 // css::xml::sax::XFastDocumentHandler:
169 void SAL_CALL OOXMLFastDocumentHandler::startDocument()
173 void SAL_CALL OOXMLFastDocumentHandler::endDocument()
177 void SAL_CALL OOXMLFastDocumentHandler::processingInstruction( const OUString& /*rTarget*/, const OUString& /*rData*/ )
181 void SAL_CALL OOXMLFastDocumentHandler::setDocumentLocator
182 (const uno::Reference< xml::sax::XLocator > & /*xLocator*/)
186 void OOXMLFastDocumentHandler::setIsSubstream( bool bSubstream )
188 if ( mpStream != nullptr && mpDocument != nullptr )
190 getContextHandler( )->getParserState( )->setInSectionGroup( bSubstream );
196 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */