sw/qa/writerfilter/cppunittests/filter/WriterFilter.cxx                      | 
  26 ++++++++++
 sw/qa/writerfilter/cppunittests/filter/data/inline-endnote-and-footnote.docx 
|binary
 sw/source/writerfilter/filter/WriterFilter.cxx                               | 
   1 
 3 files changed, 27 insertions(+)

New commits:
commit 1ae5ea3f78cca11ba18f2dd1a06f875263336a3b
Author:     Miklos Vajna <vmik...@collabora.com>
AuthorDate: Tue May 21 08:15:53 2024 +0200
Commit:     Miklos Vajna <vmik...@collabora.com>
CommitDate: Tue May 21 10:42:40 2024 +0200

    tdf#160984 sw continuous endnotes: enable DOCX import
    
    This was working for DOC already.
    
    For DOCX, this was already enabled once with commit
    f9982c24066d6dd2f938cc20176af0f196bc018f (tdf#58521 DOCX import: enable
    ContinuousEndnotes compat flag, 2021-07-13), but then it was reverted
    later with commit commit eeda1b35a6e87d5349545464da33d997c52f15e3
    (Revert "tdf#58521 DOCX import: enable ContinuousEndnotes compat flag",
    2021-08-10), because of tdf#143456.
    
    Enable it again, now that the section-based layout seems good enough to
    handle larger number of endnotes, e.g. the 48 endnotes from tdf#143456.
    
    Change-Id: Id221f31f9208e84db2c358546d4d6ceea991b6b3
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/167881
    Tested-by: Jenkins
    Reviewed-by: Miklos Vajna <vmik...@collabora.com>

diff --git a/sw/qa/writerfilter/cppunittests/filter/WriterFilter.cxx 
b/sw/qa/writerfilter/cppunittests/filter/WriterFilter.cxx
index 10b8cab57a45..e084f0fa52ee 100644
--- a/sw/qa/writerfilter/cppunittests/filter/WriterFilter.cxx
+++ b/sw/qa/writerfilter/cppunittests/filter/WriterFilter.cxx
@@ -50,6 +50,32 @@ CPPUNIT_TEST_FIXTURE(Test, testDoNotMirrorRtlDrawObjs)
     // i.e. the shape was on the left margin.
     CPPUNIT_ASSERT_GREATER(nBodyRight, nShapeLeft);
 }
+
+CPPUNIT_TEST_FIXTURE(Test, testInlineEndnoteAndFootnoteDOCX)
+{
+    // Given a DOCX file with an endnote and then a footnote:
+    loadFromFile(u"inline-endnote-and-footnote.docx");
+
+    // When laying out that document:
+    uno::Reference<frame::XModel> xModel(mxComponent, uno::UNO_QUERY);
+    css::uno::Reference<qa::XDumper> xDumper(xModel->getCurrentController(), 
uno::UNO_QUERY);
+    OString aDump = xDumper->dump("layout").toUtf8();
+    auto pCharBuffer = reinterpret_cast<const xmlChar*>(aDump.getStr());
+    xmlDocUniquePtr pXmlDoc(xmlParseDoc(pCharBuffer));
+
+    // Then make sure the footnote is below the endnote:
+    // Without the accompanying fix in place, this test would have failed with:
+    // - xpath should match exactly 1 node
+    // i.e. the endnote was also in the footnote container, not at the end of 
the body text.
+    sal_Int32 nEndnoteTop
+        = getXPath(pXmlDoc, 
"/root/page/body/section/column/ftncont/ftn/infos/bounds"_ostr,
+                   "top"_ostr)
+              .toInt32();
+    sal_Int32 nFootnoteTop
+        = getXPath(pXmlDoc, "/root/page/ftncont/ftn/infos/bounds"_ostr, 
"top"_ostr).toInt32();
+    // Endnote at the end of body text, footnote at page bottom.
+    CPPUNIT_ASSERT_LESS(nFootnoteTop, nEndnoteTop);
+}
 }
 
 CPPUNIT_PLUGIN_IMPLEMENT();
diff --git 
a/sw/qa/writerfilter/cppunittests/filter/data/inline-endnote-and-footnote.docx 
b/sw/qa/writerfilter/cppunittests/filter/data/inline-endnote-and-footnote.docx
new file mode 100644
index 000000000000..84343b8afa45
Binary files /dev/null and 
b/sw/qa/writerfilter/cppunittests/filter/data/inline-endnote-and-footnote.docx 
differ
diff --git a/sw/source/writerfilter/filter/WriterFilter.cxx 
b/sw/source/writerfilter/filter/WriterFilter.cxx
index 742ae2bbeee2..ee8131f95ae3 100644
--- a/sw/source/writerfilter/filter/WriterFilter.cxx
+++ b/sw/source/writerfilter/filter/WriterFilter.cxx
@@ -333,6 +333,7 @@ void WriterFilter::setTargetDocument(const 
uno::Reference<lang::XComponent>& xDo
     // rely on default for HyphenateURLs=false
     // rely on default for 
APPLY_TEXT_ATTR_TO_EMPTY_LINE_AT_END_OF_PARAGRAPH=true
     xSettings->setPropertyValue("DoNotMirrorRtlDrawObjs", uno::Any(true));
+    xSettings->setPropertyValue("ContinuousEndnotes", uno::Any(true));
 }
 
 void WriterFilter::setSourceDocument(const uno::Reference<lang::XComponent>& 
xDoc)

Reply via email to