[Libreoffice-commits] .: Branch 'feature/calc-matrix-rework' - 2 commits - sc/source

Kohei Yoshida kohei at kemper.freedesktop.org
Fri Dec 17 13:25:26 PST 2010


 sc/source/ui/docshell/externalrefmgr.cxx |   45 +------------------------------
 1 file changed, 2 insertions(+), 43 deletions(-)

New commits:
commit cb9594579083db2619336d7280ba93b2c899a6f4
Author: Kohei Yoshida <kyoshida at novell.com>
Date:   Fri Dec 17 16:24:39 2010 -0500

    Use sparse matrix when building an external range data.

diff --git a/sc/source/ui/docshell/externalrefmgr.cxx b/sc/source/ui/docshell/externalrefmgr.cxx
index cbdff8f..ef514bb 100644
--- a/sc/source/ui/docshell/externalrefmgr.cxx
+++ b/sc/source/ui/docshell/externalrefmgr.cxx
@@ -585,11 +585,8 @@ ScExternalRefCache::TokenArrayRef ScExternalRefCache::getCellRangeData(
         }
 
         ScMatrixRef xMat = new ScMatrix(
-            static_cast<SCSIZE>(nDataCol2-nDataCol1+1), static_cast<SCSIZE>(nDataRow2-nDataRow1+1));
-
-#if 0
-        // TODO: Switch to this code block once we have support for sparsely-filled
-        // matrices in ScMatrix.
+            static_cast<SCSIZE>(nDataCol2-nDataCol1+1),
+            static_cast<SCSIZE>(nDataRow2-nDataRow1+1), ScMatrix::SPARSE_EMPTY);
 
         // Only fill non-empty cells, for better performance.
         vector<SCROW> aRows;
@@ -621,40 +618,6 @@ ScExternalRefCache::TokenArrayRef ScExternalRefCache::getCellRangeData(
                 }
             }
         }
-#else
-        vector<SCROW> aRows;
-        pTab->getAllRows(aRows, nDataRow1, nDataRow2);
-        if (aRows.empty())
-            // Cache is empty.
-            return TokenArrayRef();
-        else
-            // Trim the column below the last non-empty row.
-            nDataRow2 = aRows.back();
-
-        // Empty all matrix elements first, and fill only non-empty elements.
-        for (SCROW nRow = nDataRow1; nRow <= nDataRow2; ++nRow)
-        {
-            for (SCCOL nCol = nDataCol1; nCol <= nDataCol2; ++nCol)
-            {
-                TokenRef pToken = pTab->getCell(nCol, nRow);
-                SCSIZE nC = nCol - nCol1, nR = nRow - nRow1;
-                if (!pToken)
-                    return TokenArrayRef();
-
-                switch (pToken->GetType())
-                {
-                    case svDouble:
-                        xMat->PutDouble(pToken->GetDouble(), nC, nR);
-                    break;
-                    case svString:
-                        xMat->PutString(pToken->GetString(), nC, nR);
-                    break;
-                    default:
-                        xMat->PutEmpty(nC, nR);
-                }
-            }
-        }
-#endif
 
         if (!bFirstTab)
             pArray->AddOpCode(ocSep);
commit 505caa5b84bbd5a8e9404929dda7084430ba63d5
Author: Kohei Yoshida <kyoshida at novell.com>
Date:   Fri Dec 17 15:42:21 2010 -0500

    Removed TODO comment as it's already been completed.

diff --git a/sc/source/ui/docshell/externalrefmgr.cxx b/sc/source/ui/docshell/externalrefmgr.cxx
index fa915e9..cbdff8f 100644
--- a/sc/source/ui/docshell/externalrefmgr.cxx
+++ b/sc/source/ui/docshell/externalrefmgr.cxx
@@ -2048,10 +2048,6 @@ const ScDocument* ScExternalRefManager::getSrcDocument(sal_uInt16 nFileId)
     {
         // document already loaded.
 
-        // TODO: Find out a way to access a document that's already open in
-        // memory and re-use that instance, instead of loading it from the
-        // disk again.
-
         SfxObjectShell* p = itr->second.maShell;
         itr->second.maLastAccess = Time();
         return static_cast<ScDocShell*>(p)->GetDocument();


More information about the Libreoffice-commits mailing list