[Libreoffice-commits] core.git: Branch 'libreoffice-6-1' - sc/source
Libreoffice Gerrit user
logerrit at kemper.freedesktop.org
Fri Jul 13 20:01:11 UTC 2018
sc/source/core/tool/interpr1.cxx | 34 +++++++++++++++++++++++++++++++++-
1 file changed, 33 insertions(+), 1 deletion(-)
New commits:
commit 2dc7a3b7515ffd6181d740aca4ad6e0549ea4a3a
Author: Eike Rathke <erack at redhat.com>
AuthorDate: Tue Jul 10 15:58:17 2018 +0200
Commit: Markus Mohrhard <markus.mohrhard at googlemail.com>
CommitDate: Fri Jul 13 22:00:45 2018 +0200
Resolves: tdf#118624 let RAND() in array/matrix mode fill a matrix
... instead of only top left that is referenced for other
elements.
Change-Id: I718946d7e4327b152e2d9f80712395fd7ab67dee
Reviewed-on: https://gerrit.libreoffice.org/57235
Tested-by: Jenkins
Reviewed-by: Eike Rathke <erack at redhat.com>
(cherry picked from commit 8afccbd129ecda81ff00dd2c6e5e10af254ae0ef)
Reviewed-on: https://gerrit.libreoffice.org/57247
Reviewed-by: Markus Mohrhard <markus.mohrhard at googlemail.com>
diff --git a/sc/source/core/tool/interpr1.cxx b/sc/source/core/tool/interpr1.cxx
index 33cd8c3f840e..c83951d59b79 100644
--- a/sc/source/core/tool/interpr1.cxx
+++ b/sc/source/core/tool/interpr1.cxx
@@ -1733,7 +1733,39 @@ void ScInterpreter::ScPi()
void ScInterpreter::ScRandom()
{
- PushDouble(::comphelper::rng::uniform_real_distribution());
+ if (bMatrixFormula && pMyFormulaCell)
+ {
+ SCCOL nCols;
+ SCROW nRows;
+ pMyFormulaCell->GetMatColsRows( nCols, nRows);
+ // 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()
+ // asks for a not selected range.
+ if (nCols == 0)
+ nCols = 1;
+ if (nRows == 0)
+ nRows = 1;
+ ScMatrixRef pResMat = GetNewMat( static_cast<SCSIZE>(nCols), static_cast<SCSIZE>(nRows));
+ if (!pResMat)
+ PushError( FormulaError::MatrixSize);
+ else
+ {
+ for (SCCOL i=0; i < nCols; ++i)
+ {
+ for (SCROW j=0; j < nRows; ++j)
+ {
+ pResMat->PutDouble( comphelper::rng::uniform_real_distribution(),
+ static_cast<SCSIZE>(i), static_cast<SCSIZE>(j));
+ }
+ }
+ PushMatrix( pResMat);
+ }
+ }
+ else
+ {
+ PushDouble( comphelper::rng::uniform_real_distribution());
+ }
}
void ScInterpreter::ScTrue()
More information about the Libreoffice-commits
mailing list