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

Kohei Yoshida kohei.yoshida at collabora.com
Mon Jun 16 07:51:12 PDT 2014


 sc/source/ui/docshell/externalrefmgr.cxx |   16 +++++++++++-----
 1 file changed, 11 insertions(+), 5 deletions(-)

New commits:
commit 32c7969c6ef0d35782a4f3fc11aaa9fd4771da71
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date:   Mon Jun 16 10:43:08 2014 -0400

    Cache table entry may be null. Let's not assume it's always non-null.
    
    This is done intentionally because we do need correct table index when
    resolving external reference. This requires we do need to allocate array
    with the same sheet size as the remote document.  But we don't allocate
    Table instances for remote sheets that we don't reference, to save
    memory.
    
    Change-Id: I27fb6228f0e4558327aa4a04a6bccce8d2f1085f
    (cherry picked from commit 3dcfb9a892e528a386bb304e4e00d2fa34b1de25)

diff --git a/sc/source/ui/docshell/externalrefmgr.cxx b/sc/source/ui/docshell/externalrefmgr.cxx
index 9c89c00..325cfb2 100644
--- a/sc/source/ui/docshell/externalrefmgr.cxx
+++ b/sc/source/ui/docshell/externalrefmgr.cxx
@@ -1122,15 +1122,18 @@ void ScExternalRefCache::getAllCachedDataSpans( sal_uInt16 nFileId, sc::ColumnSp
     const std::vector<TableTypeRef>& rTables = pDocItem->maTables;
     for (size_t nTab = 0, nTabCount = rTables.size(); nTab < nTabCount; ++nTab)
     {
-        const Table& rTable = *rTables[nTab];
+        TableTypeRef pTab = rTables[nTab];
+        if (!pTab)
+            continue;
+
         std::vector<SCROW> aRows;
-        rTable.getAllRows(aRows);
+        pTab->getAllRows(aRows);
         std::vector<SCROW>::const_iterator itRow = aRows.begin(), itRowEnd = aRows.end();
         for (; itRow != itRowEnd; ++itRow)
         {
             SCROW nRow = *itRow;
             std::vector<SCCOL> aCols;
-            rTable.getAllCols(nRow, aCols);
+            pTab->getAllCols(nRow, aCols);
             std::vector<SCCOL>::const_iterator itCol = aCols.begin(), itColEnd = aCols.end();
             for (; itCol != itColEnd; ++itCol)
             {
@@ -1246,8 +1249,11 @@ void ScExternalRefCache::clearCacheTables(sal_uInt16 nFileId)
     std::vector<TableTypeRef>& rTabs = pDocItem->maTables;
     for (size_t i = 0, n = rTabs.size(); i < n; ++i)
     {
-        Table& rTab = *rTabs[i];
-        rTab.clear();
+        TableTypeRef pTab = rTabs[i];
+        if (!pTab)
+            continue;
+
+        pTab->clear();
     }
 
     // Clear the external range name caches.


More information about the Libreoffice-commits mailing list