diff options
Diffstat (limited to 'basic/source/sbx/sbxdbl.cxx')
-rw-r--r-- | basic/source/sbx/sbxdbl.cxx | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/basic/source/sbx/sbxdbl.cxx b/basic/source/sbx/sbxdbl.cxx index 823693c3a149..968dc837edb8 100644 --- a/basic/source/sbx/sbxdbl.cxx +++ b/basic/source/sbx/sbxdbl.cxx @@ -19,6 +19,7 @@ #include <config_features.h> +#include <o3tl/float_int_conversion.hxx> #include <vcl/errcode.hxx> #include <basic/sbx.hxx> #include "sbxconv.hxx" @@ -210,17 +211,17 @@ start: break; } case SbxBYREF | SbxCHAR: - if( n > SbxMAXCHAR ) + if( !o3tl::convertsToAtMost(o3tl::roundAway(n), SbxMAXCHAR) ) { SbxBase::SetError( ERRCODE_BASIC_MATH_OVERFLOW ); n = SbxMAXCHAR; } - else if( n < SbxMINCHAR ) + else if( !o3tl::convertsToAtLeast(o3tl::roundAway(n), SbxMINCHAR) ) { SbxBase::SetError( ERRCODE_BASIC_MATH_OVERFLOW ); n = SbxMINCHAR; } *p->pChar = static_cast<sal_Unicode>(n); break; case SbxBYREF | SbxBYTE: - if( n > SbxMAXBYTE ) + if( !o3tl::convertsToAtMost(o3tl::roundAway(n), SbxMAXBYTE) ) { SbxBase::SetError( ERRCODE_BASIC_MATH_OVERFLOW ); n = SbxMAXBYTE; } @@ -231,18 +232,18 @@ start: *p->pByte = static_cast<sal_uInt8>(n); break; case SbxBYREF | SbxINTEGER: case SbxBYREF | SbxBOOL: - if( n > SbxMAXINT ) + if( !o3tl::convertsToAtMost(o3tl::roundAway(n), SbxMAXINT) ) { SbxBase::SetError( ERRCODE_BASIC_MATH_OVERFLOW ); n = SbxMAXINT; } - else if( n < SbxMININT ) + else if( !o3tl::convertsToAtLeast(o3tl::roundAway(n), SbxMININT) ) { SbxBase::SetError( ERRCODE_BASIC_MATH_OVERFLOW ); n = SbxMININT; } *p->pInteger = static_cast<sal_Int16>(n); break; case SbxBYREF | SbxERROR: case SbxBYREF | SbxUSHORT: - if( n > SbxMAXUINT ) + if( !o3tl::convertsToAtMost(o3tl::roundAway(n), SbxMAXUINT) ) { SbxBase::SetError( ERRCODE_BASIC_MATH_OVERFLOW ); n = SbxMAXUINT; } @@ -252,17 +253,17 @@ start: } *p->pUShort = static_cast<sal_uInt16>(n); break; case SbxBYREF | SbxLONG: - if( n > SbxMAXLNG ) + if( !o3tl::convertsToAtMost(o3tl::roundAway(n), SbxMAXLNG) ) { SbxBase::SetError( ERRCODE_BASIC_MATH_OVERFLOW ); n = SbxMAXLNG; } - else if( n < SbxMINLNG ) + else if( !o3tl::convertsToAtLeast(o3tl::roundAway(n), SbxMINLNG) ) { SbxBase::SetError( ERRCODE_BASIC_MATH_OVERFLOW ); n = SbxMINLNG; } *p->pLong = static_cast<sal_Int32>(n); break; case SbxBYREF | SbxULONG: - if( n > SbxMAXULNG ) + if( !o3tl::convertsToAtMost(o3tl::roundAway(n), SbxMAXULNG) ) { SbxBase::SetError( ERRCODE_BASIC_MATH_OVERFLOW ); n = SbxMAXULNG; } |