blob: 55c4d68a2653a2b18d3049b530962ede6f2a9d23 (
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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
|
/*
* 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"
RtfStringBufferValue::RtfStringBufferValue()
: m_aBuffer(),
m_pFlyFrameFormat(nullptr),
m_pGrfNode(nullptr)
{
}
RtfStringBufferValue::RtfStringBufferValue(const SwFlyFrameFormat* pFlyFrameFormat, const SwGrfNode* pGrfNode)
: m_aBuffer(),
m_pFlyFrameFormat(pFlyFrameFormat),
m_pGrfNode(pGrfNode)
{
}
void RtfStringBufferValue::makeStringAndClear(RtfAttributeOutput* pAttributeOutput)
{
if (!isGraphic())
pAttributeOutput->m_rExport.Strm().WriteCharPtr(m_aBuffer.makeStringAndClear().getStr());
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()
: m_aValues()
{
}
sal_Int32 RtfStringBuffer::getLength() const
{
sal_Int32 nRet = 0;
for (RtfStringBuffer::Values_t::const_iterator i = m_aValues.begin(); i != m_aValues.end(); ++i)
if (!i->isGraphic())
nRet += i->m_aBuffer.getLength();
return nRet;
}
void RtfStringBuffer::makeStringAndClear(RtfAttributeOutput* pAttributeOutput)
{
for (RtfStringBuffer::Values_t::iterator i = m_aValues.begin(); i != m_aValues.end(); ++i)
i->makeStringAndClear(pAttributeOutput);
}
OString RtfStringBuffer::makeStringAndClear()
{
OStringBuffer aBuf;
for (RtfStringBuffer::Values_t::iterator i = m_aValues.begin(); i != m_aValues.end(); ++i)
if (!i->isGraphic())
aBuf.append(i->makeStringAndClear());
return aBuf.makeStringAndClear();
}
OStringBuffer& RtfStringBuffer::getLastBuffer()
{
if (m_aValues.empty() || m_aValues.back().isGraphic())
m_aValues.push_back(RtfStringBufferValue());
return m_aValues.back().m_aBuffer;
}
OStringBuffer* RtfStringBuffer::operator->()
{
return &getLastBuffer();
}
void RtfStringBuffer::clear()
{
m_aValues.clear();
}
void RtfStringBuffer::append(const SwFlyFrameFormat* pFlyFrameFormat, const SwGrfNode* pGrfNode)
{
m_aValues.push_back(RtfStringBufferValue(pFlyFrameFormat, pGrfNode));
}
void RtfStringBuffer::appendAndClear(RtfStringBuffer& rBuf)
{
for (RtfStringBuffer::Values_t::iterator i = rBuf.m_aValues.begin(); i != rBuf.m_aValues.end(); ++i)
m_aValues.push_back(*i);
rBuf.clear();
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|