diff options
author | Jean-Pierre Ledure <jp@ledure.be> | 2024-01-12 22:30:06 +0100 |
---|---|---|
committer | Jean-Pierre Ledure <jp@ledure.be> | 2024-01-13 11:20:08 +0100 |
commit | ca9168b8ad842c86b2168e12bb98087b9f8139bd (patch) | |
tree | b141810433b8c45157c8b0c8525024cc81bdb497 /wizards | |
parent | 29cd541dfcff93a50c2e1ae9eab74f1908214c2e (diff) |
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 <jp@ledure.be>
Tested-by: Jenkins
Diffstat (limited to 'wizards')
-rw-r--r-- | wizards/source/scriptforge/SF_Array.xba | 2 |
1 files changed, 1 insertions, 1 deletions
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 |