From 294725dd76e6c5288d2e96f47c730a94c9b09037 Mon Sep 17 00:00:00 2001 From: Luke Deller Date: Thu, 31 May 2018 23:16:26 +1000 Subject: Fix top margin in DOC import for tdf#117885 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Reviewed-by: Miklos Vajna (cherry picked from commit 6c68e52532d45c97a83b2396bd40c98ade9b5bb4) Reviewed-on: https://gerrit.libreoffice.org/55465 Tested-by: Jenkins Reviewed-by: Xisco FaulĂ­ --- sw/qa/extras/ww8export/data/tdf117885.doc | Bin 0 -> 50688 bytes sw/qa/extras/ww8export/ww8export2.cxx | 19 +++++++++++++++++++ sw/source/filter/ww8/ww8par6.cxx | 16 +++++++++++----- 3 files changed, 30 insertions(+), 5 deletions(-) create mode 100644 sw/qa/extras/ww8export/data/tdf117885.doc 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/ww8export2.cxx b/sw/qa/extras/ww8export/ww8export2.cxx index f7ec720bce99..af3185d5e41b 100644 --- a/sw/qa/extras/ww8export/ww8export2.cxx +++ b/sw/qa/extras/ww8export/ww8export2.cxx @@ -821,6 +821,25 @@ DECLARE_WW8EXPORT_TEST(testTdf117503, "tdf117503.docx") CPPUNIT_ASSERT_EQUAL(2, getPages()); } +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); +} + 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 621a7060b4e7..227fe8937a0f 100644 --- a/sw/source/filter/ww8/ww8par6.cxx +++ b/sw/source/filter/ww8/ww8par6.cxx @@ -496,8 +496,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_HEADER_EVEN | WW8_HEADER_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 ) { @@ -518,9 +527,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 -- cgit v1.2.3