Branch data 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@frugalware.org>
16 : : * Portions created by the Initial Developer are Copyright (C) 2011 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 _RTFSPRM_HXX_
29 : : #define _RTFSPRM_HXX_
30 : :
31 : : #include <rtfcontrolwords.hxx>
32 : : #include <rtfvalue.hxx>
33 : :
34 : : namespace writerfilter {
35 : : namespace rtftok {
36 : : /// A list of RTFSprm with a copy constructor that performs a deep copy.
37 : 5824125 : class RTFSprms
38 : : {
39 : : public:
40 : : typedef ::boost::shared_ptr<RTFSprms> Pointer_t;
41 : : typedef std::pair<Id, RTFValue::Pointer_t> Entry_t;
42 : : typedef std::vector<Entry_t>::iterator Iterator_t;
43 : : RTFSprms();
44 : : RTFSprms(const RTFSprms& rSprms);
45 : : RTFSprms& operator=(const RTFSprms& rOther);
46 : : RTFValue::Pointer_t find(Id nKeyword);
47 : : /// Does the same as ->push_back(), except that it can overwrite existing entries.
48 : : void set(Id nKeyword, RTFValue::Pointer_t pValue, bool bOverwrite = true);
49 : : bool erase(Id nKeyword);
50 : : void swap(RTFSprms& rOther);
51 : 864 : size_t size() const { return m_aSprms.size(); }
52 : : bool empty() const { return m_aSprms.empty(); }
53 : 861 : Entry_t& back() { return m_aSprms.back(); }
54 : 45117 : Iterator_t begin() { return m_aSprms.begin(); }
55 : 116361 : Iterator_t end() { return m_aSprms.end(); }
56 : 12681 : void clear() { return m_aSprms.clear(); }
57 : : private:
58 : : std::vector< std::pair<Id, RTFValue::Pointer_t> > m_aSprms;
59 : : };
60 : :
61 : : /// RTF keyword with a parameter
62 : : class RTFSprm
63 : : : public Sprm
64 : : {
65 : : public:
66 : : RTFSprm(Id nKeyword, RTFValue::Pointer_t& pValue);
67 [ - + ]: 55998 : virtual ~RTFSprm() {}
68 : : virtual sal_uInt32 getId() const;
69 : : virtual Value::Pointer_t getValue();
70 : : virtual writerfilter::Reference<BinaryObj>::Pointer_t getBinary();
71 : : virtual writerfilter::Reference<Stream>::Pointer_t getStream();
72 : : virtual writerfilter::Reference<Properties>::Pointer_t getProps();
73 : : virtual Kind getKind();
74 : : virtual std::string getName() const;
75 : : virtual std::string toString() const;
76 : : private:
77 : : Id m_nKeyword;
78 : : RTFValue::Pointer_t& m_pValue;
79 : : };
80 : : } // namespace rtftok
81 : : } // namespace writerfilter
82 : :
83 : : #endif // _RTFSPRM_HXX_
84 : :
85 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|