merge the formfield patch from ooo-build
[ooovba.git] / writerfilter / source / ooxml / OOXMLFastDocumentHandler.cxx
blob016599aca29ac30ae7e4d47b476c0f61dae15111
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: OOXMLFastDocumentHandler.cxx,v $
10 * $Revision: 1.4 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #include <iostream>
32 #include <boost/shared_ptr.hpp>
33 #include "OOXMLFastDocumentHandler.hxx"
34 #include "OOXMLFastContextHandler.hxx"
35 #include "OOXMLFastTokens.hxx"
37 namespace writerfilter {
38 namespace ooxml
40 using namespace ::com::sun::star;
41 using namespace ::std;
44 OOXMLFastDocumentHandler::OOXMLFastDocumentHandler
45 (uno::Reference< uno::XComponentContext > const & context)
46 : m_xContext(context)
49 // ::com::sun::star::xml::sax::XFastContextHandler:
50 void SAL_CALL OOXMLFastDocumentHandler::startFastElement
51 (::sal_Int32
52 #ifdef DEBUG_CONTEXT_STACK
53 Element
54 #endif
55 , const uno::Reference< xml::sax::XFastAttributeList > & /*Attribs*/)
56 throw (uno::RuntimeException, xml::sax::SAXException)
58 #ifdef DEBUG_CONTEXT_STACK
59 clog << this << ":start element:"
60 << fastTokenToId(Element)
61 << endl;
62 #endif
65 void SAL_CALL OOXMLFastDocumentHandler::startUnknownElement
66 (const ::rtl::OUString &
67 #ifdef DEBUG_CONTEXT_STACK
68 Namespace
69 #endif
70 , const ::rtl::OUString &
71 #ifdef DEBUG_CONTEXT_STACK
72 Name
73 #endif
75 const uno::Reference< xml::sax::XFastAttributeList > & /*Attribs*/)
76 throw (uno::RuntimeException, xml::sax::SAXException)
78 #ifdef DEBUG_CONTEXT_STACK
79 clog << this << ":start unknown element:"
80 << OUStringToOString(Namespace, RTL_TEXTENCODING_ASCII_US).getStr()
81 << ":"
82 << OUStringToOString(Name, RTL_TEXTENCODING_ASCII_US).getStr()
83 << endl;
84 #endif
87 void SAL_CALL OOXMLFastDocumentHandler::endFastElement(::sal_Int32
88 #ifdef DEBUG_CONTEXT_STACK
89 Element
90 #endif
92 throw (uno::RuntimeException, xml::sax::SAXException)
94 #ifdef DEBUG_CONTEXT_STACK
95 clog << this << ":end element:"
96 << fastTokenToId(Element)
97 << endl;
98 #endif
101 void SAL_CALL OOXMLFastDocumentHandler::endUnknownElement
102 (const ::rtl::OUString &
103 #ifdef DEBUG_CONTEXT_STACK
104 Namespace
105 #endif
106 , const ::rtl::OUString &
107 #ifdef DEBUG_CONTEXT_STACK
108 Name
109 #endif
111 throw (uno::RuntimeException, xml::sax::SAXException)
113 #ifdef DEBUG_CONTEXT_STACK
114 clog << this << ":end unknown element:"
115 << OUStringToOString(Namespace, RTL_TEXTENCODING_ASCII_US).getStr()
116 << ":"
117 << OUStringToOString(Name, RTL_TEXTENCODING_ASCII_US).getStr()
118 << endl;
119 #endif
122 OOXMLFastContextHandler::Pointer_t
123 OOXMLFastDocumentHandler::getContextHandler() const
125 if (mpContextHandler == OOXMLFastContextHandler::Pointer_t())
127 mpContextHandler.reset
128 (new OOXMLFastContextHandler(m_xContext));
129 mpContextHandler->setStream(mpStream);
130 mpContextHandler->setDocument(mpDocument);
131 mpContextHandler->setXNoteId(msXNoteId);
132 mpContextHandler->setForwardEvents(true);
135 return mpContextHandler;
138 uno::Reference< xml::sax::XFastContextHandler > SAL_CALL
139 OOXMLFastDocumentHandler::createFastChildContext
140 (::sal_Int32 Element,
141 const uno::Reference< xml::sax::XFastAttributeList > & Attribs)
142 throw (uno::RuntimeException, xml::sax::SAXException)
144 #ifdef DEBUG_CONTEXT_STACK
145 clog << this << ":createFastChildContext:"
146 << fastTokenToId(Element)
147 << endl;
148 #endif
150 return getContextHandler()->createFromStart(Element, Attribs);
153 OOXMLParserState::Pointer_t OOXMLFastDocumentHandler::getParserState() const
155 OOXMLParserState::Pointer_t pParserState;
157 return getContextHandler()->getParserState();
160 uno::Reference< xml::sax::XFastContextHandler > SAL_CALL
161 OOXMLFastDocumentHandler::createUnknownChildContext
162 (const ::rtl::OUString &
163 #ifdef DEBUG_CONTEXT_STACK
164 Namespace
165 #endif
167 const ::rtl::OUString &
168 #ifdef DEBUG_CONTEXT_STACK
169 Name
170 #endif
171 , const uno::Reference< xml::sax::XFastAttributeList > & /*Attribs*/)
172 throw (uno::RuntimeException, xml::sax::SAXException)
174 #ifdef DEBUG_CONTEXT_STACK
175 clog << this << ":createUnknownChildContext:"
176 << OUStringToOString(Namespace, RTL_TEXTENCODING_ASCII_US).getStr()
177 << ":"
178 << OUStringToOString(Name, RTL_TEXTENCODING_ASCII_US).getStr()
179 << endl;
180 #endif
182 return uno::Reference< xml::sax::XFastContextHandler >
183 (new OOXMLFastDocumentHandler(m_xContext));
186 void SAL_CALL OOXMLFastDocumentHandler::characters(const ::rtl::OUString & /*aChars*/)
187 throw (uno::RuntimeException, xml::sax::SAXException)
189 // TODO: Insert your implementation for "characters" here.
192 // ::com::sun::star::xml::sax::XFastDocumentHandler:
193 void SAL_CALL OOXMLFastDocumentHandler::startDocument()
194 throw (uno::RuntimeException, xml::sax::SAXException)
198 void SAL_CALL OOXMLFastDocumentHandler::endDocument()
199 throw (uno::RuntimeException, xml::sax::SAXException)
201 #ifdef DEBUG_CONTEXT_STACK
202 OOXMLFastContextHandler::dumpOpenContexts();
203 #endif
206 void SAL_CALL OOXMLFastDocumentHandler::setDocumentLocator
207 (const uno::Reference< xml::sax::XLocator > & /*xLocator*/)
208 throw (uno::RuntimeException, xml::sax::SAXException)
210 // TODO: Insert your implementation for "setDocumentLocator" here.
213 void OOXMLFastDocumentHandler::setStream(Stream * pStream)
215 mpStream = pStream;
218 void OOXMLFastDocumentHandler::setDocument(OOXMLDocument * pDocument)
220 mpDocument = pDocument;
223 void OOXMLFastDocumentHandler::setXNoteId(const ::rtl::OUString & rXNoteId)
225 msXNoteId = rXNoteId;
228 void OOXMLFastDocumentHandler::setIsSubstream( bool bSubstream )
230 getContextHandler( )->getParserState( )->setInSectionGroup( bSubstream );