Kaydet (Commit) 05dbd67f authored tarafından Julien Nabet's avatar Julien Nabet

Replace list by vector in macromgr.cxx (sc)

Change-Id: I5b57d4f4a1e0c68fdc56d84392f4b1472a67e82b
Reviewed-on: https://gerrit.libreoffice.org/42992Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarJulien Nabet <serval2412@yahoo.fr>
üst 20bae560
...@@ -34,7 +34,7 @@ public: ...@@ -34,7 +34,7 @@ public:
SC_DLLPUBLIC bool GetUserFuncVolatile( const OUString& sName ); SC_DLLPUBLIC bool GetUserFuncVolatile( const OUString& sName );
void AddDependentCell(const OUString& aModuleName, ScFormulaCell* pCell); void AddDependentCell(const OUString& aModuleName, ScFormulaCell* pCell);
void RemoveDependentCell(ScFormulaCell* pCell); void RemoveDependentCell(const ScFormulaCell* pCell);
void BroadcastModuleUpdate(const OUString& aModuleName); void BroadcastModuleUpdate(const OUString& aModuleName);
private: private:
......
...@@ -24,14 +24,13 @@ ...@@ -24,14 +24,13 @@
#include <cppuhelper/implbase.hxx> #include <cppuhelper/implbase.hxx>
#include <sfx2/objsh.hxx> #include <sfx2/objsh.hxx>
#include "formulacell.hxx" #include "formulacell.hxx"
#include <vector>
#include <com/sun/star/container/XContainer.hpp> #include <com/sun/star/container/XContainer.hpp>
#include <list>
using namespace ::com::sun::star; using namespace ::com::sun::star;
using ::com::sun::star::uno::RuntimeException; using ::com::sun::star::uno::RuntimeException;
using ::com::sun::star::uno::Reference; using ::com::sun::star::uno::Reference;
using ::std::list; using ::std::vector;
using ::std::pair; using ::std::pair;
/** /**
...@@ -48,7 +47,7 @@ public: ...@@ -48,7 +47,7 @@ public:
if (itr == maCells.end()) if (itr == maCells.end())
{ {
pair<ModuleCellMap::iterator, bool> r = maCells.emplace( pair<ModuleCellMap::iterator, bool> r = maCells.emplace(
rModuleName, list<ScFormulaCell*>()); rModuleName, vector<ScFormulaCell*>());
if (!r.second) if (!r.second)
// insertion failed. // insertion failed.
...@@ -59,31 +58,33 @@ public: ...@@ -59,31 +58,33 @@ public:
itr->second.push_back(pCell); itr->second.push_back(pCell);
} }
void removeCell(ScFormulaCell* pCell) void removeCell(const ScFormulaCell* pCell)
{ {
ModuleCellMap::iterator itr = maCells.begin(), itrEnd = maCells.end(); ModuleCellMap::iterator itr = maCells.begin(), itrEnd = maCells.end();
for (; itr != itrEnd; ++itr) for (; itr != itrEnd; ++itr)
itr->second.remove(pCell); {
itr->second.erase(std::remove(itr->second.begin(), itr->second.end(), pCell), itr->second.end() );
}
} }
void getCellsByModule(const OUString& rModuleName, list<ScFormulaCell*>& rCells) void getCellsByModule(const OUString& rModuleName, vector<ScFormulaCell*>& rCells)
{ {
ModuleCellMap::iterator itr = maCells.find(rModuleName); ModuleCellMap::iterator itr = maCells.find(rModuleName);
if (itr == maCells.end()) if (itr == maCells.end())
return; return;
list<ScFormulaCell*>& rCellList = itr->second; vector<ScFormulaCell*>& rCellList = itr->second;
// Remove duplicates. // Remove duplicates.
rCellList.sort(); std::sort(rCellList.begin(), rCellList.end());
rCellList.unique(); std::unique(rCellList.begin(), rCellList.end());
// exception safe copy // exception safe copy
list<ScFormulaCell*> temp(rCellList); vector<ScFormulaCell*> temp(rCellList);
rCells.swap(temp); rCells.swap(temp);
} }
private: private:
typedef std::unordered_map<OUString, list<ScFormulaCell*>, OUStringHash> ModuleCellMap; typedef std::unordered_map<OUString, vector<ScFormulaCell*>, OUStringHash> ModuleCellMap;
ModuleCellMap maCells; ModuleCellMap maCells;
}; };
...@@ -172,16 +173,16 @@ void ScMacroManager::AddDependentCell(const OUString& aModuleName, ScFormulaCell ...@@ -172,16 +173,16 @@ void ScMacroManager::AddDependentCell(const OUString& aModuleName, ScFormulaCell
mpDepTracker->addCell(aModuleName, pCell); mpDepTracker->addCell(aModuleName, pCell);
} }
void ScMacroManager::RemoveDependentCell(ScFormulaCell* pCell) void ScMacroManager::RemoveDependentCell(const ScFormulaCell* pCell)
{ {
mpDepTracker->removeCell(pCell); mpDepTracker->removeCell(pCell);
} }
void ScMacroManager::BroadcastModuleUpdate(const OUString& aModuleName) void ScMacroManager::BroadcastModuleUpdate(const OUString& aModuleName)
{ {
list<ScFormulaCell*> aCells; vector<ScFormulaCell*> aCells;
mpDepTracker->getCellsByModule(aModuleName, aCells); mpDepTracker->getCellsByModule(aModuleName, aCells);
list<ScFormulaCell*>::iterator itr = aCells.begin(), itrEnd = aCells.end(); vector<ScFormulaCell*>::iterator itr = aCells.begin(), itrEnd = aCells.end();
for (; itr != itrEnd; ++itr) for (; itr != itrEnd; ++itr)
{ {
ScFormulaCell* pCell = *itr; ScFormulaCell* pCell = *itr;
......
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