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: cintitem.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"
33 #include <com/sun/star/uno/Any.hxx>
34 #include <tools/stream.hxx>
35 #include <svtools/cintitem.hxx>
37 //============================================================================
41 //============================================================================
45 //============================================================================
46 TYPEINIT1_AUTOFACTORY(CntByteItem
, SfxPoolItem
);
48 //============================================================================
49 CntByteItem::CntByteItem(USHORT which
, SvStream
& rStream
):
52 DBG_CTOR(CntByteItem
, 0);
56 //============================================================================
58 int CntByteItem::operator ==(const SfxPoolItem
& rItem
) const
60 DBG_CHKTHIS(CntByteItem
, 0);
61 DBG_ASSERT(rItem
.ISA(CntByteItem
),
62 "CntByteItem::operator ==(): Bad type");
63 return m_nValue
== SAL_STATIC_CAST(const CntByteItem
*, &rItem
)->m_nValue
;
66 //============================================================================
68 int CntByteItem::Compare(const SfxPoolItem
& rWith
) const
70 DBG_CHKTHIS(CntByteItem
, 0);
71 DBG_ASSERT(rWith
.ISA(CntByteItem
), "CntByteItem::Compare(): Bad type");
72 return SAL_STATIC_CAST(const CntByteItem
*, &rWith
)->m_nValue
< m_nValue
?
74 SAL_STATIC_CAST(const CntByteItem
*, &rWith
)->m_nValue
79 //============================================================================
81 SfxItemPresentation
CntByteItem::GetPresentation(SfxItemPresentation
,
82 SfxMapUnit
, SfxMapUnit
,
84 const IntlWrapper
*) const
86 DBG_CHKTHIS(CntByteItem
, 0);
87 rText
= XubString::CreateFromInt32(m_nValue
);
88 return SFX_ITEM_PRESENTATION_NAMELESS
;
91 //============================================================================
93 BOOL
CntByteItem::QueryValue(com::sun::star::uno::Any
& rVal
,BYTE
) const
95 sal_Int8 nValue
= m_nValue
;
100 //============================================================================
102 BOOL
CntByteItem::PutValue(const com::sun::star::uno::Any
& rVal
,BYTE
)
104 sal_Int8 nValue
= sal_Int8();
111 DBG_ERROR( "CntByteItem::PutValue - Wrong type!" );
115 //============================================================================
117 SfxPoolItem
* CntByteItem::Create(SvStream
& rStream
, USHORT
) const
119 DBG_CHKTHIS(CntByteItem
, 0);
121 rStream
>> nTheValue
;
122 return new CntByteItem(Which(), BYTE(nTheValue
));
125 //============================================================================
127 SvStream
& CntByteItem::Store(SvStream
& rStream
, USHORT
) const
129 DBG_CHKTHIS(CntByteItem
, 0);
130 rStream
<< short(m_nValue
);
134 //============================================================================
136 SfxPoolItem
* CntByteItem::Clone(SfxItemPool
*) const
138 DBG_CHKTHIS(CntByteItem
, 0);
139 return new CntByteItem(*this);
142 //============================================================================
144 BYTE
CntByteItem::GetMin() const
146 DBG_CHKTHIS(CntByteItem
, 0);
150 //============================================================================
152 BYTE
CntByteItem::GetMax() const
154 DBG_CHKTHIS(CntByteItem
, 0);
158 //============================================================================
160 SfxFieldUnit
CntByteItem::GetUnit() const
162 DBG_CHKTHIS(CntByteItem
, 0);
163 return SFX_FUNIT_NONE
;
166 //============================================================================
168 // class CntUInt16Item
170 //============================================================================
172 DBG_NAME(CntUInt16Item
);
174 //============================================================================
175 TYPEINIT1_AUTOFACTORY(CntUInt16Item
, SfxPoolItem
);
177 //============================================================================
178 CntUInt16Item::CntUInt16Item(USHORT which
, SvStream
& rStream
) :
181 DBG_CTOR(CntUInt16Item
, 0);
182 USHORT nTheValue
= 0;
183 rStream
>> nTheValue
;
184 m_nValue
= nTheValue
;
187 //============================================================================
189 int CntUInt16Item::operator ==(const SfxPoolItem
& rItem
) const
191 DBG_CHKTHIS(CntUInt16Item
, 0);
192 DBG_ASSERT(rItem
.ISA(CntUInt16Item
),
193 "CntUInt16Item::operator ==(): Bad type");
194 return m_nValue
== SAL_STATIC_CAST(const CntUInt16Item
*, &rItem
)->
198 //============================================================================
200 int CntUInt16Item::Compare(const SfxPoolItem
& rWith
) const
202 DBG_CHKTHIS(CntUInt16Item
, 0);
203 DBG_ASSERT(rWith
.ISA(CntUInt16Item
),
204 "CntUInt16Item::Compare(): Bad type");
205 return SAL_STATIC_CAST(const CntUInt16Item
*, &rWith
)->m_nValue
208 SAL_STATIC_CAST(const CntUInt16Item
*, &rWith
)->m_nValue
213 //============================================================================
215 SfxItemPresentation
CntUInt16Item::GetPresentation(SfxItemPresentation
,
216 SfxMapUnit
, SfxMapUnit
,
221 DBG_CHKTHIS(CntUInt16Item
, 0);
222 rText
= XubString::CreateFromInt32(m_nValue
);
223 return SFX_ITEM_PRESENTATION_NAMELESS
;
226 //============================================================================
228 BOOL
CntUInt16Item::QueryValue(com::sun::star::uno::Any
& rVal
,BYTE
) const
230 sal_Int32 nValue
= m_nValue
;
235 //============================================================================
237 BOOL
CntUInt16Item::PutValue(const com::sun::star::uno::Any
& rVal
,BYTE
)
239 sal_Int32 nValue
= 0;
242 DBG_ASSERT( nValue
<= USHRT_MAX
, "Overflow in UInt16 value!");
243 m_nValue
= (sal_uInt16
)nValue
;
247 DBG_ERROR( "CntUInt16Item::PutValue - Wrong type!" );
251 //============================================================================
253 SfxPoolItem
* CntUInt16Item::Create(SvStream
& rStream
, USHORT
) const
255 DBG_CHKTHIS(CntUInt16Item
, 0);
256 return new CntUInt16Item(Which(), rStream
);
259 //============================================================================
261 SvStream
& CntUInt16Item::Store(SvStream
&rStream
, USHORT
) const
263 DBG_CHKTHIS(CntUInt16Item
, 0);
264 rStream
<< USHORT(m_nValue
);
268 //============================================================================
270 SfxPoolItem
* CntUInt16Item::Clone(SfxItemPool
*) const
272 DBG_CHKTHIS(CntUInt16Item
, 0);
273 return new CntUInt16Item(*this);
276 //============================================================================
278 UINT16
CntUInt16Item::GetMin() const
280 DBG_CHKTHIS(CntUInt16Item
, 0);
284 //============================================================================
286 UINT16
CntUInt16Item::GetMax() const
288 DBG_CHKTHIS(CntUInt16Item
, 0);
292 //============================================================================
294 SfxFieldUnit
CntUInt16Item::GetUnit() const
296 DBG_CHKTHIS(CntUInt16Item
, 0);
297 return SFX_FUNIT_NONE
;
300 //============================================================================
302 // class CntInt32Item
304 //============================================================================
306 DBG_NAME(CntInt32Item
);
308 //============================================================================
309 TYPEINIT1_AUTOFACTORY(CntInt32Item
, SfxPoolItem
);
311 //============================================================================
312 CntInt32Item::CntInt32Item(USHORT which
, SvStream
& rStream
) :
315 DBG_CTOR(CntInt32Item
, 0);
317 rStream
>> nTheValue
;
318 m_nValue
= nTheValue
;
321 //============================================================================
323 int CntInt32Item::operator ==(const SfxPoolItem
& rItem
) const
325 DBG_CHKTHIS(CntInt32Item
, 0);
326 DBG_ASSERT(rItem
.ISA(CntInt32Item
),
327 "CntInt32Item::operator ==(): Bad type");
328 return m_nValue
== SAL_STATIC_CAST(const CntInt32Item
*, &rItem
)->
332 //============================================================================
334 int CntInt32Item::Compare(const SfxPoolItem
& rWith
) const
336 DBG_CHKTHIS(CntInt32Item
, 0);
337 DBG_ASSERT(rWith
.ISA(CntInt32Item
), "CntInt32Item::Compare(): Bad type");
338 return SAL_STATIC_CAST(const CntInt32Item
*, &rWith
)->m_nValue
341 SAL_STATIC_CAST(const CntInt32Item
*, &rWith
)->m_nValue
346 //============================================================================
348 SfxItemPresentation
CntInt32Item::GetPresentation(SfxItemPresentation
,
349 SfxMapUnit
, SfxMapUnit
,
351 const IntlWrapper
*) const
353 DBG_CHKTHIS(CntInt32Item
, 0);
354 rText
= XubString::CreateFromInt32(m_nValue
);
355 return SFX_ITEM_PRESENTATION_NAMELESS
;
358 //============================================================================
360 BOOL
CntInt32Item::QueryValue(com::sun::star::uno::Any
& rVal
,BYTE
) const
362 sal_Int32 nValue
= m_nValue
;
367 //============================================================================
369 BOOL
CntInt32Item::PutValue(const com::sun::star::uno::Any
& rVal
,BYTE
)
371 sal_Int32 nValue
= 0;
378 DBG_ERROR( "CntInt32Item::PutValue - Wrong type!" );
382 //============================================================================
384 SfxPoolItem
* CntInt32Item::Create(SvStream
& rStream
, USHORT
) const
386 DBG_CHKTHIS(CntInt32Item
, 0);
387 return new CntInt32Item(Which(), rStream
);
390 //============================================================================
392 SvStream
& CntInt32Item::Store(SvStream
&rStream
, USHORT
) const
394 DBG_CHKTHIS(CntInt32Item
, 0);
395 rStream
<< long(m_nValue
);
399 //============================================================================
401 SfxPoolItem
* CntInt32Item::Clone(SfxItemPool
*) const
403 DBG_CHKTHIS(CntInt32Item
, 0);
404 return new CntInt32Item(*this);
407 //============================================================================
409 INT32
CntInt32Item::GetMin() const
411 DBG_CHKTHIS(CntInt32Item
, 0);
412 return INT32(0x80000000);
415 //============================================================================
417 INT32
CntInt32Item::GetMax() const
419 DBG_CHKTHIS(CntInt32Item
, 0);
423 //============================================================================
425 SfxFieldUnit
CntInt32Item::GetUnit() const
427 DBG_CHKTHIS(CntInt32Item
, 0);
428 return SFX_FUNIT_NONE
;
431 //============================================================================
433 // class CntUInt32Item
435 //============================================================================
437 DBG_NAME(CntUInt32Item
);
439 //============================================================================
440 TYPEINIT1_AUTOFACTORY(CntUInt32Item
, SfxPoolItem
);
442 //============================================================================
443 CntUInt32Item::CntUInt32Item(USHORT which
, SvStream
& rStream
) :
446 DBG_CTOR(CntUInt32Item
, 0);
447 sal_uInt32 nTheValue
= 0;
448 rStream
>> nTheValue
;
449 m_nValue
= nTheValue
;
452 //============================================================================
454 int CntUInt32Item::operator ==(const SfxPoolItem
& rItem
) const
456 DBG_CHKTHIS(CntUInt32Item
, 0);
457 DBG_ASSERT(rItem
.ISA(CntUInt32Item
),
458 "CntUInt32Item::operator ==(): Bad type");
459 return m_nValue
== SAL_STATIC_CAST(const CntUInt32Item
*, &rItem
)->
463 //============================================================================
465 int CntUInt32Item::Compare(const SfxPoolItem
& rWith
) const
467 DBG_CHKTHIS(CntUInt32Item
, 0);
468 DBG_ASSERT(rWith
.ISA(CntUInt32Item
),
469 "CntUInt32Item::operator ==(): Bad type");
470 return SAL_STATIC_CAST(const CntUInt32Item
*, &rWith
)->m_nValue
473 SAL_STATIC_CAST(const CntUInt32Item
*, &rWith
)->m_nValue
478 //============================================================================
480 SfxItemPresentation
CntUInt32Item::GetPresentation(SfxItemPresentation
,
481 SfxMapUnit
, SfxMapUnit
,
486 DBG_CHKTHIS(CntUInt32Item
, 0);
487 rText
= XubString::CreateFromInt64(m_nValue
);
488 return SFX_ITEM_PRESENTATION_NAMELESS
;
491 //============================================================================
493 BOOL
CntUInt32Item::QueryValue(com::sun::star::uno::Any
& rVal
,BYTE
) const
495 sal_Int32 nValue
= m_nValue
;
496 DBG_ASSERT( nValue
>=0, "Overflow in UInt32 value!");
501 //============================================================================
503 BOOL
CntUInt32Item::PutValue(const com::sun::star::uno::Any
& rVal
,BYTE
)
505 sal_Int32 nValue
= 0;
508 DBG_ASSERT( nValue
>=0, "Overflow in UInt32 value!");
513 DBG_ERROR( "CntUInt32Item::PutValue - Wrong type!" );
517 //============================================================================
519 SfxPoolItem
* CntUInt32Item::Create(SvStream
& rStream
, USHORT
) const
521 DBG_CHKTHIS(CntUInt32Item
, 0);
522 return new CntUInt32Item(Which(), rStream
);
525 //============================================================================
527 SvStream
& CntUInt32Item::Store(SvStream
&rStream
, USHORT
) const
529 DBG_CHKTHIS(CntUInt32Item
, 0);
530 rStream
<< static_cast<sal_uInt32
>(m_nValue
);
534 //============================================================================
536 SfxPoolItem
* CntUInt32Item::Clone(SfxItemPool
*) const
538 DBG_CHKTHIS(CntUInt32Item
, 0);
539 return new CntUInt32Item(*this);
542 //============================================================================
544 UINT32
CntUInt32Item::GetMin() const
546 DBG_CHKTHIS(CntUInt32Item
, 0);
550 //============================================================================
552 UINT32
CntUInt32Item::GetMax() const
554 DBG_CHKTHIS(CntUInt32Item
, 0);
558 //============================================================================
560 SfxFieldUnit
CntUInt32Item::GetUnit() const
562 DBG_CHKTHIS(CntUInt32Item
, 0);
563 return SFX_FUNIT_NONE
;