[Libreoffice-commits] .: Branch 'libreoffice-3-4' - sc/source

Markus Mohrhard mmohrhard at kemper.freedesktop.org
Tue Nov 1 09:27:15 PDT 2011


 sc/source/ui/docshell/externalrefmgr.cxx |   79 +++++++++++++++----------------
 1 file changed, 39 insertions(+), 40 deletions(-)

New commits:
commit e6c3ff17ced2aa004eda5ab3a52bc26d4fea74b7
Author: Kohei Yoshida <kohei.yoshida at suse.com>
Date:   Tue Nov 1 15:49:42 2011 +0000

    fdo#40110: Correctly map external ranges into matrix instances.
    
    This is a simple silly mistake; the matrix representation of the
    external range should've preserved the original range; not the data
    range which can be smaller than the originally requested range.
    
    Signed-off-by: Markus Mohrhard <markus.mohrhard at googlemail.com>

diff --git a/sc/source/ui/docshell/externalrefmgr.cxx b/sc/source/ui/docshell/externalrefmgr.cxx
index 1bfdc8b..295b123 100644
--- a/sc/source/ui/docshell/externalrefmgr.cxx
+++ b/sc/source/ui/docshell/externalrefmgr.cxx
@@ -1403,8 +1403,8 @@ static ScTokenArray* lcl_convertToTokenArray(const ScDocument* pSrcDoc, ScRange&
             pUsedRange.reset(new ScRange(nDataCol1, nDataRow1, 0, nDataCol2, nDataRow2, 0));
 
         ScMatrixRef xMat = new ScMatrix(
-            static_cast<SCSIZE>(nDataCol2-nDataCol1+1),
-            static_cast<SCSIZE>(nDataRow2-nDataRow1+1));
+            static_cast<SCSIZE>(nCol2-nCol1+1),
+            static_cast<SCSIZE>(nRow2-nRow1+1), ScMatrix::SPARSE_EMPTY);
 
         for (SCCOL nCol = nDataCol1; nCol <= nDataCol2; ++nCol)
         {
@@ -1414,53 +1414,52 @@ static ScTokenArray* lcl_convertToTokenArray(const ScDocument* pSrcDoc, ScRange&
                 ScBaseCell* pCell;
                 pSrcDoc->GetCell(nCol, nRow, nTab, pCell);
                 if (!pCell || pCell->HasEmptyData())
-                    xMat->PutEmpty(nC, nR);
-                else
+                    // Skip empty cells.  Matrix's default values are empty elements.
+                    continue;
+
+                switch (pCell->GetCellType())
                 {
-                    switch (pCell->GetCellType())
+                    case CELLTYPE_EDIT:
+                    {
+                        String aStr;
+                        static_cast<ScEditCell*>(pCell)->GetString(aStr);
+                        xMat->PutString(aStr, nC, nR);
+                    }
+                    break;
+                    case CELLTYPE_STRING:
+                    {
+                        String aStr;
+                        static_cast<ScStringCell*>(pCell)->GetString(aStr);
+                        xMat->PutString(aStr, nC, nR);
+                    }
+                    break;
+                    case CELLTYPE_VALUE:
+                    {
+                        double fVal = static_cast<ScValueCell*>(pCell)->GetValue();
+                        xMat->PutDouble(fVal, nC, nR);
+                    }
+                    break;
+                    case CELLTYPE_FORMULA:
                     {
-                        case CELLTYPE_EDIT:
+                        ScFormulaCell* pFCell = static_cast<ScFormulaCell*>(pCell);
+                        sal_uInt16 nError = pFCell->GetErrCode();
+                        if (nError)
+                            xMat->PutDouble( CreateDoubleError( nError), nC, nR);
+                        else if (pFCell->IsValue())
                         {
-                            String aStr;
-                            static_cast<ScEditCell*>(pCell)->GetString(aStr);
-                            xMat->PutString(aStr, nC, nR);
+                            double fVal = pFCell->GetValue();
+                            xMat->PutDouble(fVal, nC, nR);
                         }
-                        break;
-                        case CELLTYPE_STRING:
+                        else
                         {
                             String aStr;
-                            static_cast<ScStringCell*>(pCell)->GetString(aStr);
+                            pFCell->GetString(aStr);
                             xMat->PutString(aStr, nC, nR);
                         }
-                        break;
-                        case CELLTYPE_VALUE:
-                        {
-                            double fVal = static_cast<ScValueCell*>(pCell)->GetValue();
-                            xMat->PutDouble(fVal, nC, nR);
-                        }
-                        break;
-                        case CELLTYPE_FORMULA:
-                        {
-                            ScFormulaCell* pFCell = static_cast<ScFormulaCell*>(pCell);
-                            sal_uInt16 nError = pFCell->GetErrCode();
-                            if (nError)
-                                xMat->PutDouble( CreateDoubleError( nError), nC, nR);
-                            else if (pFCell->IsValue())
-                            {
-                                double fVal = pFCell->GetValue();
-                                xMat->PutDouble(fVal, nC, nR);
-                            }
-                            else
-                            {
-                                String aStr;
-                                pFCell->GetString(aStr);
-                                xMat->PutString(aStr, nC, nR);
-                            }
-                        }
-                        break;
-                        default:
-                            OSL_FAIL("attempted to convert an unknown cell type.");
                     }
+                    break;
+                    default:
+                        OSL_FAIL("attempted to convert an unknown cell type.");
                 }
             }
         }


More information about the Libreoffice-commits mailing list