Kaydet (Commit) 8795dff9 authored tarafından Michael Stahl's avatar Michael Stahl

sc: replace boost::ptr_map with std::map<std::unique_ptr>

Change-Id: Iaaf8e5f14691cde32058a78842b9c411f2b92d93
üst 85f17f9e
...@@ -33,6 +33,7 @@ ...@@ -33,6 +33,7 @@
#include <memory> #include <memory>
#include <set> #include <set>
#include <vector> #include <vector>
#include <map>
#include <boost/ptr_container/ptr_map.hpp> #include <boost/ptr_container/ptr_map.hpp>
...@@ -267,9 +268,9 @@ public: ...@@ -267,9 +268,9 @@ public:
class SheetCaches class SheetCaches
{ {
friend class ScDPCollection; friend class ScDPCollection;
typedef boost::ptr_map<size_t, ScDPCache> CachesType; typedef std::map<size_t, std::unique_ptr<ScDPCache>> CachesType;
typedef std::vector<ScRange> RangeIndexType; typedef std::vector<ScRange> RangeIndexType;
CachesType maCaches; CachesType m_Caches;
RangeIndexType maRanges; RangeIndexType maRanges;
ScDocument* mpDoc; ScDocument* mpDoc;
public: public:
......
...@@ -2841,8 +2841,8 @@ bool ScDPCollection::SheetCaches::hasCache(const ScRange& rRange) const ...@@ -2841,8 +2841,8 @@ bool ScDPCollection::SheetCaches::hasCache(const ScRange& rRange) const
// Already cached. // Already cached.
size_t nIndex = std::distance(maRanges.begin(), it); size_t nIndex = std::distance(maRanges.begin(), it);
CachesType::const_iterator itCache = maCaches.find(nIndex); CachesType::const_iterator const itCache = m_Caches.find(nIndex);
return itCache != maCaches.end(); return itCache != m_Caches.end();
} }
const ScDPCache* ScDPCollection::SheetCaches::getCache(const ScRange& rRange, const ScDPDimensionSaveData* pDimData) const ScDPCache* ScDPCollection::SheetCaches::getCache(const ScRange& rRange, const ScDPDimensionSaveData* pDimData)
...@@ -2852,8 +2852,8 @@ const ScDPCache* ScDPCollection::SheetCaches::getCache(const ScRange& rRange, co ...@@ -2852,8 +2852,8 @@ const ScDPCache* ScDPCollection::SheetCaches::getCache(const ScRange& rRange, co
{ {
// Already cached. // Already cached.
size_t nIndex = std::distance(maRanges.begin(), it); size_t nIndex = std::distance(maRanges.begin(), it);
CachesType::iterator itCache = maCaches.find(nIndex); CachesType::iterator const itCache = m_Caches.find(nIndex);
if (itCache == maCaches.end()) if (itCache == m_Caches.end())
{ {
OSL_FAIL("Cache pool and index pool out-of-sync !!!"); OSL_FAIL("Cache pool and index pool out-of-sync !!!");
return nullptr; return nullptr;
...@@ -2862,7 +2862,7 @@ const ScDPCache* ScDPCollection::SheetCaches::getCache(const ScRange& rRange, co ...@@ -2862,7 +2862,7 @@ const ScDPCache* ScDPCollection::SheetCaches::getCache(const ScRange& rRange, co
if (pDimData) if (pDimData)
pDimData->WriteToCache(*itCache->second); pDimData->WriteToCache(*itCache->second);
return itCache->second; return itCache->second.get();
} }
// Not cached. Create a new cache. // Not cached. Create a new cache.
...@@ -2888,7 +2888,7 @@ const ScDPCache* ScDPCollection::SheetCaches::getCache(const ScRange& rRange, co ...@@ -2888,7 +2888,7 @@ const ScDPCache* ScDPCollection::SheetCaches::getCache(const ScRange& rRange, co
} }
const ScDPCache* p = pCache.get(); const ScDPCache* p = pCache.get();
o3tl::ptr_container::insert(maCaches, nIndex, std::move(pCache)); m_Caches.insert(std::make_pair(nIndex, std::move(pCache)));
return p; return p;
} }
...@@ -2901,14 +2901,14 @@ ScDPCache* ScDPCollection::SheetCaches::getExistingCache(const ScRange& rRange) ...@@ -2901,14 +2901,14 @@ ScDPCache* ScDPCollection::SheetCaches::getExistingCache(const ScRange& rRange)
// Already cached. // Already cached.
size_t nIndex = std::distance(maRanges.begin(), it); size_t nIndex = std::distance(maRanges.begin(), it);
CachesType::iterator itCache = maCaches.find(nIndex); CachesType::iterator const itCache = m_Caches.find(nIndex);
if (itCache == maCaches.end()) if (itCache == m_Caches.end())
{ {
OSL_FAIL("Cache pool and index pool out-of-sync !!!"); OSL_FAIL("Cache pool and index pool out-of-sync !!!");
return nullptr; return nullptr;
} }
return itCache->second; return itCache->second.get();
} }
const ScDPCache* ScDPCollection::SheetCaches::getExistingCache(const ScRange& rRange) const const ScDPCache* ScDPCollection::SheetCaches::getExistingCache(const ScRange& rRange) const
...@@ -2920,19 +2920,19 @@ const ScDPCache* ScDPCollection::SheetCaches::getExistingCache(const ScRange& rR ...@@ -2920,19 +2920,19 @@ const ScDPCache* ScDPCollection::SheetCaches::getExistingCache(const ScRange& rR
// Already cached. // Already cached.
size_t nIndex = std::distance(maRanges.begin(), it); size_t nIndex = std::distance(maRanges.begin(), it);
CachesType::const_iterator itCache = maCaches.find(nIndex); CachesType::const_iterator const itCache = m_Caches.find(nIndex);
if (itCache == maCaches.end()) if (itCache == m_Caches.end())
{ {
OSL_FAIL("Cache pool and index pool out-of-sync !!!"); OSL_FAIL("Cache pool and index pool out-of-sync !!!");
return nullptr; return nullptr;
} }
return itCache->second; return itCache->second.get();
} }
size_t ScDPCollection::SheetCaches::size() const size_t ScDPCollection::SheetCaches::size() const
{ {
return maCaches.size(); return m_Caches.size();
} }
void ScDPCollection::SheetCaches::updateReference( void ScDPCollection::SheetCaches::updateReference(
...@@ -2979,8 +2979,8 @@ void ScDPCollection::SheetCaches::updateCache(const ScRange& rRange, std::set<Sc ...@@ -2979,8 +2979,8 @@ void ScDPCollection::SheetCaches::updateCache(const ScRange& rRange, std::set<Sc
} }
size_t nIndex = std::distance(maRanges.begin(), it); size_t nIndex = std::distance(maRanges.begin(), it);
CachesType::iterator itCache = maCaches.find(nIndex); CachesType::iterator const itCache = m_Caches.find(nIndex);
if (itCache == maCaches.end()) if (itCache == m_Caches.end())
{ {
OSL_FAIL("Cache pool and index pool out-of-sync !!!"); OSL_FAIL("Cache pool and index pool out-of-sync !!!");
rRefs.clear(); rRefs.clear();
...@@ -3001,13 +3001,13 @@ void ScDPCollection::SheetCaches::updateCache(const ScRange& rRange, std::set<Sc ...@@ -3001,13 +3001,13 @@ void ScDPCollection::SheetCaches::updateCache(const ScRange& rRange, std::set<Sc
bool ScDPCollection::SheetCaches::remove(const ScDPCache* p) bool ScDPCollection::SheetCaches::remove(const ScDPCache* p)
{ {
CachesType::iterator it = maCaches.begin(), itEnd = maCaches.end(); CachesType::iterator it = m_Caches.begin(), itEnd = m_Caches.end();
for (; it != itEnd; ++it) for (; it != itEnd; ++it)
{ {
if (it->second == p) if (it->second.get() == p)
{ {
size_t idx = it->first; size_t idx = it->first;
maCaches.erase(it); m_Caches.erase(it);
maRanges[idx].SetInvalid(); maRanges[idx].SetInvalid();
return true; return true;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment