basic/qa/basic_coverage/test_isnumeric_method.bas | 5 +++++ basic/qa/vba_tests/isnumeric.vb | 2 +- basic/source/runtime/methods.cxx | 2 +- basic/source/sbx/sbxvalue.cxx | 4 ++++ 4 files changed, 11 insertions(+), 2 deletions(-)
New commits: commit b76d70338258811bb0ca516d01c6cfe7a222ca76 Author: Mike Kaganski <mike.kagan...@collabora.com> AuthorDate: Mon Jan 6 15:19:28 2025 +0500 Commit: Mike Kaganski <mike.kagan...@collabora.com> CommitDate: Wed Jan 8 06:02:48 2025 +0100 tdf#164600: Return true from IsNumeric for booleans in VBASupport mode Change-Id: Ib68f237001389c8f7b9d2771d5162a583b544b83 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/179866 Reviewed-by: Mike Kaganski <mike.kagan...@collabora.com> Tested-by: Jenkins diff --git a/basic/qa/basic_coverage/test_isnumeric_method.bas b/basic/qa/basic_coverage/test_isnumeric_method.bas index eb476e8a6b35..5f6bbac5c0cb 100644 --- a/basic/qa/basic_coverage/test_isnumeric_method.bas +++ b/basic/qa/basic_coverage/test_isnumeric_method.bas @@ -24,6 +24,11 @@ Sub verify_IsNumeric TestUtil.Assert(IsNumeric(" 0 "), "IsNumeric("" 0 "")") TestUtil.Assert(IsNumeric(" +0 "), "IsNumeric("" +0 "")") TestUtil.Assert(IsNumeric(" -0 "), "IsNumeric("" -0 "")") + + ' Note: the following test behaves different in VBA; + ' should it be unified maybe in non-VBA, too (a breaking change)? + TestUtil.Assert(Not IsNumeric(True), "Not IsNumeric(True)") + TestUtil.Assert(Not IsNumeric(""), "Not IsNumeric("""")") TestUtil.Assert(Not IsNumeric(" "), "Not IsNumeric("" "")") TestUtil.Assert(Not IsNumeric(" + "), "Not IsNumeric("" + "")") diff --git a/basic/qa/vba_tests/isnumeric.vb b/basic/qa/vba_tests/isnumeric.vb index 721a2fb7f4b6..b44e37001797 100644 --- a/basic/qa/vba_tests/isnumeric.vb +++ b/basic/qa/vba_tests/isnumeric.vb @@ -22,7 +22,7 @@ Sub verify_testIsNumeric() TestUtil.Assert(IsNumeric(-123), "IsNumeric(-123)") TestUtil.Assert(IsNumeric(123.8), "IsNumeric(123.8)") TestUtil.Assert(Not IsNumeric("a"), "Not IsNumeric(""a"")") -rem TestUtil.Assert(IsNumeric(True), "IsNumeric(True)") + TestUtil.Assert(IsNumeric(True), "IsNumeric(True)") TestUtil.Assert(IsNumeric("123"), "IsNumeric(""123"")") TestUtil.Assert(IsNumeric("+123"), "IsNumeric(""+123"")") diff --git a/basic/source/runtime/methods.cxx b/basic/source/runtime/methods.cxx index 2ce6361c8d8b..0982c591de6c 100644 --- a/basic/source/runtime/methods.cxx +++ b/basic/source/runtime/methods.cxx @@ -1358,7 +1358,7 @@ void SbRtl_Str(StarBASIC *, SbxArray & rPar, bool) pArg->Format( aStr ); // Numbers start with a space - if( pArg->IsNumericRTL() ) + if (pArg->GetType() != SbxBOOL && pArg->IsNumericRTL()) { // replace commas by points so that it's symmetric to Val! aStr = aStr.replaceFirst( ",", "." ); diff --git a/basic/source/sbx/sbxvalue.cxx b/basic/source/sbx/sbxvalue.cxx index 146c4f50faf1..8fac8fd867ef 100644 --- a/basic/source/sbx/sbxvalue.cxx +++ b/basic/source/sbx/sbxvalue.cxx @@ -699,6 +699,10 @@ bool SbxValue::ImpIsNumeric( bool bOnlyIntntl ) const } return false; } +#if HAVE_FEATURE_SCRIPTING + else if (t == SbxBOOL && bOnlyIntntl && SbiRuntime::isVBAEnabled()) + return true; +#endif else return t == SbxEMPTY || ( t >= SbxINTEGER && t <= SbxCURRENCY )