1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 .
21 #include "OOXMLFastDocumentHandler.hxx"
22 #include "OOXMLFastContextHandler.hxx"
23 #include "OOXMLFactory.hxx"
25 namespace writerfilter
{
28 using namespace ::com::sun::star
;
29 using namespace ::std
;
32 OOXMLFastDocumentHandler::OOXMLFastDocumentHandler(
33 uno::Reference
< uno::XComponentContext
> const & context
,
35 OOXMLDocumentImpl
* pDocument
,
39 , mpDocument( pDocument
)
40 , mnXNoteId( nXNoteId
)
45 OOXMLFastDocumentHandler::~OOXMLFastDocumentHandler() {}
47 // css::xml::sax::XFastContextHandler:
48 void SAL_CALL
OOXMLFastDocumentHandler::startFastElement
53 , const uno::Reference
< xml::sax::XFastAttributeList
> & /*Attribs*/)
56 clog
<< this << ":start element:"
57 << fastTokenToId(Element
)
62 void SAL_CALL
OOXMLFastDocumentHandler::startUnknownElement
72 const uno::Reference
< xml::sax::XFastAttributeList
> & /*Attribs*/)
75 clog
<< this << ":start unknown element:"
76 << Namespace
<< ":" << Name
<< endl
;
80 void SAL_CALL
OOXMLFastDocumentHandler::endFastElement(::sal_Int32
87 clog
<< this << ":end element:"
88 << fastTokenToId(Element
)
93 void SAL_CALL
OOXMLFastDocumentHandler::endUnknownElement
105 clog
<< this << ":end unknown element:"
106 << Namespace
<< ":" << Name
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
138 return OOXMLFactory::createFastChildContextFromStart(getContextHandler().get(), Element
);
141 uno::Reference
< xml::sax::XFastContextHandler
> SAL_CALL
142 OOXMLFastDocumentHandler::createUnknownChildContext
152 , const uno::Reference
< xml::sax::XFastAttributeList
> & /*Attribs*/)
155 clog
<< this << ":createUnknownChildContext:"
156 << Namespace
<< ":"<< Name
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: */