1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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/.
10 #include <rtfreferenceproperties.hxx>
12 namespace writerfilter
{
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
)
24 m_bForceString(bForceString
)
26 m_pAttributes
.reset(new RTFSprms(rAttributes
));
27 m_pSprms
.reset(new RTFSprms(rSprms
));
30 RTFValue::RTFValue(int nValue
)
38 m_pAttributes
.reset(new RTFSprms());
39 m_pSprms
.reset(new RTFSprms());
42 RTFValue::RTFValue(OUString sValue
, bool bForce
)
48 m_bForceString(bForce
)
50 m_pAttributes
.reset(new RTFSprms());
51 m_pSprms
.reset(new RTFSprms());
54 RTFValue::RTFValue(RTFSprms rAttributes
)
62 m_pAttributes
.reset(new RTFSprms(rAttributes
));
63 m_pSprms
.reset(new RTFSprms());
66 RTFValue::RTFValue(RTFSprms rAttributes
, RTFSprms rSprms
)
74 m_pAttributes
.reset(new RTFSprms(rAttributes
));
75 m_pSprms
.reset(new RTFSprms(rSprms
));
78 RTFValue::RTFValue(uno::Reference
<drawing::XShape
> rShape
)
86 m_pAttributes
.reset(new RTFSprms());
87 m_pSprms
.reset(new RTFSprms());
90 RTFValue::RTFValue(uno::Reference
<io::XInputStream
> rStream
)
98 m_pAttributes
.reset(new RTFSprms());
99 m_pSprms
.reset(new RTFSprms());
102 RTFValue::RTFValue(uno::Reference
<embed::XEmbeddedObject
> 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
123 OUString
RTFValue::getString() const
125 if (!m_sValue
.isEmpty() || m_bForceString
)
128 return OUString::valueOf(sal_Int32(m_nValue
));
131 void RTFValue::setString(OUString sValue
)
136 uno::Any
RTFValue::getAny() const
139 if (!m_sValue
.isEmpty() || m_bForceString
)
141 else if (m_xShape
.is())
143 else if (m_xStream
.is())
145 else if (m_xObject
.is())
148 ret
<<= static_cast<sal_Int32
>(m_nValue
);
152 writerfilter::Reference
<Properties
>::Pointer_t
RTFValue::getProperties()
154 writerfilter::Reference
<Properties
>::Pointer_t
const pProperties(
155 new RTFReferenceProperties(*m_pAttributes
, *m_pSprms
)
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();
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()
198 } // namespace rtftok
199 } // namespace writerfilter
201 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */