blob: ae491e45b4f03ddfc72ad0adf3e3b614954bbf25 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
|
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#include "rtfstringbuffer.hxx"
#include "rtfattributeoutput.hxx"
#include "rtfexport.hxx"
RtfStringBufferValue::RtfStringBufferValue() = default;
RtfStringBufferValue::RtfStringBufferValue(const SwFlyFrameFormat* pFlyFrameFormat,
const SwGrfNode* pGrfNode)
: m_pFlyFrameFormat(pFlyFrameFormat)
, m_pGrfNode(pGrfNode)
{
}
void RtfStringBufferValue::makeStringAndClear(RtfAttributeOutput* pAttributeOutput)
{
if (!isGraphic())
{
pAttributeOutput->m_rExport.Strm().WriteOString(m_aBuffer);
m_aBuffer.setLength(0);
}
else
pAttributeOutput->FlyFrameGraphic(m_pFlyFrameFormat, m_pGrfNode);
}
OString RtfStringBufferValue::makeStringAndClear() { return m_aBuffer.makeStringAndClear(); }
bool RtfStringBufferValue::isGraphic() const
{
return m_pFlyFrameFormat != nullptr && m_pGrfNode != nullptr;
}
RtfStringBuffer::RtfStringBuffer() = default;
sal_Int32 RtfStringBuffer::getLength() const
{
sal_Int32 nRet = 0;
for (const auto& rValue : m_aValues)
if (!rValue.isGraphic())
nRet += rValue.getBuffer().getLength();
return nRet;
}
void RtfStringBuffer::makeStringAndClear(RtfAttributeOutput* pAttributeOutput)
{
for (auto& rValue : m_aValues)
rValue.makeStringAndClear(pAttributeOutput);
}
OString RtfStringBuffer::makeStringAndClear()
{
OStringBuffer aBuf;
for (auto& rValue : m_aValues)
if (!rValue.isGraphic())
aBuf.append(rValue.makeStringAndClear());
return aBuf.makeStringAndClear();
}
OStringBuffer& RtfStringBuffer::getLastBuffer()
{
if (m_aValues.empty() || m_aValues.back().isGraphic())
m_aValues.emplace_back();
return m_aValues.back().getBuffer();
}
OStringBuffer* RtfStringBuffer::operator->() { return &getLastBuffer(); }
void RtfStringBuffer::clear() { m_aValues.clear(); }
void RtfStringBuffer::append(const SwFlyFrameFormat* pFlyFrameFormat, const SwGrfNode* pGrfNode)
{
m_aValues.emplace_back(pFlyFrameFormat, pGrfNode);
}
void RtfStringBuffer::appendAndClear(RtfStringBuffer& rBuf)
{
m_aValues.insert(m_aValues.end(), rBuf.m_aValues.begin(), rBuf.m_aValues.end());
rBuf.clear();
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|