1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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>
24 //============================================================================
28 //============================================================================
32 //============================================================================
33 TYPEINIT1_AUTOFACTORY(CntByteItem
, SfxPoolItem
);
35 //============================================================================
37 int CntByteItem::operator ==(const SfxPoolItem
& rItem
) const
39 DBG_CHKTHIS(CntByteItem
, 0);
40 DBG_ASSERT(rItem
.ISA(CntByteItem
),
41 "CntByteItem::operator ==(): Bad type");
42 return m_nValue
== (static_cast< const CntByteItem
* >(&rItem
))->m_nValue
;
45 //============================================================================
47 int CntByteItem::Compare(const SfxPoolItem
& rWith
) const
49 DBG_CHKTHIS(CntByteItem
, 0);
50 DBG_ASSERT(rWith
.ISA(CntByteItem
), "CntByteItem::Compare(): Bad type");
51 return (static_cast< const CntByteItem
* >(&rWith
))->m_nValue
< m_nValue
?
53 (static_cast< const CntByteItem
* >(&rWith
))->m_nValue
58 //============================================================================
60 SfxItemPresentation
CntByteItem::GetPresentation(SfxItemPresentation
,
61 SfxMapUnit
, SfxMapUnit
,
63 const IntlWrapper
*) const
65 DBG_CHKTHIS(CntByteItem
, 0);
66 rText
= OUString::number( m_nValue
);
67 return SFX_ITEM_PRESENTATION_NAMELESS
;
70 //============================================================================
72 bool CntByteItem::QueryValue(com::sun::star::uno::Any
& rVal
, sal_uInt8
) const
74 sal_Int8 nValue
= m_nValue
;
79 //============================================================================
81 bool CntByteItem::PutValue(const com::sun::star::uno::Any
& rVal
, sal_uInt8
)
83 sal_Int8 nValue
= sal_Int8();
90 OSL_FAIL( "CntByteItem::PutValue - Wrong type!" );
94 //============================================================================
96 SfxPoolItem
* CntByteItem::Create(SvStream
& rStream
, sal_uInt16
) const
98 DBG_CHKTHIS(CntByteItem
, 0);
100 rStream
>> nTheValue
;
101 return new CntByteItem(Which(), sal_uInt8(nTheValue
));
104 //============================================================================
106 SvStream
& CntByteItem::Store(SvStream
& rStream
, sal_uInt16
) const
108 DBG_CHKTHIS(CntByteItem
, 0);
109 rStream
<< short(m_nValue
);
113 //============================================================================
115 SfxPoolItem
* CntByteItem::Clone(SfxItemPool
*) const
117 DBG_CHKTHIS(CntByteItem
, 0);
118 return new CntByteItem(*this);
121 //============================================================================
123 sal_uInt8
CntByteItem::GetMin() const
125 DBG_CHKTHIS(CntByteItem
, 0);
129 //============================================================================
131 sal_uInt8
CntByteItem::GetMax() const
133 DBG_CHKTHIS(CntByteItem
, 0);
137 //============================================================================
139 SfxFieldUnit
CntByteItem::GetUnit() const
141 DBG_CHKTHIS(CntByteItem
, 0);
142 return SFX_FUNIT_NONE
;
145 //============================================================================
147 // class CntUInt16Item
149 //============================================================================
151 DBG_NAME(CntUInt16Item
);
153 //============================================================================
154 TYPEINIT1_AUTOFACTORY(CntUInt16Item
, SfxPoolItem
);
156 //============================================================================
157 CntUInt16Item::CntUInt16Item(sal_uInt16 which
, SvStream
& rStream
) :
160 DBG_CTOR(CntUInt16Item
, 0);
161 sal_uInt16 nTheValue
= 0;
162 rStream
>> nTheValue
;
163 m_nValue
= nTheValue
;
166 //============================================================================
168 int CntUInt16Item::operator ==(const SfxPoolItem
& rItem
) const
170 DBG_CHKTHIS(CntUInt16Item
, 0);
171 DBG_ASSERT(rItem
.ISA(CntUInt16Item
),
172 "CntUInt16Item::operator ==(): Bad type");
173 return m_nValue
== (static_cast< const CntUInt16Item
* >(&rItem
))->
177 //============================================================================
179 int CntUInt16Item::Compare(const SfxPoolItem
& rWith
) const
181 DBG_CHKTHIS(CntUInt16Item
, 0);
182 DBG_ASSERT(rWith
.ISA(CntUInt16Item
),
183 "CntUInt16Item::Compare(): Bad type");
184 return (static_cast< const CntUInt16Item
* >(&rWith
))->m_nValue
187 (static_cast< const CntUInt16Item
* >(&rWith
))->m_nValue
192 //============================================================================
194 SfxItemPresentation
CntUInt16Item::GetPresentation(SfxItemPresentation
,
195 SfxMapUnit
, SfxMapUnit
,
200 DBG_CHKTHIS(CntUInt16Item
, 0);
201 rText
= OUString::number( m_nValue
);
202 return SFX_ITEM_PRESENTATION_NAMELESS
;
205 //============================================================================
207 bool CntUInt16Item::QueryValue(com::sun::star::uno::Any
& rVal
, sal_uInt8
) const
209 sal_Int32 nValue
= m_nValue
;
214 //============================================================================
216 bool CntUInt16Item::PutValue(const com::sun::star::uno::Any
& rVal
, sal_uInt8
)
218 sal_Int32 nValue
= 0;
221 DBG_ASSERT( nValue
<= USHRT_MAX
, "Overflow in UInt16 value!");
222 m_nValue
= (sal_uInt16
)nValue
;
226 OSL_FAIL( "CntUInt16Item::PutValue - Wrong type!" );
230 //============================================================================
232 SfxPoolItem
* CntUInt16Item::Create(SvStream
& rStream
, sal_uInt16
) const
234 DBG_CHKTHIS(CntUInt16Item
, 0);
235 return new CntUInt16Item(Which(), rStream
);
238 //============================================================================
240 SvStream
& CntUInt16Item::Store(SvStream
&rStream
, sal_uInt16
) const
242 DBG_CHKTHIS(CntUInt16Item
, 0);
243 rStream
<< sal_uInt16(m_nValue
);
247 //============================================================================
249 SfxPoolItem
* CntUInt16Item::Clone(SfxItemPool
*) const
251 DBG_CHKTHIS(CntUInt16Item
, 0);
252 return new CntUInt16Item(*this);
255 //============================================================================
257 sal_uInt16
CntUInt16Item::GetMin() const
259 DBG_CHKTHIS(CntUInt16Item
, 0);
263 //============================================================================
265 sal_uInt16
CntUInt16Item::GetMax() const
267 DBG_CHKTHIS(CntUInt16Item
, 0);
271 //============================================================================
273 SfxFieldUnit
CntUInt16Item::GetUnit() const
275 DBG_CHKTHIS(CntUInt16Item
, 0);
276 return SFX_FUNIT_NONE
;
279 //============================================================================
281 // class CntInt32Item
283 //============================================================================
285 DBG_NAME(CntInt32Item
);
287 //============================================================================
288 TYPEINIT1_AUTOFACTORY(CntInt32Item
, SfxPoolItem
);
290 //============================================================================
291 CntInt32Item::CntInt32Item(sal_uInt16 which
, SvStream
& rStream
) :
294 DBG_CTOR(CntInt32Item
, 0);
295 //fdo#39428 SvStream no longer supports operator>>(long&)
299 //============================================================================
301 int CntInt32Item::operator ==(const SfxPoolItem
& rItem
) const
303 DBG_CHKTHIS(CntInt32Item
, 0);
304 DBG_ASSERT(rItem
.ISA(CntInt32Item
),
305 "CntInt32Item::operator ==(): Bad type");
306 return m_nValue
== (static_cast< const CntInt32Item
* >(&rItem
))->
310 //============================================================================
312 int CntInt32Item::Compare(const SfxPoolItem
& rWith
) const
314 DBG_CHKTHIS(CntInt32Item
, 0);
315 DBG_ASSERT(rWith
.ISA(CntInt32Item
), "CntInt32Item::Compare(): Bad type");
316 return (static_cast< const CntInt32Item
* >(&rWith
))->m_nValue
319 (static_cast< const CntInt32Item
* >(&rWith
))->m_nValue
324 //============================================================================
326 SfxItemPresentation
CntInt32Item::GetPresentation(SfxItemPresentation
,
327 SfxMapUnit
, SfxMapUnit
,
329 const IntlWrapper
*) const
331 DBG_CHKTHIS(CntInt32Item
, 0);
332 rText
= OUString::number( m_nValue
);
333 return SFX_ITEM_PRESENTATION_NAMELESS
;
336 //============================================================================
338 bool CntInt32Item::QueryValue(com::sun::star::uno::Any
& rVal
, sal_uInt8
) const
340 sal_Int32 nValue
= m_nValue
;
345 //============================================================================
347 bool CntInt32Item::PutValue(const com::sun::star::uno::Any
& rVal
, sal_uInt8
)
349 sal_Int32 nValue
= 0;
356 OSL_FAIL( "CntInt32Item::PutValue - Wrong type!" );
360 //============================================================================
362 SfxPoolItem
* CntInt32Item::Create(SvStream
& rStream
, sal_uInt16
) const
364 DBG_CHKTHIS(CntInt32Item
, 0);
365 return new CntInt32Item(Which(), rStream
);
368 //============================================================================
370 SvStream
& CntInt32Item::Store(SvStream
&rStream
, sal_uInt16
) const
372 DBG_CHKTHIS(CntInt32Item
, 0);
373 //fdo#39428 SvStream no longer supports operator<<(long)
378 //============================================================================
380 SfxPoolItem
* CntInt32Item::Clone(SfxItemPool
*) const
382 DBG_CHKTHIS(CntInt32Item
, 0);
383 return new CntInt32Item(*this);
386 //============================================================================
388 sal_Int32
CntInt32Item::GetMin() const
390 DBG_CHKTHIS(CntInt32Item
, 0);
391 return sal_Int32(0x80000000);
394 //============================================================================
396 sal_Int32
CntInt32Item::GetMax() const
398 DBG_CHKTHIS(CntInt32Item
, 0);
402 //============================================================================
404 SfxFieldUnit
CntInt32Item::GetUnit() const
406 DBG_CHKTHIS(CntInt32Item
, 0);
407 return SFX_FUNIT_NONE
;
410 //============================================================================
412 // class CntUInt32Item
414 //============================================================================
416 DBG_NAME(CntUInt32Item
);
418 //============================================================================
419 TYPEINIT1_AUTOFACTORY(CntUInt32Item
, SfxPoolItem
);
421 //============================================================================
422 CntUInt32Item::CntUInt32Item(sal_uInt16 which
, SvStream
& rStream
) :
425 DBG_CTOR(CntUInt32Item
, 0);
426 sal_uInt32 nTheValue
= 0;
427 rStream
>> nTheValue
;
428 m_nValue
= nTheValue
;
431 //============================================================================
433 int CntUInt32Item::operator ==(const SfxPoolItem
& rItem
) const
435 DBG_CHKTHIS(CntUInt32Item
, 0);
436 DBG_ASSERT(rItem
.ISA(CntUInt32Item
),
437 "CntUInt32Item::operator ==(): Bad type");
438 return m_nValue
== (static_cast< const CntUInt32Item
* >(&rItem
))->
442 //============================================================================
444 int CntUInt32Item::Compare(const SfxPoolItem
& rWith
) const
446 DBG_CHKTHIS(CntUInt32Item
, 0);
447 DBG_ASSERT(rWith
.ISA(CntUInt32Item
),
448 "CntUInt32Item::operator ==(): Bad type");
449 return (static_cast< const CntUInt32Item
* >(&rWith
))->m_nValue
452 (static_cast< const CntUInt32Item
* >(&rWith
))->m_nValue
457 //============================================================================
459 SfxItemPresentation
CntUInt32Item::GetPresentation(SfxItemPresentation
,
460 SfxMapUnit
, SfxMapUnit
,
465 DBG_CHKTHIS(CntUInt32Item
, 0);
466 rText
= OUString::number(m_nValue
);
467 return SFX_ITEM_PRESENTATION_NAMELESS
;
470 //============================================================================
472 bool CntUInt32Item::QueryValue(com::sun::star::uno::Any
& rVal
, sal_uInt8
) const
474 sal_Int32 nValue
= m_nValue
;
475 DBG_ASSERT( nValue
>=0, "Overflow in UInt32 value!");
480 //============================================================================
482 bool CntUInt32Item::PutValue(const com::sun::star::uno::Any
& rVal
, sal_uInt8
)
484 sal_Int32 nValue
= 0;
487 DBG_ASSERT( nValue
>=0, "Overflow in UInt32 value!");
492 OSL_FAIL( "CntUInt32Item::PutValue - Wrong type!" );
496 //============================================================================
498 SfxPoolItem
* CntUInt32Item::Create(SvStream
& rStream
, sal_uInt16
) const
500 DBG_CHKTHIS(CntUInt32Item
, 0);
501 return new CntUInt32Item(Which(), rStream
);
504 //============================================================================
506 SvStream
& CntUInt32Item::Store(SvStream
&rStream
, sal_uInt16
) const
508 DBG_CHKTHIS(CntUInt32Item
, 0);
509 rStream
<< static_cast<sal_uInt32
>(m_nValue
);
513 //============================================================================
515 SfxPoolItem
* CntUInt32Item::Clone(SfxItemPool
*) const
517 DBG_CHKTHIS(CntUInt32Item
, 0);
518 return new CntUInt32Item(*this);
521 //============================================================================
523 sal_uInt32
CntUInt32Item::GetMin() const
525 DBG_CHKTHIS(CntUInt32Item
, 0);
529 //============================================================================
531 sal_uInt32
CntUInt32Item::GetMax() const
533 DBG_CHKTHIS(CntUInt32Item
, 0);
537 //============================================================================
539 SfxFieldUnit
CntUInt32Item::GetUnit() const
541 DBG_CHKTHIS(CntUInt32Item
, 0);
542 return SFX_FUNIT_NONE
;
545 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */