Bump version to 4.1-6
[LibreOffice.git] / writerfilter / source / ooxml / OOXMLFastDocumentHandler.cxx
blobf6f6b60d27d00ac7c4f8f16c7533327cf7446a8e
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 <boost/shared_ptr.hpp>
22 #ifdef DEBUG_ELEMENT
23 #include "ooxmlLoggers.hxx"
24 #include <resourcemodel/Protocol.hxx>
25 #endif
26 #include "OOXMLFastDocumentHandler.hxx"
27 #include "OOXMLFastContextHandler.hxx"
28 #include "ooxml/OOXMLFastTokens.hxx"
29 #include "OOXMLFactory.hxx"
31 namespace writerfilter {
32 namespace ooxml
34 using namespace ::com::sun::star;
35 using namespace ::std;
38 OOXMLFastDocumentHandler::OOXMLFastDocumentHandler
39 (uno::Reference< uno::XComponentContext > const & context)
40 : m_xContext(context), mpStream(0), mpDocument(0)
43 // ::com::sun::star::xml::sax::XFastContextHandler:
44 void SAL_CALL OOXMLFastDocumentHandler::startFastElement
45 (::sal_Int32
46 #ifdef DEBUG_CONTEXT_STACK
47 Element
48 #endif
49 , const uno::Reference< xml::sax::XFastAttributeList > & /*Attribs*/)
50 throw (uno::RuntimeException, xml::sax::SAXException)
52 #ifdef DEBUG_CONTEXT_STACK
53 clog << this << ":start element:"
54 << fastTokenToId(Element)
55 << endl;
56 #endif
59 void SAL_CALL OOXMLFastDocumentHandler::startUnknownElement
60 (const OUString &
61 #ifdef DEBUG_CONTEXT_STACK
62 Namespace
63 #endif
64 , const OUString &
65 #ifdef DEBUG_CONTEXT_STACK
66 Name
67 #endif
69 const uno::Reference< xml::sax::XFastAttributeList > & /*Attribs*/)
70 throw (uno::RuntimeException, xml::sax::SAXException)
72 #ifdef DEBUG_CONTEXT_STACK
73 clog << this << ":start unknown element:"
74 << OUStringToOString(Namespace, RTL_TEXTENCODING_ASCII_US).getStr()
75 << ":"
76 << OUStringToOString(Name, RTL_TEXTENCODING_ASCII_US).getStr()
77 << endl;
78 #endif
81 void SAL_CALL OOXMLFastDocumentHandler::endFastElement(::sal_Int32
82 #ifdef DEBUG_CONTEXT_STACK
83 Element
84 #endif
86 throw (uno::RuntimeException, xml::sax::SAXException)
88 #ifdef DEBUG_CONTEXT_STACK
89 clog << this << ":end element:"
90 << fastTokenToId(Element)
91 << endl;
92 #endif
95 void SAL_CALL OOXMLFastDocumentHandler::endUnknownElement
96 (const OUString &
97 #ifdef DEBUG_CONTEXT_STACK
98 Namespace
99 #endif
100 , const OUString &
101 #ifdef DEBUG_CONTEXT_STACK
102 Name
103 #endif
105 throw (uno::RuntimeException, xml::sax::SAXException)
107 #ifdef DEBUG_CONTEXT_STACK
108 clog << this << ":end unknown element:"
109 << OUStringToOString(Namespace, RTL_TEXTENCODING_ASCII_US).getStr()
110 << ":"
111 << OUStringToOString(Name, RTL_TEXTENCODING_ASCII_US).getStr()
112 << endl;
113 #endif
116 OOXMLFastContextHandler::Pointer_t
117 OOXMLFastDocumentHandler::getContextHandler() const
119 if (mpContextHandler == OOXMLFastContextHandler::Pointer_t())
121 mpContextHandler.reset
122 (new OOXMLFastContextHandler(m_xContext));
123 mpContextHandler->setStream(mpStream);
124 mpContextHandler->setDocument(mpDocument);
125 mpContextHandler->setXNoteId(mnXNoteId);
126 mpContextHandler->setForwardEvents(true);
129 return mpContextHandler;
132 uno::Reference< xml::sax::XFastContextHandler > SAL_CALL
133 OOXMLFastDocumentHandler::createFastChildContext
134 (::sal_Int32 Element,
135 const uno::Reference< xml::sax::XFastAttributeList > & /*Attribs*/)
136 throw (uno::RuntimeException, xml::sax::SAXException)
138 #ifdef DEBUG_CONTEXT_STACK
139 clog << this << ":createFastChildContext:"
140 << fastTokenToId(Element)
141 << endl;
142 #endif
144 return OOXMLFactory::getInstance()->createFastChildContextFromStart(getContextHandler().get(), Element);
147 uno::Reference< xml::sax::XFastContextHandler > SAL_CALL
148 OOXMLFastDocumentHandler::createUnknownChildContext
149 (const OUString &
150 #ifdef DEBUG_CONTEXT_STACK
151 Namespace
152 #endif
154 const OUString &
155 #ifdef DEBUG_CONTEXT_STACK
156 Name
157 #endif
158 , const uno::Reference< xml::sax::XFastAttributeList > & /*Attribs*/)
159 throw (uno::RuntimeException, xml::sax::SAXException)
161 #ifdef DEBUG_CONTEXT_STACK
162 clog << this << ":createUnknownChildContext:"
163 << OUStringToOString(Namespace, RTL_TEXTENCODING_ASCII_US).getStr()
164 << ":"
165 << OUStringToOString(Name, RTL_TEXTENCODING_ASCII_US).getStr()
166 << endl;
167 #endif
169 return uno::Reference< xml::sax::XFastContextHandler >
170 (new OOXMLFastDocumentHandler(m_xContext));
173 void SAL_CALL OOXMLFastDocumentHandler::characters(const OUString & /*aChars*/)
174 throw (uno::RuntimeException, xml::sax::SAXException)
176 // TODO: Insert your implementation for "characters" here.
179 // ::com::sun::star::xml::sax::XFastDocumentHandler:
180 void SAL_CALL OOXMLFastDocumentHandler::startDocument()
181 throw (uno::RuntimeException, xml::sax::SAXException)
185 void SAL_CALL OOXMLFastDocumentHandler::endDocument()
186 throw (uno::RuntimeException, xml::sax::SAXException)
190 void SAL_CALL OOXMLFastDocumentHandler::setDocumentLocator
191 (const uno::Reference< xml::sax::XLocator > & /*xLocator*/)
192 throw (uno::RuntimeException, xml::sax::SAXException)
194 // TODO: Insert your implementation for "setDocumentLocator" here.
197 void OOXMLFastDocumentHandler::setStream(Stream * pStream)
199 #ifdef DEBUG_PROTOCOL
200 mpTmpStream.reset(new StreamProtocol(pStream, debug_logger));
201 mpStream = mpTmpStream.get();
202 #else
203 mpStream = pStream;
204 #endif
207 void OOXMLFastDocumentHandler::setDocument(OOXMLDocument * pDocument)
209 mpDocument = pDocument;
212 void OOXMLFastDocumentHandler::setXNoteId(const sal_Int32 nXNoteId)
214 mnXNoteId = nXNoteId;
217 void OOXMLFastDocumentHandler::setIsSubstream( bool bSubstream )
219 getContextHandler( )->getParserState( )->setInSectionGroup( bSubstream );
224 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */