diff options
author | Justin Luth <justin_luth@sil.org> | 2018-12-29 08:31:20 +0300 |
---|---|---|
committer | Justin Luth <justin_luth@sil.org> | 2018-12-29 11:38:00 +0100 |
commit | 7815b4d2a2c89261ad6424c7fe3ce0c453e4d02c (patch) | |
tree | cd52c899c81c84034a26109ba5103f5fb63eb4df /sw | |
parent | 648f24f5d1dae3f0fd5b132d68a5e39066f2572d (diff) |
tdf#113849 ooxmlexport: even headers/footers for both or none.
For DOCX, there is a single setting to indicate the use of even
headers/footers. So, if either one of these has a separate
even, then create an even for both.
In 2017, nBreakCode was used to write an empty footer to
prevent inheriting any previously defined footer.
So I also removed the obsolete debug.
Change-Id: I3ec4a399103679092e6a6ec3a7ae9b1ae303cc3e
Reviewed-on: https://gerrit.libreoffice.org/65699
Tested-by: Jenkins
Reviewed-by: Justin Luth <justin_luth@sil.org>
Diffstat (limited to 'sw')
-rw-r--r-- | sw/qa/extras/ooxmlexport/data/tdf113849_evenAndOddHeaders.odt | bin | 0 -> 24355 bytes | |||
-rw-r--r-- | sw/qa/extras/ooxmlexport/ooxmlexport11.cxx | 17 | ||||
-rw-r--r-- | sw/source/filter/ww8/docxexport.cxx | 25 |
3 files changed, 36 insertions, 6 deletions
diff --git a/sw/qa/extras/ooxmlexport/data/tdf113849_evenAndOddHeaders.odt b/sw/qa/extras/ooxmlexport/data/tdf113849_evenAndOddHeaders.odt Binary files differnew file mode 100644 index 000000000000..d9aa0ae23541 --- /dev/null +++ b/sw/qa/extras/ooxmlexport/data/tdf113849_evenAndOddHeaders.odt diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx index 986414ff64a6..66599999f9a4 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx @@ -203,6 +203,23 @@ DECLARE_OOXMLEXPORT_TEST(testTdf112694, "tdf112694.docx") CPPUNIT_ASSERT(!getProperty<bool>(aPageStyle, "HeaderIsOn")); } +DECLARE_OOXMLEXPORT_TEST(testTdf113849_evenAndOddHeaders, "tdf113849_evenAndOddHeaders.odt") +{ + CPPUNIT_ASSERT_EQUAL_MESSAGE("Header2 text", OUString("L. J. Kendall"), parseDump("/root/page[2]/header/txt")); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Footer2 text", OUString("*"), parseDump("/root/page[2]/footer/txt")); + + CPPUNIT_ASSERT_EQUAL_MESSAGE("Header3 text", OUString("Shadow Hunt"), parseDump("/root/page[3]/header/txt")); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Footer3 text", OUString("*"), parseDump("/root/page[3]/footer/txt")); + + CPPUNIT_ASSERT_EQUAL_MESSAGE("Header4 text", OUString("L. J. Kendall"), parseDump("/root/page[4]/header/txt")); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Footer4 text", OUString("*"), parseDump("/root/page[4]/footer/txt")); + + CPPUNIT_ASSERT_EQUAL_MESSAGE("Footer5 text", OUString(""), parseDump("/root/page[5]/footer/txt")); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Footer6 text", OUString(""), parseDump("/root/page[6]/footer/txt")); + + //CPPUNIT_ASSERT_EQUAL_MESSAGE("Number of pages", 6, getPages() ); +} + DECLARE_OOXMLEXPORT_TEST(testTdf118361_RTLfootnoteSeparator, "tdf118361_RTLfootnoteSeparator.docx") { uno::Any aPageStyle = getStyles("PageStyles")->getByName("Standard"); diff --git a/sw/source/filter/ww8/docxexport.cxx b/sw/source/filter/ww8/docxexport.cxx index 0965d01942a9..097195c9cc20 100644 --- a/sw/source/filter/ww8/docxexport.cxx +++ b/sw/source/filter/ww8/docxexport.cxx @@ -251,12 +251,24 @@ void DocxExport::WriteHeadersFooters( sal_uInt8 nHeadFootFlags, const SwFrameFormat& rFormat, const SwFrameFormat& rLeftFormat, const SwFrameFormat& rFirstPageFormat, sal_uInt8 nBreakCode ) { m_nHeadersFootersInSection = 1; + + // document setting indicating the requirement of EVEN and ODD for both headers and footers + if ( nHeadFootFlags & ( nsHdFtFlags::WW8_FOOTER_EVEN | nsHdFtFlags::WW8_HEADER_EVEN )) + m_aSettings.evenAndOddHeaders = true; + // Turn ON flag for 'Writing Headers \ Footers' m_pAttrOutput->SetWritingHeaderFooter( true ); // headers if ( nHeadFootFlags & nsHdFtFlags::WW8_HEADER_EVEN ) WriteHeaderFooter( &rLeftFormat, true, "even" ); + else if ( m_aSettings.evenAndOddHeaders ) + { + if ( nHeadFootFlags & nsHdFtFlags::WW8_HEADER_ODD ) + WriteHeaderFooter( &rFormat, true, "even" ); + else if ( m_bHasHdr && nBreakCode == 2 ) + WriteHeaderFooter( nullptr, true, "even" ); + } if ( nHeadFootFlags & nsHdFtFlags::WW8_HEADER_ODD ) WriteHeaderFooter( &rFormat, true, "default" ); @@ -274,6 +286,13 @@ void DocxExport::WriteHeadersFooters( sal_uInt8 nHeadFootFlags, // footers if ( nHeadFootFlags & nsHdFtFlags::WW8_FOOTER_EVEN ) WriteHeaderFooter( &rLeftFormat, false, "even" ); + else if ( m_aSettings.evenAndOddHeaders ) + { + if ( nHeadFootFlags & nsHdFtFlags::WW8_FOOTER_ODD ) + WriteHeaderFooter( &rFormat, false, "even" ); + else if ( m_bHasFtr && nBreakCode == 2 ) + WriteHeaderFooter( nullptr, false, "even"); + } if ( nHeadFootFlags & nsHdFtFlags::WW8_FOOTER_ODD ) WriteHeaderFooter( &rFormat, false, "default" ); @@ -287,14 +306,8 @@ void DocxExport::WriteHeadersFooters( sal_uInt8 nHeadFootFlags, && m_bHasFtr && nBreakCode == 2 ) // 2: nexPage WriteHeaderFooter( nullptr, false, "default"); - if ( nHeadFootFlags & ( nsHdFtFlags::WW8_FOOTER_EVEN | nsHdFtFlags::WW8_HEADER_EVEN )) - m_aSettings.evenAndOddHeaders = true; - // Turn OFF flag for 'Writing Headers \ Footers' m_pAttrOutput->SetWritingHeaderFooter( false ); -#if OSL_DEBUG_LEVEL > 1 - fprintf( stderr, "DocxExport::WriteHeadersFooters() - nBreakCode introduced, but ignored\n" ); -#endif } void DocxExport::OutputField( const SwField* pField, ww::eField eFieldType, const OUString& rFieldCmd, FieldFlags nMode ) |