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 .
20 #include "OOXMLFastDocumentHandler.hxx"
21 #include "OOXMLFastContextHandler.hxx"
22 #include "OOXMLFactory.hxx"
23 #include <sal/log.hxx>
25 namespace writerfilter::ooxml
27 using namespace ::com::sun::star
;
28 using namespace ::std
;
31 OOXMLFastDocumentHandler::OOXMLFastDocumentHandler(
32 uno::Reference
< uno::XComponentContext
> const & context
,
34 OOXMLDocumentImpl
* pDocument
,
38 , mpDocument( pDocument
)
39 , mnXNoteId( nXNoteId
)
44 OOXMLFastDocumentHandler::~OOXMLFastDocumentHandler() {}
46 // css::xml::sax::XFastContextHandler:
47 void SAL_CALL
OOXMLFastDocumentHandler::startFastElement(sal_Int32 Element
48 , const uno::Reference
< xml::sax::XFastAttributeList
> & /*Attribs*/)
50 SAL_INFO("writerfilter", "start element:" << fastTokenToId(Element
));
53 void SAL_CALL
OOXMLFastDocumentHandler::startUnknownElement
54 (const OUString
& Namespace
55 , const OUString
& Name
56 , const uno::Reference
< xml::sax::XFastAttributeList
> & /*Attribs*/)
58 SAL_INFO("writerfilter", "start unknown element:" << Namespace
<< ":" << Name
);
61 void SAL_CALL
OOXMLFastDocumentHandler::endFastElement(sal_Int32 Element
)
63 SAL_INFO("writerfilter", "end element:" << fastTokenToId(Element
));
66 void SAL_CALL
OOXMLFastDocumentHandler::endUnknownElement
67 (const OUString
& Namespace
68 , const OUString
& Name
)
70 SAL_INFO("writerfilter", "end unknown element:" << Namespace
<< ":" << Name
);
73 rtl::Reference
< OOXMLFastContextHandler
> const &
74 OOXMLFastDocumentHandler::getContextHandler() const
76 if (!mxContextHandler
.is())
78 mxContextHandler
= new OOXMLFastContextHandler(m_xContext
);
79 mxContextHandler
->setStream(mpStream
);
80 mxContextHandler
->setDocument(mpDocument
);
81 mxContextHandler
->setXNoteId(mnXNoteId
);
82 mxContextHandler
->setForwardEvents(true);
85 return mxContextHandler
;
88 uno::Reference
< xml::sax::XFastContextHandler
> SAL_CALL
89 OOXMLFastDocumentHandler::createFastChildContext
91 const uno::Reference
< xml::sax::XFastAttributeList
> & /*Attribs*/)
93 if ( mpStream
== nullptr && mpDocument
== nullptr )
95 // document handler has been created as unknown child - see <OOXMLFastDocumentHandler::createUnknownChildContext(..)>
96 // --> do not provide a child context
100 return OOXMLFactory::createFastChildContextFromStart(getContextHandler().get(), Element
);
103 uno::Reference
< xml::sax::XFastContextHandler
> SAL_CALL
104 OOXMLFastDocumentHandler::createUnknownChildContext
105 (const OUString
& Namespace
106 , const OUString
& Name
107 , const uno::Reference
< xml::sax::XFastAttributeList
> & /*Attribs*/)
109 SAL_INFO("writerfilter", "createUnknownChildContext:" << Namespace
<< ":"<< Name
);
111 return uno::Reference
< xml::sax::XFastContextHandler
>
112 ( new OOXMLFastDocumentHandler( m_xContext
, nullptr, nullptr, 0 ) );
115 void SAL_CALL
OOXMLFastDocumentHandler::characters(const OUString
& /*aChars*/)
119 // css::xml::sax::XFastDocumentHandler:
120 void SAL_CALL
OOXMLFastDocumentHandler::startDocument()
124 void SAL_CALL
OOXMLFastDocumentHandler::endDocument()
128 void SAL_CALL
OOXMLFastDocumentHandler::processingInstruction( const OUString
& /*rTarget*/, const OUString
& /*rData*/ )
132 void SAL_CALL
OOXMLFastDocumentHandler::setDocumentLocator
133 (const uno::Reference
< xml::sax::XLocator
> & /*xLocator*/)
137 void OOXMLFastDocumentHandler::setIsSubstream( bool bSubstream
)
139 if ( mpStream
!= nullptr && mpDocument
!= nullptr )
141 getContextHandler( )->getParserState( )->setInSectionGroup( bSubstream
);
147 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */