1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: sbxint.cxx,v $
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_basic.hxx"
33 #include <tools/errcode.hxx>
34 #include <basic/sbx.hxx>
35 #include "sbxconv.hxx"
37 double ImpRound( double d
)
39 return d
+ ( d
< 0 ? -0.5 : 0.5 );
42 INT16
ImpGetInteger( const SbxValues
* p
)
50 SbxBase::SetError( SbxERR_CONVERSION
);
54 nRes
= p
->nChar
; break;
56 nRes
= p
->nByte
; break;
59 nRes
= p
->nInteger
; break;
62 if( p
->nUShort
> (USHORT
) SbxMAXINT
)
64 SbxBase::SetError( SbxERR_OVERFLOW
); nRes
= SbxMAXINT
;
67 nRes
= (INT16
) p
->nUShort
;
70 if( p
->nLong
> SbxMAXINT
)
72 SbxBase::SetError( SbxERR_OVERFLOW
); nRes
= SbxMAXINT
;
74 else if( p
->nLong
< SbxMININT
)
76 SbxBase::SetError( SbxERR_OVERFLOW
); nRes
= SbxMININT
;
79 nRes
= (INT16
) p
->nLong
;
82 if( p
->nULong
> SbxMAXINT
)
84 SbxBase::SetError( SbxERR_OVERFLOW
); nRes
= SbxMAXINT
;
87 nRes
= (INT16
) p
->nULong
;
90 if( p
->nSingle
> SbxMAXINT
)
92 SbxBase::SetError( SbxERR_OVERFLOW
); nRes
= SbxMAXINT
;
94 else if( p
->nSingle
< SbxMININT
)
96 SbxBase::SetError( SbxERR_OVERFLOW
); nRes
= SbxMININT
;
99 nRes
= (INT16
) ImpRound( p
->nSingle
);
102 if( p
->nInt64
> SbxMAXINT
)
104 SbxBase::SetError( SbxERR_OVERFLOW
); nRes
= SbxMAXINT
;
106 else if( p
->nInt64
< SbxMININT
)
108 SbxBase::SetError( SbxERR_OVERFLOW
); nRes
= SbxMININT
;
111 nRes
= (INT16
) p
->nInt64
;
114 if( p
->uInt64
> SbxMAXINT
)
116 SbxBase::SetError( SbxERR_OVERFLOW
); nRes
= SbxMAXINT
;
119 nRes
= (INT16
) p
->uInt64
;
127 case SbxBYREF
| SbxDECIMAL
:
130 if( p
->eType
== SbxCURRENCY
)
131 dVal
= ImpCurrencyToDouble( p
->nLong64
);
132 else if( p
->eType
== SbxLONG64
)
133 dVal
= ImpINT64ToDouble( p
->nLong64
);
134 else if( p
->eType
== SbxULONG64
)
135 dVal
= ImpUINT64ToDouble( p
->nULong64
);
136 else if( p
->eType
== SbxDECIMAL
)
140 p
->pDecimal
->getDouble( dVal
);
145 if( dVal
> SbxMAXINT
)
147 SbxBase::SetError( SbxERR_OVERFLOW
); nRes
= SbxMAXINT
;
149 else if( dVal
< SbxMININT
)
151 SbxBase::SetError( SbxERR_OVERFLOW
); nRes
= SbxMININT
;
154 nRes
= (INT16
) ImpRound( dVal
);
159 case SbxBYREF
| SbxSTRING
:
166 if( ImpScan( *p
->pString
, d
, t
, NULL
) != SbxERR_OK
)
168 else if( d
> SbxMAXINT
)
170 SbxBase::SetError( SbxERR_OVERFLOW
); nRes
= SbxMAXINT
;
172 else if( d
< SbxMININT
)
174 SbxBase::SetError( SbxERR_OVERFLOW
); nRes
= SbxMININT
;
177 nRes
= (INT16
) ImpRound( d
);
182 SbxValue
* pVal
= PTR_CAST(SbxValue
,p
->pObj
);
184 nRes
= pVal
->GetInteger();
187 SbxBase::SetError( SbxERR_NO_OBJECT
); nRes
= 0;
192 case SbxBYREF
| SbxCHAR
:
193 nRes
= *p
->pChar
; break;
194 case SbxBYREF
| SbxBYTE
:
195 nRes
= *p
->pByte
; break;
196 case SbxBYREF
| SbxINTEGER
:
197 case SbxBYREF
| SbxBOOL
:
198 nRes
= *p
->pInteger
; break;
200 // ab hier muss getestet werden
201 case SbxBYREF
| SbxLONG
:
202 aTmp
.nLong
= *p
->pLong
; goto ref
;
203 case SbxBYREF
| SbxULONG
:
204 aTmp
.nULong
= *p
->pULong
; goto ref
;
205 case SbxBYREF
| SbxERROR
:
206 case SbxBYREF
| SbxUSHORT
:
207 aTmp
.nUShort
= *p
->pUShort
; goto ref
;
208 case SbxBYREF
| SbxSINGLE
:
209 aTmp
.nSingle
= *p
->pSingle
; goto ref
;
210 case SbxBYREF
| SbxDATE
:
211 case SbxBYREF
| SbxDOUBLE
:
212 aTmp
.nDouble
= *p
->pDouble
; goto ref
;
213 case SbxBYREF
| SbxULONG64
:
214 aTmp
.nULong64
= *p
->pULong64
; goto ref
;
215 case SbxBYREF
| SbxLONG64
:
216 case SbxBYREF
| SbxCURRENCY
:
217 aTmp
.nLong64
= *p
->pLong64
; goto ref
;
218 case SbxBYREF
| SbxSALINT64
:
219 aTmp
.nInt64
= *p
->pnInt64
; goto ref
;
220 case SbxBYREF
| SbxSALUINT64
:
221 aTmp
.uInt64
= *p
->puInt64
; goto ref
;
223 aTmp
.eType
= SbxDataType( p
->eType
& 0x0FFF );
224 p
= &aTmp
; goto start
;
227 SbxBase::SetError( SbxERR_CONVERSION
); nRes
= 0;
232 void ImpPutInteger( SbxValues
* p
, INT16 n
)
238 // hier muss getestet werden
240 aTmp
.pChar
= &p
->nChar
; goto direct
;
242 aTmp
.pByte
= &p
->nByte
; goto direct
;
244 aTmp
.pULong
= &p
->nULong
; goto direct
;
247 aTmp
.pUShort
= &p
->nUShort
; goto direct
;
249 aTmp
.puInt64
= &p
->uInt64
; goto direct
;
251 aTmp
.eType
= SbxDataType( p
->eType
| SbxBYREF
);
252 p
= &aTmp
; goto start
;
254 // ab hier nicht mehr
257 p
->nInteger
= n
; break;
261 p
->nSingle
= n
; break;
264 p
->nDouble
= n
; break;
266 p
->nInt64
= n
; break;
268 p
->nULong64
= ImpDoubleToUINT64( (double)n
); break;
270 p
->nLong64
= ImpDoubleToINT64( (double)n
); break;
272 p
->nLong64
= ImpDoubleToCurrency( (double)n
); break;
274 case SbxBYREF
| SbxDECIMAL
:
275 ImpCreateDecimal( p
)->setInt( n
);
280 case SbxBYREF
| SbxSTRING
:
282 p
->pString
= new XubString
;
283 ImpCvtNum( (double) n
, 0, *p
->pString
);
287 SbxValue
* pVal
= PTR_CAST(SbxValue
,p
->pObj
);
289 pVal
->PutInteger( n
);
291 SbxBase::SetError( SbxERR_NO_OBJECT
);
294 case SbxBYREF
| SbxCHAR
:
297 SbxBase::SetError( SbxERR_OVERFLOW
); n
= SbxMINCHAR
;
299 *p
->pChar
= (char) n
; break;
300 case SbxBYREF
| SbxBYTE
:
303 SbxBase::SetError( SbxERR_OVERFLOW
); n
= SbxMAXBYTE
;
307 SbxBase::SetError( SbxERR_OVERFLOW
); n
= 0;
309 *p
->pByte
= (BYTE
) n
; break;
310 case SbxBYREF
| SbxINTEGER
:
311 case SbxBYREF
| SbxBOOL
:
312 *p
->pInteger
= n
; break;
313 case SbxBYREF
| SbxERROR
:
314 case SbxBYREF
| SbxUSHORT
:
317 SbxBase::SetError( SbxERR_OVERFLOW
); n
= 0;
319 *p
->pUShort
= (UINT16
) n
; break;
320 case SbxBYREF
| SbxLONG
:
321 *p
->pLong
= (INT32
) n
; break;
322 case SbxBYREF
| SbxULONG
:
325 SbxBase::SetError( SbxERR_OVERFLOW
); n
= 0;
327 *p
->pULong
= (UINT32
) n
; break;
328 case SbxBYREF
| SbxSALINT64
:
329 *p
->pnInt64
= n
; break;
330 case SbxBYREF
| SbxSALUINT64
:
333 SbxBase::SetError( SbxERR_OVERFLOW
); *p
->puInt64
= 0;
338 case SbxBYREF
| SbxSINGLE
:
339 *p
->pSingle
= (float) n
; break;
340 case SbxBYREF
| SbxDATE
:
341 case SbxBYREF
| SbxDOUBLE
:
342 *p
->pDouble
= (double) n
; break;
343 case SbxBYREF
| SbxULONG64
:
344 *p
->pULong64
= ImpDoubleToUINT64( (double)n
); break;
345 case SbxBYREF
| SbxLONG64
:
346 *p
->pLong64
= ImpDoubleToINT64( (double)n
); break;
347 case SbxBYREF
| SbxCURRENCY
:
348 *p
->pLong64
= ImpDoubleToCurrency( (double)n
); break;
351 SbxBase::SetError( SbxERR_CONVERSION
);
358 sal_Int64
ImpDoubleToSalInt64( double d
)
361 if( d
> SbxMAXSALINT64
)
363 SbxBase::SetError( SbxERR_OVERFLOW
); nRes
= SbxMAXSALINT64
;
365 else if( d
< SbxMINSALINT64
)
367 SbxBase::SetError( SbxERR_OVERFLOW
); nRes
= SbxMINSALINT64
;
370 nRes
= (sal_Int64
) ImpRound( d
);
374 sal_uInt64
ImpDoubleToSalUInt64( double d
)
377 if( d
> SbxMAXSALUINT64
)
379 SbxBase::SetError( SbxERR_OVERFLOW
); nRes
= SbxMAXSALUINT64
;
383 SbxBase::SetError( SbxERR_OVERFLOW
); nRes
= 0;
386 nRes
= (sal_uInt64
) ImpRound( d
);
390 double ImpSalUInt64ToDouble( sal_uInt64 n
)
393 if( n
> SbxMAXSALINT64
)
394 SbxBase::SetError( SbxERR_CONVERSION
);
396 d
= (double)(sal_Int64
) n
;
401 sal_Int64
ImpGetInt64( const SbxValues
* p
)
409 SbxBase::SetError( SbxERR_CONVERSION
);
413 nRes
= p
->nChar
; break;
415 nRes
= p
->nByte
; break;
418 nRes
= p
->nInteger
; break;
421 nRes
= p
->nUShort
; break;
423 nRes
= p
->nLong
; break;
425 nRes
= (sal_Int64
) p
->nULong
; break;
427 nRes
= ImpDoubleToSalInt64( (double)p
->nSingle
);
436 if( p
->eType
== SbxCURRENCY
)
437 dVal
= ImpCurrencyToDouble( p
->nLong64
);
438 else if( p
->eType
== SbxLONG64
)
439 dVal
= ImpINT64ToDouble( p
->nLong64
);
440 else if( p
->eType
== SbxULONG64
)
441 dVal
= ImpUINT64ToDouble( p
->nULong64
);
445 nRes
= ImpDoubleToSalInt64( dVal
);
449 nRes
= p
->nInt64
; break;
451 if( p
->uInt64
> SbxMAXSALINT64
)
453 SbxBase::SetError( SbxERR_OVERFLOW
); nRes
= SbxMAXSALINT64
;
456 nRes
= (sal_Int64
) p
->uInt64
;
459 case SbxBYREF
| SbxSTRING
:
466 ::rtl::OUString
aOUStr( *p
->pString
);
467 ::rtl::OString aOStr
= ::rtl::OUStringToOString
468 ( aOUStr
, RTL_TEXTENCODING_ASCII_US
);
469 nRes
= aOStr
.toInt64();
472 // Check if really 0 or invalid conversion
475 if( ImpScan( *p
->pString
, d
, t
, NULL
) != SbxERR_OK
)
478 nRes
= ImpDoubleToSalInt64( d
);
484 SbxValue
* pVal
= PTR_CAST(SbxValue
,p
->pObj
);
486 nRes
= pVal
->GetInt64();
489 SbxBase::SetError( SbxERR_NO_OBJECT
); nRes
= 0;
494 case SbxBYREF
| SbxCHAR
:
495 nRes
= *p
->pChar
; break;
496 case SbxBYREF
| SbxBYTE
:
497 nRes
= *p
->pByte
; break;
498 case SbxBYREF
| SbxINTEGER
:
499 case SbxBYREF
| SbxBOOL
:
500 nRes
= *p
->pInteger
; break;
501 case SbxBYREF
| SbxLONG
:
502 nRes
= *p
->pLong
; break;
503 case SbxBYREF
| SbxULONG
:
504 nRes
= *p
->pULong
; break;
505 case SbxBYREF
| SbxSALINT64
:
506 nRes
= *p
->pnInt64
; break;
508 // from here the values has to be checked
509 case SbxBYREF
| SbxERROR
:
510 case SbxBYREF
| SbxUSHORT
:
511 aTmp
.nUShort
= *p
->pUShort
; goto ref
;
512 case SbxBYREF
| SbxSINGLE
:
513 aTmp
.nSingle
= *p
->pSingle
; goto ref
;
514 case SbxBYREF
| SbxDATE
:
515 case SbxBYREF
| SbxDOUBLE
:
516 aTmp
.nDouble
= *p
->pDouble
; goto ref
;
517 case SbxBYREF
| SbxULONG64
:
518 aTmp
.nULong64
= *p
->pULong64
; goto ref
;
519 case SbxBYREF
| SbxLONG64
:
520 case SbxBYREF
| SbxCURRENCY
:
521 aTmp
.nLong64
= *p
->pLong64
; goto ref
;
522 case SbxBYREF
| SbxSALUINT64
:
523 aTmp
.uInt64
= *p
->puInt64
; goto ref
;
525 aTmp
.eType
= SbxDataType( p
->eType
& 0x0FFF );
526 p
= &aTmp
; goto start
;
529 SbxBase::SetError( SbxERR_CONVERSION
); nRes
= 0;
534 void ImpPutInt64( SbxValues
* p
, sal_Int64 n
)
543 aTmp
.pChar
= &p
->nChar
; goto direct
;
545 aTmp
.pByte
= &p
->nByte
; goto direct
;
548 aTmp
.pInteger
= &p
->nInteger
; goto direct
;
550 aTmp
.pULong64
= &p
->nULong64
; goto direct
;
553 aTmp
.pLong64
= &p
->nLong64
; goto direct
;
555 aTmp
.pULong
= &p
->nULong
; goto direct
;
558 aTmp
.pUShort
= &p
->nUShort
; goto direct
;
560 aTmp
.pnInt64
= &p
->nInt64
; goto direct
;
562 aTmp
.puInt64
= &p
->uInt64
; goto direct
;
565 aTmp
.eType
= SbxDataType( p
->eType
| SbxBYREF
);
566 p
= &aTmp
; goto start
;
568 // Check not neccessary
570 p
->nInt64
= n
; break;
572 p
->nSingle
= (float) n
; break;
575 p
->nDouble
= (double) n
; break;
577 case SbxBYREF
| SbxSTRING
:
582 p
->pString
= new XubString
;
584 ::rtl::OString aOStr
= ::rtl::OString::valueOf( n
);
585 ::rtl::OUString aOUStr
= ::rtl::OStringToOUString
586 ( aOStr
, RTL_TEXTENCODING_ASCII_US
);
587 (*p
->pString
) = aOUStr
;
592 SbxValue
* pVal
= PTR_CAST(SbxValue
,p
->pObj
);
596 SbxBase::SetError( SbxERR_NO_OBJECT
);
599 case SbxBYREF
| SbxCHAR
:
602 SbxBase::SetError( SbxERR_OVERFLOW
); n
= SbxMAXCHAR
;
604 else if( n
< SbxMINCHAR
)
606 SbxBase::SetError( SbxERR_OVERFLOW
); n
= SbxMINCHAR
;
608 *p
->pChar
= (xub_Unicode
) n
; break;
609 case SbxBYREF
| SbxBYTE
:
612 SbxBase::SetError( SbxERR_OVERFLOW
); n
= SbxMAXBYTE
;
616 SbxBase::SetError( SbxERR_OVERFLOW
); n
= 0;
618 *p
->pByte
= (BYTE
) n
; break;
619 case SbxBYREF
| SbxINTEGER
:
620 case SbxBYREF
| SbxBOOL
:
623 SbxBase::SetError( SbxERR_OVERFLOW
); n
= SbxMAXINT
;
625 else if( n
< SbxMININT
)
627 SbxBase::SetError( SbxERR_OVERFLOW
); n
= SbxMININT
;
629 *p
->pInteger
= (INT16
) n
; break;
630 case SbxBYREF
| SbxERROR
:
631 case SbxBYREF
| SbxUSHORT
:
634 SbxBase::SetError( SbxERR_OVERFLOW
); n
= SbxMAXUINT
;
638 SbxBase::SetError( SbxERR_OVERFLOW
); n
= 0;
640 *p
->pUShort
= (UINT16
) n
; break;
641 case SbxBYREF
| SbxLONG
:
644 SbxBase::SetError( SbxERR_OVERFLOW
); n
= SbxMAXLNG
;
646 else if( n
< SbxMINLNG
)
648 SbxBase::SetError( SbxERR_OVERFLOW
); n
= SbxMINLNG
;
650 *p
->pLong
= (INT32
) n
; break;
651 case SbxBYREF
| SbxULONG
:
654 SbxBase::SetError( SbxERR_OVERFLOW
); n
= SbxMAXULNG
;
658 SbxBase::SetError( SbxERR_OVERFLOW
); n
= 0;
660 *p
->pULong
= (UINT32
) n
; break;
661 case SbxBYREF
| SbxSINGLE
:
662 *p
->pSingle
= (float) n
; break;
663 case SbxBYREF
| SbxDATE
:
664 case SbxBYREF
| SbxDOUBLE
:
665 *p
->pDouble
= (double) n
; break;
666 case SbxBYREF
| SbxCURRENCY
:
669 SbxBase::SetError( SbxERR_OVERFLOW
); n
= (sal_Int64
) SbxMAXCURR
;
671 else if( n
< SbxMINCURR
)
673 SbxBase::SetError( SbxERR_OVERFLOW
); n
= (sal_Int64
) SbxMINCURR
;
675 *p
->pLong64
= ImpDoubleToCurrency( (double)n
); break;
677 case SbxBYREF
| SbxSALINT64
:
678 *p
->pnInt64
= n
; break;
679 case SbxBYREF
| SbxSALUINT64
:
682 SbxBase::SetError( SbxERR_OVERFLOW
); n
= 0;
684 *p
->puInt64
= (sal_Int64
) n
; break;
687 SbxBase::SetError( SbxERR_CONVERSION
);
691 sal_uInt64
ImpGetUInt64( const SbxValues
* p
)
699 SbxBase::SetError( SbxERR_CONVERSION
);
703 nRes
= p
->nChar
; break;
705 nRes
= p
->nByte
; break;
708 nRes
= p
->nInteger
; break;
711 nRes
= p
->nUShort
; break;
713 nRes
= p
->nLong
; break;
715 nRes
= (sal_uInt64
) p
->nULong
; break;
717 nRes
= ImpDoubleToSalUInt64( (double)p
->nSingle
);
726 if( p
->eType
== SbxCURRENCY
)
727 dVal
= ImpCurrencyToDouble( p
->nLong64
);
728 else if( p
->eType
== SbxLONG64
)
729 dVal
= ImpINT64ToDouble( p
->nLong64
);
730 else if( p
->eType
== SbxULONG64
)
731 dVal
= ImpUINT64ToDouble( p
->nULong64
);
735 nRes
= ImpDoubleToSalUInt64( dVal
);
741 SbxBase::SetError( SbxERR_OVERFLOW
); nRes
= 0;
744 nRes
= (sal_uInt64
) p
->nInt64
;
746 nRes
= p
->uInt64
; break;
748 case SbxBYREF
| SbxSTRING
:
755 ::rtl::OUString
aOUStr( *p
->pString
);
756 ::rtl::OString aOStr
= ::rtl::OUStringToOString
757 ( aOUStr
, RTL_TEXTENCODING_ASCII_US
);
758 sal_Int64 n64
= aOStr
.toInt64();
761 // Check if really 0 or invalid conversion
764 if( ImpScan( *p
->pString
, d
, t
, NULL
) != SbxERR_OK
)
766 else if( d
> SbxMAXSALUINT64
)
768 SbxBase::SetError( SbxERR_OVERFLOW
); nRes
= SbxMAXSALUINT64
;
772 SbxBase::SetError( SbxERR_OVERFLOW
); nRes
= 0;
775 nRes
= (sal_uInt64
) ImpRound( d
);
779 SbxBase::SetError( SbxERR_OVERFLOW
); nRes
= 0;
789 SbxValue
* pVal
= PTR_CAST(SbxValue
,p
->pObj
);
791 nRes
= pVal
->GetUInt64();
794 SbxBase::SetError( SbxERR_NO_OBJECT
); nRes
= 0;
799 case SbxBYREF
| SbxCHAR
:
800 nRes
= *p
->pChar
; break;
801 case SbxBYREF
| SbxBYTE
:
802 nRes
= *p
->pByte
; break;
803 case SbxBYREF
| SbxINTEGER
:
804 case SbxBYREF
| SbxBOOL
:
805 nRes
= *p
->pInteger
; break;
806 case SbxBYREF
| SbxLONG
:
807 nRes
= *p
->pLong
; break;
808 case SbxBYREF
| SbxULONG
:
809 nRes
= *p
->pULong
; break;
810 case SbxBYREF
| SbxSALUINT64
:
811 nRes
= *p
->puInt64
; break;
813 // from here the values has to be checked
814 case SbxBYREF
| SbxERROR
:
815 case SbxBYREF
| SbxUSHORT
:
816 aTmp
.nUShort
= *p
->pUShort
; goto ref
;
817 case SbxBYREF
| SbxSINGLE
:
818 aTmp
.nSingle
= *p
->pSingle
; goto ref
;
819 case SbxBYREF
| SbxDATE
:
820 case SbxBYREF
| SbxDOUBLE
:
821 aTmp
.nDouble
= *p
->pDouble
; goto ref
;
822 case SbxBYREF
| SbxULONG64
:
823 aTmp
.nULong64
= *p
->pULong64
; goto ref
;
824 case SbxBYREF
| SbxLONG64
:
825 case SbxBYREF
| SbxCURRENCY
:
826 aTmp
.nLong64
= *p
->pLong64
; goto ref
;
827 case SbxBYREF
| SbxSALINT64
:
828 aTmp
.nInt64
= *p
->pnInt64
; goto ref
;
830 aTmp
.eType
= SbxDataType( p
->eType
& 0x0FFF );
831 p
= &aTmp
; goto start
;
834 SbxBase::SetError( SbxERR_CONVERSION
); nRes
= 0;
839 void ImpPutUInt64( SbxValues
* p
, sal_uInt64 n
)
848 aTmp
.pChar
= &p
->nChar
; goto direct
;
850 aTmp
.pByte
= &p
->nByte
; goto direct
;
853 aTmp
.pInteger
= &p
->nInteger
; goto direct
;
855 aTmp
.pULong64
= &p
->nULong64
; goto direct
;
858 aTmp
.pLong64
= &p
->nLong64
; goto direct
;
860 aTmp
.pULong
= &p
->nULong
; goto direct
;
863 aTmp
.pUShort
= &p
->nUShort
; goto direct
;
865 aTmp
.pnInt64
= &p
->nInt64
; goto direct
;
867 aTmp
.pnInt64
= &p
->nInt64
; goto direct
;
869 aTmp
.pSingle
= &p
->nSingle
; goto direct
;
872 aTmp
.pDouble
= &p
->nDouble
; goto direct
;
875 aTmp
.eType
= SbxDataType( p
->eType
| SbxBYREF
);
876 p
= &aTmp
; goto start
;
878 // Check not neccessary
880 p
->uInt64
= n
; break;
882 case SbxBYREF
| SbxSTRING
:
886 p
->pString
= new XubString
;
887 if( n
> SbxMAXSALINT64
)
888 SbxBase::SetError( SbxERR_CONVERSION
);
891 ::rtl::OString aOStr
= ::rtl::OString::valueOf( (sal_Int64
)n
);
892 ::rtl::OUString aOUStr
= ::rtl::OStringToOUString
893 ( aOStr
, RTL_TEXTENCODING_ASCII_US
);
894 (*p
->pString
) = aOUStr
;
899 SbxValue
* pVal
= PTR_CAST(SbxValue
,p
->pObj
);
901 pVal
->PutUInt64( n
);
903 SbxBase::SetError( SbxERR_NO_OBJECT
);
906 case SbxBYREF
| SbxCHAR
:
909 SbxBase::SetError( SbxERR_OVERFLOW
); n
= SbxMAXCHAR
;
911 *p
->pChar
= (xub_Unicode
) n
; break;
912 case SbxBYREF
| SbxBYTE
:
915 SbxBase::SetError( SbxERR_OVERFLOW
); n
= SbxMAXBYTE
;
917 *p
->pByte
= (BYTE
) n
; break;
918 case SbxBYREF
| SbxINTEGER
:
919 case SbxBYREF
| SbxBOOL
:
922 SbxBase::SetError( SbxERR_OVERFLOW
); n
= SbxMAXINT
;
924 *p
->pInteger
= (INT16
) n
; break;
925 case SbxBYREF
| SbxERROR
:
926 case SbxBYREF
| SbxUSHORT
:
929 SbxBase::SetError( SbxERR_OVERFLOW
); n
= SbxMAXUINT
;
931 *p
->pUShort
= (UINT16
) n
; break;
932 case SbxBYREF
| SbxLONG
:
935 SbxBase::SetError( SbxERR_OVERFLOW
); n
= SbxMAXLNG
;
937 *p
->pLong
= (INT32
) n
; break;
938 case SbxBYREF
| SbxULONG
:
941 SbxBase::SetError( SbxERR_OVERFLOW
); n
= SbxMAXULNG
;
943 *p
->pULong
= (UINT32
) n
; break;
944 case SbxBYREF
| SbxSINGLE
:
945 *p
->pDouble
= (float)ImpSalUInt64ToDouble( n
); break;
946 case SbxBYREF
| SbxDATE
:
947 case SbxBYREF
| SbxDOUBLE
:
948 *p
->pDouble
= ImpSalUInt64ToDouble( n
); break;
949 case SbxBYREF
| SbxCURRENCY
:
950 if( n
> SbxMAXSALINT64
|| (sal_Int64
)n
> SbxMAXCURR
)
952 SbxBase::SetError( SbxERR_OVERFLOW
); n
= (sal_Int64
) SbxMAXCURR
;
954 *p
->pLong64
= ImpDoubleToCurrency( (double)(sal_Int64
) n
); break;
956 case SbxBYREF
| SbxSALUINT64
:
957 *p
->puInt64
= n
; break;
958 case SbxBYREF
| SbxSALINT64
:
959 if( n
> SbxMAXSALINT64
)
961 SbxBase::SetError( SbxERR_OVERFLOW
); n
= 0;
963 *p
->pnInt64
= (sal_Int64
) n
; break;
966 SbxBase::SetError( SbxERR_CONVERSION
);