bump product version to 4.1.6.2
[LibreOffice.git] / writerfilter / source / rtftok / rtfvalue.cxx
bloba9f31f8740c754eb235ec2343b453a02b57f4942
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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 */
10 #include <rtfreferenceproperties.hxx>
12 namespace writerfilter {
13 namespace rtftok {
16 RTFValue::RTFValue(int nValue, OUString sValue, RTFSprms rAttributes,
17 RTFSprms rSprms, uno::Reference<drawing::XShape> xShape,
18 uno::Reference<io::XInputStream> xStream, uno::Reference<embed::XEmbeddedObject> xObject, bool bForceString)
19 : m_nValue(nValue),
20 m_sValue(sValue),
21 m_xShape(xShape),
22 m_xStream(xStream),
23 m_xObject(xObject),
24 m_bForceString(bForceString)
26 m_pAttributes.reset(new RTFSprms(rAttributes));
27 m_pSprms.reset(new RTFSprms(rSprms));
30 RTFValue::RTFValue(int nValue)
31 : m_nValue(nValue),
32 m_sValue(),
33 m_xShape(),
34 m_xStream(),
35 m_xObject(),
36 m_bForceString(false)
38 m_pAttributes.reset(new RTFSprms());
39 m_pSprms.reset(new RTFSprms());
42 RTFValue::RTFValue(OUString sValue, bool bForce)
43 : m_nValue(),
44 m_sValue(sValue),
45 m_xShape(),
46 m_xStream(),
47 m_xObject(),
48 m_bForceString(bForce)
50 m_pAttributes.reset(new RTFSprms());
51 m_pSprms.reset(new RTFSprms());
54 RTFValue::RTFValue(RTFSprms rAttributes)
55 : m_nValue(),
56 m_sValue(),
57 m_xShape(),
58 m_xStream(),
59 m_xObject(),
60 m_bForceString(false)
62 m_pAttributes.reset(new RTFSprms(rAttributes));
63 m_pSprms.reset(new RTFSprms());
66 RTFValue::RTFValue(RTFSprms rAttributes, RTFSprms rSprms)
67 : m_nValue(),
68 m_sValue(),
69 m_xShape(),
70 m_xStream(),
71 m_xObject(),
72 m_bForceString(false)
74 m_pAttributes.reset(new RTFSprms(rAttributes));
75 m_pSprms.reset(new RTFSprms(rSprms));
78 RTFValue::RTFValue(uno::Reference<drawing::XShape> rShape)
79 : m_nValue(),
80 m_sValue(),
81 m_xShape(rShape),
82 m_xStream(),
83 m_xObject(),
84 m_bForceString(false)
86 m_pAttributes.reset(new RTFSprms());
87 m_pSprms.reset(new RTFSprms());
90 RTFValue::RTFValue(uno::Reference<io::XInputStream> rStream)
91 : m_nValue(),
92 m_sValue(),
93 m_xShape(),
94 m_xStream(rStream),
95 m_xObject(),
96 m_bForceString(false)
98 m_pAttributes.reset(new RTFSprms());
99 m_pSprms.reset(new RTFSprms());
102 RTFValue::RTFValue(uno::Reference<embed::XEmbeddedObject> xObject)
103 : m_nValue(),
104 m_sValue(),
105 m_xShape(),
106 m_xStream(),
107 m_xObject(xObject),
108 m_bForceString(false)
110 m_pAttributes.reset(new RTFSprms());
111 m_pSprms.reset(new RTFSprms());
114 RTFValue::~RTFValue()
118 int RTFValue::getInt() const
120 return m_nValue;
123 OUString RTFValue::getString() const
125 if (!m_sValue.isEmpty() || m_bForceString)
126 return m_sValue;
127 else
128 return OUString::valueOf(sal_Int32(m_nValue));
131 void RTFValue::setString(OUString sValue)
133 m_sValue = sValue;
136 uno::Any RTFValue::getAny() const
138 uno::Any ret;
139 if (!m_sValue.isEmpty() || m_bForceString)
140 ret <<= m_sValue;
141 else if (m_xShape.is())
142 ret <<= m_xShape;
143 else if (m_xStream.is())
144 ret <<= m_xStream;
145 else if (m_xObject.is())
146 ret <<= m_xObject;
147 else
148 ret <<= static_cast<sal_Int32>(m_nValue);
149 return ret;
152 writerfilter::Reference<Properties>::Pointer_t RTFValue::getProperties()
154 writerfilter::Reference<Properties>::Pointer_t const pProperties(
155 new RTFReferenceProperties(*m_pAttributes, *m_pSprms)
157 return pProperties;
160 writerfilter::Reference<Stream>::Pointer_t RTFValue::getStream()
162 return writerfilter::Reference<Stream>::Pointer_t();
165 writerfilter::Reference<BinaryObj>::Pointer_t RTFValue::getBinary()
167 return writerfilter::Reference<BinaryObj>::Pointer_t();
170 std::string RTFValue::toString() const
172 if (!m_sValue.isEmpty() || m_bForceString)
173 return OUStringToOString(m_sValue, RTL_TEXTENCODING_UTF8).getStr();
174 else
175 return OString::number(m_nValue).getStr();
178 RTFValue* RTFValue::Clone()
180 return new RTFValue(m_nValue, m_sValue, *m_pAttributes, *m_pSprms, m_xShape, m_xStream, m_xObject, m_bForceString);
183 bool RTFValue::equals(RTFValue& rOther)
185 return m_nValue == rOther.m_nValue;
188 RTFSprms& RTFValue::getAttributes()
190 return *m_pAttributes;
193 RTFSprms& RTFValue::getSprms()
195 return *m_pSprms;
198 } // namespace rtftok
199 } // namespace writerfilter
201 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */