1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <tools/errcode.hxx>
21 #include <basic/sbx.hxx>
22 #include "sbxconv.hxx"
24 double ImpRound( double d
)
26 return d
+ ( d
< 0 ? -0.5 : 0.5 );
29 sal_Int16
ImpGetInteger( const SbxValues
* p
)
37 SbxBase::SetError( SbxERR_CONVERSION
);
41 nRes
= p
->nChar
; break;
43 nRes
= p
->nByte
; break;
46 nRes
= p
->nInteger
; break;
49 if( p
->nUShort
> (sal_uInt16
) SbxMAXINT
)
51 SbxBase::SetError( SbxERR_OVERFLOW
); nRes
= SbxMAXINT
;
54 nRes
= (sal_Int16
) p
->nUShort
;
57 if( p
->nLong
> SbxMAXINT
)
59 SbxBase::SetError( SbxERR_OVERFLOW
); nRes
= SbxMAXINT
;
61 else if( p
->nLong
< SbxMININT
)
63 SbxBase::SetError( SbxERR_OVERFLOW
); nRes
= SbxMININT
;
66 nRes
= (sal_Int16
) p
->nLong
;
69 if( p
->nULong
> SbxMAXINT
)
71 SbxBase::SetError( SbxERR_OVERFLOW
); nRes
= SbxMAXINT
;
74 nRes
= (sal_Int16
) p
->nULong
;
77 if( p
->nSingle
> SbxMAXINT
)
79 SbxBase::SetError( SbxERR_OVERFLOW
); nRes
= SbxMAXINT
;
81 else if( p
->nSingle
< SbxMININT
)
83 SbxBase::SetError( SbxERR_OVERFLOW
); nRes
= SbxMININT
;
86 nRes
= (sal_Int16
) ImpRound( p
->nSingle
);
90 sal_Int64 tstVal
= (sal_Int64
) p
->nInt64
/ (sal_Int64
) CURRENCY_FACTOR
;
92 if( tstVal
> SbxMAXINT
)
94 SbxBase::SetError( SbxERR_OVERFLOW
); nRes
= SbxMAXINT
;
96 else if( tstVal
< SbxMININT
)
98 SbxBase::SetError( SbxERR_OVERFLOW
); nRes
= SbxMININT
;
101 nRes
= (sal_Int16
) (tstVal
);
105 if( p
->nInt64
> SbxMAXINT
)
107 SbxBase::SetError( SbxERR_OVERFLOW
); nRes
= SbxMAXINT
;
109 else if( p
->nInt64
< SbxMININT
)
111 SbxBase::SetError( SbxERR_OVERFLOW
); nRes
= SbxMININT
;
114 nRes
= (sal_Int16
) p
->nInt64
;
117 if( p
->uInt64
> SbxMAXINT
)
119 SbxBase::SetError( SbxERR_OVERFLOW
); nRes
= SbxMAXINT
;
122 nRes
= (sal_Int16
) p
->uInt64
;
127 case SbxBYREF
| SbxDECIMAL
:
130 if( p
->eType
== SbxDECIMAL
)
133 p
->pDecimal
->getDouble( dVal
);
138 if( dVal
> SbxMAXINT
)
140 SbxBase::SetError( SbxERR_OVERFLOW
); nRes
= SbxMAXINT
;
142 else if( dVal
< SbxMININT
)
144 SbxBase::SetError( SbxERR_OVERFLOW
); nRes
= SbxMININT
;
147 nRes
= (sal_Int16
) ImpRound( dVal
);
152 case SbxBYREF
| SbxSTRING
:
159 if( ImpScan( *p
->pOUString
, d
, t
, NULL
) != SbxERR_OK
)
161 else if( d
> SbxMAXINT
)
163 SbxBase::SetError( SbxERR_OVERFLOW
); nRes
= SbxMAXINT
;
165 else if( d
< SbxMININT
)
167 SbxBase::SetError( SbxERR_OVERFLOW
); nRes
= SbxMININT
;
170 nRes
= (sal_Int16
) ImpRound( d
);
175 SbxValue
* pVal
= PTR_CAST(SbxValue
,p
->pObj
);
177 nRes
= pVal
->GetInteger();
180 SbxBase::SetError( SbxERR_NO_OBJECT
); nRes
= 0;
185 case SbxBYREF
| SbxCHAR
:
186 nRes
= *p
->pChar
; break;
187 case SbxBYREF
| SbxBYTE
:
188 nRes
= *p
->pByte
; break;
189 case SbxBYREF
| SbxINTEGER
:
190 case SbxBYREF
| SbxBOOL
:
191 nRes
= *p
->pInteger
; break;
193 // from here had to be tested
194 case SbxBYREF
| SbxLONG
:
195 aTmp
.nLong
= *p
->pLong
; goto ref
;
196 case SbxBYREF
| SbxULONG
:
197 aTmp
.nULong
= *p
->pULong
; goto ref
;
198 case SbxBYREF
| SbxERROR
:
199 case SbxBYREF
| SbxUSHORT
:
200 aTmp
.nUShort
= *p
->pUShort
; goto ref
;
201 case SbxBYREF
| SbxSINGLE
:
202 aTmp
.nSingle
= *p
->pSingle
; goto ref
;
203 case SbxBYREF
| SbxDATE
:
204 case SbxBYREF
| SbxDOUBLE
:
205 aTmp
.nDouble
= *p
->pDouble
; goto ref
;
206 case SbxBYREF
| SbxCURRENCY
:
207 case SbxBYREF
| SbxSALINT64
:
208 aTmp
.nInt64
= *p
->pnInt64
; goto ref
;
209 case SbxBYREF
| SbxSALUINT64
:
210 aTmp
.uInt64
= *p
->puInt64
; goto ref
;
212 aTmp
.eType
= SbxDataType( p
->eType
& 0x0FFF );
213 p
= &aTmp
; goto start
;
216 SbxBase::SetError( SbxERR_CONVERSION
); nRes
= 0;
221 void ImpPutInteger( SbxValues
* p
, sal_Int16 n
)
227 // here had to be tested
229 aTmp
.pChar
= &p
->nChar
; goto direct
;
231 aTmp
.pByte
= &p
->nByte
; goto direct
;
233 aTmp
.pULong
= &p
->nULong
; goto direct
;
236 aTmp
.pUShort
= &p
->nUShort
; goto direct
;
238 aTmp
.puInt64
= &p
->uInt64
; goto direct
;
240 aTmp
.eType
= SbxDataType( p
->eType
| SbxBYREF
);
241 p
= &aTmp
; goto start
;
243 // from here no tests needed
246 p
->nInteger
= n
; break;
250 p
->nSingle
= n
; break;
253 p
->nDouble
= n
; break;
255 p
->nInt64
= n
* CURRENCY_FACTOR
; break;
257 p
->nInt64
= n
; break;
259 case SbxBYREF
| SbxDECIMAL
:
260 ImpCreateDecimal( p
)->setInt( n
);
265 case SbxBYREF
| SbxSTRING
:
267 p
->pOUString
= new ::rtl::OUString
;
268 ImpCvtNum( (double) n
, 0, *p
->pOUString
);
272 SbxValue
* pVal
= PTR_CAST(SbxValue
,p
->pObj
);
274 pVal
->PutInteger( n
);
276 SbxBase::SetError( SbxERR_NO_OBJECT
);
279 case SbxBYREF
| SbxCHAR
:
282 SbxBase::SetError( SbxERR_OVERFLOW
); n
= SbxMINCHAR
;
284 *p
->pChar
= (char) n
; break;
285 case SbxBYREF
| SbxBYTE
:
288 SbxBase::SetError( SbxERR_OVERFLOW
); n
= SbxMAXBYTE
;
292 SbxBase::SetError( SbxERR_OVERFLOW
); n
= 0;
294 *p
->pByte
= (sal_uInt8
) n
; break;
295 case SbxBYREF
| SbxINTEGER
:
296 case SbxBYREF
| SbxBOOL
:
297 *p
->pInteger
= n
; break;
298 case SbxBYREF
| SbxERROR
:
299 case SbxBYREF
| SbxUSHORT
:
302 SbxBase::SetError( SbxERR_OVERFLOW
); n
= 0;
304 *p
->pUShort
= (sal_uInt16
) n
; break;
305 case SbxBYREF
| SbxLONG
:
306 *p
->pLong
= (sal_Int32
) n
; break;
307 case SbxBYREF
| SbxULONG
:
310 SbxBase::SetError( SbxERR_OVERFLOW
); n
= 0;
312 *p
->pULong
= (sal_uInt32
) n
; break;
313 case SbxBYREF
| SbxCURRENCY
:
314 *p
->pnInt64
= n
* CURRENCY_FACTOR
; break;
315 case SbxBYREF
| SbxSALINT64
:
316 *p
->pnInt64
= n
; break;
317 case SbxBYREF
| SbxSALUINT64
:
320 SbxBase::SetError( SbxERR_OVERFLOW
);
326 case SbxBYREF
| SbxSINGLE
:
327 *p
->pSingle
= (float) n
; break;
328 case SbxBYREF
| SbxDATE
:
329 case SbxBYREF
| SbxDOUBLE
:
330 *p
->pDouble
= (double) n
; break;
333 SbxBase::SetError( SbxERR_CONVERSION
);
340 sal_Int64
ImpDoubleToSalInt64( double d
)
343 if( d
> SbxMAXSALINT64
)
345 SbxBase::SetError( SbxERR_OVERFLOW
); nRes
= SbxMAXSALINT64
;
347 else if( d
< SbxMINSALINT64
)
349 SbxBase::SetError( SbxERR_OVERFLOW
); nRes
= SbxMINSALINT64
;
352 nRes
= (sal_Int64
) ImpRound( d
);
356 sal_uInt64
ImpDoubleToSalUInt64( double d
)
359 if( d
> SbxMAXSALUINT64
)
361 SbxBase::SetError( SbxERR_OVERFLOW
); nRes
= SbxMAXSALUINT64
;
365 SbxBase::SetError( SbxERR_OVERFLOW
); nRes
= 0;
368 nRes
= (sal_uInt64
) ImpRound( d
);
373 double ImpSalUInt64ToDouble( sal_uInt64 n
)
376 if( n
> SbxMAXSALINT64
)
377 SbxBase::SetError( SbxERR_CONVERSION
);
379 d
= (double)(sal_Int64
) n
;
384 sal_Int64
ImpGetInt64( const SbxValues
* p
)
392 SbxBase::SetError( SbxERR_CONVERSION
);
396 nRes
= p
->nChar
; break;
398 nRes
= p
->nByte
; break;
401 nRes
= p
->nInteger
; break;
404 nRes
= (sal_Int64
) p
->nUShort
; break;
406 nRes
= (sal_Int64
) p
->nLong
; break;
408 nRes
= (sal_Int64
) p
->nULong
; break;
410 nRes
= (sal_Int64
) p
->nSingle
;
414 nRes
= (sal_Int64
) p
->nDouble
;
417 nRes
= p
->nInt64
/ CURRENCY_FACTOR
; break;
419 nRes
= p
->nInt64
; break;
421 if( p
->uInt64
> SbxMAXSALINT64
)
423 SbxBase::SetError( SbxERR_OVERFLOW
); nRes
= SbxMAXSALINT64
;
426 nRes
= (sal_Int64
) p
->uInt64
;
429 case SbxBYREF
| SbxSTRING
:
436 ::rtl::OString aOStr
= ::rtl::OUStringToOString
437 ( *p
->pOUString
, RTL_TEXTENCODING_ASCII_US
);
438 nRes
= aOStr
.toInt64();
441 // Check if really 0 or invalid conversion
444 if( ImpScan( *p
->pOUString
, d
, t
, NULL
) != SbxERR_OK
)
447 nRes
= (sal_Int64
) d
;
453 SbxValue
* pVal
= PTR_CAST(SbxValue
,p
->pObj
);
455 nRes
= pVal
->GetInt64();
458 SbxBase::SetError( SbxERR_NO_OBJECT
); nRes
= 0;
463 case SbxBYREF
| SbxCHAR
:
464 nRes
= *p
->pChar
; break;
465 case SbxBYREF
| SbxBYTE
:
466 nRes
= *p
->pByte
; break;
467 case SbxBYREF
| SbxINTEGER
:
468 case SbxBYREF
| SbxBOOL
:
469 nRes
= *p
->pInteger
; break;
470 case SbxBYREF
| SbxLONG
:
471 nRes
= *p
->pLong
; break;
472 case SbxBYREF
| SbxULONG
:
473 nRes
= *p
->pULong
; break;
474 case SbxBYREF
| SbxCURRENCY
:
475 nRes
= p
->nInt64
/ CURRENCY_FACTOR
; break;
476 case SbxBYREF
| SbxSALINT64
:
477 nRes
= *p
->pnInt64
; break;
479 // from here the values has to be checked
480 case SbxBYREF
| SbxSALUINT64
:
481 aTmp
.uInt64
= *p
->puInt64
; goto ref
;
483 case SbxBYREF
| SbxERROR
:
484 case SbxBYREF
| SbxUSHORT
:
485 aTmp
.nUShort
= *p
->pUShort
; goto ref
;
486 case SbxBYREF
| SbxSINGLE
:
487 aTmp
.nSingle
= *p
->pSingle
; goto ref
;
488 case SbxBYREF
| SbxDATE
:
489 case SbxBYREF
| SbxDOUBLE
:
490 aTmp
.nDouble
= *p
->pDouble
; goto ref
;
492 aTmp
.eType
= SbxDataType( p
->eType
& 0x0FFF );
493 p
= &aTmp
; goto start
;
496 SbxBase::SetError( SbxERR_CONVERSION
); nRes
= 0;
501 void ImpPutInt64( SbxValues
* p
, sal_Int64 n
)
510 aTmp
.pChar
= &p
->nChar
; goto direct
;
512 aTmp
.pByte
= &p
->nByte
; goto direct
;
515 aTmp
.pInteger
= &p
->nInteger
; goto direct
;
517 aTmp
.pULong
= &p
->nULong
; goto direct
;
520 aTmp
.pUShort
= &p
->nUShort
; goto direct
;
522 aTmp
.pnInt64
= &p
->nInt64
; goto direct
;
525 aTmp
.pnInt64
= &p
->nInt64
; goto direct
;
527 aTmp
.puInt64
= &p
->uInt64
; goto direct
;
530 aTmp
.eType
= SbxDataType( p
->eType
| SbxBYREF
);
531 p
= &aTmp
; goto start
;
534 p
->nSingle
= (float) n
; break;
537 p
->nDouble
= (double) n
; break;
539 case SbxBYREF
| SbxSTRING
:
544 p
->pOUString
= new ::rtl::OUString
;
546 ::rtl::OString aOStr
= ::rtl::OString::valueOf( n
);
547 (*p
->pOUString
) = ::rtl::OStringToOUString
548 ( aOStr
, RTL_TEXTENCODING_ASCII_US
);
553 SbxValue
* pVal
= PTR_CAST(SbxValue
,p
->pObj
);
557 SbxBase::SetError( SbxERR_NO_OBJECT
);
560 case SbxBYREF
| SbxCHAR
:
563 SbxBase::SetError( SbxERR_OVERFLOW
); n
= SbxMAXCHAR
;
565 else if( n
< SbxMINCHAR
)
567 SbxBase::SetError( SbxERR_OVERFLOW
); n
= SbxMINCHAR
;
569 *p
->pChar
= (sal_Unicode
) n
; break;
570 case SbxBYREF
| SbxBYTE
:
573 SbxBase::SetError( SbxERR_OVERFLOW
); n
= SbxMAXBYTE
;
577 SbxBase::SetError( SbxERR_OVERFLOW
); n
= 0;
579 *p
->pByte
= (sal_uInt8
) n
; break;
580 case SbxBYREF
| SbxINTEGER
:
581 case SbxBYREF
| SbxBOOL
:
584 SbxBase::SetError( SbxERR_OVERFLOW
); n
= SbxMAXINT
;
586 else if( n
< SbxMININT
)
588 SbxBase::SetError( SbxERR_OVERFLOW
); n
= SbxMININT
;
590 *p
->pInteger
= (sal_Int16
) n
; break;
591 case SbxBYREF
| SbxERROR
:
592 case SbxBYREF
| SbxUSHORT
:
595 SbxBase::SetError( SbxERR_OVERFLOW
); n
= SbxMAXUINT
;
599 SbxBase::SetError( SbxERR_OVERFLOW
); n
= 0;
601 *p
->pUShort
= (sal_uInt16
) n
; break;
602 case SbxBYREF
| SbxLONG
:
605 SbxBase::SetError( SbxERR_OVERFLOW
); n
= SbxMAXLNG
;
607 else if( n
< SbxMINLNG
)
609 SbxBase::SetError( SbxERR_OVERFLOW
); n
= SbxMINLNG
;
611 *p
->pLong
= (sal_Int32
) n
; break;
612 case SbxBYREF
| SbxULONG
:
615 SbxBase::SetError( SbxERR_OVERFLOW
); n
= SbxMAXULNG
;
619 SbxBase::SetError( SbxERR_OVERFLOW
); n
= 0;
621 *p
->pULong
= (sal_uInt32
) n
; break;
622 case SbxBYREF
| SbxSINGLE
:
623 *p
->pSingle
= (float) n
; break;
624 case SbxBYREF
| SbxDATE
:
625 case SbxBYREF
| SbxDOUBLE
:
626 *p
->pDouble
= (double) n
; break;
627 case SbxBYREF
| SbxCURRENCY
:
628 *p
->pnInt64
= n
* CURRENCY_FACTOR
; break;
629 case SbxBYREF
| SbxSALINT64
:
630 *p
->pnInt64
= n
; break;
631 case SbxBYREF
| SbxSALUINT64
:
634 SbxBase::SetError( SbxERR_OVERFLOW
); n
= 0;
636 *p
->puInt64
= (sal_Int64
) n
; break;
639 SbxBase::SetError( SbxERR_CONVERSION
);
643 sal_uInt64
ImpGetUInt64( const SbxValues
* p
)
651 SbxBase::SetError( SbxERR_CONVERSION
);
655 nRes
= p
->nChar
; break;
657 nRes
= p
->nByte
; break;
660 nRes
= p
->nInteger
; break;
663 nRes
= p
->nUShort
; break;
665 nRes
= p
->nLong
; break;
667 nRes
= (sal_uInt64
) p
->nULong
; break;
669 nRes
= (sal_uInt64
) p
->nSingle
; break;
673 //TODO overflow check
674 nRes
= (sal_uInt64
) p
->nDouble
;
678 nRes
= p
->nInt64
* CURRENCY_FACTOR
; break;
682 SbxBase::SetError( SbxERR_OVERFLOW
); nRes
= 0;
685 nRes
= (sal_uInt64
) p
->nInt64
;
688 nRes
= p
->uInt64
; break;
690 case SbxBYREF
| SbxSTRING
:
697 ::rtl::OString aOStr
= ::rtl::OUStringToOString
698 ( *p
->pOUString
, RTL_TEXTENCODING_ASCII_US
);
699 sal_Int64 n64
= aOStr
.toInt64();
702 // Check if really 0 or invalid conversion
705 if( ImpScan( *p
->pOUString
, d
, t
, NULL
) != SbxERR_OK
)
707 else if( d
> SbxMAXSALUINT64
)
709 SbxBase::SetError( SbxERR_OVERFLOW
); nRes
= SbxMAXSALUINT64
;
713 SbxBase::SetError( SbxERR_OVERFLOW
); nRes
= 0;
716 nRes
= (sal_uInt64
) ImpRound( d
);
720 SbxBase::SetError( SbxERR_OVERFLOW
); nRes
= 0;
730 SbxValue
* pVal
= PTR_CAST(SbxValue
,p
->pObj
);
732 nRes
= pVal
->GetUInt64();
735 SbxBase::SetError( SbxERR_NO_OBJECT
); nRes
= 0;
740 case SbxBYREF
| SbxCHAR
:
741 nRes
= *p
->pChar
; break;
742 case SbxBYREF
| SbxBYTE
:
743 nRes
= *p
->pByte
; break;
744 case SbxBYREF
| SbxINTEGER
:
745 case SbxBYREF
| SbxBOOL
:
746 nRes
= *p
->pInteger
; break;
747 case SbxBYREF
| SbxLONG
:
748 nRes
= *p
->pLong
; break;
749 case SbxBYREF
| SbxULONG
:
750 nRes
= *p
->pULong
; break;
751 case SbxBYREF
| SbxSALUINT64
:
752 nRes
= *p
->puInt64
; break;
754 // from here on the value has to be checked
755 case SbxBYREF
| SbxERROR
:
756 case SbxBYREF
| SbxUSHORT
:
757 aTmp
.nUShort
= *p
->pUShort
; goto ref
;
758 case SbxBYREF
| SbxSINGLE
:
759 aTmp
.nSingle
= *p
->pSingle
; goto ref
;
760 case SbxBYREF
| SbxDATE
:
761 case SbxBYREF
| SbxDOUBLE
:
762 aTmp
.nDouble
= *p
->pDouble
; goto ref
;
763 case SbxBYREF
| SbxCURRENCY
:
764 case SbxBYREF
| SbxSALINT64
:
765 aTmp
.nInt64
= *p
->pnInt64
; goto ref
;
767 aTmp
.eType
= SbxDataType( p
->eType
& 0x0FFF );
768 p
= &aTmp
; goto start
;
771 SbxBase::SetError( SbxERR_CONVERSION
); nRes
= 0;
776 void ImpPutUInt64( SbxValues
* p
, sal_uInt64 n
)
785 aTmp
.pChar
= &p
->nChar
; goto direct
;
787 aTmp
.pByte
= &p
->nByte
; goto direct
;
790 aTmp
.pInteger
= &p
->nInteger
; goto direct
;
792 aTmp
.pULong
= &p
->nULong
; goto direct
;
795 aTmp
.pUShort
= &p
->nUShort
; goto direct
;
797 aTmp
.pnInt64
= &p
->nInt64
; goto direct
;
800 aTmp
.pnInt64
= &p
->nInt64
; goto direct
;
802 aTmp
.pSingle
= &p
->nSingle
; goto direct
;
805 aTmp
.pDouble
= &p
->nDouble
; goto direct
;
808 aTmp
.eType
= SbxDataType( p
->eType
| SbxBYREF
);
809 p
= &aTmp
; goto start
;
811 // Check not neccessary
813 p
->uInt64
= n
; break;
815 case SbxBYREF
| SbxSTRING
:
819 p
->pOUString
= new ::rtl::OUString
;
820 if( n
> SbxMAXSALINT64
)
821 SbxBase::SetError( SbxERR_CONVERSION
);
824 ::rtl::OString aOStr
= ::rtl::OString::valueOf( (sal_Int64
)n
);
825 (*p
->pOUString
) = ::rtl::OStringToOUString
826 ( aOStr
, RTL_TEXTENCODING_ASCII_US
);
831 SbxValue
* pVal
= PTR_CAST(SbxValue
,p
->pObj
);
833 pVal
->PutUInt64( n
);
835 SbxBase::SetError( SbxERR_NO_OBJECT
);
838 case SbxBYREF
| SbxCHAR
:
841 SbxBase::SetError( SbxERR_OVERFLOW
); n
= SbxMAXCHAR
;
843 *p
->pChar
= (sal_Unicode
) n
; break;
844 case SbxBYREF
| SbxBYTE
:
847 SbxBase::SetError( SbxERR_OVERFLOW
); n
= SbxMAXBYTE
;
849 *p
->pByte
= (sal_uInt8
) n
; break;
850 case SbxBYREF
| SbxINTEGER
:
851 case SbxBYREF
| SbxBOOL
:
854 SbxBase::SetError( SbxERR_OVERFLOW
); n
= SbxMAXINT
;
856 *p
->pInteger
= (sal_Int16
) n
; break;
857 case SbxBYREF
| SbxERROR
:
858 case SbxBYREF
| SbxUSHORT
:
861 SbxBase::SetError( SbxERR_OVERFLOW
); n
= SbxMAXUINT
;
863 *p
->pUShort
= (sal_uInt16
) n
; break;
864 case SbxBYREF
| SbxLONG
:
867 SbxBase::SetError( SbxERR_OVERFLOW
); n
= SbxMAXLNG
;
869 *p
->pLong
= (sal_Int32
) n
; break;
870 case SbxBYREF
| SbxULONG
:
873 SbxBase::SetError( SbxERR_OVERFLOW
); n
= SbxMAXULNG
;
875 *p
->pULong
= (sal_uInt32
) n
; break;
876 case SbxBYREF
| SbxSINGLE
:
877 *p
->pDouble
= (float)ImpSalUInt64ToDouble( n
); break;
878 case SbxBYREF
| SbxDATE
:
879 case SbxBYREF
| SbxDOUBLE
:
881 *p
->pDouble
= ImpSalUInt64ToDouble( n
); break;
882 case SbxBYREF
| SbxCURRENCY
:
883 if ( n
> ( SbxMAXSALINT64
/ CURRENCY_FACTOR
) )
884 SbxBase::SetError( SbxERR_OVERFLOW
); n
= SbxMAXSALINT64
;
885 *p
->pnInt64
= ( sal_Int64
) ( n
* CURRENCY_FACTOR
); break;
886 case SbxBYREF
| SbxSALUINT64
:
887 *p
->puInt64
= n
; break;
888 case SbxBYREF
| SbxSALINT64
:
889 if( n
> SbxMAXSALINT64
)
891 SbxBase::SetError( SbxERR_OVERFLOW
); n
= 0;
893 *p
->pnInt64
= (sal_Int64
) n
; break;
896 SbxBase::SetError( SbxERR_CONVERSION
);
901 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */