summaryrefslogtreecommitdiff
path: root/sw/source/filter/ww8/docxexport.cxx
diff options
context:
space:
mode:
authorJustin Luth <jluth@mail.com>2022-07-22 13:31:33 -0400
committerJustin Luth <jluth@mail.com>2022-07-23 04:45:23 +0200
commitfa5d80106080fa305479758dd43d0defb684376a (patch)
tree9b041e24d6b2240a4bbcc1e983cf0356939411c3 /sw/source/filter/ww8/docxexport.cxx
parentb1a2f727ca99ecd3402d4b051b99cbfd24266e59 (diff)
related tdf#145998 docx export: fix writing blank headers/footers
That perpetual m_bHasHdr variable was really confusing, and it was completely misused (by me). This change should make it much easier to understand the purpose. To do this completely efficiently would require multiple variables for each type, but this is good enough. (It just means we might create a few more empty headers than is absolutely necessary.) Change-Id: I0686fe2af81203021ff1bd58d79d9cd3bc81a89f Reviewed-on: https://gerrit.libreoffice.org/c/core/+/137375 Tested-by: Jenkins Reviewed-by: Justin Luth <jluth@mail.com>
Diffstat (limited to 'sw/source/filter/ww8/docxexport.cxx')
-rw-r--r--sw/source/filter/ww8/docxexport.cxx29
1 files changed, 14 insertions, 15 deletions
diff --git a/sw/source/filter/ww8/docxexport.cxx b/sw/source/filter/ww8/docxexport.cxx
index eddb4c2ea147..88f397026ff7 100644
--- a/sw/source/filter/ww8/docxexport.cxx
+++ b/sw/source/filter/ww8/docxexport.cxx
@@ -263,6 +263,10 @@ void DocxExport::WriteHeadersFooters( sal_uInt8 nHeadFootFlags,
// Turn ON flag for 'Writing Headers \ Footers'
m_pAttrOutput->SetWritingHeaderFooter( true );
+ const bool bPrevSectionHadHeader = m_bHasHdr;
+ const bool bPrevSectionHadFooter = m_bHasFtr;
+ m_bHasHdr = m_bHasFtr = false;
+
// headers
if ( nHeadFootFlags & nsHdFtFlags::WW8_HEADER_EVEN )
WriteHeaderFooter( &rLeftHeaderFormat, true, "even" );
@@ -270,22 +274,19 @@ void DocxExport::WriteHeadersFooters( sal_uInt8 nHeadFootFlags,
{
if ( nHeadFootFlags & nsHdFtFlags::WW8_HEADER_ODD )
WriteHeaderFooter( &rFormat, true, "even" );
- else if ( m_bHasHdr && nBreakCode == 2 )
+ else if (bPrevSectionHadHeader && nBreakCode == 2)
WriteHeaderFooter( nullptr, true, "even" );
}
if ( nHeadFootFlags & nsHdFtFlags::WW8_HEADER_ODD )
WriteHeaderFooter( &rFormat, true, "default" );
+ else if (bPrevSectionHadHeader && nBreakCode == 2) // 2: nextPage
+ WriteHeaderFooter(nullptr, true, "default");
if ( nHeadFootFlags & nsHdFtFlags::WW8_HEADER_FIRST )
WriteHeaderFooter( &rFirstPageFormat, true, "first" );
-
- if( (nHeadFootFlags & (nsHdFtFlags::WW8_HEADER_EVEN
- | nsHdFtFlags::WW8_HEADER_ODD
- | nsHdFtFlags::WW8_HEADER_FIRST)) == 0
- && m_bHasHdr && nBreakCode == 2 ) // 2: nexPage
- WriteHeaderFooter( nullptr, true, "default" );
-
+ else if (bPrevSectionHadHeader && nBreakCode == 2)
+ WriteHeaderFooter(nullptr, true, "first");
// footers
if ( nHeadFootFlags & nsHdFtFlags::WW8_FOOTER_EVEN )
@@ -294,21 +295,19 @@ void DocxExport::WriteHeadersFooters( sal_uInt8 nHeadFootFlags,
{
if ( nHeadFootFlags & nsHdFtFlags::WW8_FOOTER_ODD )
WriteHeaderFooter( &rFormat, false, "even" );
- else if ( m_bHasFtr && nBreakCode == 2 )
+ else if (bPrevSectionHadFooter && nBreakCode == 2)
WriteHeaderFooter( nullptr, false, "even");
}
if ( nHeadFootFlags & nsHdFtFlags::WW8_FOOTER_ODD )
WriteHeaderFooter( &rFormat, false, "default" );
+ else if (bPrevSectionHadFooter && nBreakCode == 2)
+ WriteHeaderFooter(nullptr, false, "default");
if ( nHeadFootFlags & nsHdFtFlags::WW8_FOOTER_FIRST )
WriteHeaderFooter( &rFirstPageFormat, false, "first" );
-
- if( (nHeadFootFlags & (nsHdFtFlags::WW8_FOOTER_EVEN
- | nsHdFtFlags::WW8_FOOTER_ODD
- | nsHdFtFlags::WW8_FOOTER_FIRST)) == 0
- && m_bHasFtr && nBreakCode == 2 ) // 2: nexPage
- WriteHeaderFooter( nullptr, false, "default");
+ else if (bPrevSectionHadFooter && nBreakCode == 2)
+ WriteHeaderFooter(nullptr, false, "first");
// Turn OFF flag for 'Writing Headers \ Footers'
m_pAttrOutput->SetWritingHeaderFooter( false );