tdf#130857 qt weld: Implement QtInstanceWidget::strip_mnemonic
[LibreOffice.git] / svl / source / items / cintitem.cxx
blob3063af33e66d589b42506cb52c8e58b1b05eac98
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 <o3tl/hash_combine.hxx>
22 #include <svl/cintitem.hxx>
23 #include <sal/log.hxx>
26 // virtual
27 bool CntByteItem::operator ==(const SfxPoolItem & rItem) const
29 assert(SfxPoolItem::operator==(rItem));
30 return m_nValue == static_cast< const CntByteItem * >(&rItem)->m_nValue;
33 // virtual
34 bool CntByteItem::supportsHashCode() const
36 return true;
39 // virtual
40 size_t CntByteItem::hashCode() const
42 std::size_t seed(0);
43 o3tl::hash_combine(seed, Which());
44 o3tl::hash_combine(seed, m_nValue);
45 return seed;
48 // virtual
49 bool CntByteItem::GetPresentation(SfxItemPresentation, MapUnit, MapUnit,
50 OUString & rText,
51 const IntlWrapper&) const
53 rText = OUString::number( m_nValue );
54 return true;
57 // virtual
58 bool CntByteItem::QueryValue(css::uno::Any& rVal, sal_uInt8) const
60 sal_Int8 nValue = m_nValue;
61 rVal <<= nValue;
62 return true;
65 // virtual
66 bool CntByteItem::PutValue(const css::uno::Any& rVal, sal_uInt8)
68 sal_Int8 nValue = sal_Int8();
69 if (rVal >>= nValue)
71 m_nValue = nValue;
72 return true;
75 SAL_WARN("svl.items", "CntByteItem::PutValue - Wrong type!");
76 return false;
79 // virtual
80 CntByteItem* CntByteItem::Clone(SfxItemPool *) const
82 return new CntByteItem(*this);
85 // virtual
86 bool CntUInt16Item::operator ==(const SfxPoolItem & rItem) const
88 assert(SfxPoolItem::operator==(rItem));
89 return m_nValue == static_cast<const CntUInt16Item *>(&rItem)->m_nValue;
92 // virtual
93 bool CntUInt16Item::supportsHashCode() const
95 return true;
98 // virtual
99 size_t CntUInt16Item::hashCode() const
101 std::size_t seed(0);
102 o3tl::hash_combine(seed, Which());
103 o3tl::hash_combine(seed, m_nValue);
104 return seed;
107 // virtual
108 bool CntUInt16Item::GetPresentation(SfxItemPresentation,
109 MapUnit, MapUnit,
110 OUString & rText,
111 const IntlWrapper&)
112 const
114 rText = OUString::number( m_nValue );
115 return true;
118 // virtual
119 bool CntUInt16Item::QueryValue(css::uno::Any& rVal, sal_uInt8) const
121 sal_Int32 nValue = m_nValue;
122 rVal <<= nValue;
123 return true;
126 // virtual
127 bool CntUInt16Item::PutValue(const css::uno::Any& rVal, sal_uInt8)
129 sal_Int32 nValue = 0;
130 if (rVal >>= nValue)
132 SAL_WARN_IF(nValue < 0 || nValue > SAL_MAX_UINT16, "svl.items", "Overflow in UInt16 value!");
133 m_nValue = static_cast<sal_uInt16>(nValue);
134 return true;
137 SAL_WARN("svl.items", "CntUInt16Item::PutValue - Wrong type!");
138 return false;
141 // virtual
142 CntUInt16Item* CntUInt16Item::Clone(SfxItemPool *) const
144 return new CntUInt16Item(*this);
147 // virtual
148 bool CntInt32Item::operator ==(const SfxPoolItem & rItem) const
150 assert(SfxPoolItem::operator==(rItem));
151 return m_nValue == static_cast<const CntInt32Item *>(&rItem)->m_nValue;
154 // virtual
155 bool CntInt32Item::supportsHashCode() const
157 return true;
160 // virtual
161 size_t CntInt32Item::hashCode() const
163 std::size_t seed(0);
164 o3tl::hash_combine(seed, Which());
165 o3tl::hash_combine(seed, m_nValue);
166 return seed;
169 // virtual
170 bool CntInt32Item::GetPresentation(SfxItemPresentation,
171 MapUnit, MapUnit,
172 OUString & rText,
173 const IntlWrapper&) const
175 rText = OUString::number( m_nValue );
176 return true;
179 // virtual
180 bool CntInt32Item::QueryValue(css::uno::Any& rVal, sal_uInt8) const
182 sal_Int32 nValue = m_nValue;
183 rVal <<= nValue;
184 return true;
187 // virtual
188 bool CntInt32Item::PutValue(const css::uno::Any& rVal, sal_uInt8)
190 sal_Int32 nValue = 0;
191 if (rVal >>= nValue)
193 m_nValue = nValue;
194 return true;
197 SAL_WARN("svl.items", "CntInt32Item::PutValue - Wrong type!");
198 return false;
201 // virtual
202 CntInt32Item* CntInt32Item::Clone(SfxItemPool *) const
204 return new CntInt32Item(*this);
207 // virtual
208 bool CntUInt32Item::operator ==(const SfxPoolItem & rItem) const
210 assert(SfxPoolItem::operator==(rItem));
211 return m_nValue == static_cast<const CntUInt32Item *>(&rItem)->m_nValue;
214 // virtual
215 bool CntUInt32Item::supportsHashCode() const
217 return true;
220 // virtual
221 size_t CntUInt32Item::hashCode() const
223 std::size_t seed(0);
224 o3tl::hash_combine(seed, Which());
225 o3tl::hash_combine(seed, m_nValue);
226 return seed;
229 // virtual
230 bool CntUInt32Item::GetPresentation(SfxItemPresentation,
231 MapUnit, MapUnit,
232 OUString & rText,
233 const IntlWrapper&)
234 const
236 rText = OUString::number(m_nValue);
237 return true;
240 // virtual
241 bool CntUInt32Item::QueryValue(css::uno::Any& rVal, sal_uInt8) const
243 sal_Int32 nValue = m_nValue;
244 SAL_WARN_IF(nValue < 0, "svl.items", "Overflow in UInt32 value!");
245 rVal <<= nValue;
246 return true;
249 // virtual
250 bool CntUInt32Item::PutValue(const css::uno::Any& rVal, sal_uInt8)
252 sal_Int32 nValue = 0;
253 if (rVal >>= nValue)
255 SAL_WARN_IF(nValue < 0, "svl.items", "Overflow in UInt32 value!");
256 m_nValue = nValue;
257 return true;
260 SAL_WARN("svl.items", "CntUInt32Item::PutValue - Wrong type!");
261 return false;
264 // virtual
265 CntUInt32Item* CntUInt32Item::Clone(SfxItemPool *) const
267 return new CntUInt32Item(*this);
270 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */