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/.
9 #include "rtfattributeoutput.hxx"
10 #include "rtfstringbuffer.hxx"
12 RtfStringBufferValue::RtfStringBufferValue()
19 RtfStringBufferValue::RtfStringBufferValue(const SwFlyFrmFmt
* pFlyFrmFmt
, const SwGrfNode
* pGrfNode
)
21 m_pFlyFrmFmt(pFlyFrmFmt
),
26 void RtfStringBufferValue::makeStringAndClear(RtfAttributeOutput
* pAttributeOutput
)
29 pAttributeOutput
->m_rExport
.Strm() << m_aBuffer
.makeStringAndClear().getStr();
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()
49 sal_Int32
RtfStringBuffer::getLength() const
52 for (RtfStringBuffer::Values_t::const_iterator i
= m_aValues
.begin(); i
!= m_aValues
.end(); ++i
)
54 nRet
+= i
->m_aBuffer
.getLength();
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()
67 for (RtfStringBuffer::Values_t::iterator i
= m_aValues
.begin(); i
!= m_aValues
.end(); ++i
)
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()
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
);
102 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */