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 <osl/diagnose.h>
22 #include <tools/stream.hxx>
23 #include <svl/cintitem.hxx>
25 TYPEINIT1_AUTOFACTORY(CntByteItem
, SfxPoolItem
);
28 bool CntByteItem::operator ==(const SfxPoolItem
& rItem
) const
30 DBG_ASSERT(rItem
.ISA(CntByteItem
),
31 "CntByteItem::operator ==(): Bad type");
32 return m_nValue
== (static_cast< const CntByteItem
* >(&rItem
))->m_nValue
;
36 int CntByteItem::Compare(const SfxPoolItem
& rWith
) const
38 DBG_ASSERT(rWith
.ISA(CntByteItem
), "CntByteItem::Compare(): Bad type");
39 return (static_cast< const CntByteItem
* >(&rWith
))->m_nValue
< m_nValue
?
41 (static_cast< const CntByteItem
* >(&rWith
))->m_nValue
47 bool CntByteItem::GetPresentation(SfxItemPresentation
,
48 SfxMapUnit
, SfxMapUnit
,
50 const IntlWrapper
*) const
52 rText
= OUString::number( m_nValue
);
57 bool CntByteItem::QueryValue(com::sun::star::uno::Any
& rVal
, sal_uInt8
) const
59 sal_Int8 nValue
= m_nValue
;
65 bool CntByteItem::PutValue(const com::sun::star::uno::Any
& rVal
, sal_uInt8
)
67 sal_Int8 nValue
= sal_Int8();
74 OSL_FAIL( "CntByteItem::PutValue - Wrong type!" );
79 SfxPoolItem
* CntByteItem::Create(SvStream
& rStream
, sal_uInt16
) const
82 rStream
.ReadInt16( nTheValue
);
83 return new CntByteItem(Which(), sal_uInt8(nTheValue
));
87 SvStream
& CntByteItem::Store(SvStream
& rStream
, sal_uInt16
) const
89 rStream
.WriteInt16( short(m_nValue
) );
94 SfxPoolItem
* CntByteItem::Clone(SfxItemPool
*) const
96 return new CntByteItem(*this);
99 TYPEINIT1_AUTOFACTORY(CntUInt16Item
, SfxPoolItem
);
101 CntUInt16Item::CntUInt16Item(sal_uInt16 which
, SvStream
& rStream
) :
104 sal_uInt16 nTheValue
= 0;
105 rStream
.ReadUInt16( nTheValue
);
106 m_nValue
= nTheValue
;
110 bool CntUInt16Item::operator ==(const SfxPoolItem
& rItem
) const
112 DBG_ASSERT(rItem
.ISA(CntUInt16Item
),
113 "CntUInt16Item::operator ==(): Bad type");
114 return m_nValue
== (static_cast< const CntUInt16Item
* >(&rItem
))->
119 int CntUInt16Item::Compare(const SfxPoolItem
& rWith
) const
121 DBG_ASSERT(rWith
.ISA(CntUInt16Item
),
122 "CntUInt16Item::Compare(): Bad type");
123 return (static_cast< const CntUInt16Item
* >(&rWith
))->m_nValue
126 (static_cast< const CntUInt16Item
* >(&rWith
))->m_nValue
132 bool CntUInt16Item::GetPresentation(SfxItemPresentation
,
133 SfxMapUnit
, SfxMapUnit
,
138 rText
= OUString::number( m_nValue
);
143 bool CntUInt16Item::QueryValue(com::sun::star::uno::Any
& rVal
, sal_uInt8
) const
145 sal_Int32 nValue
= m_nValue
;
151 bool CntUInt16Item::PutValue(const com::sun::star::uno::Any
& rVal
, sal_uInt8
)
153 sal_Int32 nValue
= 0;
156 DBG_ASSERT( nValue
<= USHRT_MAX
, "Overflow in UInt16 value!");
157 m_nValue
= (sal_uInt16
)nValue
;
161 OSL_FAIL( "CntUInt16Item::PutValue - Wrong type!" );
166 SfxPoolItem
* CntUInt16Item::Create(SvStream
& rStream
, sal_uInt16
) const
168 return new CntUInt16Item(Which(), rStream
);
172 SvStream
& CntUInt16Item::Store(SvStream
&rStream
, sal_uInt16
) const
174 rStream
.WriteUInt16( m_nValue
);
179 SfxPoolItem
* CntUInt16Item::Clone(SfxItemPool
*) const
181 return new CntUInt16Item(*this);
184 TYPEINIT1_AUTOFACTORY(CntInt32Item
, SfxPoolItem
);
186 CntInt32Item::CntInt32Item(sal_uInt16 which
, SvStream
& rStream
)
190 rStream
.ReadInt32( m_nValue
);
194 bool CntInt32Item::operator ==(const SfxPoolItem
& rItem
) const
196 DBG_ASSERT(rItem
.ISA(CntInt32Item
),
197 "CntInt32Item::operator ==(): Bad type");
198 return m_nValue
== (static_cast< const CntInt32Item
* >(&rItem
))->
203 int CntInt32Item::Compare(const SfxPoolItem
& rWith
) const
205 DBG_ASSERT(rWith
.ISA(CntInt32Item
), "CntInt32Item::Compare(): Bad type");
206 return (static_cast< const CntInt32Item
* >(&rWith
))->m_nValue
209 (static_cast< const CntInt32Item
* >(&rWith
))->m_nValue
215 bool CntInt32Item::GetPresentation(SfxItemPresentation
,
216 SfxMapUnit
, SfxMapUnit
,
218 const IntlWrapper
*) const
220 rText
= OUString::number( m_nValue
);
225 bool CntInt32Item::QueryValue(com::sun::star::uno::Any
& rVal
, sal_uInt8
) const
227 sal_Int32 nValue
= m_nValue
;
233 bool CntInt32Item::PutValue(const com::sun::star::uno::Any
& rVal
, sal_uInt8
)
235 sal_Int32 nValue
= 0;
242 OSL_FAIL( "CntInt32Item::PutValue - Wrong type!" );
247 SfxPoolItem
* CntInt32Item::Create(SvStream
& rStream
, sal_uInt16
) const
249 return new CntInt32Item(Which(), rStream
);
253 SvStream
& CntInt32Item::Store(SvStream
&rStream
, sal_uInt16
) const
255 rStream
.WriteInt32( m_nValue
);
260 SfxPoolItem
* CntInt32Item::Clone(SfxItemPool
*) const
262 return new CntInt32Item(*this);
265 TYPEINIT1_AUTOFACTORY(CntUInt32Item
, SfxPoolItem
);
267 CntUInt32Item::CntUInt32Item(sal_uInt16 which
, SvStream
& rStream
) :
270 sal_uInt32 nTheValue
= 0;
271 rStream
.ReadUInt32( nTheValue
);
272 m_nValue
= nTheValue
;
276 bool CntUInt32Item::operator ==(const SfxPoolItem
& rItem
) const
278 DBG_ASSERT(rItem
.ISA(CntUInt32Item
),
279 "CntUInt32Item::operator ==(): Bad type");
280 return m_nValue
== (static_cast< const CntUInt32Item
* >(&rItem
))->
285 int CntUInt32Item::Compare(const SfxPoolItem
& rWith
) const
287 DBG_ASSERT(rWith
.ISA(CntUInt32Item
),
288 "CntUInt32Item::operator ==(): Bad type");
289 return (static_cast< const CntUInt32Item
* >(&rWith
))->m_nValue
292 (static_cast< const CntUInt32Item
* >(&rWith
))->m_nValue
298 bool CntUInt32Item::GetPresentation(SfxItemPresentation
,
299 SfxMapUnit
, SfxMapUnit
,
304 rText
= OUString::number(m_nValue
);
309 bool CntUInt32Item::QueryValue(com::sun::star::uno::Any
& rVal
, sal_uInt8
) const
311 sal_Int32 nValue
= m_nValue
;
312 DBG_ASSERT( nValue
>=0, "Overflow in UInt32 value!");
318 bool CntUInt32Item::PutValue(const com::sun::star::uno::Any
& rVal
, sal_uInt8
)
320 sal_Int32 nValue
= 0;
323 DBG_ASSERT( nValue
>=0, "Overflow in UInt32 value!");
328 OSL_FAIL( "CntUInt32Item::PutValue - Wrong type!" );
333 SfxPoolItem
* CntUInt32Item::Create(SvStream
& rStream
, sal_uInt16
) const
335 return new CntUInt32Item(Which(), rStream
);
339 SvStream
& CntUInt32Item::Store(SvStream
&rStream
, sal_uInt16
) const
341 rStream
.WriteUInt32( m_nValue
);
346 SfxPoolItem
* CntUInt32Item::Clone(SfxItemPool
*) const
348 return new CntUInt32Item(*this);
351 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */