Kaydet (Commit) 63de1888 authored tarafından Michael Stahl's avatar Michael Stahl

svtools: replace boost::ptr_vector with std::vector<std::unique_ptr>

Change-Id: I37cf472e7558ffd7714659436b78851caa187945
üst 1b7ab966
...@@ -26,7 +26,8 @@ ...@@ -26,7 +26,8 @@
#include <svtools/treelistentries.hxx> #include <svtools/treelistentries.hxx>
#include <o3tl/typed_flags_set.hxx> #include <o3tl/typed_flags_set.hxx>
#include <boost/ptr_container/ptr_vector.hpp> #include <vector>
#include <memory>
// flags related to the model // flags related to the model
enum class SvTLEntryFlags enum class SvTLEntryFlags
...@@ -53,13 +54,13 @@ class SVT_DLLPUBLIC SvTreeListEntry ...@@ -53,13 +54,13 @@ class SVT_DLLPUBLIC SvTreeListEntry
friend class SvListView; friend class SvListView;
friend class SvTreeListBox; friend class SvTreeListBox;
typedef boost::ptr_vector<SvLBoxItem> ItemsType; typedef std::vector<std::unique_ptr<SvLBoxItem>> ItemsType;
SvTreeListEntry* pParent; SvTreeListEntry* pParent;
SvTreeListEntries maChildren; SvTreeListEntries maChildren;
sal_uLong nAbsPos; sal_uLong nAbsPos;
sal_uLong nListPos; sal_uLong nListPos;
ItemsType maItems; ItemsType m_Items;
bool bIsMarked; bool bIsMarked;
void* pUserData; void* pUserData;
SvTLEntryFlags nEntryFlags; SvTLEntryFlags nEntryFlags;
......
...@@ -82,7 +82,7 @@ SvTreeListEntry::~SvTreeListEntry() ...@@ -82,7 +82,7 @@ SvTreeListEntry::~SvTreeListEntry()
#endif #endif
maChildren.clear(); maChildren.clear();
maItems.clear(); m_Items.clear();
} }
bool SvTreeListEntry::HasChildren() const bool SvTreeListEntry::HasChildren() const
...@@ -112,14 +112,13 @@ void SvTreeListEntry::Clone(SvTreeListEntry* pSource) ...@@ -112,14 +112,13 @@ void SvTreeListEntry::Clone(SvTreeListEntry* pSource)
nListPos |= ( pSource->nListPos & 0x7fffffff); nListPos |= ( pSource->nListPos & 0x7fffffff);
nAbsPos = pSource->nAbsPos; nAbsPos = pSource->nAbsPos;
maItems.clear(); m_Items.clear();
ItemsType::iterator it = pSource->maItems.begin(), itEnd = pSource->maItems.end(); for (auto const& it : pSource->m_Items)
for (; it != itEnd; ++it)
{ {
SvLBoxItem* pItem = &(*it); SvLBoxItem* pItem = &(*it);
SvLBoxItem* pNewItem = pItem->Create(); std::unique_ptr<SvLBoxItem> pNewItem(pItem->Create());
pNewItem->Clone(pItem); pNewItem->Clone(pItem);
maItems.push_back(pNewItem); m_Items.push_back(std::move(pNewItem));
} }
pUserData = pSource->GetUserData(); pUserData = pSource->GetUserData();
...@@ -128,12 +127,12 @@ void SvTreeListEntry::Clone(SvTreeListEntry* pSource) ...@@ -128,12 +127,12 @@ void SvTreeListEntry::Clone(SvTreeListEntry* pSource)
size_t SvTreeListEntry::ItemCount() const size_t SvTreeListEntry::ItemCount() const
{ {
return maItems.size(); return m_Items.size();
} }
void SvTreeListEntry::AddItem( SvLBoxItem* pItem ) void SvTreeListEntry::AddItem( SvLBoxItem* pItem )
{ {
maItems.push_back( pItem ); m_Items.push_back(std::unique_ptr<SvLBoxItem>(pItem));
} }
void SvTreeListEntry::EnableChildrenOnDemand( bool bEnable ) void SvTreeListEntry::EnableChildrenOnDemand( bool bEnable )
...@@ -147,25 +146,25 @@ void SvTreeListEntry::EnableChildrenOnDemand( bool bEnable ) ...@@ -147,25 +146,25 @@ void SvTreeListEntry::EnableChildrenOnDemand( bool bEnable )
void SvTreeListEntry::ReplaceItem( SvLBoxItem* pNewItem, size_t nPos ) void SvTreeListEntry::ReplaceItem( SvLBoxItem* pNewItem, size_t nPos )
{ {
DBG_ASSERT(pNewItem,"ReplaceItem:No Item"); DBG_ASSERT(pNewItem,"ReplaceItem:No Item");
if (nPos >= maItems.size()) if (nPos >= m_Items.size())
{ {
// Out of bound. Bail out. // Out of bound. Bail out.
delete pNewItem; delete pNewItem;
return; return;
} }
maItems.erase(maItems.begin()+nPos); m_Items.erase(m_Items.begin()+nPos);
maItems.insert(maItems.begin()+nPos, pNewItem); m_Items.insert(m_Items.begin()+nPos, std::unique_ptr<SvLBoxItem>(pNewItem));
} }
const SvLBoxItem& SvTreeListEntry::GetItem( size_t nPos ) const const SvLBoxItem& SvTreeListEntry::GetItem( size_t nPos ) const
{ {
return maItems[nPos]; return *m_Items[nPos];
} }
SvLBoxItem& SvTreeListEntry::GetItem( size_t nPos ) SvLBoxItem& SvTreeListEntry::GetItem( size_t nPos )
{ {
return maItems[nPos]; return *m_Items[nPos];
} }
namespace { namespace {
...@@ -175,9 +174,9 @@ class FindByType : std::unary_function<SvLBoxItem, void> ...@@ -175,9 +174,9 @@ class FindByType : std::unary_function<SvLBoxItem, void>
sal_uInt16 mnId; sal_uInt16 mnId;
public: public:
explicit FindByType(sal_uInt16 nId) : mnId(nId) {} explicit FindByType(sal_uInt16 nId) : mnId(nId) {}
bool operator() (const SvLBoxItem& rItem) const bool operator() (const std::unique_ptr<SvLBoxItem>& rpItem) const
{ {
return rItem.GetType() == mnId; return rpItem->GetType() == mnId;
} }
}; };
...@@ -186,9 +185,9 @@ class FindByPointer : std::unary_function<SvLBoxItem, void> ...@@ -186,9 +185,9 @@ class FindByPointer : std::unary_function<SvLBoxItem, void>
const SvLBoxItem* mpItem; const SvLBoxItem* mpItem;
public: public:
explicit FindByPointer(const SvLBoxItem* p) : mpItem(p) {} explicit FindByPointer(const SvLBoxItem* p) : mpItem(p) {}
bool operator() (const SvLBoxItem& rItem) const bool operator() (const std::unique_ptr<SvLBoxItem>& rpItem) const
{ {
return &rItem == mpItem; return rpItem.get() == mpItem;
} }
}; };
...@@ -196,20 +195,20 @@ public: ...@@ -196,20 +195,20 @@ public:
const SvLBoxItem* SvTreeListEntry::GetFirstItem( sal_uInt16 nId ) const const SvLBoxItem* SvTreeListEntry::GetFirstItem( sal_uInt16 nId ) const
{ {
ItemsType::const_iterator it = std::find_if(maItems.begin(), maItems.end(), FindByType(nId)); ItemsType::const_iterator it = std::find_if(m_Items.begin(), m_Items.end(), FindByType(nId));
return it == maItems.end() ? NULL : &(*it); return (it == m_Items.end()) ? nullptr : (*it).get();
} }
SvLBoxItem* SvTreeListEntry::GetFirstItem( sal_uInt16 nId ) SvLBoxItem* SvTreeListEntry::GetFirstItem( sal_uInt16 nId )
{ {
ItemsType::iterator it = std::find_if(maItems.begin(), maItems.end(), FindByType(nId)); ItemsType::iterator it = std::find_if(m_Items.begin(), m_Items.end(), FindByType(nId));
return it == maItems.end() ? NULL : &(*it); return (it == m_Items.end()) ? nullptr : (*it).get();
} }
size_t SvTreeListEntry::GetPos( const SvLBoxItem* pItem ) const size_t SvTreeListEntry::GetPos( const SvLBoxItem* pItem ) const
{ {
ItemsType::const_iterator it = std::find_if(maItems.begin(), maItems.end(), FindByPointer(pItem)); ItemsType::const_iterator it = std::find_if(m_Items.begin(), m_Items.end(), FindByPointer(pItem));
return it == maItems.end() ? ITEM_NOT_FOUND : std::distance(maItems.begin(), it); return it == m_Items.end() ? ITEM_NOT_FOUND : std::distance(m_Items.begin(), it);
} }
......
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