1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: intitem.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_svtools.hxx"
34 #include <svtools/intitem.hxx>
35 #include <com/sun/star/uno/Any.hxx>
36 #include <tools/bigint.hxx>
37 #include <tools/stream.hxx>
38 #include <svtools/metitem.hxx>
40 //============================================================================
44 //============================================================================
46 TYPEINIT1_AUTOFACTORY(SfxByteItem
, CntByteItem
);
48 //============================================================================
50 SfxPoolItem
* SfxByteItem::Create(SvStream
& rStream
, USHORT
) const
54 return new SfxByteItem(Which(), BYTE(nValue
));
57 //============================================================================
61 //============================================================================
63 DBG_NAME(SfxInt16Item
);
65 //============================================================================
66 TYPEINIT1_AUTOFACTORY(SfxInt16Item
, SfxPoolItem
);
68 //============================================================================
69 SfxInt16Item::SfxInt16Item(USHORT which
, SvStream
& rStream
):
72 DBG_CTOR(SfxInt16Item
, 0);
78 //============================================================================
80 int SfxInt16Item::operator ==(const SfxPoolItem
& rItem
) const
82 DBG_CHKTHIS(SfxInt16Item
, 0);
83 DBG_ASSERT(SfxPoolItem::operator ==(rItem
), "unequal type");
84 return m_nValue
== SAL_STATIC_CAST(const SfxInt16Item
*, &rItem
)->
88 //============================================================================
90 int SfxInt16Item::Compare(const SfxPoolItem
& rWith
) const
92 DBG_CHKTHIS(SfxInt16Item
, 0);
93 DBG_ASSERT(SfxPoolItem::operator ==(rWith
), "unequal type");
94 return SAL_STATIC_CAST(const SfxInt16Item
*, &rWith
)->m_nValue
97 SAL_STATIC_CAST(const SfxInt16Item
*, &rWith
)->m_nValue
102 //============================================================================
104 SfxItemPresentation
SfxInt16Item::GetPresentation(SfxItemPresentation
,
105 SfxMapUnit
, SfxMapUnit
,
107 const IntlWrapper
*) const
109 DBG_CHKTHIS(SfxInt16Item
, 0);
110 rText
= UniString::CreateFromInt32(m_nValue
);
111 return SFX_ITEM_PRESENTATION_NAMELESS
;
115 //============================================================================
117 BOOL
SfxInt16Item::QueryValue(com::sun::star::uno::Any
& rVal
, BYTE
) const
119 sal_Int16 nValue
= m_nValue
;
124 //============================================================================
126 BOOL
SfxInt16Item::PutValue(const com::sun::star::uno::Any
& rVal
, BYTE
)
128 sal_Int16 nValue
= sal_Int16();
135 DBG_ERROR( "SfxInt16Item::PutValue - Wrong type!" );
139 //============================================================================
141 SfxPoolItem
* SfxInt16Item::Create(SvStream
& rStream
, USHORT
) const
143 DBG_CHKTHIS(SfxInt16Item
, 0);
144 return new SfxInt16Item(Which(), rStream
);
147 //============================================================================
149 SvStream
& SfxInt16Item::Store(SvStream
& rStream
, USHORT
) const
151 DBG_CHKTHIS(SfxInt16Item
, 0);
152 rStream
<< short(m_nValue
);
156 //============================================================================
157 SfxPoolItem
* SfxInt16Item::Clone(SfxItemPool
*) const
159 DBG_CHKTHIS(SfxInt16Item
, 0);
160 return new SfxInt16Item(*this);
163 //============================================================================
164 INT16
SfxInt16Item::GetMin() const
166 DBG_CHKTHIS(SfxInt16Item
, 0);
170 //============================================================================
171 INT16
SfxInt16Item::GetMax() const
173 DBG_CHKTHIS(SfxInt16Item
, 0);
177 //============================================================================
178 SfxFieldUnit
SfxInt16Item::GetUnit() const
180 DBG_CHKTHIS(SfxInt16Item
, 0);
181 return SFX_FUNIT_NONE
;
184 //============================================================================
186 // class SfxUInt16Item
188 //============================================================================
190 TYPEINIT1_AUTOFACTORY(SfxUInt16Item
, CntUInt16Item
);
193 //============================================================================
195 // class SfxInt32Item
197 //============================================================================
199 TYPEINIT1_AUTOFACTORY(SfxInt32Item
, CntInt32Item
);
202 //============================================================================
204 // class SfxUInt32Item
206 //============================================================================
208 TYPEINIT1_AUTOFACTORY(SfxUInt32Item
, CntUInt32Item
);
211 //============================================================================
213 // class SfxMetricItem
215 //============================================================================
217 DBG_NAME(SfxMetricItem
);
219 //============================================================================
220 TYPEINIT1_AUTOFACTORY(SfxMetricItem
, SfxInt32Item
);
222 //============================================================================
223 SfxMetricItem::SfxMetricItem(USHORT which
, UINT32 nValue
):
224 SfxInt32Item(which
, nValue
)
226 DBG_CTOR(SfxMetricItem
, 0);
229 //============================================================================
230 SfxMetricItem::SfxMetricItem(USHORT which
, SvStream
& rStream
):
231 SfxInt32Item(which
, rStream
)
233 DBG_CTOR(SfxMetricItem
, 0);
236 //============================================================================
237 SfxMetricItem::SfxMetricItem(const SfxMetricItem
& rItem
):
240 DBG_CTOR(SfxMetricItem
, 0);
243 //============================================================================
245 int SfxMetricItem::ScaleMetrics(long nMult
, long nDiv
)
247 BigInt
aTheValue(GetValue());
249 aTheValue
+= nDiv
/ 2;
255 //============================================================================
257 int SfxMetricItem::HasMetrics() const