LCOV - code coverage report
Current view: top level - writerfilter/source/ooxml - OOXMLPropertySetImpl.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 246 317 77.6 %
Date: 2015-06-13 12:38:46 Functions: 89 123 72.4 %
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 "OOXMLPropertySetImpl.hxx"
      21             : #include <stdio.h>
      22             : #include <iostream>
      23             : #include <ooxml/QNameToString.hxx>
      24             : #include <com/sun/star/drawing/XShape.hpp>
      25             : #include <oox/token/tokens.hxx>
      26             : 
      27             : namespace writerfilter {
      28             : namespace ooxml
      29             : {
      30             : using namespace ::std;
      31             : using namespace com::sun::star;
      32             : 
      33     3727024 : OOXMLProperty::~OOXMLProperty()
      34             : {
      35     3727024 : }
      36             : 
      37     2277601 : OOXMLPropertySet::~OOXMLPropertySet()
      38             : {
      39     2277601 : }
      40             : 
      41       12462 : OOXMLTable::~OOXMLTable()
      42             : {
      43       12462 : }
      44             : 
      45     3727024 : OOXMLPropertyImpl::OOXMLPropertyImpl(Id id, OOXMLValue::Pointer_t pValue,
      46             :                                      OOXMLPropertyImpl::Type_t eType)
      47     3727024 : : mId(id), mpValue(pValue), meType(eType)
      48             : {
      49     3727024 : }
      50             : 
      51           0 : OOXMLPropertyImpl::OOXMLPropertyImpl(const OOXMLPropertyImpl & rSprm)
      52           0 : : OOXMLProperty(), mId(rSprm.mId), mpValue(rSprm.mpValue), meType(rSprm.meType)
      53             : {
      54           0 : }
      55             : 
      56     7454048 : OOXMLPropertyImpl::~OOXMLPropertyImpl()
      57             : {
      58     7454048 : }
      59             : 
      60     6940433 : sal_uInt32 OOXMLPropertyImpl::getId() const
      61             : {
      62     6940433 :     return mId;
      63             : }
      64             : 
      65     4114307 : Value::Pointer_t OOXMLPropertyImpl::getValue()
      66             : {
      67     4114307 :     Value::Pointer_t pResult;
      68             : 
      69     4114307 :     if (mpValue.get() != nullptr)
      70     4113325 :         pResult = Value::Pointer_t(mpValue->clone());
      71             :     else
      72         982 :         pResult = Value::Pointer_t(new OOXMLValue());
      73             : 
      74     4114307 :     return pResult;
      75             : }
      76             : 
      77           0 : writerfilter::Reference<BinaryObj>::Pointer_t OOXMLPropertyImpl::getBinary()
      78             : {
      79           0 :     writerfilter::Reference<BinaryObj>::Pointer_t pResult;
      80             : 
      81           0 :     if (mpValue.get() != nullptr)
      82           0 :         pResult = mpValue->getBinary();
      83             : 
      84           0 :     return pResult;
      85             : }
      86             : 
      87           0 : writerfilter::Reference<Stream>::Pointer_t OOXMLPropertyImpl::getStream()
      88             : {
      89           0 :     writerfilter::Reference<Stream>::Pointer_t pResult;
      90             : 
      91           0 :     if (mpValue.get() != nullptr)
      92           0 :         pResult = mpValue->getStream();
      93             : 
      94           0 :     return pResult;
      95             : }
      96             : 
      97      920802 : writerfilter::Reference<Properties>::Pointer_t OOXMLPropertyImpl::getProps()
      98             : {
      99      920802 :     writerfilter::Reference<Properties>::Pointer_t pResult;
     100             : 
     101      920802 :     if (mpValue.get() != nullptr)
     102      918088 :         pResult = mpValue->getProperties();
     103             : 
     104      920802 :     return pResult;
     105             : }
     106             : 
     107             : #ifdef DEBUG_WRITERFILTER
     108             : string OOXMLPropertyImpl::getName() const
     109             : {
     110             :     string sResult;
     111             : 
     112             :     sResult = (*QNameToString::Instance())(mId);
     113             : 
     114             :     if (sResult.length() == 0)
     115             :         sResult = fastTokenToId(mId);
     116             : 
     117             :     if (sResult.length() == 0)
     118             :     {
     119             :         static char sBuffer[256];
     120             : 
     121             :         snprintf(sBuffer, sizeof(sBuffer), "%" SAL_PRIxUINT32, mId);
     122             :         sResult = sBuffer;
     123             :     }
     124             : 
     125             :     return sResult;
     126             : }
     127             : #endif
     128             : 
     129             : #ifdef DEBUG_WRITERFILTER
     130             : string OOXMLPropertyImpl::toString() const
     131             : {
     132             :     string sResult = "(";
     133             : 
     134             :     sResult += getName();
     135             :     sResult += ", ";
     136             :     if (mpValue.get() != nullptr)
     137             :         sResult += mpValue->toString();
     138             :     else
     139             :         sResult +="(null)";
     140             :     sResult +=")";
     141             : 
     142             :     return sResult;
     143             : }
     144             : #endif
     145             : 
     146           0 : Sprm * OOXMLPropertyImpl::clone()
     147             : {
     148           0 :     return new OOXMLPropertyImpl(*this);
     149             : }
     150             : 
     151     3486806 : void OOXMLPropertyImpl::resolve(writerfilter::Properties & rProperties)
     152             : {
     153     3486806 :     writerfilter::Properties * pProperties = nullptr;
     154     3486806 :     pProperties = &rProperties;
     155             : 
     156     3486806 :     switch (meType)
     157             :     {
     158             :     case SPRM:
     159     1498793 :         if (mId != 0x0)
     160     1498793 :             pProperties->sprm(*this);
     161     1498793 :         break;
     162             :     case ATTRIBUTE:
     163     1988013 :         pProperties->attribute(mId, *getValue());
     164     1988013 :         break;
     165             :     }
     166     3486806 : }
     167             : 
     168             : /*
     169             :    class OOXMLValue
     170             : */
     171             : 
     172     3528835 : OOXMLValue::OOXMLValue()
     173             : {
     174     3528835 : }
     175             : 
     176     7698679 : OOXMLValue::~OOXMLValue()
     177             : {
     178     7698679 : }
     179             : 
     180           0 : bool OOXMLValue::getBool() const
     181             : {
     182           0 :     return false;
     183             : }
     184             : 
     185     1696304 : int OOXMLValue::getInt() const
     186             : {
     187     1696304 :     return 0;
     188             : }
     189             : 
     190     1070046 : OUString OOXMLValue::getString() const
     191             : {
     192     1070046 :     return OUString();
     193             : }
     194             : 
     195           0 : uno::Any OOXMLValue::getAny() const
     196             : {
     197           0 :     return uno::Any();
     198             : }
     199             : 
     200       64455 : writerfilter::Reference<Properties>::Pointer_t OOXMLValue::getProperties()
     201             : {
     202       64455 :     return writerfilter::Reference<Properties>::Pointer_t();
     203             : }
     204             : 
     205           0 : writerfilter::Reference<Stream>::Pointer_t OOXMLValue::getStream()
     206             : {
     207           0 :     return writerfilter::Reference<Stream>::Pointer_t();
     208             : }
     209             : 
     210           0 : writerfilter::Reference<BinaryObj>::Pointer_t OOXMLValue::getBinary()
     211             : {
     212           0 :     return writerfilter::Reference<BinaryObj>::Pointer_t();
     213             : }
     214             : 
     215             : #ifdef DEBUG_WRITERFILTER
     216             : string OOXMLValue::toString() const
     217             : {
     218             :     return "OOXMLValue";
     219             : }
     220             : #endif
     221             : 
     222           0 : OOXMLValue * OOXMLValue::clone() const
     223             : {
     224           0 :     return new OOXMLValue(*this);
     225             : }
     226             : 
     227             : /*
     228             :   class OOXMLBinaryValue
     229             :  */
     230             : 
     231           0 : OOXMLBinaryValue::OOXMLBinaryValue(OOXMLBinaryObjectReference::Pointer_t
     232             :                                    pBinaryObj)
     233           0 : : mpBinaryObj(pBinaryObj)
     234             : {
     235           0 : }
     236             : 
     237           0 : OOXMLBinaryValue::~OOXMLBinaryValue()
     238             : {
     239           0 : }
     240             : 
     241           0 : writerfilter::Reference<BinaryObj>::Pointer_t OOXMLBinaryValue::getBinary()
     242             : {
     243           0 :     return mpBinaryObj;
     244             : }
     245             : 
     246             : #ifdef DEBUG_WRITERFILTER
     247             : string OOXMLBinaryValue::toString() const
     248             : {
     249             :     return "BinaryObj";
     250             : }
     251             : #endif
     252             : 
     253           0 : OOXMLValue * OOXMLBinaryValue::clone() const
     254             : {
     255           0 :     return new OOXMLBinaryValue(mpBinaryObj);
     256             : }
     257             : 
     258             : /*
     259             :   class OOXMLBooleanValue
     260             : */
     261             : 
     262       77500 : static bool GetBooleanValue(const char *pValue)
     263             : {
     264       77500 :     return !strcmp(pValue, "true")
     265       76650 :            || !strcmp(pValue, "True")
     266       76650 :            || !strcmp(pValue, "1")
     267       34347 :            || !strcmp(pValue, "on")
     268      111831 :            || !strcmp(pValue, "On");
     269             : }
     270             : 
     271      199600 : OOXMLValue::Pointer_t OOXMLBooleanValue::Create(bool bValue)
     272             : {
     273      199600 :     static OOXMLValue::Pointer_t False(new OOXMLBooleanValue (false));
     274      199600 :     static OOXMLValue::Pointer_t True(new OOXMLBooleanValue (true));
     275             : 
     276      199600 :     return bValue ? True : False;
     277             : }
     278             : 
     279       77500 : OOXMLValue::Pointer_t OOXMLBooleanValue::Create(const char *pValue)
     280             : {
     281       77500 :     return Create (GetBooleanValue(pValue));
     282             : }
     283             : 
     284          38 : OOXMLBooleanValue::OOXMLBooleanValue(bool bValue)
     285          38 : : mbValue(bValue)
     286             : {
     287          38 : }
     288             : 
     289      668200 : OOXMLBooleanValue::~OOXMLBooleanValue()
     290             : {
     291      668200 : }
     292             : 
     293           0 : bool OOXMLBooleanValue::getBool() const
     294             : {
     295           0 :     return mbValue;
     296             : }
     297             : 
     298      325414 : int OOXMLBooleanValue::getInt() const
     299             : {
     300      325414 :     return mbValue ? 1 : 0;
     301             : }
     302             : 
     303           0 : uno::Any OOXMLBooleanValue::getAny() const
     304             : {
     305           0 :     uno::Any aResult(mbValue);
     306             : 
     307           0 :     return aResult;
     308             : }
     309             : 
     310             : #ifdef DEBUG_WRITERFILTER
     311             : string OOXMLBooleanValue::toString() const
     312             : {
     313             :     return mbValue ? "true" : "false";
     314             : }
     315             : #endif
     316             : 
     317      334062 : OOXMLValue * OOXMLBooleanValue::clone() const
     318             : {
     319      334062 :     return new OOXMLBooleanValue(*this);
     320             : }
     321             : 
     322             : /*
     323             :   class OOXMLStringValue
     324             : */
     325             : 
     326     1560766 : OOXMLStringValue::OOXMLStringValue(const OUString & rStr)
     327     1560766 : : mStr(rStr)
     328             : {
     329     1560766 : }
     330             : 
     331     6115258 : OOXMLStringValue::~OOXMLStringValue()
     332             : {
     333     6115258 : }
     334             : 
     335           0 : uno::Any OOXMLStringValue::getAny() const
     336             : {
     337           0 :     uno::Any aAny(mStr);
     338             : 
     339           0 :     return aAny;
     340             : }
     341             : 
     342     1376579 : OUString OOXMLStringValue::getString() const
     343             : {
     344     1376579 :     return mStr;
     345             : }
     346             : 
     347             : #ifdef DEBUG_WRITERFILTER
     348             : string OOXMLStringValue::toString() const
     349             : {
     350             :     return OUStringToOString(mStr, RTL_TEXTENCODING_ASCII_US).getStr();
     351             : }
     352             : #endif
     353             : 
     354     1496863 : OOXMLValue * OOXMLStringValue::clone() const
     355             : {
     356     1496863 :     return new OOXMLStringValue(*this);
     357             : }
     358             : 
     359             : /*
     360             :   class OOXMLInputStreamValue
     361             :  */
     362         162 : OOXMLInputStreamValue::OOXMLInputStreamValue(uno::Reference<io::XInputStream> xInputStream)
     363         162 : : mxInputStream(xInputStream)
     364             : {
     365         162 : }
     366             : 
     367         324 : OOXMLInputStreamValue::~OOXMLInputStreamValue()
     368             : {
     369         324 : }
     370             : 
     371          54 : uno::Any OOXMLInputStreamValue::getAny() const
     372             : {
     373          54 :     uno::Any aAny(mxInputStream);
     374             : 
     375          54 :     return aAny;
     376             : }
     377             : 
     378             : #ifdef DEBUG_WRITERFILTER
     379             : string OOXMLInputStreamValue::toString() const
     380             : {
     381             :     return "InputStream";
     382             : }
     383             : #endif
     384             : 
     385         108 : OOXMLValue * OOXMLInputStreamValue::clone() const
     386             : {
     387         108 :     return new OOXMLInputStreamValue(mxInputStream);
     388             : }
     389             : 
     390             : /*
     391             :   struct OOXMLPropertySetImplCompare
     392             :  */
     393             : 
     394           0 : bool OOXMLPropertySetImplCompare::operator()(const OOXMLProperty::Pointer_t& x,
     395             :                                              const OOXMLProperty::Pointer_t& y) const
     396             : {
     397           0 :     bool bResult = false;
     398             : 
     399           0 :     if (x.get() == nullptr && y.get() != nullptr)
     400           0 :         bResult = true;
     401           0 :     else if (x.get() != nullptr && y.get() != nullptr)
     402           0 :         bResult = x->getId() < y->getId();
     403             : 
     404           0 :     return bResult;
     405             : }
     406             : 
     407             : /**
     408             :    class OOXMLPropertySetImpl
     409             : */
     410             : 
     411     1331674 : OOXMLPropertySetImpl::OOXMLPropertySetImpl()
     412             : {
     413     1331674 :     static OString aName("OOXMLPropertySetImpl");
     414     1331674 :     maType = aName;
     415     1331674 : }
     416             : 
     417     4555202 : OOXMLPropertySetImpl::~OOXMLPropertySetImpl()
     418             : {
     419     4555202 : }
     420             : 
     421     1103431 : void OOXMLPropertySetImpl::resolve(Properties & rHandler)
     422             : {
     423             :     // The pProp->resolve(rHandler) call below can cause elements to
     424             :     // be appended to mProperties. I don't think it can cause elements
     425             :     // to be deleted. But let's check with < here just to be safe that
     426             :     // the indexing below works.
     427     4622672 :     for (size_t nIt = 0; nIt < mProperties.size(); ++nIt)
     428             :     {
     429     3519241 :         OOXMLProperty::Pointer_t pProp = mProperties[nIt];
     430             : 
     431     3519241 :         if (pProp.get() != nullptr)
     432     3486806 :             pProp->resolve(rHandler);
     433     3519241 :     }
     434     1103431 : }
     435             : 
     436           0 : OOXMLPropertySetImpl::OOXMLProperties_t::iterator OOXMLPropertySetImpl::begin()
     437             : {
     438           0 :     return mProperties.begin();
     439             : }
     440             : 
     441           0 : OOXMLPropertySetImpl::OOXMLProperties_t::iterator OOXMLPropertySetImpl::end()
     442             : {
     443           0 :     return mProperties.end();
     444             : }
     445             : 
     446             : OOXMLPropertySetImpl::OOXMLProperties_t::const_iterator
     447           0 : OOXMLPropertySetImpl::begin() const
     448             : {
     449           0 :     return mProperties.begin();
     450             : }
     451             : 
     452             : OOXMLPropertySetImpl::OOXMLProperties_t::const_iterator
     453           0 : OOXMLPropertySetImpl::end() const
     454             : {
     455           0 :     return mProperties.end();
     456             : }
     457             : 
     458     3752588 : void OOXMLPropertySetImpl::add(OOXMLProperty::Pointer_t pProperty)
     459             : {
     460     3752588 :     if (pProperty.get() != nullptr && pProperty->getId() != 0x0)
     461             :     {
     462     3676495 :         mProperties.push_back(pProperty);
     463             :     }
     464     3752588 : }
     465             : 
     466       10993 : void OOXMLPropertySetImpl::add(OOXMLPropertySet::Pointer_t pPropertySet)
     467             : {
     468       10993 :     if (pPropertySet.get() != nullptr)
     469             :     {
     470             :         OOXMLPropertySetImpl * pSet =
     471       10993 :             dynamic_cast<OOXMLPropertySetImpl *>(pPropertySet.get());
     472             : 
     473       10993 :         if (pSet != nullptr)
     474             :         {
     475       10993 :             mProperties.resize(mProperties.size() + pSet->mProperties.size());
     476      109671 :             for (OOXMLProperties_t::iterator aIt = pSet->mProperties.begin();
     477       73114 :                  aIt != pSet->mProperties.end(); ++aIt)
     478       25564 :                 add(*aIt);
     479             :         }
     480             :     }
     481       10993 : }
     482             : 
     483      945927 : OOXMLPropertySet * OOXMLPropertySetImpl::clone() const
     484             : {
     485      945927 :     return new OOXMLPropertySetImpl(*this);
     486             : }
     487             : 
     488           0 : void OOXMLPropertySetImpl::setType(const string & rsType)
     489             : {
     490           0 :     maType = OString(rsType.c_str(), rsType.size());
     491           0 : }
     492             : 
     493             : #ifdef DEBUG_WRITERFILTER
     494             : string OOXMLPropertySetImpl::toString()
     495             : {
     496             :     string sResult = "[";
     497             :     char sBuffer[256];
     498             :     snprintf(sBuffer, sizeof(sBuffer), "%p", this);
     499             :     sResult += sBuffer;
     500             :     sResult += ":";
     501             : 
     502             :     OOXMLProperties_t::iterator aItBegin = begin();
     503             :     OOXMLProperties_t::iterator aItEnd = end();
     504             : 
     505             :     for (OOXMLProperties_t::iterator aIt = aItBegin; aIt != aItEnd; ++aIt)
     506             :     {
     507             :         if (aIt != aItBegin)
     508             :             sResult += ", ";
     509             : 
     510             :         if ((*aIt).get() != nullptr)
     511             :             sResult += (*aIt)->toString();
     512             :         else
     513             :             sResult += "0x0";
     514             :     }
     515             : 
     516             :     sResult += "]";
     517             : 
     518             :     return sResult;
     519             : }
     520             : #endif
     521             : 
     522             : /*
     523             :   class OOXMLPropertySetValue
     524             : */
     525             : 
     526     1037803 : OOXMLPropertySetValue::OOXMLPropertySetValue
     527             : (OOXMLPropertySet::Pointer_t pPropertySet)
     528     1037803 : : mpPropertySet(pPropertySet)
     529             : {
     530     1037803 : }
     531             : 
     532     4567588 : OOXMLPropertySetValue::~OOXMLPropertySetValue()
     533             : {
     534     4567588 : }
     535             : 
     536      944120 : writerfilter::Reference<Properties>::Pointer_t OOXMLPropertySetValue::getProperties()
     537             : {
     538             :     return writerfilter::Reference<Properties>::Pointer_t
     539      944120 :         (mpPropertySet->clone());
     540             : }
     541             : 
     542             : #ifdef DEBUG_WRITERFILTER
     543             : string OOXMLPropertySetValue::toString() const
     544             : {
     545             :     char sBuffer[256];
     546             : 
     547             :     snprintf(sBuffer, sizeof(sBuffer), "t:%p, m:%p", this, mpPropertySet.get());
     548             : 
     549             :     return "OOXMLPropertySetValue(" + string(sBuffer) + ")";
     550             : }
     551             : #endif
     552             : 
     553     1245991 : OOXMLValue * OOXMLPropertySetValue::clone() const
     554             : {
     555     1245991 :     return new OOXMLPropertySetValue(*this);
     556             : }
     557             : 
     558             : /*
     559             :   class OOXMLIntegerValue
     560             : */
     561             : 
     562      660123 : OOXMLValue::Pointer_t OOXMLIntegerValue::Create(sal_Int32 nValue)
     563             : {
     564      660123 :     static OOXMLValue::Pointer_t Zero(new OOXMLIntegerValue (0));
     565      660123 :     static OOXMLValue::Pointer_t One(new OOXMLIntegerValue (1));
     566      660123 :     static OOXMLValue::Pointer_t Two(new OOXMLIntegerValue (2));
     567      660123 :     static OOXMLValue::Pointer_t Three(new OOXMLIntegerValue (3));
     568      660123 :     static OOXMLValue::Pointer_t Four(new OOXMLIntegerValue (4));
     569      660123 :     static OOXMLValue::Pointer_t Five(new OOXMLIntegerValue (5));
     570      660123 :     static OOXMLValue::Pointer_t Six(new OOXMLIntegerValue (6));
     571      660123 :     static OOXMLValue::Pointer_t Seven(new OOXMLIntegerValue (7));
     572      660123 :     static OOXMLValue::Pointer_t Eight(new OOXMLIntegerValue (8));
     573      660123 :     static OOXMLValue::Pointer_t Nine(new OOXMLIntegerValue (9));
     574             : 
     575      660123 :     switch (nValue) {
     576       49677 :     case 0: return Zero;
     577       81740 :     case 1: return One;
     578        5676 :     case 2: return Two;
     579        1075 :     case 3: return Three;
     580       11222 :     case 4: return Four;
     581         681 :     case 5: return Five;
     582        3038 :     case 6: return Six;
     583         528 :     case 7: return Seven;
     584        2186 :     case 8: return Eight;
     585        1984 :     case 9: return Nine;
     586      502316 :     default: break;
     587             :     }
     588             : 
     589      502316 :     OOXMLValue::Pointer_t value(new OOXMLIntegerValue(nValue));
     590             : 
     591      502316 :     return value;
     592             : }
     593             : 
     594      502506 : OOXMLIntegerValue::OOXMLIntegerValue(sal_Int32 nValue)
     595      502506 : : mnValue(nValue)
     596             : {
     597      502506 : }
     598             : 
     599     2620936 : OOXMLIntegerValue::~OOXMLIntegerValue()
     600             : {
     601     2620936 : }
     602             : 
     603      788620 : int OOXMLIntegerValue::getInt() const
     604             : {
     605      788620 :     return mnValue;
     606             : }
     607             : 
     608           0 : uno::Any OOXMLIntegerValue::getAny() const
     609             : {
     610           0 :     uno::Any aResult(mnValue);
     611             : 
     612           0 :     return aResult;
     613             : }
     614             : 
     615      807962 : OOXMLValue * OOXMLIntegerValue::clone() const
     616             : {
     617      807962 :     return new OOXMLIntegerValue(*this);
     618             : }
     619             : 
     620             : #ifdef DEBUG_WRITERFILTER
     621             : string OOXMLIntegerValue::toString() const
     622             : {
     623             :     char buffer[256];
     624             :     snprintf(buffer, sizeof(buffer), "%" SAL_PRIdINT32, mnValue);
     625             : 
     626             :     return buffer;
     627             : }
     628             : #endif
     629             : 
     630             : /*
     631             :   class OOXMLHexValue
     632             : */
     633             : 
     634           0 : OOXMLHexValue::OOXMLHexValue(sal_uInt32 nValue)
     635           0 : : mnValue(nValue)
     636             : {
     637           0 : }
     638             : 
     639      266454 : OOXMLHexValue::OOXMLHexValue(const char * pValue)
     640             : {
     641      266454 :     mnValue = rtl_str_toUInt32(pValue, 16);
     642      266454 : }
     643             : 
     644      754788 : OOXMLHexValue::~OOXMLHexValue()
     645             : {
     646      754788 : }
     647             : 
     648      112533 : int OOXMLHexValue::getInt() const
     649             : {
     650      112533 :     return mnValue;
     651             : }
     652             : 
     653      110940 : OOXMLValue * OOXMLHexValue::clone() const
     654             : {
     655      110940 :     return new OOXMLHexValue(*this);
     656             : }
     657             : 
     658             : #ifdef DEBUG_WRITERFILTER
     659             : string OOXMLHexValue::toString() const
     660             : {
     661             :     char buffer[256];
     662             :     snprintf(buffer, sizeof(buffer), "0x%" SAL_PRIxUINT32, mnValue);
     663             : 
     664             :     return buffer;
     665             : }
     666             : #endif
     667             : 
     668             : // OOXMLUniversalMeasureValue
     669             : 
     670      155074 : OOXMLUniversalMeasureValue::OOXMLUniversalMeasureValue(const char * pValue)
     671             : {
     672      155074 :     mnValue = rtl_str_toUInt32(pValue, 10); // will ignore the trailing 'pt'
     673             : 
     674      155074 :     int nLen = strlen(pValue);
     675      285954 :     if (nLen > 2 &&
     676      130929 :         pValue[nLen-2] == 'p' &&
     677          49 :         pValue[nLen-1] == 't')
     678             :     {
     679          49 :         mnValue = mnValue * 20;
     680             :     }
     681      155074 : }
     682             : 
     683      656236 : OOXMLUniversalMeasureValue::~OOXMLUniversalMeasureValue()
     684             : {
     685      656236 : }
     686             : 
     687      173041 : int OOXMLUniversalMeasureValue::getInt() const
     688             : {
     689      173041 :     return mnValue;
     690             : }
     691             : 
     692      173044 : OOXMLValue* OOXMLUniversalMeasureValue::clone() const
     693             : {
     694      173044 :     return new OOXMLUniversalMeasureValue(*this);
     695             : }
     696             : 
     697             : #ifdef DEBUG_WRITERFILTER
     698             : string OOXMLUniversalMeasureValue::toString() const
     699             : {
     700             :     return OString::number(mnValue).getStr();
     701             : }
     702             : #endif
     703             : 
     704             : /*
     705             :   class OOXMLShapeValue
     706             :  */
     707             : 
     708             : 
     709        4662 : OOXMLShapeValue::OOXMLShapeValue(uno::Reference<drawing::XShape> rShape)
     710        4662 : : mrShape(rShape)
     711             : {
     712        4662 : }
     713             : 
     714        9324 : OOXMLShapeValue::~OOXMLShapeValue()
     715             : {
     716        9324 : }
     717             : 
     718        1629 : uno::Any OOXMLShapeValue::getAny() const
     719             : {
     720        1629 :     return uno::Any(mrShape);
     721             : }
     722             : 
     723             : #ifdef DEBUG_WRITERFILTER
     724             : string OOXMLShapeValue::toString() const
     725             : {
     726             :     return "Shape";
     727             : }
     728             : #endif
     729             : 
     730        2965 : OOXMLValue * OOXMLShapeValue::clone() const
     731             : {
     732        2965 :     return new OOXMLShapeValue(mrShape);
     733             : }
     734             : 
     735             : /*
     736             :   class OOXMLStarMathValue
     737             :  */
     738             : 
     739             : 
     740         388 : OOXMLStarMathValue::OOXMLStarMathValue( uno::Reference< embed::XEmbeddedObject > c )
     741         388 : : component(c)
     742             : {
     743         388 : }
     744             : 
     745         776 : OOXMLStarMathValue::~OOXMLStarMathValue()
     746             : {
     747         776 : }
     748             : 
     749         388 : uno::Any OOXMLStarMathValue::getAny() const
     750             : {
     751         388 :     return uno::Any(component);
     752             : }
     753             : 
     754             : #ifdef DEBUG_WRITERFILTER
     755             : string OOXMLStarMathValue::toString() const
     756             : {
     757             :     return "StarMath";
     758             : }
     759             : #endif
     760             : 
     761         194 : OOXMLValue * OOXMLStarMathValue::clone() const
     762             : {
     763         194 :     return new OOXMLStarMathValue( component );
     764             : }
     765             : 
     766             : /*
     767             :   class OOXMLTableImpl
     768             :  */
     769             : 
     770        6231 : OOXMLTableImpl::OOXMLTableImpl()
     771             : {
     772        6231 : }
     773             : 
     774       18693 : OOXMLTableImpl::~OOXMLTableImpl()
     775             : {
     776       18693 : }
     777             : 
     778        6231 : void OOXMLTableImpl::resolve(Table & rTable)
     779             : {
     780        6231 :     Table * pTable = &rTable;
     781             : 
     782        6231 :     int nPos = 0;
     783             : 
     784        6231 :     PropertySets_t::iterator it = mPropertySets.begin();
     785        6231 :     PropertySets_t::iterator itEnd = mPropertySets.end();
     786             : 
     787       73073 :     while (it != itEnd)
     788             :     {
     789             :         writerfilter::Reference<Properties>::Pointer_t pProperties
     790       60611 :             ((*it)->getProperties());
     791             : 
     792       60611 :         if (pProperties.get() != nullptr)
     793       60611 :             pTable->entry(nPos, pProperties);
     794             : 
     795       60611 :         ++nPos;
     796       60611 :         ++it;
     797       60611 :     }
     798        6231 : }
     799             : 
     800       60611 : void OOXMLTableImpl::add(ValuePointer_t pPropertySet)
     801             : {
     802       60611 :     if (pPropertySet.get() != nullptr)
     803       60611 :         mPropertySets.push_back(pPropertySet);
     804       60611 : }
     805             : 
     806        6231 : OOXMLTable * OOXMLTableImpl::clone() const
     807             : {
     808        6231 :     return new OOXMLTableImpl(*this);
     809             : }
     810             : 
     811             : /*
     812             :   class: OOXMLPropertySetEntryToString
     813             : */
     814             : 
     815          39 : OOXMLPropertySetEntryToString::OOXMLPropertySetEntryToString(Id nId)
     816          39 : : mnId(nId)
     817             : {
     818          39 : }
     819             : 
     820          39 : OOXMLPropertySetEntryToString::~OOXMLPropertySetEntryToString()
     821             : {
     822          39 : }
     823             : 
     824           0 : void OOXMLPropertySetEntryToString::sprm(Sprm & /*rSprm*/)
     825             : {
     826           0 : }
     827             : 
     828          39 : void OOXMLPropertySetEntryToString::attribute(Id nId, Value & rValue)
     829             : {
     830          39 :     if (nId == mnId)
     831          39 :         mStr = rValue.getString();
     832          39 : }
     833             : 
     834             : /*
     835             :   class: OOXMLPropertySetEntryToInteger
     836             : */
     837             : 
     838       10443 : OOXMLPropertySetEntryToInteger::OOXMLPropertySetEntryToInteger(Id nId)
     839       10443 : : mnId(nId), mnValue(0)
     840             : {
     841       10443 : }
     842             : 
     843       10443 : OOXMLPropertySetEntryToInteger::~OOXMLPropertySetEntryToInteger()
     844             : {
     845       10443 : }
     846             : 
     847           0 : void OOXMLPropertySetEntryToInteger::sprm(Sprm & /*rSprm*/)
     848             : {
     849           0 : }
     850             : 
     851       10479 : void OOXMLPropertySetEntryToInteger::attribute(Id nId, Value & rValue)
     852             : {
     853       10479 :     if (nId == mnId)
     854       10443 :         mnValue = rValue.getInt();
     855       10479 : }
     856             : 
     857             : /*
     858             :   class: OOXMLPropertySetEntryToBool
     859             : */
     860             : 
     861        3481 : OOXMLPropertySetEntryToBool::OOXMLPropertySetEntryToBool(Id nId)
     862        3481 :     : mnId(nId), mValue(false)
     863        3481 : {}
     864             : 
     865        3481 : OOXMLPropertySetEntryToBool::~OOXMLPropertySetEntryToBool() {}
     866             : 
     867           0 : void OOXMLPropertySetEntryToBool::sprm(Sprm & /*rSprm*/) {}
     868             : 
     869        3493 : void OOXMLPropertySetEntryToBool::attribute(Id nId, Value & rValue)
     870             : {
     871        3493 :     if (nId == mnId)
     872          12 :         mValue = (rValue.getInt() != 0);
     873        3493 : }
     874             : 
     875          72 : }}
     876             : 
     877             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11