android: Update app-specific/MIME type icons
[LibreOffice.git] / sw / source / filter / ww8 / rtfstringbuffer.cxx
blobae491e45b4f03ddfc72ad0adf3e3b614954bbf25
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 "rtfstringbuffer.hxx"
10 #include "rtfattributeoutput.hxx"
11 #include "rtfexport.hxx"
13 RtfStringBufferValue::RtfStringBufferValue() = default;
15 RtfStringBufferValue::RtfStringBufferValue(const SwFlyFrameFormat* pFlyFrameFormat,
16 const SwGrfNode* pGrfNode)
17 : m_pFlyFrameFormat(pFlyFrameFormat)
18 , m_pGrfNode(pGrfNode)
22 void RtfStringBufferValue::makeStringAndClear(RtfAttributeOutput* pAttributeOutput)
24 if (!isGraphic())
26 pAttributeOutput->m_rExport.Strm().WriteOString(m_aBuffer);
27 m_aBuffer.setLength(0);
29 else
30 pAttributeOutput->FlyFrameGraphic(m_pFlyFrameFormat, m_pGrfNode);
33 OString RtfStringBufferValue::makeStringAndClear() { return m_aBuffer.makeStringAndClear(); }
35 bool RtfStringBufferValue::isGraphic() const
37 return m_pFlyFrameFormat != nullptr && m_pGrfNode != nullptr;
40 RtfStringBuffer::RtfStringBuffer() = default;
42 sal_Int32 RtfStringBuffer::getLength() const
44 sal_Int32 nRet = 0;
45 for (const auto& rValue : m_aValues)
46 if (!rValue.isGraphic())
47 nRet += rValue.getBuffer().getLength();
48 return nRet;
51 void RtfStringBuffer::makeStringAndClear(RtfAttributeOutput* pAttributeOutput)
53 for (auto& rValue : m_aValues)
54 rValue.makeStringAndClear(pAttributeOutput);
57 OString RtfStringBuffer::makeStringAndClear()
59 OStringBuffer aBuf;
60 for (auto& rValue : m_aValues)
61 if (!rValue.isGraphic())
62 aBuf.append(rValue.makeStringAndClear());
63 return aBuf.makeStringAndClear();
66 OStringBuffer& RtfStringBuffer::getLastBuffer()
68 if (m_aValues.empty() || m_aValues.back().isGraphic())
69 m_aValues.emplace_back();
70 return m_aValues.back().getBuffer();
73 OStringBuffer* RtfStringBuffer::operator->() { return &getLastBuffer(); }
75 void RtfStringBuffer::clear() { m_aValues.clear(); }
77 void RtfStringBuffer::append(const SwFlyFrameFormat* pFlyFrameFormat, const SwGrfNode* pGrfNode)
79 m_aValues.emplace_back(pFlyFrameFormat, pGrfNode);
82 void RtfStringBuffer::appendAndClear(RtfStringBuffer& rBuf)
84 m_aValues.insert(m_aValues.end(), rBuf.m_aValues.begin(), rBuf.m_aValues.end());
85 rBuf.clear();
88 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */