[Libreoffice-commits] core.git: sw/qa sw/source
Libreoffice Gerrit user
logerrit at kemper.freedesktop.org
Sat Dec 29 10:38:20 UTC 2018
sw/qa/extras/ooxmlexport/data/tdf113849_evenAndOddHeaders.odt |binary
sw/qa/extras/ooxmlexport/ooxmlexport11.cxx | 17 ++++++
sw/source/filter/ww8/docxexport.cxx | 25 +++++++---
3 files changed, 36 insertions(+), 6 deletions(-)
New commits:
commit 7815b4d2a2c89261ad6424c7fe3ce0c453e4d02c
Author: Justin Luth <justin_luth at sil.org>
AuthorDate: Sat Dec 29 08:31:20 2018 +0300
Commit: Justin Luth <justin_luth at sil.org>
CommitDate: Sat Dec 29 11:38:00 2018 +0100
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 at sil.org>
diff --git a/sw/qa/extras/ooxmlexport/data/tdf113849_evenAndOddHeaders.odt b/sw/qa/extras/ooxmlexport/data/tdf113849_evenAndOddHeaders.odt
new file mode 100644
index 000000000000..d9aa0ae23541
Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/tdf113849_evenAndOddHeaders.odt differ
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 )
More information about the Libreoffice-commits
mailing list