ScriptForge - tdf#150203 Use RANDBETWEEN.NV i.o. RANDBETWEEN
Extract of the bug report (Rafael Lima)
This bug affects a method from the ScriptForge library,
more specifically the GetTempName method from
the FileSystem service, which relies on calling RANDBETWEEN.
Because of this bug, GetTempName only works in English,
but fails in other languages. Below is a sample code
for testing the GetTempName error.
Sub TestTempName
GlobalScope.BasicLibraries.LoadLibrary("ScriptForge")
fs = CreateScriptService("FileSystem")
MsgBox fs.GetTempName()
End sub
Interestingly changing RANDBETWEEN for RANDBETWEEN.NV
in the macro above will work.
Occurrences of the use of RANDBETWEEN:
wizards/source/scriptforge/SF_FileSystem.xba
wizards/source/sfdocuments/SF_Calc.xba
Change-Id: Iea38f11acb7113aa5eaab1feff7a0e64a739aada
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/137691
Tested-by: Jean-Pierre Ledure <jp@ledure.be>
Reviewed-by: Jean-Pierre Ledure <jp@ledure.be>
Tested-by: Jenkins
diff --git a/wizards/source/scriptforge/SF_FileSystem.xba b/wizards/source/scriptforge/SF_FileSystem.xba
index 8b21ea9..21464c7 100644
--- a/wizards/source/scriptforge/SF_FileSystem.xba
+++ b/wizards/source/scriptforge/SF_FileSystem.xba
@@ -1178,7 +1178,7 @@ Check:
SF_Utils._EnterFunction(cstThisSub, cstSubArgs)
Try:
lRandom = SF_Session.ExecuteCalcFunction("RANDBETWEEN", 1, 999999)
lRandom = SF_Session.ExecuteCalcFunction("RANDBETWEEN.NV", 1, 999999)
sFile = SF_FileSystem.TemporaryFolder & "SF_" & Right("000000" & lRandom, 6)
Finally:
diff --git a/wizards/source/sfdocuments/SF_Calc.xba b/wizards/source/sfdocuments/SF_Calc.xba
index 8cfbd34..b929fac 100644
--- a/wizards/source/sfdocuments/SF_Calc.xba
+++ b/wizards/source/sfdocuments/SF_Calc.xba
@@ -935,7 +935,7 @@ Try:
' If a sheet with same name as input exists in the target sheet, rename it first with a random name
sRandom = ""
If ScriptForge.SF_Array.Contains(vSheets, .SheetName) Then
lRandom = ScriptForge.SF_Session.ExecuteCalcFunction("RANDBETWEEN", 1, 9999999)
lRandom = ScriptForge.SF_Session.ExecuteCalcFunction("RANDBETWEEN.NV", 1, 9999999)
sRandom = "SF_" & Right("0000000" & lRandom, 7)
oSheets.getByName(.SheetName).setName(sRandom)
End If
@@ -944,7 +944,7 @@ Try:
' Rename to new sheet name
oSheets.getByName(.SheetName).setName(NewName)
' Reset random name
If Len(sRandom) > 0 Then oSheets.getByName(srandom).setName(.SheetName)
If Len(sRandom) > 0 Then oSheets.getByName(sRandom).setName(.SheetName)
End With
End If
bCopy = True