| commit | 67a2cba41b6caeabac031f1ae35b6c465037b0fd | [log] |
|---|---|---|
| author | Jean-Pierre Ledure <jp@ledure.be> | Fri Jan 12 22:30:06 2024 +0100 |
| committer | Xisco Fauli <xiscofauli@libreoffice.org> | Tue Jan 16 09:40:22 2024 +0100 |
| tree | f07983873c38e86e04dfe3c26ea2142a202a55e2 | |
| parent | e5899a8aa8b27658035db757fc7bd58bd8f016e6 [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 (cherry picked from commit ca9168b8ad842c86b2168e12bb98087b9f8139bd) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/162009 Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org> (cherry picked from commit d4898d7bbe8496504e36f7d91f55f62043f6a302) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/162105
diff --git a/wizards/source/scriptforge/SF_Array.xba b/wizards/source/scriptforge/SF_Array.xba index 49bdab1..c124461 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