summaryrefslogtreecommitdiff
path: root/sc/source
diff options
context:
space:
mode:
authorKohei Yoshida <kyoshida@novell.com>2011-05-05 22:46:39 -0400
committerKohei Yoshida <kyoshida@novell.com>2011-05-05 22:46:39 -0400
commitfb4f96da8c159ad75da3a16e08d1940dd588c1e7 (patch)
treeebccd49ccc1d16f91ed67cd6ee3952d3841bba0c /sc/source
parent052b1d73876717e01b63b0afa5af4b39534c37dd (diff)
Properly cache external reference values in named ranges.
Values of the external references used only in named ranges were not cached properly. This commit fixes it.
Diffstat (limited to 'sc/source')
-rw-r--r--sc/source/core/data/documen4.cxx85
1 files changed, 57 insertions, 28 deletions
diff --git a/sc/source/core/data/documen4.cxx b/sc/source/core/data/documen4.cxx
index 1958bf721a4c..b9c79e1c9ebf 100644
--- a/sc/source/core/data/documen4.cxx
+++ b/sc/source/core/data/documen4.cxx
@@ -296,42 +296,71 @@ void ScDocument::InsertTableOp(const ScTabOpParam& rParam, // Mehrfachopera
pTab[i]->PutCell( j, k, aRefCell.CloneWithoutNote( *this, ScAddress( j, k, i ), SC_CLONECELL_STARTLISTENING ) );
}
+namespace {
+
+bool setCacheTableReferenced(ScToken& rToken, ScExternalRefManager& rRefMgr)
+{
+ switch (rToken.GetType())
+ {
+ case svExternalSingleRef:
+ return rRefMgr.setCacheTableReferenced(
+ rToken.GetIndex(), rToken.GetString(), 1);
+ case svExternalDoubleRef:
+ {
+ const ScComplexRefData& rRef = rToken.GetDoubleRef();
+ size_t nSheets = rRef.Ref2.nTab - rRef.Ref1.nTab + 1;
+ return rRefMgr.setCacheTableReferenced(
+ rToken.GetIndex(), rToken.GetString(), nSheets);
+ }
+ case svExternalName:
+ /* TODO: external names aren't supported yet, but would
+ * have to be marked as well, if so. Mechanism would be
+ * different. */
+ DBG_ERRORFILE("ScDocument::MarkUsedExternalReferences: implement the svExternalName case!");
+ default:
+ ;
+ }
+ return false;
+}
+
+}
+
bool ScDocument::MarkUsedExternalReferences( ScTokenArray & rArr )
{
+ if (!rArr.GetLen())
+ return false;
+
+ ScExternalRefManager* pRefMgr = NULL;
+ rArr.Reset();
+ ScToken* t = NULL;
bool bAllMarked = false;
- if (rArr.GetLen())
+ while (!bAllMarked && (t = static_cast<ScToken*>(rArr.GetNextReferenceOrName())) != NULL)
{
- ScExternalRefManager* pRefMgr = NULL;
- rArr.Reset();
- ScToken* t;
- while (!bAllMarked && (t = static_cast<ScToken*>(rArr.GetNextReferenceOrName())) != NULL)
+ if (t->IsExternalRef())
+ {
+ if (!pRefMgr)
+ pRefMgr = GetExternalRefManager();
+
+ bAllMarked = setCacheTableReferenced(*t, *pRefMgr);
+ }
+ else if (t->GetType() == svIndex)
{
- if (t->IsExternalRef())
+ // this is a named range. Check if the range contains an external
+ // reference.
+ ScRangeData* pRangeData = GetRangeName()->findByIndex(t->GetIndex());
+ if (!pRangeData)
+ continue;
+
+ ScTokenArray* pArray = pRangeData->GetCode();
+ for (t = static_cast<ScToken*>(pArray->First()); t; t = static_cast<ScToken*>(pArray->Next()))
{
+ if (!t->IsExternalRef())
+ continue;
+
if (!pRefMgr)
pRefMgr = GetExternalRefManager();
- switch (t->GetType())
- {
- case svExternalSingleRef:
- bAllMarked = pRefMgr->setCacheTableReferenced(
- t->GetIndex(), t->GetString(), 1);
- break;
- case svExternalDoubleRef:
- {
- const ScComplexRefData& rRef = t->GetDoubleRef();
- size_t nSheets = rRef.Ref2.nTab - rRef.Ref1.nTab + 1;
- bAllMarked = pRefMgr->setCacheTableReferenced(
- t->GetIndex(), t->GetString(), nSheets);
- }
- break;
- case svExternalName:
- /* TODO: external names aren't supported yet, but would
- * have to be marked as well, if so. Mechanism would be
- * different. */
- DBG_ERRORFILE("ScDocument::MarkUsedExternalReferences: implement the svExternalName case!");
- break;
- default: break;
- }
+
+ bAllMarked = setCacheTableReferenced(*t, *pRefMgr);
}
}
}