summaryrefslogtreecommitdiff
path: root/vcl/source/edit/textdoc.cxx
diff options
context:
space:
mode:
authorNoel Grandin <noel@peralex.com>2015-11-11 14:36:01 +0200
committerNoel Grandin <noel@peralex.com>2015-11-12 08:01:35 +0200
commite2d92d641b81d4c0698e442ddb2a4fd4f37c3621 (patch)
tree7e2ee4f743bfde2a7b11ac7df76d231427245fc0 /vcl/source/edit/textdoc.cxx
parent6cc4118a1014acad34f29901eebc1be7a9208112 (diff)
vcl: boost::ptr_vector->std::vector
Change-Id: Ib75e4dffb35032f273b9482341a438ccb9b00397
Diffstat (limited to 'vcl/source/edit/textdoc.cxx')
-rw-r--r--vcl/source/edit/textdoc.cxx44
1 files changed, 23 insertions, 21 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;
}