xref: /aoo42x/main/basic/source/sbx/sbxdec.cxx (revision cdf0e10c)
1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir 
28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
29*cdf0e10cSrcweir #include "precompiled_basic.hxx"
30*cdf0e10cSrcweir #include <tools/errcode.hxx>
31*cdf0e10cSrcweir 
32*cdf0e10cSrcweir #include <basic/sbx.hxx>
33*cdf0e10cSrcweir #include "sbxconv.hxx"
34*cdf0e10cSrcweir 
35*cdf0e10cSrcweir #include <com/sun/star/bridge/oleautomation/Decimal.hpp>
36*cdf0e10cSrcweir 
37*cdf0e10cSrcweir 
38*cdf0e10cSrcweir // int GnDecCounter = 0;
39*cdf0e10cSrcweir 
40*cdf0e10cSrcweir // Implementation SbxDecimal
41*cdf0e10cSrcweir SbxDecimal::SbxDecimal( void )
42*cdf0e10cSrcweir {
43*cdf0e10cSrcweir 	setInt( 0 );
44*cdf0e10cSrcweir 	mnRefCount = 0;
45*cdf0e10cSrcweir 	// GnDecCounter++;
46*cdf0e10cSrcweir }
47*cdf0e10cSrcweir 
48*cdf0e10cSrcweir SbxDecimal::SbxDecimal( const SbxDecimal& rDec )
49*cdf0e10cSrcweir {
50*cdf0e10cSrcweir #ifdef WIN32
51*cdf0e10cSrcweir 	maDec = rDec.maDec;
52*cdf0e10cSrcweir #else
53*cdf0e10cSrcweir     (void)rDec;
54*cdf0e10cSrcweir #endif
55*cdf0e10cSrcweir 	mnRefCount = 0;
56*cdf0e10cSrcweir 	// GnDecCounter++;
57*cdf0e10cSrcweir }
58*cdf0e10cSrcweir 
59*cdf0e10cSrcweir SbxDecimal::SbxDecimal
60*cdf0e10cSrcweir 	( const com::sun::star::bridge::oleautomation::Decimal& rAutomationDec )
61*cdf0e10cSrcweir {
62*cdf0e10cSrcweir #ifdef WIN32
63*cdf0e10cSrcweir 	maDec.scale = rAutomationDec.Scale;
64*cdf0e10cSrcweir 	maDec.sign  = rAutomationDec.Sign;
65*cdf0e10cSrcweir 	maDec.Lo32 = rAutomationDec.LowValue;
66*cdf0e10cSrcweir 	maDec.Mid32 = rAutomationDec.MiddleValue;
67*cdf0e10cSrcweir 	maDec.Hi32 = rAutomationDec.HighValue;
68*cdf0e10cSrcweir #else
69*cdf0e10cSrcweir     (void)rAutomationDec;
70*cdf0e10cSrcweir #endif
71*cdf0e10cSrcweir 	mnRefCount = 0;
72*cdf0e10cSrcweir 	// GnDecCounter++;
73*cdf0e10cSrcweir }
74*cdf0e10cSrcweir 
75*cdf0e10cSrcweir void SbxDecimal::fillAutomationDecimal
76*cdf0e10cSrcweir 	( com::sun::star::bridge::oleautomation::Decimal& rAutomationDec )
77*cdf0e10cSrcweir {
78*cdf0e10cSrcweir #ifdef WIN32
79*cdf0e10cSrcweir 	rAutomationDec.Scale = maDec.scale;
80*cdf0e10cSrcweir 	rAutomationDec.Sign = maDec.sign;
81*cdf0e10cSrcweir 	rAutomationDec.LowValue = maDec.Lo32;
82*cdf0e10cSrcweir 	rAutomationDec.MiddleValue = maDec.Mid32;
83*cdf0e10cSrcweir 	rAutomationDec.HighValue = maDec.Hi32;
84*cdf0e10cSrcweir #else
85*cdf0e10cSrcweir     (void)rAutomationDec;
86*cdf0e10cSrcweir #endif
87*cdf0e10cSrcweir }
88*cdf0e10cSrcweir 
89*cdf0e10cSrcweir SbxDecimal::~SbxDecimal()
90*cdf0e10cSrcweir {
91*cdf0e10cSrcweir 	// GnDecCounter--;
92*cdf0e10cSrcweir }
93*cdf0e10cSrcweir 
94*cdf0e10cSrcweir void releaseDecimalPtr( SbxDecimal*& rpDecimal )
95*cdf0e10cSrcweir {
96*cdf0e10cSrcweir 	if( rpDecimal )
97*cdf0e10cSrcweir 	{
98*cdf0e10cSrcweir 		rpDecimal->mnRefCount--;
99*cdf0e10cSrcweir 		if( rpDecimal->mnRefCount == 0 )
100*cdf0e10cSrcweir 		{
101*cdf0e10cSrcweir 			delete rpDecimal;
102*cdf0e10cSrcweir 			rpDecimal = NULL;
103*cdf0e10cSrcweir 		}
104*cdf0e10cSrcweir 	}
105*cdf0e10cSrcweir }
106*cdf0e10cSrcweir 
107*cdf0e10cSrcweir #ifdef WIN32
108*cdf0e10cSrcweir 
109*cdf0e10cSrcweir bool SbxDecimal::operator -= ( const SbxDecimal &r )
110*cdf0e10cSrcweir {
111*cdf0e10cSrcweir 	HRESULT hResult = VarDecSub( &maDec, (LPDECIMAL)&r.maDec, &maDec );
112*cdf0e10cSrcweir 	bool bRet = ( hResult == S_OK );
113*cdf0e10cSrcweir 	return bRet;
114*cdf0e10cSrcweir }
115*cdf0e10cSrcweir 
116*cdf0e10cSrcweir bool SbxDecimal::operator += ( const SbxDecimal &r )
117*cdf0e10cSrcweir {
118*cdf0e10cSrcweir 	HRESULT hResult = VarDecAdd( &maDec, (LPDECIMAL)&r.maDec, &maDec );
119*cdf0e10cSrcweir 	bool bRet = ( hResult == S_OK );
120*cdf0e10cSrcweir 	return bRet;
121*cdf0e10cSrcweir }
122*cdf0e10cSrcweir 
123*cdf0e10cSrcweir bool SbxDecimal::operator /= ( const SbxDecimal &r )
124*cdf0e10cSrcweir {
125*cdf0e10cSrcweir 	HRESULT hResult = VarDecDiv( &maDec, (LPDECIMAL)&r.maDec, &maDec );
126*cdf0e10cSrcweir 	bool bRet = ( hResult == S_OK );
127*cdf0e10cSrcweir 	return bRet;
128*cdf0e10cSrcweir }
129*cdf0e10cSrcweir 
130*cdf0e10cSrcweir bool SbxDecimal::operator *= ( const SbxDecimal &r )
131*cdf0e10cSrcweir {
132*cdf0e10cSrcweir 	HRESULT hResult = VarDecMul( &maDec, (LPDECIMAL)&r.maDec, &maDec );
133*cdf0e10cSrcweir 	bool bRet = ( hResult == S_OK );
134*cdf0e10cSrcweir 	return bRet;
135*cdf0e10cSrcweir }
136*cdf0e10cSrcweir 
137*cdf0e10cSrcweir bool SbxDecimal::neg( void )
138*cdf0e10cSrcweir {
139*cdf0e10cSrcweir 	HRESULT hResult = VarDecNeg( &maDec, &maDec );
140*cdf0e10cSrcweir 	bool bRet = ( hResult == S_OK );
141*cdf0e10cSrcweir 	return bRet;
142*cdf0e10cSrcweir }
143*cdf0e10cSrcweir 
144*cdf0e10cSrcweir bool SbxDecimal::isZero( void )
145*cdf0e10cSrcweir {
146*cdf0e10cSrcweir 	SbxDecimal aZeroDec;
147*cdf0e10cSrcweir 	aZeroDec.setLong( 0 );
148*cdf0e10cSrcweir 	bool bZero = ( EQ == compare( *this, aZeroDec ) );
149*cdf0e10cSrcweir 	return bZero;
150*cdf0e10cSrcweir }
151*cdf0e10cSrcweir 
152*cdf0e10cSrcweir SbxDecimal::CmpResult compare( const SbxDecimal &rLeft, const SbxDecimal &rRight )
153*cdf0e10cSrcweir {
154*cdf0e10cSrcweir 	HRESULT hResult = VarDecCmp( (LPDECIMAL)&rLeft.maDec, (LPDECIMAL)&rRight.maDec );
155*cdf0e10cSrcweir 	SbxDecimal::CmpResult eRes = (SbxDecimal::CmpResult)hResult;
156*cdf0e10cSrcweir 	return eRes;
157*cdf0e10cSrcweir }
158*cdf0e10cSrcweir 
159*cdf0e10cSrcweir void SbxDecimal::setChar( sal_Unicode val )
160*cdf0e10cSrcweir {
161*cdf0e10cSrcweir 	VarDecFromUI2( (sal_uInt16)val, &maDec );
162*cdf0e10cSrcweir }
163*cdf0e10cSrcweir 
164*cdf0e10cSrcweir void SbxDecimal::setByte( sal_uInt8 val )
165*cdf0e10cSrcweir {
166*cdf0e10cSrcweir 	VarDecFromUI1( (sal_uInt8)val, &maDec );
167*cdf0e10cSrcweir }
168*cdf0e10cSrcweir 
169*cdf0e10cSrcweir void SbxDecimal::setShort( sal_Int16 val )
170*cdf0e10cSrcweir {
171*cdf0e10cSrcweir 	VarDecFromI2( (short)val, &maDec );
172*cdf0e10cSrcweir }
173*cdf0e10cSrcweir 
174*cdf0e10cSrcweir void SbxDecimal::setLong( sal_Int32 val )
175*cdf0e10cSrcweir {
176*cdf0e10cSrcweir 	VarDecFromI4( (long)val, &maDec );
177*cdf0e10cSrcweir }
178*cdf0e10cSrcweir 
179*cdf0e10cSrcweir void SbxDecimal::setUShort( sal_uInt16 val )
180*cdf0e10cSrcweir {
181*cdf0e10cSrcweir 	VarDecFromUI2( (sal_uInt16)val, &maDec );
182*cdf0e10cSrcweir }
183*cdf0e10cSrcweir 
184*cdf0e10cSrcweir void SbxDecimal::setULong( sal_uInt32 val )
185*cdf0e10cSrcweir {
186*cdf0e10cSrcweir 	VarDecFromUI4( (sal_uIntPtr)val, &maDec );
187*cdf0e10cSrcweir }
188*cdf0e10cSrcweir 
189*cdf0e10cSrcweir bool SbxDecimal::setSingle( float val )
190*cdf0e10cSrcweir {
191*cdf0e10cSrcweir 	bool bRet = ( VarDecFromR4( val, &maDec ) == S_OK );
192*cdf0e10cSrcweir 	return bRet;
193*cdf0e10cSrcweir }
194*cdf0e10cSrcweir 
195*cdf0e10cSrcweir bool SbxDecimal::setDouble( double val )
196*cdf0e10cSrcweir {
197*cdf0e10cSrcweir 	bool bRet = ( VarDecFromR8( val, &maDec ) == S_OK );
198*cdf0e10cSrcweir 	return bRet;
199*cdf0e10cSrcweir }
200*cdf0e10cSrcweir 
201*cdf0e10cSrcweir void SbxDecimal::setInt( int val )
202*cdf0e10cSrcweir {
203*cdf0e10cSrcweir 	setLong( (sal_Int32)val );
204*cdf0e10cSrcweir }
205*cdf0e10cSrcweir 
206*cdf0e10cSrcweir void SbxDecimal::setUInt( unsigned int val )
207*cdf0e10cSrcweir {
208*cdf0e10cSrcweir 	setULong( (sal_uInt32)val );
209*cdf0e10cSrcweir }
210*cdf0e10cSrcweir 
211*cdf0e10cSrcweir // sbxscan.cxx
212*cdf0e10cSrcweir void ImpGetIntntlSep( sal_Unicode& rcDecimalSep, sal_Unicode& rcThousandSep );
213*cdf0e10cSrcweir 
214*cdf0e10cSrcweir bool SbxDecimal::setString( ::rtl::OUString* pOUString )
215*cdf0e10cSrcweir {
216*cdf0e10cSrcweir 	static LCID nLANGID = MAKELANGID( LANG_ENGLISH, SUBLANG_ENGLISH_US );
217*cdf0e10cSrcweir 
218*cdf0e10cSrcweir 	// Convert delimiter
219*cdf0e10cSrcweir 	sal_Unicode cDecimalSep;
220*cdf0e10cSrcweir 	sal_Unicode cThousandSep;
221*cdf0e10cSrcweir 	ImpGetIntntlSep( cDecimalSep, cThousandSep );
222*cdf0e10cSrcweir 
223*cdf0e10cSrcweir 	bool bRet = false;
224*cdf0e10cSrcweir 	HRESULT hResult;
225*cdf0e10cSrcweir 	if( cDecimalSep != '.' || cThousandSep != ',' )
226*cdf0e10cSrcweir 	{
227*cdf0e10cSrcweir 		int nLen = pOUString->getLength();
228*cdf0e10cSrcweir 		sal_Unicode* pBuffer = new sal_Unicode[nLen +  1];
229*cdf0e10cSrcweir 		pBuffer[nLen] = 0;
230*cdf0e10cSrcweir 
231*cdf0e10cSrcweir 		const sal_Unicode* pSrc = pOUString->getStr();
232*cdf0e10cSrcweir 		int i;
233*cdf0e10cSrcweir 		for( i = 0 ; i < nLen ; ++i )
234*cdf0e10cSrcweir 			pBuffer[i] = pSrc[i];
235*cdf0e10cSrcweir 
236*cdf0e10cSrcweir 		sal_Unicode c;
237*cdf0e10cSrcweir 		i = 0;
238*cdf0e10cSrcweir 		while( (c = pBuffer[i]) != 0 )
239*cdf0e10cSrcweir 		{
240*cdf0e10cSrcweir 			if( c == cDecimalSep )
241*cdf0e10cSrcweir 				pBuffer[i] = '.';
242*cdf0e10cSrcweir 			else if( c == cThousandSep )
243*cdf0e10cSrcweir 				pBuffer[i] = ',';
244*cdf0e10cSrcweir 			i++;
245*cdf0e10cSrcweir 		}
246*cdf0e10cSrcweir 		hResult = VarDecFromStr( (OLECHAR*)pBuffer, nLANGID, 0, &maDec );
247*cdf0e10cSrcweir 		delete pBuffer;
248*cdf0e10cSrcweir 	}
249*cdf0e10cSrcweir 	else
250*cdf0e10cSrcweir 	{
251*cdf0e10cSrcweir 		hResult = VarDecFromStr( (OLECHAR*)pOUString->getStr(), nLANGID, 0, &maDec );
252*cdf0e10cSrcweir 	}
253*cdf0e10cSrcweir 	bRet = ( hResult == S_OK );
254*cdf0e10cSrcweir 	return bRet;
255*cdf0e10cSrcweir }
256*cdf0e10cSrcweir 
257*cdf0e10cSrcweir 
258*cdf0e10cSrcweir bool SbxDecimal::getChar( sal_Unicode& rVal )
259*cdf0e10cSrcweir {
260*cdf0e10cSrcweir 	bool bRet = ( VarUI2FromDec( &maDec, &rVal ) == S_OK );
261*cdf0e10cSrcweir 	return bRet;
262*cdf0e10cSrcweir }
263*cdf0e10cSrcweir 
264*cdf0e10cSrcweir bool SbxDecimal::getByte( sal_uInt8& rVal )
265*cdf0e10cSrcweir {
266*cdf0e10cSrcweir 	bool bRet = ( VarUI1FromDec( &maDec, &rVal ) == S_OK );
267*cdf0e10cSrcweir 	return bRet;
268*cdf0e10cSrcweir }
269*cdf0e10cSrcweir 
270*cdf0e10cSrcweir bool SbxDecimal::getShort( sal_Int16& rVal )
271*cdf0e10cSrcweir {
272*cdf0e10cSrcweir 	bool bRet = ( VarI2FromDec( &maDec, &rVal ) == S_OK );
273*cdf0e10cSrcweir 	return bRet;
274*cdf0e10cSrcweir }
275*cdf0e10cSrcweir 
276*cdf0e10cSrcweir bool SbxDecimal::getLong( sal_Int32& rVal )
277*cdf0e10cSrcweir {
278*cdf0e10cSrcweir 	bool bRet = ( VarI4FromDec( &maDec, &rVal ) == S_OK );
279*cdf0e10cSrcweir 	return bRet;
280*cdf0e10cSrcweir }
281*cdf0e10cSrcweir 
282*cdf0e10cSrcweir bool SbxDecimal::getUShort( sal_uInt16& rVal )
283*cdf0e10cSrcweir {
284*cdf0e10cSrcweir 	bool bRet = ( VarUI2FromDec( &maDec, &rVal ) == S_OK );
285*cdf0e10cSrcweir 	return bRet;
286*cdf0e10cSrcweir }
287*cdf0e10cSrcweir 
288*cdf0e10cSrcweir bool SbxDecimal::getULong( sal_uInt32& rVal )
289*cdf0e10cSrcweir {
290*cdf0e10cSrcweir 	bool bRet = ( VarUI4FromDec( &maDec, &rVal ) == S_OK );
291*cdf0e10cSrcweir 	return bRet;
292*cdf0e10cSrcweir }
293*cdf0e10cSrcweir 
294*cdf0e10cSrcweir bool SbxDecimal::getSingle( float& rVal )
295*cdf0e10cSrcweir {
296*cdf0e10cSrcweir 	bool bRet = ( VarR4FromDec( &maDec, &rVal ) == S_OK );
297*cdf0e10cSrcweir 	return bRet;
298*cdf0e10cSrcweir }
299*cdf0e10cSrcweir 
300*cdf0e10cSrcweir bool SbxDecimal::getDouble( double& rVal )
301*cdf0e10cSrcweir {
302*cdf0e10cSrcweir 	bool bRet = ( VarR8FromDec( &maDec, &rVal ) == S_OK );
303*cdf0e10cSrcweir 	return bRet;
304*cdf0e10cSrcweir }
305*cdf0e10cSrcweir 
306*cdf0e10cSrcweir bool SbxDecimal::getInt( int& rVal )
307*cdf0e10cSrcweir {
308*cdf0e10cSrcweir 	sal_Int32 TmpVal;
309*cdf0e10cSrcweir 	bool bRet = getLong( TmpVal );
310*cdf0e10cSrcweir 	rVal = TmpVal;
311*cdf0e10cSrcweir 	return bRet;
312*cdf0e10cSrcweir }
313*cdf0e10cSrcweir 
314*cdf0e10cSrcweir bool SbxDecimal::getUInt( unsigned int& rVal )
315*cdf0e10cSrcweir {
316*cdf0e10cSrcweir 	sal_uInt32 TmpVal;
317*cdf0e10cSrcweir 	bool bRet = getULong( TmpVal );
318*cdf0e10cSrcweir 	rVal = TmpVal;
319*cdf0e10cSrcweir 	return bRet;
320*cdf0e10cSrcweir }
321*cdf0e10cSrcweir 
322*cdf0e10cSrcweir #else
323*cdf0e10cSrcweir // !WIN32
324*cdf0e10cSrcweir 
325*cdf0e10cSrcweir bool SbxDecimal::operator -= ( const SbxDecimal &r )
326*cdf0e10cSrcweir {
327*cdf0e10cSrcweir     (void)r;
328*cdf0e10cSrcweir 	return false;
329*cdf0e10cSrcweir }
330*cdf0e10cSrcweir 
331*cdf0e10cSrcweir bool SbxDecimal::operator += ( const SbxDecimal &r )
332*cdf0e10cSrcweir {
333*cdf0e10cSrcweir     (void)r;
334*cdf0e10cSrcweir 	return false;
335*cdf0e10cSrcweir }
336*cdf0e10cSrcweir 
337*cdf0e10cSrcweir bool SbxDecimal::operator /= ( const SbxDecimal &r )
338*cdf0e10cSrcweir {
339*cdf0e10cSrcweir     (void)r;
340*cdf0e10cSrcweir 	return false;
341*cdf0e10cSrcweir }
342*cdf0e10cSrcweir 
343*cdf0e10cSrcweir bool SbxDecimal::operator *= ( const SbxDecimal &r )
344*cdf0e10cSrcweir {
345*cdf0e10cSrcweir     (void)r;
346*cdf0e10cSrcweir 	return false;
347*cdf0e10cSrcweir }
348*cdf0e10cSrcweir 
349*cdf0e10cSrcweir bool SbxDecimal::neg( void )
350*cdf0e10cSrcweir {
351*cdf0e10cSrcweir 	return false;
352*cdf0e10cSrcweir }
353*cdf0e10cSrcweir 
354*cdf0e10cSrcweir bool SbxDecimal::isZero( void )
355*cdf0e10cSrcweir {
356*cdf0e10cSrcweir 	return false;
357*cdf0e10cSrcweir }
358*cdf0e10cSrcweir 
359*cdf0e10cSrcweir SbxDecimal::CmpResult compare( const SbxDecimal &rLeft, const SbxDecimal &rRight )
360*cdf0e10cSrcweir {
361*cdf0e10cSrcweir     (void)rLeft;
362*cdf0e10cSrcweir     (void)rRight;
363*cdf0e10cSrcweir 	return (SbxDecimal::CmpResult)0;
364*cdf0e10cSrcweir }
365*cdf0e10cSrcweir 
366*cdf0e10cSrcweir void SbxDecimal::setChar( sal_Unicode val )		{ (void)val; }
367*cdf0e10cSrcweir void SbxDecimal::setByte( sal_uInt8 val )			{ (void)val; }
368*cdf0e10cSrcweir void SbxDecimal::setShort( sal_Int16 val )			{ (void)val; }
369*cdf0e10cSrcweir void SbxDecimal::setLong( sal_Int32 val )			{ (void)val; }
370*cdf0e10cSrcweir void SbxDecimal::setUShort( sal_uInt16 val )		{ (void)val; }
371*cdf0e10cSrcweir void SbxDecimal::setULong( sal_uInt32 val )			{ (void)val; }
372*cdf0e10cSrcweir bool SbxDecimal::setSingle( float val )			{ (void)val; return false; }
373*cdf0e10cSrcweir bool SbxDecimal::setDouble( double val )		{ (void)val; return false; }
374*cdf0e10cSrcweir void SbxDecimal::setInt( int val )				{ (void)val; }
375*cdf0e10cSrcweir void SbxDecimal::setUInt( unsigned int val )	{ (void)val; }
376*cdf0e10cSrcweir bool SbxDecimal::setString( ::rtl::OUString* pOUString )	{ (void)pOUString;  return false; }
377*cdf0e10cSrcweir 
378*cdf0e10cSrcweir bool SbxDecimal::getChar( sal_Unicode& rVal )	{ (void)rVal; return false; }
379*cdf0e10cSrcweir bool SbxDecimal::getByte( sal_uInt8& rVal )			{ (void)rVal; return false; }
380*cdf0e10cSrcweir bool SbxDecimal::getShort( sal_Int16& rVal )		{ (void)rVal; return false; }
381*cdf0e10cSrcweir bool SbxDecimal::getLong( sal_Int32& rVal )			{ (void)rVal; return false; }
382*cdf0e10cSrcweir bool SbxDecimal::getUShort( sal_uInt16& rVal )		{ (void)rVal; return false; }
383*cdf0e10cSrcweir bool SbxDecimal::getULong( sal_uInt32& rVal )		{ (void)rVal; return false; }
384*cdf0e10cSrcweir bool SbxDecimal::getSingle( float& rVal )		{ (void)rVal; return false; }
385*cdf0e10cSrcweir bool SbxDecimal::getDouble( double& rVal )		{ (void)rVal; return false; }
386*cdf0e10cSrcweir bool SbxDecimal::getInt( int& rVal )			{ (void)rVal; return false; }
387*cdf0e10cSrcweir bool SbxDecimal::getUInt( unsigned int& rVal )	{ (void)rVal; return false; }
388*cdf0e10cSrcweir 
389*cdf0e10cSrcweir #endif
390*cdf0e10cSrcweir 
391*cdf0e10cSrcweir bool SbxDecimal::getString( ::rtl::OUString& rString )
392*cdf0e10cSrcweir {
393*cdf0e10cSrcweir #ifdef WIN32
394*cdf0e10cSrcweir 	static LCID nLANGID = MAKELANGID( LANG_ENGLISH, SUBLANG_ENGLISH_US );
395*cdf0e10cSrcweir 
396*cdf0e10cSrcweir 	bool bRet = false;
397*cdf0e10cSrcweir 
398*cdf0e10cSrcweir 	OLECHAR sz[100];
399*cdf0e10cSrcweir 	BSTR aBStr = SysAllocString( sz );
400*cdf0e10cSrcweir 	if( aBStr != NULL )
401*cdf0e10cSrcweir 	{
402*cdf0e10cSrcweir 		HRESULT hResult = VarBstrFromDec( &maDec, nLANGID, 0, &aBStr );
403*cdf0e10cSrcweir 		bRet = ( hResult == S_OK );
404*cdf0e10cSrcweir 		if( bRet )
405*cdf0e10cSrcweir 		{
406*cdf0e10cSrcweir 			// Convert delimiter
407*cdf0e10cSrcweir 			sal_Unicode cDecimalSep;
408*cdf0e10cSrcweir 			sal_Unicode cThousandSep;
409*cdf0e10cSrcweir 			ImpGetIntntlSep( cDecimalSep, cThousandSep );
410*cdf0e10cSrcweir 
411*cdf0e10cSrcweir 			if( cDecimalSep != '.' || cThousandSep != ',' )
412*cdf0e10cSrcweir 			{
413*cdf0e10cSrcweir 				sal_Unicode c;
414*cdf0e10cSrcweir 				int i = 0;
415*cdf0e10cSrcweir 				while( (c = aBStr[i]) != 0 )
416*cdf0e10cSrcweir 				{
417*cdf0e10cSrcweir 					if( c == '.' )
418*cdf0e10cSrcweir 						aBStr[i] = cDecimalSep;
419*cdf0e10cSrcweir 					else if( c == ',' )
420*cdf0e10cSrcweir 						aBStr[i] = cThousandSep;
421*cdf0e10cSrcweir 					i++;
422*cdf0e10cSrcweir 				}
423*cdf0e10cSrcweir 			}
424*cdf0e10cSrcweir 			rString = reinterpret_cast<const sal_Unicode*>(aBStr);
425*cdf0e10cSrcweir 		}
426*cdf0e10cSrcweir 
427*cdf0e10cSrcweir 		SysFreeString( aBStr );
428*cdf0e10cSrcweir 	}
429*cdf0e10cSrcweir 	return bRet;
430*cdf0e10cSrcweir #else
431*cdf0e10cSrcweir     (void)rString;
432*cdf0e10cSrcweir 	return false;
433*cdf0e10cSrcweir #endif
434*cdf0e10cSrcweir }
435*cdf0e10cSrcweir 
436*cdf0e10cSrcweir SbxDecimal* ImpCreateDecimal( SbxValues* p )
437*cdf0e10cSrcweir {
438*cdf0e10cSrcweir #ifdef WIN32
439*cdf0e10cSrcweir 	if( !p )
440*cdf0e10cSrcweir 		return NULL;
441*cdf0e10cSrcweir 
442*cdf0e10cSrcweir 	SbxDecimal*& rpDecimal = p->pDecimal;
443*cdf0e10cSrcweir 	if( rpDecimal == NULL )
444*cdf0e10cSrcweir 	{
445*cdf0e10cSrcweir 		rpDecimal = new SbxDecimal();
446*cdf0e10cSrcweir 		rpDecimal->addRef();
447*cdf0e10cSrcweir 	}
448*cdf0e10cSrcweir 	return rpDecimal;
449*cdf0e10cSrcweir #else
450*cdf0e10cSrcweir     (void)p;
451*cdf0e10cSrcweir 	return NULL;
452*cdf0e10cSrcweir #endif
453*cdf0e10cSrcweir }
454*cdf0e10cSrcweir 
455*cdf0e10cSrcweir SbxDecimal* ImpGetDecimal( const SbxValues* p )
456*cdf0e10cSrcweir {
457*cdf0e10cSrcweir #ifdef WIN32
458*cdf0e10cSrcweir 	SbxValues aTmp;
459*cdf0e10cSrcweir 	SbxDecimal* pnDecRes;
460*cdf0e10cSrcweir 
461*cdf0e10cSrcweir 	SbxDataType eType = p->eType;
462*cdf0e10cSrcweir 	if( eType == SbxDECIMAL && p->pDecimal )
463*cdf0e10cSrcweir 	{
464*cdf0e10cSrcweir 		pnDecRes = new SbxDecimal( *p->pDecimal );
465*cdf0e10cSrcweir 		pnDecRes->addRef();
466*cdf0e10cSrcweir 		return pnDecRes;
467*cdf0e10cSrcweir 	}
468*cdf0e10cSrcweir 	pnDecRes = new SbxDecimal();
469*cdf0e10cSrcweir 	pnDecRes->addRef();
470*cdf0e10cSrcweir 
471*cdf0e10cSrcweir start:
472*cdf0e10cSrcweir 	switch( +eType )
473*cdf0e10cSrcweir 	{
474*cdf0e10cSrcweir 		case SbxNULL:
475*cdf0e10cSrcweir 			SbxBase::SetError( SbxERR_CONVERSION );
476*cdf0e10cSrcweir 		case SbxEMPTY:
477*cdf0e10cSrcweir 			pnDecRes->setShort( 0 ); break;
478*cdf0e10cSrcweir 		case SbxCHAR:
479*cdf0e10cSrcweir 			pnDecRes->setChar( p->nChar ); break;
480*cdf0e10cSrcweir 		case SbxBYTE:
481*cdf0e10cSrcweir 			pnDecRes->setByte( p->nByte ); break;
482*cdf0e10cSrcweir 		case SbxINTEGER:
483*cdf0e10cSrcweir 		case SbxBOOL:
484*cdf0e10cSrcweir 			pnDecRes->setInt( p->nInteger ); break;
485*cdf0e10cSrcweir 		case SbxERROR:
486*cdf0e10cSrcweir 		case SbxUSHORT:
487*cdf0e10cSrcweir 			pnDecRes->setUShort( p->nUShort ); break;
488*cdf0e10cSrcweir 		case SbxLONG:
489*cdf0e10cSrcweir 			pnDecRes->setLong( p->nLong ); break;
490*cdf0e10cSrcweir 		case SbxULONG:
491*cdf0e10cSrcweir 			pnDecRes->setULong( p->nULong ); break;
492*cdf0e10cSrcweir 		case SbxSINGLE:
493*cdf0e10cSrcweir 			if( !pnDecRes->setSingle( p->nSingle ) )
494*cdf0e10cSrcweir 				SbxBase::SetError( SbxERR_OVERFLOW );
495*cdf0e10cSrcweir 			break;
496*cdf0e10cSrcweir 		case SbxSALINT64:
497*cdf0e10cSrcweir 			{
498*cdf0e10cSrcweir 				double d = (double)p->nInt64;
499*cdf0e10cSrcweir 				pnDecRes->setDouble( d );
500*cdf0e10cSrcweir 				break;
501*cdf0e10cSrcweir 			}
502*cdf0e10cSrcweir 		case SbxSALUINT64:
503*cdf0e10cSrcweir 			{
504*cdf0e10cSrcweir 				double d = ImpSalUInt64ToDouble( p->uInt64 );
505*cdf0e10cSrcweir 				pnDecRes->setDouble( d );
506*cdf0e10cSrcweir 				break;
507*cdf0e10cSrcweir 			}
508*cdf0e10cSrcweir 		case SbxDATE:
509*cdf0e10cSrcweir 		case SbxDOUBLE:
510*cdf0e10cSrcweir 		case SbxLONG64:
511*cdf0e10cSrcweir 		case SbxULONG64:
512*cdf0e10cSrcweir 		case SbxCURRENCY:
513*cdf0e10cSrcweir 			{
514*cdf0e10cSrcweir 			double dVal;
515*cdf0e10cSrcweir 			if( p->eType ==	SbxCURRENCY )
516*cdf0e10cSrcweir 				dVal = ImpCurrencyToDouble( p->nLong64 );
517*cdf0e10cSrcweir 			else if( p->eType == SbxLONG64 )
518*cdf0e10cSrcweir 				dVal = ImpINT64ToDouble( p->nLong64 );
519*cdf0e10cSrcweir 			else if( p->eType == SbxULONG64 )
520*cdf0e10cSrcweir 				dVal = ImpUINT64ToDouble( p->nULong64 );
521*cdf0e10cSrcweir 			else
522*cdf0e10cSrcweir 				dVal = p->nDouble;
523*cdf0e10cSrcweir 
524*cdf0e10cSrcweir 			if( !pnDecRes->setDouble( dVal ) )
525*cdf0e10cSrcweir 				SbxBase::SetError( SbxERR_OVERFLOW );
526*cdf0e10cSrcweir 			break;
527*cdf0e10cSrcweir 			}
528*cdf0e10cSrcweir 		case SbxLPSTR:
529*cdf0e10cSrcweir 		case SbxSTRING:
530*cdf0e10cSrcweir 		case SbxBYREF | SbxSTRING:
531*cdf0e10cSrcweir 			pnDecRes->setString( p->pOUString ); break;
532*cdf0e10cSrcweir 		case SbxOBJECT:
533*cdf0e10cSrcweir 		{
534*cdf0e10cSrcweir 			SbxValue* pVal = PTR_CAST(SbxValue,p->pObj);
535*cdf0e10cSrcweir 			if( pVal )
536*cdf0e10cSrcweir 				pnDecRes->setDecimal( pVal->GetDecimal() );
537*cdf0e10cSrcweir 			else
538*cdf0e10cSrcweir 			{
539*cdf0e10cSrcweir 				SbxBase::SetError( SbxERR_NO_OBJECT );
540*cdf0e10cSrcweir 				pnDecRes->setShort( 0 );
541*cdf0e10cSrcweir 			}
542*cdf0e10cSrcweir 			break;
543*cdf0e10cSrcweir 		}
544*cdf0e10cSrcweir 
545*cdf0e10cSrcweir 		case SbxBYREF | SbxCHAR:
546*cdf0e10cSrcweir 			pnDecRes->setChar( *p->pChar ); break;
547*cdf0e10cSrcweir 		case SbxBYREF | SbxBYTE:
548*cdf0e10cSrcweir 			pnDecRes->setByte( *p->pByte ); break;
549*cdf0e10cSrcweir 		case SbxBYREF | SbxINTEGER:
550*cdf0e10cSrcweir 		case SbxBYREF | SbxBOOL:
551*cdf0e10cSrcweir 			pnDecRes->setInt( *p->pInteger ); break;
552*cdf0e10cSrcweir 		case SbxBYREF | SbxLONG:
553*cdf0e10cSrcweir 			pnDecRes->setLong( *p->pLong ); break;
554*cdf0e10cSrcweir 		case SbxBYREF | SbxULONG:
555*cdf0e10cSrcweir 			pnDecRes->setULong( *p->pULong ); break;
556*cdf0e10cSrcweir 		case SbxBYREF | SbxERROR:
557*cdf0e10cSrcweir 		case SbxBYREF | SbxUSHORT:
558*cdf0e10cSrcweir 			pnDecRes->setUShort( *p->pUShort ); break;
559*cdf0e10cSrcweir 
560*cdf0e10cSrcweir 		// ab hier muss getestet werden
561*cdf0e10cSrcweir 		case SbxBYREF | SbxSINGLE:
562*cdf0e10cSrcweir 			aTmp.nSingle = *p->pSingle; goto ref;
563*cdf0e10cSrcweir 		case SbxBYREF | SbxDATE:
564*cdf0e10cSrcweir 		case SbxBYREF | SbxDOUBLE:
565*cdf0e10cSrcweir 			aTmp.nDouble = *p->pDouble; goto ref;
566*cdf0e10cSrcweir 		case SbxBYREF | SbxULONG64:
567*cdf0e10cSrcweir 			aTmp.nULong64 = *p->pULong64; goto ref;
568*cdf0e10cSrcweir 		case SbxBYREF | SbxLONG64:
569*cdf0e10cSrcweir 		case SbxBYREF | SbxCURRENCY:
570*cdf0e10cSrcweir 			aTmp.nLong64 = *p->pLong64; goto ref;
571*cdf0e10cSrcweir 		case SbxBYREF | SbxSALINT64:
572*cdf0e10cSrcweir 			aTmp.nInt64 = *p->pnInt64; goto ref;
573*cdf0e10cSrcweir 		case SbxBYREF | SbxSALUINT64:
574*cdf0e10cSrcweir 			aTmp.uInt64 = *p->puInt64; goto ref;
575*cdf0e10cSrcweir 		ref:
576*cdf0e10cSrcweir 			aTmp.eType = SbxDataType( p->eType & 0x0FFF );
577*cdf0e10cSrcweir 			p = &aTmp; goto start;
578*cdf0e10cSrcweir 
579*cdf0e10cSrcweir 		default:
580*cdf0e10cSrcweir 			SbxBase::SetError( SbxERR_CONVERSION ); pnDecRes->setShort( 0 );
581*cdf0e10cSrcweir 	}
582*cdf0e10cSrcweir 	return pnDecRes;
583*cdf0e10cSrcweir #else
584*cdf0e10cSrcweir     (void)p;
585*cdf0e10cSrcweir     return NULL;
586*cdf0e10cSrcweir #endif
587*cdf0e10cSrcweir }
588*cdf0e10cSrcweir 
589*cdf0e10cSrcweir 
590*cdf0e10cSrcweir void ImpPutDecimal( SbxValues* p, SbxDecimal* pDec )
591*cdf0e10cSrcweir {
592*cdf0e10cSrcweir #ifdef WIN32
593*cdf0e10cSrcweir 	if( !pDec )
594*cdf0e10cSrcweir 		return;
595*cdf0e10cSrcweir 
596*cdf0e10cSrcweir 	SbxValues aTmp;
597*cdf0e10cSrcweir start:
598*cdf0e10cSrcweir 	switch( +p->eType )
599*cdf0e10cSrcweir 	{
600*cdf0e10cSrcweir 		// hier muss getestet werden
601*cdf0e10cSrcweir 		case SbxCHAR:
602*cdf0e10cSrcweir 			aTmp.pChar = &p->nChar; goto direct;
603*cdf0e10cSrcweir 		case SbxBYTE:
604*cdf0e10cSrcweir 			aTmp.pByte = &p->nByte; goto direct;
605*cdf0e10cSrcweir 		case SbxULONG:
606*cdf0e10cSrcweir 			aTmp.pULong = &p->nULong; goto direct;
607*cdf0e10cSrcweir 		case SbxERROR:
608*cdf0e10cSrcweir 		case SbxUSHORT:
609*cdf0e10cSrcweir 			aTmp.pUShort = &p->nUShort; goto direct;
610*cdf0e10cSrcweir 		case SbxSALUINT64:
611*cdf0e10cSrcweir 			aTmp.puInt64 = &p->uInt64; goto direct;
612*cdf0e10cSrcweir 		case SbxINTEGER:
613*cdf0e10cSrcweir 		case SbxBOOL:
614*cdf0e10cSrcweir 			aTmp.pInteger = &p->nInteger; goto direct;
615*cdf0e10cSrcweir 		case SbxLONG:
616*cdf0e10cSrcweir 			aTmp.pLong = &p->nLong; goto direct;
617*cdf0e10cSrcweir 		case SbxSALINT64:
618*cdf0e10cSrcweir 			aTmp.pnInt64 = &p->nInt64; goto direct;
619*cdf0e10cSrcweir 		case SbxCURRENCY:
620*cdf0e10cSrcweir 			aTmp.pLong64 = &p->nLong64; goto direct;
621*cdf0e10cSrcweir 		direct:
622*cdf0e10cSrcweir 			aTmp.eType = SbxDataType( p->eType | SbxBYREF );
623*cdf0e10cSrcweir 			p = &aTmp; goto start;
624*cdf0e10cSrcweir 
625*cdf0e10cSrcweir 		// ab hier nicht mehr
626*cdf0e10cSrcweir 		case SbxDECIMAL:
627*cdf0e10cSrcweir 		case SbxBYREF | SbxDECIMAL:
628*cdf0e10cSrcweir 		{
629*cdf0e10cSrcweir 			if( pDec != p->pDecimal )
630*cdf0e10cSrcweir 			{
631*cdf0e10cSrcweir 				releaseDecimalPtr( p->pDecimal );
632*cdf0e10cSrcweir 				// if( p->pDecimal )
633*cdf0e10cSrcweir 					// p->pDecimal->ReleaseRef();
634*cdf0e10cSrcweir 				p->pDecimal = pDec;
635*cdf0e10cSrcweir 				if( pDec )
636*cdf0e10cSrcweir 					pDec->addRef();
637*cdf0e10cSrcweir 			}
638*cdf0e10cSrcweir 			break;
639*cdf0e10cSrcweir 		}
640*cdf0e10cSrcweir 		case SbxSINGLE:
641*cdf0e10cSrcweir 		{
642*cdf0e10cSrcweir 			float f;
643*cdf0e10cSrcweir 			pDec->getSingle( f );
644*cdf0e10cSrcweir 			p->nSingle = f;
645*cdf0e10cSrcweir 			break;
646*cdf0e10cSrcweir 		}
647*cdf0e10cSrcweir 		case SbxDATE:
648*cdf0e10cSrcweir 		case SbxDOUBLE:
649*cdf0e10cSrcweir 		{
650*cdf0e10cSrcweir 			double d;
651*cdf0e10cSrcweir 			pDec->getDouble( d );
652*cdf0e10cSrcweir 			p->nDouble = d;
653*cdf0e10cSrcweir 			break;
654*cdf0e10cSrcweir 		}
655*cdf0e10cSrcweir 		case SbxULONG64:
656*cdf0e10cSrcweir 		{
657*cdf0e10cSrcweir 			double d;
658*cdf0e10cSrcweir 			pDec->getDouble( d );
659*cdf0e10cSrcweir 			p->nULong64 = ImpDoubleToUINT64( d );
660*cdf0e10cSrcweir 			break;
661*cdf0e10cSrcweir 		}
662*cdf0e10cSrcweir 		case SbxLONG64:
663*cdf0e10cSrcweir 		{
664*cdf0e10cSrcweir 			double d;
665*cdf0e10cSrcweir 			pDec->getDouble( d );
666*cdf0e10cSrcweir 			p->nLong64 = ImpDoubleToINT64( d );
667*cdf0e10cSrcweir 			break;
668*cdf0e10cSrcweir 		}
669*cdf0e10cSrcweir 
670*cdf0e10cSrcweir 		case SbxLPSTR:
671*cdf0e10cSrcweir 		case SbxSTRING:
672*cdf0e10cSrcweir 		case SbxBYREF | SbxSTRING:
673*cdf0e10cSrcweir 			if( !p->pOUString )
674*cdf0e10cSrcweir 				p->pOUString = new ::rtl::OUString;
675*cdf0e10cSrcweir 			// ImpCvtNum( (double) n, 0, *p->pString );
676*cdf0e10cSrcweir 			pDec->getString( *p->pOUString );
677*cdf0e10cSrcweir 			break;
678*cdf0e10cSrcweir 		case SbxOBJECT:
679*cdf0e10cSrcweir 		{
680*cdf0e10cSrcweir 			SbxValue* pVal = PTR_CAST(SbxValue,p->pObj);
681*cdf0e10cSrcweir 			if( pVal )
682*cdf0e10cSrcweir 				pVal->PutDecimal( pDec );
683*cdf0e10cSrcweir 			else
684*cdf0e10cSrcweir 				SbxBase::SetError( SbxERR_NO_OBJECT );
685*cdf0e10cSrcweir 			break;
686*cdf0e10cSrcweir 		}
687*cdf0e10cSrcweir 
688*cdf0e10cSrcweir 		case SbxBYREF | SbxCHAR:
689*cdf0e10cSrcweir 			if( !pDec->getChar( *p->pChar ) )
690*cdf0e10cSrcweir 			{
691*cdf0e10cSrcweir 				SbxBase::SetError( SbxERR_OVERFLOW );
692*cdf0e10cSrcweir 				*p->pChar = 0;
693*cdf0e10cSrcweir 			}
694*cdf0e10cSrcweir 			break;
695*cdf0e10cSrcweir 		case SbxBYREF | SbxBYTE:
696*cdf0e10cSrcweir 			if( !pDec->getChar( *p->pChar ) )
697*cdf0e10cSrcweir 			{
698*cdf0e10cSrcweir 				SbxBase::SetError( SbxERR_OVERFLOW );
699*cdf0e10cSrcweir 				*p->pByte = 0;
700*cdf0e10cSrcweir 			}
701*cdf0e10cSrcweir 			break;
702*cdf0e10cSrcweir 		case SbxBYREF | SbxINTEGER:
703*cdf0e10cSrcweir 		case SbxBYREF | SbxBOOL:
704*cdf0e10cSrcweir 			if( !pDec->getShort( *p->pInteger ) )
705*cdf0e10cSrcweir 			{
706*cdf0e10cSrcweir 				SbxBase::SetError( SbxERR_OVERFLOW );
707*cdf0e10cSrcweir 				*p->pInteger = 0;
708*cdf0e10cSrcweir 			}
709*cdf0e10cSrcweir 			break;
710*cdf0e10cSrcweir 			// *p->pInteger = n; break;
711*cdf0e10cSrcweir 		case SbxBYREF | SbxERROR:
712*cdf0e10cSrcweir 		case SbxBYREF | SbxUSHORT:
713*cdf0e10cSrcweir 			if( !pDec->getUShort( *p->pUShort ) )
714*cdf0e10cSrcweir 			{
715*cdf0e10cSrcweir 				SbxBase::SetError( SbxERR_OVERFLOW );
716*cdf0e10cSrcweir 				*p->pUShort = 0;
717*cdf0e10cSrcweir 			}
718*cdf0e10cSrcweir 			break;
719*cdf0e10cSrcweir 		case SbxBYREF | SbxLONG:
720*cdf0e10cSrcweir 			if( !pDec->getLong( *p->pLong ) )
721*cdf0e10cSrcweir 			{
722*cdf0e10cSrcweir 				SbxBase::SetError( SbxERR_OVERFLOW );
723*cdf0e10cSrcweir 				*p->pLong = 0;
724*cdf0e10cSrcweir 			}
725*cdf0e10cSrcweir 			break;
726*cdf0e10cSrcweir 		case SbxBYREF | SbxULONG:
727*cdf0e10cSrcweir 			if( !pDec->getULong( *p->pULong ) )
728*cdf0e10cSrcweir 			{
729*cdf0e10cSrcweir 				SbxBase::SetError( SbxERR_OVERFLOW );
730*cdf0e10cSrcweir 				*p->pULong = 0;
731*cdf0e10cSrcweir 			}
732*cdf0e10cSrcweir 			break;
733*cdf0e10cSrcweir 		case SbxBYREF | SbxSALINT64:
734*cdf0e10cSrcweir 			{
735*cdf0e10cSrcweir 			double d;
736*cdf0e10cSrcweir 			if( !pDec->getDouble( d ) )
737*cdf0e10cSrcweir 				SbxBase::SetError( SbxERR_OVERFLOW );
738*cdf0e10cSrcweir 			else
739*cdf0e10cSrcweir 				*p->pnInt64 = ImpDoubleToSalInt64( d );
740*cdf0e10cSrcweir 			break;
741*cdf0e10cSrcweir 			}
742*cdf0e10cSrcweir 		case SbxBYREF | SbxSALUINT64:
743*cdf0e10cSrcweir 			{
744*cdf0e10cSrcweir 			double d;
745*cdf0e10cSrcweir 			if( !pDec->getDouble( d ) )
746*cdf0e10cSrcweir 				SbxBase::SetError( SbxERR_OVERFLOW );
747*cdf0e10cSrcweir 			else
748*cdf0e10cSrcweir 				*p->puInt64 = ImpDoubleToSalUInt64( d );
749*cdf0e10cSrcweir 			break;
750*cdf0e10cSrcweir 			}
751*cdf0e10cSrcweir 		case SbxBYREF | SbxSINGLE:
752*cdf0e10cSrcweir 			if( !pDec->getSingle( *p->pSingle ) )
753*cdf0e10cSrcweir 			{
754*cdf0e10cSrcweir 				SbxBase::SetError( SbxERR_OVERFLOW );
755*cdf0e10cSrcweir 				*p->pSingle = 0;
756*cdf0e10cSrcweir 			}
757*cdf0e10cSrcweir 			break;
758*cdf0e10cSrcweir 			// *p->pSingle = (float) n; break;
759*cdf0e10cSrcweir 		case SbxBYREF | SbxDATE:
760*cdf0e10cSrcweir 		case SbxBYREF | SbxDOUBLE:
761*cdf0e10cSrcweir 			if( !pDec->getDouble( *p->pDouble ) )
762*cdf0e10cSrcweir 			{
763*cdf0e10cSrcweir 				SbxBase::SetError( SbxERR_OVERFLOW );
764*cdf0e10cSrcweir 				*p->pDouble = 0;
765*cdf0e10cSrcweir 			}
766*cdf0e10cSrcweir 			break;
767*cdf0e10cSrcweir 		case SbxBYREF | SbxULONG64:
768*cdf0e10cSrcweir 		{
769*cdf0e10cSrcweir 			double d;
770*cdf0e10cSrcweir 			pDec->getDouble( d );
771*cdf0e10cSrcweir 			*p->pULong64 = ImpDoubleToUINT64( d );
772*cdf0e10cSrcweir 			break;
773*cdf0e10cSrcweir 		}
774*cdf0e10cSrcweir 		case SbxBYREF | SbxLONG64:
775*cdf0e10cSrcweir 		{
776*cdf0e10cSrcweir 			double d;
777*cdf0e10cSrcweir 			pDec->getDouble( d );
778*cdf0e10cSrcweir 			*p->pLong64 = ImpDoubleToINT64( d );
779*cdf0e10cSrcweir 			break;
780*cdf0e10cSrcweir 		}
781*cdf0e10cSrcweir 		case SbxBYREF | SbxCURRENCY:
782*cdf0e10cSrcweir 		{
783*cdf0e10cSrcweir 			double d;
784*cdf0e10cSrcweir 			pDec->getDouble( d );
785*cdf0e10cSrcweir 			*p->pLong64 = ImpDoubleToCurrency( d );
786*cdf0e10cSrcweir 			break;
787*cdf0e10cSrcweir 		}
788*cdf0e10cSrcweir 
789*cdf0e10cSrcweir 		default:
790*cdf0e10cSrcweir 			SbxBase::SetError( SbxERR_CONVERSION );
791*cdf0e10cSrcweir 	}
792*cdf0e10cSrcweir #else
793*cdf0e10cSrcweir     (void)p;
794*cdf0e10cSrcweir     (void)pDec;
795*cdf0e10cSrcweir #endif
796*cdf0e10cSrcweir }
797*cdf0e10cSrcweir 
798