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