sw/qa/extras/ooxmlexport/data/tdf165492_exactWithBottomSpacing.docx |binary
 sw/qa/extras/ooxmlexport/ooxmlexport21.cxx                          |    8 +++
 sw/qa/extras/ooxmlexport/ooxmlexport22.cxx                          |   21 
++++++++++
 sw/source/core/layout/tabfrm.cxx                                    |   12 
+++++
 4 files changed, 40 insertions(+), 1 deletion(-)

New commits:
commit 14c64dcb2dae37f7a363afaa8783301b7719e0bf
Author:     Justin Luth <justin.l...@collabora.com>
AuthorDate: Fri Apr 4 16:58:25 2025 -0400
Commit:     Miklos Vajna <vmik...@collabora.com>
CommitDate: Wed Apr 9 10:40:20 2025 +0200

    tdf#165492 sw mso layout: add bottom border padding to 'exact' height
    
    at least for MS Word formats.
    
    This improves 25.2 commit 4f5b896d004af023f210f235aeafa9abc50068d2
        tdf#155229 Calculate row height incl. border if 'atLeast' is set
    by applying an anomaly shared with the atLeast calculation.
    
    Interestingly, the top padding has no effect at all
    on the 'exact' cell height.
    Yet, the bottom padding is added on top of the provided height,
    and therefore 'exact' doesn't mean exact at all.
    Rather bizarre actually.
    
    make CppunitTest_sw_ooxmlexport22 \
       CPPUNIT_TEST_NAME=testTdf165492_exactWithBottomSpacing
    
    make CppunitTest_sw_ooxmlexport21 \
       CPPUNIT_TEST_NAME=testTdf160077_layoutInCellB
    
    ooxmlexport14's tdf87569_vml.docx is another decent example
    where the mailing labels now fill the entire page better.
    
    Change-Id: Iec1a935950ecafc0d8d84d23bca4b85b79b700e5
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/183823
    Reviewed-by: Justin Luth <jl...@mail.com>
    Reviewed-by: Miklos Vajna <vmik...@collabora.com>
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com>

diff --git 
a/sw/qa/extras/ooxmlexport/data/tdf165492_exactWithBottomSpacing.docx 
b/sw/qa/extras/ooxmlexport/data/tdf165492_exactWithBottomSpacing.docx
new file mode 100644
index 000000000000..5bdeaa79fe3e
Binary files /dev/null and 
b/sw/qa/extras/ooxmlexport/data/tdf165492_exactWithBottomSpacing.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport21.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport21.cxx
index 6d4532b24c79..a388b7a3657a 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport21.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport21.cxx
@@ -581,6 +581,14 @@ DECLARE_OOXMLEXPORT_TEST(testTdf160077_layoutInCellB, 
"tdf160077_layoutInCellB.d
                          getProperty<sal_Int16>(xShape, 
u"VertOrientRelation"_ustr));
 
     CPPUNIT_ASSERT(getProperty<bool>(xShape, u"IsFollowingTextFlow"_ustr));
+
+    // tdf#165492: the "column" headings should be across from each other
+    sal_Int32 nObjectiveBottom
+        = getXPath(pDump, "//body/tab[1]/row[1]/cell[1]/txt[2]/infos/bounds", 
"bottom").toInt32();
+    sal_Int32 nExperienceBottom
+        = getXPath(pDump, "//body/tab[1]/row[1]/cell[2]/txt[1]/infos/bounds", 
"bottom").toInt32();
+    // Headers: "Objective"'s vertical position (4905) is nearly identical to 
"Experience" (4891)
+    CPPUNIT_ASSERT_DOUBLES_EQUAL(nObjectiveBottom, nExperienceBottom, 20);
 }
 
 DECLARE_OOXMLEXPORT_TEST(testTdf160077_layoutInCellC, 
"tdf160077_layoutInCellC.docx")
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport22.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport22.cxx
index f86a36da0c10..e095ad9760c8 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport22.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport22.cxx
@@ -55,6 +55,27 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf165933_noDelTextOnMove)
     assertXPath(pXmlDoc, "//w:moveFrom/w:r/w:delText", 0);
 }
 
+CPPUNIT_TEST_FIXTURE(Test, testTdf165492_exactWithBottomSpacing)
+{
+    // Given a document with "exact row height" of 2cm
+    // and table bottom border padding of 1.5cm...
+
+    loadAndSave("tdf165492_exactWithBottomSpacing.docx");
+
+    // When laying out that document:
+    xmlDocUniquePtr pXmlDoc = parseLayoutDump();
+
+    // the actual row heights should be exactly 3.5cm each (rounded up = 1985 
twips)
+    // giving a total table height of 5955 instead of 3402.
+    SwTwips nTableHeight
+        = getXPath(pXmlDoc, "//column[1]/body/tab/infos/prtBounds", 
"height").toInt32();
+    CPPUNIT_ASSERT_EQUAL(static_cast<SwTwips>(5955), nTableHeight);
+
+    // the table in the right column has no bottom border padding, so its 
height is 3402.
+    nTableHeight = getXPath(pXmlDoc, "//column[2]/body/tab/infos/prtBounds", 
"height").toInt32();
+    CPPUNIT_ASSERT_EQUAL(static_cast<SwTwips>(3402), nTableHeight);
+}
+
 CPPUNIT_TEST_FIXTURE(Test, testTdf165492_atLeastWithBottomSpacing)
 {
     // Given a document with "minimum row height" of 2cm
diff --git a/sw/source/core/layout/tabfrm.cxx b/sw/source/core/layout/tabfrm.cxx
index e753c245e2e3..313cc09a68dd 100644
--- a/sw/source/core/layout/tabfrm.cxx
+++ b/sw/source/core/layout/tabfrm.cxx
@@ -4944,6 +4944,16 @@ static SwTwips lcl_CalcMinCellHeight( const 
SwLayoutFrame *_pCell,
     return nHeight;
 }
 
+static SwTwips lcl_GetFixedRowHeight(const SwRowFrame& rRow, SwTwips nHeight)
+{
+    auto& rIDSA = rRow.GetFormat()->GetDoc()->GetDocumentSettingManager();
+    if (rIDSA.get(DocumentSettingId::MIN_ROW_HEIGHT_INCL_BORDER)) // MS Word 
'exact' oddities
+    {
+        nHeight += lcl_GetBottomLineDist(rRow);
+    }
+
+    return nHeight;
+}
 // #i26945# - add parameter <_bConsiderObjs> in order to control,
 // if floating screen objects have to be considered for the minimal cell height
 static SwTwips lcl_CalcMinRowHeight( const SwRowFrame* _pRow,
@@ -5335,7 +5345,7 @@ void SwRowFrame::Format( vcl::RenderContext* 
/*pRenderContext*/, const SwBorderA
 #endif
         const SwTwips nDiff = aRectFnSet.GetHeight(getFrameArea()) -
                               ( HasFixSize() && !IsRowSpanLine()
-                                ? pAttrs->GetSize().Height()
+                                ? lcl_GetFixedRowHeight(*this, 
pAttrs->GetSize().Height())
                                 // #i26945#
                                 : ::lcl_CalcMinRowHeight( this,
                                     
FindTabFrame()->IsConsiderObjsForMinCellHeight() ) );

Reply via email to