sc/source/core/tool/interpr1.cxx |   14 ++++++++++++++
 sc/source/core/tool/scmatrix.cxx |    2 +-
 2 files changed, 15 insertions(+), 1 deletion(-)

New commits:
commit 6328c5b5b06f8c065a014b18f3c86fd8c24b91c2
Author: Eike Rathke <er...@redhat.com>
Date:   Thu Apr 11 01:29:22 2013 +0200

    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 <fridr...@documentfoundation.org>
    Tested-by: Fridrich Strba <fridr...@documentfoundation.org>

diff --git a/sc/source/core/tool/interpr1.cxx b/sc/source/core/tool/interpr1.cxx
index 42a0825..f645ec7 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 47ed6e9..aa11192 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;
 }
 
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to