sw/qa/extras/layout/data/tdf164907_rowHeightAtLeast.docx |binary sw/qa/extras/layout/layout4.cxx | 7 +++++ sw/source/core/layout/tabfrm.cxx | 21 ++++++++++++++- 3 files changed, 27 insertions(+), 1 deletion(-)
New commits: commit e9ed6f1d2cc145e7514bf0a27b8c77f370ceab2d Author: Justin Luth <justin.l...@collabora.com> AuthorDate: Mon Feb 24 18:54:08 2025 -0500 Commit: Justin Luth <justin.l...@collabora.com> CommitDate: Sat Mar 1 04:09:52 2025 +0100 tdf#164907 sw: Calculate row height adds border if 'atLeast' set #2 The idea in 25.2 commit 4f5b896d004af023f210f235aeafa9abc50068d2 was to add the border line's width to the atLeast row height. However, the function used also included the border spacing, which is not (really) correct. [It appears that the BOTTOM border padding should be added, but that is true for both the atLeast and the 'exact' cases, so that change should be handled separately.] In MS Word, the bottom border of one row is also the top border of the next row (IsCollapsedBorders()). The bottom border line width seems to be irrelvant in regards to the height of the row, so the fact that the code only adds the top border seems correct. The last row puts the bottom border _below_ the row. make CppunitTest_sw_layoutwriter4 \ CPPUNIT_TEST_NAME=TestTdf164907_rowHeightAtLeast Change-Id: I756d38109a724d06e6230f5607b80a0bdc059bc6 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/182139 Tested-by: Jenkins Reviewed-by: Justin Luth <jl...@mail.com> diff --git a/sw/qa/extras/layout/data/tdf164907_rowHeightAtLeast.docx b/sw/qa/extras/layout/data/tdf164907_rowHeightAtLeast.docx new file mode 100644 index 000000000000..e42a7e34d405 Binary files /dev/null and b/sw/qa/extras/layout/data/tdf164907_rowHeightAtLeast.docx differ diff --git a/sw/qa/extras/layout/layout4.cxx b/sw/qa/extras/layout/layout4.cxx index 36af7e749aae..eb9abea5a538 100644 --- a/sw/qa/extras/layout/layout4.cxx +++ b/sw/qa/extras/layout/layout4.cxx @@ -1610,6 +1610,13 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter4, TestTdf155229RowAtLeast) CPPUNIT_ASSERT_EQUAL(sal_Int32(15494), nTableHeight); } +CPPUNIT_TEST_FIXTURE(SwLayoutWriter4, TestTdf164907_rowHeightAtLeast) +{ + createSwDoc("tdf164907_rowHeightAtLeast.docx"); + + CPPUNIT_ASSERT_EQUAL(1, getPages()); +} + CPPUNIT_TEST_FIXTURE(SwLayoutWriter4, TestTdf157829LTR) { // Verify that line breaking inside a bidi portion triggers underflow to previous bidi portions diff --git a/sw/source/core/layout/tabfrm.cxx b/sw/source/core/layout/tabfrm.cxx index f45d7c9b1986..6582879955b5 100644 --- a/sw/source/core/layout/tabfrm.cxx +++ b/sw/source/core/layout/tabfrm.cxx @@ -215,6 +215,7 @@ static bool lcl_InnerCalcLayout( SwFrame *pFrame, // cell height. static SwTwips lcl_CalcMinRowHeight( const SwRowFrame *pRow, const bool _bConsiderObjs ); +static sal_uInt16 lcl_GetLineWidth(const SwRowFrame& rRow, const SvxBoxItemLine& rLine); static sal_uInt16 lcl_GetTopSpace( const SwRowFrame& rRow ); static SwTwips lcl_CalcTopAndBottomMargin( const SwLayoutFrame&, const SwBorderAttrs& ); @@ -5008,7 +5009,7 @@ static SwTwips lcl_CalcMinRowHeight( const SwRowFrame* _pRow, if (bMinRowHeightInclBorder) { //get horizontal border(s) - nHeight += lcl_GetTopSpace(*_pRow); + nHeight += lcl_GetLineWidth(*_pRow, SvxBoxItemLine::TOP); } } } @@ -5054,6 +5055,24 @@ static SwTwips lcl_CalcMinRowHeight( const SwRowFrame* _pRow, return nHeight; } +// Calculate the maximum border-line thickness (CalcLineWidth) off all the cells in the row +static sal_uInt16 lcl_GetLineWidth(const SwRowFrame& rRow, const SvxBoxItemLine& rLine) +{ + sal_uInt16 nBorderThickness = 0; + for (const SwCellFrame* pCell = static_cast<const SwCellFrame*>(rRow.Lower()); pCell; + pCell = static_cast<const SwCellFrame*>(pCell->GetNext())) + { + sal_uInt16 nTmpWidth = 0; + const SwFrame* pLower = pCell->Lower(); + if (pLower && pLower->IsRowFrame()) + nTmpWidth = lcl_GetLineWidth(*static_cast<const SwRowFrame*>(pLower), rLine); + else + nTmpWidth = pCell->GetFormat()->GetAttrSet().GetBox().CalcLineWidth(rLine); + nBorderThickness = std::max(nBorderThickness, nTmpWidth); + } + return nBorderThickness; +} + // #i29550# // Calculate the maximum of (TopLineSize + TopLineDist) over all lowers: