sw/source/core/layout/tabfrm.cxx | 9 +--- sw/source/core/layout/wsfrm.cxx | 75 ++++++++++++++++----------------------- 2 files changed, 35 insertions(+), 49 deletions(-)
New commits: commit c2337ff12896b2ae09437d2cbc726971c9fb170f Author: Mike Kaganski <mike.kagan...@collabora.com> AuthorDate: Sat Aug 24 13:04:47 2024 +0500 Commit: Mike Kaganski <mike.kagan...@collabora.com> CommitDate: Sat Aug 24 12:12:14 2024 +0200 Simplify a bit Change-Id: Ia18d2d28d1026e3a695374dd523fb23ee97b96b5 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/172344 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kagan...@collabora.com> diff --git a/sw/source/core/layout/tabfrm.cxx b/sw/source/core/layout/tabfrm.cxx index a7286a4860b9..ee3cb240c590 100644 --- a/sw/source/core/layout/tabfrm.cxx +++ b/sw/source/core/layout/tabfrm.cxx @@ -3776,16 +3776,13 @@ SwTwips SwTabFrame::GrowFrame( SwTwips nDist, bool bTst, bool bInfo ) //The upper only grows as far as needed. nReal provides the distance //which is already available. SwTwips nReal = aRectFnSet.GetHeight(GetUpper()->getFramePrintArea()); - SwFrame *pFrame = GetUpper()->Lower(); - while ( pFrame && GetFollow() != pFrame ) - { + for (SwFrame* pFrame = GetUpper()->Lower(); pFrame && GetFollow() != pFrame; + pFrame = pFrame->GetNext()) nReal -= aRectFnSet.GetHeight(pFrame->getFrameArea()); - pFrame = pFrame->GetNext(); - } if ( nReal < nDist ) { - tools::Long nTmp = GetUpper()->Grow( nDist - std::max<tools::Long>(nReal, 0), bTst, bInfo ); + tools::Long nTmp = GetUpper()->Grow(nDist - std::max(nReal, SwTwips(0)), bTst, bInfo); if ( IsRestrictTableGrowth() ) { diff --git a/sw/source/core/layout/wsfrm.cxx b/sw/source/core/layout/wsfrm.cxx index ce8be2555649..b776eedea063 100644 --- a/sw/source/core/layout/wsfrm.cxx +++ b/sw/source/core/layout/wsfrm.cxx @@ -2183,11 +2183,8 @@ SwTwips SwContentFrame::GrowFrame( SwTwips nDist, bool bTst, bool bInfo ) } SwTwips nReal = aRectFnSet.GetHeight(GetUpper()->getFramePrintArea()); - SwFrame *pFrame = GetUpper()->Lower(); - while( pFrame && nReal > 0 ) - { nReal -= aRectFnSet.GetHeight(pFrame->getFrameArea()); - pFrame = pFrame->GetNext(); - } + for (SwFrame* pFrame = GetUpper()->Lower(); pFrame && nReal > 0; pFrame = pFrame->GetNext()) + nReal -= aRectFnSet.GetHeight(pFrame->getFrameArea()); if ( !bTst ) { @@ -2224,8 +2221,7 @@ SwTwips SwContentFrame::GrowFrame( SwTwips nDist, bool bTst, bool bInfo ) if( GetUpper() ) { if( bTst || !GetUpper()->IsFooterFrame() ) - nReal = GetUpper()->Grow( nDist - std::max<tools::Long>(nReal, 0), - bTst, bInfo ); + nReal = GetUpper()->Grow(nDist - std::max(nReal, SwTwips(0)), bTst, bInfo); else { nReal = 0; @@ -2688,11 +2684,8 @@ SwTwips SwLayoutFrame::GrowFrame( SwTwips nDist, bool bTst, bool bInfo ) SwTwips nMin = 0; if ( GetUpper() && !IsCellFrame() ) { - SwFrame *pFrame = GetUpper()->Lower(); - while( pFrame ) - { nMin += aRectFnSet.GetHeight(pFrame->getFrameArea()); - pFrame = pFrame->GetNext(); - } + for (SwFrame* pFrame = GetUpper()->Lower(); pFrame; pFrame = pFrame->GetNext()) + nMin += aRectFnSet.GetHeight(pFrame->getFrameArea()); nMin = aRectFnSet.GetHeight(GetUpper()->getFramePrintArea()) - nMin; if ( nMin < 0 ) nMin = 0; @@ -2731,7 +2724,7 @@ SwTwips SwLayoutFrame::GrowFrame( SwTwips nDist, bool bTst, bool bInfo ) nReal += AdjustNeighbourhood( nReal, bTst ); SwTwips nGrow = 0; - if( 0 < nReal ) + if( nReal > 0 ) { SwFrame* pToGrow = GetUpper(); // NEW TABLES commit 3caa0db8cfcf2ed2469e7a4cecba8a57d142dc04 Author: Mike Kaganski <mike.kagan...@collabora.com> AuthorDate: Sat Aug 24 12:35:05 2024 +0500 Commit: Mike Kaganski <mike.kagan...@collabora.com> CommitDate: Sat Aug 24 12:12:07 2024 +0200 Flatten SwFrame::Grow Change-Id: I0357a2b773ce7039697593df5f44b7ee35f89511 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/172342 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kagan...@collabora.com> diff --git a/sw/source/core/layout/wsfrm.cxx b/sw/source/core/layout/wsfrm.cxx index 225416da96af..ce8be2555649 100644 --- a/sw/source/core/layout/wsfrm.cxx +++ b/sw/source/core/layout/wsfrm.cxx @@ -1552,42 +1552,38 @@ SwTwips SwFrame::Grow( SwTwips nDist, bool bTst, bool bInfo ) PROTOCOL_ENTER( this, bTst ? PROT::GrowTest : PROT::Grow, DbgAction::NONE, &nDist ) - if ( nDist ) + if ( !nDist ) + return 0; + if ( IsFlyFrame() ) + return static_cast<SwFlyFrame*>(this)->Grow_( nDist, bTst ); + if ( IsSctFrame() ) + return static_cast<SwSectionFrame*>(this)->Grow_( nDist, bTst ); + if (IsCellFrame()) { - SwRectFnSet aRectFnSet(this); + const SwCellFrame* pThisCell = static_cast<const SwCellFrame*>(this); + const SwTabFrame* pTab = FindTabFrame(); - SwTwips nPrtHeight = aRectFnSet.GetHeight(getFramePrintArea()); - if( nPrtHeight > 0 && nDist > (LONG_MAX - nPrtHeight) ) - nDist = LONG_MAX - nPrtHeight; + // NEW TABLES + if ( pTab->IsVertical() != IsVertical() || + pThisCell->GetLayoutRowSpan() < 1 ) + return 0; + } - if ( IsFlyFrame() ) - return static_cast<SwFlyFrame*>(this)->Grow_( nDist, bTst ); - else if( IsSctFrame() ) - return static_cast<SwSectionFrame*>(this)->Grow_( nDist, bTst ); - else - { - if (IsCellFrame()) - { - const SwCellFrame* pThisCell = static_cast<const SwCellFrame*>(this); - const SwTabFrame* pTab = FindTabFrame(); + SwRectFnSet aRectFnSet(this); - // NEW TABLES - if ( pTab->IsVertical() != IsVertical() || - pThisCell->GetLayoutRowSpan() < 1 ) - return 0; - } - const SwTwips nReal = GrowFrame( nDist, bTst, bInfo ); - if( !bTst ) - { - nPrtHeight = aRectFnSet.GetHeight(getFramePrintArea()); + SwTwips nPrtHeight = aRectFnSet.GetHeight(getFramePrintArea()); + if( nPrtHeight > 0 && nDist > (LONG_MAX - nPrtHeight) ) + nDist = LONG_MAX - nPrtHeight; - SwFrameAreaDefinition::FramePrintAreaWriteAccess aPrt(*this); - aRectFnSet.SetHeight( aPrt, nPrtHeight + ( IsContentFrame() ? nDist : nReal ) ); - } - return nReal; - } + const SwTwips nReal = GrowFrame( nDist, bTst, bInfo ); + if( !bTst ) + { + nPrtHeight = aRectFnSet.GetHeight(getFramePrintArea()); + + SwFrameAreaDefinition::FramePrintAreaWriteAccess aPrt(*this); + aRectFnSet.SetHeight( aPrt, nPrtHeight + ( IsContentFrame() ? nDist : nReal ) ); } - return 0; + return nReal; } SwTwips SwFrame::Shrink( SwTwips nDist, bool bTst, bool bInfo )