summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKohei Yoshida <kyoshida@novell.com>2010-03-08 10:38:03 -0500
committerKohei Yoshida <kyoshida@novell.com>2010-03-08 10:38:03 -0500
commit3387f0a6dd7c2cc78e1b7c134d49f5bcb2b0870a (patch)
treec3414797992b93ee42fedecf603c2e16b14e5643
parentb7450350c117ec6d4e3f5edee10a2a9dbb3b2b99 (diff)
koheiextref01: i#109170# Iterate through the formula cell list in the external ref mgr to mark used references.
The old code scanned *all* formula cells in the entire document, to see if any external references exist in the document. Now that the external ref mgr tracks formula cells with external references better, let's use that list, to be more efficient.
-rw-r--r--sc/inc/column.hxx1
-rw-r--r--sc/inc/externalrefmgr.hxx2
-rw-r--r--sc/inc/table.hxx1
-rw-r--r--sc/source/core/data/column.cxx16
-rw-r--r--sc/source/core/data/documen3.cxx7
-rw-r--r--sc/source/core/data/table2.cxx11
-rw-r--r--sc/source/ui/docshell/externalrefmgr.cxx18
7 files changed, 22 insertions, 34 deletions
diff --git a/sc/inc/column.hxx b/sc/inc/column.hxx
index 08f3d1f7b1e3..3386b3ebec67 100644
--- a/sc/inc/column.hxx
+++ b/sc/inc/column.hxx
@@ -273,7 +273,6 @@ public:
void CalcAfterLoad();
void CompileAll();
void CompileXML( ScProgress& rProgress );
- bool MarkUsedExternalReferences();
void ResetChanged( SCROW nStartRow, SCROW nEndRow );
diff --git a/sc/inc/externalrefmgr.hxx b/sc/inc/externalrefmgr.hxx
index 198c139e28ae..10020a8380d8 100644
--- a/sc/inc/externalrefmgr.hxx
+++ b/sc/inc/externalrefmgr.hxx
@@ -486,6 +486,8 @@ public:
*/
bool markUsedByLinkListeners();
+ bool markUsedExternalRefCells();
+
/**
* Set all tables of a document as referenced, used only during
* store-to-file.
diff --git a/sc/inc/table.hxx b/sc/inc/table.hxx
index b7d6721e4344..46e8f133c274 100644
--- a/sc/inc/table.hxx
+++ b/sc/inc/table.hxx
@@ -416,7 +416,6 @@ public:
void CalcAfterLoad();
void CompileAll();
void CompileXML( ScProgress& rProgress );
- bool MarkUsedExternalReferences();
void UpdateReference( UpdateRefMode eUpdateRefMode, SCCOL nCol1, SCROW nRow1, SCTAB nTab1,
SCCOL nCol2, SCROW nRow2, SCTAB nTab2,
diff --git a/sc/source/core/data/column.cxx b/sc/source/core/data/column.cxx
index 49ae4a98b1c6..d68994354af4 100644
--- a/sc/source/core/data/column.cxx
+++ b/sc/source/core/data/column.cxx
@@ -2100,22 +2100,6 @@ void ScColumn::CalcAfterLoad()
}
-bool ScColumn::MarkUsedExternalReferences()
-{
- bool bAllMarked = false;
- if (pItems)
- {
- for (SCSIZE i = 0; i < nCount && !bAllMarked; ++i)
- {
- ScBaseCell* pCell = pItems[i].pCell;
- if ( pCell->GetCellType() == CELLTYPE_FORMULA )
- bAllMarked = ((ScFormulaCell*)pCell)->MarkUsedExternalReferences();
- }
- }
- return bAllMarked;
-}
-
-
void ScColumn::ResetChanged( SCROW nStartRow, SCROW nEndRow )
{
if (pItems)
diff --git a/sc/source/core/data/documen3.cxx b/sc/source/core/data/documen3.cxx
index cc06d7ac6b32..683f5ea55eb6 100644
--- a/sc/source/core/data/documen3.cxx
+++ b/sc/source/core/data/documen3.cxx
@@ -460,11 +460,8 @@ void ScDocument::MarkUsedExternalReferences()
// Charts.
bool bAllMarked = pExternalRefMgr->markUsedByLinkListeners();
// Formula cells.
- for (SCTAB nTab = 0; !bAllMarked && nTab < nMaxTableNumber; ++nTab)
- {
- if (pTab[nTab])
- bAllMarked = pTab[nTab]->MarkUsedExternalReferences();
- }
+ bAllMarked = pExternalRefMgr->markUsedExternalRefCells();
+
/* NOTE: Conditional formats and validation objects are marked when
* collecting them during export. */
}
diff --git a/sc/source/core/data/table2.cxx b/sc/source/core/data/table2.cxx
index 5b3f6078d489..b6aaa08a7db3 100644
--- a/sc/source/core/data/table2.cxx
+++ b/sc/source/core/data/table2.cxx
@@ -1125,17 +1125,6 @@ void ScTable::CalcAfterLoad()
}
-bool ScTable::MarkUsedExternalReferences()
-{
- bool bAllMarked = false;
- for (SCCOL i=0; i <= MAXCOL && !bAllMarked; ++i)
- {
- bAllMarked = aCol[i].MarkUsedExternalReferences();
- }
- return bAllMarked;
-}
-
-
void ScTable::ResetChanged( const ScRange& rRange )
{
SCCOL nStartCol = rRange.aStart.Col();
diff --git a/sc/source/ui/docshell/externalrefmgr.cxx b/sc/source/ui/docshell/externalrefmgr.cxx
index c067083c4017..ed929e986b2f 100644
--- a/sc/source/ui/docshell/externalrefmgr.cxx
+++ b/sc/source/ui/docshell/externalrefmgr.cxx
@@ -1532,6 +1532,24 @@ bool ScExternalRefManager::markUsedByLinkListeners()
return bAllMarked;
}
+bool ScExternalRefManager::markUsedExternalRefCells()
+{
+ RefCellMap::iterator itr = maRefCells.begin(), itrEnd = maRefCells.end();
+ for (; itr != itrEnd; ++itr)
+ {
+ RefCellSet::iterator itrCell = itr->second.begin(), itrCellEnd = itr->second.end();
+ for (; itrCell != itrCellEnd; ++itrCell)
+ {
+ ScFormulaCell* pCell = *itrCell;
+ bool bUsed = pCell->MarkUsedExternalReferences();
+ if (bUsed)
+ // Return true even only one cell references external documents.
+ return true;
+ }
+ }
+ return false;
+}
+
bool ScExternalRefManager::setCacheDocReferenced( sal_uInt16 nFileId )
{
return maRefCache.setCacheDocReferenced( nFileId);