summaryrefslogtreecommitdiff
path: root/sc/source/core/data/dpshttab.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'sc/source/core/data/dpshttab.cxx')
-rw-r--r--sc/source/core/data/dpshttab.cxx18
1 files changed, 13 insertions, 5 deletions
diff --git a/sc/source/core/data/dpshttab.cxx b/sc/source/core/data/dpshttab.cxx
index e4aca9a45253..cfad761377bc 100644
--- a/sc/source/core/data/dpshttab.cxx
+++ b/sc/source/core/data/dpshttab.cxx
@@ -60,7 +60,7 @@ using ::std::vector;
// -----------------------------------------------------------------------
-ScSheetDPData::ScSheetDPData(ScDocument* pD, const ScSheetSourceDesc& rDesc, ScDPCache* pCache) :
+ScSheetDPData::ScSheetDPData(ScDocument* pD, const ScSheetSourceDesc& rDesc, const ScDPCache* pCache) :
ScDPTableData(pD),
aQuery ( rDesc.GetQueryParam() ),
pSpecial(NULL),
@@ -307,7 +307,7 @@ bool ScSheetSourceDesc::operator== (const ScSheetSourceDesc& rOther) const
maQueryParam == rOther.maQueryParam;
}
-ScDPCache* ScSheetSourceDesc::CreateCache() const
+const ScDPCache* ScSheetSourceDesc::CreateCache() const
{
if (!mpDoc)
return NULL;
@@ -319,9 +319,17 @@ ScDPCache* ScSheetSourceDesc::CreateCache() const
return NULL;
}
- ScDPCache* pCache = new ScDPCache(mpDoc);
- pCache->InitFromDoc(mpDoc, GetSourceRange());
- return pCache;
+ // All cache instances are managed centrally by ScDPCollection.
+ ScDPCollection* pDPs = mpDoc->GetDPCollection();
+ if (HasRangeName())
+ {
+ // Name-based data source.
+ ScDPCollection::NameCaches& rCaches = pDPs->GetNameCaches();
+ return rCaches.getCache(GetRangeName(), GetSourceRange());
+ }
+
+ ScDPCollection::SheetCaches& rCaches = pDPs->GetSheetCaches();
+ return rCaches.getCache(GetSourceRange());
}
long ScSheetSourceDesc::GetCacheId() const