GPU-Calc: remove Alloc_Host_Ptr for clmem of NAN vector
[LibreOffice.git] / svl / source / items / intitem.cxx
blobb8cd293f108b7fe17f8440329f898775c28a4989
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 .
21 #include <svl/intitem.hxx>
22 #include <com/sun/star/uno/Any.hxx>
23 #include <tools/bigint.hxx>
24 #include <tools/stream.hxx>
25 #include <svl/metitem.hxx>
28 // class SfxByteItem
31 TYPEINIT1_AUTOFACTORY(SfxByteItem, CntByteItem);
33 // virtual
34 SfxPoolItem * SfxByteItem::Create(SvStream & rStream, sal_uInt16) const
36 short nValue = 0;
37 rStream >> nValue;
38 return new SfxByteItem(Which(), sal_uInt8(nValue));
42 // class SfxInt16Item
45 DBG_NAME(SfxInt16Item);
47 TYPEINIT1_AUTOFACTORY(SfxInt16Item, SfxPoolItem);
49 SfxInt16Item::SfxInt16Item(sal_uInt16 which, SvStream & rStream):
50 SfxPoolItem(which)
52 DBG_CTOR(SfxInt16Item, 0);
53 short nTheValue = 0;
54 rStream >> nTheValue;
55 m_nValue = nTheValue;
58 // virtual
59 int SfxInt16Item::operator ==(const SfxPoolItem & rItem) const
61 DBG_CHKTHIS(SfxInt16Item, 0);
62 DBG_ASSERT(SfxPoolItem::operator ==(rItem), "unequal type");
63 return m_nValue == (static_cast< const SfxInt16Item * >(&rItem))->
64 m_nValue;
67 // virtual
68 int SfxInt16Item::Compare(const SfxPoolItem & rWith) const
70 DBG_CHKTHIS(SfxInt16Item, 0);
71 DBG_ASSERT(SfxPoolItem::operator ==(rWith), "unequal type");
72 return (static_cast< const SfxInt16Item * >(&rWith))->m_nValue
73 < m_nValue ?
74 -1 :
75 (static_cast< const SfxInt16Item * >(&rWith))->m_nValue
76 == m_nValue ?
77 0 : 1;
80 // virtual
81 SfxItemPresentation SfxInt16Item::GetPresentation(SfxItemPresentation,
82 SfxMapUnit, SfxMapUnit,
83 OUString & rText,
84 const IntlWrapper *) const
86 DBG_CHKTHIS(SfxInt16Item, 0);
87 rText = OUString::number(m_nValue);
88 return SFX_ITEM_PRESENTATION_NAMELESS;
92 // virtual
93 bool SfxInt16Item::QueryValue(com::sun::star::uno::Any& rVal, sal_uInt8) const
95 sal_Int16 nValue = m_nValue;
96 rVal <<= nValue;
97 return true;
100 // virtual
101 bool SfxInt16Item::PutValue(const com::sun::star::uno::Any& rVal, sal_uInt8 )
103 sal_Int16 nValue = sal_Int16();
104 if (rVal >>= nValue)
106 m_nValue = nValue;
107 return true;
110 OSL_FAIL( "SfxInt16Item::PutValue - Wrong type!" );
111 return false;
114 // virtual
115 SfxPoolItem * SfxInt16Item::Create(SvStream & rStream, sal_uInt16) const
117 DBG_CHKTHIS(SfxInt16Item, 0);
118 return new SfxInt16Item(Which(), rStream);
121 // virtual
122 SvStream & SfxInt16Item::Store(SvStream & rStream, sal_uInt16) const
124 DBG_CHKTHIS(SfxInt16Item, 0);
125 rStream << short(m_nValue);
126 return rStream;
129 SfxPoolItem * SfxInt16Item::Clone(SfxItemPool *) const
131 DBG_CHKTHIS(SfxInt16Item, 0);
132 return new SfxInt16Item(*this);
135 sal_Int16 SfxInt16Item::GetMin() const
137 DBG_CHKTHIS(SfxInt16Item, 0);
138 return -32768;
141 sal_Int16 SfxInt16Item::GetMax() const
143 DBG_CHKTHIS(SfxInt16Item, 0);
144 return 32767;
147 SfxFieldUnit SfxInt16Item::GetUnit() const
149 DBG_CHKTHIS(SfxInt16Item, 0);
150 return SFX_FUNIT_NONE;
154 // class SfxUInt16Item
157 TYPEINIT1_AUTOFACTORY(SfxUInt16Item, CntUInt16Item);
161 // class SfxInt32Item
164 TYPEINIT1_AUTOFACTORY(SfxInt32Item, CntInt32Item);
168 // class SfxUInt32Item
171 TYPEINIT1_AUTOFACTORY(SfxUInt32Item, CntUInt32Item);
175 // class SfxMetricItem
178 DBG_NAME(SfxMetricItem);
180 TYPEINIT1_AUTOFACTORY(SfxMetricItem, SfxInt32Item);
182 SfxMetricItem::SfxMetricItem(sal_uInt16 which, sal_uInt32 nValue):
183 SfxInt32Item(which, nValue)
185 DBG_CTOR(SfxMetricItem, 0);
188 SfxMetricItem::SfxMetricItem(sal_uInt16 which, SvStream & rStream):
189 SfxInt32Item(which, rStream)
191 DBG_CTOR(SfxMetricItem, 0);
194 SfxMetricItem::SfxMetricItem(const SfxMetricItem & rItem):
195 SfxInt32Item(rItem)
197 DBG_CTOR(SfxMetricItem, 0);
200 // virtual
201 bool SfxMetricItem::ScaleMetrics(long nMult, long nDiv)
203 BigInt aTheValue(GetValue());
204 aTheValue *= nMult;
205 aTheValue += nDiv / 2;
206 aTheValue /= nDiv;
207 SetValue(aTheValue);
208 return true;
211 // virtual
212 bool SfxMetricItem::HasMetrics() const
214 return true;
217 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */