Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : */
9 :
10 : #include <rtfreferenceproperties.hxx>
11 : #include <rtfdocumentimpl.hxx>
12 :
13 : namespace writerfilter {
14 : namespace rtftok {
15 :
16 :
17 65938 : RTFValue::RTFValue(int nValue, OUString sValue, RTFSprms rAttributes,
18 : RTFSprms rSprms, uno::Reference<drawing::XShape> xShape,
19 : uno::Reference<io::XInputStream> xStream, uno::Reference<embed::XEmbeddedObject> xObject, bool bForceString,
20 : RTFShape aShape)
21 : : m_nValue(nValue),
22 : m_sValue(sValue),
23 : m_xShape(xShape),
24 : m_xStream(xStream),
25 : m_xObject(xObject),
26 65938 : m_bForceString(bForceString)
27 : {
28 65938 : m_pAttributes.reset(new RTFSprms(rAttributes));
29 65938 : m_pSprms.reset(new RTFSprms(rSprms));
30 65938 : m_pShape.reset(new RTFShape(aShape));
31 65938 : }
32 :
33 29969 : RTFValue::RTFValue(int nValue)
34 : : m_nValue(nValue),
35 : m_sValue(),
36 : m_xShape(),
37 : m_xStream(),
38 : m_xObject(),
39 29969 : m_bForceString(false)
40 : {
41 29969 : m_pAttributes.reset(new RTFSprms());
42 29969 : m_pSprms.reset(new RTFSprms());
43 29969 : m_pShape.reset(new RTFShape());
44 29969 : }
45 :
46 1531 : RTFValue::RTFValue(OUString sValue, bool bForce)
47 : : m_nValue(),
48 : m_sValue(sValue),
49 : m_xShape(),
50 : m_xStream(),
51 : m_xObject(),
52 1531 : m_bForceString(bForce)
53 : {
54 1531 : m_pAttributes.reset(new RTFSprms());
55 1531 : m_pSprms.reset(new RTFSprms());
56 1531 : m_pShape.reset(new RTFShape());
57 1531 : }
58 :
59 1316 : RTFValue::RTFValue(RTFSprms rAttributes)
60 : : m_nValue(),
61 : m_sValue(),
62 : m_xShape(),
63 : m_xStream(),
64 : m_xObject(),
65 1316 : m_bForceString(false)
66 : {
67 1316 : m_pAttributes.reset(new RTFSprms(rAttributes));
68 1316 : m_pSprms.reset(new RTFSprms());
69 1316 : m_pShape.reset(new RTFShape());
70 1316 : }
71 :
72 1341 : RTFValue::RTFValue(RTFSprms rAttributes, RTFSprms rSprms)
73 : : m_nValue(),
74 : m_sValue(),
75 : m_xShape(),
76 : m_xStream(),
77 : m_xObject(),
78 1341 : m_bForceString(false)
79 : {
80 1341 : m_pAttributes.reset(new RTFSprms(rAttributes));
81 1341 : m_pSprms.reset(new RTFSprms(rSprms));
82 1341 : m_pShape.reset(new RTFShape());
83 1341 : }
84 :
85 12 : RTFValue::RTFValue(uno::Reference<drawing::XShape> rShape)
86 : : m_nValue(),
87 : m_sValue(),
88 : m_xShape(rShape),
89 : m_xStream(),
90 : m_xObject(),
91 12 : m_bForceString(false)
92 : {
93 12 : m_pAttributes.reset(new RTFSprms());
94 12 : m_pSprms.reset(new RTFSprms());
95 12 : m_pShape.reset(new RTFShape());
96 12 : }
97 :
98 0 : RTFValue::RTFValue(uno::Reference<io::XInputStream> rStream)
99 : : m_nValue(),
100 : m_sValue(),
101 : m_xShape(),
102 : m_xStream(rStream),
103 : m_xObject(),
104 0 : m_bForceString(false)
105 : {
106 0 : m_pAttributes.reset(new RTFSprms());
107 0 : m_pSprms.reset(new RTFSprms());
108 0 : m_pShape.reset(new RTFShape());
109 0 : }
110 :
111 61 : RTFValue::RTFValue(uno::Reference<embed::XEmbeddedObject> xObject)
112 : : m_nValue(),
113 : m_sValue(),
114 : m_xShape(),
115 : m_xStream(),
116 : m_xObject(xObject),
117 61 : m_bForceString(false)
118 : {
119 61 : m_pAttributes.reset(new RTFSprms());
120 61 : m_pSprms.reset(new RTFSprms());
121 61 : m_pShape.reset(new RTFShape());
122 61 : }
123 :
124 1 : RTFValue::RTFValue(RTFShape aShape)
125 : : m_nValue(),
126 : m_sValue(),
127 : m_xShape(),
128 : m_xStream(),
129 : m_xObject(),
130 1 : m_bForceString(false)
131 : {
132 1 : m_pAttributes.reset(new RTFSprms());
133 1 : m_pSprms.reset(new RTFSprms());
134 1 : m_pShape.reset(new RTFShape(aShape));
135 1 : }
136 :
137 200338 : RTFValue::~RTFValue()
138 : {
139 200338 : }
140 :
141 65778 : int RTFValue::getInt() const
142 : {
143 65778 : return m_nValue;
144 : }
145 :
146 25726 : OUString RTFValue::getString() const
147 : {
148 25726 : if (!m_sValue.isEmpty() || m_bForceString)
149 1413 : return m_sValue;
150 : else
151 24313 : return OUString::valueOf(sal_Int32(m_nValue));
152 : }
153 :
154 32 : void RTFValue::setString(OUString sValue)
155 : {
156 32 : m_sValue = sValue;
157 32 : }
158 :
159 134 : uno::Any RTFValue::getAny() const
160 : {
161 134 : uno::Any ret;
162 134 : if (!m_sValue.isEmpty() || m_bForceString)
163 0 : ret <<= m_sValue;
164 134 : else if (m_xShape.is())
165 12 : ret <<= m_xShape;
166 122 : else if (m_xStream.is())
167 0 : ret <<= m_xStream;
168 122 : else if (m_xObject.is())
169 122 : ret <<= m_xObject;
170 : else
171 0 : ret <<= static_cast<sal_Int32>(m_nValue);
172 134 : return ret;
173 : }
174 :
175 1 : RTFShape& RTFValue::getShape() const
176 : {
177 1 : return *m_pShape;
178 : }
179 :
180 2075 : writerfilter::Reference<Properties>::Pointer_t RTFValue::getProperties()
181 : {
182 : writerfilter::Reference<Properties>::Pointer_t const pProperties(
183 6225 : new RTFReferenceProperties(*m_pAttributes, *m_pSprms)
184 6225 : );
185 2075 : return pProperties;
186 : }
187 :
188 0 : writerfilter::Reference<Stream>::Pointer_t RTFValue::getStream()
189 : {
190 0 : return writerfilter::Reference<Stream>::Pointer_t();
191 : }
192 :
193 0 : writerfilter::Reference<BinaryObj>::Pointer_t RTFValue::getBinary()
194 : {
195 0 : return writerfilter::Reference<BinaryObj>::Pointer_t();
196 : }
197 :
198 0 : std::string RTFValue::toString() const
199 : {
200 0 : if (!m_sValue.isEmpty() || m_bForceString)
201 0 : return OUStringToOString(m_sValue, RTL_TEXTENCODING_UTF8).getStr();
202 : else
203 0 : return OString::number(m_nValue).getStr();
204 : }
205 :
206 65938 : RTFValue* RTFValue::Clone()
207 : {
208 65938 : return new RTFValue(m_nValue, m_sValue, *m_pAttributes, *m_pSprms, m_xShape, m_xStream, m_xObject, m_bForceString, *m_pShape);
209 : }
210 :
211 1381 : bool RTFValue::equals(RTFValue& rOther)
212 : {
213 1381 : return m_nValue == rOther.m_nValue;
214 : }
215 :
216 2990 : RTFSprms& RTFValue::getAttributes()
217 : {
218 2990 : return *m_pAttributes;
219 : }
220 :
221 2548 : RTFSprms& RTFValue::getSprms()
222 : {
223 2548 : return *m_pSprms;
224 : }
225 :
226 : } // namespace rtftok
227 24 : } // namespace writerfilter
228 :
229 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|