diff options
author | Kohei Yoshida <kyoshida@novell.com> | 2011-04-29 12:26:16 -0400 |
---|---|---|
committer | Kohei Yoshida <kyoshida@novell.com> | 2011-04-29 12:28:08 -0400 |
commit | 0d0fe4085479d0425f7402a3cf478d7f5f9e3aab (patch) | |
tree | 9da82fe6ded7a371edabb5d65b52619433e39ead /sc/source/core/data/dpobject.cxx | |
parent | fb2ffa4384c138acfb44e73b4bfa2c4ee81992c9 (diff) |
Manage data caches for named range data source separately.
Without this, updating the named range and refreshing would fail to
remove the old cache, which is no longer referenced. Very bad for
memory footprint.
Diffstat (limited to 'sc/source/core/data/dpobject.cxx')
-rw-r--r-- | sc/source/core/data/dpobject.cxx | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/sc/source/core/data/dpobject.cxx b/sc/source/core/data/dpobject.cxx index e5c76d465..4c9961352 100644 --- a/sc/source/core/data/dpobject.cxx +++ b/sc/source/core/data/dpobject.cxx @@ -2416,6 +2416,29 @@ void ScDPCollection::SheetCaches::removeCache(const ScRange& rRange) maCaches.erase(itr); } +ScDPCollection::NameCaches::NameCaches(ScDocument* pDoc) : mpDoc(pDoc) {} + +const ScDPCache* ScDPCollection::NameCaches::getCache(const OUString& rName, const ScRange& rRange) +{ + CachesType::const_iterator itr = maCaches.find(rName); + if (itr != maCaches.end()) + // already cached. + return itr->second; + + ::std::auto_ptr<ScDPCache> pCache(new ScDPCache(mpDoc)); + pCache->InitFromDoc(mpDoc, rRange); + const ScDPCache* p = pCache.get(); + maCaches.insert(rName, pCache); + return p; +} + +void ScDPCollection::NameCaches::removeCache(const OUString& rName) +{ + CachesType::iterator itr = maCaches.find(rName); + if (itr != maCaches.end()) + maCaches.erase(itr); +} + ScDPCollection::DBType::DBType(sal_Int32 nSdbType, const OUString& rDBName, const OUString& rCommand) : mnSdbType(nSdbType), maDBName(rDBName), maCommand(rCommand) {} @@ -2502,6 +2525,7 @@ void ScDPCollection::DBCaches::removeCache(sal_Int32 nSdbType, const OUString& r ScDPCollection::ScDPCollection(ScDocument* pDocument) : pDoc( pDocument ), maSheetCaches(pDocument), + maNameCaches(pDocument), maDBCaches(pDocument) { } @@ -2509,6 +2533,7 @@ ScDPCollection::ScDPCollection(ScDocument* pDocument) : ScDPCollection::ScDPCollection(const ScDPCollection& r) : pDoc(r.pDoc), maSheetCaches(r.pDoc), + maNameCaches(r.pDoc), maDBCaches(r.pDoc) { } @@ -2707,6 +2732,11 @@ ScDPCollection::SheetCaches& ScDPCollection::GetSheetCaches() return maSheetCaches; } +ScDPCollection::NameCaches& ScDPCollection::GetNameCaches() +{ + return maNameCaches; +} + ScDPCollection::DBCaches& ScDPCollection::GetDBCaches() { return maDBCaches; |