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>
26 namespace writerfilter::ooxml
28 using namespace ::com::sun::star
;
31 OOXMLFastDocumentHandler::OOXMLFastDocumentHandler(
32 uno::Reference
< uno::XComponentContext
> context
,
34 OOXMLDocumentImpl
* pDocument
,
36 : m_xContext(std::move(context
))
38 , mpDocument( pDocument
)
39 , mnXNoteId( nXNoteId
)
43 OOXMLFastDocumentHandler::~OOXMLFastDocumentHandler() {}
45 // css::xml::sax::XFastContextHandler:
46 void SAL_CALL
OOXMLFastDocumentHandler::startFastElement(sal_Int32 Element
47 , const uno::Reference
< xml::sax::XFastAttributeList
> & /*Attribs*/)
49 SAL_INFO("writerfilter", "start element:" << fastTokenToId(Element
));
52 void SAL_CALL
OOXMLFastDocumentHandler::startUnknownElement
53 (const OUString
& Namespace
54 , const OUString
& Name
55 , const uno::Reference
< xml::sax::XFastAttributeList
> & /*Attribs*/)
57 SAL_INFO("writerfilter", "start unknown element:" << Namespace
<< ":" << Name
);
60 void SAL_CALL
OOXMLFastDocumentHandler::endFastElement(sal_Int32 Element
)
62 SAL_INFO("writerfilter", "end element:" << fastTokenToId(Element
));
65 void SAL_CALL
OOXMLFastDocumentHandler::endUnknownElement
66 (const OUString
& Namespace
67 , const OUString
& Name
)
69 SAL_INFO("writerfilter", "end unknown element:" << Namespace
<< ":" << Name
);
72 rtl::Reference
< OOXMLFastContextHandler
> const &
73 OOXMLFastDocumentHandler::getContextHandler() const
75 if (!mxContextHandler
.is())
77 mxContextHandler
= new OOXMLFastContextHandler(m_xContext
);
78 mxContextHandler
->setStream(mpStream
);
79 mxContextHandler
->setDocument(mpDocument
);
80 mxContextHandler
->setXNoteId(mnXNoteId
);
81 mxContextHandler
->setForwardEvents(true);
84 return mxContextHandler
;
87 uno::Reference
< xml::sax::XFastContextHandler
> SAL_CALL
88 OOXMLFastDocumentHandler::createFastChildContext
90 const uno::Reference
< xml::sax::XFastAttributeList
> & /*Attribs*/)
92 if ( mpStream
== nullptr && mpDocument
== nullptr )
94 // document handler has been created as unknown child - see <OOXMLFastDocumentHandler::createUnknownChildContext(..)>
95 // --> do not provide a child context
99 return OOXMLFactory::createFastChildContextFromStart(getContextHandler().get(), Element
);
102 uno::Reference
< xml::sax::XFastContextHandler
> SAL_CALL
103 OOXMLFastDocumentHandler::createUnknownChildContext
104 (const OUString
& Namespace
105 , const OUString
& Name
106 , const uno::Reference
< xml::sax::XFastAttributeList
> & /*Attribs*/)
108 SAL_INFO("writerfilter", "createUnknownChildContext:" << Namespace
<< ":"<< Name
);
110 return uno::Reference
< xml::sax::XFastContextHandler
>
111 ( new OOXMLFastDocumentHandler( m_xContext
, nullptr, nullptr, 0 ) );
114 void SAL_CALL
OOXMLFastDocumentHandler::characters(const OUString
& /*aChars*/)
118 // css::xml::sax::XFastDocumentHandler:
119 void SAL_CALL
OOXMLFastDocumentHandler::startDocument()
123 void SAL_CALL
OOXMLFastDocumentHandler::endDocument()
127 void SAL_CALL
OOXMLFastDocumentHandler::processingInstruction( const OUString
& /*rTarget*/, const OUString
& /*rData*/ )
131 void SAL_CALL
OOXMLFastDocumentHandler::setDocumentLocator
132 (const uno::Reference
< xml::sax::XLocator
> & /*xLocator*/)
136 void OOXMLFastDocumentHandler::setIsSubstream( bool bSubstream
)
138 if ( mpStream
!= nullptr && mpDocument
!= nullptr )
140 getContextHandler( )->getParserState( )->setInSectionGroup( bSubstream
);
146 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */