diff options
author | Ashod Nakashian <ashodnakashian@yahoo.com> | 2015-10-31 21:04:59 -0400 |
---|---|---|
committer | Björn Michaelsen <bjoern.michaelsen@canonical.com> | 2015-11-07 21:22:01 +0000 |
commit | 04783fd91832fa01a5b096f395edd7ad4f9c0f6b (patch) | |
tree | fd677ba54851b1742ad163e3a27bc6cea314052c /sw/source/core/layout | |
parent | 12d973aa9b6b3d962702f27fc46ef05b0151cabc (diff) |
Misc tweaks and cleanups.
Streamlined a couple of hotspots and some
minor cleanups.
Change-Id: I85a9423e03f7e20ce78736a44d668da859a443cd
Reviewed-on: https://gerrit.libreoffice.org/19720
Reviewed-by: Björn Michaelsen <bjoern.michaelsen@canonical.com>
Tested-by: Björn Michaelsen <bjoern.michaelsen@canonical.com>
Diffstat (limited to 'sw/source/core/layout')
-rw-r--r-- | sw/source/core/layout/calcmove.cxx | 2 | ||||
-rw-r--r-- | sw/source/core/layout/findfrm.cxx | 12 | ||||
-rw-r--r-- | sw/source/core/layout/layact.cxx | 3 | ||||
-rw-r--r-- | sw/source/core/layout/pagechg.cxx | 44 | ||||
-rw-r--r-- | sw/source/core/layout/paintfrm.cxx | 2 | ||||
-rw-r--r-- | sw/source/core/layout/wsfrm.cxx | 17 |
6 files changed, 39 insertions, 41 deletions
diff --git a/sw/source/core/layout/calcmove.cxx b/sw/source/core/layout/calcmove.cxx index 9de4a2ff5e3c..5b32b56acae8 100644 --- a/sw/source/core/layout/calcmove.cxx +++ b/sw/source/core/layout/calcmove.cxx @@ -254,7 +254,7 @@ void SwFrm::PrepareMake(vcl::RenderContext* pRenderContext) const bool bTab = IsTabFrm(); bool bNoSect = IsInSct(); bool bOldTabLock = false, bFoll = false; - SwFlowFrm* pThis = bCnt ? static_cast<SwContentFrm*>(this) : NULL; + SwFlowFrm* pThis = bCnt ? static_cast<SwContentFrm*>(this) : nullptr; if ( bTab ) { diff --git a/sw/source/core/layout/findfrm.cxx b/sw/source/core/layout/findfrm.cxx index ced90ecc8cf1..8936e25ea4a2 100644 --- a/sw/source/core/layout/findfrm.cxx +++ b/sw/source/core/layout/findfrm.cxx @@ -393,7 +393,7 @@ const SwContentFrm* SwContentFrm::ImplGetNextContentFrm( bool bFwd ) const return pContentFrm; } -SwPageFrm* SwFrm::FindPageFrm() +SwPageFrm* SwFrm::ImplFindPageFrm() { SwFrm *pRet = this; while ( pRet && !pRet->IsPageFrm() ) @@ -403,13 +403,13 @@ SwPageFrm* SwFrm::FindPageFrm() else if ( pRet->IsFlyFrm() ) { // #i28701# - use new method <GetPageFrm()> - if ( static_cast<SwFlyFrm*>(pRet)->GetPageFrm() ) - pRet = static_cast<SwFlyFrm*>(pRet)->GetPageFrm(); - else - pRet = static_cast<SwFlyFrm*>(pRet)->AnchorFrm(); + const auto pFly(static_cast<SwFlyFrm*>(pRet)); + pRet = pFly->GetPageFrm(); + if (pRet == nullptr) + pRet = pFly->AnchorFrm(); } else - return 0; + return nullptr; } return static_cast<SwPageFrm*>(pRet); } diff --git a/sw/source/core/layout/layact.cxx b/sw/source/core/layout/layact.cxx index 989ec2f29257..e9bedbafa2af 100644 --- a/sw/source/core/layout/layact.cxx +++ b/sw/source/core/layout/layact.cxx @@ -483,7 +483,8 @@ void SwLayAction::InternalAction(OutputDevice* pRenderContext) ::SetProgressState( nPercentPageNum, pImp->GetShell()->GetDoc()->GetDocShell()); } pOptTab = 0; - // No Shortcut for Idle or CalcLayout + + // No Shortcut for Idle or CalcLayout if ( !IsIdle() && !IsComplete() && IsShortCut( pPage ) ) { pRoot->DeleteEmptySct(); diff --git a/sw/source/core/layout/pagechg.cxx b/sw/source/core/layout/pagechg.cxx index 3c43775dcffe..6d698bdff1b2 100644 --- a/sw/source/core/layout/pagechg.cxx +++ b/sw/source/core/layout/pagechg.cxx @@ -1754,44 +1754,41 @@ static void lcl_MoveAllLowers( SwFrm* pFrm, const Point& rOffset ); static void lcl_MoveAllLowerObjs( SwFrm* pFrm, const Point& rOffset ) { - SwSortedObjs* pSortedObj = 0; const bool bPage = pFrm->IsPageFrm(); + const SwSortedObjs* pSortedObj = bPage + ? static_cast<SwPageFrm*>(pFrm)->GetSortedObjs() + : pFrm->GetDrawObjs(); + if (pSortedObj == nullptr) + return; - if ( bPage ) - pSortedObj = static_cast<SwPageFrm*>(pFrm)->GetSortedObjs(); - else - pSortedObj = pFrm->GetDrawObjs(); - - for ( size_t i = 0; pSortedObj && i < pSortedObj->size(); ++i) + for (SwAnchoredObject* pAnchoredObj : *pSortedObj) { - SwAnchoredObject* pAnchoredObj = (*pSortedObj)[i]; - const SwFrameFormat& rObjFormat = pAnchoredObj->GetFrameFormat(); const SwFormatAnchor& rAnchor = rObjFormat.GetAnchor(); // all except from the as character anchored objects are moved // when processing the page frame: - const bool bAsChar = (rAnchor.GetAnchorId() == FLY_AS_CHAR); - if ( !bPage && !bAsChar ) + if ( !bPage && (rAnchor.GetAnchorId() != FLY_AS_CHAR) ) continue; SwObjPositioningInProgress aPosInProgress( *pAnchoredObj ); - if ( dynamic_cast< const SwFlyFrm *>( pAnchoredObj ) != nullptr ) + if ( dynamic_cast< const SwFlyFrm *>( pAnchoredObj ) != nullptr ) { SwFlyFrm* pFlyFrm( static_cast<SwFlyFrm*>(pAnchoredObj) ); lcl_MoveAllLowers( pFlyFrm, rOffset ); pFlyFrm->NotifyDrawObj(); // --> let the active embedded object be moved - if ( pFlyFrm->Lower() ) + SwFrm* pLower = pFlyFrm->Lower(); + if ( pLower ) { - if ( pFlyFrm->Lower()->IsNoTextFrm() ) + if ( pLower->IsNoTextFrm() ) { - SwContentFrm* pContentFrm = static_cast<SwContentFrm*>(pFlyFrm->Lower()); - SwRootFrm* pRoot = pFlyFrm->Lower()->getRootFrm(); - SwViewShell *pSh = pRoot ? pRoot->GetCurrShell() : 0; + SwRootFrm* pRoot = pLower->getRootFrm(); + SwViewShell *pSh = pRoot ? pRoot->GetCurrShell() : nullptr; if ( pSh ) { + SwContentFrm* pContentFrm = static_cast<SwContentFrm*>(pLower); SwOLENode* pNode = pContentFrm->GetNode()->GetOLENode(); if ( pNode ) { @@ -1815,11 +1812,10 @@ static void lcl_MoveAllLowerObjs( SwFrm* pFrm, const Point& rOffset ) SwAnchoredDrawObject* pAnchoredDrawObj( static_cast<SwAnchoredDrawObject*>(pAnchoredObj) ); // don't touch objects that are not yet positioned: - const bool bNotYetPositioned = pAnchoredDrawObj->NotYetPositioned(); - if ( bNotYetPositioned ) + if ( pAnchoredDrawObj->NotYetPositioned() ) continue; - const Point aCurrAnchorPos = pAnchoredDrawObj->GetDrawObj()->GetAnchorPos(); + const Point& aCurrAnchorPos = pAnchoredDrawObj->GetDrawObj()->GetAnchorPos(); const Point aNewAnchorPos( ( aCurrAnchorPos + rOffset ) ); pAnchoredDrawObj->DrawObj()->SetAnchorPos( aNewAnchorPos ); pAnchoredDrawObj->SetLastObjRect( pAnchoredDrawObj->GetObjRect().SVRect() ); @@ -1874,12 +1870,13 @@ static void lcl_MoveAllLowers( SwFrm* pFrm, const Point& rOffset ) // Calculate how the pages have to be positioned void SwRootFrm::CheckViewLayout( const SwViewOption* pViewOpt, const SwRect* pVisArea ) { - vcl::RenderContext* pRenderContext = GetCurrShell() ? GetCurrShell()->GetOut() : 0; + SwViewShell* pSh = GetCurrShell(); + vcl::RenderContext* pRenderContext = pSh ? pSh->GetOut() : nullptr; // #i91432# // No calculation of page positions, if only an empty page is present. // This situation occurs when <SwRootFrm> instance is in construction // and the document contains only left pages. - if ( Lower()->GetNext() == 0 && + if ( Lower()->GetNext() == nullptr && static_cast<SwPageFrm*>(Lower())->IsEmptyPage() ) { return; @@ -1922,7 +1919,6 @@ void SwRootFrm::CheckViewLayout( const SwViewOption* pViewOpt, const SwRect* pVi const long nBorder = Frm().Pos().getX(); const long nVisWidth = mnViewWidth - 2 * nBorder; - SwViewShell* pSh = GetCurrShell(); const long nGapBetweenPages = pViewOpt ? pViewOpt->GetGapBetweenPages() : (pSh ? pSh->GetViewOptions()->GetGapBetweenPages() : SwViewOption::GetDefGapBetweenPages()); @@ -1950,7 +1946,7 @@ void SwRootFrm::CheckViewLayout( const SwViewOption* pViewOpt, const SwRect* pVi bool bPageChanged = false; const bool bRTL = !IsLeftToRightViewLayout(); - const SwTwips nSidebarWidth = SwPageFrm::GetSidebarBorderWidth( GetCurrShell() ); + const SwTwips nSidebarWidth = SwPageFrm::GetSidebarBorderWidth( pSh ); while ( pPageFrm ) { diff --git a/sw/source/core/layout/paintfrm.cxx b/sw/source/core/layout/paintfrm.cxx index 3f6acc2547d6..b92c6e884839 100644 --- a/sw/source/core/layout/paintfrm.cxx +++ b/sw/source/core/layout/paintfrm.cxx @@ -6411,7 +6411,7 @@ SwRect SwPageFrm::GetBoundRect(OutputDevice* pOutputDevice) const /*static*/ SwTwips SwPageFrm::GetSidebarBorderWidth( const SwViewShell* _pViewShell ) { - const SwPostItMgr* pPostItMgr = _pViewShell ? _pViewShell->GetPostItMgr() : 0; + const SwPostItMgr* pPostItMgr = _pViewShell ? _pViewShell->GetPostItMgr() : nullptr; const SwTwips nRet = pPostItMgr && pPostItMgr->HasNotes() && pPostItMgr->ShowNotes() ? pPostItMgr->GetSidebarWidth() + pPostItMgr->GetSidebarBorderWidth() : 0; return nRet; } diff --git a/sw/source/core/layout/wsfrm.cxx b/sw/source/core/layout/wsfrm.cxx index b767f8b19828..fbf706e7f331 100644 --- a/sw/source/core/layout/wsfrm.cxx +++ b/sw/source/core/layout/wsfrm.cxx @@ -58,11 +58,11 @@ SwFrm::SwFrm( SwModify *pMod, SwFrm* pSib ) : mbIfAccTableShouldDisposing( false ), //A member to identify if the acc table should dispose mbInDtor(false), mnFrmId( SwFrm::mnLastFrmId++ ), - mpRoot( pSib ? pSib->getRootFrm() : 0 ), - mpUpper( 0 ), - mpNext( 0 ), - mpPrev( 0 ), - mpDrawObjs( 0 ), + mpRoot( pSib ? pSib->getRootFrm() : nullptr ), + mpUpper(nullptr), + mpNext(nullptr), + mpPrev(nullptr), + mpDrawObjs(nullptr), mnFrmType(0), mbInfBody( false ), mbInfTab ( false ), @@ -2157,11 +2157,12 @@ TYPEINIT1(SwLayoutFrm,SwFrm); SwTwips SwLayoutFrm::InnerHeight() const { - if( !Lower() ) - return 0; - SwTwips nRet = 0; const SwFrm* pCnt = Lower(); + if (!pCnt) + return 0; + SWRECTFN( this ) + SwTwips nRet = 0; if( pCnt->IsColumnFrm() || pCnt->IsCellFrm() ) { do |