diff options
author | Miklos Vajna <vmiklos@collabora.co.uk> | 2014-11-21 17:41:24 +0100 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.co.uk> | 2014-11-21 18:10:59 +0100 |
commit | 17e51f427b3f0cec74ac8e0a1b3f51189006ae6f (patch) | |
tree | 8ba685a9029fe5972a490abc58fcef69b843f7e9 | |
parent | e37e8f38d1f5c6bc427965dc535f1a64f0c8649c (diff) |
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
-rw-r--r-- | sw/qa/extras/ooxmlexport/data/header-border.docx | bin | 0 -> 15503 bytes | |||
-rw-r--r-- | sw/qa/extras/ooxmlexport/ooxmlexport5.cxx | 7 | ||||
-rw-r--r-- | sw/qa/extras/ooxmlexport/ooxmlsdrexport.cxx | 4 | ||||
-rw-r--r-- | writerfilter/source/dmapper/DomainMapper_Impl.cxx | 11 |
4 files changed, 20 insertions, 2 deletions
diff --git a/sw/qa/extras/ooxmlexport/data/header-border.docx b/sw/qa/extras/ooxmlexport/data/header-border.docx Binary files differnew file mode 100644 index 000000000000..18ee9f52ad50 --- /dev/null +++ b/sw/qa/extras/ooxmlexport/data/header-border.docx diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport5.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport5.cxx index 6d9bfc752d9a..fd9341c5f054 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 1432888887c6..3d7124111123 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 b4fa15bd45e4..5c3aaebbe1ec 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()) |