Line data Source code
1 : /*
2 : * Version: MPL 1.1 / GPLv3+ / LGPLv3+
3 : *
4 : * The contents of this file are subject to the Mozilla Public License Version
5 : * 1.1 (the "License"); you may not use this file except in compliance with
6 : * the License. You may obtain a copy of the License at
7 : * http://www.mozilla.org/MPL/
8 : *
9 : * Software distributed under the License is distributed on an "AS IS" basis,
10 : * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
11 : * for the specific language governing rights and limitations under the
12 : * License.
13 : *
14 : * The Initial Developer of the Original Code is
15 : * Miklos Vajna <vmiklos@suse.cz> (SUSE, Inc.)
16 : * Portions created by the Initial Developer are Copyright (C) 2012 the
17 : * Initial Developer. All Rights Reserved.
18 : *
19 : * Contributor(s):
20 : *
21 : * Alternatively, the contents of this file may be used under the terms of
22 : * either the GNU General Public License Version 3 or later (the "GPLv3+"), or
23 : * the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
24 : * in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
25 : * instead of those above.
26 : */
27 :
28 : #ifndef _RTFSTRINGBUFFER_HXX_
29 : #define _RTFSTRINGBUFFER_HXX_
30 :
31 : #include <rtl/strbuf.hxx>
32 : #include <vector>
33 :
34 : class SwGrfNode;
35 : class SwFlyFrmFmt;
36 : class RtfAttributeOutput;
37 :
38 : /// Contains a buffered string or graphic during RTF export.
39 1736 : class RtfStringBufferValue
40 : {
41 : public:
42 : /// Constructor for a string buffering.
43 : RtfStringBufferValue();
44 : /// Constructor for graphic buffering.
45 : RtfStringBufferValue(const SwFlyFrmFmt* pFlyFrmFmt, const SwGrfNode* pGrfNode);
46 : /// This version handles graphics.
47 : void makeStringAndClear(RtfAttributeOutput* pAttributeOutput);
48 : /// This one doesn't.
49 : rtl::OString makeStringAndClear();
50 : bool isGraphic() const;
51 :
52 : rtl::OStringBuffer m_aBuffer;
53 : const SwFlyFrmFmt* m_pFlyFrmFmt;
54 : const SwGrfNode* m_pGrfNode;
55 : };
56 :
57 : /// Wrapper around OStringBuffers, so less hexdump of graphics have to be kept in memory during RTF export.
58 250 : class RtfStringBuffer
59 : {
60 : public:
61 : RtfStringBuffer();
62 : /// Length of all the contained buffers.
63 : sal_Int32 getLength() const;
64 : /// Writes the contents of the buffer directly to the supplied stream.
65 : void makeStringAndClear(RtfAttributeOutput* pAttributeOutput);
66 : /// Returns the bufferent strings as a string (ignores graphic elements!)
67 : rtl::OString makeStringAndClear();
68 : /// Access to the last buffer.
69 : rtl::OStringBuffer& getLastBuffer();
70 : rtl::OStringBuffer* operator->();
71 : /// Similar to ->setLength(0), but for all buffers.
72 : void clear();
73 : /// Same as ->append(), but for graphics and without expanding contents to save memory.
74 : void append(const SwFlyFrmFmt* pFlyFrmFmt, const SwGrfNode* pGrfNode);
75 : /// Append all contained buffers and clear the argument.
76 : void appendAndClear(RtfStringBuffer& rBuf);
77 : private:
78 : typedef std::vector<RtfStringBufferValue> Values_t;
79 : Values_t m_aValues;
80 : };
81 :
82 : #endif // _RTFSTRINGBUFFER_HXX_
83 :
84 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|