merge the formfield patch from ooo-build
[ooovba.git] / writerfilter / source / ooxml / OOXMLFastContextHandler.cxx
blobfdaf476ef836106e06213148dde692a00f92f603
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: OOXMLFastContextHandler.cxx,v $
10 * $Revision: 1.12 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #include <stdio.h>
32 #include <iostream>
33 #include <set>
34 #include <rtl/uuid.h>
35 #include <com/sun/star/drawing/XShapes.hpp>
36 #include <resourcemodel/QNameToString.hxx>
37 #include <resourcemodel/util.hxx>
38 #include <ooxml/resourceids.hxx>
39 #include <ooxml/OOXMLnamespaceids.hxx>
40 #include "OOXMLFastContextHandler.hxx"
41 #include "Handler.hxx"
42 #include "ooxmlLoggers.hxx"
44 static const sal_uInt8 s0x7[] = { 0x7, 0x0 };
45 static const sal_uInt8 s0xd[] = { 0xd, 0x0 };
46 static const sal_uInt8 sCR[] = { 0xd, 0x0 };
47 static const sal_uInt8 sFtnEdnRef[] = { 0x2, 0x0 };
48 static const sal_uInt8 sFtnEdnSep[] = { 0x3, 0x0 };
49 static const sal_uInt8 sFtnEdnCont[] = { 0x4, 0x0 };
50 static const sal_uInt8 sTab[] = { 0x9, 0x0 };
51 static const sal_uInt8 sPgNum[] = { 0x0, 0x0 };
52 static const sal_uInt8 sFieldStart[] = { 0x13 };
53 static const sal_uInt8 sFieldSep[] = { 0x14 };
54 static const sal_uInt8 sFieldEnd[] = { 0x15 };
55 static const sal_uInt8 sNoBreakHyphen[] = { 0x1e, 0x0 };
56 static const sal_uInt8 sSoftHyphen[] = { 0x1f, 0x0 };
58 namespace writerfilter {
59 namespace ooxml
61 using ::com::sun::star::lang::XMultiComponentFactory;
62 using namespace ::com::sun::star;
63 using namespace ::std;
65 static uno::Sequence< sal_Int8 > CreateUnoTunnelId()
67 static osl::Mutex aCreateMutex;
68 osl::Guard<osl::Mutex> aGuard( aCreateMutex );
69 uno::Sequence< sal_Int8 > aSeq( 16 );
70 rtl_createUuid( (sal_uInt8*)aSeq.getArray(), 0, sal_True );
71 return aSeq;
74 static string resourceToString
75 (OOXMLFastContextHandler::ResourceEnum_t eResource)
77 string sResult;
79 switch (eResource)
81 case OOXMLFastContextHandler::STREAM:
82 sResult = "Stream";
83 break;
84 case OOXMLFastContextHandler::PROPERTIES:
85 sResult = "Properties";
86 break;
87 case OOXMLFastContextHandler::TABLE:
88 sResult = "Table";
89 break;
90 case OOXMLFastContextHandler::SHAPE:
91 sResult = "Shape";
92 break;
93 default:
94 sResult = "??";
97 return sResult;
100 set<OOXMLFastContextHandler *> aSetContexts;
103 class OOXMLIdToString : public IdToString
105 public:
106 OOXMLIdToString() : IdToString() {}
107 virtual ~OOXMLIdToString() {}
109 virtual string toString(const Id & rId) const
111 string s(fastTokenToId(rId));
113 if (s.size() == 0)
114 s = (*QNameToString::Instance())(rId);
116 return s;
121 class OOXMLFastContextHandler
124 sal_uInt32 OOXMLFastContextHandler::mnInstanceCount = 0;
126 OOXMLFastContextHandler::OOXMLFastContextHandler
127 (uno::Reference< uno::XComponentContext > const & context)
128 : mpParent(NULL),
129 mId(0),
130 mnToken(OOXML_FAST_TOKENS_END),
131 mpStream(NULL),
132 mnTableDepth(0),
133 mnInstanceNumber(mnInstanceCount),
134 mnRefCount(0),
135 m_xContext(context),
136 mbFallback(false)
138 mnInstanceCount++;
139 aSetContexts.insert(this);
141 if (mpParserState.get() == NULL)
142 mpParserState.reset(new OOXMLParserState());
144 mpParserState->incContextCount();
147 OOXMLFastContextHandler::OOXMLFastContextHandler
148 (OOXMLFastContextHandler * pContext)
149 : cppu::WeakImplHelper1<com::sun::star::xml::sax::XFastContextHandler>(),
150 mpParent(pContext),
151 mnToken(OOXML_FAST_TOKENS_END),
152 mpStream(NULL),
153 mnTableDepth(0),
154 mnInstanceNumber(mnInstanceCount),
155 mnRefCount(0),
156 m_xContext(pContext->m_xContext),
157 mbFallback(false)
159 if (pContext != NULL)
161 mpStream = pContext->mpStream;
162 mpParserState = pContext->mpParserState;
163 mnTableDepth = pContext->mnTableDepth;
164 m_xContext = pContext->m_xContext;
167 if (mpParserState.get() == NULL)
168 mpParserState.reset(new OOXMLParserState());
170 mnInstanceCount++;
171 aSetContexts.insert(this);
172 mpParserState->incContextCount();
175 OOXMLFastContextHandler::~OOXMLFastContextHandler()
177 aSetContexts.erase(this);
180 void OOXMLFastContextHandler::dumpOpenContexts()
182 debug_logger->startElement("open-contexts");
183 XMLTag aTag("open-contexts");
185 set<OOXMLFastContextHandler *>::iterator aIt(aSetContexts.begin());
186 while (aIt != aSetContexts.end())
188 debug_logger->startElement("open-context");
189 debug_logger->addTag((*aIt)->toTag());
190 debug_logger->endElement("open-context");
192 aIt++;
195 static char buffer[256];
196 snprintf(buffer, sizeof(buffer), "%" SAL_PRI_SIZET "u",
197 aSetContexts.size());
199 debug_logger->attribute("count", buffer);
200 debug_logger->endElement("open-contexts");
203 #ifdef DEBUG_MEMORY
204 void SAL_CALL OOXMLFastContextHandler::acquire()
205 throw ()
207 mnRefCount++;
209 static char buffer[256];
210 snprintf(buffer, sizeof(buffer), "%ld: %s: aquire(%ld)", mnInstanceNumber,
211 getType().c_str(), mnRefCount);
212 logger("MEMORY", buffer);
214 cppu::WeakImplHelper1<com::sun::star::xml::sax::XFastContextHandler>::acquire();
217 void SAL_CALL OOXMLFastContextHandler::release()
218 throw ()
220 static char buffer[256];
221 snprintf(buffer, sizeof(buffer), "%s: release(%ld)", mnInstanceNumber,
222 getType().c_str(), mnRefCount);
223 logger("MEMORY", buffer);
225 cppu::WeakImplHelper1<com::sun::star::xml::sax::XFastContextHandler>::release();
226 mnRefCount--;
228 #endif
230 sal_uInt32 OOXMLFastContextHandler::getInstanceNumber() const
232 return mnInstanceNumber;
235 // ::com::sun::star::xml::sax::XFastContextHandler:
236 void SAL_CALL OOXMLFastContextHandler::startFastElement
237 (Token_t Element,
238 const uno::Reference< xml::sax::XFastAttributeList > & Attribs)
239 throw (uno::RuntimeException, xml::sax::SAXException)
241 #ifdef DEBUG_ELEMENT
242 debug_logger->startElement("element");
243 debug_logger->attribute("token", fastTokenToId(Element));
244 debug_logger->attribute("type",getType());
245 debug_logger->startElement("at-start");
246 debug_logger->addTag(toTag());
247 debug_logger->endElement("at-start");
248 #endif
249 #ifdef DEBUG_MEMORY
250 static char buffer[256];
251 snprintf(buffer, sizeof(buffer), "%ld: startFastElement", mnInstanceNumber);
252 logger("MEMORY", buffer);
253 #endif
255 attributes(Attribs);
256 lcl_startFastElement(Element, Attribs);
259 void SAL_CALL OOXMLFastContextHandler::startUnknownElement
260 (const ::rtl::OUString & Namespace, const ::rtl::OUString & Name,
261 const uno::Reference< xml::sax::XFastAttributeList > & /*Attribs*/)
262 throw (uno::RuntimeException, xml::sax::SAXException)
264 #ifdef DEBUG_CONTEXT_STACK
265 debug_logger->startElement("unknown-element");
266 debug_logger->attribute("namespace", Namespace);
267 debug_logger->attribute("name", Name);
268 #else
269 (void) Namespace;
270 (void) Name;
271 #endif
274 void SAL_CALL OOXMLFastContextHandler::endFastElement(Token_t Element)
275 throw (uno::RuntimeException, xml::sax::SAXException)
277 lcl_endFastElement(Element);
279 #ifdef DEBUG_ELEMENT
280 debug_logger->startElement("at-end");
281 debug_logger->addTag(toTag());
282 debug_logger->endElement("at-end");
283 debug_logger->endElement("element");
284 #endif
285 #ifdef DEBUG_MEMORY
286 static char buffer[256];
287 snprintf(buffer, sizeof(buffer), "%ld: %s:endFastElement", mnInstanceNumber,
288 getType().c_str());
289 logger("MEMORY", buffer);
290 #endif
293 void OOXMLFastContextHandler::lcl_startFastElement
294 (Token_t Element,
295 const uno::Reference< xml::sax::XFastAttributeList > & /*Attribs*/)
296 throw (uno::RuntimeException, xml::sax::SAXException)
298 startAction(Element);
301 void OOXMLFastContextHandler::lcl_endFastElement
302 (Token_t Element)
303 throw (uno::RuntimeException, xml::sax::SAXException)
305 #ifdef DEBUG_CONTEXT_STACK
306 debug_logger->startElement("endAction");
307 debug_logger->endElement("endAction");
308 debug_logger->startElement("token");
309 debug_logger->chars(fastTokenToId(Element));
310 debug_logger->endElement("token");
311 #endif
313 endAction(Element);
316 void SAL_CALL OOXMLFastContextHandler::endUnknownElement
317 (const ::rtl::OUString & , const ::rtl::OUString & )
318 throw (uno::RuntimeException, xml::sax::SAXException)
320 #ifdef DEBUG_ELEMENT
321 debug_logger->startElement("unknown-element");
322 debug_logger->endElement("unknown-element");
323 #endif
326 uno::Reference< xml::sax::XFastContextHandler > SAL_CALL
327 OOXMLFastContextHandler::createFastChildContext
328 (Token_t Element,
329 const uno::Reference< xml::sax::XFastAttributeList > & Attribs)
330 throw (uno::RuntimeException, xml::sax::SAXException)
332 #ifdef DEBUG_CONTEXT_STACK
333 debug_logger->startElement("createFastChildContext");
334 debug_logger->attribute("token", fastTokenToId(Element));
335 debug_logger->attribute("type", getType());
336 #endif
338 uno::Reference< xml::sax::XFastContextHandler > xResult
339 (lcl_createFastChildContext(Element, Attribs));
341 #ifdef DEBUG_CONTEXT_STACK
342 debug_logger->endElement("createFastChildContext");
343 #endif
345 return xResult;
348 uno::Reference< xml::sax::XFastContextHandler >
349 OOXMLFastContextHandler::lcl_createFastChildContext
350 (Token_t /*Element*/,
351 const uno::Reference< xml::sax::XFastAttributeList > & /*Attribs*/)
352 throw (uno::RuntimeException, xml::sax::SAXException)
354 OOXMLFastContextHandler * pResult = new OOXMLFastContextHandler(this);
355 pResult->setFallback(true);
357 return uno::Reference< xml::sax::XFastContextHandler > (pResult);
360 uno::Reference< xml::sax::XFastContextHandler > SAL_CALL
361 OOXMLFastContextHandler::createUnknownChildContext
362 (const ::rtl::OUString & Namespace,
363 const ::rtl::OUString & Name,
364 const uno::Reference< xml::sax::XFastAttributeList > & /*Attribs*/)
365 throw (uno::RuntimeException, xml::sax::SAXException)
367 #ifdef DEBUG_ELEMENT
368 debug_logger->startElement("createUnknownChildContext");
369 debug_logger->attribute("namespace", Namespace);
370 debug_logger->attribute("name", Name);
371 debug_logger->endElement("createUnknownChildContext");
372 #else
373 (void) Namespace;
374 (void) Name;
375 #endif
377 return uno::Reference< xml::sax::XFastContextHandler >
378 (new OOXMLFastContextHandler(*const_cast<const OOXMLFastContextHandler *>(this)));
381 void SAL_CALL OOXMLFastContextHandler::characters
382 (const ::rtl::OUString & aChars)
383 throw (uno::RuntimeException, xml::sax::SAXException)
385 lcl_characters(aChars);
388 void OOXMLFastContextHandler::lcl_characters
389 (const ::rtl::OUString & /*aChars*/)
390 throw (uno::RuntimeException, xml::sax::SAXException)
394 const uno::Sequence< sal_Int8 > & OOXMLFastContextHandler::getUnoTunnelId()
396 static uno::Sequence< sal_Int8 > aSeq = CreateUnoTunnelId();
397 return aSeq;
400 sal_Int64 SAL_CALL OOXMLFastContextHandler::getSomething( const uno::Sequence< sal_Int8 >& rId )
401 throw(uno::RuntimeException)
403 if( rId.getLength() == 16
404 && 0 == rtl_compareMemory( getUnoTunnelId().getConstArray(),
405 rId.getConstArray(), 16 ) )
407 return sal::static_int_cast<sal_Int64>
408 (reinterpret_cast<sal_IntPtr>(this));
411 return 0x0;
414 void OOXMLFastContextHandler::setStream(Stream * pStream)
416 mpStream = pStream;
419 OOXMLValue::Pointer_t OOXMLFastContextHandler::getValue() const
421 return OOXMLValue::Pointer_t();
424 void OOXMLFastContextHandler::attributes
425 (const uno::Reference< xml::sax::XFastAttributeList > & /*Attribs*/)
426 throw (uno::RuntimeException, xml::sax::SAXException)
430 void OOXMLFastContextHandler::startAction(Token_t Element)
432 #ifdef DEBUG_ELEMENT
433 debug_logger->startElement("startAction");
434 #endif
435 lcl_startAction(Element);
436 #ifdef DEBUG_ELEMENT
437 debug_logger->endElement("startAction");
438 #endif
441 void OOXMLFastContextHandler::lcl_startAction(Token_t /* Element */)
445 void OOXMLFastContextHandler::endAction(Token_t Element)
447 #ifdef DEBUG_ELEMENT
448 debug_logger->startElement("endAction");
449 #endif
450 lcl_endAction(Element);
451 #ifdef DEBUG_ELEMENT
452 debug_logger->endElement("endAction");
453 #endif
456 void OOXMLFastContextHandler::lcl_endAction(Token_t /* Element */)
460 XMLTag::Pointer_t OOXMLFastContextHandler::toPropertiesTag
461 (OOXMLPropertySet::Pointer_t pProps)
463 XMLTag::Pointer_t pTag;
465 if (pProps.get() != NULL)
467 PropertySetToTagHandler aHandler(IdToString::Pointer_t(new OOXMLIdToString()));
469 pProps->resolve(aHandler);
470 pTag = aHandler.getTag();
473 return pTag;
476 XMLTag::Pointer_t OOXMLFastContextHandler::toTag() const
478 XMLTag::Pointer_t pTag(new XMLTag("context"));
480 static char sBuffer[128];
481 snprintf(sBuffer, sizeof(sBuffer), "%p", this);
483 pTag->addAttr("parent", sBuffer);
484 pTag->addAttr("type", getType());
485 pTag->addAttr("resource", getResourceString());
486 pTag->addAttr("token", fastTokenToId(getToken()));
487 pTag->addAttr("id", (*QNameToString::Instance())(getId()));
489 OOXMLValue::Pointer_t pVal(getValue());
491 if (pVal.get() != NULL)
492 pTag->addAttr("value", pVal->toString());
493 else
494 pTag->addAttr("value", "(null)");
496 XMLTag::Pointer_t pTagProps(toPropertiesTag(getPropertySet()));
497 if (pTagProps.get() != NULL)
498 pTag->addTag(pTagProps);
500 pTag->addTag(mpParserState->toTag());
502 return pTag;
505 string OOXMLFastContextHandler::toString() const
507 return toTag()->toString();
510 string OOXMLFastContextHandler::getResourceString() const
512 return resourceToString(getResource());
515 void OOXMLFastContextHandler::setId(Id rId)
517 #ifdef DEBUG_ELEMENT
518 debug_logger->startElement("setId");
520 static char sBuffer[256];
521 snprintf(sBuffer, sizeof(sBuffer), "%ld", rId);
523 debug_logger->attribute("id", sBuffer);
524 debug_logger->chars((*QNameToString::Instance())(rId));
525 debug_logger->endElement("setId");
526 #endif
528 mId = rId;
531 Id OOXMLFastContextHandler::getId() const
533 return mId;
536 void OOXMLFastContextHandler::setFallback(bool bFallback)
538 mbFallback = bFallback;
541 bool OOXMLFastContextHandler::isFallback() const
543 return mbFallback;
546 OOXMLParserState::Pointer_t OOXMLFastContextHandler::getParserState() const
548 return mpParserState;
551 void OOXMLFastContextHandler::setToken(Token_t nToken)
553 mnToken = nToken;
555 #ifdef DEBUG_CONTEXT_STACK
556 msTokenString = fastTokenToId(mnToken);
557 #endif
560 Token_t OOXMLFastContextHandler::getToken() const
562 return mnToken;
565 void OOXMLFastContextHandler::mark(const Id & rId, OOXMLValue::Pointer_t pVal)
567 OOXMLPropertySetImpl::Pointer_t pPropSet(new OOXMLPropertySetImpl());
568 OOXMLPropertyImpl::Pointer_t pProperty
569 (new OOXMLPropertyImpl(rId, pVal, OOXMLPropertyImpl::ATTRIBUTE));
571 #ifdef DEBUG_PROPERTIES
572 debug_logger->startElement("mark");
573 debug_logger->chars(xmlify(pProperty->toString()));
574 debug_logger->endElement("mark");
575 #endif
576 pPropSet->add(pProperty);
577 mpStream->props(pPropSet);
580 void OOXMLFastContextHandler::setParent
581 (OOXMLFastContextHandler * pParent)
583 mpParent = pParent;
586 OOXMLPropertySet * OOXMLFastContextHandler::getPicturePropSet
587 (const ::rtl::OUString & rId)
589 return dynamic_cast<OOXMLDocumentImpl *>(mpParserState->getDocument())->
590 getPicturePropSet(rId);
593 void OOXMLFastContextHandler::sendTableDepth() const
595 #ifdef DEBUG_ELEMENT
596 debug_logger->startElement("sendTableDepth");
597 #endif
599 if (mnTableDepth > 0)
601 OOXMLPropertySet * pProps = new OOXMLPropertySetImpl();
603 OOXMLValue::Pointer_t pVal
604 (new OOXMLIntegerValue(mnTableDepth));
605 OOXMLProperty::Pointer_t pProp
606 (new OOXMLPropertyImpl(0x6649, pVal, OOXMLPropertyImpl::SPRM));
607 pProps->add(pProp);
610 OOXMLValue::Pointer_t pVal
611 (new OOXMLIntegerValue(1));
612 OOXMLProperty::Pointer_t pProp
613 (new OOXMLPropertyImpl(0x2416, pVal, OOXMLPropertyImpl::SPRM));
614 pProps->add(pProp);
617 #ifdef DEBUG_PROPERTIES
618 debug_logger->startElement("props");
619 debug_logger->chars(pProps->toString());
620 debug_logger->endElement("props");
621 #endif
622 mpStream->props(writerfilter::Reference<Properties>::Pointer_t(pProps));
623 #ifdef DEBUG_PROPERTIES
624 debug_logger->endElement("sendTableDepth");
625 #endif
629 void OOXMLFastContextHandler::setHandle()
631 mpParserState->setHandle();
632 mpStream->info(mpParserState->getHandle());
635 void OOXMLFastContextHandler::startCharacterGroup()
637 if (isForwardEvents())
639 if (mpParserState->isInCharacterGroup())
640 endCharacterGroup();
642 if (! mpParserState->isInParagraphGroup())
643 startParagraphGroup();
645 if (! mpParserState->isInCharacterGroup())
647 #ifdef DEBUG_ELEMENT
648 debug_logger->element("startCharacterGroup");
649 #endif
651 mpStream->startCharacterGroup();
652 mpParserState->setInCharacterGroup(true);
653 mpParserState->resolveCharacterProperties(*mpStream);
658 void OOXMLFastContextHandler::endCharacterGroup()
660 if (isForwardEvents() && mpParserState->isInCharacterGroup())
662 #ifdef DEBUG_ELEMENT
663 debug_logger->element("endCharacterGroup");
664 #endif
666 mpStream->endCharacterGroup();
667 mpParserState->setInCharacterGroup(false);
671 void OOXMLFastContextHandler::startParagraphGroup()
673 if (isForwardEvents())
675 if (mpParserState->isInParagraphGroup())
676 endParagraphGroup();
678 if (! mpParserState->isInSectionGroup())
679 startSectionGroup();
681 if (! mpParserState->isInParagraphGroup())
683 #ifdef DEBUG_ELEMENT
684 debug_logger->element("startParagraphGroup");
685 #endif
687 mpStream->startParagraphGroup();
688 mpParserState->setInParagraphGroup(true);
693 void OOXMLFastContextHandler::endParagraphGroup()
695 if (isForwardEvents())
697 if (mpParserState->isInCharacterGroup())
698 endCharacterGroup();
700 if (mpParserState->isInParagraphGroup())
702 #ifdef DEBUG_ELEMENT
703 debug_logger->element("endParagraphGroup");
704 #endif
705 mpStream->endParagraphGroup();
706 mpParserState->setInParagraphGroup(false);
711 void OOXMLFastContextHandler::startSectionGroup()
713 if (isForwardEvents())
715 if (mpParserState->isInSectionGroup())
716 endSectionGroup();
718 if (! mpParserState->isInSectionGroup())
720 #ifdef DEBUG_ELEMENT
721 debug_logger->element("startSectionGroup");
722 #endif
723 mpStream->info(mpParserState->getHandle());
724 mpStream->startSectionGroup();
725 mpParserState->setInSectionGroup(true);
730 void OOXMLFastContextHandler::endSectionGroup()
732 if (isForwardEvents())
734 if (mpParserState->isInParagraphGroup())
735 endParagraphGroup();
737 if (mpParserState->isInSectionGroup())
739 #ifdef DEBUG_ELEMENT
740 debug_logger->element("endSectionGroup");
741 #endif
742 mpStream->endSectionGroup();
743 mpParserState->setInSectionGroup(false);
748 void OOXMLFastContextHandler::setLastParagraphInSection()
750 #ifdef DEBUG_ELEMENT
751 debug_logger->element("setLastParagraphInSection");
752 #endif
754 mpParserState->setLastParagraphInSection(true);
755 mpStream->markLastParagraphInSection( );
758 void OOXMLFastContextHandler::newProperty
759 (const Id & /*nId*/, OOXMLValue::Pointer_t /*pVal*/)
763 void OOXMLFastContextHandler::setPropertySet
764 (OOXMLPropertySet::Pointer_t /* pPropertySet */)
768 OOXMLPropertySet::Pointer_t OOXMLFastContextHandler::getPropertySet() const
770 return OOXMLPropertySet::Pointer_t();
773 void OOXMLFastContextHandler::startField()
775 #ifdef DEBUG_ELEMENT
776 debug_logger->element("startField");
777 #endif
778 startCharacterGroup();
779 if (isForwardEvents())
780 mpStream->text(sFieldStart, 1);
781 endCharacterGroup();
784 void OOXMLFastContextHandler::fieldSeparator()
786 #ifdef DEBUG_ELEMENT
787 debug_logger->element("fieldSeparator");
788 #endif
789 startCharacterGroup();
790 if (isForwardEvents())
791 mpStream->text(sFieldSep, 1);
792 endCharacterGroup();
795 void OOXMLFastContextHandler::endField()
797 #ifdef DEBUG_ELEMENT
798 debug_logger->element("endField");
799 #endif
800 startCharacterGroup();
801 if (isForwardEvents())
802 mpStream->text(sFieldEnd, 1);
803 endCharacterGroup();
806 void OOXMLFastContextHandler::ftnednref()
808 #ifdef DEBUG_ELEMENT
809 debug_logger->element("ftnednref");
810 #endif
811 if (isForwardEvents())
812 mpStream->utext(sFtnEdnRef, 1);
815 void OOXMLFastContextHandler::ftnednsep()
817 #ifdef DEBUG_ELEMENT
818 debug_logger->element("ftnednsep");
819 #endif
820 if (isForwardEvents())
821 mpStream->utext(sFtnEdnSep, 1);
824 void OOXMLFastContextHandler::ftnedncont()
826 #ifdef DEBUG_ELEMENT
827 debug_logger->element("ftnedncont");
828 #endif
829 if (isForwardEvents())
830 mpStream->text(sFtnEdnCont, 1);
833 void OOXMLFastContextHandler::pgNum()
835 #ifdef DEBUG_ELEMENT
836 debug_logger->element("pgNum");
837 #endif
838 if (isForwardEvents())
839 mpStream->utext((const sal_uInt8*)sPgNum, 1);
842 void OOXMLFastContextHandler::tab()
844 #ifdef DEBUG_ELEMENT
845 debug_logger->element("tab");
846 #endif
847 if (isForwardEvents())
848 mpStream->utext((const sal_uInt8*)sTab, 1);
851 void OOXMLFastContextHandler::cr()
853 #ifdef DEBUG_ELEMENT
854 debug_logger->element("cr");
855 #endif
856 if (isForwardEvents())
857 mpStream->utext((const sal_uInt8*)sCR, 1);
860 void OOXMLFastContextHandler::noBreakHyphen()
862 #ifdef DEBUG_ELEMENT
863 debug_logger->element("noBreakHyphen");
864 #endif
865 if (isForwardEvents())
866 mpStream->utext((const sal_uInt8*)sNoBreakHyphen, 1);
869 void OOXMLFastContextHandler::softHyphen()
871 #ifdef DEBUG_ELEMENT
872 debug_logger->element("softHyphen");
873 #endif
874 if (isForwardEvents())
875 mpStream->utext((const sal_uInt8*)sSoftHyphen, 1);
878 void OOXMLFastContextHandler::handleLastParagraphInSection()
880 #ifdef DEBUG_ELEMENT
881 debug_logger->element("handleLastParagraphInSection");
882 #endif
884 if (mpParserState->isLastParagraphInSection())
886 mpParserState->setLastParagraphInSection(false);
887 startSectionGroup();
891 void OOXMLFastContextHandler::endOfParagraph()
893 #ifdef DEBUG_ELEMENT
894 debug_logger->element("endOfParagraph");
895 #endif
896 if (! mpParserState->isInCharacterGroup())
897 startCharacterGroup();
898 if (isForwardEvents())
899 mpStream->utext((const sal_uInt8*)sCR, 1);
902 void OOXMLFastContextHandler::text(const ::rtl::OUString & sText)
904 #ifdef DEBUG_ELEMENT
905 debug_logger->startElement("text");
906 debug_logger->chars(sText);
907 debug_logger->endElement("text");
908 #endif
909 if (isForwardEvents())
910 mpStream->utext(reinterpret_cast < const sal_uInt8 * >
911 (sText.getStr()),
912 sText.getLength());
915 void OOXMLFastContextHandler::propagateCharacterProperties()
917 #ifdef DEBUG_ELEMENT
918 debug_logger->startElement("propagateCharacterProperties");
919 debug_logger->addTag(toPropertiesTag(getPropertySet()));
920 debug_logger->endElement("propagateCharacterProperties");
921 #endif
923 mpParserState->setCharacterProperties(getPropertySet());
926 void OOXMLFastContextHandler::propagateCharacterPropertiesAsSet(const Id & rId)
928 #ifdef DEBUG_ELEMENT
929 debug_logger->startElement("propagateCharacterPropertiesAsSet");
930 debug_logger->addTag(toPropertiesTag(getPropertySet()));
931 debug_logger->endElement("propagateCharacterPropertiesAsSet");
932 #endif
934 OOXMLValue::Pointer_t pValue(new OOXMLPropertySetValue(getPropertySet()));
935 OOXMLPropertySet::Pointer_t pPropertySet(new OOXMLPropertySetImpl());
937 OOXMLProperty::Pointer_t pProp
938 (new OOXMLPropertyImpl(rId, pValue, OOXMLPropertyImpl::SPRM));
940 pPropertySet->add(pProp);
941 mpParserState->setCharacterProperties(pPropertySet);
944 bool OOXMLFastContextHandler::propagatesProperties() const
946 return false;
949 void OOXMLFastContextHandler::propagateTableProperties()
951 #ifdef DEBUG_ELEMENT
952 debug_logger->element("propagateTableProperties");
953 #endif
955 mpParserState->setTableProperties(getPropertySet());
958 void OOXMLFastContextHandler::sendPropertiesWithId(const Id & rId)
960 #ifdef DEBUG_ELEMENT
961 debug_logger->startElement("sendPropertiesWithId");
962 debug_logger->attribute("id", fastTokenToId(rId));
963 #endif
965 OOXMLValue::Pointer_t pValue(new OOXMLPropertySetValue(getPropertySet()));
966 OOXMLPropertySet::Pointer_t pPropertySet(new OOXMLPropertySetImpl());
968 OOXMLProperty::Pointer_t pProp
969 (new OOXMLPropertyImpl(rId, pValue, OOXMLPropertyImpl::SPRM));
971 pPropertySet->add(pProp);
972 mpStream->props(pPropertySet);
974 #ifdef DEBUG_ELEMENT
975 debug_logger->addTag(toPropertiesTag(pPropertySet));
976 debug_logger->endElement("sendPropertiesWithId");
977 #endif
980 void OOXMLFastContextHandler::clearProps()
982 #ifdef DEBUG_ELEMENT
983 debug_logger->element("clearProps");
984 #endif
986 setPropertySet(OOXMLPropertySet::Pointer_t(new OOXMLPropertySetImpl()));
989 void OOXMLFastContextHandler::setDocument(OOXMLDocument * pDocument)
991 mpParserState->setDocument(pDocument);
994 OOXMLDocument * OOXMLFastContextHandler::getDocument()
996 return mpParserState->getDocument();
999 void OOXMLFastContextHandler::setForwardEvents(bool bForwardEvents)
1001 #ifdef DEBUG_ELEMENT
1002 debug_logger->startElement("setForwardEvents");
1004 if (bForwardEvents)
1005 debug_logger->chars("true");
1006 else
1007 debug_logger->chars("false");
1009 debug_logger->endElement("setForwardEvents");
1010 #endif
1012 mpParserState->setForwardEvents(bForwardEvents);
1015 bool OOXMLFastContextHandler::isForwardEvents() const
1017 return mpParserState->isForwardEvents();
1020 void OOXMLFastContextHandler::setXNoteId(const ::rtl::OUString & rId)
1022 mpParserState->setXNoteId(rId);
1025 const rtl::OUString & OOXMLFastContextHandler::getXNoteId() const
1027 return mpParserState->getXNoteId();
1030 void OOXMLFastContextHandler::resolveFootnote
1031 (const rtl::OUString & rId)
1033 mpParserState->getDocument()->resolveFootnote
1034 (*mpStream, 0, rId);
1037 void OOXMLFastContextHandler::resolveEndnote(const rtl::OUString & rId)
1039 mpParserState->getDocument()->resolveEndnote
1040 (*mpStream, 0, rId);
1043 void OOXMLFastContextHandler::resolveComment(const rtl::OUString & rId)
1045 mpParserState->getDocument()->resolveComment(*mpStream, rId);
1048 void OOXMLFastContextHandler::resolvePicture(const rtl::OUString & rId)
1050 mpParserState->getDocument()->resolvePicture(*mpStream, rId);
1053 void OOXMLFastContextHandler::resolveHeader
1054 (const sal_Int32 type, const rtl::OUString & rId)
1056 mpParserState->getDocument()->resolveHeader(*mpStream, type, rId);
1059 void OOXMLFastContextHandler::resolveFooter
1060 (const sal_Int32 type, const rtl::OUString & rId)
1062 mpParserState->getDocument()->resolveFooter(*mpStream, type, rId);
1065 void OOXMLFastContextHandler::resolveOLE(const rtl::OUString & rId)
1067 uno::Reference<io::XInputStream> xInputStream
1068 (mpParserState->getDocument()->getInputStreamForId(rId));
1070 OOXMLValue::Pointer_t aValue(new OOXMLInputStreamValue(xInputStream));
1072 newProperty(NS_ooxml::LN_inputstream, aValue);
1075 ::rtl::OUString OOXMLFastContextHandler::getTargetForId
1076 (const ::rtl::OUString & rId)
1078 return mpParserState->getDocument()->getTargetForId(rId);
1081 void OOXMLFastContextHandler::resolvePropertySetAttrs()
1085 void OOXMLFastContextHandler::sendPropertyToParent()
1087 if (mpParent != NULL)
1089 OOXMLPropertySet::Pointer_t pProps(mpParent->getPropertySet());
1091 if (pProps.get() != NULL)
1093 OOXMLProperty::Pointer_t
1094 pProp(new OOXMLPropertyImpl(mId, getValue(),
1095 OOXMLPropertyImpl::SPRM));
1096 pProps->add(pProp);
1101 uno::Reference< uno::XComponentContext >
1102 OOXMLFastContextHandler::getComponentContext()
1104 return m_xContext;
1108 class OOXMLFastContextHandlerNoResource
1110 OOXMLFastContextHandlerNoResource::OOXMLFastContextHandlerNoResource
1111 (OOXMLFastContextHandler * pContext)
1112 : OOXMLFastContextHandler(pContext)
1116 OOXMLFastContextHandlerNoResource::~OOXMLFastContextHandlerNoResource()
1121 class OOXMLFastContextHandlerStream
1124 OOXMLFastContextHandlerStream::OOXMLFastContextHandlerStream
1125 (OOXMLFastContextHandler * pContext)
1126 : OOXMLFastContextHandler(pContext),
1127 mpPropertySetAttrs(new OOXMLPropertySetImpl())
1131 OOXMLFastContextHandlerStream::~OOXMLFastContextHandlerStream()
1135 void OOXMLFastContextHandlerStream::newProperty(const Id & rId,
1136 OOXMLValue::Pointer_t pVal)
1138 if (rId != 0x0)
1140 OOXMLPropertyImpl::Pointer_t pProperty
1141 (new OOXMLPropertyImpl(rId, pVal, OOXMLPropertyImpl::ATTRIBUTE));
1143 mpPropertySetAttrs->add(pProperty);
1147 void OOXMLFastContextHandlerStream::sendProperty(Id nId)
1149 #ifdef DEBUG_PROPERTIES
1150 debug_logger->startElement("sendProperty");
1151 debug_logger->attribute("id", (*QNameToString::Instance())(nId));
1152 debug_logger->chars(xmlify(getPropertySetAttrs()->toString()));
1153 debug_logger->endElement("sendProperty");
1154 #endif
1156 OOXMLPropertySetEntryToString aHandler(nId);
1157 getPropertySetAttrs()->resolve(aHandler);
1158 const ::rtl::OUString & sText = aHandler.getString();
1159 mpStream->utext(reinterpret_cast < const sal_uInt8 * >
1160 (sText.getStr()),
1161 sText.getLength());
1164 void OOXMLFastContextHandlerStream::setPropertySetAttrs
1165 (OOXMLPropertySet::Pointer_t pPropertySetAttrs)
1167 mpPropertySetAttrs = pPropertySetAttrs;
1170 OOXMLPropertySet::Pointer_t
1171 OOXMLFastContextHandlerStream::getPropertySetAttrs() const
1173 return mpPropertySetAttrs;
1176 void OOXMLFastContextHandlerStream::resolvePropertySetAttrs()
1178 #ifdef DEBUG_PROPERTIES
1179 debug_logger->startElement("resolvePropertySetAttrs");
1180 debug_logger->chars(mpPropertySetAttrs->toString());
1181 debug_logger->endElement("resolvePropertySetAttrs");
1182 #endif
1183 mpStream->props(mpPropertySetAttrs);
1186 OOXMLPropertySet::Pointer_t OOXMLFastContextHandlerStream::getPropertySet()
1187 const
1189 return getPropertySetAttrs();
1192 void OOXMLFastContextHandlerStream::handleHyperlink()
1194 OOXMLHyperlinkHandler aHyperlinkHandler(this);
1195 getPropertySetAttrs()->resolve(aHyperlinkHandler);
1198 void OOXMLFastContextHandlerStream::lcl_characters
1199 (const ::rtl::OUString & rChars)
1200 throw (uno::RuntimeException, xml::sax::SAXException)
1202 text(rChars);
1206 class OOXMLFastContextHandlerProperties
1208 OOXMLFastContextHandlerProperties::OOXMLFastContextHandlerProperties
1209 (OOXMLFastContextHandler * pContext)
1210 : OOXMLFastContextHandler(pContext), mpPropertySet(new OOXMLPropertySetImpl()),
1211 mbResolve(false)
1213 if (pContext->getResource() == STREAM)
1214 mbResolve = true;
1217 OOXMLFastContextHandlerProperties::~OOXMLFastContextHandlerProperties()
1221 void OOXMLFastContextHandlerProperties::lcl_endFastElement
1222 (Token_t Element)
1223 throw (uno::RuntimeException, xml::sax::SAXException)
1225 endAction(Element);
1227 if (mbResolve)
1229 if (isForwardEvents())
1231 #ifdef DEBUG_PROPERTIES
1232 debug_logger->startElement("sendproperties");
1233 debug_logger->addTag(toPropertiesTag(getPropertySet()));
1234 debug_logger->endElement("sendproperties");
1235 #endif
1236 mpStream->props(mpPropertySet);
1239 else
1241 OOXMLValue::Pointer_t pVal
1242 (new OOXMLPropertySetValue(mpPropertySet));
1244 OOXMLPropertyImpl::Pointer_t pProperty
1245 (new OOXMLPropertyImpl(mId, pVal, OOXMLPropertyImpl::SPRM));
1247 OOXMLPropertySet::Pointer_t pProperties = (*mpParent).getPropertySet();
1249 if (pProperties.get() != NULL)
1251 #ifdef DEBUG_PROPERTIES
1252 debug_logger->startElement("property");
1253 debug_logger->chars(xmlify(pProperty->toString()));
1254 debug_logger->endElement("property");
1255 #endif
1256 pProperties->add(pProperty);
1258 #ifdef DEBUG_PROPERTIES
1259 else if (! propagatesProperties())
1261 debug_logger->startElement("warning");
1262 debug_logger->chars("properties lost");
1263 debug_logger->endElement("warning");
1265 #endif
1269 OOXMLValue::Pointer_t OOXMLFastContextHandlerProperties::getValue() const
1271 return OOXMLValue::Pointer_t(new OOXMLPropertySetValue(mpPropertySet));
1274 XMLTag::Pointer_t OOXMLFastContextHandlerProperties::toTag() const
1276 XMLTag::Pointer_t pTag(OOXMLFastContextHandler::toTag());
1277 pTag->addAttr("resolve", mbResolve ? "resolve" : "noResolve");
1279 return pTag;
1282 void OOXMLFastContextHandlerProperties::newProperty
1283 (const Id & rId, OOXMLValue::Pointer_t pVal)
1285 if (rId != 0x0)
1287 OOXMLPropertyImpl::Pointer_t pProperty
1288 (new OOXMLPropertyImpl(rId, pVal, OOXMLPropertyImpl::ATTRIBUTE));
1290 mpPropertySet->add(pProperty);
1294 void OOXMLFastContextHandlerProperties::handleXNotes()
1296 switch (mnToken)
1298 case NS_wordprocessingml|OOXML_footnoteReference:
1300 OOXMLFootnoteHandler aFootnoteHandler(this);
1301 mpPropertySet->resolve(aFootnoteHandler);
1303 break;
1304 case NS_wordprocessingml|OOXML_endnoteReference:
1306 OOXMLEndnoteHandler aEndnoteHandler(this);
1307 mpPropertySet->resolve(aEndnoteHandler);
1309 break;
1310 default:
1311 break;
1315 void OOXMLFastContextHandlerProperties::handleHdrFtr()
1317 switch (mnToken)
1319 case NS_wordprocessingml|OOXML_footerReference:
1321 OOXMLFooterHandler aFooterHandler(this);
1322 mpPropertySet->resolve(aFooterHandler);
1324 break;
1325 case NS_wordprocessingml|OOXML_headerReference:
1327 OOXMLHeaderHandler aHeaderHandler(this);
1328 mpPropertySet->resolve(aHeaderHandler);
1330 break;
1331 default:
1332 break;
1336 void OOXMLFastContextHandlerProperties::handleComment()
1338 #ifdef DEBUG_ELEMENT
1339 debug_logger->element("handleComment");
1340 #endif
1342 OOXMLCommentHandler aCommentHandler(this);
1343 getPropertySet()->resolve(aCommentHandler);
1346 void OOXMLFastContextHandlerProperties::handlePicture()
1348 #ifdef DEBUG_ELEMENT
1349 debug_logger->element("handlePicture");
1350 #endif
1352 OOXMLPictureHandler aPictureHandler(this);
1353 getPropertySet()->resolve(aPictureHandler);
1356 void OOXMLFastContextHandlerProperties::handleBreak()
1358 #ifdef DEBUG_ELEMENT
1359 debug_logger->element("handleBreak");
1360 #endif
1362 OOXMLBreakHandler aBreakHandler(*mpStream, this);
1363 getPropertySet()->resolve(aBreakHandler);
1366 void OOXMLFastContextHandlerProperties::handleOLE()
1368 #ifdef DEBUG_ELEMENT
1369 debug_logger->element("handleOLE");
1370 #endif
1372 OOXMLOLEHandler aOLEHandler(this);
1373 getPropertySet()->resolve(aOLEHandler);
1376 void OOXMLFastContextHandlerProperties::setParent
1377 (OOXMLFastContextHandler * pParent)
1379 #ifdef DEBUG_ELEMENT
1380 debug_logger->startElement("setParent");
1381 debug_logger->chars("OOXMLFastContextHandlerProperties");
1382 debug_logger->endElement("setParent");
1383 #endif
1385 OOXMLFastContextHandler::setParent(pParent);
1387 if (mpParent->getResource() == STREAM)
1388 mbResolve = true;
1391 void OOXMLFastContextHandlerProperties::setPropertySet
1392 (OOXMLPropertySet::Pointer_t pPropertySet)
1394 if (pPropertySet.get() != NULL)
1395 mpPropertySet = pPropertySet;
1398 OOXMLPropertySet::Pointer_t
1399 OOXMLFastContextHandlerProperties::getPropertySet() const
1401 return mpPropertySet;
1405 * class OOXMLFasContextHandlerPropertyTable
1408 OOXMLFastContextHandlerPropertyTable::OOXMLFastContextHandlerPropertyTable
1409 (OOXMLFastContextHandler * pContext)
1410 : OOXMLFastContextHandlerProperties(pContext)
1414 OOXMLFastContextHandlerPropertyTable::~OOXMLFastContextHandlerPropertyTable()
1418 void OOXMLFastContextHandlerPropertyTable::lcl_endFastElement
1419 (Token_t Element)
1420 throw (uno::RuntimeException, xml::sax::SAXException)
1422 OOXMLPropertySet::Pointer_t pPropSet(mpPropertySet->clone());
1423 OOXMLTableImpl::ValuePointer_t pTmpVal
1424 (new OOXMLPropertySetValue(pPropSet));
1426 mTable.add(pTmpVal);
1428 writerfilter::Reference<Table>::Pointer_t pTable(mTable.clone());
1429 mpStream->table(mId, pTable);
1431 endAction(Element);
1435 class OOXMLFastContextHandlerBooleanValue
1438 OOXMLFastContextHandlerBooleanValue::OOXMLFastContextHandlerBooleanValue
1439 (OOXMLFastContextHandler * pContext)
1440 : OOXMLFastContextHandler(pContext), mbValue(true)
1444 OOXMLFastContextHandlerBooleanValue::~OOXMLFastContextHandlerBooleanValue()
1448 void OOXMLFastContextHandlerBooleanValue::attributes
1449 (const uno::Reference < xml::sax::XFastAttributeList > & Attribs)
1450 throw (uno::RuntimeException, xml::sax::SAXException)
1452 if (Attribs->hasAttribute(NS_wordprocessingml|OOXML_val))
1453 mbValue = Attribs->getValue(NS_wordprocessingml|OOXML_val).toBoolean();
1456 OOXMLValue::Pointer_t OOXMLFastContextHandlerBooleanValue::getValue() const
1458 return OOXMLValue::Pointer_t(new OOXMLBooleanValue(mbValue));
1461 void OOXMLFastContextHandlerBooleanValue::setValue
1462 (const ::rtl::OUString & rString)
1464 static rtl::OUString sOn(RTL_CONSTASCII_USTRINGPARAM("on"));
1465 static rtl::OUString sOff(RTL_CONSTASCII_USTRINGPARAM("off"));
1466 static rtl::OUString sTrue(RTL_CONSTASCII_USTRINGPARAM("true"));
1467 static rtl::OUString sFalse(RTL_CONSTASCII_USTRINGPARAM("false"));
1469 if (rString == sOn || rString == sTrue)
1470 mbValue = true;
1471 else if (rString == sOff || rString == sFalse)
1472 mbValue = false;
1475 void OOXMLFastContextHandlerBooleanValue::lcl_endFastElement
1476 (Token_t Element)
1477 throw (uno::RuntimeException, xml::sax::SAXException)
1479 sendPropertyToParent();
1481 endAction(Element);
1485 class OOXMLFastContextHandlerIntegerValue
1488 OOXMLFastContextHandlerIntegerValue::OOXMLFastContextHandlerIntegerValue
1489 (OOXMLFastContextHandler * pContext)
1490 : OOXMLFastContextHandler(pContext), mnValue(0)
1494 OOXMLFastContextHandlerIntegerValue::~OOXMLFastContextHandlerIntegerValue()
1498 void OOXMLFastContextHandlerIntegerValue::attributes
1499 (const uno::Reference < xml::sax::XFastAttributeList > & Attribs)
1500 throw (uno::RuntimeException, xml::sax::SAXException)
1502 if (Attribs->hasAttribute(NS_wordprocessingml|OOXML_val))
1503 mnValue = Attribs->getValue(NS_wordprocessingml|OOXML_val).toInt32();
1506 void OOXMLFastContextHandlerIntegerValue::lcl_endFastElement
1507 (Token_t Element)
1508 throw (uno::RuntimeException, xml::sax::SAXException)
1510 sendPropertyToParent();
1512 endAction(Element);
1515 OOXMLValue::Pointer_t OOXMLFastContextHandlerIntegerValue::getValue() const
1517 return OOXMLValue::Pointer_t(new OOXMLIntegerValue(mnValue));
1521 class OOXMLFastContextHandlerStringValue
1524 OOXMLFastContextHandlerStringValue::OOXMLFastContextHandlerStringValue
1525 (OOXMLFastContextHandler * pContext)
1526 : OOXMLFastContextHandler(pContext)
1530 OOXMLFastContextHandlerStringValue::~OOXMLFastContextHandlerStringValue()
1534 void OOXMLFastContextHandlerStringValue::attributes
1535 (const uno::Reference < xml::sax::XFastAttributeList > & Attribs)
1536 throw (uno::RuntimeException, xml::sax::SAXException)
1538 if (Attribs->hasAttribute(NS_wordprocessingml|OOXML_val))
1539 msValue = Attribs->getValue(NS_wordprocessingml|OOXML_val);
1542 void OOXMLFastContextHandlerStringValue::lcl_endFastElement
1543 (Token_t Element)
1544 throw (uno::RuntimeException, xml::sax::SAXException)
1546 sendPropertyToParent();
1548 endAction(Element);
1551 OOXMLValue::Pointer_t OOXMLFastContextHandlerStringValue::getValue() const
1553 return OOXMLValue::Pointer_t(new OOXMLStringValue(msValue));
1557 class OOXMLFastContextHandlerHexValue
1560 OOXMLFastContextHandlerHexValue::OOXMLFastContextHandlerHexValue
1561 (OOXMLFastContextHandler * pContext)
1562 : OOXMLFastContextHandler(pContext), mnValue(0)
1566 OOXMLFastContextHandlerHexValue::~OOXMLFastContextHandlerHexValue()
1570 void OOXMLFastContextHandlerHexValue::attributes
1571 (const uno::Reference < xml::sax::XFastAttributeList > & Attribs)
1572 throw (uno::RuntimeException, xml::sax::SAXException)
1574 if (Attribs->hasAttribute(NS_wordprocessingml|OOXML_val))
1575 mnValue = Attribs->getValue(NS_wordprocessingml|OOXML_val).toInt32(16);
1578 void OOXMLFastContextHandlerHexValue::lcl_endFastElement
1579 (Token_t Element)
1580 throw (uno::RuntimeException, xml::sax::SAXException)
1582 sendPropertyToParent();
1584 endAction(Element);
1587 OOXMLValue::Pointer_t OOXMLFastContextHandlerHexValue::getValue() const
1589 return OOXMLValue::Pointer_t(new OOXMLIntegerValue(mnValue));
1593 class OOXMLFastContextHandlerListValue
1596 OOXMLFastContextHandlerListValue::OOXMLFastContextHandlerListValue
1597 (OOXMLFastContextHandler * pContext)
1598 : OOXMLFastContextHandler(pContext)
1602 OOXMLFastContextHandlerListValue::~OOXMLFastContextHandlerListValue()
1606 void OOXMLFastContextHandlerListValue::lcl_endFastElement
1607 (Token_t Element)
1608 throw (uno::RuntimeException, xml::sax::SAXException)
1610 sendPropertyToParent();
1612 endAction(Element);
1615 OOXMLValue::Pointer_t OOXMLFastContextHandlerListValue::getValue() const
1617 return mpValue;
1621 class OOXMLFastContextHandlerTable
1624 OOXMLFastContextHandlerTable::OOXMLFastContextHandlerTable
1625 (OOXMLFastContextHandler * pContext)
1626 : OOXMLFastContextHandler(pContext)
1630 OOXMLFastContextHandlerTable::~OOXMLFastContextHandlerTable()
1634 uno::Reference< xml::sax::XFastContextHandler > SAL_CALL
1635 OOXMLFastContextHandlerTable::createFastChildContext
1636 (Token_t Element,
1637 const uno::Reference< xml::sax::XFastAttributeList > & Attribs)
1638 throw (uno::RuntimeException, xml::sax::SAXException)
1640 addCurrentChild();
1642 mCurrentChild.set
1643 (OOXMLFastContextHandler::createFastChildContext(Element, Attribs));
1645 return mCurrentChild;
1648 void OOXMLFastContextHandlerTable::lcl_endFastElement
1649 (Token_t /*Element*/)
1650 throw (uno::RuntimeException, xml::sax::SAXException)
1652 addCurrentChild();
1654 writerfilter::Reference<Table>::Pointer_t pTable(mTable.clone());
1655 if (isForwardEvents() && mId != 0x0)
1656 mpStream->table(mId, pTable);
1659 void OOXMLFastContextHandlerTable::addCurrentChild()
1661 OOXMLFastContextHandler * pHandler = mCurrentChild.getPointer();
1662 if ( pHandler != NULL)
1664 OOXMLValue::Pointer_t pValue(pHandler->getValue());
1666 if (pValue.get() != NULL)
1668 OOXMLTableImpl::ValuePointer_t pTmpVal(pValue->clone());
1669 mTable.add(pTmpVal);
1674 void OOXMLFastContextHandlerTable::newPropertySet
1675 (OOXMLPropertySet::Pointer_t /*pPropertySet*/)
1681 class OOXMLFastContextHandlerXNote
1684 OOXMLFastContextHandlerXNote::OOXMLFastContextHandlerXNote
1685 (OOXMLFastContextHandler * pContext)
1686 : OOXMLFastContextHandler(pContext)
1690 OOXMLFastContextHandlerXNote::~OOXMLFastContextHandlerXNote()
1694 void OOXMLFastContextHandlerXNote::lcl_startFastElement
1695 (Token_t Element,
1696 const uno::Reference< xml::sax::XFastAttributeList > & /*Attribs*/)
1697 throw (uno::RuntimeException, xml::sax::SAXException)
1699 mbForwardEventsSaved = isForwardEvents();
1701 if (msMyXNoteId.compareTo(getXNoteId()) == 0)
1702 setForwardEvents(true);
1703 else
1704 setForwardEvents(false);
1706 startAction(Element);
1709 void OOXMLFastContextHandlerXNote::lcl_endFastElement
1710 (Token_t Element)
1711 throw (uno::RuntimeException, xml::sax::SAXException)
1713 endAction(Element);
1715 setForwardEvents(mbForwardEventsSaved);
1718 void OOXMLFastContextHandlerXNote::checkId(const rtl::OUString & rId)
1720 #ifdef DEBUG_ELEMENT
1721 debug_logger->startElement("checkId");
1722 debug_logger->attribute("myId", rId);
1723 debug_logger->attribute("id", getXNoteId());
1724 debug_logger->endElement("checkId");
1725 #endif
1727 msMyXNoteId = rId;
1731 class OOXMLFastContextHandlerTextTableCell
1734 OOXMLFastContextHandlerTextTableCell::OOXMLFastContextHandlerTextTableCell
1735 (OOXMLFastContextHandler * pContext)
1736 : OOXMLFastContextHandler(pContext)
1740 OOXMLFastContextHandlerTextTableCell::~OOXMLFastContextHandlerTextTableCell()
1744 void OOXMLFastContextHandlerTextTableCell::startCell()
1748 void OOXMLFastContextHandlerTextTableCell::endCell()
1750 if (isForwardEvents())
1752 OOXMLPropertySet * pProps = new OOXMLPropertySetImpl();
1754 OOXMLValue::Pointer_t pVal
1755 (new OOXMLIntegerValue(mnTableDepth));
1756 OOXMLProperty::Pointer_t pProp
1757 (new OOXMLPropertyImpl(0x6649, pVal, OOXMLPropertyImpl::SPRM));
1758 pProps->add(pProp);
1761 OOXMLValue::Pointer_t pVal
1762 (new OOXMLIntegerValue(1));
1763 OOXMLProperty::Pointer_t pProp
1764 (new OOXMLPropertyImpl(0x2416, pVal, OOXMLPropertyImpl::SPRM));
1765 pProps->add(pProp);
1768 OOXMLValue::Pointer_t pVal
1769 (new OOXMLIntegerValue(mnTableDepth));
1770 OOXMLProperty::Pointer_t pProp
1771 (new OOXMLPropertyImpl(0x244b, pVal, OOXMLPropertyImpl::SPRM));
1772 pProps->add(pProp);
1775 #ifdef DEBUG_PROPERTIES
1776 debug_logger->startElement("endcell");
1777 debug_logger->addTag(toPropertiesTag
1778 (OOXMLPropertySet::Pointer_t(pProps->clone())));
1779 debug_logger->endElement("endcell");
1780 #endif
1781 mpStream->props(writerfilter::Reference<Properties>::Pointer_t(pProps));
1786 class OOXMLFastContextHandlerTextTableRow
1789 OOXMLFastContextHandlerTextTableRow::OOXMLFastContextHandlerTextTableRow
1790 (OOXMLFastContextHandler * pContext)
1791 : OOXMLFastContextHandler(pContext)
1793 startRow();
1796 OOXMLFastContextHandlerTextTableRow::~OOXMLFastContextHandlerTextTableRow()
1798 endRow();
1801 void OOXMLFastContextHandlerTextTableRow::startRow()
1805 void OOXMLFastContextHandlerTextTableRow::endRow()
1807 startParagraphGroup();
1809 if (isForwardEvents())
1811 OOXMLPropertySet * pProps = new OOXMLPropertySetImpl();
1813 OOXMLValue::Pointer_t pVal
1814 (new OOXMLIntegerValue(mnTableDepth));
1815 OOXMLProperty::Pointer_t pProp
1816 (new OOXMLPropertyImpl(0x6649, pVal, OOXMLPropertyImpl::SPRM));
1817 pProps->add(pProp);
1820 OOXMLValue::Pointer_t pVal
1821 (new OOXMLIntegerValue(1));
1822 OOXMLProperty::Pointer_t pProp
1823 (new OOXMLPropertyImpl(0x2416, pVal, OOXMLPropertyImpl::SPRM));
1824 pProps->add(pProp);
1827 OOXMLValue::Pointer_t pVal
1828 (new OOXMLIntegerValue(1));
1829 OOXMLProperty::Pointer_t pProp
1830 (new OOXMLPropertyImpl(0x244c, pVal, OOXMLPropertyImpl::SPRM));
1831 pProps->add(pProp);
1834 #ifdef DEBUG_PROPERTIES
1835 debug_logger->startElement("endrow");
1836 debug_logger->addTag(toPropertiesTag
1837 (OOXMLPropertySet::Pointer_t(pProps->clone())));
1838 debug_logger->endElement("endrow");
1839 #endif
1841 mpStream->props(writerfilter::Reference<Properties>::Pointer_t(pProps));
1842 mpParserState->resolveTableProperties(*mpStream);
1845 startCharacterGroup();
1847 if (isForwardEvents())
1848 mpStream->utext(s0xd, 1);
1850 endParagraphGroup();
1854 class OOXMLFastContextHandlerTextTable
1857 OOXMLFastContextHandlerTextTable::OOXMLFastContextHandlerTextTable
1858 (OOXMLFastContextHandler * pContext)
1859 : OOXMLFastContextHandler(pContext)
1863 OOXMLFastContextHandlerTextTable::~OOXMLFastContextHandlerTextTable()
1867 void OOXMLFastContextHandlerTextTable::lcl_startFastElement
1868 (Token_t Element,
1869 const uno::Reference< xml::sax::XFastAttributeList > & /*Attribs*/)
1870 throw (uno::RuntimeException, xml::sax::SAXException)
1872 mnTableDepth++;
1874 boost::shared_ptr<OOXMLPropertySet> pProps( new OOXMLPropertySetImpl );
1876 OOXMLValue::Pointer_t pVal
1877 (new OOXMLIntegerValue(mnTableDepth));
1878 OOXMLProperty::Pointer_t pProp
1879 (new OOXMLPropertyImpl(NS_ooxml::LN_tblStart, pVal, OOXMLPropertyImpl::SPRM));
1880 pProps->add(pProp);
1882 mpParserState->setCharacterProperties(pProps);
1884 startAction(Element);
1887 void OOXMLFastContextHandlerTextTable::lcl_endFastElement
1888 (Token_t Element)
1889 throw (uno::RuntimeException, xml::sax::SAXException)
1891 endAction(Element);
1893 mnTableDepth--;
1897 class OOXMLFastContextHandlerShape
1900 class ShapesNoAdd:
1901 public ::cppu::WeakImplHelper1<
1902 drawing::XShapes>
1904 public:
1905 explicit ShapesNoAdd(uno::Reference< uno::XComponentContext > const & context, uno::Reference< drawing::XShapes> const & xShapes);
1907 private:
1908 // container::XElementAccess:
1909 virtual uno::Type SAL_CALL getElementType() throw (uno::RuntimeException);
1910 virtual ::sal_Bool SAL_CALL hasElements() throw (uno::RuntimeException);
1912 // container::XIndexAccess:
1913 virtual ::sal_Int32 SAL_CALL getCount() throw (uno::RuntimeException);
1914 virtual uno::Any SAL_CALL getByIndex(::sal_Int32 Index) throw (uno::RuntimeException, lang::IndexOutOfBoundsException, lang::WrappedTargetException);
1916 // drawing::XShapes:
1917 virtual void SAL_CALL add(const uno::Reference< drawing::XShape > & xShape) throw (uno::RuntimeException);
1918 virtual void SAL_CALL remove(const uno::Reference< drawing::XShape > & xShape) throw (uno::RuntimeException);
1920 ShapesNoAdd(ShapesNoAdd &); // not defined
1921 void operator =(ShapesNoAdd &); // not defined
1923 virtual ~ShapesNoAdd() {}
1925 uno::Reference< uno::XComponentContext > m_xContext;
1926 uno::Reference< drawing::XShapes > m_xShapes;
1929 ShapesNoAdd::ShapesNoAdd(uno::Reference< uno::XComponentContext > const & context, uno::Reference< drawing::XShapes> const & xShapes) :
1930 m_xContext(context), m_xShapes(xShapes)
1933 // container::XElementAccess:
1934 uno::Type SAL_CALL ShapesNoAdd::getElementType() throw (uno::RuntimeException)
1936 return m_xShapes->getElementType();
1939 ::sal_Bool SAL_CALL ShapesNoAdd::hasElements() throw (uno::RuntimeException)
1941 return m_xShapes->hasElements();
1944 // container::XIndexAccess:
1945 ::sal_Int32 SAL_CALL ShapesNoAdd::getCount() throw (uno::RuntimeException)
1947 return m_xShapes->getCount();
1950 uno::Any SAL_CALL ShapesNoAdd::getByIndex(::sal_Int32 Index) throw (uno::RuntimeException, lang::IndexOutOfBoundsException, lang::WrappedTargetException)
1952 return m_xShapes->getByIndex(Index);
1955 // drawing::XShapes:
1956 void SAL_CALL ShapesNoAdd::add(const uno::Reference< drawing::XShape > &
1957 ) throw (uno::RuntimeException)
1961 void SAL_CALL ShapesNoAdd::remove(const uno::Reference< drawing::XShape > & xShape) throw (uno::RuntimeException)
1963 m_xShapes->remove(xShape);
1966 OOXMLFastContextHandlerShape::OOXMLFastContextHandlerShape
1967 (OOXMLFastContextHandler * pContext)
1968 : OOXMLFastContextHandlerProperties(pContext), m_bShapeSent( false )
1970 uno::Reference<uno::XComponentContext> xContext(getComponentContext());
1971 if (xContext.is())
1973 uno::Reference<XMultiComponentFactory> rServiceManager
1974 (xContext->getServiceManager());
1976 mrShapeContext.set
1977 (rServiceManager->
1978 createInstanceWithContext
1979 (::rtl::OUString
1980 (RTL_CONSTASCII_USTRINGPARAM
1981 ("com.sun.star.xml.sax.FastShapeContextHandler")), xContext),
1982 uno::UNO_QUERY);
1984 if (mrShapeContext.is())
1986 mrShapeContext->setModel(getDocument()->getModel());
1987 mrShapeContext->setDrawPage(getDocument()->getDrawPage());
1988 mrShapeContext->setInputStream(getDocument()->getStorageStream());
1990 #ifdef DEBUG_ELEMENT
1991 debug_logger->startElement("setRelationFragmentPath");
1992 debug_logger->attribute("path", mpParserState->getTarget());
1993 debug_logger->endElement("setRelationFragmentPath");
1994 #endif
1995 mrShapeContext->setRelationFragmentPath
1996 (mpParserState->getTarget());
1998 #ifdef DEBUG_CONTEXT_STACK
1999 else
2001 debug_logger->startElement("error");
2002 debug_logger->chars("failed to get shape handler");
2003 debug_logger->endElement("error");
2005 #endif
2009 OOXMLFastContextHandlerShape::~OOXMLFastContextHandlerShape()
2013 void OOXMLFastContextHandlerShape::lcl_startFastElement
2014 (Token_t Element,
2015 const uno::Reference< xml::sax::XFastAttributeList > & Attribs)
2016 throw (uno::RuntimeException, xml::sax::SAXException)
2018 startAction(Element);
2020 if (mrShapeContext.is())
2022 mrShapeContext->startFastElement(Element, Attribs);
2026 void SAL_CALL OOXMLFastContextHandlerShape::startUnknownElement
2027 (const ::rtl::OUString & Namespace,
2028 const ::rtl::OUString & Name,
2029 const uno::Reference< xml::sax::XFastAttributeList > & Attribs)
2030 throw (uno::RuntimeException, xml::sax::SAXException)
2032 if (mrShapeContext.is())
2033 mrShapeContext->startUnknownElement(Namespace, Name, Attribs);
2036 void OOXMLFastContextHandlerShape::setToken(Token_t nToken)
2038 OOXMLFastContextHandler::setToken(nToken);
2040 if (mrShapeContext.is())
2041 mrShapeContext->setStartToken(nToken);
2044 void OOXMLFastContextHandlerShape::sendShape( Token_t Element )
2046 if ( mrShapeContext.is() && !m_bShapeSent )
2048 uno::Reference<drawing::XShape> xShape(mrShapeContext->getShape());
2049 if (xShape.is())
2051 OOXMLValue::Pointer_t
2052 pValue(new OOXMLShapeValue(xShape));
2053 newProperty(NS_ooxml::LN_shape, pValue);
2054 m_bShapeSent = true;
2056 bool bIsPicture = Element == ( NS_picture | OOXML_pic );
2058 // Notify the dmapper that the shape is ready to use
2059 if ( !bIsPicture )
2060 mpStream->startShape( xShape );
2065 void OOXMLFastContextHandlerShape::lcl_endFastElement
2066 (Token_t Element)
2067 throw (uno::RuntimeException, xml::sax::SAXException)
2069 if (mrShapeContext.is())
2071 mrShapeContext->endFastElement(Element);
2072 sendShape( Element );
2075 OOXMLFastContextHandlerProperties::lcl_endFastElement(Element);
2077 // Ending the shape should be the last thing to do
2078 bool bIsPicture = Element == ( NS_picture | OOXML_pic );
2079 if ( !bIsPicture )
2080 mpStream->endShape( );
2083 void SAL_CALL OOXMLFastContextHandlerShape::endUnknownElement
2084 (const ::rtl::OUString & Namespace,
2085 const ::rtl::OUString & Name)
2086 throw (uno::RuntimeException, xml::sax::SAXException)
2088 if (mrShapeContext.is())
2089 mrShapeContext->endUnknownElement(Namespace, Name);
2092 uno::Reference< xml::sax::XFastContextHandler >
2093 OOXMLFastContextHandlerShape::lcl_createFastChildContext
2094 (Token_t Element,
2095 const uno::Reference< xml::sax::XFastAttributeList > & Attribs)
2096 throw (uno::RuntimeException, xml::sax::SAXException)
2098 uno::Reference< xml::sax::XFastContextHandler > xContextHandler;
2100 sal_uInt32 nNamespace = Element & 0xffff0000;
2102 switch (nNamespace)
2104 case NS_wordprocessingml:
2105 case NS_vml_wordprocessingDrawing:
2106 case NS_office:
2107 xContextHandler.set(createFromStart(Element, Attribs));
2108 break;
2109 default:
2110 if (mrShapeContext.is())
2112 uno::Reference<XFastContextHandler> pChildContext =
2113 mrShapeContext->createFastChildContext(Element, Attribs);
2115 OOXMLFastContextHandlerWrapper * pWrapper =
2116 new OOXMLFastContextHandlerWrapper(this, pChildContext);
2118 pWrapper->addNamespace(NS_wordprocessingml);
2119 pWrapper->addNamespace(NS_vml_wordprocessingDrawing);
2120 pWrapper->addNamespace(NS_office);
2121 pWrapper->addToken( NS_vml|OOXML_textbox );
2123 xContextHandler.set(pWrapper);
2125 else
2126 xContextHandler.set(this);
2127 break;
2131 return xContextHandler;
2134 uno::Reference< xml::sax::XFastContextHandler > SAL_CALL
2135 OOXMLFastContextHandlerShape::createUnknownChildContext
2136 (const ::rtl::OUString & Namespace,
2137 const ::rtl::OUString & Name,
2138 const uno::Reference< xml::sax::XFastAttributeList > & Attribs)
2139 throw (uno::RuntimeException, xml::sax::SAXException)
2141 uno::Reference< xml::sax::XFastContextHandler > xResult;
2143 if (mrShapeContext.is())
2144 xResult.set(mrShapeContext->createUnknownChildContext
2145 (Namespace, Name, Attribs));
2147 return xResult;
2150 void OOXMLFastContextHandlerShape::lcl_characters
2151 (const ::rtl::OUString & aChars)
2152 throw (uno::RuntimeException, xml::sax::SAXException)
2154 if (mrShapeContext.is())
2155 mrShapeContext->characters(aChars);
2159 class OOXMLFastContextHandlerWrapper
2162 OOXMLFastContextHandlerWrapper::OOXMLFastContextHandlerWrapper
2163 (OOXMLFastContextHandler * pParent,
2164 uno::Reference<XFastContextHandler> xContext)
2165 : OOXMLFastContextHandler(pParent), mxContext(xContext)
2167 if (pParent != NULL)
2169 setId(pParent->getId());
2170 setToken(pParent->getToken());
2171 setPropertySet(pParent->getPropertySet());
2175 OOXMLFastContextHandlerWrapper::~OOXMLFastContextHandlerWrapper()
2179 void SAL_CALL OOXMLFastContextHandlerWrapper::startUnknownElement
2180 (const ::rtl::OUString & Namespace,
2181 const ::rtl::OUString & Name,
2182 const uno::Reference< xml::sax::XFastAttributeList > & Attribs)
2183 throw (uno::RuntimeException, xml::sax::SAXException)
2185 if (mxContext.is())
2186 mxContext->startUnknownElement(Namespace, Name, Attribs);
2189 void SAL_CALL OOXMLFastContextHandlerWrapper::endUnknownElement
2190 (const ::rtl::OUString & Namespace,
2191 const ::rtl::OUString & Name)
2192 throw (uno::RuntimeException, xml::sax::SAXException)
2194 if (mxContext.is())
2195 mxContext->endUnknownElement(Namespace, Name);
2198 uno::Reference< xml::sax::XFastContextHandler > SAL_CALL
2199 OOXMLFastContextHandlerWrapper::createUnknownChildContext
2200 (const ::rtl::OUString & Namespace,
2201 const ::rtl::OUString & Name,
2202 const uno::Reference< xml::sax::XFastAttributeList > & Attribs)
2203 throw (uno::RuntimeException, xml::sax::SAXException)
2205 uno::Reference< xml::sax::XFastContextHandler > xResult;
2207 if (mxContext.is())
2208 xResult = mxContext->createUnknownChildContext
2209 (Namespace, Name, Attribs);
2210 else
2211 xResult.set(this);
2213 return xResult;
2216 void OOXMLFastContextHandlerWrapper::attributes
2217 (const uno::Reference< xml::sax::XFastAttributeList > & Attribs)
2218 throw (uno::RuntimeException, xml::sax::SAXException)
2220 if (mxContext.is())
2222 OOXMLFastContextHandler * pHandler = getFastContextHandler();
2223 if (pHandler != NULL)
2224 pHandler->attributes(Attribs);
2228 OOXMLFastContextHandler::ResourceEnum_t
2229 OOXMLFastContextHandlerWrapper::getResource() const
2231 return UNKNOWN;
2234 void OOXMLFastContextHandlerWrapper::addNamespace(const Id & nId)
2236 mMyNamespaces.insert(nId);
2239 void OOXMLFastContextHandlerWrapper::addToken( Token_t Token )
2241 mMyTokens.insert( Token );
2244 void OOXMLFastContextHandlerWrapper::lcl_startFastElement
2245 (Token_t Element,
2246 const uno::Reference< xml::sax::XFastAttributeList > & Attribs)
2247 throw (uno::RuntimeException, xml::sax::SAXException)
2249 if (mxContext.is())
2250 mxContext->startFastElement(Element, Attribs);
2253 void OOXMLFastContextHandlerWrapper::lcl_endFastElement
2254 (Token_t Element)
2255 throw (uno::RuntimeException, xml::sax::SAXException)
2257 if (mxContext.is())
2258 mxContext->endFastElement(Element);
2261 uno::Reference< xml::sax::XFastContextHandler >
2262 OOXMLFastContextHandlerWrapper::lcl_createFastChildContext
2263 (Token_t Element,
2264 const uno::Reference< xml::sax::XFastAttributeList > & Attribs)
2265 throw (uno::RuntimeException, xml::sax::SAXException)
2267 uno::Reference< xml::sax::XFastContextHandler > xResult;
2269 Id nNameSpace = Element & 0xffff0000;
2271 #ifdef DEBUG_ELEMENT
2272 debug_logger->startElement("Wrapper-createChildContext");
2273 debug_logger->attribute("token", fastTokenToId(Element));
2275 set<Id>::const_iterator aIt(mMyNamespaces.begin());
2276 while (aIt != mMyNamespaces.end())
2278 debug_logger->startElement("namespace");
2279 debug_logger->attribute("id", fastTokenToId(*aIt));
2280 debug_logger->endElement("namespace");
2282 aIt++;
2285 debug_logger->endElement("Wrapper-createChildContext");
2286 #endif
2288 bool bInNamespaces = mMyNamespaces.find(nNameSpace) != mMyNamespaces.end();
2289 bool bInTokens = mMyTokens.find( Element ) != mMyTokens.end( );
2290 if ( bInNamespaces )
2291 xResult.set(createFromStart(Element, Attribs));
2292 else if (mxContext.is())
2294 OOXMLFastContextHandlerWrapper * pWrapper =
2295 new OOXMLFastContextHandlerWrapper
2296 (this, mxContext->createFastChildContext(Element, Attribs));
2297 pWrapper->mMyNamespaces = mMyNamespaces;
2298 pWrapper->setPropertySet(getPropertySet());
2299 xResult.set(pWrapper);
2301 else
2302 xResult.set(this);
2304 if ( bInTokens )
2306 OOXMLFastContextHandlerShape* pShapeCtx = (OOXMLFastContextHandlerShape*)mpParent;
2307 pShapeCtx->sendShape( Element );
2310 return xResult;
2313 void OOXMLFastContextHandlerWrapper::lcl_characters
2314 (const ::rtl::OUString & aChars)
2315 throw (uno::RuntimeException, xml::sax::SAXException)
2317 if (mxContext.is())
2318 mxContext->characters(aChars);
2321 OOXMLFastContextHandler *
2322 OOXMLFastContextHandlerWrapper::getFastContextHandler() const
2324 if (mxContext.is())
2325 return dynamic_cast<OOXMLFastContextHandler *>(mxContext.get());
2327 return NULL;
2330 void OOXMLFastContextHandlerWrapper::newProperty
2331 (const Id & rId, OOXMLValue::Pointer_t pVal)
2333 if (mxContext.is())
2335 OOXMLFastContextHandler * pHandler = getFastContextHandler();
2336 if (pHandler != NULL)
2337 pHandler->newProperty(rId, pVal);
2341 void OOXMLFastContextHandlerWrapper::setPropertySet
2342 (OOXMLPropertySet::Pointer_t pPropertySet)
2344 if (mxContext.is())
2346 OOXMLFastContextHandler * pHandler = getFastContextHandler();
2347 if (pHandler != NULL)
2348 pHandler->setPropertySet(pPropertySet);
2351 mpPropertySet = pPropertySet;
2354 OOXMLPropertySet::Pointer_t OOXMLFastContextHandlerWrapper::getPropertySet()
2355 const
2357 OOXMLPropertySet::Pointer_t pResult(mpPropertySet);
2359 if (mxContext.is())
2361 OOXMLFastContextHandler * pHandler = getFastContextHandler();
2362 if (pHandler != NULL)
2363 pResult = pHandler->getPropertySet();
2366 return pResult;
2369 string OOXMLFastContextHandlerWrapper::getType() const
2371 string sResult = "Wrapper(";
2373 if (mxContext.is())
2375 OOXMLFastContextHandler * pHandler = getFastContextHandler();
2376 if (pHandler != NULL)
2377 sResult += pHandler->getType();
2380 sResult += ")";
2382 return sResult;
2385 void OOXMLFastContextHandlerWrapper::setId(Id rId)
2387 OOXMLFastContextHandler::setId(rId);
2389 if (mxContext.is())
2391 OOXMLFastContextHandler * pHandler = getFastContextHandler();
2392 if (pHandler != NULL)
2393 pHandler->setId(rId);
2397 Id OOXMLFastContextHandlerWrapper::getId() const
2399 Id nResult = OOXMLFastContextHandler::getId();
2401 if (mxContext.is())
2403 OOXMLFastContextHandler * pHandler = getFastContextHandler();
2404 if (pHandler != NULL && pHandler->getId() != 0)
2405 nResult = pHandler->getId();
2408 return nResult;
2411 void OOXMLFastContextHandlerWrapper::setToken(Token_t nToken)
2413 OOXMLFastContextHandler::setToken(nToken);
2415 if (mxContext.is())
2417 OOXMLFastContextHandler * pHandler = getFastContextHandler();
2418 if (pHandler != NULL)
2419 pHandler->setToken(nToken);
2423 Token_t OOXMLFastContextHandlerWrapper::getToken() const
2425 Token_t nResult = OOXMLFastContextHandler::getToken();
2427 if (mxContext.is())
2429 OOXMLFastContextHandler * pHandler = getFastContextHandler();
2430 if (pHandler != NULL)
2431 nResult = pHandler->getToken();
2434 return nResult;