LCOV - code coverage report
Current view: top level - sw/source/filter/ww8 - rtfstringbuffer.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 45 51 88.2 %
Date: 2014-11-03 Functions: 15 16 93.8 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /*
       2             :  * This file is part of the LibreOffice project.
       3             :  *
       4             :  * This Source Code Form is subject to the terms of the Mozilla Public
       5             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       6             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       7             :  */
       8             : 
       9             : #include "rtfattributeoutput.hxx"
      10             : #include "rtfstringbuffer.hxx"
      11             : 
      12        2070 : RtfStringBufferValue::RtfStringBufferValue()
      13             :     : m_aBuffer(),
      14             :       m_pFlyFrmFmt(0),
      15        2070 :       m_pGrfNode(0)
      16             : {
      17        2070 : }
      18             : 
      19          14 : RtfStringBufferValue::RtfStringBufferValue(const SwFlyFrmFmt* pFlyFrmFmt, const SwGrfNode* pGrfNode)
      20             :     : m_aBuffer(),
      21             :       m_pFlyFrmFmt(pFlyFrmFmt),
      22          14 :       m_pGrfNode(pGrfNode)
      23             : {
      24          14 : }
      25             : 
      26        2032 : void RtfStringBufferValue::makeStringAndClear(RtfAttributeOutput* pAttributeOutput)
      27             : {
      28        2032 :     if (!isGraphic())
      29        2018 :         pAttributeOutput->m_rExport.Strm().WriteCharPtr(m_aBuffer.makeStringAndClear().getStr());
      30             :     else
      31          14 :         pAttributeOutput->FlyFrameGraphic(m_pFlyFrmFmt, m_pGrfNode);
      32        2032 : }
      33             : 
      34          60 : OString RtfStringBufferValue::makeStringAndClear()
      35             : {
      36          60 :     return m_aBuffer.makeStringAndClear();
      37             : }
      38             : 
      39       15402 : bool RtfStringBufferValue::isGraphic() const
      40             : {
      41       15402 :     return m_pFlyFrmFmt != 0 && m_pGrfNode != 0;
      42             : }
      43             : 
      44        1476 : RtfStringBuffer::RtfStringBuffer()
      45        1476 :     : m_aValues()
      46             : {
      47        1476 : }
      48             : 
      49           0 : sal_Int32 RtfStringBuffer::getLength() const
      50             : {
      51           0 :     sal_Int32 nRet = 0;
      52           0 :     for (RtfStringBuffer::Values_t::const_iterator i = m_aValues.begin(); i != m_aValues.end(); ++i)
      53           0 :         if (!i->isGraphic())
      54           0 :             nRet += i->m_aBuffer.getLength();
      55           0 :     return nRet;
      56             : }
      57             : 
      58        1156 : void RtfStringBuffer::makeStringAndClear(RtfAttributeOutput* pAttributeOutput)
      59             : {
      60        3188 :     for (RtfStringBuffer::Values_t::iterator i = m_aValues.begin(); i != m_aValues.end(); ++i)
      61        2032 :         i->makeStringAndClear(pAttributeOutput);
      62        1156 : }
      63             : 
      64          68 : OString RtfStringBuffer::makeStringAndClear()
      65             : {
      66          68 :     OStringBuffer aBuf;
      67         128 :     for (RtfStringBuffer::Values_t::iterator i = m_aValues.begin(); i != m_aValues.end(); ++i)
      68          60 :         if (!i->isGraphic())
      69          60 :             aBuf.append(i->makeStringAndClear());
      70          68 :     return aBuf.makeStringAndClear();
      71             : }
      72             : 
      73       15366 : OStringBuffer& RtfStringBuffer::getLastBuffer()
      74             : {
      75       15366 :     if (m_aValues.empty() || m_aValues.back().isGraphic())
      76        2070 :         m_aValues.push_back(RtfStringBufferValue());
      77       15366 :     return m_aValues.back().m_aBuffer;
      78             : }
      79             : 
      80       10530 : OStringBuffer* RtfStringBuffer::operator->()
      81             : {
      82       10530 :     return &getLastBuffer();
      83             : }
      84             : 
      85        2618 : void RtfStringBuffer::clear()
      86             : {
      87        2618 :     m_aValues.clear();
      88        2618 : }
      89             : 
      90          14 : void RtfStringBuffer::append(const SwFlyFrmFmt* pFlyFrmFmt, const SwGrfNode* pGrfNode)
      91             : {
      92          14 :     m_aValues.push_back(RtfStringBufferValue(pFlyFrmFmt, pGrfNode));
      93          14 : }
      94             : 
      95        2572 : void RtfStringBuffer::appendAndClear(RtfStringBuffer& rBuf)
      96             : {
      97        5548 :     for (RtfStringBuffer::Values_t::iterator i = rBuf.m_aValues.begin(); i != rBuf.m_aValues.end(); ++i)
      98        2976 :         m_aValues.push_back(*i);
      99        2572 :     rBuf.clear();
     100        2674 : }
     101             : 
     102             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10