Line data Source code
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 :
20 : #include <stdio.h>
21 : #include <iostream>
22 : #include <set>
23 : #include <comphelper/servicehelper.hxx>
24 : #include <com/sun/star/drawing/XShapes.hpp>
25 : #include <resourcemodel/QNameToString.hxx>
26 : #include <resourcemodel/XPathLogger.hxx>
27 : #include <resourcemodel/util.hxx>
28 : #include <ooxml/resourceids.hxx>
29 : #include <doctok/sprmids.hxx>
30 : #include <ooxml/OOXMLnamespaceids.hxx>
31 : #include <dmapper/DomainMapper.hxx>
32 : #include <dmapper/GraphicHelpers.hxx>
33 : #include <comphelper/embeddedobjectcontainer.hxx>
34 : #include <tools/globname.hxx>
35 : #include <comphelper/classids.hxx>
36 : #include <sfx2/sfxbasemodel.hxx>
37 : #include "OOXMLFastContextHandler.hxx"
38 : #include "OOXMLFactory.hxx"
39 : #include "Handler.hxx"
40 : #include "ooxmlLoggers.hxx"
41 :
42 : static const sal_Unicode uCR = 0xd;
43 : static const sal_Unicode uFtnEdnRef = 0x2;
44 : static const sal_Unicode uFtnEdnSep = 0x3;
45 : static const sal_Unicode uTab = 0x9;
46 : static const sal_Unicode uPgNum = 0x0;
47 : static const sal_Unicode uNoBreakHyphen = 0x2011;
48 : static const sal_Unicode uSoftHyphen = 0xAD;
49 :
50 : static const sal_uInt8 cFtnEdnCont = 0x4;
51 : static const sal_uInt8 cFieldStart = 0x13;
52 : static const sal_uInt8 cFieldSep = 0x14;
53 : static const sal_uInt8 cFieldEnd = 0x15;
54 :
55 : namespace writerfilter {
56 : namespace ooxml
57 : {
58 : using ::com::sun::star::lang::XMultiComponentFactory;
59 : using namespace ::com::sun::star;
60 : using namespace ::std;
61 :
62 : #if OSL_DEBUG_LEVEL > 1
63 : static string resourceToString
64 : (OOXMLFastContextHandler::ResourceEnum_t eResource)
65 : {
66 : string sResult;
67 :
68 : switch (eResource)
69 : {
70 : case OOXMLFastContextHandler::STREAM:
71 : sResult = "Stream";
72 : break;
73 : case OOXMLFastContextHandler::PROPERTIES:
74 : sResult = "Properties";
75 : break;
76 : case OOXMLFastContextHandler::TABLE:
77 : sResult = "Table";
78 : break;
79 : case OOXMLFastContextHandler::SHAPE:
80 : sResult = "Shape";
81 : break;
82 : default:
83 : sResult = "??";
84 : }
85 :
86 : return sResult;
87 : }
88 : #endif
89 :
90 8 : set<OOXMLFastContextHandler *> aSetContexts;
91 :
92 : #if OSL_DEBUG_LEVEL > 1
93 : class OOXMLIdToString : public IdToString
94 : {
95 : public:
96 : OOXMLIdToString() : IdToString() {}
97 : virtual ~OOXMLIdToString() {}
98 :
99 : virtual string toString(const Id & rId) const
100 : {
101 : string s((*QNameToString::Instance())(rId));
102 :
103 : if (s.empty())
104 : s = "(fasttoken)" + fastTokenToId(rId);
105 : else
106 : s = "(qname)" + s;
107 :
108 : return s;
109 : }
110 : };
111 : #endif
112 :
113 : /*
114 : class OOXMLFastContextHandler
115 : */
116 :
117 : sal_uInt32 OOXMLFastContextHandler::mnInstanceCount = 0;
118 :
119 828 : OOXMLFastContextHandler::OOXMLFastContextHandler
120 : (uno::Reference< uno::XComponentContext > const & context)
121 : : mpParent(NULL),
122 : mId(0),
123 : mnDefine(0),
124 : mnToken(OOXML_FAST_TOKENS_END),
125 : mpStream(NULL),
126 : mnTableDepth(0),
127 : mnInstanceNumber(mnInstanceCount),
128 : mnRefCount(0),
129 : inPositionV(false),
130 : m_xContext(context),
131 828 : m_bDiscardChildren(false)
132 : {
133 828 : mnInstanceCount++;
134 828 : aSetContexts.insert(this);
135 :
136 828 : if (mpParserState.get() == NULL)
137 828 : mpParserState.reset(new OOXMLParserState());
138 :
139 828 : mpParserState->incContextCount();
140 828 : }
141 :
142 61461 : OOXMLFastContextHandler::OOXMLFastContextHandler
143 : (OOXMLFastContextHandler * pContext)
144 : : cppu::WeakImplHelper1<com::sun::star::xml::sax::XFastContextHandler>(),
145 : mpParent(pContext),
146 : mId(0),
147 : mnDefine(0),
148 : mnToken(OOXML_FAST_TOKENS_END),
149 : mpStream(NULL),
150 : mnTableDepth(0),
151 : mnInstanceNumber(mnInstanceCount),
152 : mnRefCount(0),
153 : inPositionV(pContext->inPositionV),
154 : m_xContext(pContext->m_xContext),
155 61461 : m_bDiscardChildren(pContext->m_bDiscardChildren)
156 : {
157 61461 : if (pContext != NULL)
158 : {
159 61461 : mpStream = pContext->mpStream;
160 61461 : mpParserState = pContext->mpParserState;
161 61461 : mnTableDepth = pContext->mnTableDepth;
162 61461 : m_xContext = pContext->m_xContext;
163 : }
164 :
165 61461 : if (mpParserState.get() == NULL)
166 0 : mpParserState.reset(new OOXMLParserState());
167 :
168 61461 : mnInstanceCount++;
169 61461 : aSetContexts.insert(this);
170 61461 : mpParserState->incContextCount();
171 61461 : }
172 :
173 125457 : OOXMLFastContextHandler::~OOXMLFastContextHandler()
174 : {
175 62306 : aSetContexts.erase(this);
176 63151 : }
177 :
178 : // ::com::sun::star::xml::sax::XFastContextHandler:
179 63965 : void SAL_CALL OOXMLFastContextHandler::startFastElement
180 : (Token_t Element,
181 : const uno::Reference< xml::sax::XFastAttributeList > & Attribs)
182 : throw (uno::RuntimeException, xml::sax::SAXException)
183 : {
184 : #ifdef DEBUG_CONTEXT_HANDLER
185 : debug_logger->startElement("contexthandler.element");
186 : string sToken = fastTokenToId(Element);
187 : mpParserState->getXPathLogger().startElement(sToken);
188 : debug_logger->attribute("token", sToken);
189 : debug_logger->attribute("type", getType());
190 : debug_logger->attribute("xpath", mpParserState->getXPathLogger().getXPath());
191 : debug_logger->startElement("at-start");
192 : dumpXml( debug_logger );
193 : debug_logger->endElement();
194 : #endif
195 63965 : if ((Element & 0xffff0000) == NS_mce && (Element & 0xffff) == OOXML_Choice)
196 0 : m_bDiscardChildren = true;
197 :
198 63965 : if (!m_bDiscardChildren)
199 : {
200 63965 : attributes(Attribs);
201 63965 : lcl_startFastElement(Element, Attribs);
202 : }
203 63965 : }
204 :
205 17 : void SAL_CALL OOXMLFastContextHandler::startUnknownElement
206 : (const OUString & Namespace, const OUString & Name,
207 : const uno::Reference< xml::sax::XFastAttributeList > & /*Attribs*/)
208 : throw (uno::RuntimeException, xml::sax::SAXException)
209 : {
210 : #ifdef DEBUG_CONTEXT_HANDLER
211 : debug_logger->startElement("contexthandler.unknown-element");
212 : debug_logger->attribute("namespace", Namespace);
213 : debug_logger->attribute("name", Name);
214 : mpParserState->getXPathLogger().startElement("unknown");
215 : #else
216 : (void) Namespace;
217 : (void) Name;
218 : #endif
219 17 : }
220 :
221 63959 : void SAL_CALL OOXMLFastContextHandler::endFastElement(Token_t Element)
222 : throw (uno::RuntimeException, xml::sax::SAXException)
223 : {
224 : #ifdef DEBUG_CONTEXT_HANDLER
225 : string sToken = fastTokenToId(Element);
226 : (void) sToken;
227 : #endif
228 :
229 63959 : if ((Element & 0xffff0000) == NS_mce && (Element & 0xffff) == OOXML_Choice)
230 0 : m_bDiscardChildren = false;
231 :
232 63959 : if (!m_bDiscardChildren)
233 63959 : lcl_endFastElement(Element);
234 :
235 : #ifdef DEBUG_CONTEXT_HANDLER
236 : debug_logger->startElement("at-end");
237 : dumpXml( debug_logger );
238 : debug_logger->endElement();
239 : debug_logger->endElement();
240 : mpParserState->getXPathLogger().endElement();
241 : #endif
242 63959 : }
243 :
244 60308 : void OOXMLFastContextHandler::lcl_startFastElement
245 : (Token_t Element,
246 : const uno::Reference< xml::sax::XFastAttributeList > & /*Attribs*/)
247 : throw (uno::RuntimeException, xml::sax::SAXException)
248 : {
249 60308 : OOXMLFactory::getInstance()->startAction(this, Element);
250 60308 : if( Element == (NS_wordprocessingDrawing|OOXML_positionV) )
251 5 : inPositionV = true;
252 60303 : else if( Element == (NS_wordprocessingDrawing|OOXML_positionH) )
253 5 : inPositionV = false;
254 :
255 60308 : }
256 :
257 3976 : void OOXMLFastContextHandler::lcl_endFastElement
258 : (Token_t Element)
259 : throw (uno::RuntimeException, xml::sax::SAXException)
260 : {
261 3976 : OOXMLFactory::getInstance()->endAction(this, Element);
262 3976 : }
263 :
264 17 : void SAL_CALL OOXMLFastContextHandler::endUnknownElement
265 : (const OUString & , const OUString & )
266 : throw (uno::RuntimeException, xml::sax::SAXException)
267 : {
268 : #ifdef DEBUG_CONTEXT_HANDLER
269 : debug_logger->endElement();
270 : mpParserState->getXPathLogger().endElement();
271 : #endif
272 17 : }
273 :
274 : uno::Reference< xml::sax::XFastContextHandler > SAL_CALL
275 64908 : OOXMLFastContextHandler::createFastChildContext
276 : (Token_t Element,
277 : const uno::Reference< xml::sax::XFastAttributeList > & Attribs)
278 : throw (uno::RuntimeException, xml::sax::SAXException)
279 : {
280 : #ifdef DEBUG_CONTEXT_HANDLER
281 : debug_logger->startElement("contexthandler.createFastChildContext");
282 : debug_logger->attribute("token", fastTokenToId(Element));
283 : debug_logger->attribute("type", getType());
284 : debug_logger->attribute("discard-children", OUString::valueOf(m_bDiscardChildren));
285 : #endif
286 :
287 64908 : uno::Reference< xml::sax::XFastContextHandler > xResult;
288 64908 : if ((Element & 0xffff0000) != NS_mce && !m_bDiscardChildren)
289 64908 : xResult.set(lcl_createFastChildContext(Element, Attribs));
290 0 : else if ((Element & 0xffff0000) == NS_mce)
291 0 : xResult = this;
292 :
293 : #ifdef DEBUG_CONTEXT_HANDLER
294 : debug_logger->endElement();
295 : #endif
296 :
297 64908 : return xResult;
298 : }
299 :
300 : uno::Reference< xml::sax::XFastContextHandler >
301 61418 : OOXMLFastContextHandler::lcl_createFastChildContext
302 : (Token_t Element,
303 : const uno::Reference< xml::sax::XFastAttributeList > & /*Attribs*/)
304 : throw (uno::RuntimeException, xml::sax::SAXException)
305 : {
306 61418 : return OOXMLFactory::getInstance()->createFastChildContext(this, Element);
307 : }
308 :
309 : uno::Reference< xml::sax::XFastContextHandler > SAL_CALL
310 17 : OOXMLFastContextHandler::createUnknownChildContext
311 : (const OUString & Namespace,
312 : const OUString & Name,
313 : const uno::Reference< xml::sax::XFastAttributeList > & /*Attribs*/)
314 : throw (uno::RuntimeException, xml::sax::SAXException)
315 : {
316 : #ifdef DEBUG_CONTEXT_HANDLER
317 : debug_logger->startElement("contexthandler.createUnknownChildContext");
318 : debug_logger->attribute("namespace", Namespace);
319 : debug_logger->attribute("name", Name);
320 : debug_logger->endElement();
321 : #else
322 : (void) Namespace;
323 : (void) Name;
324 : #endif
325 :
326 : return uno::Reference< xml::sax::XFastContextHandler >
327 17 : (new OOXMLFastContextHandler(*const_cast<const OOXMLFastContextHandler *>(this)));
328 : }
329 :
330 15291 : void SAL_CALL OOXMLFastContextHandler::characters
331 : (const OUString & aChars)
332 : throw (uno::RuntimeException, xml::sax::SAXException)
333 : {
334 15291 : lcl_characters(aChars);
335 15291 : }
336 :
337 13156 : void OOXMLFastContextHandler::lcl_characters
338 : (const OUString & rString)
339 : throw (uno::RuntimeException, xml::sax::SAXException)
340 : {
341 13156 : if (!m_bDiscardChildren)
342 13156 : OOXMLFactory::getInstance()->characters(this, rString);
343 13156 : }
344 :
345 : namespace
346 : {
347 : class theOOXMLFastContextHandlerUnoTunnelId : public rtl::Static< UnoTunnelIdInit, theOOXMLFastContextHandlerUnoTunnelId > {};
348 : }
349 :
350 0 : const uno::Sequence< sal_Int8 > & OOXMLFastContextHandler::getUnoTunnelId()
351 : {
352 0 : return theOOXMLFastContextHandlerUnoTunnelId::get().getSeq();
353 : }
354 :
355 0 : sal_Int64 SAL_CALL OOXMLFastContextHandler::getSomething( const uno::Sequence< sal_Int8 >& rId )
356 : throw(uno::RuntimeException)
357 : {
358 0 : if( rId.getLength() == 16
359 0 : && 0 == memcmp( getUnoTunnelId().getConstArray(),
360 0 : rId.getConstArray(), 16 ) )
361 : {
362 : return sal::static_int_cast<sal_Int64>
363 0 : (reinterpret_cast<sal_IntPtr>(this));
364 : }
365 :
366 0 : return 0x0;
367 : }
368 :
369 828 : void OOXMLFastContextHandler::setStream(Stream * pStream)
370 : {
371 828 : mpStream = pStream;
372 828 : }
373 :
374 0 : OOXMLValue::Pointer_t OOXMLFastContextHandler::getValue() const
375 : {
376 0 : return OOXMLValue::Pointer_t();
377 : }
378 :
379 62906 : void OOXMLFastContextHandler::attributes
380 : (const uno::Reference< xml::sax::XFastAttributeList > & Attribs)
381 : throw (uno::RuntimeException, xml::sax::SAXException)
382 : {
383 62906 : OOXMLFactory::getInstance()->attributes(this, Attribs);
384 62906 : }
385 :
386 128 : void OOXMLFastContextHandler::startAction(Token_t Element)
387 : {
388 : #ifdef DEBUG_CONTEXT_HANDLER
389 : debug_logger->startElement("contexthandler.startAction");
390 : #endif
391 128 : lcl_startAction(Element);
392 : #ifdef DEBUG_CONTEXT_HANDLER
393 : debug_logger->endElement();
394 : #endif
395 128 : }
396 :
397 128 : void OOXMLFastContextHandler::lcl_startAction(Token_t Element)
398 : {
399 128 : OOXMLFactory::getInstance()->startAction(this, Element);
400 128 : }
401 :
402 56044 : void OOXMLFastContextHandler::endAction(Token_t Element)
403 : {
404 : #ifdef DEBUG_CONTEXT_HANDLER
405 : debug_logger->startElement("contexthandler.endAction");
406 : #endif
407 56044 : lcl_endAction(Element);
408 : #ifdef DEBUG_CONTEXT_HANDLER
409 : debug_logger->endElement();
410 : #endif
411 56044 : }
412 :
413 56044 : void OOXMLFastContextHandler::lcl_endAction(Token_t Element)
414 : {
415 56044 : OOXMLFactory::getInstance()->endAction(this, Element);
416 56044 : }
417 :
418 : #if OSL_DEBUG_LEVEL > 1
419 : void OOXMLFastContextHandler::dumpXml( const TagLogger::Pointer_t pLogger ) const
420 : {
421 : pLogger->startElement("context");
422 :
423 : static char sBuffer[128];
424 : snprintf(sBuffer, sizeof(sBuffer), "%p", this);
425 :
426 : pLogger->attribute("parent", std::string(sBuffer));
427 : pLogger->attribute("type", getType());
428 : pLogger->attribute("resource", resourceToString(getResource()));
429 : pLogger->attribute("token", fastTokenToId(getToken()));
430 : pLogger->attribute("id", (*QNameToString::Instance())(getId()));
431 :
432 : OOXMLValue::Pointer_t pVal(getValue());
433 :
434 : if (pVal.get() != NULL)
435 : pLogger->attribute("value", pVal->toString());
436 : else
437 : pLogger->attribute("value", std::string("(null)"));
438 :
439 : pLogger->propertySet(getPropertySet(),
440 : IdToString::Pointer_t(new OOXMLIdToString()));
441 :
442 : mpParserState->dumpXml( pLogger );
443 :
444 : pLogger->endElement();
445 : }
446 :
447 : #endif
448 :
449 61461 : void OOXMLFastContextHandler::setId(Id rId)
450 : {
451 : #ifdef DEBUG_CONTEXT_HANDLER
452 : debug_logger->startElement("contexthandler.setId");
453 :
454 : static char sBuffer[256];
455 : snprintf(sBuffer, sizeof(sBuffer), "%" SAL_PRIuUINT32, rId);
456 :
457 : debug_logger->attribute("id", std::string(sBuffer));
458 : debug_logger->attribute("name", (*QNameToString::Instance())(rId));
459 : debug_logger->endElement();
460 : #endif
461 :
462 61461 : mId = rId;
463 61461 : }
464 :
465 33101 : Id OOXMLFastContextHandler::getId() const
466 : {
467 33101 : return mId;
468 : }
469 :
470 60524 : void OOXMLFastContextHandler::setDefine(Id nDefine)
471 : {
472 60524 : mnDefine = nDefine;
473 60524 : }
474 :
475 514261 : Id OOXMLFastContextHandler::getDefine() const
476 : {
477 514261 : return mnDefine;
478 : }
479 :
480 244 : OOXMLParserState::Pointer_t OOXMLFastContextHandler::getParserState() const
481 : {
482 244 : return mpParserState;
483 : }
484 :
485 61461 : void OOXMLFastContextHandler::setToken(Token_t nToken)
486 : {
487 61461 : mnToken = nToken;
488 :
489 : #ifdef DEBUG_CONTEXT_HANDLER
490 : msTokenString = fastTokenToId(mnToken);
491 : #endif
492 61461 : }
493 :
494 942 : Token_t OOXMLFastContextHandler::getToken() const
495 : {
496 942 : return mnToken;
497 : }
498 :
499 5 : void OOXMLFastContextHandler::mark(const Id & rId, OOXMLValue::Pointer_t pVal)
500 : {
501 5 : OOXMLPropertySetImpl::Pointer_t pPropSet(new OOXMLPropertySetImpl());
502 : OOXMLPropertyImpl::Pointer_t pProperty
503 10 : (new OOXMLPropertyImpl(rId, pVal, OOXMLPropertyImpl::ATTRIBUTE));
504 :
505 5 : pPropSet->add(pProperty);
506 10 : mpStream->props(pPropSet);
507 5 : }
508 :
509 0 : void OOXMLFastContextHandler::setParent
510 : (OOXMLFastContextHandler * pParent)
511 : {
512 0 : mpParent = pParent;
513 0 : }
514 :
515 0 : OOXMLPropertySet * OOXMLFastContextHandler::getPicturePropSet
516 : (const OUString & rId)
517 : {
518 0 : return dynamic_cast<OOXMLDocumentImpl *>(mpParserState->getDocument())->
519 0 : getPicturePropSet(rId);
520 : }
521 :
522 1122 : void OOXMLFastContextHandler::sendTableDepth() const
523 : {
524 : #ifdef DEBUG_CONTEXT_HANDLER
525 : debug_logger->startElement("contexthandler.sendTableDepth");
526 : #endif
527 :
528 1122 : if (mnTableDepth > 0)
529 : {
530 582 : OOXMLPropertySet * pProps = new OOXMLPropertySetImpl();
531 : {
532 : OOXMLValue::Pointer_t pVal
533 582 : (new OOXMLIntegerValue(mnTableDepth));
534 : OOXMLProperty::Pointer_t pProp
535 1164 : (new OOXMLPropertyImpl(NS_sprm::LN_PTableDepth, pVal, OOXMLPropertyImpl::SPRM));
536 1164 : pProps->add(pProp);
537 : }
538 : {
539 : OOXMLValue::Pointer_t pVal
540 582 : (new OOXMLIntegerValue(1));
541 : OOXMLProperty::Pointer_t pProp
542 1164 : (new OOXMLPropertyImpl(NS_sprm::LN_PFInTable, pVal, OOXMLPropertyImpl::SPRM));
543 1164 : pProps->add(pProp);
544 : }
545 :
546 582 : mpStream->props(writerfilter::Reference<Properties>::Pointer_t(pProps));
547 : }
548 : #ifdef DEBUG_CONTEXT_HANDLER
549 : debug_logger->endElement();
550 : #endif
551 1122 : }
552 :
553 1122 : void OOXMLFastContextHandler::setHandle()
554 : {
555 1122 : mpParserState->setHandle();
556 1122 : mpStream->info(mpParserState->getHandle());
557 1122 : }
558 :
559 1710 : void OOXMLFastContextHandler::startCharacterGroup()
560 : {
561 : #ifdef DEBUG_CONTEXT_HANDLER
562 : debug_logger->element("contexthandler.startCharacterGroup");
563 : #endif
564 :
565 1710 : if (isForwardEvents())
566 : {
567 1710 : if (mpParserState->isInCharacterGroup())
568 398 : endCharacterGroup();
569 :
570 1710 : if (! mpParserState->isInParagraphGroup())
571 0 : startParagraphGroup();
572 :
573 1710 : if (! mpParserState->isInCharacterGroup())
574 : {
575 1710 : mpStream->startCharacterGroup();
576 1710 : mpParserState->setInCharacterGroup(true);
577 1710 : mpParserState->resolveCharacterProperties(*mpStream);
578 : }
579 : }
580 1710 : }
581 :
582 1631 : void OOXMLFastContextHandler::endCharacterGroup()
583 : {
584 : #ifdef DEBUG_CONTEXT_HANDLER
585 : debug_logger->element("contexthandler.endCharacterGroup");
586 : #endif
587 :
588 1631 : if (isForwardEvents() && mpParserState->isInCharacterGroup())
589 : {
590 1630 : mpStream->endCharacterGroup();
591 1630 : mpParserState->setInCharacterGroup(false);
592 : }
593 1631 : }
594 :
595 1291 : void OOXMLFastContextHandler::startParagraphGroup()
596 : {
597 : #ifdef DEBUG_CONTEXT_HANDLER
598 : debug_logger->element("contexthandler.startParagraphGroup");
599 : #endif
600 :
601 1291 : if (isForwardEvents())
602 : {
603 1291 : if (mpParserState->isInParagraphGroup())
604 293 : endParagraphGroup();
605 :
606 1291 : if (! mpParserState->isInSectionGroup())
607 0 : startSectionGroup();
608 :
609 1291 : if (! mpParserState->isInParagraphGroup())
610 : {
611 1291 : mpStream->startParagraphGroup();
612 1291 : mpParserState->setInParagraphGroup(true);
613 : }
614 : }
615 1291 : }
616 :
617 1212 : void OOXMLFastContextHandler::endParagraphGroup()
618 : {
619 : #ifdef DEBUG_CONTEXT_HANDLER
620 : debug_logger->element("contexthandler.endParagraphGroup");
621 : #endif
622 :
623 1212 : if (isForwardEvents())
624 : {
625 1212 : if (mpParserState->isInCharacterGroup())
626 881 : endCharacterGroup();
627 :
628 1212 : if (mpParserState->isInParagraphGroup())
629 : {
630 1211 : mpStream->endParagraphGroup();
631 1211 : mpParserState->setInParagraphGroup(false);
632 : }
633 : }
634 1212 : }
635 :
636 7 : void OOXMLFastContextHandler::startSdt()
637 : {
638 : #ifdef DEBUG_CONTEXT_HANDLER
639 : debug_logger->element("contexthandler.startSdt");
640 : #endif
641 :
642 7 : OOXMLPropertySet * pProps = new OOXMLPropertySetImpl();
643 7 : OOXMLValue::Pointer_t pVal(new OOXMLIntegerValue(1));
644 14 : OOXMLProperty::Pointer_t pProp(new OOXMLPropertyImpl(NS_ooxml::LN_CT_SdtBlock_sdtContent, pVal, OOXMLPropertyImpl::ATTRIBUTE));
645 7 : pProps->add(pProp);
646 14 : mpStream->props(writerfilter::Reference<Properties>::Pointer_t(pProps));
647 7 : }
648 :
649 7 : void OOXMLFastContextHandler::endSdt()
650 : {
651 : #ifdef DEBUG_CONTEXT_HANDLER
652 : debug_logger->element("contexthandler.endSdt");
653 : #endif
654 :
655 7 : OOXMLPropertySet * pProps = new OOXMLPropertySetImpl();
656 7 : OOXMLValue::Pointer_t pVal(new OOXMLIntegerValue(1));
657 14 : OOXMLProperty::Pointer_t pProp(new OOXMLPropertyImpl(NS_ooxml::LN_CT_SdtBlock_sdtEndContent, pVal, OOXMLPropertyImpl::ATTRIBUTE));
658 7 : pProps->add(pProp);
659 14 : mpStream->props(writerfilter::Reference<Properties>::Pointer_t(pProps));
660 7 : }
661 :
662 180 : void OOXMLFastContextHandler::startSectionGroup()
663 : {
664 : #ifdef DEBUG_CONTEXT_HANDLER
665 : debug_logger->element("contexthandler.startSectionGroup");
666 : #endif
667 :
668 180 : if (isForwardEvents())
669 : {
670 180 : if (mpParserState->isInSectionGroup())
671 15 : endSectionGroup();
672 :
673 180 : if (! mpParserState->isInSectionGroup())
674 : {
675 180 : mpStream->info(mpParserState->getHandle());
676 180 : mpStream->startSectionGroup();
677 180 : mpParserState->setInSectionGroup(true);
678 : }
679 : }
680 180 : }
681 :
682 179 : void OOXMLFastContextHandler::endSectionGroup()
683 : {
684 : #ifdef DEBUG_CONTEXT_HANDLER
685 : debug_logger->element("contexthandler.endSectionGroup");
686 : #endif
687 :
688 179 : if (isForwardEvents())
689 : {
690 179 : if (mpParserState->isInParagraphGroup())
691 17 : endParagraphGroup();
692 :
693 179 : if (mpParserState->isInSectionGroup())
694 : {
695 179 : mpStream->endSectionGroup();
696 179 : mpParserState->setInSectionGroup(false);
697 : }
698 : }
699 179 : }
700 :
701 176 : void OOXMLFastContextHandler::setLastParagraphInSection()
702 : {
703 176 : mpParserState->setLastParagraphInSection(true);
704 176 : mpStream->markLastParagraphInSection( );
705 176 : }
706 :
707 18796 : void OOXMLFastContextHandler::newProperty
708 : (const Id & /*nId*/, OOXMLValue::Pointer_t /*pVal*/)
709 : {
710 18796 : }
711 :
712 5 : void OOXMLFastContextHandler::setPropertySet
713 : (OOXMLPropertySet::Pointer_t /* pPropertySet */)
714 : {
715 5 : }
716 :
717 2577 : OOXMLPropertySet::Pointer_t OOXMLFastContextHandler::getPropertySet() const
718 : {
719 2577 : return OOXMLPropertySet::Pointer_t();
720 : }
721 :
722 15 : void OOXMLFastContextHandler::startField()
723 : {
724 : #ifdef DEBUG_CONTEXT_HANDLER
725 : debug_logger->element("contexthandler.startField");
726 : #endif
727 15 : startCharacterGroup();
728 15 : if (isForwardEvents())
729 15 : mpStream->text(&cFieldStart, 1);
730 15 : endCharacterGroup();
731 15 : }
732 :
733 11 : void OOXMLFastContextHandler::fieldSeparator()
734 : {
735 : #ifdef DEBUG_CONTEXT_HANDLER
736 : debug_logger->element("contexthandler.fieldSeparator");
737 : #endif
738 11 : startCharacterGroup();
739 11 : if (isForwardEvents())
740 11 : mpStream->text(&cFieldSep, 1);
741 11 : endCharacterGroup();
742 11 : }
743 :
744 15 : void OOXMLFastContextHandler::endField()
745 : {
746 : #ifdef DEBUG_CONTEXT_HANDLER
747 : debug_logger->element("contexthandler.endField");
748 : #endif
749 15 : startCharacterGroup();
750 15 : if (isForwardEvents())
751 15 : mpStream->text(&cFieldEnd, 1);
752 15 : endCharacterGroup();
753 15 : }
754 :
755 0 : void OOXMLFastContextHandler::ftnednref()
756 : {
757 : #ifdef DEBUG_CONTEXT_HANDLER
758 : debug_logger->element("contexthandler.ftnednref");
759 : #endif
760 0 : if (isForwardEvents())
761 0 : mpStream->utext((const sal_uInt8*)&uFtnEdnRef, 1);
762 0 : }
763 :
764 0 : void OOXMLFastContextHandler::ftnednsep()
765 : {
766 : #ifdef DEBUG_CONTEXT_HANDLER
767 : debug_logger->element("contexthandler.ftnednsep");
768 : #endif
769 0 : if (isForwardEvents())
770 0 : mpStream->utext((const sal_uInt8*)&uFtnEdnSep, 1);
771 0 : }
772 :
773 0 : void OOXMLFastContextHandler::ftnedncont()
774 : {
775 : #ifdef DEBUG_CONTEXT_HANDLER
776 : debug_logger->element("contexthandler.ftnedncont");
777 : #endif
778 0 : if (isForwardEvents())
779 0 : mpStream->text(&cFtnEdnCont, 1);
780 0 : }
781 :
782 0 : void OOXMLFastContextHandler::pgNum()
783 : {
784 : #ifdef DEBUG_CONTEXT_HANDLER
785 : debug_logger->element("contexthandler.pgNum");
786 : #endif
787 0 : if (isForwardEvents())
788 0 : mpStream->utext((const sal_uInt8*)&uPgNum, 1);
789 0 : }
790 :
791 2 : void OOXMLFastContextHandler::tab()
792 : {
793 : #ifdef DEBUG_CONTEXT_HANDLER
794 : debug_logger->element("contexthandler.tab");
795 : #endif
796 2 : if (isForwardEvents())
797 2 : mpStream->utext((const sal_uInt8*)&uTab, 1);
798 2 : }
799 :
800 0 : void OOXMLFastContextHandler::cr()
801 : {
802 : #ifdef DEBUG_CONTEXT_HANDLER
803 : debug_logger->element("contexthandler.cr");
804 : #endif
805 0 : if (isForwardEvents())
806 0 : mpStream->utext((const sal_uInt8*)&uCR, 1);
807 0 : }
808 :
809 0 : void OOXMLFastContextHandler::noBreakHyphen()
810 : {
811 : #ifdef DEBUG_CONTEXT_HANDLER
812 : debug_logger->element("contexthandler.noBreakHyphen");
813 : #endif
814 0 : if (isForwardEvents())
815 0 : mpStream->utext((const sal_uInt8*)&uNoBreakHyphen, 1);
816 0 : }
817 :
818 0 : void OOXMLFastContextHandler::softHyphen()
819 : {
820 : #ifdef DEBUG_CONTEXT_HANDLER
821 : debug_logger->element("contexthandler.softHyphen");
822 : #endif
823 0 : if (isForwardEvents())
824 0 : mpStream->utext((const sal_uInt8*)&uSoftHyphen, 1);
825 0 : }
826 :
827 1122 : void OOXMLFastContextHandler::handleLastParagraphInSection()
828 : {
829 : #ifdef DEBUG_CONTEXT_HANDLER
830 : debug_logger->element("contexthandler.handleLastParagraphInSection");
831 : #endif
832 :
833 1122 : if (mpParserState->isLastParagraphInSection())
834 : {
835 15 : mpParserState->setLastParagraphInSection(false);
836 15 : startSectionGroup();
837 : }
838 1122 : }
839 :
840 1121 : void OOXMLFastContextHandler::endOfParagraph()
841 : {
842 : #ifdef DEBUG_CONTEXT_HANDLER
843 : debug_logger->element("contexthandler.endOfParagraph");
844 : #endif
845 1121 : if (! mpParserState->isInCharacterGroup())
846 545 : startCharacterGroup();
847 1121 : if (isForwardEvents())
848 1121 : mpStream->utext((const sal_uInt8*)&uCR, 1);
849 1121 : }
850 :
851 21 : void OOXMLFastContextHandler::startTxbxContent()
852 : {
853 : #ifdef DEBUG_CONTEXT_HANDLER
854 : debug_logger->element("contexthandler.startTxbxContent");
855 : #endif
856 : /*
857 : This usually means there are recursive <w:p> elements, and the ones
858 : inside and outside of w:txbxContent should not interfere (e.g.
859 : the lastParagraphInSection setting). So save the whole state
860 : and possibly start new groups for the nested content (not section
861 : group though, as that'd cause the txbxContent to be moved onto
862 : another page, I'm not sure how that should work exactly).
863 : */
864 21 : mpParserState->startTxbxContent();
865 21 : startParagraphGroup();
866 21 : }
867 :
868 21 : void OOXMLFastContextHandler::endTxbxContent()
869 : {
870 : #ifdef DEBUG_CONTEXT_HANDLER
871 : debug_logger->element("contexthandler.endTxbxContent");
872 : #endif
873 21 : endParagraphGroup();
874 21 : mpParserState->endTxbxContent();
875 21 : }
876 :
877 677 : void OOXMLFastContextHandler::text(const OUString & sText)
878 : {
879 : #ifdef DEBUG_CONTEXT_HANDLER
880 : debug_logger->startElement("contexthandler.text");
881 : debug_logger->chars(sText);
882 : debug_logger->endElement();
883 : #endif
884 677 : if (isForwardEvents())
885 : mpStream->utext(reinterpret_cast < const sal_uInt8 * >
886 677 : (sText.getStr()),
887 1354 : sText.getLength());
888 677 : }
889 :
890 : /*
891 : HACK. An ugly hack. The problem with wp:positionOffset, wp:alignV and wp:alignH
892 : is that they do not work in the usual OOXML way of <tag val="value"/> but instead
893 : it's <tag>value</tag>, which is otherwise used only things like <t>. And I really
894 : haven't managed to find out how to make this XML parsing monstrosity to handle this
895 : on its own, so the code is modelled after <t> handling and does it manually in a hackish
896 : way - it reads the value as text and converts itself, moreover the reading of the value
897 : is done sooner than lcl_sprms() actually results in processing the tags it is enclosed
898 : in, so the values are stored in PositionHandler for later use.
899 : */
900 8 : void OOXMLFastContextHandler::positionOffset(const OUString & sText)
901 : {
902 : #ifdef DEBUG_ELEMENT
903 : debug_logger->startElement("positionOffset");
904 : debug_logger->chars(sText);
905 : debug_logger->endElement();
906 : #endif
907 8 : if (isForwardEvents())
908 8 : ::writerfilter::dmapper::PositionHandler::setPositionOffset( sText, inPositionV );
909 8 : }
910 :
911 1 : void OOXMLFastContextHandler::alignH(const OUString & sText)
912 : {
913 : #ifdef DEBUG_ELEMENT
914 : debug_logger->startElement("alignH");
915 : debug_logger->chars(sText);
916 : debug_logger->endElement();
917 : #endif
918 1 : if (isForwardEvents())
919 1 : ::writerfilter::dmapper::PositionHandler::setAlignH( sText );
920 1 : }
921 :
922 1 : void OOXMLFastContextHandler::alignV(const OUString & sText)
923 : {
924 : #ifdef DEBUG_ELEMENT
925 : debug_logger->startElement("alignV");
926 : debug_logger->chars(sText);
927 : debug_logger->endElement();
928 : #endif
929 1 : if (isForwardEvents())
930 1 : ::writerfilter::dmapper::PositionHandler::setAlignV( sText );
931 1 : }
932 :
933 0 : void OOXMLFastContextHandler::propagateCharacterProperties()
934 : {
935 : #ifdef DEBUG_CONTEXT_HANDLER
936 : debug_logger->startElement("contexthandler.propagateCharacterProperties");
937 : debug_logger->propertySet(getPropertySet(),
938 : IdToString::Pointer_t(new OOXMLIdToString()));
939 : debug_logger->endElement();
940 : #endif
941 :
942 0 : mpParserState->setCharacterProperties(getPropertySet());
943 0 : }
944 :
945 10 : void OOXMLFastContextHandler::propagateCharacterPropertiesAsSet(const Id & rId)
946 : {
947 : #ifdef DEBUG_CONTEXT_HANDLER
948 : debug_logger->startElement("contexthandler.propagateCharacterPropertiesAsSet");
949 : debug_logger->propertySet(getPropertySet(),
950 : IdToString::Pointer_t(new OOXMLIdToString()));
951 : debug_logger->endElement();
952 : #endif
953 :
954 10 : OOXMLValue::Pointer_t pValue(new OOXMLPropertySetValue(getPropertySet()));
955 20 : OOXMLPropertySet::Pointer_t pPropertySet(new OOXMLPropertySetImpl());
956 :
957 : OOXMLProperty::Pointer_t pProp
958 20 : (new OOXMLPropertyImpl(rId, pValue, OOXMLPropertyImpl::SPRM));
959 :
960 10 : pPropertySet->add(pProp);
961 20 : mpParserState->setCharacterProperties(pPropertySet);
962 10 : }
963 :
964 0 : bool OOXMLFastContextHandler::propagatesProperties() const
965 : {
966 0 : return false;
967 : }
968 :
969 548 : void OOXMLFastContextHandler::propagateCellProperties()
970 : {
971 : #ifdef DEBUG_CONTEXT_HANDLER
972 : debug_logger->element("contexthandler.propagateCellProperties");
973 : #endif
974 :
975 548 : mpParserState->setCellProperties(getPropertySet());
976 548 : }
977 :
978 94 : void OOXMLFastContextHandler::propagateRowProperties()
979 : {
980 : #ifdef DEBUG_CONTEXT_HANDLER
981 : debug_logger->element("contexthandler.propagateRowProperties");
982 : #endif
983 :
984 94 : mpParserState->setRowProperties(getPropertySet());
985 94 : }
986 :
987 110 : void OOXMLFastContextHandler::propagateTableProperties()
988 : {
989 110 : OOXMLPropertySet::Pointer_t pProps = getPropertySet();
990 : #ifdef DEBUG_CONTEXT_HANDLER
991 : debug_logger->startElement("contexthandler.propagateTableProperties");
992 : debug_logger->propertySet(getPropertySet(),
993 : IdToString::Pointer_t(new OOXMLIdToString()));
994 : debug_logger->endElement();
995 : #endif
996 :
997 110 : mpParserState->setTableProperties(pProps);
998 110 : }
999 :
1000 571 : void OOXMLFastContextHandler::sendCellProperties()
1001 : {
1002 : #ifdef DEBUG_CONTEXT_HANDLER
1003 : debug_logger->startElement("contexthandler.sendCellProperties");
1004 : #endif
1005 :
1006 571 : mpParserState->resolveCellProperties(*mpStream);
1007 :
1008 : #ifdef DEBUG_CONTEXT_HANDLER
1009 : debug_logger->endElement();
1010 : #endif
1011 571 : }
1012 :
1013 148 : void OOXMLFastContextHandler::sendRowProperties()
1014 : {
1015 : #ifdef DEBUG_CONTEXT_HANDLER
1016 : debug_logger->startElement("contexthandler.sendRowProperties");
1017 : #endif
1018 :
1019 148 : mpParserState->resolveRowProperties(*mpStream);
1020 :
1021 : #ifdef DEBUG_CONTEXT_HANDLER
1022 : debug_logger->endElement();
1023 : #endif
1024 148 : }
1025 :
1026 148 : void OOXMLFastContextHandler::sendTableProperties()
1027 : {
1028 : #ifdef DEBUG_CONTEXT_HANDLER
1029 : debug_logger->startElement("contexthandler.sendTableProperties");
1030 : #endif
1031 :
1032 148 : mpParserState->resolveTableProperties(*mpStream);
1033 :
1034 : #ifdef DEBUG_CONTEXT_HANDLER
1035 : debug_logger->endElement();
1036 : #endif
1037 148 : }
1038 :
1039 56 : void OOXMLFastContextHandler::clearTableProps()
1040 : {
1041 : #ifdef DEBUG_CONTEXT_HANDLER
1042 : debug_logger->element("contexthandler.clearTableProps");
1043 : #endif
1044 :
1045 : mpParserState->setTableProperties(OOXMLPropertySet::Pointer_t
1046 56 : (new OOXMLPropertySetImpl()));
1047 56 : }
1048 :
1049 54 : void OOXMLFastContextHandler::sendPropertiesWithId(const Id & rId)
1050 : {
1051 : #ifdef DEBUG_CONTEXT_HANDLER
1052 : debug_logger->startElement("contexthandler.sendPropertiesWithId");
1053 : debug_logger->attribute("id", fastTokenToId(rId));
1054 : #endif
1055 :
1056 54 : OOXMLValue::Pointer_t pValue(new OOXMLPropertySetValue(getPropertySet()));
1057 108 : OOXMLPropertySet::Pointer_t pPropertySet(new OOXMLPropertySetImpl());
1058 :
1059 : OOXMLProperty::Pointer_t pProp
1060 108 : (new OOXMLPropertyImpl(rId, pValue, OOXMLPropertyImpl::SPRM));
1061 :
1062 54 : pPropertySet->add(pProp);
1063 108 : mpStream->props(pPropertySet);
1064 :
1065 : #ifdef DEBUG_CONTEXT_HANDLER
1066 : debug_logger->propertySet(getPropertySet(),
1067 : IdToString::Pointer_t(new OOXMLIdToString()));
1068 : debug_logger->endElement();
1069 : #endif
1070 54 : }
1071 :
1072 816 : void OOXMLFastContextHandler::clearProps()
1073 : {
1074 : #ifdef DEBUG_CONTEXT_HANDLER
1075 : debug_logger->element("contexthandler.clearProps");
1076 : #endif
1077 :
1078 816 : setPropertySet(OOXMLPropertySet::Pointer_t(new OOXMLPropertySetImpl()));
1079 816 : }
1080 :
1081 0 : void OOXMLFastContextHandler::setDefaultBooleanValue()
1082 : {
1083 0 : }
1084 :
1085 0 : void OOXMLFastContextHandler::setDefaultIntegerValue()
1086 : {
1087 0 : }
1088 :
1089 0 : void OOXMLFastContextHandler::setDefaultHexValue()
1090 : {
1091 0 : }
1092 :
1093 0 : void OOXMLFastContextHandler::setDefaultStringValue()
1094 : {
1095 0 : }
1096 :
1097 828 : void OOXMLFastContextHandler::setDocument(OOXMLDocument * pDocument)
1098 : {
1099 828 : mpParserState->setDocument(pDocument);
1100 828 : }
1101 :
1102 330 : OOXMLDocument * OOXMLFastContextHandler::getDocument()
1103 : {
1104 330 : return mpParserState->getDocument();
1105 : }
1106 :
1107 832 : void OOXMLFastContextHandler::setForwardEvents(bool bForwardEvents)
1108 : {
1109 : #ifdef DEBUG_CONTEXT_HANDLER
1110 : debug_logger->startElement("contexthandler.setForwardEvents");
1111 :
1112 : if (bForwardEvents)
1113 : debug_logger->chars(std::string("true"));
1114 : else
1115 : debug_logger->chars(std::string("false"));
1116 :
1117 : debug_logger->endElement();
1118 : #endif
1119 :
1120 832 : mpParserState->setForwardEvents(bForwardEvents);
1121 832 : }
1122 :
1123 12017 : bool OOXMLFastContextHandler::isForwardEvents() const
1124 : {
1125 12017 : return mpParserState->isForwardEvents();
1126 : }
1127 :
1128 828 : void OOXMLFastContextHandler::setXNoteId(const sal_Int32 nId)
1129 : {
1130 828 : mpParserState->setXNoteId(nId);
1131 828 : }
1132 :
1133 0 : void OOXMLFastContextHandler::setXNoteId(OOXMLValue::Pointer_t pValue)
1134 : {
1135 0 : mpParserState->setXNoteId(sal_Int32(pValue->getInt()));
1136 0 : }
1137 :
1138 2 : sal_Int32 OOXMLFastContextHandler::getXNoteId() const
1139 : {
1140 2 : return mpParserState->getXNoteId();
1141 : }
1142 :
1143 0 : void OOXMLFastContextHandler::resolveFootnote
1144 : (const sal_Int32 nId)
1145 : {
1146 0 : mpParserState->getDocument()->resolveFootnote
1147 0 : (*mpStream, 0, nId);
1148 0 : }
1149 :
1150 0 : void OOXMLFastContextHandler::resolveEndnote(const sal_Int32 nId)
1151 : {
1152 0 : mpParserState->getDocument()->resolveEndnote
1153 0 : (*mpStream, 0, nId);
1154 0 : }
1155 :
1156 2 : void OOXMLFastContextHandler::resolveComment(const sal_Int32 nId)
1157 : {
1158 2 : mpParserState->getDocument()->resolveComment(*mpStream, nId);
1159 2 : }
1160 :
1161 0 : void OOXMLFastContextHandler::resolvePicture(const OUString & rId)
1162 : {
1163 0 : mpParserState->getDocument()->resolvePicture(*mpStream, rId);
1164 0 : }
1165 :
1166 38 : void OOXMLFastContextHandler::resolveHeader
1167 : (const sal_Int32 type, const OUString & rId)
1168 : {
1169 38 : mpParserState->getDocument()->resolveHeader(*mpStream, type, rId);
1170 38 : }
1171 :
1172 41 : void OOXMLFastContextHandler::resolveFooter
1173 : (const sal_Int32 type, const OUString & rId)
1174 : {
1175 41 : mpParserState->getDocument()->resolveFooter(*mpStream, type, rId);
1176 41 : }
1177 :
1178 : // Add the data pointed to by the reference as another property.
1179 5 : void OOXMLFastContextHandler::resolveData(const OUString & rId)
1180 : {
1181 5 : OOXMLDocument * objDocument = getDocument();
1182 : SAL_WARN_IF(!objDocument, "writerfilter", "no document to resolveData");
1183 5 : if (!objDocument)
1184 5 : return;
1185 :
1186 : uno::Reference<io::XInputStream> xInputStream
1187 5 : (objDocument->getInputStreamForId(rId));
1188 :
1189 10 : OOXMLValue::Pointer_t aValue(new OOXMLInputStreamValue(xInputStream));
1190 :
1191 10 : newProperty(NS_ooxml::LN_inputstream, aValue);
1192 : }
1193 :
1194 2 : OUString OOXMLFastContextHandler::getTargetForId
1195 : (const OUString & rId)
1196 : {
1197 2 : return mpParserState->getDocument()->getTargetForId(rId);
1198 : }
1199 :
1200 0 : void OOXMLFastContextHandler::resolvePropertySetAttrs()
1201 : {
1202 0 : }
1203 :
1204 21608 : void OOXMLFastContextHandler::sendPropertyToParent()
1205 : {
1206 : #ifdef DEBUG_CONTEXT_HANDLER
1207 : debug_logger->element("sendPropertyToParent");
1208 : #endif
1209 :
1210 21608 : if (mpParent != NULL)
1211 : {
1212 21608 : OOXMLPropertySet::Pointer_t pProps(mpParent->getPropertySet());
1213 :
1214 21608 : if (pProps.get() != NULL)
1215 : {
1216 : OOXMLProperty::Pointer_t
1217 21608 : pProp(new OOXMLPropertyImpl(mId, getValue(),
1218 21608 : OOXMLPropertyImpl::SPRM));
1219 21608 : pProps->add(pProp);
1220 21608 : }
1221 : }
1222 21608 : }
1223 :
1224 31617 : void OOXMLFastContextHandler::sendPropertiesToParent()
1225 : {
1226 : #ifdef DEBUG_CONTEXT_HANDLER
1227 : debug_logger->startElement("contexthandler.sendPropertiesToParent");
1228 : #endif
1229 31617 : if (mpParent != NULL)
1230 : {
1231 31617 : OOXMLPropertySet::Pointer_t pParentProps(mpParent->getPropertySet());
1232 :
1233 31617 : if (pParentProps.get() != NULL)
1234 : {
1235 29040 : OOXMLPropertySet::Pointer_t pProps(getPropertySet());
1236 :
1237 29040 : if (pProps.get() != NULL)
1238 : {
1239 : OOXMLValue::Pointer_t pValue
1240 29040 : (new OOXMLPropertySetValue(getPropertySet()));
1241 :
1242 : OOXMLProperty::Pointer_t pProp
1243 58080 : (new OOXMLPropertyImpl(getId(), pValue, OOXMLPropertyImpl::SPRM));
1244 :
1245 :
1246 58080 : pParentProps->add(pProp);
1247 :
1248 29040 : }
1249 31617 : }
1250 : }
1251 : #ifdef DEBUG_CONTEXT_HANDLER
1252 : debug_logger->endElement();
1253 : #endif
1254 31617 : }
1255 :
1256 : uno::Reference< uno::XComponentContext >
1257 70 : OOXMLFastContextHandler::getComponentContext()
1258 : {
1259 70 : return m_xContext;
1260 : }
1261 :
1262 : /*
1263 : class OOXMLFastContextHandlerStream
1264 : */
1265 :
1266 3260 : OOXMLFastContextHandlerStream::OOXMLFastContextHandlerStream
1267 : (OOXMLFastContextHandler * pContext)
1268 : : OOXMLFastContextHandler(pContext),
1269 3260 : mpPropertySetAttrs(new OOXMLPropertySetImpl())
1270 : {
1271 3260 : }
1272 :
1273 6520 : OOXMLFastContextHandlerStream::~OOXMLFastContextHandlerStream()
1274 : {
1275 6520 : }
1276 :
1277 2782 : void OOXMLFastContextHandlerStream::newProperty(const Id & rId,
1278 : OOXMLValue::Pointer_t pVal)
1279 : {
1280 2782 : if (rId != 0x0)
1281 : {
1282 : OOXMLPropertyImpl::Pointer_t pProperty
1283 224 : (new OOXMLPropertyImpl(rId, pVal, OOXMLPropertyImpl::ATTRIBUTE));
1284 :
1285 224 : mpPropertySetAttrs->add(pProperty);
1286 : }
1287 2782 : }
1288 :
1289 1 : void OOXMLFastContextHandlerStream::sendProperty(Id nId)
1290 : {
1291 : #ifdef DEBUG_CONTEXT_HANDLER
1292 : debug_logger->startElement("contexthandler.sendProperty");
1293 : debug_logger->attribute("id", (*QNameToString::Instance())(nId));
1294 : debug_logger->chars(xmlify(getPropertySetAttrs()->toString()));
1295 : debug_logger->endElement();
1296 : #endif
1297 :
1298 1 : OOXMLPropertySetEntryToString aHandler(nId);
1299 1 : getPropertySetAttrs()->resolve(aHandler);
1300 1 : const OUString & sText = aHandler.getString();
1301 : mpStream->utext(reinterpret_cast < const sal_uInt8 * >
1302 1 : (sText.getStr()),
1303 2 : sText.getLength());
1304 1 : }
1305 :
1306 : OOXMLPropertySet::Pointer_t
1307 104 : OOXMLFastContextHandlerStream::getPropertySetAttrs() const
1308 : {
1309 104 : return mpPropertySetAttrs;
1310 : }
1311 :
1312 0 : void OOXMLFastContextHandlerStream::resolvePropertySetAttrs()
1313 : {
1314 : #ifdef DEBUG_CONTEXT_HANDLER
1315 : debug_logger->startElement("contexthandler.resolvePropertySetAttrs");
1316 : debug_logger->chars(mpPropertySetAttrs->toString());
1317 : debug_logger->endElement();
1318 : #endif
1319 0 : mpStream->props(mpPropertySetAttrs);
1320 0 : }
1321 :
1322 5 : OOXMLPropertySet::Pointer_t OOXMLFastContextHandlerStream::getPropertySet()
1323 : const
1324 : {
1325 5 : return getPropertySetAttrs();
1326 : }
1327 :
1328 2 : void OOXMLFastContextHandlerStream::handleHyperlink()
1329 : {
1330 2 : OOXMLHyperlinkHandler aHyperlinkHandler(this);
1331 2 : getPropertySetAttrs()->resolve(aHyperlinkHandler);
1332 2 : }
1333 :
1334 : /*
1335 : class OOXMLFastContextHandlerProperties
1336 : */
1337 34466 : OOXMLFastContextHandlerProperties::OOXMLFastContextHandlerProperties
1338 : (OOXMLFastContextHandler * pContext)
1339 0 : : OOXMLFastContextHandler(pContext), mpPropertySet(new OOXMLPropertySetImpl()),
1340 34466 : mbResolve(false)
1341 : {
1342 34466 : if (pContext->getResource() == STREAM)
1343 2849 : mbResolve = true;
1344 34466 : }
1345 :
1346 68603 : OOXMLFastContextHandlerProperties::~OOXMLFastContextHandlerProperties()
1347 : {
1348 68603 : }
1349 :
1350 34209 : void OOXMLFastContextHandlerProperties::lcl_endFastElement
1351 : (Token_t Element)
1352 : throw (uno::RuntimeException, xml::sax::SAXException)
1353 : {
1354 34209 : endAction(Element);
1355 :
1356 34209 : if (mbResolve)
1357 : {
1358 2592 : if (isForwardEvents())
1359 : {
1360 2592 : mpStream->props(mpPropertySet);
1361 : }
1362 : }
1363 : else
1364 : {
1365 31617 : sendPropertiesToParent();
1366 : }
1367 34209 : }
1368 :
1369 2577 : OOXMLValue::Pointer_t OOXMLFastContextHandlerProperties::getValue() const
1370 : {
1371 2577 : return OOXMLValue::Pointer_t(new OOXMLPropertySetValue(mpPropertySet));
1372 : }
1373 :
1374 : #if OSL_DEBUG_LEVEL > 1
1375 : void OOXMLFastContextHandlerProperties::dumpXml( const TagLogger::Pointer_t pLogger) const
1376 : {
1377 : pLogger->startElement("context");
1378 :
1379 : static char sBuffer[128];
1380 : snprintf(sBuffer, sizeof(sBuffer), "%p", this);
1381 :
1382 : pLogger->attribute("parent", std::string(sBuffer));
1383 : pLogger->attribute("type", getType());
1384 : pLogger->attribute("resource", resourceToString(getResource()));
1385 : pLogger->attribute("token", fastTokenToId(getToken()));
1386 : pLogger->attribute("id", (*QNameToString::Instance())(getId()));
1387 :
1388 : OOXMLValue::Pointer_t pVal(getValue());
1389 :
1390 : if (pVal.get() != NULL)
1391 : pLogger->attribute("value", pVal->toString());
1392 : else
1393 : pLogger->attribute("value", std::string("(null)"));
1394 :
1395 : pLogger->attribute("resolve", mbResolve ? "resolve" : "noResolve");
1396 :
1397 : pLogger->propertySet(getPropertySet(),
1398 : IdToString::Pointer_t(new OOXMLIdToString()));
1399 :
1400 : mpParserState->dumpXml( pLogger );
1401 :
1402 : pLogger->endElement();
1403 : }
1404 : #endif
1405 :
1406 45237 : void OOXMLFastContextHandlerProperties::newProperty
1407 : (const Id & rId, OOXMLValue::Pointer_t pVal)
1408 : {
1409 45237 : if (rId != 0x0)
1410 : {
1411 : OOXMLPropertyImpl::Pointer_t pProperty
1412 45036 : (new OOXMLPropertyImpl(rId, pVal, OOXMLPropertyImpl::ATTRIBUTE));
1413 :
1414 45036 : mpPropertySet->add(pProperty);
1415 : }
1416 45237 : }
1417 :
1418 0 : void OOXMLFastContextHandlerProperties::handleXNotes()
1419 : {
1420 0 : switch (mnToken)
1421 : {
1422 : case NS_wordprocessingml|OOXML_footnoteReference:
1423 : {
1424 0 : OOXMLFootnoteHandler aFootnoteHandler(this);
1425 0 : mpPropertySet->resolve(aFootnoteHandler);
1426 : }
1427 0 : break;
1428 : case NS_wordprocessingml|OOXML_endnoteReference:
1429 : {
1430 0 : OOXMLEndnoteHandler aEndnoteHandler(this);
1431 0 : mpPropertySet->resolve(aEndnoteHandler);
1432 : }
1433 0 : break;
1434 : default:
1435 0 : break;
1436 : }
1437 0 : }
1438 :
1439 79 : void OOXMLFastContextHandlerProperties::handleHdrFtr()
1440 : {
1441 79 : switch (mnToken)
1442 : {
1443 : case NS_wordprocessingml|OOXML_footerReference:
1444 : {
1445 41 : OOXMLFooterHandler aFooterHandler(this);
1446 41 : mpPropertySet->resolve(aFooterHandler);
1447 : }
1448 41 : break;
1449 : case NS_wordprocessingml|OOXML_headerReference:
1450 : {
1451 38 : OOXMLHeaderHandler aHeaderHandler(this);
1452 38 : mpPropertySet->resolve(aHeaderHandler);
1453 : }
1454 38 : break;
1455 : default:
1456 0 : break;
1457 : }
1458 79 : }
1459 :
1460 2 : void OOXMLFastContextHandlerProperties::handleComment()
1461 : {
1462 : #ifdef DEBUG_ELEMENT
1463 : debug_logger->element("handleComment");
1464 : #endif
1465 :
1466 2 : OOXMLCommentHandler aCommentHandler(this);
1467 2 : getPropertySet()->resolve(aCommentHandler);
1468 2 : }
1469 :
1470 16 : void OOXMLFastContextHandlerProperties::handlePicture()
1471 : {
1472 : #ifdef DEBUG_ELEMENT
1473 : debug_logger->element("handlePicture");
1474 : #endif
1475 :
1476 16 : OOXMLPictureHandler aPictureHandler(this);
1477 16 : getPropertySet()->resolve(aPictureHandler);
1478 16 : }
1479 :
1480 16 : void OOXMLFastContextHandlerProperties::handleBreak()
1481 : {
1482 : #ifdef DEBUG_ELEMENT
1483 : debug_logger->element("handleBreak");
1484 : #endif
1485 :
1486 16 : OOXMLBreakHandler aBreakHandler(*mpStream);
1487 16 : getPropertySet()->resolve(aBreakHandler);
1488 16 : }
1489 :
1490 5 : void OOXMLFastContextHandlerProperties::handleOLE()
1491 : {
1492 : #ifdef DEBUG_ELEMENT
1493 : debug_logger->element("handleOLE");
1494 : #endif
1495 :
1496 5 : OOXMLOLEHandler aOLEHandler(this);
1497 5 : getPropertySet()->resolve(aOLEHandler);
1498 5 : }
1499 :
1500 0 : void OOXMLFastContextHandlerProperties::handleFontRel()
1501 : {
1502 0 : OOXMLEmbeddedFontHandler handler(this);
1503 0 : getPropertySet()->resolve(handler);
1504 0 : }
1505 :
1506 0 : void OOXMLFastContextHandlerProperties::setParent
1507 : (OOXMLFastContextHandler * pParent)
1508 : {
1509 : #ifdef DEBUG_ELEMENT
1510 : debug_logger->startElement("setParent");
1511 : debug_logger->chars(std::string("OOXMLFastContextHandlerProperties"));
1512 : debug_logger->endElement();
1513 : #endif
1514 :
1515 0 : OOXMLFastContextHandler::setParent(pParent);
1516 :
1517 0 : if (mpParent->getResource() == STREAM)
1518 0 : mbResolve = true;
1519 0 : }
1520 :
1521 811 : void OOXMLFastContextHandlerProperties::setPropertySet
1522 : (OOXMLPropertySet::Pointer_t pPropertySet)
1523 : {
1524 811 : if (pPropertySet.get() != NULL)
1525 811 : mpPropertySet = pPropertySet;
1526 811 : }
1527 :
1528 : OOXMLPropertySet::Pointer_t
1529 109671 : OOXMLFastContextHandlerProperties::getPropertySet() const
1530 : {
1531 109671 : return mpPropertySet;
1532 : }
1533 :
1534 : /*
1535 : * class OOXMLFasContextHandlerPropertyTable
1536 : */
1537 :
1538 169 : OOXMLFastContextHandlerPropertyTable::OOXMLFastContextHandlerPropertyTable
1539 : (OOXMLFastContextHandler * pContext)
1540 169 : : OOXMLFastContextHandlerProperties(pContext)
1541 : {
1542 169 : }
1543 :
1544 338 : OOXMLFastContextHandlerPropertyTable::~OOXMLFastContextHandlerPropertyTable()
1545 : {
1546 338 : }
1547 :
1548 169 : void OOXMLFastContextHandlerPropertyTable::lcl_endFastElement
1549 : (Token_t Element)
1550 : throw (uno::RuntimeException, xml::sax::SAXException)
1551 : {
1552 169 : OOXMLPropertySet::Pointer_t pPropSet(mpPropertySet->clone());
1553 : OOXMLTableImpl::ValuePointer_t pTmpVal
1554 338 : (new OOXMLPropertySetValue(pPropSet));
1555 :
1556 169 : mTable.add(pTmpVal);
1557 :
1558 338 : writerfilter::Reference<Table>::Pointer_t pTable(mTable.clone());
1559 :
1560 : #ifdef DEBUG_PROPERTIES
1561 : debug_logger->startElement("table");
1562 : debug_logger->attribute("id", (*QNameToString::Instance())(mId));
1563 : debug_logger->endElement();
1564 : #endif
1565 :
1566 169 : mpStream->table(mId, pTable);
1567 :
1568 338 : endAction(Element);
1569 169 : }
1570 :
1571 : /*
1572 : class OOXMLFastContextHandlerValue
1573 : */
1574 :
1575 21608 : OOXMLFastContextHandlerValue::OOXMLFastContextHandlerValue
1576 : (OOXMLFastContextHandler * pContext)
1577 21608 : : OOXMLFastContextHandler(pContext)
1578 : {
1579 21608 : }
1580 :
1581 43216 : OOXMLFastContextHandlerValue::~OOXMLFastContextHandlerValue()
1582 : {
1583 43216 : }
1584 :
1585 21498 : void OOXMLFastContextHandlerValue::setValue(OOXMLValue::Pointer_t pValue)
1586 : {
1587 : #ifdef DEBUG_CONTEXT_HANDLER
1588 : debug_logger->startElement("contexthandler.setValue");
1589 : debug_logger->attribute("value", pValue->toString());
1590 : #endif
1591 :
1592 21498 : mpValue = pValue;
1593 :
1594 : #ifdef DEBUG_CONTEXT_HANDLER
1595 : debug_logger->endElement();
1596 : #endif
1597 21498 : }
1598 :
1599 21608 : OOXMLValue::Pointer_t OOXMLFastContextHandlerValue::getValue() const
1600 : {
1601 21608 : return mpValue;
1602 : }
1603 :
1604 21608 : void OOXMLFastContextHandlerValue::lcl_endFastElement
1605 : (Token_t Element)
1606 : throw (uno::RuntimeException, xml::sax::SAXException)
1607 : {
1608 21608 : sendPropertyToParent();
1609 :
1610 21608 : endAction(Element);
1611 21608 : }
1612 :
1613 3706 : void OOXMLFastContextHandlerValue::setDefaultBooleanValue()
1614 : {
1615 : #ifdef DEBUG_ELEMENT
1616 : debug_logger->element("setDefaultBooleanValue");
1617 : #endif
1618 :
1619 3706 : if (mpValue.get() == NULL)
1620 : {
1621 : // Value should not always be 'true'
1622 : //OOXMLValue::Pointer_t pValue(new OOXMLBooleanValue(true));
1623 3082 : bool bSet = true;
1624 :
1625 : // Paragraph properties are not always 'true' by default
1626 : // For example - RTL layout of paragraph is by default 'false' (look in this link for 'sprmPFBiDi')
1627 : // http://msdn.microsoft.com/en-us/library/dd923496%28v=office.12%29.aspx
1628 3082 : if (getId() == NS_sprm::LN_PFBiDi)
1629 : {
1630 1 : bSet = false;
1631 : }
1632 :
1633 3082 : OOXMLValue::Pointer_t pValue(new OOXMLBooleanValue(bSet));
1634 3082 : setValue(pValue);
1635 : }
1636 3706 : }
1637 :
1638 4389 : void OOXMLFastContextHandlerValue::setDefaultIntegerValue()
1639 : {
1640 : #ifdef DEBUG_ELEMENT
1641 : debug_logger->element("setDefaultIntegerValue");
1642 : #endif
1643 :
1644 4389 : if (mpValue.get() == NULL)
1645 : {
1646 0 : OOXMLValue::Pointer_t pValue(new OOXMLIntegerValue(0));
1647 0 : setValue(pValue);
1648 : }
1649 4389 : }
1650 :
1651 4914 : void OOXMLFastContextHandlerValue::setDefaultHexValue()
1652 : {
1653 : #ifdef DEBUG_ELEMENT
1654 : debug_logger->element("setDefaultHexValue");
1655 : #endif
1656 :
1657 4914 : if (mpValue.get() == NULL)
1658 : {
1659 0 : OOXMLValue::Pointer_t pValue(new OOXMLHexValue(0));
1660 0 : setValue(pValue);
1661 : }
1662 4914 : }
1663 :
1664 4866 : void OOXMLFastContextHandlerValue::setDefaultStringValue()
1665 : {
1666 : #ifdef DEBUG_ELEMENT
1667 : debug_logger->element("setDefaultStringValue");
1668 : #endif
1669 :
1670 4866 : if (mpValue.get() == NULL)
1671 : {
1672 0 : OOXMLValue::Pointer_t pValue(new OOXMLStringValue(OUString()));
1673 0 : setValue(pValue);
1674 : }
1675 4866 : }
1676 : /*
1677 : class OOXMLFastContextHandlerTable
1678 : */
1679 :
1680 415 : OOXMLFastContextHandlerTable::OOXMLFastContextHandlerTable
1681 : (OOXMLFastContextHandler * pContext)
1682 415 : : OOXMLFastContextHandler(pContext)
1683 : {
1684 415 : }
1685 :
1686 830 : OOXMLFastContextHandlerTable::~OOXMLFastContextHandlerTable()
1687 : {
1688 830 : }
1689 :
1690 : uno::Reference< xml::sax::XFastContextHandler > SAL_CALL
1691 2855 : OOXMLFastContextHandlerTable::createFastChildContext
1692 : (Token_t Element,
1693 : const uno::Reference< xml::sax::XFastAttributeList > & Attribs)
1694 : throw (uno::RuntimeException, xml::sax::SAXException)
1695 : {
1696 2855 : addCurrentChild();
1697 :
1698 : mCurrentChild.set
1699 2855 : (OOXMLFastContextHandler::createFastChildContext(Element, Attribs));
1700 :
1701 2855 : return mCurrentChild;
1702 : }
1703 :
1704 415 : void OOXMLFastContextHandlerTable::lcl_endFastElement
1705 : (Token_t /*Element*/)
1706 : throw (uno::RuntimeException, xml::sax::SAXException)
1707 : {
1708 415 : addCurrentChild();
1709 :
1710 415 : writerfilter::Reference<Table>::Pointer_t pTable(mTable.clone());
1711 415 : if (isForwardEvents() && mId != 0x0)
1712 : {
1713 : #ifdef DEBUG_PROPERTIES
1714 : debug_logger->startElement("table");
1715 : string str = (*QNameToString::Instance())(mId);
1716 : debug_logger->attribute("id", str);
1717 : debug_logger->endElement();
1718 : #endif
1719 :
1720 415 : mpStream->table(mId, pTable);
1721 415 : }
1722 415 : }
1723 :
1724 3270 : void OOXMLFastContextHandlerTable::addCurrentChild()
1725 : {
1726 3270 : OOXMLFastContextHandler * pHandler = mCurrentChild.getPointer();
1727 3270 : if ( pHandler != NULL)
1728 : {
1729 2577 : OOXMLValue::Pointer_t pValue(pHandler->getValue());
1730 :
1731 2577 : if (pValue.get() != NULL)
1732 : {
1733 2577 : OOXMLTableImpl::ValuePointer_t pTmpVal(pValue->clone());
1734 2577 : mTable.add(pTmpVal);
1735 2577 : }
1736 : }
1737 3270 : }
1738 :
1739 0 : void OOXMLFastContextHandlerTable::newPropertySet
1740 : (OOXMLPropertySet::Pointer_t /*pPropertySet*/)
1741 : {
1742 :
1743 0 : }
1744 :
1745 : /*
1746 : class OOXMLFastContextHandlerXNote
1747 : */
1748 :
1749 2 : OOXMLFastContextHandlerXNote::OOXMLFastContextHandlerXNote
1750 : (OOXMLFastContextHandler * pContext)
1751 2 : : OOXMLFastContextHandlerProperties(pContext), mbForwardEventsSaved(false)
1752 : {
1753 2 : }
1754 :
1755 4 : OOXMLFastContextHandlerXNote::~OOXMLFastContextHandlerXNote()
1756 : {
1757 4 : }
1758 :
1759 2 : void OOXMLFastContextHandlerXNote::lcl_startFastElement
1760 : (Token_t Element,
1761 : const uno::Reference< xml::sax::XFastAttributeList > & /*Attribs*/)
1762 : throw (uno::RuntimeException, xml::sax::SAXException)
1763 : {
1764 2 : mbForwardEventsSaved = isForwardEvents();
1765 :
1766 2 : if (mnMyXNoteId == getXNoteId())
1767 2 : setForwardEvents(true);
1768 : else
1769 0 : setForwardEvents(false);
1770 :
1771 2 : startAction(Element);
1772 2 : }
1773 :
1774 2 : void OOXMLFastContextHandlerXNote::lcl_endFastElement
1775 : (Token_t Element)
1776 : throw (uno::RuntimeException, xml::sax::SAXException)
1777 : {
1778 2 : endAction(Element);
1779 :
1780 2 : OOXMLFastContextHandlerProperties::lcl_endFastElement(Element);
1781 :
1782 2 : setForwardEvents(mbForwardEventsSaved);
1783 2 : }
1784 :
1785 2 : void OOXMLFastContextHandlerXNote::checkId(OOXMLValue::Pointer_t pValue)
1786 : {
1787 : #ifdef DEBUG_ELEMENT
1788 : debug_logger->startElement("checkId");
1789 : debug_logger->attribute("myId", sal_Int32(pValue->getInt()));
1790 : debug_logger->attribute("id", getXNoteId());
1791 : debug_logger->endElement();
1792 : #endif
1793 :
1794 2 : mnMyXNoteId = sal_Int32(pValue->getInt());
1795 2 : }
1796 :
1797 : /*
1798 : class OOXMLFastContextHandlerTextTableCell
1799 : */
1800 :
1801 571 : OOXMLFastContextHandlerTextTableCell::OOXMLFastContextHandlerTextTableCell
1802 : (OOXMLFastContextHandler * pContext)
1803 571 : : OOXMLFastContextHandler(pContext)
1804 : {
1805 571 : }
1806 :
1807 1142 : OOXMLFastContextHandlerTextTableCell::~OOXMLFastContextHandlerTextTableCell()
1808 : {
1809 1142 : }
1810 :
1811 571 : void OOXMLFastContextHandlerTextTableCell::startCell()
1812 : {
1813 571 : }
1814 :
1815 571 : void OOXMLFastContextHandlerTextTableCell::endCell()
1816 : {
1817 571 : if (isForwardEvents())
1818 : {
1819 571 : OOXMLPropertySet * pProps = new OOXMLPropertySetImpl();
1820 : {
1821 : OOXMLValue::Pointer_t pVal
1822 571 : (new OOXMLIntegerValue(mnTableDepth));
1823 : OOXMLProperty::Pointer_t pProp
1824 1142 : (new OOXMLPropertyImpl(NS_sprm::LN_PTableDepth, pVal, OOXMLPropertyImpl::SPRM));
1825 1142 : pProps->add(pProp);
1826 : }
1827 : {
1828 : OOXMLValue::Pointer_t pVal
1829 571 : (new OOXMLIntegerValue(1));
1830 : OOXMLProperty::Pointer_t pProp
1831 1142 : (new OOXMLPropertyImpl(NS_sprm::LN_PFInTable, pVal, OOXMLPropertyImpl::SPRM));
1832 1142 : pProps->add(pProp);
1833 : }
1834 : {
1835 : OOXMLValue::Pointer_t pVal
1836 571 : (new OOXMLBooleanValue(mnTableDepth > 0));
1837 : OOXMLProperty::Pointer_t pProp
1838 1142 : (new OOXMLPropertyImpl(NS_sprm::LN_PCell, pVal, OOXMLPropertyImpl::SPRM));
1839 1142 : pProps->add(pProp);
1840 : }
1841 :
1842 : #ifdef DEBUG_PROPERTIES
1843 : debug_logger->startElement("endcell");
1844 : debug_logger->propertySet(OOXMLPropertySet::Pointer_t(pProps->clone()),
1845 : IdToString::Pointer_t(new OOXMLIdToString()));
1846 : debug_logger->endElement();
1847 : #endif
1848 571 : mpStream->props(writerfilter::Reference<Properties>::Pointer_t(pProps));
1849 : }
1850 571 : }
1851 :
1852 : /*
1853 : class OOXMLFastContextHandlerTextTableRow
1854 : */
1855 :
1856 148 : OOXMLFastContextHandlerTextTableRow::OOXMLFastContextHandlerTextTableRow
1857 : (OOXMLFastContextHandler * pContext)
1858 148 : : OOXMLFastContextHandler(pContext)
1859 : {
1860 148 : }
1861 :
1862 296 : OOXMLFastContextHandlerTextTableRow::~OOXMLFastContextHandlerTextTableRow()
1863 : {
1864 296 : }
1865 :
1866 148 : void OOXMLFastContextHandlerTextTableRow::startRow()
1867 : {
1868 148 : }
1869 :
1870 148 : void OOXMLFastContextHandlerTextTableRow::endRow()
1871 : {
1872 148 : startParagraphGroup();
1873 :
1874 148 : if (isForwardEvents())
1875 : {
1876 148 : OOXMLPropertySet * pProps = new OOXMLPropertySetImpl();
1877 : {
1878 : OOXMLValue::Pointer_t pVal
1879 148 : (new OOXMLIntegerValue(mnTableDepth));
1880 : OOXMLProperty::Pointer_t pProp
1881 296 : (new OOXMLPropertyImpl(NS_sprm::LN_PTableDepth, pVal, OOXMLPropertyImpl::SPRM));
1882 296 : pProps->add(pProp);
1883 : }
1884 : {
1885 : OOXMLValue::Pointer_t pVal
1886 148 : (new OOXMLIntegerValue(1));
1887 : OOXMLProperty::Pointer_t pProp
1888 296 : (new OOXMLPropertyImpl(NS_sprm::LN_PFInTable, pVal, OOXMLPropertyImpl::SPRM));
1889 296 : pProps->add(pProp);
1890 : }
1891 : {
1892 : OOXMLValue::Pointer_t pVal
1893 148 : (new OOXMLIntegerValue(1));
1894 : OOXMLProperty::Pointer_t pProp
1895 296 : (new OOXMLPropertyImpl(NS_sprm::LN_PRow, pVal, OOXMLPropertyImpl::SPRM));
1896 296 : pProps->add(pProp);
1897 : }
1898 :
1899 : #ifdef DEBUG_PROPERTIES
1900 : debug_logger->startElement("endrow");
1901 : debug_logger->propertySet(OOXMLPropertySet::Pointer_t(pProps->clone()),
1902 : IdToString::Pointer_t(new OOXMLIdToString()));
1903 : debug_logger->endElement();
1904 : #endif
1905 :
1906 148 : mpStream->props(writerfilter::Reference<Properties>::Pointer_t(pProps));
1907 : }
1908 :
1909 148 : startCharacterGroup();
1910 :
1911 148 : if (isForwardEvents())
1912 148 : mpStream->utext((const sal_uInt8*)&uCR, 1);
1913 :
1914 148 : endCharacterGroup();
1915 148 : endParagraphGroup();
1916 148 : }
1917 :
1918 : /*
1919 : class OOXMLFastContextHandlerTextTable
1920 : */
1921 :
1922 56 : OOXMLFastContextHandlerTextTable::OOXMLFastContextHandlerTextTable
1923 : (OOXMLFastContextHandler * pContext)
1924 56 : : OOXMLFastContextHandler(pContext)
1925 : {
1926 56 : }
1927 :
1928 168 : OOXMLFastContextHandlerTextTable::~OOXMLFastContextHandlerTextTable()
1929 : {
1930 56 : clearTableProps();
1931 112 : }
1932 :
1933 56 : void OOXMLFastContextHandlerTextTable::lcl_startFastElement
1934 : (Token_t Element,
1935 : const uno::Reference< xml::sax::XFastAttributeList > & /*Attribs*/)
1936 : throw (uno::RuntimeException, xml::sax::SAXException)
1937 : {
1938 56 : mpParserState->startTable();
1939 56 : mnTableDepth++;
1940 :
1941 56 : boost::shared_ptr<OOXMLPropertySet> pProps( new OOXMLPropertySetImpl );
1942 : {
1943 : OOXMLValue::Pointer_t pVal
1944 56 : (new OOXMLIntegerValue(mnTableDepth));
1945 : OOXMLProperty::Pointer_t pProp
1946 112 : (new OOXMLPropertyImpl(NS_ooxml::LN_tblStart, pVal, OOXMLPropertyImpl::SPRM));
1947 112 : pProps->add(pProp);
1948 : }
1949 56 : mpParserState->setCharacterProperties(pProps);
1950 :
1951 56 : startAction(Element);
1952 56 : }
1953 :
1954 56 : void OOXMLFastContextHandlerTextTable::lcl_endFastElement
1955 : (Token_t Element)
1956 : throw (uno::RuntimeException, xml::sax::SAXException)
1957 : {
1958 56 : endAction(Element);
1959 :
1960 56 : mnTableDepth--;
1961 56 : mpParserState->endTable();
1962 56 : }
1963 :
1964 : /*
1965 : class OOXMLFastContextHandlerShape
1966 : */
1967 :
1968 70 : OOXMLFastContextHandlerShape::OOXMLFastContextHandlerShape
1969 : (OOXMLFastContextHandler * pContext)
1970 : : OOXMLFastContextHandlerProperties(pContext), m_bShapeSent( false ),
1971 70 : m_bShapeStarted(false)
1972 : {
1973 70 : uno::Reference<uno::XComponentContext> xContext(getComponentContext());
1974 70 : if (xContext.is())
1975 : {
1976 : uno::Reference<XMultiComponentFactory> rServiceManager
1977 70 : (xContext->getServiceManager());
1978 :
1979 70 : mrShapeContext.set( getDocument( )->getShapeContext( ) );
1980 70 : if ( !mrShapeContext.is( ) )
1981 : {
1982 : // Define the shape context for the whole document
1983 : mrShapeContext.set
1984 45 : (rServiceManager->
1985 : createInstanceWithContext
1986 45 : ("com.sun.star.xml.sax.FastShapeContextHandler", xContext),
1987 45 : uno::UNO_QUERY);
1988 45 : getDocument()->setShapeContext( mrShapeContext );
1989 : }
1990 :
1991 70 : if (mrShapeContext.is())
1992 : {
1993 70 : mrShapeContext->setModel(getDocument()->getModel());
1994 70 : mrShapeContext->setDrawPage(getDocument()->getDrawPage());
1995 70 : mrShapeContext->setInputStream(getDocument()->getStorageStream());
1996 :
1997 : #ifdef DEBUG_ELEMENT
1998 : debug_logger->startElement("setRelationFragmentPath");
1999 : debug_logger->attribute("path", mpParserState->getTarget());
2000 : debug_logger->endElement();
2001 : #endif
2002 70 : mrShapeContext->setRelationFragmentPath
2003 70 : (mpParserState->getTarget());
2004 70 : }
2005 : #ifdef DEBUG_CONTEXT_STACK
2006 : else
2007 : {
2008 : debug_logger->startElement("error");
2009 : debug_logger->chars(std::string("failed to get shape handler"));
2010 : debug_logger->endElement();
2011 : }
2012 : #endif
2013 70 : }
2014 70 : }
2015 :
2016 140 : OOXMLFastContextHandlerShape::~OOXMLFastContextHandlerShape()
2017 : {
2018 140 : }
2019 :
2020 70 : void OOXMLFastContextHandlerShape::lcl_startFastElement
2021 : (Token_t Element,
2022 : const uno::Reference< xml::sax::XFastAttributeList > & Attribs)
2023 : throw (uno::RuntimeException, xml::sax::SAXException)
2024 : {
2025 70 : startAction(Element);
2026 :
2027 70 : if (mrShapeContext.is())
2028 : {
2029 70 : mrShapeContext->startFastElement(Element, Attribs);
2030 : }
2031 70 : }
2032 :
2033 0 : void SAL_CALL OOXMLFastContextHandlerShape::startUnknownElement
2034 : (const OUString & Namespace,
2035 : const OUString & Name,
2036 : const uno::Reference< xml::sax::XFastAttributeList > & Attribs)
2037 : throw (uno::RuntimeException, xml::sax::SAXException)
2038 : {
2039 0 : if (mrShapeContext.is())
2040 0 : mrShapeContext->startUnknownElement(Namespace, Name, Attribs);
2041 0 : }
2042 :
2043 70 : void OOXMLFastContextHandlerShape::setToken(Token_t nToken)
2044 : {
2045 70 : OOXMLFastContextHandler::setToken(nToken);
2046 :
2047 70 : if (mrShapeContext.is())
2048 70 : mrShapeContext->setStartToken(nToken);
2049 70 : }
2050 :
2051 91 : void OOXMLFastContextHandlerShape::sendShape( Token_t Element )
2052 : {
2053 91 : if ( mrShapeContext.is() && !m_bShapeSent )
2054 : {
2055 70 : uno::Reference<drawing::XShape> xShape(mrShapeContext->getShape());
2056 70 : if (xShape.is())
2057 : {
2058 : OOXMLValue::Pointer_t
2059 69 : pValue(new OOXMLShapeValue(xShape));
2060 69 : newProperty(NS_ooxml::LN_shape, pValue);
2061 69 : m_bShapeSent = true;
2062 :
2063 69 : bool bIsPicture = Element == ( NS_picture | OOXML_pic );
2064 :
2065 : // Notify the dmapper that the shape is ready to use
2066 69 : if ( !bIsPicture )
2067 : {
2068 55 : mpStream->startShape( xShape );
2069 55 : m_bShapeStarted = true;
2070 69 : }
2071 70 : }
2072 : }
2073 91 : }
2074 :
2075 70 : void OOXMLFastContextHandlerShape::lcl_endFastElement
2076 : (Token_t Element)
2077 : throw (uno::RuntimeException, xml::sax::SAXException)
2078 : {
2079 70 : if (mrShapeContext.is())
2080 : {
2081 70 : mrShapeContext->endFastElement(Element);
2082 70 : sendShape( Element );
2083 : }
2084 :
2085 70 : OOXMLFastContextHandlerProperties::lcl_endFastElement(Element);
2086 :
2087 : // Ending the shape should be the last thing to do
2088 70 : bool bIsPicture = Element == ( NS_picture | OOXML_pic );
2089 70 : if ( !bIsPicture && m_bShapeStarted)
2090 55 : mpStream->endShape( );
2091 70 : }
2092 :
2093 0 : void SAL_CALL OOXMLFastContextHandlerShape::endUnknownElement
2094 : (const OUString & Namespace,
2095 : const OUString & Name)
2096 : throw (uno::RuntimeException, xml::sax::SAXException)
2097 : {
2098 0 : if (mrShapeContext.is())
2099 0 : mrShapeContext->endUnknownElement(Namespace, Name);
2100 0 : }
2101 :
2102 : uno::Reference< xml::sax::XFastContextHandler >
2103 120 : OOXMLFastContextHandlerShape::lcl_createFastChildContext
2104 : (Token_t Element,
2105 : const uno::Reference< xml::sax::XFastAttributeList > & Attribs)
2106 : throw (uno::RuntimeException, xml::sax::SAXException)
2107 : {
2108 120 : uno::Reference< xml::sax::XFastContextHandler > xContextHandler;
2109 :
2110 120 : bool bGroupShape = Element == Token_t(NS_vml | OOXML_group);
2111 120 : sal_uInt32 nNamespace = Element & 0xffff0000;
2112 :
2113 120 : switch (nNamespace)
2114 : {
2115 : case NS_wordprocessingml:
2116 : case NS_vml_wordprocessingDrawing:
2117 : case NS_office:
2118 5 : if (!bGroupShape)
2119 5 : xContextHandler.set(OOXMLFactory::getInstance()->createFastChildContextFromStart(this, Element));
2120 : // no break;
2121 : default:
2122 120 : if (!xContextHandler.is())
2123 : {
2124 115 : if (mrShapeContext.is())
2125 : {
2126 : uno::Reference<XFastContextHandler> pChildContext =
2127 115 : mrShapeContext->createFastChildContext(Element, Attribs);
2128 :
2129 : OOXMLFastContextHandlerWrapper * pWrapper =
2130 115 : new OOXMLFastContextHandlerWrapper(this, pChildContext);
2131 :
2132 115 : if (!bGroupShape)
2133 : {
2134 108 : pWrapper->addNamespace(NS_wordprocessingml);
2135 108 : pWrapper->addNamespace(NS_vml_wordprocessingDrawing);
2136 108 : pWrapper->addNamespace(NS_office);
2137 108 : pWrapper->addToken( NS_vml|OOXML_textbox );
2138 : }
2139 :
2140 115 : xContextHandler.set(pWrapper);
2141 : }
2142 : else
2143 0 : xContextHandler.set(this);
2144 : }
2145 120 : break;
2146 : }
2147 :
2148 :
2149 120 : return xContextHandler;
2150 : }
2151 :
2152 : uno::Reference< xml::sax::XFastContextHandler > SAL_CALL
2153 0 : OOXMLFastContextHandlerShape::createUnknownChildContext
2154 : (const OUString & Namespace,
2155 : const OUString & Name,
2156 : const uno::Reference< xml::sax::XFastAttributeList > & Attribs)
2157 : throw (uno::RuntimeException, xml::sax::SAXException)
2158 : {
2159 0 : uno::Reference< xml::sax::XFastContextHandler > xResult;
2160 :
2161 0 : if (mrShapeContext.is())
2162 0 : xResult.set(mrShapeContext->createUnknownChildContext
2163 0 : (Namespace, Name, Attribs));
2164 :
2165 0 : return xResult;
2166 : }
2167 :
2168 158 : void OOXMLFastContextHandlerShape::lcl_characters
2169 : (const OUString & aChars)
2170 : throw (uno::RuntimeException, xml::sax::SAXException)
2171 : {
2172 158 : if (mrShapeContext.is())
2173 158 : mrShapeContext->characters(aChars);
2174 158 : }
2175 :
2176 : /*
2177 : class OOXMLFastContextHandlerWrapper
2178 : */
2179 :
2180 937 : OOXMLFastContextHandlerWrapper::OOXMLFastContextHandlerWrapper
2181 : (OOXMLFastContextHandler * pParent,
2182 : uno::Reference<XFastContextHandler> xContext)
2183 937 : : OOXMLFastContextHandler(pParent), mxContext(xContext)
2184 : {
2185 937 : if (pParent != NULL)
2186 : {
2187 937 : setId(pParent->getId());
2188 937 : setToken(pParent->getToken());
2189 937 : setPropertySet(pParent->getPropertySet());
2190 : }
2191 937 : }
2192 :
2193 1874 : OOXMLFastContextHandlerWrapper::~OOXMLFastContextHandlerWrapper()
2194 : {
2195 1874 : }
2196 :
2197 2 : void SAL_CALL OOXMLFastContextHandlerWrapper::startUnknownElement
2198 : (const OUString & Namespace,
2199 : const OUString & Name,
2200 : const uno::Reference< xml::sax::XFastAttributeList > & Attribs)
2201 : throw (uno::RuntimeException, xml::sax::SAXException)
2202 : {
2203 2 : if (mxContext.is())
2204 0 : mxContext->startUnknownElement(Namespace, Name, Attribs);
2205 2 : }
2206 :
2207 2 : void SAL_CALL OOXMLFastContextHandlerWrapper::endUnknownElement
2208 : (const OUString & Namespace,
2209 : const OUString & Name)
2210 : throw (uno::RuntimeException, xml::sax::SAXException)
2211 : {
2212 2 : if (mxContext.is())
2213 0 : mxContext->endUnknownElement(Namespace, Name);
2214 2 : }
2215 :
2216 : uno::Reference< xml::sax::XFastContextHandler > SAL_CALL
2217 2 : OOXMLFastContextHandlerWrapper::createUnknownChildContext
2218 : (const OUString & Namespace,
2219 : const OUString & Name,
2220 : const uno::Reference< xml::sax::XFastAttributeList > & Attribs)
2221 : throw (uno::RuntimeException, xml::sax::SAXException)
2222 : {
2223 2 : uno::Reference< xml::sax::XFastContextHandler > xResult;
2224 :
2225 2 : if (mxContext.is())
2226 0 : xResult = mxContext->createUnknownChildContext
2227 0 : (Namespace, Name, Attribs);
2228 : else
2229 2 : xResult.set(this);
2230 :
2231 2 : return xResult;
2232 : }
2233 :
2234 1059 : void OOXMLFastContextHandlerWrapper::attributes
2235 : (const uno::Reference< xml::sax::XFastAttributeList > & Attribs)
2236 : throw (uno::RuntimeException, xml::sax::SAXException)
2237 : {
2238 1059 : if (mxContext.is())
2239 : {
2240 649 : OOXMLFastContextHandler * pHandler = getFastContextHandler();
2241 649 : if (pHandler != NULL)
2242 0 : pHandler->attributes(Attribs);
2243 : }
2244 1059 : }
2245 :
2246 : OOXMLFastContextHandler::ResourceEnum_t
2247 13 : OOXMLFastContextHandlerWrapper::getResource() const
2248 : {
2249 13 : return UNKNOWN;
2250 : }
2251 :
2252 324 : void OOXMLFastContextHandlerWrapper::addNamespace(const Id & nId)
2253 : {
2254 324 : mMyNamespaces.insert(nId);
2255 324 : }
2256 :
2257 108 : void OOXMLFastContextHandlerWrapper::addToken( Token_t Token )
2258 : {
2259 108 : mMyTokens.insert( Token );
2260 108 : }
2261 :
2262 1059 : void OOXMLFastContextHandlerWrapper::lcl_startFastElement
2263 : (Token_t Element,
2264 : const uno::Reference< xml::sax::XFastAttributeList > & Attribs)
2265 : throw (uno::RuntimeException, xml::sax::SAXException)
2266 : {
2267 1059 : if (mxContext.is())
2268 649 : mxContext->startFastElement(Element, Attribs);
2269 1059 : }
2270 :
2271 1059 : void OOXMLFastContextHandlerWrapper::lcl_endFastElement
2272 : (Token_t Element)
2273 : throw (uno::RuntimeException, xml::sax::SAXException)
2274 : {
2275 1059 : if (mxContext.is())
2276 649 : mxContext->endFastElement(Element);
2277 1059 : }
2278 :
2279 : uno::Reference< xml::sax::XFastContextHandler >
2280 988 : OOXMLFastContextHandlerWrapper::lcl_createFastChildContext
2281 : (Token_t Element,
2282 : const uno::Reference< xml::sax::XFastAttributeList > & Attribs)
2283 : throw (uno::RuntimeException, xml::sax::SAXException)
2284 : {
2285 988 : uno::Reference< xml::sax::XFastContextHandler > xResult;
2286 :
2287 988 : Id nNameSpace = Element & 0xffff0000;
2288 :
2289 : #ifdef DEBUG_ELEMENT
2290 : debug_logger->startElement("Wrapper-createChildContext");
2291 : debug_logger->attribute("token", fastTokenToId(Element));
2292 :
2293 : const set<Id>::const_iterator aEnd(mMyNamespaces.end());
2294 : for (set<Id>::const_iterator aIt(mMyNamespaces.begin());
2295 : aIt != aEnd; ++aIt)
2296 : {
2297 : debug_logger->startElement("namespace");
2298 : debug_logger->attribute("id", fastTokenToId(*aIt));
2299 : debug_logger->endElement();
2300 : }
2301 :
2302 : debug_logger->endElement();
2303 : #endif
2304 :
2305 988 : bool bInNamespaces = mMyNamespaces.find(nNameSpace) != mMyNamespaces.end();
2306 988 : bool bInTokens = mMyTokens.find( Element ) != mMyTokens.end( );
2307 :
2308 988 : OOXMLFastContextHandlerShape* pShapeCtx = (OOXMLFastContextHandlerShape*)mpParent;
2309 :
2310 : // We have methods to _add_ individual tokens or whole namespaces to be
2311 : // processed by writerfilter (instead of oox), but we have no method to
2312 : // filter out a single token. Just hardwire the wrap token here till we
2313 : // need a more generic solution.
2314 988 : bool bIsWrap = Element == static_cast<sal_Int32>(NS_vml_wordprocessingDrawing | OOXML_wrap);
2315 988 : if ( bInNamespaces && ((pShapeCtx->isShapeSent() && bIsWrap) || !bIsWrap) )
2316 44 : xResult.set(OOXMLFactory::getInstance()->createFastChildContextFromStart(this, Element));
2317 944 : else if (mxContext.is())
2318 : {
2319 : OOXMLFastContextHandlerWrapper * pWrapper =
2320 : new OOXMLFastContextHandlerWrapper
2321 822 : (this, mxContext->createFastChildContext(Element, Attribs));
2322 822 : pWrapper->mMyNamespaces = mMyNamespaces;
2323 822 : pWrapper->setPropertySet(getPropertySet());
2324 822 : xResult.set(pWrapper);
2325 : }
2326 : else
2327 122 : xResult.set(this);
2328 :
2329 988 : if ( bInTokens )
2330 21 : pShapeCtx->sendShape( Element );
2331 :
2332 988 : return xResult;
2333 : }
2334 :
2335 1438 : void OOXMLFastContextHandlerWrapper::lcl_characters
2336 : (const OUString & aChars)
2337 : throw (uno::RuntimeException, xml::sax::SAXException)
2338 : {
2339 1438 : if (mxContext.is())
2340 1324 : mxContext->characters(aChars);
2341 1438 : }
2342 :
2343 : OOXMLFastContextHandler *
2344 6442 : OOXMLFastContextHandlerWrapper::getFastContextHandler() const
2345 : {
2346 6442 : if (mxContext.is())
2347 6442 : return dynamic_cast<OOXMLFastContextHandler *>(mxContext.get());
2348 :
2349 0 : return NULL;
2350 : }
2351 :
2352 0 : void OOXMLFastContextHandlerWrapper::newProperty
2353 : (const Id & rId, OOXMLValue::Pointer_t pVal)
2354 : {
2355 0 : if (mxContext.is())
2356 : {
2357 0 : OOXMLFastContextHandler * pHandler = getFastContextHandler();
2358 0 : if (pHandler != NULL)
2359 0 : pHandler->newProperty(rId, pVal);
2360 : }
2361 0 : }
2362 :
2363 1759 : void OOXMLFastContextHandlerWrapper::setPropertySet
2364 : (OOXMLPropertySet::Pointer_t pPropertySet)
2365 : {
2366 1759 : if (mxContext.is())
2367 : {
2368 1185 : OOXMLFastContextHandler * pHandler = getFastContextHandler();
2369 1185 : if (pHandler != NULL)
2370 0 : pHandler->setPropertySet(pPropertySet);
2371 : }
2372 :
2373 1759 : mpPropertySet = pPropertySet;
2374 1759 : }
2375 :
2376 1666 : OOXMLPropertySet::Pointer_t OOXMLFastContextHandlerWrapper::getPropertySet()
2377 : const
2378 : {
2379 1666 : OOXMLPropertySet::Pointer_t pResult(mpPropertySet);
2380 :
2381 1666 : if (mxContext.is())
2382 : {
2383 1666 : OOXMLFastContextHandler * pHandler = getFastContextHandler();
2384 1666 : if (pHandler != NULL)
2385 0 : pResult = pHandler->getPropertySet();
2386 : }
2387 :
2388 1666 : return pResult;
2389 : }
2390 :
2391 0 : string OOXMLFastContextHandlerWrapper::getType() const
2392 : {
2393 0 : string sResult = "Wrapper(";
2394 :
2395 0 : if (mxContext.is())
2396 : {
2397 0 : OOXMLFastContextHandler * pHandler = getFastContextHandler();
2398 0 : if (pHandler != NULL)
2399 0 : sResult += pHandler->getType();
2400 : }
2401 :
2402 0 : sResult += ")";
2403 :
2404 0 : return sResult;
2405 : }
2406 :
2407 937 : void OOXMLFastContextHandlerWrapper::setId(Id rId)
2408 : {
2409 937 : OOXMLFastContextHandler::setId(rId);
2410 :
2411 937 : if (mxContext.is())
2412 : {
2413 649 : OOXMLFastContextHandler * pHandler = getFastContextHandler();
2414 649 : if (pHandler != NULL)
2415 0 : pHandler->setId(rId);
2416 : }
2417 937 : }
2418 :
2419 822 : Id OOXMLFastContextHandlerWrapper::getId() const
2420 : {
2421 822 : Id nResult = OOXMLFastContextHandler::getId();
2422 :
2423 822 : if (mxContext.is())
2424 : {
2425 822 : OOXMLFastContextHandler * pHandler = getFastContextHandler();
2426 822 : if (pHandler != NULL && pHandler->getId() != 0)
2427 0 : nResult = pHandler->getId();
2428 : }
2429 :
2430 822 : return nResult;
2431 : }
2432 :
2433 937 : void OOXMLFastContextHandlerWrapper::setToken(Token_t nToken)
2434 : {
2435 937 : OOXMLFastContextHandler::setToken(nToken);
2436 :
2437 937 : if (mxContext.is())
2438 : {
2439 649 : OOXMLFastContextHandler * pHandler = getFastContextHandler();
2440 649 : if (pHandler != NULL)
2441 0 : pHandler->setToken(nToken);
2442 : }
2443 937 : }
2444 :
2445 822 : Token_t OOXMLFastContextHandlerWrapper::getToken() const
2446 : {
2447 822 : Token_t nResult = OOXMLFastContextHandler::getToken();
2448 :
2449 822 : if (mxContext.is())
2450 : {
2451 822 : OOXMLFastContextHandler * pHandler = getFastContextHandler();
2452 822 : if (pHandler != NULL)
2453 0 : nResult = pHandler->getToken();
2454 : }
2455 :
2456 822 : return nResult;
2457 : }
2458 :
2459 :
2460 : /*
2461 : class OOXMLFastContextHandlerLinear
2462 : */
2463 :
2464 88 : OOXMLFastContextHandlerLinear::OOXMLFastContextHandlerLinear(OOXMLFastContextHandler* pContext)
2465 : : OOXMLFastContextHandlerProperties(pContext)
2466 88 : , depthCount( 0 )
2467 : {
2468 88 : }
2469 :
2470 2470 : void OOXMLFastContextHandlerLinear::lcl_startFastElement(Token_t Element,
2471 : const uno::Reference< xml::sax::XFastAttributeList >& Attribs)
2472 : throw (uno::RuntimeException, xml::sax::SAXException)
2473 : {
2474 2470 : buffer.appendOpeningTag( Element, Attribs );
2475 2470 : ++depthCount;
2476 2470 : }
2477 :
2478 2467 : void OOXMLFastContextHandlerLinear::lcl_endFastElement(Token_t Element)
2479 : throw (uno::RuntimeException, xml::sax::SAXException)
2480 : {
2481 2467 : buffer.appendClosingTag( Element );
2482 2467 : if( --depthCount == 0 )
2483 87 : process();
2484 2467 : }
2485 :
2486 : uno::Reference< xml::sax::XFastContextHandler >
2487 2382 : OOXMLFastContextHandlerLinear::lcl_createFastChildContext(Token_t,
2488 : const uno::Reference< xml::sax::XFastAttributeList >&)
2489 : throw (uno::RuntimeException, xml::sax::SAXException)
2490 : {
2491 2382 : uno::Reference< xml::sax::XFastContextHandler > xContextHandler;
2492 2382 : xContextHandler.set( this );
2493 2382 : return xContextHandler;
2494 : }
2495 :
2496 539 : void OOXMLFastContextHandlerLinear::lcl_characters(const OUString& aChars)
2497 : throw (uno::RuntimeException, xml::sax::SAXException)
2498 : {
2499 539 : buffer.appendCharacters( aChars );
2500 539 : }
2501 :
2502 : /*
2503 : class OOXMLFastContextHandlerLinear
2504 : */
2505 :
2506 88 : OOXMLFastContextHandlerMath::OOXMLFastContextHandlerMath(OOXMLFastContextHandler* pContext)
2507 88 : : OOXMLFastContextHandlerLinear(pContext)
2508 : {
2509 88 : }
2510 :
2511 87 : void OOXMLFastContextHandlerMath::process()
2512 : {
2513 87 : SvGlobalName name( SO3_SM_CLASSID );
2514 174 : comphelper::EmbeddedObjectContainer container;
2515 174 : OUString aName;
2516 174 : uno::Reference< embed::XEmbeddedObject > ref = container.CreateEmbeddedObject( name.GetByteSequence(), aName );
2517 : assert(ref.is());
2518 87 : if (!ref.is())
2519 87 : return;
2520 174 : uno::Reference< uno::XInterface > component( ref->getComponent(), uno::UNO_QUERY );
2521 : // gcc4.4 (and 4.3 and possibly older) have a problem with dynamic_cast directly to the target class,
2522 : // so help it with an intermediate cast. I'm not sure what exactly the problem is, seems to be unrelated
2523 : // to RTLD_GLOBAL, so most probably a gcc bug.
2524 87 : oox::FormulaImportBase* import = dynamic_cast< oox::FormulaImportBase* >( dynamic_cast< SfxBaseModel* >(component.get()));
2525 : assert( import != NULL );
2526 87 : import->readFormulaOoxml( buffer );
2527 87 : if (isForwardEvents())
2528 : {
2529 87 : OOXMLPropertySet * pProps = new OOXMLPropertySetImpl();
2530 87 : OOXMLValue::Pointer_t pVal( new OOXMLStarMathValue( ref ));
2531 174 : OOXMLProperty::Pointer_t pProp( new OOXMLPropertyImpl( NS_ooxml::LN_starmath, pVal, OOXMLPropertyImpl::ATTRIBUTE ));
2532 87 : pProps->add( pProp );
2533 174 : mpStream->props( writerfilter::Reference< Properties >::Pointer_t( pProps ));
2534 87 : }
2535 : }
2536 :
2537 24 : }}
2538 :
2539 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|