LibreOffice Module writerfilter (master) 1
OOXMLFastDocumentHandler.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19
22#include "OOXMLFactory.hxx"
23#include <sal/log.hxx>
24#include <utility>
25
26namespace writerfilter::ooxml
27{
28using namespace ::com::sun::star;
29
30
32 uno::Reference< uno::XComponentContext > context,
33 Stream* pStream,
34 OOXMLDocumentImpl* pDocument,
35 sal_Int32 nXNoteId )
36 : m_xContext(std::move(context))
37 , mpStream( pStream )
38 , mpDocument( pDocument )
39 , mnXNoteId( nXNoteId )
40{
41}
42
43OOXMLFastDocumentHandler::~OOXMLFastDocumentHandler() {}
44
45// css::xml::sax::XFastContextHandler:
46void SAL_CALL OOXMLFastDocumentHandler::startFastElement(sal_Int32 Element
48{
49 SAL_INFO("writerfilter", "start element:" << fastTokenToId(Element));
50}
51
52void SAL_CALL OOXMLFastDocumentHandler::startUnknownElement
53(const OUString & Namespace
54, const OUString & Name
56{
57 SAL_INFO("writerfilter", "start unknown element:" << Namespace << ":" << Name);
58}
59
60void SAL_CALL OOXMLFastDocumentHandler::endFastElement(sal_Int32 Element)
61{
62 SAL_INFO("writerfilter", "end element:" << fastTokenToId(Element));
63}
64
65void SAL_CALL OOXMLFastDocumentHandler::endUnknownElement
66(const OUString & Namespace
67, const OUString & Name)
68{
69 SAL_INFO("writerfilter", "end unknown element:" << Namespace << ":" << Name);
70}
71
73OOXMLFastDocumentHandler::getContextHandler() const
74{
75 if (!mxContextHandler.is())
76 {
77 mxContextHandler = new OOXMLFastContextHandler(m_xContext);
78 mxContextHandler->setStream(mpStream);
79 mxContextHandler->setDocument(mpDocument);
80 mxContextHandler->setXNoteId(mnXNoteId);
81 mxContextHandler->setForwardEvents(true);
82 }
83
84 return mxContextHandler;
85}
86
88 OOXMLFastDocumentHandler::createFastChildContext
89(::sal_Int32 Element,
91{
92 if ( mpStream == nullptr && mpDocument == nullptr )
93 {
94 // document handler has been created as unknown child - see <OOXMLFastDocumentHandler::createUnknownChildContext(..)>
95 // --> do not provide a child context
96 return nullptr;
97 }
98
99 return OOXMLFactory::createFastChildContextFromStart(getContextHandler().get(), Element);
100}
101
103OOXMLFastDocumentHandler::createUnknownChildContext
104(const OUString & Namespace
105, const OUString & Name
107{
108 SAL_INFO("writerfilter", "createUnknownChildContext:" << Namespace << ":"<< Name);
109
111 ( new OOXMLFastDocumentHandler( m_xContext, nullptr, nullptr, 0 ) );
112}
113
114void SAL_CALL OOXMLFastDocumentHandler::characters(const OUString & /*aChars*/)
115{
116}
117
118// css::xml::sax::XFastDocumentHandler:
119void SAL_CALL OOXMLFastDocumentHandler::startDocument()
120{
121}
122
123void SAL_CALL OOXMLFastDocumentHandler::endDocument()
124{
125}
126
127void SAL_CALL OOXMLFastDocumentHandler::processingInstruction( const OUString& /*rTarget*/, const OUString& /*rData*/ )
128{
129}
130
131void SAL_CALL OOXMLFastDocumentHandler::setDocumentLocator
132(const uno::Reference< xml::sax::XLocator > & /*xLocator*/)
133{
134}
135
136void OOXMLFastDocumentHandler::setIsSubstream( bool bSubstream )
137{
138 if ( mpStream != nullptr && mpDocument != nullptr )
139 {
140 getContextHandler( )->getParserState( )->setInSectionGroup( bSubstream );
141 }
142}
143
144}
145
146/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Reference< XComponentContext > m_xContext
OOXMLFastDocumentHandler(css::uno::Reference< css::uno::XComponentContext > context, Stream *pStream, OOXMLDocumentImpl *pDocument, sal_Int32 nXNoteId)
#define SAL_INFO(area, stream)
def fastTokenToId(model)
Definition: factoryimpl.py:110
def createFastChildContextFromStart(model)
Definition: factoryimpl.py:87
css::uno::Reference< css::linguistic2::XProofreadingIterator > get(css::uno::Reference< css::uno::XComponentContext > const &context)
OUString Name