summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.com>2023-03-14 08:15:06 +0100
committerMiklos Vajna <vmiklos@collabora.com>2023-03-14 08:00:26 +0000
commitbaebe41647e4522a2d58f7a4eb392ceab66fc2c9 (patch)
tree2d0c4c88d73fca2f56ae8ad71dc2f37ccae962a5
parent260735ff98631b94ae8737cf1cead3e20bade618 (diff)
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. Change-Id: Ic9171683ef7e14a70f7f8d5305198bbc16277d92 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/148834 Reviewed-by: Miklos Vajna <vmiklos@collabora.com> Tested-by: Jenkins
-rw-r--r--sw/qa/core/layout/flycnt.cxx13
-rw-r--r--sw/source/core/layout/tabfrm.cxx16
2 files changed, 29 insertions, 0 deletions
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 8bba0deab8e1..71d736499d8e 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.