Kaydet (Commit) 14a0115b authored tarafından Michael Stahl's avatar Michael Stahl

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

Change-Id: I311d3a3e35ae4321e92e1fe2e0651b3b4899c0bd
üst 27f5679c
...@@ -59,7 +59,9 @@ ...@@ -59,7 +59,9 @@
#include "zforauto.hxx" #include "zforauto.hxx"
#include <boost/noncopyable.hpp> #include <boost/noncopyable.hpp>
#include <boost/ptr_container/ptr_map.hpp>
#include <memory>
#include <map>
/** /**
A binary blob of writer-specific data. This data typically consists of types that are A binary blob of writer-specific data. This data typically consists of types that are
...@@ -313,8 +315,8 @@ struct DefaultFirstEntry { ...@@ -313,8 +315,8 @@ struct DefaultFirstEntry {
class SC_DLLPUBLIC ScAutoFormat class SC_DLLPUBLIC ScAutoFormat
{ {
typedef boost::ptr_map<OUString, ScAutoFormatData, DefaultFirstEntry> MapType; typedef std::map<OUString, std::unique_ptr<ScAutoFormatData>, DefaultFirstEntry> MapType;
MapType maData; MapType m_Data;
bool mbSaveLater; bool mbSaveLater;
ScAfVersions m_aVersions; ScAfVersions m_aVersions;
......
...@@ -31,6 +31,7 @@ ...@@ -31,6 +31,7 @@
#include <tools/urlobj.hxx> #include <tools/urlobj.hxx>
#include <unotools/transliterationwrapper.hxx> #include <unotools/transliterationwrapper.hxx>
#include <tools/tenccvt.hxx> #include <tools/tenccvt.hxx>
#include <o3tl/make_unique.hxx>
#include "globstr.hrc" #include "globstr.hrc"
#include "document.hxx" #include "document.hxx"
...@@ -906,9 +907,14 @@ bool DefaultFirstEntry::operator() (const OUString& left, const OUString& right) ...@@ -906,9 +907,14 @@ bool DefaultFirstEntry::operator() (const OUString& left, const OUString& right)
return ScGlobal::GetCollator()->compareString( left, right) < 0; return ScGlobal::GetCollator()->compareString( left, right) < 0;
} }
ScAutoFormat::ScAutoFormat(const ScAutoFormat& r) : ScAutoFormat::ScAutoFormat(const ScAutoFormat& r)
maData(r.maData), : mbSaveLater(false)
mbSaveLater(false) {} {
for (auto const& it : r.m_Data)
{
m_Data.insert(std::make_pair(it.first, o3tl::make_unique<ScAutoFormatData>(*it.second)));
}
}
ScAutoFormat::~ScAutoFormat() ScAutoFormat::~ScAutoFormat()
{ {
...@@ -926,30 +932,30 @@ void ScAutoFormat::SetSaveLater( bool bSet ) ...@@ -926,30 +932,30 @@ void ScAutoFormat::SetSaveLater( bool bSet )
const ScAutoFormatData* ScAutoFormat::findByIndex(size_t nIndex) const const ScAutoFormatData* ScAutoFormat::findByIndex(size_t nIndex) const
{ {
if (nIndex >= maData.size()) if (nIndex >= m_Data.size())
return nullptr; return nullptr;
MapType::const_iterator it = maData.begin(); MapType::const_iterator it = m_Data.begin();
std::advance(it, nIndex); std::advance(it, nIndex);
return it->second; return it->second.get();
} }
ScAutoFormatData* ScAutoFormat::findByIndex(size_t nIndex) ScAutoFormatData* ScAutoFormat::findByIndex(size_t nIndex)
{ {
if (nIndex >= maData.size()) if (nIndex >= m_Data.size())
return nullptr; return nullptr;
MapType::iterator it = maData.begin(); MapType::iterator it = m_Data.begin();
std::advance(it, nIndex); std::advance(it, nIndex);
return it->second; return it->second.get();
} }
ScAutoFormat::iterator ScAutoFormat::find(const ScAutoFormatData* pData) ScAutoFormat::iterator ScAutoFormat::find(const ScAutoFormatData* pData)
{ {
MapType::iterator it = maData.begin(), itEnd = maData.end(); MapType::iterator it = m_Data.begin(), itEnd = m_Data.end();
for (; it != itEnd; ++it) for (; it != itEnd; ++it)
{ {
if (it->second == pData) if (it->second.get() == pData)
return it; return it;
} }
return itEnd; return itEnd;
...@@ -957,43 +963,43 @@ ScAutoFormat::iterator ScAutoFormat::find(const ScAutoFormatData* pData) ...@@ -957,43 +963,43 @@ ScAutoFormat::iterator ScAutoFormat::find(const ScAutoFormatData* pData)
ScAutoFormat::iterator ScAutoFormat::find(const OUString& rName) ScAutoFormat::iterator ScAutoFormat::find(const OUString& rName)
{ {
return maData.find(rName); return m_Data.find(rName);
} }
bool ScAutoFormat::insert(ScAutoFormatData* pNew) bool ScAutoFormat::insert(ScAutoFormatData* pNew)
{ {
OUString aName = pNew->GetName(); OUString aName = pNew->GetName();
return maData.insert(aName, pNew).second; return m_Data.insert(std::make_pair(aName, std::unique_ptr<ScAutoFormatData>(pNew))).second;
} }
void ScAutoFormat::erase(const iterator& it) void ScAutoFormat::erase(const iterator& it)
{ {
maData.erase(it); m_Data.erase(it);
} }
size_t ScAutoFormat::size() const size_t ScAutoFormat::size() const
{ {
return maData.size(); return m_Data.size();
} }
ScAutoFormat::const_iterator ScAutoFormat::begin() const ScAutoFormat::const_iterator ScAutoFormat::begin() const
{ {
return maData.begin(); return m_Data.begin();
} }
ScAutoFormat::const_iterator ScAutoFormat::end() const ScAutoFormat::const_iterator ScAutoFormat::end() const
{ {
return maData.end(); return m_Data.end();
} }
ScAutoFormat::iterator ScAutoFormat::begin() ScAutoFormat::iterator ScAutoFormat::begin()
{ {
return maData.begin(); return m_Data.begin();
} }
ScAutoFormat::iterator ScAutoFormat::end() ScAutoFormat::iterator ScAutoFormat::end()
{ {
return maData.end(); return m_Data.end();
} }
bool ScAutoFormat::Load() bool ScAutoFormat::Load()
...@@ -1084,9 +1090,9 @@ bool ScAutoFormat::Save() ...@@ -1084,9 +1090,9 @@ bool ScAutoFormat::Save()
bRet &= (rStream.GetError() == 0); bRet &= (rStream.GetError() == 0);
rStream.WriteUInt16( maData.size() - 1 ); rStream.WriteUInt16( m_Data.size() - 1 );
bRet &= (rStream.GetError() == 0); bRet &= (rStream.GetError() == 0);
MapType::iterator it = maData.begin(), itEnd = maData.end(); MapType::iterator it = m_Data.begin(), itEnd = m_Data.end();
if (it != itEnd) if (it != itEnd)
{ {
for (++it; bRet && it != itEnd; ++it) // Skip the first item. for (++it; bRet && it != itEnd; ++it) // Skip the first item.
......
...@@ -84,7 +84,7 @@ ScAutoFormatDlg::ScAutoFormatDlg(vcl::Window* pParent, ...@@ -84,7 +84,7 @@ ScAutoFormatDlg::ScAutoFormatDlg(vcl::Window* pParent,
Init(); Init();
ScAutoFormat::iterator it = pFormat->begin(); ScAutoFormat::iterator it = pFormat->begin();
m_pWndPreview->NotifyChange(it->second); m_pWndPreview->NotifyChange(it->second.get());
} }
ScAutoFormatDlg::~ScAutoFormatDlg() ScAutoFormatDlg::~ScAutoFormatDlg()
......
...@@ -149,7 +149,7 @@ static bool lcl_FindAutoFormatIndex( const ScAutoFormat& rFormats, const OUStrin ...@@ -149,7 +149,7 @@ static bool lcl_FindAutoFormatIndex( const ScAutoFormat& rFormats, const OUStrin
ScAutoFormat::const_iterator itBeg = rFormats.begin(), itEnd = rFormats.end(); ScAutoFormat::const_iterator itBeg = rFormats.begin(), itEnd = rFormats.end();
for (ScAutoFormat::const_iterator it = itBeg; it != itEnd; ++it) for (ScAutoFormat::const_iterator it = itBeg; it != itEnd; ++it)
{ {
const ScAutoFormatData* pEntry = it->second; const ScAutoFormatData *const pEntry = it->second.get();
const OUString& aEntryName = pEntry->GetName(); const OUString& aEntryName = pEntry->GetName();
if ( aEntryName.equals(rName) ) if ( aEntryName.equals(rName) )
{ {
...@@ -513,7 +513,7 @@ void SAL_CALL ScAutoFormatObj::setName( const OUString& aNewName ) ...@@ -513,7 +513,7 @@ void SAL_CALL ScAutoFormatObj::setName( const OUString& aNewName )
{ {
ScAutoFormat::iterator it = pFormats->begin(); ScAutoFormat::iterator it = pFormats->begin();
std::advance(it, nFormatIndex); std::advance(it, nFormatIndex);
ScAutoFormatData* pData = it->second; ScAutoFormatData *const pData = it->second.get();
OSL_ENSURE(pData,"AutoFormat Daten nicht da"); OSL_ENSURE(pData,"AutoFormat Daten nicht da");
ScAutoFormatData* pNew = new ScAutoFormatData(*pData); ScAutoFormatData* pNew = new ScAutoFormatData(*pData);
......
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