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