Resolves: tdf#156467 Let array ROW() and COLUMN() return a scalar value
... instead of a single element matrix.
Change-Id: I8307e24ef68dc54350fbdda74bc61b1df6a5107b
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/154908
Reviewed-by: Eike Rathke <erack@redhat.com>
Tested-by: Jenkins
(cherry picked from commit 49b601937f5ba7739198a1b16ba6da2351897750)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/154952
Reviewed-by: Caolán McNamara <caolan.mcnamara@collabora.com>
diff --git a/sc/source/core/tool/interpr1.cxx b/sc/source/core/tool/interpr1.cxx
index a8fba64..56840ce 100644
--- a/sc/source/core/tool/interpr1.cxx
+++ b/sc/source/core/tool/interpr1.cxx
@@ -4457,20 +4457,29 @@ void ScInterpreter::ScColumn()
SCROW nRows = 0;
if (pMyFormulaCell)
pMyFormulaCell->GetMatColsRows( nCols, nRows);
bool bMayBeScalar;
if (nCols == 0)
{
// Happens if called via ScViewFunc::EnterMatrix()
// ScFormulaCell::GetResultDimensions() as of course a
// matrix result is not available yet.
nCols = 1;
bMayBeScalar = false;
}
ScMatrixRef pResMat = GetNewMat( static_cast<SCSIZE>(nCols), 1, /*bEmpty*/true );
if (pResMat)
else
{
for (SCCOL i=0; i < nCols; ++i)
pResMat->PutDouble( nVal + i, static_cast<SCSIZE>(i), 0);
PushMatrix( pResMat);
return;
bMayBeScalar = true;
}
if (!bMayBeScalar || nCols != 1 || nRows != 1)
{
ScMatrixRef pResMat = GetNewMat( static_cast<SCSIZE>(nCols), 1, /*bEmpty*/true );
if (pResMat)
{
for (SCCOL i=0; i < nCols; ++i)
pResMat->PutDouble( nVal + i, static_cast<SCSIZE>(i), 0);
PushMatrix( pResMat);
return;
}
}
}
}
@@ -4561,20 +4570,29 @@ void ScInterpreter::ScRow()
SCROW nRows = 0;
if (pMyFormulaCell)
pMyFormulaCell->GetMatColsRows( nCols, nRows);
bool bMayBeScalar;
if (nRows == 0)
{
// Happens if called via ScViewFunc::EnterMatrix()
// ScFormulaCell::GetResultDimensions() as of course a
// matrix result is not available yet.
nRows = 1;
bMayBeScalar = false;
}
ScMatrixRef pResMat = GetNewMat( 1, static_cast<SCSIZE>(nRows), /*bEmpty*/true);
if (pResMat)
else
{
for (SCROW i=0; i < nRows; i++)
pResMat->PutDouble( nVal + i, 0, static_cast<SCSIZE>(i));
PushMatrix( pResMat);
return;
bMayBeScalar = true;
}
if (!bMayBeScalar || nCols != 1 || nRows != 1)
{
ScMatrixRef pResMat = GetNewMat( 1, static_cast<SCSIZE>(nRows), /*bEmpty*/true);
if (pResMat)
{
for (SCROW i=0; i < nRows; i++)
pResMat->PutDouble( nVal + i, 0, static_cast<SCSIZE>(i));
PushMatrix( pResMat);
return;
}
}
}
}