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