sw/qa/core/layout/flycnt.cxx     |   13 +++++++++++++
 sw/source/core/layout/tabfrm.cxx |   16 ++++++++++++++++
 2 files changed, 29 insertions(+)

New commits:
commit a6f0889f8d845c4245e78db16645083a8e7a1242
Author:     Miklos Vajna <vmik...@collabora.com>
AuthorDate: Tue Mar 14 08:15:06 2023 +0100
Commit:     Miklos Vajna <vmik...@collabora.com>
CommitDate: Thu Mar 16 09:59:36 2023 +0000

    sw floattable: reject small(er than min height) row master at page bottom
    
    The problem was that the second row in the doc model was split between
    page 1 & page 2, but it was expected that row 2 is entirely on page 2.
    
    The underlying reason seems to be similar to what commit
    913b71dbe06c33773c4d779e00c6ec4b6a4af59f (sw floattable: ignore height
    of masters in lcl_CalcMinRowHeight(), 2023-03-10) fixed: again the
    minimum row height is meant to be enforced for each row frame of the
    row, so in case the remainings size on the page is 566 twips and the
    minimum row height is 1134, then we should not split the row, instead we
    should move the entire row to the next page.
    
    Fix the problem by checking for this (relatively) at the start of
    SwTabFrame::Split(), so we don't even try to split the row in this case.
    
    I assume that this would be correct to do in general, but have no such
    sample to confirm this in Word, so keep this specific to tables in split
    flys for now.
    
    (cherry picked from commit baebe41647e4522a2d58f7a4eb392ceab66fc2c9)
    
    Change-Id: Ic9171683ef7e14a70f7f8d5305198bbc16277d92
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/148949
    Tested-by: Miklos Vajna <vmik...@collabora.com>
    Reviewed-by: Miklos Vajna <vmik...@collabora.com>

diff --git a/sw/qa/core/layout/flycnt.cxx b/sw/qa/core/layout/flycnt.cxx
index 079030d80054..5df8d7fc5c73 100644
--- a/sw/qa/core/layout/flycnt.cxx
+++ b/sw/qa/core/layout/flycnt.cxx
@@ -510,6 +510,19 @@ CPPUNIT_TEST_FIXTURE(Test, testSplitFlyCompat14)
     // Without the accompanying fix in place, this test would have failed, the 
first row was split,
     // but not in Word.
     CPPUNIT_ASSERT(!pCell1->GetFollowCell());
+    // Also make sure that the second row is entirely on page 2:
+    auto pPage2 = dynamic_cast<SwPageFrame*>(pPage1->GetNext());
+    CPPUNIT_ASSERT(pPage2);
+    const SwSortedObjs& rPage2Objs = *pPage2->GetSortedObjs();
+    CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(1), rPage2Objs.size());
+    auto pPage2Fly = dynamic_cast<SwFlyAtContentFrame*>(rPage2Objs[0]);
+    CPPUNIT_ASSERT(pPage2Fly);
+    SwFrame* pTab2 = pPage2Fly->GetLower();
+    SwFrame* pRow2 = pTab2->GetLower();
+    auto pCell2 = dynamic_cast<SwCellFrame*>(pRow2->GetLower());
+    // Without the accompanying fix in place, this test would have failed, the 
second row was split,
+    // but not in Word.
+    CPPUNIT_ASSERT(!pCell2->GetPreviousCell());
 }
 }
 
diff --git a/sw/source/core/layout/tabfrm.cxx b/sw/source/core/layout/tabfrm.cxx
index 611d14c2d536..0e1829af0844 100644
--- a/sw/source/core/layout/tabfrm.cxx
+++ b/sw/source/core/layout/tabfrm.cxx
@@ -1087,6 +1087,22 @@ bool SwTabFrame::Split( const SwTwips nCutPos, bool 
bTryToSplit, bool bTableRowK
         bTryToSplit = false;
     }
 
+    SwFlyFrame* pFly = FindFlyFrame();
+    if (bSplitRowAllowed && pFly && pFly->IsFlySplitAllowed())
+    {
+        // The remaining size is less than the minimum row height, then don't 
even try to split the
+        // row, just move it forward.
+        const SwFormatFrameSize& rRowSize = pRow->GetFormat()->GetFrameSize();
+        if (rRowSize.GetHeightSizeType() == SwFrameSize::Minimum)
+        {
+            SwTwips nMinHeight = rRowSize.GetHeight();
+            if (nMinHeight > nRemainingSpaceForLastRow)
+            {
+                bSplitRowAllowed = false;
+            }
+        }
+    }
+
     // #i29771#
     // To avoid loops, we do some checks before actually trying to split
     // the row. Maybe we should keep the next row in this table.

Reply via email to