OInterfaceContainerHelper3 needs to be thread-safe
[LibreOffice.git] / svl / source / items / cintitem.cxx
blob0f522f7a92602b653bafe28040827780f8efbc56
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/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <com/sun/star/uno/Any.hxx>
21 #include <svl/cintitem.hxx>
22 #include <sal/log.hxx>
25 // virtual
26 bool CntByteItem::operator ==(const SfxPoolItem & rItem) const
28 assert(dynamic_cast<const CntByteItem*>(&rItem) != nullptr);
29 return m_nValue == static_cast< const CntByteItem * >(&rItem)->m_nValue;
32 // virtual
33 bool CntByteItem::GetPresentation(SfxItemPresentation, MapUnit, MapUnit,
34 OUString & rText,
35 const IntlWrapper&) const
37 rText = OUString::number( m_nValue );
38 return true;
41 // virtual
42 bool CntByteItem::QueryValue(css::uno::Any& rVal, sal_uInt8) const
44 sal_Int8 nValue = m_nValue;
45 rVal <<= nValue;
46 return true;
49 // virtual
50 bool CntByteItem::PutValue(const css::uno::Any& rVal, sal_uInt8)
52 sal_Int8 nValue = sal_Int8();
53 if (rVal >>= nValue)
55 m_nValue = nValue;
56 return true;
59 SAL_WARN("svl.items", "CntByteItem::PutValue - Wrong type!");
60 return false;
63 // virtual
64 CntByteItem* CntByteItem::Clone(SfxItemPool *) const
66 return new CntByteItem(*this);
69 // virtual
70 bool CntUInt16Item::operator ==(const SfxPoolItem & rItem) const
72 assert(dynamic_cast<const CntUInt16Item*>(&rItem) != nullptr);
73 return m_nValue == static_cast<const CntUInt16Item *>(&rItem)->m_nValue;
76 // virtual
77 bool CntUInt16Item::GetPresentation(SfxItemPresentation,
78 MapUnit, MapUnit,
79 OUString & rText,
80 const IntlWrapper&)
81 const
83 rText = OUString::number( m_nValue );
84 return true;
87 // virtual
88 bool CntUInt16Item::QueryValue(css::uno::Any& rVal, sal_uInt8) const
90 sal_Int32 nValue = m_nValue;
91 rVal <<= nValue;
92 return true;
95 // virtual
96 bool CntUInt16Item::PutValue(const css::uno::Any& rVal, sal_uInt8)
98 sal_Int32 nValue = 0;
99 if (rVal >>= nValue)
101 SAL_WARN_IF(nValue < 0 || nValue > SAL_MAX_UINT16, "svl.items", "Overflow in UInt16 value!");
102 m_nValue = static_cast<sal_uInt16>(nValue);
103 return true;
106 SAL_WARN("svl.items", "CntUInt16Item::PutValue - Wrong type!");
107 return false;
110 // virtual
111 CntUInt16Item* CntUInt16Item::Clone(SfxItemPool *) const
113 return new CntUInt16Item(*this);
116 // virtual
117 bool CntInt32Item::operator ==(const SfxPoolItem & rItem) const
119 assert(dynamic_cast<const CntInt32Item*>(&rItem) != nullptr);
120 return m_nValue == static_cast<const CntInt32Item *>(&rItem)->m_nValue;
123 // virtual
124 bool CntInt32Item::GetPresentation(SfxItemPresentation,
125 MapUnit, MapUnit,
126 OUString & rText,
127 const IntlWrapper&) const
129 rText = OUString::number( m_nValue );
130 return true;
133 // virtual
134 bool CntInt32Item::QueryValue(css::uno::Any& rVal, sal_uInt8) const
136 sal_Int32 nValue = m_nValue;
137 rVal <<= nValue;
138 return true;
141 // virtual
142 bool CntInt32Item::PutValue(const css::uno::Any& rVal, sal_uInt8)
144 sal_Int32 nValue = 0;
145 if (rVal >>= nValue)
147 m_nValue = nValue;
148 return true;
151 SAL_WARN("svl.items", "CntInt32Item::PutValue - Wrong type!");
152 return false;
155 // virtual
156 CntInt32Item* CntInt32Item::Clone(SfxItemPool *) const
158 return new CntInt32Item(*this);
161 // virtual
162 bool CntUInt32Item::operator ==(const SfxPoolItem & rItem) const
164 assert(dynamic_cast<const CntUInt32Item*>(&rItem) != nullptr);
165 return m_nValue == static_cast<const CntUInt32Item *>(&rItem)->m_nValue;
168 // virtual
169 bool CntUInt32Item::GetPresentation(SfxItemPresentation,
170 MapUnit, MapUnit,
171 OUString & rText,
172 const IntlWrapper&)
173 const
175 rText = OUString::number(m_nValue);
176 return true;
179 // virtual
180 bool CntUInt32Item::QueryValue(css::uno::Any& rVal, sal_uInt8) const
182 sal_Int32 nValue = m_nValue;
183 SAL_WARN_IF(nValue < 0, "svl.items", "Overflow in UInt32 value!");
184 rVal <<= nValue;
185 return true;
188 // virtual
189 bool CntUInt32Item::PutValue(const css::uno::Any& rVal, sal_uInt8)
191 sal_Int32 nValue = 0;
192 if (rVal >>= nValue)
194 SAL_WARN_IF(nValue < 0, "svl.items", "Overflow in UInt32 value!");
195 m_nValue = nValue;
196 return true;
199 SAL_WARN("svl.items", "CntUInt32Item::PutValue - Wrong type!");
200 return false;
203 // virtual
204 CntUInt32Item* CntUInt32Item::Clone(SfxItemPool *) const
206 return new CntUInt32Item(*this);
209 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */