diff options
author | Noel Grandin <noel@peralex.com> | 2015-11-11 14:36:01 +0200 |
---|---|---|
committer | Noel Grandin <noel@peralex.com> | 2015-11-12 08:01:35 +0200 |
commit | e2d92d641b81d4c0698e442ddb2a4fd4f37c3621 (patch) | |
tree | 7e2ee4f743bfde2a7b11ac7df76d231427245fc0 /vcl/source/edit | |
parent | 6cc4118a1014acad34f29901eebc1be7a9208112 (diff) |
vcl: boost::ptr_vector->std::vector
Change-Id: Ib75e4dffb35032f273b9482341a438ccb9b00397
Diffstat (limited to 'vcl/source/edit')
-rw-r--r-- | vcl/source/edit/textdoc.cxx | 44 | ||||
-rw-r--r-- | vcl/source/edit/textdoc.hxx | 11 |
2 files changed, 29 insertions, 26 deletions
diff --git a/vcl/source/edit/textdoc.cxx b/vcl/source/edit/textdoc.cxx index f90331090b30..9c7eb49450c7 100644 --- a/vcl/source/edit/textdoc.cxx +++ b/vcl/source/edit/textdoc.cxx @@ -19,13 +19,12 @@ #include <textdoc.hxx> #include <stdlib.h> -#include <boost/mem_fn.hpp> #include <osl/diagnose.h> // compare function called by QuickSort -static bool CompareStart( const TextCharAttrib& pFirst, const TextCharAttrib& pSecond ) +static bool CompareStart( const std::unique_ptr<TextCharAttrib>& pFirst, const std::unique_ptr<TextCharAttrib>& pSecond ) { - return pFirst.GetStart() < pSecond.GetStart(); + return pFirst->GetStart() < pSecond->GetStart(); } TextCharAttrib::TextCharAttrib( const TextAttrib& rAttr, sal_Int32 nStart, sal_Int32 nEnd ) @@ -71,31 +70,31 @@ void TextCharAttribList::InsertAttrib( TextCharAttrib* pAttrib ) bool bInserted = false; for (TextCharAttribs::iterator it = maAttribs.begin(); it != maAttribs.end(); ++it) { - if ( it->GetStart() > nStart ) + if ( (*it)->GetStart() > nStart ) { - maAttribs.insert( it, pAttrib ); + maAttribs.insert( it, std::unique_ptr<TextCharAttrib>(pAttrib) ); bInserted = true; break; } } if ( !bInserted ) - maAttribs.push_back( pAttrib ); + maAttribs.push_back( std::unique_ptr<TextCharAttrib>(pAttrib) ); } void TextCharAttribList::ResortAttribs() { - maAttribs.sort(CompareStart); + std::sort( maAttribs.begin(), maAttribs.end(), CompareStart ); } TextCharAttrib* TextCharAttribList::FindAttrib( sal_uInt16 nWhich, sal_Int32 nPos ) { for (TextCharAttribs::reverse_iterator it = maAttribs.rbegin(); it != maAttribs.rend(); ++it) { - if ( it->GetEnd() < nPos ) + if ( (*it)->GetEnd() < nPos ) return nullptr; - if ( ( it->Which() == nWhich ) && it->IsIn(nPos) ) - return &*it; + if ( ( (*it)->Which() == nWhich ) && (*it)->IsIn(nPos) ) + return it->get(); } return nullptr; } @@ -105,10 +104,10 @@ const TextCharAttrib* TextCharAttribList::FindNextAttrib( sal_uInt16 nWhich, sal DBG_ASSERT( nWhich, "FindNextAttrib: Which?" ); for (TextCharAttribs::const_iterator it = maAttribs.begin(); it != maAttribs.end(); ++it) { - if ( ( it->GetStart() >= nFromPos ) && - ( it->GetEnd() <= nMaxPos ) && - ( it->Which() == nWhich ) ) - return &*it; + if ( ( (*it)->GetStart() >= nFromPos ) && + ( (*it)->GetEnd() <= nMaxPos ) && + ( (*it)->Which() == nWhich ) ) + return it->get(); } return nullptr; } @@ -117,7 +116,7 @@ bool TextCharAttribList::HasAttrib( sal_uInt16 nWhich ) const { for (TextCharAttribs::const_reverse_iterator it = maAttribs.rbegin(); it != maAttribs.rend(); ++it) { - if ( it->Which() == nWhich ) + if ( (*it)->Which() == nWhich ) return true; } return false; @@ -127,10 +126,10 @@ bool TextCharAttribList::HasBoundingAttrib( sal_Int32 nBound ) { for (TextCharAttribs::reverse_iterator it = maAttribs.rbegin(); it != maAttribs.rend(); ++it) { - if ( it->GetEnd() < nBound ) + if ( (*it)->GetEnd() < nBound ) return false; - if ( ( it->GetStart() == nBound ) || ( it->GetEnd() == nBound ) ) + if ( ( (*it)->GetStart() == nBound ) || ( (*it)->GetEnd() == nBound ) ) return true; } return false; @@ -143,18 +142,21 @@ TextCharAttrib* TextCharAttribList::FindEmptyAttrib( sal_uInt16 nWhich, sal_Int3 for (TextCharAttribs::iterator it = maAttribs.begin(); it != maAttribs.end(); ++it) { - if ( it->GetStart() > nPos ) + if ( (*it)->GetStart() > nPos ) return nullptr; - if ( ( it->GetStart() == nPos ) && ( it->GetEnd() == nPos ) && ( it->Which() == nWhich ) ) - return &*it; + if ( ( (*it)->GetStart() == nPos ) && ( (*it)->GetEnd() == nPos ) && ( (*it)->Which() == nWhich ) ) + return it->get(); } return nullptr; } void TextCharAttribList::DeleteEmptyAttribs() { - maAttribs.erase_if(boost::mem_fn(&TextCharAttrib::IsEmpty)); + maAttribs.erase( + std::remove_if( maAttribs.begin(), maAttribs.end(), + [] (const std::unique_ptr<TextCharAttrib>& rAttrib) { return rAttrib->IsEmpty(); } ), + maAttribs.end() ); mbHasEmptyAttribs = false; } diff --git a/vcl/source/edit/textdoc.hxx b/vcl/source/edit/textdoc.hxx index f332f8bb0f59..cf5f62e038cf 100644 --- a/vcl/source/edit/textdoc.hxx +++ b/vcl/source/edit/textdoc.hxx @@ -23,7 +23,8 @@ #include <rtl/ustring.hxx> #include <vcl/textdata.hxx> #include <vcl/txtattr.hxx> -#include <boost/ptr_container/ptr_vector.hpp> +#include <vector> +#include <memory> class TextCharAttribList { @@ -31,7 +32,7 @@ private: TextCharAttribList(const TextCharAttribList&) = delete; TextCharAttribList& operator=(const TextCharAttribList&) = delete; - typedef boost::ptr_vector<TextCharAttrib> TextCharAttribs; + typedef std::vector<std::unique_ptr<TextCharAttrib> > TextCharAttribs; TextCharAttribs maAttribs; bool mbHasEmptyAttribs; @@ -42,9 +43,9 @@ public: void Clear(); sal_uInt16 Count() const { return maAttribs.size(); } - const TextCharAttrib& GetAttrib( sal_uInt16 n ) const { return maAttribs[n]; } - TextCharAttrib& GetAttrib( sal_uInt16 n ) { return maAttribs[n]; } - void RemoveAttrib( sal_uInt16 n ) { maAttribs.release( maAttribs.begin() + n ).release(); } + const TextCharAttrib& GetAttrib( sal_uInt16 n ) const { return *maAttribs[n].get(); } + TextCharAttrib& GetAttrib( sal_uInt16 n ) { return *maAttribs[n].get(); } + void RemoveAttrib( sal_uInt16 n ) { maAttribs[n].release(); maAttribs.erase( maAttribs.begin() + n ); } void InsertAttrib( TextCharAttrib* pAttrib ); |