summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEike Rathke <erack@redhat.com>2013-04-11 01:29:22 +0200
committerFridrich Strba <fridrich@documentfoundation.org>2013-04-11 06:21:16 +0000
commit6328c5b5b06f8c065a014b18f3c86fd8c24b91c2 (patch)
tree53257e84b89a00e29e202f7bda5603c57c742212
parent1a29c1bb23f76ba3799dc2a77b4f678ca0ad109d (diff)
resolved fdo#63403 do not create matrix with 0 rows or cols
(cherry picked from commit 7c3ab3bc15cec211767490823539efcada4fe964) Conflicts: sc/source/core/tool/scmatrix.cxx Change-Id: Icb0000bde3723c1b37713d0f26ef8305c4a199b8 Reviewed-on: https://gerrit.libreoffice.org/3322 Reviewed-by: Fridrich Strba <fridrich@documentfoundation.org> Tested-by: Fridrich Strba <fridrich@documentfoundation.org>
-rw-r--r--sc/source/core/tool/interpr1.cxx14
-rw-r--r--sc/source/core/tool/scmatrix.cxx2
2 files changed, 15 insertions, 1 deletions
diff --git a/sc/source/core/tool/interpr1.cxx b/sc/source/core/tool/interpr1.cxx
index 42a08254d863..f645ec73e49a 100644
--- a/sc/source/core/tool/interpr1.cxx
+++ b/sc/source/core/tool/interpr1.cxx
@@ -4304,6 +4304,13 @@ void ScInterpreter::ScColumn()
SCCOL nCols;
SCROW nRows;
pMyFormulaCell->GetMatColsRows( nCols, nRows);
+ if (nCols == 0)
+ {
+ // Happens if called via ScViewFunc::EnterMatrix()
+ // ScFormulaCell::GetResultDimensions() as of course a
+ // matrix result is not available yet.
+ nCols = 1;
+ }
ScMatrixRef pResMat = GetNewMat( static_cast<SCSIZE>(nCols), 1);
if (pResMat)
{
@@ -4380,6 +4387,13 @@ void ScInterpreter::ScRow()
SCCOL nCols;
SCROW nRows;
pMyFormulaCell->GetMatColsRows( nCols, nRows);
+ if (nRows == 0)
+ {
+ // Happens if called via ScViewFunc::EnterMatrix()
+ // ScFormulaCell::GetResultDimensions() as of course a
+ // matrix result is not available yet.
+ nRows = 1;
+ }
ScMatrixRef pResMat = GetNewMat( 1, static_cast<SCSIZE>(nRows));
if (pResMat)
{
diff --git a/sc/source/core/tool/scmatrix.cxx b/sc/source/core/tool/scmatrix.cxx
index 47ed6e9731d4..aa1119279a65 100644
--- a/sc/source/core/tool/scmatrix.cxx
+++ b/sc/source/core/tool/scmatrix.cxx
@@ -911,7 +911,7 @@ size_t ScMatrixImpl::Count(bool bCountStrings) const
void ScMatrixImpl::CalcPosition(SCSIZE nIndex, SCSIZE& rC, SCSIZE& rR) const
{
SCSIZE nRowSize = maCachedSize.first;
- rC = nIndex / nRowSize;
+ rC = nRowSize > 1 ? nIndex / nRowSize : nIndex;
rR = nIndex - rC*nRowSize;
}