summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEike Rathke <erack@redhat.com>2023-07-25 23:41:23 +0200
committerEike Rathke <erack@redhat.com>2023-07-26 10:29:36 +0200
commit49b601937f5ba7739198a1b16ba6da2351897750 (patch)
treec74c1bb4e74ef26071ac8fd224cd6b5cd6592cf5
parent41a3620e51726fac1419df77f87113cb32e9981a (diff)
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
-rw-r--r--sc/source/core/tool/interpr1.cxx42
1 files changed, 30 insertions, 12 deletions
diff --git a/sc/source/core/tool/interpr1.cxx b/sc/source/core/tool/interpr1.cxx
index fa0c56d5257f..e5197dd34ece 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;
+ }
}
}
}