Kaydet (Commit) b56614c6 authored tarafından Matteo Casalin's avatar Matteo Casalin

Simplify loops and reduce scope of some variables

Change-Id: I55f0044606a75e79d51dd40976f1492ec797b531
üst 2aab43b2
...@@ -1286,20 +1286,20 @@ void SwRangeRedline::DelCopyOfSection(size_t nMyPos) ...@@ -1286,20 +1286,20 @@ void SwRangeRedline::DelCopyOfSection(size_t nMyPos)
const SwRedlineTbl& rTbl = pDoc->getIDocumentRedlineAccess().GetRedlineTbl(); const SwRedlineTbl& rTbl = pDoc->getIDocumentRedlineAccess().GetRedlineTbl();
sal_uInt16 n = nMyPos; sal_uInt16 n = nMyPos;
OSL_ENSURE( n != USHRT_MAX, "How strange. We don't exist!" ); OSL_ENSURE( n != USHRT_MAX, "How strange. We don't exist!" );
for( bool bBreak = false; !bBreak && n > 0; ) while ( n > 0 )
{ {
--n; --n;
bBreak = true;
if( rTbl[ n ]->GetBound(true) == *aPam.GetPoint() ) if( rTbl[ n ]->GetBound(true) == *aPam.GetPoint() )
{ {
rTbl[ n ]->GetBound(true) = *pEnd; rTbl[ n ]->GetBound(true) = *pEnd;
bBreak = false; continue;
} }
if( rTbl[ n ]->GetBound(false) == *aPam.GetPoint() ) if( rTbl[ n ]->GetBound(false) == *aPam.GetPoint() )
{ {
rTbl[ n ]->GetBound(false) = *pEnd; rTbl[ n ]->GetBound(false) = *pEnd;
bBreak = false; continue;
} }
break;
} }
SwPosition aEnd( *pEnd ); SwPosition aEnd( *pEnd );
...@@ -1333,41 +1333,39 @@ void SwRangeRedline::MoveFromSection(size_t nMyPos) ...@@ -1333,41 +1333,39 @@ void SwRangeRedline::MoveFromSection(size_t nMyPos)
const SwRedlineTbl& rTbl = pDoc->getIDocumentRedlineAccess().GetRedlineTbl(); const SwRedlineTbl& rTbl = pDoc->getIDocumentRedlineAccess().GetRedlineTbl();
std::vector<SwPosition*> aBeforeArr, aBehindArr; std::vector<SwPosition*> aBeforeArr, aBehindArr;
OSL_ENSURE( this, "this is not in the array?" ); OSL_ENSURE( this, "this is not in the array?" );
bool bBreak = false;
SwRedlineTbl::size_type n;
for( n = nMyPos+1; !bBreak && n < rTbl.size(); ++n ) for( SwRedlineTbl::size_type n = nMyPos+1; n < rTbl.size(); ++n )
{ {
bBreak = true;
if( rTbl[ n ]->GetBound(true) == *GetPoint() ) if( rTbl[ n ]->GetBound(true) == *GetPoint() )
{ {
SwRangeRedline* pRedl = rTbl[n]; SwRangeRedline* pRedl = rTbl[n];
aBehindArr.push_back(&pRedl->GetBound(true)); aBehindArr.push_back(&pRedl->GetBound(true));
bBreak = false; continue;
} }
if( rTbl[ n ]->GetBound(false) == *GetPoint() ) if( rTbl[ n ]->GetBound(false) == *GetPoint() )
{ {
SwRangeRedline* pRedl = rTbl[n]; SwRangeRedline* pRedl = rTbl[n];
aBehindArr.push_back(&pRedl->GetBound(false)); aBehindArr.push_back(&pRedl->GetBound(false));
bBreak = false; continue;
} }
break;
} }
for( bBreak = false, n = nMyPos; !bBreak && n ; ) for( SwRedlineTbl::size_type n = nMyPos; n ; )
{ {
--n; --n;
bBreak = true;
if( rTbl[ n ]->GetBound(true) == *GetPoint() ) if( rTbl[ n ]->GetBound(true) == *GetPoint() )
{ {
SwRangeRedline* pRedl = rTbl[n]; SwRangeRedline* pRedl = rTbl[n];
aBeforeArr.push_back(&pRedl->GetBound(true)); aBeforeArr.push_back(&pRedl->GetBound(true));
bBreak = false; continue;
} }
if( rTbl[ n ]->GetBound(false) == *GetPoint() ) if( rTbl[ n ]->GetBound(false) == *GetPoint() )
{ {
SwRangeRedline* pRedl = rTbl[n]; SwRangeRedline* pRedl = rTbl[n];
aBeforeArr.push_back(&pRedl->GetBound(false)); aBeforeArr.push_back(&pRedl->GetBound(false));
bBreak = false; continue;
} }
break;
} }
const SwNode* pKeptCntntSectNode( &pCntntSect->GetNode() ); // #i95711# const SwNode* pKeptCntntSectNode( &pCntntSect->GetNode() ); // #i95711#
...@@ -1436,10 +1434,10 @@ void SwRangeRedline::MoveFromSection(size_t nMyPos) ...@@ -1436,10 +1434,10 @@ void SwRangeRedline::MoveFromSection(size_t nMyPos)
// adjustment of redline table positions must take start and // adjustment of redline table positions must take start and
// end into account, not point and mark. // end into account, not point and mark.
for( n = 0; n < aBeforeArr.size(); ++n ) for( auto& pItem : aBeforeArr )
*aBeforeArr[ n ] = *Start(); *pItem = *Start();
for( n = 0; n < aBehindArr.size(); ++n ) for( auto& pItem : aBehindArr )
*aBehindArr[ n ] = *End(); *pItem = *End();
} }
else else
InvalidateRange(); InvalidateRange();
......
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