sw/qa/extras/ooxmlexport/data/footer-margin-lost.docx |binary
 sw/qa/extras/ooxmlexport/ooxmlexport16.cxx            |   10 ++++++++++
 sw/source/filter/ww8/docxattributeoutput.cxx          |   11 +++++++++++
 3 files changed, 21 insertions(+)

New commits:
commit 80b360085f5974fbb3abe49a88b20f4d39704fb5
Author:     Miklos Vajna <vmik...@collabora.com>
AuthorDate: Mon Jan 25 21:05:12 2021 +0100
Commit:     Miklos Vajna <vmik...@collabora.com>
CommitDate: Tue Jan 26 09:03:17 2021 +0100

    tdf#134605 DOCX export: fix unexpected loss of footer margin
    
    Regression from commit 51534ac2b9747975945acb6a1e1ba5cc6d73f5c2
    (tdf#127778 DOCX import: fix unexpected heading on non-first page ...,
    2020-05-11), which replaced an import fix with an export fix.
    
    What was missed there is the import fix handled both headers and
    footers, while the export fix only handled headers.
    
    Fix the problem by doing the same mapping for footers: if a follow page
    style has no footer, but the first page style has, then take the margin
    from that one. The import side did the opposite of this already.
    
    Change-Id: Ibb191db4136bce0ad5e4bf14dcea15f5955bd298
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/109927
    Tested-by: Jenkins
    Reviewed-by: Miklos Vajna <vmik...@collabora.com>

diff --git a/sw/qa/extras/ooxmlexport/data/footer-margin-lost.docx 
b/sw/qa/extras/ooxmlexport/data/footer-margin-lost.docx
new file mode 100644
index 000000000000..d6a9d7bd8df9
Binary files /dev/null and 
b/sw/qa/extras/ooxmlexport/data/footer-margin-lost.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport16.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport16.cxx
index 77dda6a55c73..316a1c080b00 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport16.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport16.cxx
@@ -45,6 +45,16 @@ DECLARE_OOXMLEXPORT_TEST(testTdf139580, "tdf139580.odt")
     CPPUNIT_ASSERT_EQUAL(1, getPages());
 }
 
+DECLARE_OOXMLEXPORT_EXPORTONLY_TEST(testFooterMarginLost, 
"footer-margin-lost.docx")
+{
+    xmlDocUniquePtr pXmlDoc = parseExport();
+    // Without the accompanying fix in place, this test would have failed with:
+    // - Expected: 709
+    // - Actual  : 0
+    // i.e. import + export lost the footer margin value.
+    assertXPath(pXmlDoc, "/w:document/w:body/w:sectPr/w:pgMar", "footer", 
"709");
+}
+
 DECLARE_OOXMLEXPORT_TEST(testTdf138953, "croppedAndRotated.odt")
 {
     CPPUNIT_ASSERT_EQUAL(1, getShapes());
diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx 
b/sw/source/filter/ww8/docxattributeoutput.cxx
index 36cf9f570c78..43ee8a245a39 100644
--- a/sw/source/filter/ww8/docxattributeoutput.cxx
+++ b/sw/source/filter/ww8/docxattributeoutput.cxx
@@ -8836,6 +8836,17 @@ void DocxAttributeOutput::FormatULSpace( const 
SvxULSpaceItem& rULSpace )
         sal_Int32 nFooter = 0;
         if ( aDistances.HasFooter() )
             nFooter = sal_Int32( aDistances.dyaHdrBottom );
+        else if (m_rExport.m_pFirstPageFormat)
+        {
+            HdFtDistanceGlue 
aFirstPageDistances(m_rExport.m_pFirstPageFormat->GetAttrSet());
+            if (aFirstPageDistances.HasFooter())
+            {
+                // The follow page style has no footer, but the first page 
style has. In Word terms,
+                // this means that the footer margin of "the" section is 
coming from the first page
+                // style.
+                nFooter = sal_Int32(aFirstPageDistances.dyaHdrBottom);
+            }
+        }
 
         // Page Bottom
         m_pageMargins.nBottom = aDistances.dyaBottom;
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to