From f367924f17f43448e7077e524145229549005ee2 Mon Sep 17 00:00:00 2001 From: Bjoern Michaelsen Date: Wed, 3 Dec 2014 18:10:53 +0100 Subject: use C++11 iteration and simplify cast Change-Id: I3de5f37adfa0d3d46d9cbc1ce74205750357c481 --- sw/source/core/layout/layact.cxx | 57 ++++++++++++++++++++-------------------- 1 file changed, 28 insertions(+), 29 deletions(-) (limited to 'sw') diff --git a/sw/source/core/layout/layact.cxx b/sw/source/core/layout/layact.cxx index 137b42948a06..d830ed70f126 100644 --- a/sw/source/core/layout/layact.cxx +++ b/sw/source/core/layout/layact.cxx @@ -2172,88 +2172,87 @@ SwLayIdle::SwLayIdle( SwRootFrm *pRt, SwViewImp *pI ) : // somewhere or if the visibility of the CharRects has changed. bool bActions = false; size_t nBoolIdx = 0; - do + for(SwViewShell& rSh : pImp->GetShell()->GetRingContainer()) { - --pSh->mnStartAction; + --rSh.mnStartAction; - if ( pSh->Imp()->GetRegion() ) + if ( rSh.Imp()->GetRegion() ) bActions = true; else { - SwRect aTmp( pSh->VisArea() ); - pSh->UISizeNotify(); + SwRect aTmp( rSh.VisArea() ); + rSh.UISizeNotify(); // #137134# - // Are we supposed to crash if pSh isn't a cursor shell?! - // bActions |= aTmp != pSh->VisArea() || - // aBools[nBoolIdx] != ((SwCrsrShell*)pSh)->GetCharRect().IsOver( pSh->VisArea() ); + // Are we supposed to crash if rSh isn't a cursor shell?! + // bActions |= aTmp != rSh.VisArea() || + // aBools[nBoolIdx] != ((SwCrsrShell*)&rSh)->GetCharRect().IsOver( rSh.VisArea() ); // aBools[ i ] is true, if the i-th shell is a cursor shell (!!!) // and the cursor is visible. - bActions |= aTmp != pSh->VisArea(); - if ( aTmp == pSh->VisArea() && pSh->ISA(SwCrsrShell) ) + bActions |= aTmp != rSh.VisArea(); + if ( aTmp == rSh.VisArea() && rSh.ISA(SwCrsrShell) ) { bActions |= aBools[nBoolIdx] != - static_cast(pSh)->GetCharRect().IsOver( pSh->VisArea() ); + static_cast(&rSh)->GetCharRect().IsOver( rSh.VisArea() ); } } - pSh = static_cast(pSh->GetNext()); ++nBoolIdx; - } while ( pSh != pImp->GetShell() ); + } if ( bActions ) { // Prepare start/end actions via CrsrShell, so the cursor, selection // and VisArea can be set correctly. nBoolIdx = 0; - do + for(SwViewShell& rSh : pImp->GetShell()->GetRingContainer()) { - bool bCrsrShell = pSh->IsA( TYPE(SwCrsrShell) ); + SwCrsrShell* pCrsrShell = nullptr; + if(rSh.IsA( TYPE(SwCrsrShell) )) + pCrsrShell = static_cast(&rSh); - if ( bCrsrShell ) - static_cast(pSh)->SttCrsrMove(); + if ( pCrsrShell ) + pCrsrShell->SttCrsrMove(); // If there are accrued paints, it's best to simply invalidate // the whole window. Otherwise there would arise paint problems whose // solution would be disproportionally expensive. //fix(18176): - SwViewImp *pViewImp = pSh->Imp(); + SwViewImp *pViewImp = rSh.Imp(); bool bUnlock = false; if ( pViewImp->GetRegion() ) { pViewImp->DelRegion(); // Cause a repaint with virtual device. - pSh->LockPaint(); + rSh.LockPaint(); bUnlock = true; } - if ( bCrsrShell ) + if ( pCrsrShell ) // If the Crsr was visible, we need to make it visible again. // Otherwise, EndCrsrMove with true for IdleEnd - static_cast(pSh)->EndCrsrMove( !aBools[nBoolIdx] ); + pCrsrShell->EndCrsrMove( !aBools[nBoolIdx] ); if( bUnlock ) { - if( bCrsrShell ) + if( pCrsrShell ) { // UnlockPaint overwrite the selection from the // CrsrShell and calls the virtual method paint // to fill the virtual device. This fill dont have // paint the selection! -> Set the focus flag at // CrsrShell and it dont paint the selection. - static_cast(pSh)->ShLooseFcs(); - pSh->UnlockPaint( true ); - static_cast(pSh)->ShGetFcs( false ); + pCrsrShell->ShLooseFcs(); + pCrsrShell->UnlockPaint( true ); + pCrsrShell->ShGetFcs( false ); } else - pSh->UnlockPaint( true ); + rSh.UnlockPaint( true ); } - - pSh = static_cast(pSh->GetNext()); ++nBoolIdx; - } while ( pSh != pImp->GetShell() ); + } } if (!bInterrupt) -- cgit