bump product version to 6.3.0.0.beta1
[LibreOffice.git] / svl / source / items / cintitem.cxx
blob4545a8ae2cc5fa4831481d992982538eaddae3e2
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 <tools/stream.hxx>
22 #include <svl/cintitem.hxx>
23 #include <sal/log.hxx>
26 // virtual
27 bool CntByteItem::operator ==(const SfxPoolItem & rItem) const
29 assert(dynamic_cast<const CntByteItem*>(&rItem) != nullptr);
30 return m_nValue == static_cast< const CntByteItem * >(&rItem)->m_nValue;
33 // virtual
34 bool CntByteItem::GetPresentation(SfxItemPresentation, MapUnit, MapUnit,
35 OUString & rText,
36 const IntlWrapper&) const
38 rText = OUString::number( m_nValue );
39 return true;
42 // virtual
43 bool CntByteItem::QueryValue(css::uno::Any& rVal, sal_uInt8) const
45 sal_Int8 nValue = m_nValue;
46 rVal <<= nValue;
47 return true;
50 // virtual
51 bool CntByteItem::PutValue(const css::uno::Any& rVal, sal_uInt8)
53 sal_Int8 nValue = sal_Int8();
54 if (rVal >>= nValue)
56 m_nValue = nValue;
57 return true;
60 SAL_WARN("svl.items", "CntByteItem::PutValue - Wrong type!");
61 return false;
64 // virtual
65 SfxPoolItem * CntByteItem::Clone(SfxItemPool *) const
67 return new CntByteItem(*this);
71 // virtual
72 bool CntUInt16Item::operator ==(const SfxPoolItem & rItem) const
74 assert(dynamic_cast<const CntUInt16Item*>(&rItem) != nullptr);
75 return m_nValue == static_cast<const CntUInt16Item *>(&rItem)->m_nValue;
78 // virtual
79 bool CntUInt16Item::GetPresentation(SfxItemPresentation,
80 MapUnit, MapUnit,
81 OUString & rText,
82 const IntlWrapper&)
83 const
85 rText = OUString::number( m_nValue );
86 return true;
89 // virtual
90 bool CntUInt16Item::QueryValue(css::uno::Any& rVal, sal_uInt8) const
92 sal_Int32 nValue = m_nValue;
93 rVal <<= nValue;
94 return true;
97 // virtual
98 bool CntUInt16Item::PutValue(const css::uno::Any& rVal, sal_uInt8)
100 sal_Int32 nValue = 0;
101 if (rVal >>= nValue)
103 SAL_WARN_IF(nValue < 0 || nValue > SAL_MAX_UINT16, "svl.items", "Overflow in UInt16 value!");
104 m_nValue = static_cast<sal_uInt16>(nValue);
105 return true;
108 SAL_WARN("svl.items", "CntUInt16Item::PutValue - Wrong type!");
109 return false;
112 // virtual
113 SfxPoolItem * CntUInt16Item::Clone(SfxItemPool *) const
115 return new CntUInt16Item(*this);
119 // virtual
120 bool CntInt32Item::operator ==(const SfxPoolItem & rItem) const
122 assert(dynamic_cast<const CntInt32Item*>(&rItem) != nullptr);
123 return m_nValue == static_cast<const CntInt32Item *>(&rItem)->m_nValue;
126 // virtual
127 bool CntInt32Item::GetPresentation(SfxItemPresentation,
128 MapUnit, MapUnit,
129 OUString & rText,
130 const IntlWrapper&) const
132 rText = OUString::number( m_nValue );
133 return true;
136 // virtual
137 bool CntInt32Item::QueryValue(css::uno::Any& rVal, sal_uInt8) const
139 sal_Int32 nValue = m_nValue;
140 rVal <<= nValue;
141 return true;
144 // virtual
145 bool CntInt32Item::PutValue(const css::uno::Any& rVal, sal_uInt8)
147 sal_Int32 nValue = 0;
148 if (rVal >>= nValue)
150 m_nValue = nValue;
151 return true;
154 SAL_WARN("svl.items", "CntInt32Item::PutValue - Wrong type!");
155 return false;
158 // virtual
159 SfxPoolItem * CntInt32Item::Clone(SfxItemPool *) const
161 return new CntInt32Item(*this);
165 // virtual
166 bool CntUInt32Item::operator ==(const SfxPoolItem & rItem) const
168 assert(dynamic_cast<const CntUInt32Item*>(&rItem) != nullptr);
169 return m_nValue == static_cast<const CntUInt32Item *>(&rItem)->m_nValue;
172 // virtual
173 bool CntUInt32Item::GetPresentation(SfxItemPresentation,
174 MapUnit, MapUnit,
175 OUString & rText,
176 const IntlWrapper&)
177 const
179 rText = OUString::number(m_nValue);
180 return true;
183 // virtual
184 bool CntUInt32Item::QueryValue(css::uno::Any& rVal, sal_uInt8) const
186 sal_Int32 nValue = m_nValue;
187 SAL_WARN_IF(nValue < 0, "svl.items", "Overflow in UInt32 value!");
188 rVal <<= nValue;
189 return true;
192 // virtual
193 bool CntUInt32Item::PutValue(const css::uno::Any& rVal, sal_uInt8)
195 sal_Int32 nValue = 0;
196 if (rVal >>= nValue)
198 SAL_WARN_IF(nValue < 0, "svl.items", "Overflow in UInt32 value!");
199 m_nValue = nValue;
200 return true;
203 SAL_WARN("svl.items", "CntUInt32Item::PutValue - Wrong type!");
204 return false;
207 // virtual
208 SfxPoolItem * CntUInt32Item::Clone(SfxItemPool *) const
210 return new CntUInt32Item(*this);
213 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */