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 <erack@redhat.com>
Tested-by: Jenkins
diff --git a/sc/source/core/tool/interpr1.cxx b/sc/source/core/tool/interpr1.cxx
index 16a9d93..d4e867c 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()