LibreOffice Module sw (master) 1
rtfstringbuffer.cxx
Go to the documentation of this file.
1/*
2 * This file is part of the LibreOffice project.
3 *
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 */
8
9#include "rtfstringbuffer.hxx"
11#include "rtfexport.hxx"
12
14
16 const SwGrfNode* pGrfNode)
17 : m_pFlyFrameFormat(pFlyFrameFormat)
18 , m_pGrfNode(pGrfNode)
19{
20}
21
23{
24 if (!isGraphic())
25 {
26 pAttributeOutput->m_rExport.Strm().WriteOString(m_aBuffer);
27 m_aBuffer.setLength(0);
28 }
29 else
31}
32
33OString RtfStringBufferValue::makeStringAndClear() { return m_aBuffer.makeStringAndClear(); }
34
36{
37 return m_pFlyFrameFormat != nullptr && m_pGrfNode != nullptr;
38}
39
41
43{
44 sal_Int32 nRet = 0;
45 for (const auto& rValue : m_aValues)
46 if (!rValue.isGraphic())
47 nRet += rValue.getBuffer().getLength();
48 return nRet;
49}
50
52{
53 for (auto& rValue : m_aValues)
54 rValue.makeStringAndClear(pAttributeOutput);
55}
56
58{
59 OStringBuffer aBuf;
60 for (auto& rValue : m_aValues)
61 if (!rValue.isGraphic())
62 aBuf.append(rValue.makeStringAndClear());
63 return aBuf.makeStringAndClear();
64}
65
67{
68 if (m_aValues.empty() || m_aValues.back().isGraphic())
69 m_aValues.emplace_back();
70 return m_aValues.back().getBuffer();
71}
72
73OStringBuffer* RtfStringBuffer::operator->() { return &getLastBuffer(); }
74
76
77void RtfStringBuffer::append(const SwFlyFrameFormat* pFlyFrameFormat, const SwGrfNode* pGrfNode)
78{
79 m_aValues.emplace_back(pFlyFrameFormat, pGrfNode);
80}
81
83{
84 m_aValues.insert(m_aValues.end(), rBuf.m_aValues.begin(), rBuf.m_aValues.end());
85 rBuf.clear();
86}
87
88/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
The class that has handlers for various resource types when exporting as RTF.
RtfExport & m_rExport
Reference to the export, where to get the data from.
void FlyFrameGraphic(const SwFlyFrameFormat *pFlyFrameFormat, const SwGrfNode *pGrfNode)
Output graphic fly frames.
SvStream & Strm()
Definition: rtfexport.cxx:1171
const SwGrfNode * m_pGrfNode
OString makeStringAndClear()
This one doesn't.
const SwFlyFrameFormat * m_pFlyFrameFormat
RtfStringBufferValue()
Constructor for a string buffering.
Wrapper around OStringBuffers, so less hexdump of graphics have to be kept in memory during RTF expor...
void clear()
Similar to ->setLength(0), but for all buffers.
void append(const SwFlyFrameFormat *pFlyFrameFormat, const SwGrfNode *pGrfNode)
Same as ->append(), but for graphics and without expanding contents to save memory.
OStringBuffer & getLastBuffer()
Access to the last buffer.
void appendAndClear(RtfStringBuffer &rBuf)
Append all contained buffers and clear the argument.
OString makeStringAndClear()
Returns the buffered strings as a string (ignores graphic elements!)
OStringBuffer * operator->()
sal_Int32 getLength() const
Length of all the contained buffers.
SvStream & WriteOString(std::string_view rStr)
aBuf