[Libreoffice-commits] .: sc/source

Kohei Yoshida kohei at kemper.freedesktop.org
Tue Nov 1 08:58:41 PDT 2011


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

New commits:
commit 5d02007469d84b248bb623196cca95d431f7ed11
Author: Kohei Yoshida <kohei.yoshida at suse.com>
Date:   Tue Nov 1 11:49:42 2011 -0400

    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.

diff --git a/sc/source/ui/docshell/externalrefmgr.cxx b/sc/source/ui/docshell/externalrefmgr.cxx
index c806531..408feb6 100644
--- a/sc/source/ui/docshell/externalrefmgr.cxx
+++ b/sc/source/ui/docshell/externalrefmgr.cxx
@@ -1412,8 +1412,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)
         {
@@ -1423,53 +1423,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