[Libreoffice-commits] core.git: Branch 'libreoffice-6-0' - sw/qa sw/source

Luke Deller luke at deller.id.au
Mon Jul 9 09:13:49 UTC 2018


 sw/qa/extras/ww8export/data/tdf117885.doc |binary
 sw/qa/extras/ww8export/data/tdf118412.doc |binary
 sw/qa/extras/ww8export/ww8export2.cxx     |   29 +++++++++++++++++++++++++++++
 sw/source/filter/ww8/ww8par6.cxx          |   16 +++++++++++-----
 4 files changed, 40 insertions(+), 5 deletions(-)

New commits:
commit 3db1874044c24dadfb2f273d0e57e15bdcada1f5
Author: Luke Deller <luke at deller.id.au>
Date:   Thu May 31 23:16:26 2018 +1000

    Fix top margin in DOC import for tdf#117885
    
    When calculating the height of the top/bottom margin, we take into
    account whether the DOC section has a header/footer enabled.
    
    If the DOC section contains only a first-page header/footer, and the
    display of first-page header/footer in this section is not enabled,
    then we must consider the section to have no header/footer.
    
    (Also add a test case using the doc supplied by the reporter in
     tdf#117885)
    
    Change-Id: I8040298a2953b3f3fe8dd80bfd62db2304db938e
    Reviewed-on: https://gerrit.libreoffice.org/55135
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Miklos Vajna <vmiklos at collabora.co.uk>
    (cherry picked from commit 6c68e52532d45c97a83b2396bd40c98ade9b5bb4)
    
    Squashed with fixup commit from https://gerrit.libreoffice.org/56602
    for tdf#118412: DOC incorrect bottom page margin
    
    Change-Id: I8040298a2953b3f3fe8dd80bfd62db2304db938e
    Reviewed-on: https://gerrit.libreoffice.org/55466
    Reviewed-by: Michael Stahl <Michael.Stahl at cib.de>
    Tested-by: Michael Stahl <Michael.Stahl at cib.de>

diff --git a/sw/qa/extras/ww8export/data/tdf117885.doc b/sw/qa/extras/ww8export/data/tdf117885.doc
new file mode 100644
index 000000000000..bf8d0ef03d61
Binary files /dev/null and b/sw/qa/extras/ww8export/data/tdf117885.doc differ
diff --git a/sw/qa/extras/ww8export/data/tdf118412.doc b/sw/qa/extras/ww8export/data/tdf118412.doc
new file mode 100644
index 000000000000..ef9b26cb3af8
Binary files /dev/null and b/sw/qa/extras/ww8export/data/tdf118412.doc differ
diff --git a/sw/qa/extras/ww8export/ww8export2.cxx b/sw/qa/extras/ww8export/ww8export2.cxx
index 0695c309951b..03f55c6b0d78 100644
--- a/sw/qa/extras/ww8export/ww8export2.cxx
+++ b/sw/qa/extras/ww8export/ww8export2.cxx
@@ -741,6 +741,35 @@ DECLARE_OOXMLEXPORT_TEST( testObjectCrossReference, "object_cross_reference.odt"
     }
 }
 
+DECLARE_WW8EXPORT_TEST(testTdf117885, "tdf117885.doc")
+{
+    xmlDocPtr pXmlDoc = parseLayoutDump();
+
+    /* Get the vertical position of the paragraph containing the text "Start" */
+    sal_Int32 nParaA_Top = getXPath(pXmlDoc,
+        "/root/page/body/column[1]/body/txt[text()='Start']/infos/bounds", "top"
+        ).toInt32();
+
+    /* Get the vertical position of the paragraph containing the text "Top B" */
+    sal_Int32 nParaB_Top = getXPath(pXmlDoc,
+        "/root/page/body/column[2]/body/txt[text()='Top B']/infos/bounds", "top"
+        ).toInt32();
+
+    /* These two paragraphs are supposed to be at the top of the left
+     * and right columns respectively.  Check that they actually line up: */
+    CPPUNIT_ASSERT_EQUAL(nParaA_Top, nParaB_Top);
+}
+
+DECLARE_WW8EXPORT_TEST(testTdf118412, "tdf118412.doc")
+{
+    /* Check that the first page's bottom margin is 1.251cm (not 2.540cm) */
+    OUString sPageStyleName = getProperty<OUString>(getParagraph(1), "PageStyleName");
+    uno::Reference<style::XStyle> xPageStyle(
+        getStyles("PageStyles")->getByName(sPageStyleName), uno::UNO_QUERY);
+    sal_Int32 nBottomMargin = getProperty<sal_Int32>(xPageStyle, "BottomMargin");
+    CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(1251), nBottomMargin);
+}
+
 CPPUNIT_PLUGIN_IMPLEMENT();
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/filter/ww8/ww8par6.cxx b/sw/source/filter/ww8/ww8par6.cxx
index 249597032fa0..22141c52bad0 100644
--- a/sw/source/filter/ww8/ww8par6.cxx
+++ b/sw/source/filter/ww8/ww8par6.cxx
@@ -532,8 +532,17 @@ void wwSectionManager::GetPageULData(const wwSection &rSection,
         nWWUp += rSection.maSep.dzaGutter;
     }
 
-    rData.bHasHeader = (rSection.maSep.grpfIhdt &
-        (WW8_HEADER_EVEN | WW8_HEADER_ODD | WW8_HEADER_FIRST)) != 0;
+    /* Check whether this section has headers / footers */
+    sal_uInt16 nHeaderMask = WW8_HEADER_EVEN | WW8_HEADER_ODD;
+    sal_uInt16 nFooterMask = WW8_FOOTER_EVEN | WW8_FOOTER_ODD;
+    /* Ignore the presence of a first-page header/footer unless it is enabled */
+    if( rSection.HasTitlePage() )
+    {
+        nHeaderMask |= WW8_HEADER_FIRST;
+        nFooterMask |= WW8_FOOTER_FIRST;
+    }
+    rData.bHasHeader = (rSection.maSep.grpfIhdt & nHeaderMask) != 0;
+    rData.bHasFooter = (rSection.maSep.grpfIhdt & nFooterMask) != 0;
 
     if( rData.bHasHeader )
     {
@@ -554,9 +563,6 @@ void wwSectionManager::GetPageULData(const wwSection &rSection,
     else // no header -> just use Up as-is
         rData.nSwUp = std::abs(nWWUp);
 
-    rData.bHasFooter = (rSection.maSep.grpfIhdt &
-        (WW8_FOOTER_EVEN | WW8_FOOTER_ODD | WW8_FOOTER_FIRST)) != 0;
-
     if( rData.bHasFooter )
     {
         rData.nSwLo = nWWFBot;              // footer -> convert


More information about the Libreoffice-commits mailing list