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
|
/*
* 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/.
*/
#ifndef INCLUDED_SW_SOURCE_FILTER_WW8_RTFSTRINGBUFFER_HXX
#define INCLUDED_SW_SOURCE_FILTER_WW8_RTFSTRINGBUFFER_HXX
#include <rtl/strbuf.hxx>
#include <vector>
class SwGrfNode;
class SwFlyFrameFormat;
class RtfAttributeOutput;
/// Contains a buffered string or graphic during RTF export.
class RtfStringBufferValue
{
public:
/// Constructor for a string buffering.
RtfStringBufferValue();
/// Constructor for graphic buffering.
RtfStringBufferValue(const SwFlyFrameFormat* pFlyFrameFormat, const SwGrfNode* pGrfNode);
/// This version handles graphics.
void makeStringAndClear(RtfAttributeOutput* pAttributeOutput);
/// This one doesn't.
OString makeStringAndClear();
bool isGraphic() const;
OStringBuffer& getBuffer() { return m_aBuffer; }
const OStringBuffer& getBuffer() const { return m_aBuffer; }
private:
OStringBuffer m_aBuffer;
const SwFlyFrameFormat* m_pFlyFrameFormat = nullptr;
const SwGrfNode* m_pGrfNode = nullptr;
};
/// Wrapper around OStringBuffers, so less hexdump of graphics have to be kept in memory during RTF export.
class RtfStringBuffer
{
public:
RtfStringBuffer();
/// Length of all the contained buffers.
sal_Int32 getLength() const;
/// Writes the contents of the buffer directly to the supplied stream.
void makeStringAndClear(RtfAttributeOutput* pAttributeOutput);
/// Returns the buffered strings as a string (ignores graphic elements!)
OString makeStringAndClear();
/// Access to the last buffer.
OStringBuffer& getLastBuffer();
OStringBuffer* operator->();
/// Similar to ->setLength(0), but for all buffers.
void clear();
/// Same as ->append(), but for graphics and without expanding contents to save memory.
void append(const SwFlyFrameFormat* pFlyFrameFormat, const SwGrfNode* pGrfNode);
/// Append all contained buffers and clear the argument.
void appendAndClear(RtfStringBuffer& rBuf);
private:
using Values_t = std::vector<RtfStringBufferValue>;
Values_t m_aValues;
};
#endif // INCLUDED_SW_SOURCE_FILTER_WW8_RTFSTRINGBUFFER_HXX
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|