diff options
author | Noel Grandin <noel@peralex.com> | 2012-07-19 16:19:24 +0200 |
---|---|---|
committer | Michael Stahl <mstahl@redhat.com> | 2012-07-26 14:30:10 +0200 |
commit | c10159f3ed4b474736711fc6f15b85454da2669f (patch) | |
tree | ed5decd0b4cc8d750657022b79cd9459ae8880ea /sw | |
parent | 6376dd83fb436f73cb891bc11b502014e66a74da (diff) |
Convert SV_DECL_VARARR_SORT(_SwPamRanges) to o3tl::sorted_vector
Change-Id: I6f3fa6b4940ba17e21e9fc47bcdd61c9761ba477
Diffstat (limited to 'sw')
-rw-r--r-- | sw/inc/edimp.hxx | 14 | ||||
-rw-r--r-- | sw/source/core/edit/ednumber.cxx | 43 |
2 files changed, 29 insertions, 28 deletions
diff --git a/sw/inc/edimp.hxx b/sw/inc/edimp.hxx index 18c21067f14a..915ed9f7d4a4 100644 --- a/sw/inc/edimp.hxx +++ b/sw/inc/edimp.hxx @@ -30,7 +30,7 @@ #define _EDIMP_HXX #include <tools/solar.h> -#include <svl/svarray.hxx> +#include <o3tl/sorted_vector.hxx> class SwPaM; class SwNodeIndex; @@ -56,13 +56,13 @@ struct SwPamRange SwPamRange() : nStart( 0 ), nEnd( 0 ) {} SwPamRange( sal_uLong nS, sal_uLong nE ) : nStart( nS ), nEnd( nE ) {} - sal_Bool operator==( const SwPamRange& rRg ) - { return nStart == rRg.nStart ? sal_True : sal_False; } - sal_Bool operator<( const SwPamRange& rRg ) - { return nStart < rRg.nStart ? sal_True : sal_False; } + bool operator==( const SwPamRange& rRg ) const + { return nStart == rRg.nStart ? true : false; } + bool operator<( const SwPamRange& rRg ) const + { return nStart < rRg.nStart ? true : false; } }; -SV_DECL_VARARR_SORT( _SwPamRanges, SwPamRange, 0 ) +class _SwPamRanges : public o3tl::sorted_vector<SwPamRange> {}; class SwPamRanges : private _SwPamRanges { @@ -73,7 +73,7 @@ public: SwPaM& SetPam( sal_uInt16 nArrPos, SwPaM& rPam ); sal_uInt16 Count() const - { return _SwPamRanges::Count(); } + { return _SwPamRanges::size(); } SwPamRange operator[]( sal_uInt16 nPos ) const { return _SwPamRanges::operator[](nPos); } }; diff --git a/sw/source/core/edit/ednumber.cxx b/sw/source/core/edit/ednumber.cxx index 36a74b0b0361..6be3bcfadd32 100644 --- a/sw/source/core/edit/ednumber.cxx +++ b/sw/source/core/edit/ednumber.cxx @@ -36,8 +36,6 @@ #include <swundo.hxx> #include <numrule.hxx> -SV_IMPL_VARARR_SORT( _SwPamRanges, SwPamRange ) - SwPamRanges::SwPamRanges( const SwPaM& rRing ) { @@ -54,15 +52,16 @@ void SwPamRanges::Insert( const SwNodeIndex& rIdx1, const SwNodeIndex& rIdx2 ) if( aRg.nEnd < aRg.nStart ) { aRg.nStart = aRg.nEnd; aRg.nEnd = rIdx1.GetIndex(); } - sal_uInt16 nPos = 0; - const SwPamRange* pTmp; - if( Count() && Seek_Entry( aRg, &nPos )) // suche Insert Position + _SwPamRanges::iterator it = lower_bound( aRg ); + sal_uInt16 nPos = it - begin(); + if( !empty() && (*it) == aRg) // suche Insert Position { // ist der im Array stehende kleiner ?? - if( ( pTmp = GetData()+ nPos )->nEnd < aRg.nEnd ) + SwPamRange& rTmp = _SwPamRanges::operator[](nPos); + if( rTmp.nEnd < aRg.nEnd ) { - aRg.nEnd = pTmp->nEnd; - Remove( nPos, 1 ); // zusammenfassen + aRg.nEnd = rTmp.nEnd; + erase( begin() + nPos ); // zusammenfassen } else return; // ende, weil schon alle zusammengefasst waren @@ -75,35 +74,37 @@ void SwPamRanges::Insert( const SwNodeIndex& rIdx1, const SwNodeIndex& rIdx2 ) // mit dem Vorgaenger zusammenfassen ?? if( nPos > 0 ) { - if( ( pTmp = GetData()+( nPos-1 ))->nEnd == aRg.nStart - || pTmp->nEnd+1 == aRg.nStart ) + SwPamRange& rTmp = _SwPamRanges::operator[](nPos-1); + if( rTmp.nEnd == aRg.nStart + || rTmp.nEnd+1 == aRg.nStart ) { - aRg.nStart = pTmp->nStart; + aRg.nStart = rTmp.nStart; bEnde = sal_False; - Remove( --nPos, 1 ); // zusammenfassen + erase( begin() + --nPos ); // zusammenfassen } // SSelection im Bereich ?? - else if( pTmp->nStart <= aRg.nStart && aRg.nEnd <= pTmp->nEnd ) + else if( rTmp.nStart <= aRg.nStart && aRg.nEnd <= rTmp.nEnd ) return; } // mit dem Nachfolger zusammenfassen ?? - if( nPos < Count() ) + if( nPos < size() ) { - if( ( pTmp = GetData() + nPos )->nStart == aRg.nEnd || - pTmp->nStart == aRg.nEnd+1 ) + SwPamRange& rTmp = _SwPamRanges::operator[](nPos); + if( rTmp.nStart == aRg.nEnd || + rTmp.nStart == aRg.nEnd+1 ) { - aRg.nEnd = pTmp->nEnd; + aRg.nEnd = rTmp.nEnd; bEnde = sal_False; - Remove( nPos, 1 ); // zusammenfassen + erase( begin() + nPos ); // zusammenfassen } // SSelection im Bereich ?? - else if( pTmp->nStart <= aRg.nStart && aRg.nEnd <= pTmp->nEnd ) + else if( rTmp.nStart <= aRg.nStart && aRg.nEnd <= rTmp.nEnd ) return; } } while( !bEnde ); - _SwPamRanges::Insert( aRg ); + _SwPamRanges::insert( aRg ); } @@ -111,7 +112,7 @@ void SwPamRanges::Insert( const SwNodeIndex& rIdx1, const SwNodeIndex& rIdx2 ) SwPaM& SwPamRanges::SetPam( sal_uInt16 nArrPos, SwPaM& rPam ) { OSL_ASSERT( nArrPos < Count() ); - const SwPamRange& rTmp = *(GetData() + nArrPos ); + const SwPamRange& rTmp = (*this)[ nArrPos ]; rPam.GetPoint()->nNode = rTmp.nStart; rPam.GetPoint()->nContent.Assign( rPam.GetCntntNode(), 0 ); rPam.SetMark(); |