LCOV - code coverage report
Current view: top level - writerfilter/source/ooxml - OOXMLFastContextHandler.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 975 0.0 %
Date: 2014-04-14 Functions: 0 215 0.0 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.10