sw/qa/core/layout/paintfrm.cxx     |   10 ++++++++++
 sw/source/core/layout/paintfrm.cxx |    9 ++++++++-
 2 files changed, 18 insertions(+), 1 deletion(-)

New commits:
commit 69bbd6378ed7a7b7765948d5ec08673866947d5d
Author:     Miklos Vajna <vmik...@collabora.com>
AuthorDate: Fri May 24 10:51:31 2024 +0200
Commit:     Caolán McNamara <caolan.mcnam...@collabora.com>
CommitDate: Mon May 27 14:30:44 2024 +0200

    tdf#160984 sw continuous endnotes: fix the endnote separator length
    
    See
    <https://bug-attachments.documentfoundation.org/attachment.cgi?id=194324>,
    Word has a longer separator line for the foot/endnote than Writer for
    this bugdoc.
    
    Writer defaults to 25% of the body frame width in the SwPageFootnoteInfo
    ctor, and we don't seem to change that in the DOCX import. Word has a
    static 2 inches setting, which is only reduced if it would go outside
    the body frame.
    
    Fix the problem by extending SwFootnoteContFrame::PaintLine() in the
    DocumentSettingId::CONTINUOUS_ENDNOTES case to do the same.
    
    I searched the OOXML spec and the MS implementer notes, they don't
    specify this 2 inches length, but it seems static: the value doesn't
    change with the page size. With this, the single-section bugdoc is now
    rendered fine.
    
    (cherry picked from commit 755f3bebd96ec7ae43b1dcf247f907b9c15c1995)
    
    Change-Id: I3bb23680937580179b8d37c940ea14e0f80fc7f4
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/168088
    Reviewed-by: Caolán McNamara <caolan.mcnam...@collabora.com>
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com>

diff --git a/sw/qa/core/layout/paintfrm.cxx b/sw/qa/core/layout/paintfrm.cxx
index 8e7154db2501..a5213c57d639 100644
--- a/sw/qa/core/layout/paintfrm.cxx
+++ b/sw/qa/core/layout/paintfrm.cxx
@@ -177,6 +177,16 @@ CPPUNIT_TEST_FIXTURE(Test, 
testInlineEndnoteSeparatorPosition)
     // - Actual  : 2060
     // i.e. the upper spacing was too low.
     CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(2164), nEndnoteSeparatorY);
+
+    // Also make sure the separator length is correct:
+    auto nEndnoteSeparatorStart = getXPath(pXmlDoc, "//polygon/point[1]"_ostr, 
"x"_ostr).toInt32();
+    auto nEndnoteSeparatorEnd = getXPath(pXmlDoc, "//polygon/point[2]"_ostr, 
"x"_ostr).toInt32();
+    sal_Int32 nEndnoteSeparatorLength = nEndnoteSeparatorEnd - 
nEndnoteSeparatorStart;
+    // Without the accompanying fix in place, this test would have failed with:
+    // - Expected: 2880
+    // - Actual  : 2340
+    // i.e. the separator wasn't 2 inches long, but was shorter vs Word.
+    CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(2880), 
nEndnoteSeparatorLength);
 }
 }
 
diff --git a/sw/source/core/layout/paintfrm.cxx 
b/sw/source/core/layout/paintfrm.cxx
index b45226bbbcb6..89ea71f9acb7 100644
--- a/sw/source/core/layout/paintfrm.cxx
+++ b/sw/source/core/layout/paintfrm.cxx
@@ -5777,7 +5777,7 @@ void SwFootnoteContFrame::PaintLine( const SwRect& rRect,
     SwTwips nPrtWidth = aRectFnSet.GetWidth(getFramePrintArea());
     Fraction aFract( nPrtWidth, 1 );
     aFract *= rInf.GetWidth();
-    const SwTwips nWidth = static_cast<tools::Long>(aFract);
+    SwTwips nWidth = static_cast<tools::Long>(aFract);
 
     SwTwips nX = aRectFnSet.GetPrtLeft(*this);
     switch ( rInf.GetAdj() )
@@ -5808,6 +5808,13 @@ void SwFootnoteContFrame::PaintLine( const SwRect& rRect,
             // Word style: instead of fixed value, upper spacing is 60% of all 
space.
             auto nPrintAreaTop = 
static_cast<double>(getFramePrintArea().Top());
             aPoint.setY(getFrameArea().Pos().Y() + nPrintAreaTop * 0.6);
+
+            // Length is 2 inches, but don't paint outside the container frame.
+            nWidth = o3tl::convert(2, o3tl::Length::in, o3tl::Length::twip);
+            if (nWidth > nPrtWidth)
+            {
+                nWidth = nPrtWidth;
+            }
         }
         oLineRect.emplace(aPoint, Size(nWidth, rInf.GetLineWidth()));
     }

Reply via email to