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.

Change-Id: I3bb23680937580179b8d37c940ea14e0f80fc7f4
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/168009
Reviewed-by: Miklos Vajna <[email protected]>
Tested-by: Jenkins
diff --git a/sw/qa/core/layout/paintfrm.cxx b/sw/qa/core/layout/paintfrm.cxx
index 8e7154d..a5213c5 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 b139a75..a0d5f0d 100644
--- a/sw/source/core/layout/paintfrm.cxx
+++ b/sw/source/core/layout/paintfrm.cxx
@@ -5772,7 +5772,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() )
@@ -5803,6 +5803,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()));
    }