sw/source/core/layout/tabfrm.cxx |   23 +++++++++++++----------
 1 file changed, 13 insertions(+), 10 deletions(-)

New commits:
commit b9e439874477f40732b9687cae99a3d9d0770db8
Author:     Mike Kaganski <[email protected]>
AuthorDate: Wed Sep 18 14:18:17 2024 +0500
Commit:     Mike Kaganski <[email protected]>
CommitDate: Fri Sep 20 04:05:23 2024 +0200

    When split is forbidden, avoid useless calculations
    
    Change-Id: Ibfc8b839d4455c21293906f7e4625a09b0d3f4f0
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/173600
    Reviewed-by: Mike Kaganski <[email protected]>
    Tested-by: Jenkins

diff --git a/sw/source/core/layout/tabfrm.cxx b/sw/source/core/layout/tabfrm.cxx
index cd7b33faa241..0ebdd4cb17cc 100644
--- a/sw/source/core/layout/tabfrm.cxx
+++ b/sw/source/core/layout/tabfrm.cxx
@@ -1124,8 +1124,8 @@ bool SwTabFrame::Split(const SwTwips nCutPos, bool 
bTryToSplit,
     //                   table, or it will be set to false under certain
     //                   conditions that are not suitable for splitting
     //                   the row.
-    bool bSplitRowAllowed = true;
-    if (!pRow->IsRowSplitAllowed())
+    bool bSplitRowAllowed = bTryToSplit;
+    if (bSplitRowAllowed && !pRow->IsRowSplitAllowed())
     {
         // A row larger than the entire page ought to be allowed to split 
regardless of setting,
         // otherwise it has hidden content and that makes no sense
@@ -1139,9 +1139,9 @@ bool SwTabFrame::Split(const SwTwips nCutPos, bool 
bTryToSplit,
     // a splitting of the table row.
     // Special DoNotSplit case 1:
     // Search for sections inside pRow:
-    if ( lcl_FindSectionsInRow( *pRow ) )
+    if (bSplitRowAllowed && lcl_FindSectionsInRow(*pRow))
     {
-        bTryToSplit = false;
+        bSplitRowAllowed = false;
     }
 
     SwFlyFrame* pFly = FindFlyFrame();
@@ -1199,7 +1199,7 @@ bool SwTabFrame::Split(const SwTwips nCutPos, bool 
bTryToSplit,
         // Second case: The first non-headline row does not fit to the page.
         // If it is not allowed to be split, or it contains a sub-row that
         // is not allowed to be split, we keep the row in this table:
-        if ( bTryToSplit && bSplitRowAllowed )
+        if (bSplitRowAllowed)
         {
             // Check if there are (first) rows inside this row,
             // which are not allowed to be split.
@@ -1244,9 +1244,7 @@ bool SwTabFrame::Split(const SwTwips nCutPos, bool 
bTryToSplit,
     // - the attributes of the row are set accordingly and
     // - we are allowed to do so
     // - it should not be kept with the next row
-    bSplitRowAllowed = bSplitRowAllowed && bTryToSplit &&
-                       ( !bTableRowKeep ||
-                         !pRow->ShouldRowKeepWithNext() );
+    bSplitRowAllowed = bSplitRowAllowed && (!bTableRowKeep || 
!pRow->ShouldRowKeepWithNext());
 
     // Adjust pRow according to the keep-with-next attribute:
     if ( !bSplitRowAllowed && bTableRowKeep )
commit bfefb2bebd71fc63026b92b23555ce57e4feb536
Author:     Mike Kaganski <[email protected]>
AuthorDate: Thu Sep 19 18:43:35 2024 +0500
Commit:     Mike Kaganski <[email protected]>
CommitDate: Fri Sep 20 04:05:08 2024 +0200

    Re-calculate the available space before calling lcl_RecalcSplitLine
    
    Because we could change the split row several times after first
    remaining space calculation, thus obsoleting the old value.
    
    Change-Id: Ia8027b0df2b04089c31b7031ddb05bd33e6ade98
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/173674
    Tested-by: Jenkins
    Reviewed-by: Mike Kaganski <[email protected]>

diff --git a/sw/source/core/layout/tabfrm.cxx b/sw/source/core/layout/tabfrm.cxx
index afbd321ab39b..cd7b33faa241 100644
--- a/sw/source/core/layout/tabfrm.cxx
+++ b/sw/source/core/layout/tabfrm.cxx
@@ -1440,7 +1440,7 @@ bool SwTabFrame::Split(const SwTwips nCutPos, bool 
bTryToSplit,
         // we also don't shrink here, because we will be doing that in 
lcl_RecalcSplitLine
 
         // recalculate the split line
-        bRet = lcl_RecalcSplitLine(*pLastRow, *pFollowRow, 
nRemainingSpaceForLastRow, nShrink, rIsFootnoteGrowth);
+        bRet = lcl_RecalcSplitLine(*pLastRow, *pFollowRow, 
getRemainingAfter(pLastRow->GetPrev()), nShrink, rIsFootnoteGrowth);
 
         // RecalcSplitLine did not work. In this case we conceal the split 
error:
         if (!bRet && !bSplitRowAllowed)
@@ -5058,6 +5058,7 @@ void SwRowFrame::Format( vcl::RenderContext* 
/*pRenderContext*/, const SwBorderA
     OSL_ENSURE( pAttrs, "SwRowFrame::Format without Attrs." );
 
     const bool bFix = mbFixSize;
+    SwTabFrame* pTabFrame = FindTabFrame();
 
     if ( !isFramePrintAreaValid() )
     {
@@ -5075,7 +5076,6 @@ void SwRowFrame::Format( vcl::RenderContext* 
/*pRenderContext*/, const SwBorderA
 
         // #i29550#
         // Here we calculate the top-printing area for the lower cell frames
-        SwTabFrame* pTabFrame = FindTabFrame();
         if ( pTabFrame->IsCollapsingBorders() )
         {
             const sal_uInt16 nTopSpace        = lcl_GetTopSpace(       *this );
@@ -5212,6 +5212,11 @@ void SwRowFrame::Format( vcl::RenderContext* 
/*pRenderContext*/, const SwBorderA
     {   nDiff -= aRectFnSet.GetHeight(pSibling->getFrameArea());
         pSibling = pSibling->GetNext();
     } while ( pSibling );
+    if (nDiff > 0 && pTabFrame->IsCollapsingBorders())
+    {
+        // In SwTabFrame::Format, this value will be added to the table's 
bottom margin
+        nDiff -= GetBottomLineSize();
+    }
     if ( nDiff > 0 )
     {
         mbFixSize = false;

Reply via email to