sw/inc/ring.hxx | 9 +++++++- sw/source/core/crsr/crsrsh.cxx | 9 ++++---- sw/source/core/crsr/viscrs.cxx | 7 +----- sw/source/core/doc/DocumentDrawModelManager.cxx | 22 ++++++++------------ sw/source/core/doc/DocumentTimerManager.cxx | 19 ++++++++--------- sw/source/core/doc/doccorr.cxx | 15 ++++++------- sw/source/core/doc/doclay.cxx | 26 +++++++++++------------- 7 files changed, 52 insertions(+), 55 deletions(-)
New commits: commit 66b6611aae5dbfb68a958958a35e75725c8c1d9d Author: Bjoern Michaelsen <[email protected]> Date: Thu Dec 4 17:39:10 2014 +0100 cid#1256668: uninit ptr field Change-Id: I14f3bd9e3abd9562f47f21319da511df475b7fdd diff --git a/sw/inc/ring.hxx b/sw/inc/ring.hxx index 7c898a0..5d5494e 100644 --- a/sw/inc/ring.hxx +++ b/sw/inc/ring.hxx @@ -109,6 +109,7 @@ namespace sw template <class T> inline Ring<T>::Ring( T* pObj ) + : pPrev(static_cast< T* >(this)) { T* pThis = static_cast< T* >(this); if( !pObj ) commit 1b53effc6e1b305aed4f7ea59db13ffac55fe28c Author: Bjoern Michaelsen <[email protected]> Date: Thu Dec 4 17:38:50 2014 +0100 cid#1256669: uninit ptr field Change-Id: I6e3c5ac5281052b49c734b152ad4cd83021c6de9 diff --git a/sw/inc/ring.hxx b/sw/inc/ring.hxx index bca6dba..7c898a0 100644 --- a/sw/inc/ring.hxx +++ b/sw/inc/ring.hxx @@ -80,6 +80,7 @@ namespace sw * are alone in one. */ Ring() + : pPrev(static_cast< T* >(this)) { algo::init_header(static_cast< T* >(this)); } /** * Creates a new item and add it to an existing ring container. commit 917d505bff114f6431368c61565720ba41b1d067 Author: Bjoern Michaelsen <[email protected]> Date: Thu Dec 4 17:03:55 2014 +0100 cid#1256663: only allow comparing iterators from the same ring Change-Id: I77eb186f0048a9bc335408bace96111e6cb2ca53 diff --git a/sw/inc/ring.hxx b/sw/inc/ring.hxx index 8796dd0..bca6dba 100644 --- a/sw/inc/ring.hxx +++ b/sw/inc/ring.hxx @@ -188,7 +188,12 @@ namespace sw void increment() { m_pCurrent = m_pCurrent ? m_pCurrent->GetNext() : m_pStart->GetNext(); } bool equal(RingIterator const& other) const - { return m_pCurrent == other.m_pCurrent && m_pStart == other.m_pStart; } + { + // we never want to compare iterators from + // different rings or starting points + assert(m_pStart == other.m_pStart); + return m_pCurrent == other.m_pCurrent; + } T& dereference() const { return m_pCurrent ? *m_pCurrent : * m_pStart; } /** commit f5a42cf7afa2d5a1899f1c0d7c7093820703fba4 Author: Bjoern Michaelsen <[email protected]> Date: Thu Dec 4 15:53:03 2014 +0100 use C++11 iteration Change-Id: Icc47b1ead273ee02e85c35cb7ab0e06b48cc42c2 diff --git a/sw/source/core/doc/DocumentTimerManager.cxx b/sw/source/core/doc/DocumentTimerManager.cxx index 0c8bff2..0e90c8c 100644 --- a/sw/source/core/doc/DocumentTimerManager.cxx +++ b/sw/source/core/doc/DocumentTimerManager.cxx @@ -89,20 +89,19 @@ IMPL_LINK( DocumentTimerManager, DoIdleJobs, Timer *, pTimer ) if( pTmpRoot && !SfxProgress::GetActiveProgress( m_rDoc.GetDocShell() ) ) { - SwViewShell *pSh, *pStartSh; - pSh = pStartSh = m_rDoc.getIDocumentLayoutAccess().GetCurrentViewShell(); - do { - if( pSh->ActionPend() ) + SwViewShell* pShell(m_rDoc.getIDocumentLayoutAccess().GetCurrentViewShell()); + for(SwViewShell& rSh : pShell->GetRingContainer()) + { + if( rSh.ActionPend() ) { pTimer->Start(); return 0; } - pSh = static_cast<SwViewShell*>(pSh->GetNext()); - } while( pSh != pStartSh ); + } if( pTmpRoot->IsNeedGrammarCheck() ) { - bool bIsOnlineSpell = pSh->GetViewOptions()->IsOnlineSpell(); + bool bIsOnlineSpell = pShell->GetViewOptions()->IsOnlineSpell(); bool bIsAutoGrammar = false; SvtLinguConfig().GetProperty( OUString( UPN_IS_GRAMMAR_AUTO ) ) >>= bIsAutoGrammar; @@ -145,8 +144,8 @@ IMPL_LINK( DocumentTimerManager, DoIdleJobs, Timer *, pTimer ) pTmpRoot->StartAllAction(); // no jump on update of fields #i85168# - const bool bOldLockView = pStartSh->IsViewLocked(); - pStartSh->LockView( true ); + const bool bOldLockView = pShell->IsViewLocked(); + pShell->LockView( true ); m_rDoc.getIDocumentFieldsAccess().GetSysFldType( RES_CHAPTERFLD )->ModifyNotification( 0, 0 ); // ChapterField m_rDoc.getIDocumentFieldsAccess().UpdateExpFlds( 0, false ); // Updates ExpressionFields @@ -155,7 +154,7 @@ IMPL_LINK( DocumentTimerManager, DoIdleJobs, Timer *, pTimer ) pTmpRoot->EndAllAction(); - pStartSh->LockView( bOldLockView ); + pShell->LockView( bOldLockView ); m_rDoc.getIDocumentFieldsAccess().GetUpdtFlds().SetInUpdateFlds( false ); m_rDoc.getIDocumentFieldsAccess().GetUpdtFlds().SetFieldsDirty( false ); commit 359ebc27849e570d14f805bd676a0af5fd03df5c Author: Bjoern Michaelsen <[email protected]> Date: Thu Dec 4 15:49:18 2014 +0100 use C++11 iteration Change-Id: I6eb1287a6dcb27b2d29612f8ec71290ace62be32 diff --git a/sw/source/core/crsr/crsrsh.cxx b/sw/source/core/crsr/crsrsh.cxx index 0e78181..dc66cdd 100644 --- a/sw/source/core/crsr/crsrsh.cxx +++ b/sw/source/core/crsr/crsrsh.cxx @@ -2556,10 +2556,11 @@ void SwCrsrShell::ParkCrsr( const SwNodeIndex &rIdx ) // take care of all shells SwViewShell *pTmp = this; - do { - if( pTmp->IsA( TYPE( SwCrsrShell ))) + for(SwViewShell& rTmp : GetRingContainer()) + { + if( rTmp.IsA( TYPE( SwCrsrShell ))) { - SwCrsrShell* pSh = static_cast<SwCrsrShell*>(pTmp); + SwCrsrShell* pSh = static_cast<SwCrsrShell*>(&rTmp); if( pSh->m_pCrsrStk ) pSh->_ParkPams( pNew, &pSh->m_pCrsrStk ); @@ -2577,7 +2578,7 @@ void SwCrsrShell::ParkCrsr( const SwNodeIndex &rIdx ) } } } - } while ( this != (pTmp = static_cast<SwViewShell*>(pTmp->GetNext()) )); + } delete pNew; } commit f6ad09176b962dabf96aca4a5e25f8e601787367 Author: Bjoern Michaelsen <[email protected]> Date: Thu Dec 4 14:52:28 2014 +0100 use C++11 iteration Change-Id: I47eb10d425a6997d2bebaa5e56dd90543749c8b7 diff --git a/sw/source/core/doc/DocumentDrawModelManager.cxx b/sw/source/core/doc/DocumentDrawModelManager.cxx index 6d0761d..5b2b182 100644 --- a/sw/source/core/doc/DocumentDrawModelManager.cxx +++ b/sw/source/core/doc/DocumentDrawModelManager.cxx @@ -211,14 +211,11 @@ SwDrawModel* DocumentDrawModelManager::_MakeDrawModel() { OSL_ENSURE( !mpDrawModel, "_MakeDrawModel: Why?" ); InitDrawModel(); - if ( m_rDoc.getIDocumentLayoutAccess().GetCurrentViewShell() ) + SwViewShell* const pSh = m_rDoc.getIDocumentLayoutAccess().GetCurrentViewShell(); + if ( pSh ) { - SwViewShell* pTmp = m_rDoc.getIDocumentLayoutAccess().GetCurrentViewShell(); - do - { - pTmp->MakeDrawView(); - pTmp = static_cast<SwViewShell*>( pTmp->GetNext()); - } while ( pTmp != m_rDoc.getIDocumentLayoutAccess().GetCurrentViewShell() ); + for(SwViewShell& rViewSh : pSh->GetRingContainer()) + rViewSh.MakeDrawView(); // Broadcast, so that the FormShell can be connected to the DrawView if( m_rDoc.GetDocShell() ) commit 4942573a9efadb7986e9daae3db2ea4d28eb6ac1 Author: Bjoern Michaelsen <[email protected]> Date: Thu Dec 4 14:51:08 2014 +0100 use C++11 iteration Change-Id: I07de79fd793051efef717b7c44c88812cefc59d5 diff --git a/sw/source/core/doc/DocumentDrawModelManager.cxx b/sw/source/core/doc/DocumentDrawModelManager.cxx index d76b594..6d0761d 100644 --- a/sw/source/core/doc/DocumentDrawModelManager.cxx +++ b/sw/source/core/doc/DocumentDrawModelManager.cxx @@ -150,12 +150,12 @@ void DocumentDrawModelManager::InitDrawModel() mpDrawModel->SetRefDevice( pRefDev ); mpDrawModel->SetNotifyUndoActionHdl( LINK( &m_rDoc, SwDoc, AddDrawUndo )); - if ( m_rDoc.getIDocumentLayoutAccess().GetCurrentViewShell() ) + SwViewShell* const pSh = m_rDoc.getIDocumentLayoutAccess().GetCurrentViewShell(); + if ( pSh ) { - SwViewShell* pViewSh = m_rDoc.getIDocumentLayoutAccess().GetCurrentViewShell(); - do + for(SwViewShell& rViewSh : pSh->GetRingContainer()) { - SwRootFrm* pRoot = pViewSh->GetLayout(); + SwRootFrm* pRoot = rViewSh.GetLayout(); if( pRoot && !pRoot->GetDrawPage() ) { // Disable "multiple layout" for the moment: @@ -166,8 +166,7 @@ void DocumentDrawModelManager::InitDrawModel() pRoot->SetDrawPage( pDrawPage ); pDrawPage->SetSize( pRoot->Frm().SSize() ); } - pViewSh = static_cast<SwViewShell*>(pViewSh->GetNext()); - }while( pViewSh != m_rDoc.getIDocumentLayoutAccess().GetCurrentViewShell() ); + } } } commit 798ffd674b26666d0ada967f144bfdd54821e79f Author: Bjoern Michaelsen <[email protected]> Date: Thu Dec 4 14:38:27 2014 +0100 use C++11 iteration Change-Id: I8992c9fd853b7b92e328826063b50244f9fa3544 diff --git a/sw/source/core/doc/doccorr.cxx b/sw/source/core/doc/doccorr.cxx index eaf11f6..b012731 100644 --- a/sw/source/core/doc/doccorr.cxx +++ b/sw/source/core/doc/doccorr.cxx @@ -320,17 +320,16 @@ SwEditShell const * SwDoc::GetEditShell() const // Layout and OLE shells should be available if( pCurrentView ) { - SwViewShell const *pFirstVSh = pCurrentView; - SwViewShell const *pCurrentVSh = pFirstVSh; - // look for an EditShell (if it exists) - do { - if( pCurrentVSh->IsA( TYPE( SwEditShell ) ) ) + for(const SwViewShell& rCurrentSh : pCurrentView->GetRingContainer()) + { + // look for an EditShell (if it exists) + if( rCurrentSh.IsA( TYPE( SwEditShell ) ) ) { - return static_cast<const SwEditShell*>(pCurrentVSh); + return static_cast<const SwEditShell*>(&rCurrentSh); } - } while( pFirstVSh != ( pCurrentVSh = static_cast<SwViewShell*>(pCurrentVSh->GetNext()) )); + } } - return 0; + return nullptr; } SwEditShell* SwDoc::GetEditShell() commit 6aca1a26c3d46cd9b79bf7b109622352b1d0e12b Author: Bjoern Michaelsen <[email protected]> Date: Thu Dec 4 14:37:20 2014 +0100 use C++11 iteration Change-Id: I30a252d2d518a361e16050f6eeffbe4371a9c982 diff --git a/sw/source/core/crsr/viscrs.cxx b/sw/source/core/crsr/viscrs.cxx index 4bb9588..937fcf0 100644 --- a/sw/source/core/crsr/viscrs.cxx +++ b/sw/source/core/crsr/viscrs.cxx @@ -537,11 +537,8 @@ void SwShellCrsr::FillRects() void SwShellCrsr::Show() { - SwShellCrsr * pTmp = this; - do { - if (pTmp) - pTmp->SwSelPaintRects::Show(); - } while( this != ( pTmp = dynamic_cast<SwShellCrsr*>(pTmp->GetNext()) ) ); + for(SwPaM& rTmp : GetRingContainer()) + dynamic_cast<SwShellCrsr*>(&rTmp)->SwSelPaintRects::Show(); } // This rectangle gets painted anew, therefore the SSelection in this commit e04d4d196a91fce2370fd44f0bd23a195589860d Author: Bjoern Michaelsen <[email protected]> Date: Thu Dec 4 14:14:31 2014 +0100 use C++11 iteration Change-Id: I185b03dc8b747178fc442b7748dfe40762b46d32 diff --git a/sw/source/core/doc/doclay.cxx b/sw/source/core/doc/doclay.cxx index 7c4b58f..8accb57 100644 --- a/sw/source/core/doc/doclay.cxx +++ b/sw/source/core/doc/doclay.cxx @@ -430,34 +430,32 @@ SwFlyFrmFmt* SwDoc::MakeFlyAndMove( const SwPaM& rPam, const SfxItemSet& rSet, else { // copy all Pams and then delete all - SwPaM* pTmp = (SwPaM*)&rPam; bool bOldFlag = mbCopyIsMove; bool const bOldUndo = GetIDocumentUndoRedo().DoesUndo(); bool const bOldRedlineMove(getIDocumentRedlineAccess().IsRedlineMove()); mbCopyIsMove = true; GetIDocumentUndoRedo().DoUndo(false); getIDocumentRedlineAccess().SetRedlineMove(true); - do { - if( pTmp->HasMark() && - *pTmp->GetPoint() != *pTmp->GetMark() ) + for(const SwPaM& rTmp : rPam.GetRingContainer()) + { + if( rTmp.HasMark() && + *rTmp.GetPoint() != *rTmp.GetMark() ) { - getIDocumentContentOperations().CopyRange( *pTmp, aPos, false ); + getIDocumentContentOperations().CopyRange( *const_cast<SwPaM*>(&rTmp), aPos, false ); } - pTmp = static_cast<SwPaM*>(pTmp->GetNext()); - } while ( &rPam != pTmp ); + } getIDocumentRedlineAccess().SetRedlineMove(bOldRedlineMove); mbCopyIsMove = bOldFlag; GetIDocumentUndoRedo().DoUndo(bOldUndo); - pTmp = (SwPaM*)&rPam; - do { - if( pTmp->HasMark() && - *pTmp->GetPoint() != *pTmp->GetMark() ) + for(const SwPaM& rTmp : rPam.GetRingContainer()) + { + if( rTmp.HasMark() && + *rTmp.GetPoint() != *rTmp.GetMark() ) { - getIDocumentContentOperations().DeleteAndJoin( *pTmp ); + getIDocumentContentOperations().DeleteAndJoin( *const_cast<SwPaM*>(&rTmp) ); } - pTmp = static_cast<SwPaM*>(pTmp->GetNext()); - } while ( &rPam != pTmp ); + } } } while( false ); } _______________________________________________ Libreoffice-commits mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
