Update ooo320-m1
[ooovba.git] / svtools / source / items1 / bintitem.cxx
blob594d0460a42700254d3f2c425e62819f1c9e68c9
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: bintitem.cxx,v $
10 * $Revision: 1.8 $
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 <tools/bigint.hxx>
36 #include <svtools/bintitem.hxx>
38 // STATIC DATA
40 DBG_NAME(SfxBigIntItem)
42 // RTTI
43 TYPEINIT1_AUTOFACTORY(SfxBigIntItem, SfxPoolItem);
45 // SfxBigIntItem
47 //============================================================================
48 SfxBigIntItem::SfxBigIntItem()
49 : SfxPoolItem(0),
50 aVal(0)
52 DBG_CTOR(SfxBigIntItem, 0);
55 //============================================================================
56 SfxBigIntItem::SfxBigIntItem(USHORT which, const BigInt& rValue)
57 : SfxPoolItem(which),
58 aVal(rValue)
60 DBG_CTOR(SfxBigIntItem, 0);
63 //============================================================================
64 SfxBigIntItem::SfxBigIntItem(USHORT which, SvStream &rStream)
65 : SfxPoolItem(which)
67 DBG_CTOR(SfxBigIntItem, 0);
68 ByteString sTmp;
69 rStream.ReadByteString(sTmp);
70 BigInt aTmp(sTmp);
71 aVal = aTmp;
74 //============================================================================
75 SfxBigIntItem::SfxBigIntItem(const SfxBigIntItem& rItem)
76 : SfxPoolItem(rItem),
77 aVal(rItem.aVal)
79 DBG_CTOR(SfxBigIntItem, 0);
82 //============================================================================
83 SfxItemPresentation SfxBigIntItem::GetPresentation(
84 SfxItemPresentation /*ePresentation*/,
85 SfxMapUnit /*eCoreMetric*/,
86 SfxMapUnit /*ePresentationMetric*/,
87 XubString& rText,
88 const IntlWrapper * ) const
90 DBG_CHKTHIS(SfxBigIntItem, 0);
91 rText = aVal.GetString();
92 return SFX_ITEM_PRESENTATION_NAMELESS;
95 //============================================================================
96 int SfxBigIntItem::operator==(const SfxPoolItem& rItem) const
98 DBG_CHKTHIS(SfxBigIntItem, 0);
99 DBG_ASSERT(SfxPoolItem::operator==(rItem), "unequal type");
100 return ((SfxBigIntItem&)rItem).aVal == aVal;
103 //============================================================================
104 int SfxBigIntItem::Compare(const SfxPoolItem& rItem) const
106 DBG_CHKTHIS(SfxBigIntItem, 0);
107 DBG_ASSERT(SfxPoolItem::operator==(rItem), "unequal type");
109 if (((const SfxBigIntItem&)rItem ).aVal < aVal )
110 return -1;
111 else if (((const SfxBigIntItem&)rItem ).aVal == aVal)
112 return 0;
113 else
114 return 1;
117 //============================================================================
118 SfxPoolItem* SfxBigIntItem::Clone(SfxItemPool *) const
120 DBG_CHKTHIS(SfxBigIntItem, 0);
121 return new SfxBigIntItem(*this);
124 //============================================================================
125 SfxPoolItem* SfxBigIntItem::Create(SvStream &rStream, USHORT) const
127 DBG_CHKTHIS(SfxBigIntItem, 0);
128 return new SfxBigIntItem(Which(), rStream);
131 //============================================================================
132 SvStream& SfxBigIntItem::Store(SvStream &rStream, USHORT ) const
134 DBG_CHKTHIS(SfxBigIntItem, 0);
135 rStream.WriteByteString( aVal.GetByteString() );
136 return rStream;
139 //============================================================================
140 SfxFieldUnit SfxBigIntItem::GetUnit() const
142 DBG_CHKTHIS(SfxBigIntItem, 0);
143 return SFX_FUNIT_NONE;
146 //============================================================================
147 // virtual
148 BOOL SfxBigIntItem::PutValue( const com::sun::star::uno::Any& rVal, BYTE )
150 double aValue = 0.0;
151 if ( rVal >>= aValue )
153 SetValue( aValue );
154 return TRUE;
157 DBG_ERROR( "SfxBigIntItem::PutValue - Wrong type!" );
158 return FALSE;
161 //============================================================================
162 // virtual
163 BOOL SfxBigIntItem::QueryValue( com::sun::star::uno::Any& rVal, BYTE ) const
165 double aValue = GetValue();
166 rVal <<= aValue;
167 return TRUE;