summaryrefslogtreecommitdiff
path: root/wizards
diff options
context:
space:
mode:
authorJean-Pierre Ledure <jp@ledure.be>2024-01-12 22:30:06 +0100
committerJean-Pierre Ledure <jp@ledure.be>2024-01-13 11:20:08 +0100
commitca9168b8ad842c86b2168e12bb98087b9f8139bd (patch)
treeb141810433b8c45157c8b0c8525024cc81bdb497 /wizards
parent29cd541dfcff93a50c2e1ae9eab74f1908214c2e (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.xba2
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
&apos; Now ... shuffle !
Do While lCurrentIndex &gt; lMin
- lRandomIndex = Int(Rnd * (lCurrentIndex - lMin)) + lMin
+ lRandomIndex = Int(Rnd * (lCurrentIndex - lMin + 1)) + lMin
vSwapValue = vShuffle(lCurrentIndex)
vShuffle(lCurrentIndex) = vShuffle(lRandomIndex)
vShuffle(lRandomIndex) = vSwapValue