DOCX import: first page header should always set default headers as well
writerfilter imports a section with first and default headers / footers
as two page styles: a first page one and a follow one. In case we
nominally have a header on the first page only, we still need to enable
it in the follow page style as well, otherwise on export when we
recognize the first + follow chain as a single section, we'll end up
with a header that looses its header margin.
Change-Id: I4923daffefb243d2de4805a9931150ce4d9a6c81
diff --git a/sw/qa/extras/ooxmlexport/data/header-border.docx b/sw/qa/extras/ooxmlexport/data/header-border.docx
new file mode 100644
index 0000000..18ee9f5
--- /dev/null
+++ b/sw/qa/extras/ooxmlexport/data/header-border.docx
Binary files differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport5.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport5.cxx
index 6d9bfc7..fd9341c 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport5.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport5.cxx
@@ -700,6 +700,13 @@ DECLARE_OOXMLEXPORT_TEST(testFD083057, "fdo83057.docx")
assertXPath(pXmlDoc, "//mc:AlternateContent//w:sdt", 0);
}
DECLARE_OOXMLEXPORT_TEST(testHeaderBorder, "header-border.docx")
{
// This was 0, as header margin was lost during import.
if (xmlDocPtr pXmlDoc = parseExport("word/document.xml"))
assertXPath(pXmlDoc, "//w:pgMar", "header", "720");
}
CPPUNIT_PLUGIN_IMPLEMENT();
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/qa/extras/ooxmlexport/ooxmlsdrexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlsdrexport.cxx
index 1432888..3d71241 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlsdrexport.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlsdrexport.cxx
@@ -453,7 +453,7 @@ DECLARE_OOXMLEXPORT_TEST(testVMLData, "TestVMLData.docx")
{
// The problem was exporter was exporting vml data for shape in w:rPr element.
// vml data should not come under w:rPr element.
xmlDocPtr pXmlDoc = parseExport("word/header1.xml");
xmlDocPtr pXmlDoc = parseExport("word/header2.xml");
if (!pXmlDoc)
return;
CPPUNIT_ASSERT(getXPath(pXmlDoc, "/w:hdr/w:p/w:r/mc:AlternateContent/mc:Fallback/w:pict/v:rect", "stroked").match("f"));
@@ -463,7 +463,7 @@ DECLARE_OOXMLEXPORT_TEST(testImageData, "image_data.docx")
{
// The problem was exporter was exporting v:imagedata data for shape in w:pict as v:fill w element.
xmlDocPtr pXmlDoc = parseExport("word/header1.xml");
xmlDocPtr pXmlDoc = parseExport("word/header2.xml");
if (!pXmlDoc)
return;
CPPUNIT_ASSERT(getXPath(pXmlDoc, "/w:hdr/w:p/w:r/mc:AlternateContent/mc:Fallback/w:pict/v:rect/v:imagedata", "detectmouseclick").match("t"));
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
index b4fa15b..5c3aaeb 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
@@ -1478,6 +1478,17 @@ void DomainMapper_Impl::PushPageHeaderFooter(bool bHeader, SectionPropertyMap::P
rPropNameSupplier.GetName(ePropIsOn),
uno::makeAny(sal_True));
if (bFirst)
{
OUString aFollowStyle = xPageStyle->getPropertyValue("FollowStyle").get<OUString>();
if (GetPageStyles()->hasByName(aFollowStyle))
{
// This is a first page and has a follow style, then enable the header/footer there as well to be consistent.
uno::Reference<beans::XPropertySet> xFollowStyle(GetPageStyles()->getByName(aFollowStyle), uno::UNO_QUERY);
xFollowStyle->setPropertyValue(rPropNameSupplier.GetName(ePropIsOn), uno::makeAny(sal_True));
}
}
// If the 'Different Even & Odd Pages' flag is turned on - do not ignore it
// Even if the 'Even' header/footer is blank - the flag should be imported (so it would look in LO like in Word)
if (!bFirst && GetSettingsTable()->GetEvenAndOddHeaders())