wizards/source/scriptforge/SF_Array.xba | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
New commits: commit 4651a5eb1b913d61d015c8fe2d713110bd2c5c50 Author: Jean-Pierre Ledure <j...@ledure.be> AuthorDate: Fri Jan 12 22:30:06 2024 +0100 Commit: Xisco Fauli <xiscofa...@libreoffice.org> CommitDate: Mon Jan 15 14:29:48 2024 +0100 ScriptForge (SF_Array) fix tdf#158976 Shuffle() The algorithm used to shuffle a 1D array prevented any item of the array to remain in the same entry after the shuffle. This has been fixed. The potential targeted entries to receive an item include the actual entry. This change might impact existing scripts that have Randomize()d their sorts to always get the same shuffle results. This should impact test scripts only. SF_Array.Shuffle() is available in Basic only. No impact on help pages. Change-Id: If56d901f4af68f8889a7352c306bae6e3443ae97 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/161987 Reviewed-by: Jean-Pierre Ledure <j...@ledure.be> Tested-by: Jenkins (cherry picked from commit ca9168b8ad842c86b2168e12bb98087b9f8139bd) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/162009 Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org> diff --git a/wizards/source/scriptforge/SF_Array.xba b/wizards/source/scriptforge/SF_Array.xba index 54110cde9352..1b5ae92df523 100644 --- a/wizards/source/scriptforge/SF_Array.xba +++ b/wizards/source/scriptforge/SF_Array.xba @@ -1767,7 +1767,7 @@ Try: Next i ' Now ... shuffle ! Do While lCurrentIndex > lMin - lRandomIndex = Int(Rnd * (lCurrentIndex - lMin)) + lMin + lRandomIndex = Int(Rnd * (lCurrentIndex - lMin + 1)) + lMin vSwapValue = vShuffle(lCurrentIndex) vShuffle(lCurrentIndex) = vShuffle(lRandomIndex) vShuffle(lRandomIndex) = vSwapValue