lok: vcl: fix multiple floatwin removal case more robustly.
[LibreOffice.git] / svl / source / items / cintitem.cxx
blob4fc6c754c8ef2de7d6f8c950084fa64f82097e5f
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::Create(SvStream & rStream, sal_uInt16) const
67 short nTheValue = 0;
68 rStream.ReadInt16( nTheValue );
69 return new CntByteItem(Which(), sal_uInt8(nTheValue));
72 // virtual
73 SvStream & CntByteItem::Store(SvStream & rStream, sal_uInt16) const
75 rStream.WriteInt16( short(m_nValue) );
76 return rStream;
79 // virtual
80 SfxPoolItem * CntByteItem::Clone(SfxItemPool *) const
82 return new CntByteItem(*this);
86 CntUInt16Item::CntUInt16Item(sal_uInt16 which, SvStream & rStream) :
87 SfxPoolItem(which)
89 sal_uInt16 nTheValue = 0;
90 rStream.ReadUInt16( nTheValue );
91 m_nValue = nTheValue;
94 // virtual
95 bool CntUInt16Item::operator ==(const SfxPoolItem & rItem) const
97 assert(dynamic_cast<const CntUInt16Item*>(&rItem) != nullptr);
98 return m_nValue == static_cast<const CntUInt16Item *>(&rItem)->m_nValue;
101 // virtual
102 bool CntUInt16Item::GetPresentation(SfxItemPresentation,
103 MapUnit, MapUnit,
104 OUString & rText,
105 const IntlWrapper&)
106 const
108 rText = OUString::number( m_nValue );
109 return true;
112 // virtual
113 bool CntUInt16Item::QueryValue(css::uno::Any& rVal, sal_uInt8) const
115 sal_Int32 nValue = m_nValue;
116 rVal <<= nValue;
117 return true;
120 // virtual
121 bool CntUInt16Item::PutValue(const css::uno::Any& rVal, sal_uInt8)
123 sal_Int32 nValue = 0;
124 if (rVal >>= nValue)
126 SAL_WARN_IF(nValue < 0 || nValue > SAL_MAX_UINT16, "svl.items", "Overflow in UInt16 value!");
127 m_nValue = static_cast<sal_uInt16>(nValue);
128 return true;
131 SAL_WARN("svl.items", "CntUInt16Item::PutValue - Wrong type!");
132 return false;
135 // virtual
136 SfxPoolItem * CntUInt16Item::Create(SvStream & rStream, sal_uInt16) const
138 return new CntUInt16Item(Which(), rStream);
141 // virtual
142 SvStream & CntUInt16Item::Store(SvStream &rStream, sal_uInt16) const
144 rStream.WriteUInt16( m_nValue );
145 return rStream;
148 // virtual
149 SfxPoolItem * CntUInt16Item::Clone(SfxItemPool *) const
151 return new CntUInt16Item(*this);
155 CntInt32Item::CntInt32Item(sal_uInt16 which, SvStream & rStream)
156 : SfxPoolItem(which)
157 , m_nValue(0)
159 rStream.ReadInt32( m_nValue );
162 // virtual
163 bool CntInt32Item::operator ==(const SfxPoolItem & rItem) const
165 assert(dynamic_cast<const CntInt32Item*>(&rItem) != nullptr);
166 return m_nValue == static_cast<const CntInt32Item *>(&rItem)->m_nValue;
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 SfxPoolItem * CntInt32Item::Create(SvStream & rStream, sal_uInt16) const
204 return new CntInt32Item(Which(), rStream);
207 // virtual
208 SvStream & CntInt32Item::Store(SvStream &rStream, sal_uInt16) const
210 rStream.WriteInt32( m_nValue );
211 return rStream;
214 // virtual
215 SfxPoolItem * CntInt32Item::Clone(SfxItemPool *) const
217 return new CntInt32Item(*this);
221 CntUInt32Item::CntUInt32Item(sal_uInt16 which, SvStream & rStream) :
222 SfxPoolItem(which)
224 sal_uInt32 nTheValue = 0;
225 rStream.ReadUInt32( nTheValue );
226 m_nValue = nTheValue;
229 // virtual
230 bool CntUInt32Item::operator ==(const SfxPoolItem & rItem) const
232 assert(dynamic_cast<const CntUInt32Item*>(&rItem) != nullptr);
233 return m_nValue == static_cast<const CntUInt32Item *>(&rItem)->m_nValue;
236 // virtual
237 bool CntUInt32Item::GetPresentation(SfxItemPresentation,
238 MapUnit, MapUnit,
239 OUString & rText,
240 const IntlWrapper&)
241 const
243 rText = OUString::number(m_nValue);
244 return true;
247 // virtual
248 bool CntUInt32Item::QueryValue(css::uno::Any& rVal, sal_uInt8) const
250 sal_Int32 nValue = m_nValue;
251 SAL_WARN_IF(nValue < 0, "svl.items", "Overflow in UInt32 value!");
252 rVal <<= nValue;
253 return true;
256 // virtual
257 bool CntUInt32Item::PutValue(const css::uno::Any& rVal, sal_uInt8)
259 sal_Int32 nValue = 0;
260 if (rVal >>= nValue)
262 SAL_WARN_IF(nValue < 0, "svl.items", "Overflow in UInt32 value!");
263 m_nValue = nValue;
264 return true;
267 SAL_WARN("svl.items", "CntUInt32Item::PutValue - Wrong type!");
268 return false;
271 // virtual
272 SfxPoolItem * CntUInt32Item::Create(SvStream & rStream, sal_uInt16) const
274 return new CntUInt32Item(Which(), rStream);
277 // virtual
278 SvStream & CntUInt32Item::Store(SvStream &rStream, sal_uInt16) const
280 rStream.WriteUInt32( m_nValue );
281 return rStream;
284 // virtual
285 SfxPoolItem * CntUInt32Item::Clone(SfxItemPool *) const
287 return new CntUInt32Item(*this);
290 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */