diff options
author | Eike Rathke <erack@redhat.com> | 2022-05-12 19:23:14 +0200 |
---|---|---|
committer | Xisco Fauli <xiscofauli@libreoffice.org> | 2022-05-16 10:30:10 +0200 |
commit | c6cdfd364963ada3fc12aa35ecc8c641eff0276c (patch) | |
tree | e9336f68f52831408af7d905815c70368402f079 | |
parent | 50101f735af5fdecbe7534a845a7a6a8ddfe763e (diff) |
Resolves: tdf#148863 In JumpMatrix context use its dimensions for results
Problem was, that in array mode the result matrix of random values
was created according to the dimensions of the formula cell range
selected/resulting, which if transposed and displayed obeys the general rules of
a repeating vector if not a 2D matrix.
For example, entering the array formula
=TRANSPOSE(IF({1,1,1};RAND()))
(with , comma array column separator) is supposed to create a row
vector of 3 columns transposed to a column vector of 3 rows. The
selection created for the automatically determined result is 3
rows in one column, for which the RAND() was calculated, resulting
in a column vector
{
1
2
3
}
which transposed gave a row vector { 1, 2, 3 } and displayed for
one column such row vector is repeated as
{
{ 1, 2, 3 }
{ 1, 2, 3 }
{ 1, 2, 3 }
}
of which the first column displayed is the repeating first value 1.
With this change the dimensions of the JumpMatrix created by
IF({1,1,1};...) is used to generate the RAND() matrix, resulting
in a { 1, 2, 3 } row vector that then is transposed and displayed
as expected.
Change-Id: I267ff5d336a86372ee456fd929249e5f0444f843
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134247
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/+/134276
-rw-r--r-- | sc/source/core/tool/interpr1.cxx | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/sc/source/core/tool/interpr1.cxx b/sc/source/core/tool/interpr1.cxx index d40e93608d6e..87bc8e5fe8d6 100644 --- a/sc/source/core/tool/interpr1.cxx +++ b/sc/source/core/tool/interpr1.cxx @@ -1741,7 +1741,17 @@ void ScInterpreter::ScRandomImpl( const std::function<double( double fFirst, dou { SCCOL nCols = 0; SCROW nRows = 0; - if (pMyFormulaCell) + // 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) + { + SCSIZE nC, nR; + pJumpMatrix->GetDimensions( nC, nR); + nCols = std::max<SCCOL>(0, static_cast<SCCOL>(nC)); + nRows = std::max<SCROW>(0, static_cast<SCROW>(nR)); + } + else if (pMyFormulaCell) pMyFormulaCell->GetMatColsRows( nCols, nRows); if (nCols == 1 && nRows == 1) |