basic/qa/basic_coverage/test_types_conversion.vb              |   15 ++++++
 basic/source/inc/rtlproto.hxx                                 |    1 
 basic/source/runtime/methods1.cxx                             |   13 +----
 basic/source/runtime/stdobj.cxx                               |    1 
 officecfg/registry/schema/org/openoffice/Office/Scripting.xcs |   24 ++++++++++
 5 files changed, 43 insertions(+), 11 deletions(-)

New commits:
commit c9b5378656bf7c4caf165ccda1026842cf582bbf
Author:     Tor Lillqvist <t...@iki.fi>
AuthorDate: Thu Dec 9 13:11:53 2021 +0200
Commit:     Andras Timar <andras.ti...@collabora.com>
CommitDate: Fri Jan 7 10:05:34 2022 +0100

    Make the LibreOffice6FloatingPointMode thing work like in the master branch
    
    Add an Expert Configurtion setting to turn it on in addition to
    checking an environment variable.
    
    Don't expose the check as a Basic function.
    
    Change-Id: I6c7f3e85d63ce79f83a0747a00d05e14e559792f
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/126580
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com>
    Reviewed-by: Andras Timar <andras.ti...@collabora.com>

diff --git a/basic/qa/basic_coverage/test_types_conversion.vb 
b/basic/qa/basic_coverage/test_types_conversion.vb
index 68b28b1afc0a..4899b3f90fc8 100644
--- a/basic/qa/basic_coverage/test_types_conversion.vb
+++ b/basic/qa/basic_coverage/test_types_conversion.vb
@@ -11,6 +11,21 @@ Dim nTotalCount As Integer
 Dim nPassCount As Integer
 Dim nFailCount As Integer
 
+' See LibreOffice6FloatingPointMode in basic/source/runtime/methods1.cxx
+Function LibreOffice6FloatingPointMode() As Boolean
+    Dim bMode As Boolean
+    bMode = Environ("LIBREOFFICE6FLOATINGPOINTMODE") <> ""
+    If (Not bMode) Then
+       Dim oConfigProvider As Object, aNodePath(0) As New 
com.sun.star.beans.PropertyValue, oRegistryKey As Object
+       oConfigProvider = 
createUnoService("com.sun.star.configuration.ConfigurationProvider")
+       aNodePath(0).Name = "nodepath"
+       aNodePath(0).Value = 
"org.openoffice.Office.Scripting/Basic/Compatibility"
+       oRegistryKey = 
oConfigProvider.createInstanceWithArguments("com.sun.star.configuration.ConfigurationAccess",
 aNodePath)
+       bMode = 
oRegistryKey.getPropertyValue("UseLibreOffice6FloatingPointConversion")
+    End If
+    LibreOffice6FloatingPointMode = bMode
+End Function
+
 ' For the following tests the en-US (English - United States) locale is 
required
 Function doUnitTest() As Integer
     nTotalCount = 0
diff --git a/basic/source/inc/rtlproto.hxx b/basic/source/inc/rtlproto.hxx
index 93eed13bd17c..55abc086379e 100644
--- a/basic/source/inc/rtlproto.hxx
+++ b/basic/source/inc/rtlproto.hxx
@@ -352,7 +352,6 @@ 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
diff --git a/basic/source/runtime/methods1.cxx 
b/basic/source/runtime/methods1.cxx
index 3d0c378765c8..27442c8c7ef0 100644
--- a/basic/source/runtime/methods1.cxx
+++ b/basic/source/runtime/methods1.cxx
@@ -59,6 +59,9 @@
 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
 #include <com/sun/star/i18n/LocaleCalendar2.hpp>
 #include <com/sun/star/sheet/XFunctionAccess.hpp>
+
+#include <officecfg/Office/Scripting.hxx>
+
 #include <memory>
 
 using namespace comphelper;
@@ -2972,15 +2975,7 @@ 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() );
+    return bMode || 
officecfg::Office::Scripting::Basic::Compatibility::UseLibreOffice6FloatingPointConversion::get();
 }
 
 void SbRtl_Input(StarBASIC *, SbxArray & rPar, bool)
diff --git a/basic/source/runtime/stdobj.cxx b/basic/source/runtime/stdobj.cxx
index c491bf1be227..b2627748915a 100644
--- a/basic/source/runtime/stdobj.cxx
+++ b/basic/source/runtime/stdobj.cxx
@@ -147,7 +147,6 @@ 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/officecfg/registry/schema/org/openoffice/Office/Scripting.xcs 
b/officecfg/registry/schema/org/openoffice/Office/Scripting.xcs
index fa9aacd52dfe..374d96aed069 100644
--- a/officecfg/registry/schema/org/openoffice/Office/Scripting.xcs
+++ b/officecfg/registry/schema/org/openoffice/Office/Scripting.xcs
@@ -39,5 +39,29 @@
         <desc>Lists the registered Scripting Framework runtimes.</desc>
       </info>
     </set>
+    <group oor:name="Basic">
+      <info>
+       <desc>Contains settings for the Basic interpreter.</desc>
+      </info>
+      <group oor:name="Compatibility">
+       <info>
+         <desc>Contains settings for the compatibility with previous version 
of this software or
+           with other software products.
+         </desc>
+       </info>
+       <prop oor:name="UseLibreOffice6FloatingPointConversion" 
oor:type="xs:boolean" oor:nillable="false">
+         <info>
+           <!-- Yes, this description refers to a bug report and is 
technobabble. That is
+                intentional. This property is to be changed only by people who 
know what they are
+                doing.
+           -->
+           <desc>Whether conversion from strings to floating-point numbers in 
Basic should behave
+             as in LibreOffice 6, before the fix to tdf#97983.
+           </desc>
+         </info>
+         <value>false</value>
+       </prop>
+      </group>
+    </group>
   </component>
 </oor:component-schema>

Reply via email to