summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2014-11-21 18:22:53 +0100
committerMiklos Vajna <vmiklos@collabora.co.uk>2014-11-21 18:40:53 +0100
commit5009ed5eaff6769375d8d0423a98fe8d1a31e0d1 (patch)
treea06bc6d0b33c1dd3275538031656b660dbdf7b6f
parent7a0bfcbce147eff61dc9b7d243b571dd34110df8 (diff)
DOCX export: fix page border spacing in case of headers/footers
It is clear that Word/Writer has different page margin / border spacing models: in Word, the page margin includes everything and border spacing is a subset of that, in Writer the real distance between the body frame and the page frame is the sum of the two. What was less clear is what headers / footers add to this mix. It turns out that in case we have a header as well, then for large borders, we need to count the difference of the page frame and the header frame, not the difference of the page frame and the body frame. Change-Id: I3c828eeec2df461985110064ab0bf21b36594095
-rw-r--r--sw/qa/extras/ooxmlexport/ooxmlexport5.cxx8
-rw-r--r--sw/source/filter/ww8/docxattributeoutput.cxx11
2 files changed, 17 insertions, 2 deletions
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport5.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport5.cxx
index fd9341c5f054..26f521b0873c 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport5.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport5.cxx
@@ -702,9 +702,15 @@ DECLARE_OOXMLEXPORT_TEST(testFD083057, "fdo83057.docx")
DECLARE_OOXMLEXPORT_TEST(testHeaderBorder, "header-border.docx")
{
- // This was 0, as header margin was lost during import.
if (xmlDocPtr pXmlDoc = parseExport("word/document.xml"))
+ {
+ // This was 0, as header margin was lost during import.
assertXPath(pXmlDoc, "//w:pgMar", "header", "720");
+ // This was 33: 33 points -> 660 twips. We counted 900 - 240 (distance
+ // of page and body frame) instead of 720 - 240 (distance of page and
+ // header frame).
+ assertXPath(pXmlDoc, "//w:pgBorders/w:top", "space", "24");
+ }
}
CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx
index cacbe97beb80..4e4dccd175ba 100644
--- a/sw/source/filter/ww8/docxattributeoutput.cxx
+++ b/sw/source/filter/ww8/docxattributeoutput.cxx
@@ -5499,8 +5499,17 @@ void DocxAttributeOutput::SectionPageBorders( const SwFrmFmt* pFmt, const SwFrmF
aOutputBorderOptions.aShadowLocation = pShadowItem->GetLocation();
}
+ // By top margin, impl_borders() means the distance between the top of the page and the header frame.
+ PageMargins aMargins = m_pageMargins;
+ HdFtDistanceGlue aGlue(pFmt->GetAttrSet());
+ if (aGlue.HasHeader())
+ aMargins.nPageMarginTop = aGlue.dyaHdrTop;
+ // Ditto for bottom margin.
+ if (aGlue.HasFooter())
+ aMargins.nPageMarginBottom = aGlue.dyaHdrBottom;
+
std::map<sal_uInt16, css::table::BorderLine2> aEmptyMap; // empty styles map
- impl_borders( m_pSerializer, rBox, aOutputBorderOptions, &m_pageMargins,
+ impl_borders( m_pSerializer, rBox, aOutputBorderOptions, &aMargins,
aEmptyMap );
m_pSerializer->endElementNS( XML_w, XML_pgBorders );