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 : : #include <rtfreferenceproperties.hxx>
29 : :
30 : : namespace writerfilter {
31 : : namespace rtftok {
32 : :
33 : : using rtl::OString;
34 : : using rtl::OUString;
35 : :
36 : 1184832 : RTFValue::RTFValue(int nValue, rtl::OUString sValue, RTFSprms rAttributes,
37 : : RTFSprms rSprms, uno::Reference<drawing::XShape> xShape,
38 : : uno::Reference<io::XInputStream> xStream, uno::Reference<embed::XEmbeddedObject> xObject, bool bForceString)
39 : : : m_nValue(nValue),
40 : : m_sValue(sValue),
41 : : m_xShape(xShape),
42 : : m_xStream(xStream),
43 : : m_xObject(xObject),
44 [ + - ][ + - ]: 1184832 : m_bForceString(bForceString)
45 : : {
46 [ + - ][ + - ]: 1184832 : m_pAttributes.reset(new RTFSprms(rAttributes));
[ + - ]
47 [ + - ][ + - ]: 1184832 : m_pSprms.reset(new RTFSprms(rSprms));
[ + - ]
48 : 1184832 : }
49 : :
50 : 51540 : RTFValue::RTFValue(int nValue)
51 : : : m_nValue(nValue),
52 : : m_sValue(),
53 : : m_xShape(),
54 : : m_xStream(),
55 : : m_xObject(),
56 [ + - ][ + - ]: 51540 : m_bForceString(false)
57 : : {
58 [ + - ][ + - ]: 51540 : m_pAttributes.reset(new RTFSprms());
[ + - ]
59 [ + - ][ + - ]: 51540 : m_pSprms.reset(new RTFSprms());
[ + - ]
60 : 51540 : }
61 : :
62 : 2931 : RTFValue::RTFValue(OUString sValue, bool bForce)
63 : : : m_nValue(),
64 : : m_sValue(sValue),
65 : : m_xShape(),
66 : : m_xStream(),
67 : : m_xObject(),
68 [ + - ][ + - ]: 2931 : m_bForceString(bForce)
69 : : {
70 [ + - ][ + - ]: 2931 : m_pAttributes.reset(new RTFSprms());
[ + - ]
71 [ + - ][ + - ]: 2931 : m_pSprms.reset(new RTFSprms());
[ + - ]
72 : 2931 : }
73 : :
74 : 1917 : RTFValue::RTFValue(RTFSprms rAttributes)
75 : : : m_nValue(),
76 : : m_sValue(),
77 : : m_xShape(),
78 : : m_xStream(),
79 : : m_xObject(),
80 [ + - ][ + - ]: 1917 : m_bForceString(false)
81 : : {
82 [ + - ][ + - ]: 1917 : m_pAttributes.reset(new RTFSprms(rAttributes));
[ + - ]
83 [ + - ][ + - ]: 1917 : m_pSprms.reset(new RTFSprms());
[ + - ]
84 : 1917 : }
85 : :
86 : 2712 : RTFValue::RTFValue(RTFSprms rAttributes, RTFSprms rSprms)
87 : : : m_nValue(),
88 : : m_sValue(),
89 : : m_xShape(),
90 : : m_xStream(),
91 : : m_xObject(),
92 [ + - ][ + - ]: 2712 : m_bForceString(false)
93 : : {
94 [ + - ][ + - ]: 2712 : m_pAttributes.reset(new RTFSprms(rAttributes));
[ + - ]
95 [ + - ][ + - ]: 2712 : m_pSprms.reset(new RTFSprms(rSprms));
[ + - ]
96 : 2712 : }
97 : :
98 : 15 : RTFValue::RTFValue(uno::Reference<drawing::XShape> rShape)
99 : : : m_nValue(),
100 : : m_sValue(),
101 : : m_xShape(rShape),
102 : : m_xStream(),
103 : : m_xObject(),
104 [ + - ][ + - ]: 15 : m_bForceString(false)
105 : : {
106 [ + - ][ + - ]: 15 : m_pAttributes.reset(new RTFSprms());
[ + - ]
107 [ + - ][ + - ]: 15 : m_pSprms.reset(new RTFSprms());
[ + - ]
108 : 15 : }
109 : :
110 : 0 : RTFValue::RTFValue(uno::Reference<io::XInputStream> rStream)
111 : : : m_nValue(),
112 : : m_sValue(),
113 : : m_xShape(),
114 : : m_xStream(rStream),
115 : : m_xObject(),
116 [ # # ][ # # ]: 0 : m_bForceString(false)
117 : : {
118 [ # # ][ # # ]: 0 : m_pAttributes.reset(new RTFSprms());
[ # # ]
119 [ # # ][ # # ]: 0 : m_pSprms.reset(new RTFSprms());
[ # # ]
120 : 0 : }
121 : :
122 : 174 : RTFValue::RTFValue(uno::Reference<embed::XEmbeddedObject> xObject)
123 : : : m_nValue(),
124 : : m_sValue(),
125 : : m_xShape(),
126 : : m_xStream(),
127 : : m_xObject(xObject),
128 [ + - ][ + - ]: 174 : m_bForceString(false)
129 : : {
130 [ + - ][ + - ]: 174 : m_pAttributes.reset(new RTFSprms());
[ + - ]
131 [ + - ][ + - ]: 174 : m_pSprms.reset(new RTFSprms());
[ + - ]
132 : 174 : }
133 : :
134 [ + - ][ + - ]: 1244121 : RTFValue::~RTFValue()
135 : : {
136 [ - + ]: 2488242 : }
137 : :
138 : 167118 : int RTFValue::getInt() const
139 : : {
140 : 167118 : return m_nValue;
141 : : }
142 : :
143 : 64458 : OUString RTFValue::getString() const
144 : : {
145 [ + + ][ + + ]: 64458 : if (!m_sValue.isEmpty() || m_bForceString)
[ + + ]
146 : 2898 : return m_sValue;
147 : : else
148 : 64458 : return OUString::valueOf(sal_Int32(m_nValue));
149 : : }
150 : :
151 : 30 : void RTFValue::setString(OUString sValue)
152 : : {
153 : 30 : m_sValue = sValue;
154 : 30 : }
155 : :
156 : 363 : uno::Any RTFValue::getAny() const
157 : : {
158 : 363 : uno::Any ret;
159 [ - + ][ - + ]: 363 : if (!m_sValue.isEmpty() || m_bForceString)
[ + - ]
160 [ # # ]: 0 : ret <<= m_sValue;
161 [ + + ]: 363 : else if (m_xShape.is())
162 [ + - ]: 15 : ret <<= m_xShape;
163 [ - + ]: 348 : else if (m_xStream.is())
164 [ # # ]: 0 : ret <<= m_xStream;
165 [ + - ]: 348 : else if (m_xObject.is())
166 [ + - ]: 348 : ret <<= m_xObject;
167 : : else
168 [ # # ]: 0 : ret <<= static_cast<sal_Int32>(m_nValue);
169 : 363 : return ret;
170 : : }
171 : :
172 : 3252 : writerfilter::Reference<Properties>::Pointer_t RTFValue::getProperties()
173 : : {
174 : : writerfilter::Reference<Properties>::Pointer_t const pProperties(
175 [ + - ]: 9756 : new RTFReferenceProperties(*m_pAttributes, *m_pSprms)
176 [ + - ][ + - ]: 9756 : );
[ + - ]
177 : 3252 : return pProperties;
178 : : }
179 : :
180 : 0 : writerfilter::Reference<Stream>::Pointer_t RTFValue::getStream()
181 : : {
182 : 0 : return writerfilter::Reference<Stream>::Pointer_t();
183 : : }
184 : :
185 : 0 : writerfilter::Reference<BinaryObj>::Pointer_t RTFValue::getBinary()
186 : : {
187 : 0 : return writerfilter::Reference<BinaryObj>::Pointer_t();
188 : : }
189 : :
190 : 0 : std::string RTFValue::toString() const
191 : : {
192 [ # # ][ # # ]: 0 : if (!m_sValue.isEmpty() || m_bForceString)
[ # # ]
193 [ # # ][ # # ]: 0 : return OUStringToOString(m_sValue, RTL_TEXTENCODING_UTF8).getStr();
194 : : else
195 [ # # ]: 0 : return OString::valueOf(static_cast<sal_Int32>(m_nValue)).getStr();
196 : : }
197 : :
198 : 1184832 : RTFValue* RTFValue::Clone()
199 : : {
200 [ + - ][ + - ]: 1184832 : return new RTFValue(m_nValue, m_sValue, *m_pAttributes, *m_pSprms, m_xShape, m_xStream, m_xObject, m_bForceString);
[ + - ][ + - ]
201 : : }
202 : :
203 : 4674 : RTFSprms& RTFValue::getAttributes()
204 : : {
205 : 4674 : return *m_pAttributes;
206 : : }
207 : :
208 : 4611 : RTFSprms& RTFValue::getSprms()
209 : : {
210 : 4611 : return *m_pSprms;
211 : : }
212 : :
213 : : } // namespace rtftok
214 [ + - ][ + - ]: 60 : } // namespace writerfilter
215 : :
216 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|