LCOV - code coverage report
Current view: top level - libreoffice/sw/source/filter/ww8 - rtfstringbuffer.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 38 51 74.5 %
Date: 2012-12-17 Functions: 11 14 78.6 %
Legend: Lines: hit not hit

          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         232 : RtfStringBufferValue::RtfStringBufferValue()
      32             :     : m_aBuffer(),
      33             :     m_pFlyFrmFmt(0),
      34         232 :     m_pGrfNode(0)
      35             : {
      36         232 : }
      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         228 : void RtfStringBufferValue::makeStringAndClear(RtfAttributeOutput* pAttributeOutput)
      46             : {
      47         228 :     if (!isGraphic())
      48         228 :         pAttributeOutput->m_rExport.Strm() << m_aBuffer.makeStringAndClear().getStr();
      49             :     else
      50           0 :         pAttributeOutput->FlyFrameGraphic(m_pFlyFrmFmt, m_pGrfNode);
      51         228 : }
      52             : 
      53          18 : rtl::OString RtfStringBufferValue::makeStringAndClear()
      54             : {
      55          18 :     return m_aBuffer.makeStringAndClear();
      56             : }
      57             : 
      58        1946 : bool RtfStringBufferValue::isGraphic() const
      59             : {
      60        1946 :     return m_pFlyFrmFmt != 0 && m_pGrfNode != 0;
      61             : }
      62             : 
      63         244 : RtfStringBuffer::RtfStringBuffer()
      64         244 :     : m_aValues()
      65             : {
      66         244 : }
      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         130 : void RtfStringBuffer::makeStringAndClear(RtfAttributeOutput* pAttributeOutput)
      78             : {
      79         358 :     for (RtfStringBuffer::Values_t::iterator i = m_aValues.begin(); i != m_aValues.end(); ++i)
      80         228 :         i->makeStringAndClear(pAttributeOutput);
      81         130 : }
      82             : 
      83          20 : rtl::OString RtfStringBuffer::makeStringAndClear()
      84             : {
      85          20 :     rtl::OStringBuffer aBuf;
      86          38 :     for (RtfStringBuffer::Values_t::iterator i = m_aValues.begin(); i != m_aValues.end(); ++i)
      87          18 :         if (!i->isGraphic())
      88          18 :             aBuf.append(i->makeStringAndClear());
      89          20 :     return aBuf.makeStringAndClear();
      90             : }
      91             : 
      92        1932 : rtl::OStringBuffer& RtfStringBuffer::getLastBuffer()
      93             : {
      94        1932 :     if (m_aValues.empty() || m_aValues.back().isGraphic())
      95         232 :         m_aValues.push_back(RtfStringBufferValue());
      96        1932 :     return m_aValues.back().m_aBuffer;
      97             : }
      98             : 
      99        1884 : rtl::OStringBuffer* RtfStringBuffer::operator->()
     100             : {
     101        1884 :     return &getLastBuffer();
     102             : }
     103             : 
     104         286 : void RtfStringBuffer::clear()
     105             : {
     106         286 :     m_aValues.clear();
     107         286 : }
     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         278 : void RtfStringBuffer::appendAndClear(RtfStringBuffer& rBuf)
     115             : {
     116         610 :     for (RtfStringBuffer::Values_t::iterator i = rBuf.m_aValues.begin(); i != rBuf.m_aValues.end(); ++i)
     117         332 :         m_aValues.push_back(*i);
     118         278 :     rBuf.clear();
     119         278 : }
     120             : 
     121             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10