LCOV - code coverage report
Current view: top level - sw/source/filter/ww8 - rtfstringbuffer.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 30 51 58.8 %
Date: 2012-08-25 Functions: 9 14 64.3 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 18 46 39.1 %

           Branch data     Line data    Source code
       1                 :            : /*
       2                 :            :  * Version: MPL 1.1 / GPLv3+ / LGPLv3+
       3                 :            :  *
       4                 :            :  * The contents of this file are subject to the Mozilla Public License Version
       5                 :            :  * 1.1 (the "License"); you may not use this file except in compliance with
       6                 :            :  * the License. You may obtain a copy of the License at
       7                 :            :  * http://www.mozilla.org/MPL/
       8                 :            :  *
       9                 :            :  * Software distributed under the License is distributed on an "AS IS" basis,
      10                 :            :  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
      11                 :            :  * for the specific language governing rights and limitations under the
      12                 :            :  * License.
      13                 :            :  *
      14                 :            :  * The Initial Developer of the Original Code is
      15                 :            :  *       Miklos Vajna <vmiklos@suse.cz> (SUSE, Inc.)
      16                 :            :  * Portions created by the Initial Developer are Copyright (C) 2012 the
      17                 :            :  * Initial Developer. All Rights Reserved.
      18                 :            :  *
      19                 :            :  * Contributor(s):
      20                 :            :  *
      21                 :            :  * Alternatively, the contents of this file may be used under the terms of
      22                 :            :  * either the GNU General Public License Version 3 or later (the "GPLv3+"), or
      23                 :            :  * the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
      24                 :            :  * in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
      25                 :            :  * instead of those above.
      26                 :            :  */
      27                 :            : 
      28                 :            : #include "rtfattributeoutput.hxx"
      29                 :            : #include "rtfstringbuffer.hxx"
      30                 :            : 
      31                 :        258 : RtfStringBufferValue::RtfStringBufferValue()
      32                 :            :     : m_aBuffer(),
      33                 :            :     m_pFlyFrmFmt(0),
      34                 :        258 :     m_pGrfNode(0)
      35                 :            : {
      36                 :        258 : }
      37                 :            : 
      38                 :          0 : RtfStringBufferValue::RtfStringBufferValue(const SwFlyFrmFmt* pFlyFrmFmt, const SwGrfNode* pGrfNode)
      39                 :            :     : m_aBuffer(),
      40                 :            :     m_pFlyFrmFmt(pFlyFrmFmt),
      41                 :          0 :     m_pGrfNode(pGrfNode)
      42                 :            : {
      43                 :          0 : }
      44                 :            : 
      45                 :        258 : void RtfStringBufferValue::makeStringAndClear(RtfAttributeOutput* pAttributeOutput)
      46                 :            : {
      47         [ +  - ]:        258 :     if (!isGraphic())
      48 [ +  - ][ +  - ]:        258 :         pAttributeOutput->m_rExport.Strm() << m_aBuffer.makeStringAndClear().getStr();
      49                 :            :     else
      50                 :          0 :         pAttributeOutput->FlyFrameGraphic(m_pFlyFrmFmt, m_pGrfNode);
      51                 :        258 : }
      52                 :            : 
      53                 :          0 : rtl::OString RtfStringBufferValue::makeStringAndClear()
      54                 :            : {
      55                 :          0 :     return m_aBuffer.makeStringAndClear();
      56                 :            : }
      57                 :            : 
      58                 :       2199 : bool RtfStringBufferValue::isGraphic() const
      59                 :            : {
      60 [ -  + ][ #  # ]:       2199 :     return m_pFlyFrmFmt != 0 && m_pGrfNode != 0;
      61                 :            : }
      62                 :            : 
      63                 :        282 : RtfStringBuffer::RtfStringBuffer()
      64                 :        282 :     : m_aValues()
      65                 :            : {
      66                 :        282 : }
      67                 :            : 
      68                 :          0 : sal_Int32 RtfStringBuffer::getLength() const
      69                 :            : {
      70                 :          0 :     sal_Int32 nRet = 0;
      71 [ #  # ][ #  # ]:          0 :     for (RtfStringBuffer::Values_t::const_iterator i = m_aValues.begin(); i != m_aValues.end(); ++i)
      72         [ #  # ]:          0 :         if (!i->isGraphic())
      73                 :          0 :             nRet += i->m_aBuffer.getLength();
      74                 :          0 :     return nRet;
      75                 :            : }
      76                 :            : 
      77                 :        126 : void RtfStringBuffer::makeStringAndClear(RtfAttributeOutput* pAttributeOutput)
      78                 :            : {
      79 [ +  - ][ +  + ]:        384 :     for (RtfStringBuffer::Values_t::iterator i = m_aValues.begin(); i != m_aValues.end(); ++i)
      80         [ +  - ]:        258 :         i->makeStringAndClear(pAttributeOutput);
      81                 :        126 : }
      82                 :            : 
      83                 :          0 : rtl::OString RtfStringBuffer::makeStringAndClear()
      84                 :            : {
      85                 :          0 :     rtl::OStringBuffer aBuf;
      86 [ #  # ][ #  # ]:          0 :     for (RtfStringBuffer::Values_t::iterator i = m_aValues.begin(); i != m_aValues.end(); ++i)
      87         [ #  # ]:          0 :         if (!i->isGraphic())
      88         [ #  # ]:          0 :             aBuf.append(i->makeStringAndClear());
      89                 :          0 :     return aBuf.makeStringAndClear();
      90                 :            : }
      91                 :            : 
      92                 :       2199 : rtl::OStringBuffer& RtfStringBuffer::getLastBuffer()
      93                 :            : {
      94 [ +  + ][ -  + ]:       2199 :     if (m_aValues.empty() || m_aValues.back().isGraphic())
                 [ +  + ]
      95         [ +  - ]:        258 :         m_aValues.push_back(RtfStringBufferValue());
      96                 :       2199 :     return m_aValues.back().m_aBuffer;
      97                 :            : }
      98                 :            : 
      99                 :       2127 : rtl::OStringBuffer* RtfStringBuffer::operator->()
     100                 :            : {
     101                 :       2127 :     return &getLastBuffer();
     102                 :            : }
     103                 :            : 
     104                 :        267 : void RtfStringBuffer::clear()
     105                 :            : {
     106                 :        267 :     m_aValues.clear();
     107                 :        267 : }
     108                 :            : 
     109                 :          0 : void RtfStringBuffer::append(const SwFlyFrmFmt* pFlyFrmFmt, const SwGrfNode* pGrfNode)
     110                 :            : {
     111         [ #  # ]:          0 :     m_aValues.push_back(RtfStringBufferValue(pFlyFrmFmt, pGrfNode));
     112                 :          0 : }
     113                 :            : 
     114                 :        267 : void RtfStringBuffer::appendAndClear(RtfStringBuffer& rBuf)
     115                 :            : {
     116 [ +  - ][ +  + ]:        657 :     for (RtfStringBuffer::Values_t::iterator i = rBuf.m_aValues.begin(); i != rBuf.m_aValues.end(); ++i)
     117         [ +  - ]:        390 :         m_aValues.push_back(*i);
     118                 :        267 :     rBuf.clear();
     119                 :        267 : }
     120                 :            : 
     121                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10