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

New commits:
commit 445727d3bce84ef04719242745aac9446035c5bd
Author:     Eike Rathke <er...@redhat.com>
AuthorDate: Fri Oct 25 00:31:52 2019 +0200
Commit:     Eike Rathke <er...@redhat.com>
CommitDate: Fri Oct 25 11:29:43 2019 +0200

    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

diff --git a/sc/source/core/tool/interpr1.cxx b/sc/source/core/tool/interpr1.cxx
index 16a9d933ed03..d4e867c05767 100644
--- a/sc/source/core/tool/interpr1.cxx
+++ b/sc/source/core/tool/interpr1.cxx
@@ -1743,6 +1743,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