bump product version to 4.1.6.2
[LibreOffice.git] / sw / source / filter / ww8 / rtfstringbuffer.cxx
blob811cba097c8a51f71a2ce5dbd858545d5aedcad9
1 /*
2 * This file is part of the LibreOffice project.
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 */
9 #include "rtfattributeoutput.hxx"
10 #include "rtfstringbuffer.hxx"
12 RtfStringBufferValue::RtfStringBufferValue()
13 : m_aBuffer(),
14 m_pFlyFrmFmt(0),
15 m_pGrfNode(0)
19 RtfStringBufferValue::RtfStringBufferValue(const SwFlyFrmFmt* pFlyFrmFmt, const SwGrfNode* pGrfNode)
20 : m_aBuffer(),
21 m_pFlyFrmFmt(pFlyFrmFmt),
22 m_pGrfNode(pGrfNode)
26 void RtfStringBufferValue::makeStringAndClear(RtfAttributeOutput* pAttributeOutput)
28 if (!isGraphic())
29 pAttributeOutput->m_rExport.Strm() << m_aBuffer.makeStringAndClear().getStr();
30 else
31 pAttributeOutput->FlyFrameGraphic(m_pFlyFrmFmt, m_pGrfNode);
34 OString RtfStringBufferValue::makeStringAndClear()
36 return m_aBuffer.makeStringAndClear();
39 bool RtfStringBufferValue::isGraphic() const
41 return m_pFlyFrmFmt != 0 && m_pGrfNode != 0;
44 RtfStringBuffer::RtfStringBuffer()
45 : m_aValues()
49 sal_Int32 RtfStringBuffer::getLength() const
51 sal_Int32 nRet = 0;
52 for (RtfStringBuffer::Values_t::const_iterator i = m_aValues.begin(); i != m_aValues.end(); ++i)
53 if (!i->isGraphic())
54 nRet += i->m_aBuffer.getLength();
55 return nRet;
58 void RtfStringBuffer::makeStringAndClear(RtfAttributeOutput* pAttributeOutput)
60 for (RtfStringBuffer::Values_t::iterator i = m_aValues.begin(); i != m_aValues.end(); ++i)
61 i->makeStringAndClear(pAttributeOutput);
64 OString RtfStringBuffer::makeStringAndClear()
66 OStringBuffer aBuf;
67 for (RtfStringBuffer::Values_t::iterator i = m_aValues.begin(); i != m_aValues.end(); ++i)
68 if (!i->isGraphic())
69 aBuf.append(i->makeStringAndClear());
70 return aBuf.makeStringAndClear();
73 OStringBuffer& RtfStringBuffer::getLastBuffer()
75 if (m_aValues.empty() || m_aValues.back().isGraphic())
76 m_aValues.push_back(RtfStringBufferValue());
77 return m_aValues.back().m_aBuffer;
80 OStringBuffer* RtfStringBuffer::operator->()
82 return &getLastBuffer();
85 void RtfStringBuffer::clear()
87 m_aValues.clear();
90 void RtfStringBuffer::append(const SwFlyFrmFmt* pFlyFrmFmt, const SwGrfNode* pGrfNode)
92 m_aValues.push_back(RtfStringBufferValue(pFlyFrmFmt, pGrfNode));
95 void RtfStringBuffer::appendAndClear(RtfStringBuffer& rBuf)
97 for (RtfStringBuffer::Values_t::iterator i = rBuf.m_aValues.begin(); i != rBuf.m_aValues.end(); ++i)
98 m_aValues.push_back(*i);
99 rBuf.clear();
102 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */