diff options
author | Luboš Luňák <l.lunak@collabora.com> | 2014-04-28 18:03:49 +0200 |
---|---|---|
committer | Luboš Luňák <l.lunak@collabora.com> | 2014-04-28 19:20:21 +0200 |
commit | 160e93607f6c2c3981823b30ee981ca23d4e1a0d (patch) | |
tree | b717f91011ba9bc9aca7e8a56080989e9ed06b79 /sw | |
parent | f60d4c758ab94bfb55990ca0975de91e22f8265b (diff) |
move function searching for a readline directly to SwRedlineTbl
It's more fun to roll one's own lcl_ function hidden somewhere, huh?
Change-Id: I8cad6ff7e829a58c68098bff23bd48343c3e5b6a
Diffstat (limited to 'sw')
-rw-r--r-- | sw/inc/docary.hxx | 9 | ||||
-rw-r--r-- | sw/source/core/doc/docredln.cxx | 66 |
2 files changed, 42 insertions, 33 deletions
diff --git a/sw/inc/docary.hxx b/sw/inc/docary.hxx index 3269eb0dd94d..120606a550cd 100644 --- a/sw/inc/docary.hxx +++ b/sw/inc/docary.hxx @@ -182,6 +182,15 @@ public: sal_uInt16 FindPrevSeqNo( sal_uInt16 nSeqNo, sal_uInt16 nSttPos, sal_uInt16 nLookahead = 20 ) const; + /** + Find the redline at the given position. + + @param tableIndex position in SwRedlineTbl to start searching at, will be updated with the index of the returned + redline (or the next redline after the given position if not found) + @param next true: redline starts at position and ends after, false: redline starts before position and ends at or after + */ + const SwRangeRedline* FindAtPosition( const SwPosition& startPosition, sal_uInt16& tableIndex, bool next = true ) const; + using _SwRedlineTbl::size; using _SwRedlineTbl::operator[]; using _SwRedlineTbl::empty; diff --git a/sw/source/core/doc/docredln.cxx b/sw/source/core/doc/docredln.cxx index 8dcf9ee64300..5b4583837245 100644 --- a/sw/source/core/doc/docredln.cxx +++ b/sw/source/core/doc/docredln.cxx @@ -2115,35 +2115,6 @@ static sal_Bool lcl_RejectRedline( SwRedlineTbl& rArr, sal_uInt16& rPos, return bRet; } -static const SwRangeRedline* lcl_FindCurrRedline( const SwPosition& rSttPos, - sal_uInt16& rPos, - bool bNext = true ) -{ - const SwRangeRedline* pFnd = 0; - const SwRedlineTbl& rArr = rSttPos.nNode.GetNode().GetDoc()->GetRedlineTbl(); - for( ; rPos < rArr.size() ; ++rPos ) - { - const SwRangeRedline* pTmp = rArr[ rPos ]; - if( pTmp->HasMark() && pTmp->IsVisible() ) - { - const SwPosition* pRStt = pTmp->Start(), - * pREnd = pRStt == pTmp->GetPoint() ? pTmp->GetMark() - : pTmp->GetPoint(); - if( bNext ? *pRStt <= rSttPos : *pRStt < rSttPos ) - { - if( bNext ? *pREnd > rSttPos : *pREnd >= rSttPos ) - { - pFnd = pTmp; - break; - } - } - else - break; - } - } - return pFnd; -} - static int lcl_AcceptRejectRedl( Fn_AcceptReject fn_AcceptReject, SwRedlineTbl& rArr, sal_Bool bCallDelete, const SwPaM& rPam) @@ -2154,7 +2125,7 @@ static int lcl_AcceptRejectRedl( Fn_AcceptReject fn_AcceptReject, const SwPosition* pStt = rPam.Start(), * pEnd = pStt == rPam.GetPoint() ? rPam.GetMark() : rPam.GetPoint(); - const SwRangeRedline* pFnd = lcl_FindCurrRedline( *pStt, n, true ); + const SwRangeRedline* pFnd = rArr.FindAtPosition( *pStt, n, true ); if( pFnd && // Is new a part of it? ( *pFnd->Start() != *pStt || *pFnd->End() > *pEnd )) { @@ -2466,7 +2437,7 @@ const SwRangeRedline* SwDoc::SelNextRedline( SwPaM& rPam ) const // If the starting position points to the last valid ContentNode, // we take the next Redline in any case. sal_uInt16 n = 0; - const SwRangeRedline* pFnd = lcl_FindCurrRedline( rSttPos, n, true ); + const SwRangeRedline* pFnd = GetRedlineTbl().FindAtPosition( rSttPos, n, true ); if( pFnd ) { const SwPosition* pEnd = pFnd->End(); @@ -2585,7 +2556,7 @@ const SwRangeRedline* SwDoc::SelPrevRedline( SwPaM& rPam ) const // If the starting position points to the last valid ContentNode, // we take the previous Redline in any case. sal_uInt16 n = 0; - const SwRangeRedline* pFnd = lcl_FindCurrRedline( rSttPos, n, false ); + const SwRangeRedline* pFnd = GetRedlineTbl().FindAtPosition( rSttPos, n, false ); if( pFnd ) { const SwPosition* pStt = pFnd->Start(); @@ -2702,7 +2673,7 @@ bool SwDoc::SetRedlineComment( const SwPaM& rPaM, const OUString& rS ) * pEnd = pStt == rPaM.GetPoint() ? rPaM.GetMark() : rPaM.GetPoint(); sal_uInt16 n = 0; - if( lcl_FindCurrRedline( *pStt, n, true ) ) + if( GetRedlineTbl().FindAtPosition( *pStt, n, true ) ) { for( ; n < mpRedlineTbl->size(); ++n ) { @@ -3042,6 +3013,35 @@ sal_uInt16 SwRedlineTbl::FindPrevSeqNo( sal_uInt16 nSeqNo, sal_uInt16 nSttPos, return nRet; } +const SwRangeRedline* SwRedlineTbl::FindAtPosition( const SwPosition& rSttPos, + sal_uInt16& rPos, + bool bNext ) const +{ + const SwRangeRedline* pFnd = 0; + for( ; rPos < size() ; ++rPos ) + { + const SwRangeRedline* pTmp = (*this)[ rPos ]; + if( pTmp->HasMark() && pTmp->IsVisible() ) + { + const SwPosition* pRStt = pTmp->Start(), + * pREnd = pRStt == pTmp->GetPoint() ? pTmp->GetMark() + : pTmp->GetPoint(); + if( bNext ? *pRStt <= rSttPos : *pRStt < rSttPos ) + { + if( bNext ? *pREnd > rSttPos : *pREnd >= rSttPos ) + { + pFnd = pTmp; + break; + } + } + else + break; + } + } + return pFnd; +} + + SwRedlineExtraData::~SwRedlineExtraData() { } |