summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke Deller <luke@deller.id.au>2018-05-31 23:16:26 +1000
committerMichael Stahl <Michael.Stahl@cib.de>2018-07-09 11:13:27 +0200
commit3db1874044c24dadfb2f273d0e57e15bdcada1f5 (patch)
tree37833d0dd62720c0db10e0f4e81750188c20856c
parenta900c91447897e725fc0cf674205eee633b326eb (diff)
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@libreoffice.org> Reviewed-by: Miklos Vajna <vmiklos@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@cib.de> Tested-by: Michael Stahl <Michael.Stahl@cib.de>
-rw-r--r--sw/qa/extras/ww8export/data/tdf117885.docbin0 -> 50688 bytes
-rw-r--r--sw/qa/extras/ww8export/data/tdf118412.docbin0 -> 51200 bytes
-rw-r--r--sw/qa/extras/ww8export/ww8export2.cxx29
-rw-r--r--sw/source/filter/ww8/ww8par6.cxx16
4 files changed, 40 insertions, 5 deletions
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
--- /dev/null
+++ b/sw/qa/extras/ww8export/data/tdf117885.doc
Binary files 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
--- /dev/null
+++ b/sw/qa/extras/ww8export/data/tdf118412.doc
Binary files 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