Use interpreter stack to determine JumpMatrix context, tdf#148863 follow-up
pJumpMatrix may or may not be set; actually may need some rework,
but get this straight here.
Change-Id: I0948e6aeb6637e7a5009a17f63f01d0733c0205c
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134252
Reviewed-by: Eike Rathke <erack@redhat.com>
Tested-by: Jenkins
Signed-off-by: Xisco Fauli <xiscofauli@libreoffice.org>
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134277
diff --git a/sc/source/core/tool/interpr1.cxx b/sc/source/core/tool/interpr1.cxx
index 87bc8e5..42d6dde 100644
--- a/sc/source/core/tool/interpr1.cxx
+++ b/sc/source/core/tool/interpr1.cxx
@@ -1744,10 +1744,10 @@ void ScInterpreter::ScRandomImpl( const std::function<double( double fFirst, dou
// In JumpMatrix context use its dimensions for the return matrix; the
// formula cell range selected may differ, for example if the result is
// to be transposed.
if (pJumpMatrix)
if (GetStackType(1) == svJumpMatrix)
{
SCSIZE nC, nR;
pJumpMatrix->GetDimensions( nC, nR);
pStack[sp-1]->GetJumpMatrix()->GetDimensions( nC, nR);
nCols = std::max<SCCOL>(0, static_cast<SCCOL>(nC));
nRows = std::max<SCROW>(0, static_cast<SCROW>(nR));
}