diff options
-rw-r--r-- | basic/qa/basic_coverage/test_types_conversion.vb | 15 | ||||
-rw-r--r-- | basic/source/inc/rtlproto.hxx | 2 | ||||
-rw-r--r-- | basic/source/runtime/methods1.cxx | 15 | ||||
-rw-r--r-- | basic/source/runtime/stdobj.cxx | 1 | ||||
-rw-r--r-- | basic/source/sbx/sbxbool.cxx | 3 | ||||
-rw-r--r-- | basic/source/sbx/sbxbyte.cxx | 3 | ||||
-rw-r--r-- | basic/source/sbx/sbxchar.cxx | 3 | ||||
-rw-r--r-- | basic/source/sbx/sbxdbl.cxx | 3 | ||||
-rw-r--r-- | basic/source/sbx/sbxint.cxx | 7 | ||||
-rw-r--r-- | basic/source/sbx/sbxlng.cxx | 3 | ||||
-rw-r--r-- | basic/source/sbx/sbxscan.cxx | 3 | ||||
-rw-r--r-- | basic/source/sbx/sbxsng.cxx | 3 | ||||
-rw-r--r-- | basic/source/sbx/sbxuint.cxx | 3 | ||||
-rw-r--r-- | basic/source/sbx/sbxulng.cxx | 3 | ||||
-rw-r--r-- | basic/source/sbx/sbxvalue.cxx | 5 | ||||
-rw-r--r-- | basic/source/sbx/sbxvar.cxx | 5 |
16 files changed, 57 insertions, 20 deletions
diff --git a/basic/qa/basic_coverage/test_types_conversion.vb b/basic/qa/basic_coverage/test_types_conversion.vb index 0868f4d3e50a..68b28b1afc0a 100644 --- a/basic/qa/basic_coverage/test_types_conversion.vb +++ b/basic/qa/basic_coverage/test_types_conversion.vb @@ -39,10 +39,17 @@ Function doUnitTest() As Integer nVal = " -123.456 " AssertTest(nVal = -123.456) - ' Wrong decimal separator (interpreted as group separator) - StartTest() - nVal = " -123,456 " - AssertTest(nVal = -123456) + If LibreOffice6FloatingPointMode() Then + ' Wrong decimal separator (and not even interpreted as group separator) + StartTest() + nVal = " -123,45 " + AssertTest(nVal = -123) + Else + ' Wrong decimal separator (interpreted as group separator) + StartTest() + nVal = " -123,456 " + AssertTest(nVal = -123456) + End If If ((nFailCount > 0) Or (nPassCount <> nTotalCount)) Then doUnitTest = 0 diff --git a/basic/source/inc/rtlproto.hxx b/basic/source/inc/rtlproto.hxx index 2d0cb78f84b7..93eed13bd17c 100644 --- a/basic/source/inc/rtlproto.hxx +++ b/basic/source/inc/rtlproto.hxx @@ -352,10 +352,12 @@ extern void SbRtl_CDateFromUnoDateTime(StarBASIC * pBasic, SbxArray & rPar, bool extern void SbRtl_CDateToIso(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); extern void SbRtl_CDateFromIso(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); extern void SbRtl_CompatibilityMode(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); +extern void SbRtl_LibreOffice6FloatingPointMode(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); extern void SbRtl_CDec(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); extern void SbRtl_Partition(StarBASIC * pBasic, SbxArray & rPar, bool bWrite); // Fong +extern bool LibreOffice6FloatingPointMode(); extern double Now_Impl(); extern void Wait_Impl( bool bDurationBased, SbxArray& rPar ); diff --git a/basic/source/runtime/methods1.cxx b/basic/source/runtime/methods1.cxx index 2f9b6ff7b655..3d0c378765c8 100644 --- a/basic/source/runtime/methods1.cxx +++ b/basic/source/runtime/methods1.cxx @@ -2968,6 +2968,21 @@ void SbRtl_CompatibilityMode(StarBASIC *, SbxArray & rPar, bool) rPar.Get32(0)->PutBool( bEnabled ); } +bool LibreOffice6FloatingPointMode() +{ + static bool bMode = std::getenv("LIBREOFFICE6FLOATINGPOINTMODE") != nullptr; + + return bMode; +} + +void SbRtl_LibreOffice6FloatingPointMode(StarBASIC *, SbxArray & rPar, bool) +{ + if ( rPar.Count32() != 1 ) + StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT ); + + rPar.Get32(0)->PutBool( LibreOffice6FloatingPointMode() ); +} + void SbRtl_Input(StarBASIC *, SbxArray & rPar, bool) { // 2 parameters needed diff --git a/basic/source/runtime/stdobj.cxx b/basic/source/runtime/stdobj.cxx index b2627748915a..c491bf1be227 100644 --- a/basic/source/runtime/stdobj.cxx +++ b/basic/source/runtime/stdobj.cxx @@ -147,6 +147,7 @@ static Methods aMethods[] = { { "expression", SbxVARIANT, 0,nullptr,0 }, { "CompatibilityMode", SbxBOOL, 1 | FUNCTION_, RTLNAME(CompatibilityMode),0}, { "bEnable", SbxBOOL, 0,nullptr,0 }, +{ "LibreOffice6FloatingPointMode", SbxBOOL, 0 | FUNCTION_, RTLNAME(LibreOffice6FloatingPointMode),0}, { "ConvertFromUrl", SbxSTRING, 1 | FUNCTION_, RTLNAME(ConvertFromUrl),0 }, { "Url", SbxSTRING, 0,nullptr,0 }, { "ConvertToUrl", SbxSTRING, 1 | FUNCTION_, RTLNAME(ConvertToUrl),0 }, diff --git a/basic/source/sbx/sbxbool.cxx b/basic/source/sbx/sbxbool.cxx index 723939fb0c4a..7248072ce039 100644 --- a/basic/source/sbx/sbxbool.cxx +++ b/basic/source/sbx/sbxbool.cxx @@ -21,6 +21,7 @@ #include <basic/sberrors.hxx> #include "sbxconv.hxx" #include "sbxres.hxx" +#include "rtlproto.hxx" enum SbxBOOL ImpGetBool( const SbxValues* p ) { @@ -80,7 +81,7 @@ enum SbxBOOL ImpGetBool( const SbxValues* p ) double n; SbxDataType t; sal_uInt16 nLen = 0; - if( ImpScan( *p->pOUString, n, t, &nLen, true ) == ERRCODE_NONE ) + if( ImpScan( *p->pOUString, n, t, &nLen, !LibreOffice6FloatingPointMode() ) == ERRCODE_NONE ) { if( nLen == p->pOUString->getLength() ) { diff --git a/basic/source/sbx/sbxbyte.cxx b/basic/source/sbx/sbxbyte.cxx index 4974213dc7a1..6a0c8d1fb7e6 100644 --- a/basic/source/sbx/sbxbyte.cxx +++ b/basic/source/sbx/sbxbyte.cxx @@ -24,6 +24,7 @@ //#include <basic/sbx.hxx> #include <basic/sberrors.hxx> #include "sbxconv.hxx" +#include "rtlproto.hxx" #include <rtl/math.hxx> @@ -165,7 +166,7 @@ start: { double d; SbxDataType t; - if( ImpScan( *p->pOUString, d, t, nullptr, true ) != ERRCODE_NONE ) + if( ImpScan( *p->pOUString, d, t, nullptr, !LibreOffice6FloatingPointMode() ) != ERRCODE_NONE ) nRes = 0; else if( d > SbxMAXBYTE ) { diff --git a/basic/source/sbx/sbxchar.cxx b/basic/source/sbx/sbxchar.cxx index d25ccc083d7c..935bde34253e 100644 --- a/basic/source/sbx/sbxchar.cxx +++ b/basic/source/sbx/sbxchar.cxx @@ -20,6 +20,7 @@ #include <vcl/errcode.hxx> #include <basic/sberrors.hxx> #include "sbxconv.hxx" +#include "rtlproto.hxx" #include <rtl/math.hxx> @@ -147,7 +148,7 @@ start: { double d; SbxDataType t; - if( ImpScan( *p->pOUString, d, t, nullptr, true ) != ERRCODE_NONE ) + if( ImpScan( *p->pOUString, d, t, nullptr, !LibreOffice6FloatingPointMode() ) != ERRCODE_NONE ) nRes = 0; else if( d > SbxMAXCHAR ) { diff --git a/basic/source/sbx/sbxdbl.cxx b/basic/source/sbx/sbxdbl.cxx index 9010dfaa3e74..da7407c03f9d 100644 --- a/basic/source/sbx/sbxdbl.cxx +++ b/basic/source/sbx/sbxdbl.cxx @@ -22,6 +22,7 @@ #include <o3tl/float_int_conversion.hxx> #include <vcl/errcode.hxx> #include "sbxconv.hxx" +#include "rtlproto.hxx" #include <runtime.hxx> double ImpGetDouble( const SbxValues* p ) @@ -81,7 +82,7 @@ double ImpGetDouble( const SbxValues* p ) { double d; SbxDataType t; - if( ImpScan( *p->pOUString, d, t, nullptr, true ) != ERRCODE_NONE ) + if( ImpScan( *p->pOUString, d, t, nullptr, !LibreOffice6FloatingPointMode() ) != ERRCODE_NONE ) { nRes = 0; #if HAVE_FEATURE_SCRIPTING diff --git a/basic/source/sbx/sbxint.cxx b/basic/source/sbx/sbxint.cxx index a28b810eb8c7..aac57b4fb303 100644 --- a/basic/source/sbx/sbxint.cxx +++ b/basic/source/sbx/sbxint.cxx @@ -24,6 +24,7 @@ #include <vcl/errcode.hxx> #include <basic/sberrors.hxx> #include "sbxconv.hxx" +#include "rtlproto.hxx" #include <rtl/math.hxx> @@ -158,7 +159,7 @@ start: { double d; SbxDataType t; - if( ImpScan( *p->pOUString, d, t, nullptr, true ) != ERRCODE_NONE ) + if( ImpScan( *p->pOUString, d, t, nullptr, !LibreOffice6FloatingPointMode() ) != ERRCODE_NONE ) nRes = 0; else if( !o3tl::convertsToAtMost(o3tl::roundAway(d), SbxMAXINT) ) { @@ -443,7 +444,7 @@ start: // Check if really 0 or invalid conversion double d; SbxDataType t; - if( ImpScan( *p->pOUString, d, t, nullptr, true ) != ERRCODE_NONE ) + if( ImpScan( *p->pOUString, d, t, nullptr, !LibreOffice6FloatingPointMode() ) != ERRCODE_NONE ) nRes = 0; else nRes = static_cast<sal_Int64>(d); @@ -704,7 +705,7 @@ start: // Check if really 0 or invalid conversion double d; SbxDataType t; - if( ImpScan( *p->pOUString, d, t, nullptr, true ) != ERRCODE_NONE ) + if( ImpScan( *p->pOUString, d, t, nullptr, !LibreOffice6FloatingPointMode() ) != ERRCODE_NONE ) nRes = 0; else if( !o3tl::convertsToAtMost(o3tl::roundAway(d), SAL_MAX_UINT64) ) { diff --git a/basic/source/sbx/sbxlng.cxx b/basic/source/sbx/sbxlng.cxx index bda401b981db..8852f7505789 100644 --- a/basic/source/sbx/sbxlng.cxx +++ b/basic/source/sbx/sbxlng.cxx @@ -23,6 +23,7 @@ #include <vcl/errcode.hxx> #include <basic/sberrors.hxx> #include "sbxconv.hxx" +#include "rtlproto.hxx" #include <rtl/math.hxx> @@ -121,7 +122,7 @@ start: { double d; SbxDataType t; - if( ImpScan( *p->pOUString, d, t, nullptr, true ) != ERRCODE_NONE ) + if( ImpScan( *p->pOUString, d, t, nullptr, !LibreOffice6FloatingPointMode() ) != ERRCODE_NONE ) nRes = 0; else if( !o3tl::convertsToAtMost(o3tl::roundAway(d), SbxMAXLNG) ) { diff --git a/basic/source/sbx/sbxscan.cxx b/basic/source/sbx/sbxscan.cxx index de3d50dbed38..a4f021867d4f 100644 --- a/basic/source/sbx/sbxscan.cxx +++ b/basic/source/sbx/sbxscan.cxx @@ -26,6 +26,7 @@ #include <vcl/errcode.hxx> #include <unotools/resmgr.hxx> #include "sbxconv.hxx" +#include "rtlproto.hxx" #include <unotools/syslocale.hxx> #include <unotools/charclass.hxx> @@ -565,7 +566,7 @@ bool SbxValue::Scan( const OUString& rSrc, sal_uInt16* pLen ) { double n; SbxDataType t; - eRes = ImpScan( rSrc, n, t, pLen, true ); + eRes = ImpScan( rSrc, n, t, pLen, !LibreOffice6FloatingPointMode() ); if( eRes == ERRCODE_NONE ) { if( !IsFixed() ) diff --git a/basic/source/sbx/sbxsng.cxx b/basic/source/sbx/sbxsng.cxx index ad4301f9ca89..0a42876e05ab 100644 --- a/basic/source/sbx/sbxsng.cxx +++ b/basic/source/sbx/sbxsng.cxx @@ -23,6 +23,7 @@ #include <vcl/errcode.hxx> #include <basic/sberrors.hxx> #include "sbxconv.hxx" +#include "rtlproto.hxx" float ImpGetSingle( const SbxValues* p ) { @@ -109,7 +110,7 @@ start: { double d; SbxDataType t; - if( ImpScan( *p->pOUString, d, t, nullptr, true ) != ERRCODE_NONE ) + if( ImpScan( *p->pOUString, d, t, nullptr, !LibreOffice6FloatingPointMode() ) != ERRCODE_NONE ) nRes = 0; else if( d > SbxMAXSNG ) { diff --git a/basic/source/sbx/sbxuint.cxx b/basic/source/sbx/sbxuint.cxx index a3751e2661a4..4270fb72608b 100644 --- a/basic/source/sbx/sbxuint.cxx +++ b/basic/source/sbx/sbxuint.cxx @@ -23,6 +23,7 @@ #include <vcl/errcode.hxx> #include <basic/sberrors.hxx> #include "sbxconv.hxx" +#include "rtlproto.hxx" sal_uInt16 ImpGetUShort( const SbxValues* p ) { @@ -154,7 +155,7 @@ start: { double d; SbxDataType t; - if( ImpScan( *p->pOUString, d, t, nullptr, true ) != ERRCODE_NONE ) + if( ImpScan( *p->pOUString, d, t, nullptr, !LibreOffice6FloatingPointMode() ) != ERRCODE_NONE ) nRes = 0; else if( !o3tl::convertsToAtMost(o3tl::roundAway(d), SbxMAXUINT) ) { diff --git a/basic/source/sbx/sbxulng.cxx b/basic/source/sbx/sbxulng.cxx index bcb1ce0f2778..bada5a8ebcdc 100644 --- a/basic/source/sbx/sbxulng.cxx +++ b/basic/source/sbx/sbxulng.cxx @@ -23,6 +23,7 @@ #include <vcl/errcode.hxx> #include <basic/sberrors.hxx> #include "sbxconv.hxx" +#include "rtlproto.hxx" sal_uInt32 ImpGetULong( const SbxValues* p ) { @@ -121,7 +122,7 @@ start: { double d; SbxDataType t; - if( ImpScan( *p->pOUString, d, t, nullptr, true ) != ERRCODE_NONE ) + if( ImpScan( *p->pOUString, d, t, nullptr, !LibreOffice6FloatingPointMode() ) != ERRCODE_NONE ) nRes = 0; else if( !o3tl::convertsToAtMost(o3tl::roundAway(d), SbxMAXULNG) ) { diff --git a/basic/source/sbx/sbxvalue.cxx b/basic/source/sbx/sbxvalue.cxx index 90edef4cb7e7..075549133ce5 100644 --- a/basic/source/sbx/sbxvalue.cxx +++ b/basic/source/sbx/sbxvalue.cxx @@ -29,6 +29,7 @@ #include <basic/sbx.hxx> #include <sbunoobj.hxx> #include "sbxconv.hxx" +#include "rtlproto.hxx" #include <runtime.hxx> @@ -1322,7 +1323,7 @@ bool SbxValue::LoadData( SvStream& r, sal_uInt16 ) RTL_TEXTENCODING_ASCII_US); double d; SbxDataType t; - if( ImpScan( aVal, d, t, nullptr, true ) != ERRCODE_NONE || t == SbxDOUBLE ) + if( ImpScan( aVal, d, t, nullptr, !LibreOffice6FloatingPointMode() ) != ERRCODE_NONE || t == SbxDOUBLE ) { aData.nSingle = 0.0F; return false; @@ -1337,7 +1338,7 @@ bool SbxValue::LoadData( SvStream& r, sal_uInt16 ) OUString aVal = read_uInt16_lenPrefixed_uInt8s_ToOUString(r, RTL_TEXTENCODING_ASCII_US); SbxDataType t; - if( ImpScan( aVal, aData.nDouble, t, nullptr, true ) != ERRCODE_NONE ) + if( ImpScan( aVal, aData.nDouble, t, nullptr, !LibreOffice6FloatingPointMode() ) != ERRCODE_NONE ) { aData.nDouble = 0.0; return false; diff --git a/basic/source/sbx/sbxvar.cxx b/basic/source/sbx/sbxvar.cxx index 8e5b80ef1e08..c6dbeb7cd8a1 100644 --- a/basic/source/sbx/sbxvar.cxx +++ b/basic/source/sbx/sbxvar.cxx @@ -26,6 +26,7 @@ #include <runtime.hxx> #include "sbxres.hxx" #include "sbxconv.hxx" +#include "rtlproto.hxx" #include <sbunoobj.hxx> #include <rtl/character.hxx> #include <rtl/ustrbuf.hxx> @@ -504,7 +505,7 @@ bool SbxVariable::LoadData( SvStream& rStrm, sal_uInt16 nVer ) rStrm, RTL_TEXTENCODING_ASCII_US); double d; SbxDataType t; - if( ImpScan( aTmpString, d, t, nullptr, true ) != ERRCODE_NONE || t == SbxDOUBLE ) + if( ImpScan( aTmpString, d, t, nullptr, !LibreOffice6FloatingPointMode() ) != ERRCODE_NONE || t == SbxDOUBLE ) { aTmp.nSingle = 0; return false; @@ -519,7 +520,7 @@ bool SbxVariable::LoadData( SvStream& rStrm, sal_uInt16 nVer ) aTmpString = read_uInt16_lenPrefixed_uInt8s_ToOUString(rStrm, RTL_TEXTENCODING_ASCII_US); SbxDataType t; - if( ImpScan( aTmpString, aTmp.nDouble, t, nullptr, true ) != ERRCODE_NONE ) + if( ImpScan( aTmpString, aTmp.nDouble, t, nullptr, !LibreOffice6FloatingPointMode() ) != ERRCODE_NONE ) { aTmp.nDouble = 0; return false; |