Line data Source code
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 "rtfattributeoutput.hxx"
10 : #include "rtfstringbuffer.hxx"
11 :
12 180 : RtfStringBufferValue::RtfStringBufferValue()
13 : : m_aBuffer(),
14 : m_pFlyFrmFmt(0),
15 180 : m_pGrfNode(0)
16 : {
17 180 : }
18 :
19 0 : RtfStringBufferValue::RtfStringBufferValue(const SwFlyFrmFmt* pFlyFrmFmt, const SwGrfNode* pGrfNode)
20 : : m_aBuffer(),
21 : m_pFlyFrmFmt(pFlyFrmFmt),
22 0 : m_pGrfNode(pGrfNode)
23 : {
24 0 : }
25 :
26 177 : void RtfStringBufferValue::makeStringAndClear(RtfAttributeOutput* pAttributeOutput)
27 : {
28 177 : if (!isGraphic())
29 177 : pAttributeOutput->m_rExport.Strm() << m_aBuffer.makeStringAndClear().getStr();
30 : else
31 0 : pAttributeOutput->FlyFrameGraphic(m_pFlyFrmFmt, m_pGrfNode);
32 177 : }
33 :
34 5 : OString RtfStringBufferValue::makeStringAndClear()
35 : {
36 5 : return m_aBuffer.makeStringAndClear();
37 : }
38 :
39 1250 : bool RtfStringBufferValue::isGraphic() const
40 : {
41 1250 : return m_pFlyFrmFmt != 0 && m_pGrfNode != 0;
42 : }
43 :
44 179 : RtfStringBuffer::RtfStringBuffer()
45 179 : : m_aValues()
46 : {
47 179 : }
48 :
49 0 : sal_Int32 RtfStringBuffer::getLength() const
50 : {
51 0 : sal_Int32 nRet = 0;
52 0 : for (RtfStringBuffer::Values_t::const_iterator i = m_aValues.begin(); i != m_aValues.end(); ++i)
53 0 : if (!i->isGraphic())
54 0 : nRet += i->m_aBuffer.getLength();
55 0 : return nRet;
56 : }
57 :
58 95 : void RtfStringBuffer::makeStringAndClear(RtfAttributeOutput* pAttributeOutput)
59 : {
60 272 : for (RtfStringBuffer::Values_t::iterator i = m_aValues.begin(); i != m_aValues.end(); ++i)
61 177 : i->makeStringAndClear(pAttributeOutput);
62 95 : }
63 :
64 18 : OString RtfStringBuffer::makeStringAndClear()
65 : {
66 18 : OStringBuffer aBuf;
67 23 : for (RtfStringBuffer::Values_t::iterator i = m_aValues.begin(); i != m_aValues.end(); ++i)
68 5 : if (!i->isGraphic())
69 5 : aBuf.append(i->makeStringAndClear());
70 18 : return aBuf.makeStringAndClear();
71 : }
72 :
73 1248 : OStringBuffer& RtfStringBuffer::getLastBuffer()
74 : {
75 1248 : if (m_aValues.empty() || m_aValues.back().isGraphic())
76 180 : m_aValues.push_back(RtfStringBufferValue());
77 1248 : return m_aValues.back().m_aBuffer;
78 : }
79 :
80 1224 : OStringBuffer* RtfStringBuffer::operator->()
81 : {
82 1224 : return &getLastBuffer();
83 : }
84 :
85 221 : void RtfStringBuffer::clear()
86 : {
87 221 : m_aValues.clear();
88 221 : }
89 :
90 0 : void RtfStringBuffer::append(const SwFlyFrmFmt* pFlyFrmFmt, const SwGrfNode* pGrfNode)
91 : {
92 0 : m_aValues.push_back(RtfStringBufferValue(pFlyFrmFmt, pGrfNode));
93 0 : }
94 :
95 211 : void RtfStringBuffer::appendAndClear(RtfStringBuffer& rBuf)
96 : {
97 474 : for (RtfStringBuffer::Values_t::iterator i = rBuf.m_aValues.begin(); i != rBuf.m_aValues.end(); ++i)
98 263 : m_aValues.push_back(*i);
99 211 : rBuf.clear();
100 229 : }
101 :
102 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|