LCOV - code coverage report
Current view: top level - writerfilter/source/ooxml - OOXMLPropertySetImpl.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 238 308 77.3 %
Date: 2014-11-03 Functions: 86 118 72.9 %
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 <resourcemodel/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     6987566 : OOXMLProperty::~OOXMLProperty()
      34             : {
      35     6987566 : }
      36             : 
      37     4240472 : OOXMLPropertySet::~OOXMLPropertySet()
      38             : {
      39     4240472 : }
      40             : 
      41       22888 : OOXMLTable::~OOXMLTable()
      42             : {
      43       22888 : }
      44             : 
      45     6987566 : OOXMLPropertyImpl::OOXMLPropertyImpl(Id id, OOXMLValue::Pointer_t pValue,
      46             :                                      OOXMLPropertyImpl::Type_t eType)
      47     6987566 : : mId(id), mpValue(pValue), meType(eType)
      48             : {
      49     6987566 : }
      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    13975132 : OOXMLPropertyImpl::~OOXMLPropertyImpl()
      57             : {
      58    13975132 : }
      59             : 
      60    12943368 : sal_uInt32 OOXMLPropertyImpl::getId() const
      61             : {
      62    12943368 :     return mId;
      63             : }
      64             : 
      65     7676968 : Value::Pointer_t OOXMLPropertyImpl::getValue()
      66             : {
      67     7676968 :     Value::Pointer_t pResult;
      68             : 
      69     7676968 :     if (mpValue.get() != nullptr)
      70     7675046 :         pResult = Value::Pointer_t(mpValue->clone());
      71             :     else
      72        1922 :         pResult = Value::Pointer_t(new OOXMLValue());
      73             : 
      74     7676968 :     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     1724016 : writerfilter::Reference<Properties>::Pointer_t OOXMLPropertyImpl::getProps()
      98             : {
      99     1724016 :     writerfilter::Reference<Properties>::Pointer_t pResult;
     100             : 
     101     1724016 :     if (mpValue.get() != nullptr)
     102     1718854 :         pResult = mpValue->getProperties();
     103             : 
     104     1724016 :     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     6525140 : void OOXMLPropertyImpl::resolve(writerfilter::Properties & rProperties)
     152             : {
     153     6525140 :     writerfilter::Properties * pProperties = nullptr;
     154     6525140 :     pProperties = &rProperties;
     155             : 
     156     6525140 :     switch (meType)
     157             :     {
     158             :     case SPRM:
     159     2806240 :         if (mId != 0x0)
     160     2806240 :             pProperties->sprm(*this);
     161     2806240 :         break;
     162             :     case ATTRIBUTE:
     163     3718900 :         pProperties->attribute(mId, *getValue());
     164     3718900 :         break;
     165             :     }
     166     6525140 : }
     167             : 
     168             : /*
     169             :    class OOXMLValue
     170             : */
     171             : 
     172     6625054 : OOXMLValue::OOXMLValue()
     173             : {
     174     6625054 : }
     175             : 
     176    14404908 : OOXMLValue::~OOXMLValue()
     177             : {
     178    14404908 : }
     179             : 
     180           0 : bool OOXMLValue::getBool() const
     181             : {
     182           0 :     return false;
     183             : }
     184             : 
     185     3149982 : int OOXMLValue::getInt() const
     186             : {
     187     3149982 :     return 0;
     188             : }
     189             : 
     190     2005582 : OUString OOXMLValue::getString() const
     191             : {
     192     2005582 :     return OUString();
     193             : }
     194             : 
     195           0 : uno::Any OOXMLValue::getAny() const
     196             : {
     197           0 :     return uno::Any();
     198             : }
     199             : 
     200      122228 : writerfilter::Reference<Properties>::Pointer_t OOXMLValue::getProperties()
     201             : {
     202      122228 :     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      146294 : static bool GetBooleanValue(const char *pValue)
     263             : {
     264      146294 :     return !strcmp(pValue, "true")
     265      144056 :            || !strcmp(pValue, "True")
     266      144056 :            || !strcmp(pValue, "1")
     267       61708 :            || !strcmp(pValue, "on")
     268      207970 :            || !strcmp(pValue, "On");
     269             : }
     270             : 
     271      379588 : OOXMLValue::Pointer_t OOXMLBooleanValue::Create(bool bValue)
     272             : {
     273      379588 :     static OOXMLValue::Pointer_t False(new OOXMLBooleanValue (false));
     274      379588 :     static OOXMLValue::Pointer_t True(new OOXMLBooleanValue (true));
     275             : 
     276      379588 :     return bValue ? True : False;
     277             : }
     278             : 
     279      146294 : OOXMLValue::Pointer_t OOXMLBooleanValue::Create(const char *pValue)
     280             : {
     281      146294 :     return Create (GetBooleanValue(pValue));
     282             : }
     283             : 
     284          60 : OOXMLBooleanValue::OOXMLBooleanValue(bool bValue)
     285          60 : : mbValue(bValue)
     286             : {
     287          60 : }
     288             : 
     289     1272200 : OOXMLBooleanValue::~OOXMLBooleanValue()
     290             : {
     291     1272200 : }
     292             : 
     293           0 : bool OOXMLBooleanValue::getBool() const
     294             : {
     295           0 :     return mbValue;
     296             : }
     297             : 
     298      619480 : int OOXMLBooleanValue::getInt() const
     299             : {
     300      619480 :     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      636040 : OOXMLValue * OOXMLBooleanValue::clone() const
     318             : {
     319      636040 :     return new OOXMLBooleanValue(*this);
     320             : }
     321             : 
     322             : /*
     323             :   class OOXMLStringValue
     324             : */
     325             : 
     326     2929490 : OOXMLStringValue::OOXMLStringValue(const OUString & rStr)
     327     2929490 : : mStr(rStr)
     328             : {
     329     2929490 : }
     330             : 
     331    11450952 : OOXMLStringValue::~OOXMLStringValue()
     332             : {
     333    11450952 : }
     334             : 
     335           0 : uno::Any OOXMLStringValue::getAny() const
     336             : {
     337           0 :     uno::Any aAny(mStr);
     338             : 
     339           0 :     return aAny;
     340             : }
     341             : 
     342     2571016 : OUString OOXMLStringValue::getString() const
     343             : {
     344     2571016 :     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     2795986 : OOXMLValue * OOXMLStringValue::clone() const
     355             : {
     356     2795986 :     return new OOXMLStringValue(*this);
     357             : }
     358             : 
     359             : /*
     360             :   class OOXMLInputStreamValue
     361             :  */
     362         312 : OOXMLInputStreamValue::OOXMLInputStreamValue(uno::Reference<io::XInputStream> xInputStream)
     363         312 : : mxInputStream(xInputStream)
     364             : {
     365         312 : }
     366             : 
     367         624 : OOXMLInputStreamValue::~OOXMLInputStreamValue()
     368             : {
     369         624 : }
     370             : 
     371         104 : uno::Any OOXMLInputStreamValue::getAny() const
     372             : {
     373         104 :     uno::Any aAny(mxInputStream);
     374             : 
     375         104 :     return aAny;
     376             : }
     377             : 
     378             : #ifdef DEBUG_WRITERFILTER
     379             : string OOXMLInputStreamValue::toString() const
     380             : {
     381             :     return "InputStream";
     382             : }
     383             : #endif
     384             : 
     385         208 : OOXMLValue * OOXMLInputStreamValue::clone() const
     386             : {
     387         208 :     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     2472298 : OOXMLPropertySetImpl::OOXMLPropertySetImpl()
     412             : {
     413     2472298 :     static OString aName("OOXMLPropertySetImpl");
     414     2472298 :     maType = aName;
     415     2472298 : }
     416             : 
     417     8480944 : OOXMLPropertySetImpl::~OOXMLPropertySetImpl()
     418             : {
     419     8480944 : }
     420             : 
     421     2047454 : 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     8630818 :     for (size_t nIt = 0; nIt < mProperties.size(); ++nIt)
     428             :     {
     429     6583364 :         OOXMLProperty::Pointer_t pProp = mProperties[nIt];
     430             : 
     431     6583364 :         if (pProp.get() != nullptr)
     432     6525140 :             pProp->resolve(rHandler);
     433     6583364 :     }
     434     2047454 : }
     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     7033156 : void OOXMLPropertySetImpl::add(OOXMLProperty::Pointer_t pProperty)
     459             : {
     460     7033156 :     if (pProperty.get() != nullptr && pProperty->getId() != 0x0)
     461             :     {
     462     6890454 :         mProperties.push_back(pProperty);
     463             :     }
     464     7033156 : }
     465             : 
     466       19900 : void OOXMLPropertySetImpl::add(OOXMLPropertySet::Pointer_t pPropertySet)
     467             : {
     468       19900 :     if (pPropertySet.get() != nullptr)
     469             :     {
     470             :         OOXMLPropertySetImpl * pSet =
     471       19900 :             dynamic_cast<OOXMLPropertySetImpl *>(pPropertySet.get());
     472             : 
     473       19900 :         if (pSet != nullptr)
     474             :         {
     475       19900 :             mProperties.resize(mProperties.size() + pSet->mProperties.size());
     476      196470 :             for (OOXMLProperties_t::iterator aIt = pSet->mProperties.begin();
     477      130980 :                  aIt != pSet->mProperties.end(); ++aIt)
     478       45590 :                 add(*aIt);
     479             :         }
     480             :     }
     481       19900 : }
     482             : 
     483     1768174 : OOXMLPropertySet * OOXMLPropertySetImpl::clone() const
     484             : {
     485     1768174 :     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     1941794 : OOXMLPropertySetValue::OOXMLPropertySetValue
     527             : (OOXMLPropertySet::Pointer_t pPropertySet)
     528     1941794 : : mpPropertySet(pPropertySet)
     529             : {
     530     1941794 : }
     531             : 
     532     8518708 : OOXMLPropertySetValue::~OOXMLPropertySetValue()
     533             : {
     534     8518708 : }
     535             : 
     536     1764910 : writerfilter::Reference<Properties>::Pointer_t OOXMLPropertySetValue::getProperties()
     537             : {
     538             :     return writerfilter::Reference<Properties>::Pointer_t
     539     1764910 :         (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     2317560 : OOXMLValue * OOXMLPropertySetValue::clone() const
     554             : {
     555     2317560 :     return new OOXMLPropertySetValue(*this);
     556             : }
     557             : 
     558             : /*
     559             :   class OOXMLIntegerValue
     560             : */
     561             : 
     562     1228236 : OOXMLValue::Pointer_t OOXMLIntegerValue::Create(sal_Int32 nValue)
     563             : {
     564     1228236 :     static OOXMLValue::Pointer_t Zero(new OOXMLIntegerValue (0));
     565     1228236 :     static OOXMLValue::Pointer_t One(new OOXMLIntegerValue (1));
     566     1228236 :     static OOXMLValue::Pointer_t Two(new OOXMLIntegerValue (2));
     567     1228236 :     static OOXMLValue::Pointer_t Three(new OOXMLIntegerValue (3));
     568     1228236 :     static OOXMLValue::Pointer_t Four(new OOXMLIntegerValue (4));
     569     1228236 :     static OOXMLValue::Pointer_t Five(new OOXMLIntegerValue (5));
     570     1228236 :     static OOXMLValue::Pointer_t Six(new OOXMLIntegerValue (6));
     571     1228236 :     static OOXMLValue::Pointer_t Seven(new OOXMLIntegerValue (7));
     572     1228236 :     static OOXMLValue::Pointer_t Eight(new OOXMLIntegerValue (8));
     573     1228236 :     static OOXMLValue::Pointer_t Nine(new OOXMLIntegerValue (9));
     574             : 
     575     1228236 :     switch (nValue) {
     576       90994 :     case 0: return Zero;
     577      150778 :     case 1: return One;
     578        8664 :     case 2: return Two;
     579        1906 :     case 3: return Three;
     580       20106 :     case 4: return Four;
     581        1200 :     case 5: return Five;
     582        5986 :     case 6: return Six;
     583         980 :     case 7: return Seven;
     584        4220 :     case 8: return Eight;
     585        3770 :     case 9: return Nine;
     586      939632 :     default: break;
     587             :     }
     588             : 
     589      939632 :     OOXMLValue::Pointer_t value(new OOXMLIntegerValue(nValue));
     590             : 
     591      939632 :     return value;
     592             : }
     593             : 
     594      939932 : OOXMLIntegerValue::OOXMLIntegerValue(sal_Int32 nValue)
     595      939932 : : mnValue(nValue)
     596             : {
     597      939932 : }
     598             : 
     599     4866916 : OOXMLIntegerValue::~OOXMLIntegerValue()
     600             : {
     601     4866916 : }
     602             : 
     603     1463552 : int OOXMLIntegerValue::getInt() const
     604             : {
     605     1463552 :     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     1493526 : OOXMLValue * OOXMLIntegerValue::clone() const
     616             : {
     617     1493526 :     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      510908 : OOXMLHexValue::OOXMLHexValue(const char * pValue)
     640             : {
     641      510908 :     mnValue = rtl_str_toUInt32(pValue, 16);
     642      510908 : }
     643             : 
     644     1441724 : OOXMLHexValue::~OOXMLHexValue()
     645             : {
     646     1441724 : }
     647             : 
     648      213160 : int OOXMLHexValue::getInt() const
     649             : {
     650      213160 :     return mnValue;
     651             : }
     652             : 
     653      209954 : OOXMLValue * OOXMLHexValue::clone() const
     654             : {
     655      209954 :     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      291106 : OOXMLUniversalMeasureValue::OOXMLUniversalMeasureValue(const char * pValue)
     671             : {
     672      291106 :     mnValue = rtl_str_toUInt32(pValue, 10); // will ignore the trailing 'pt'
     673             : 
     674      291106 :     int nLen = strlen(pValue);
     675      538806 :     if (nLen > 2 &&
     676      247798 :         pValue[nLen-2] == 'p' &&
     677          98 :         pValue[nLen-1] == 't')
     678             :     {
     679          98 :         mnValue = mnValue * 20;
     680             :     }
     681      291106 : }
     682             : 
     683     1231944 : OOXMLUniversalMeasureValue::~OOXMLUniversalMeasureValue()
     684             : {
     685     1231944 : }
     686             : 
     687      324860 : int OOXMLUniversalMeasureValue::getInt() const
     688             : {
     689      324860 :     return mnValue;
     690             : }
     691             : 
     692      324866 : OOXMLValue* OOXMLUniversalMeasureValue::clone() const
     693             : {
     694      324866 :     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        8754 : OOXMLShapeValue::OOXMLShapeValue(uno::Reference<drawing::XShape> rShape)
     710        8754 : : mrShape(rShape)
     711             : {
     712        8754 : }
     713             : 
     714       17508 : OOXMLShapeValue::~OOXMLShapeValue()
     715             : {
     716       17508 : }
     717             : 
     718        3068 : uno::Any OOXMLShapeValue::getAny() const
     719             : {
     720        3068 :     return uno::Any(mrShape);
     721             : }
     722             : 
     723             : #ifdef DEBUG_WRITERFILTER
     724             : string OOXMLShapeValue::toString() const
     725             : {
     726             :     return "Shape";
     727             : }
     728             : #endif
     729             : 
     730        5552 : OOXMLValue * OOXMLShapeValue::clone() const
     731             : {
     732        5552 :     return new OOXMLShapeValue(mrShape);
     733             : }
     734             : 
     735             : /*
     736             :   class OOXMLStarMathValue
     737             :  */
     738             : 
     739             : 
     740         776 : OOXMLStarMathValue::OOXMLStarMathValue( uno::Reference< embed::XEmbeddedObject > c )
     741         776 : : component(c)
     742             : {
     743         776 : }
     744             : 
     745        1552 : OOXMLStarMathValue::~OOXMLStarMathValue()
     746             : {
     747        1552 : }
     748             : 
     749         776 : uno::Any OOXMLStarMathValue::getAny() const
     750             : {
     751         776 :     return uno::Any(component);
     752             : }
     753             : 
     754             : #ifdef DEBUG_WRITERFILTER
     755             : string OOXMLStarMathValue::toString() const
     756             : {
     757             :     return "StarMath";
     758             : }
     759             : #endif
     760             : 
     761         388 : OOXMLValue * OOXMLStarMathValue::clone() const
     762             : {
     763         388 :     return new OOXMLStarMathValue( component );
     764             : }
     765             : 
     766             : /*
     767             :   class OOXMLTableImpl
     768             :  */
     769             : 
     770       11444 : OOXMLTableImpl::OOXMLTableImpl()
     771             : {
     772       11444 : }
     773             : 
     774       34332 : OOXMLTableImpl::~OOXMLTableImpl()
     775             : {
     776       34332 : }
     777             : 
     778       11444 : void OOXMLTableImpl::resolve(Table & rTable)
     779             : {
     780       11444 :     Table * pTable = &rTable;
     781             : 
     782       11444 :     int nPos = 0;
     783             : 
     784       11444 :     PropertySets_t::iterator it = mPropertySets.begin();
     785       11444 :     PropertySets_t::iterator itEnd = mPropertySets.end();
     786             : 
     787      135186 :     while (it != itEnd)
     788             :     {
     789             :         writerfilter::Reference<Properties>::Pointer_t pProperties
     790      112298 :             ((*it)->getProperties());
     791             : 
     792      112298 :         if (pProperties.get() != nullptr)
     793      112298 :             pTable->entry(nPos, pProperties);
     794             : 
     795      112298 :         ++nPos;
     796      112298 :         ++it;
     797      112298 :     }
     798       11444 : }
     799             : 
     800      112298 : void OOXMLTableImpl::add(ValuePointer_t pPropertySet)
     801             : {
     802      112298 :     if (pPropertySet.get() != nullptr)
     803      112298 :         mPropertySets.push_back(pPropertySet);
     804      112298 : }
     805             : 
     806       11444 : OOXMLTable * OOXMLTableImpl::clone() const
     807             : {
     808       11444 :     return new OOXMLTableImpl(*this);
     809             : }
     810             : 
     811             : /*
     812             :   class: OOXMLPropertySetEntryToString
     813             : */
     814             : 
     815          82 : OOXMLPropertySetEntryToString::OOXMLPropertySetEntryToString(Id nId)
     816          82 : : mnId(nId)
     817             : {
     818          82 : }
     819             : 
     820          82 : OOXMLPropertySetEntryToString::~OOXMLPropertySetEntryToString()
     821             : {
     822          82 : }
     823             : 
     824           0 : void OOXMLPropertySetEntryToString::sprm(Sprm & /*rSprm*/)
     825             : {
     826           0 : }
     827             : 
     828          82 : void OOXMLPropertySetEntryToString::attribute(Id nId, Value & rValue)
     829             : {
     830          82 :     if (nId == mnId)
     831          82 :         mStr = rValue.getString();
     832          82 : }
     833             : 
     834             : 
     835       19878 : OOXMLPropertySetEntryToInteger::OOXMLPropertySetEntryToInteger(Id nId)
     836       19878 : : mnId(nId), mnValue(0)
     837             : {
     838       19878 : }
     839             : 
     840       19878 : OOXMLPropertySetEntryToInteger::~OOXMLPropertySetEntryToInteger()
     841             : {
     842       19878 : }
     843             : 
     844           0 : void OOXMLPropertySetEntryToInteger::sprm(Sprm & /*rSprm*/)
     845             : {
     846           0 : }
     847             : 
     848       19878 : void OOXMLPropertySetEntryToInteger::attribute(Id nId, Value & rValue)
     849             : {
     850       19878 :     if (nId == mnId)
     851       19878 :         mnValue = rValue.getInt();
     852       19878 : }
     853             : 
     854             : 
     855         114 : }}
     856             : 
     857             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10