sc/source/core/tool/interpr1.cxx |   12 ++++++++++++
 1 file changed, 12 insertions(+)

New commits:
commit 75c1c58c4ae47dd0bad98dbe95e99d5d3de377de
Author:     Eike Rathke <er...@redhat.com>
AuthorDate: Fri Oct 25 00:31:52 2019 +0200
Commit:     Adolfo Jayme Barrientos <fit...@ubuntu.com>
CommitDate: Sun Oct 27 10:03:53 2019 +0100

    Resolves: tdf#128218 Let RAND() return a scalar double instead of a 1x1 
matrix
    
    ... even if in array context, for FunctionAccess.callFunction()
    compatibility.
    
    Change-Id: Iddfb462dd1b5812c94a2f2061c593b4479faef24
    Reviewed-on: https://gerrit.libreoffice.org/81482
    Reviewed-by: Eike Rathke <er...@redhat.com>
    Tested-by: Jenkins
    (cherry picked from commit 445727d3bce84ef04719242745aac9446035c5bd)
    Reviewed-on: https://gerrit.libreoffice.org/81492
    Reviewed-by: Adolfo Jayme Barrientos <fit...@ubuntu.com>

diff --git a/sc/source/core/tool/interpr1.cxx b/sc/source/core/tool/interpr1.cxx
index e94bdab3f25b..b94d58cf7b0f 100644
--- a/sc/source/core/tool/interpr1.cxx
+++ b/sc/source/core/tool/interpr1.cxx
@@ -1739,6 +1739,18 @@ void ScInterpreter::ScRandom()
         SCROW nRows = 0;
         if(pMyFormulaCell)
             pMyFormulaCell->GetMatColsRows( nCols, nRows);
+
+        if (nCols == 1 && nRows == 1)
+        {
+            // For compatibility with existing
+            // com.sun.star.sheet.FunctionAccess.callFunction() calls that per
+            // default are executed in array context unless
+            // FA.setPropertyValue("IsArrayFunction",False) was set, return a
+            // scalar double instead of a 1x1 matrix object. tdf#128218
+            PushDouble( comphelper::rng::uniform_real_distribution());
+            return;
+        }
+
         // ScViewFunc::EnterMatrix() might be asking for
         // ScFormulaCell::GetResultDimensions(), which here are none so create
         // a 1x1 matrix at least which exactly is the case when EnterMatrix()
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to