summaryrefslogtreecommitdiff
path: root/sw/source/filter/ww8/docxattributeoutput.cxx
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2017-06-13 09:05:06 +0200
committerMiklos Vajna <vmiklos@collabora.co.uk>2017-06-13 11:30:43 +0200
commit2a73e7d88c19cab69733a4f6433d8576856285ac (patch)
treed448994c4d8877a8cddccc7d4302bb3797b97264 /sw/source/filter/ww8/docxattributeoutput.cxx
parent16265a1f84f0ac7c16beee6a3591653eaaa90323 (diff)
tdf#107618 DOCX export: fix missing header when doc ends with section
See commit b6e62dc0dc2b284c825f1182a67bb2f9259a30ce (tdf#106492 DOCX export: fix duplicated section break at doc end, 2017-03-21) for the context, this is one more case where it's not OK to suppress the two section breaks at the end of a document, since the suppressed section break is the one that provides the headers / footers. Change-Id: I4abd7895436e4d2e08fd7b7ff4aabbac8d65f7fb Reviewed-on: https://gerrit.libreoffice.org/38721 Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk> Tested-by: Jenkins <ci@libreoffice.org>
Diffstat (limited to 'sw/source/filter/ww8/docxattributeoutput.cxx')
-rw-r--r--sw/source/filter/ww8/docxattributeoutput.cxx41
1 files changed, 30 insertions, 11 deletions
diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx
index ba3bf43875c8..bd667fe58d17 100644
--- a/sw/source/filter/ww8/docxattributeoutput.cxx
+++ b/sw/source/filter/ww8/docxattributeoutput.cxx
@@ -118,6 +118,7 @@
#include <docsh.hxx>
#include <docary.hxx>
#include <fmtclbl.hxx>
+#include <fmthdft.hxx>
#include <IDocumentSettingAccess.hxx>
#include <IDocumentStylePoolAccess.hxx>
#include <IDocumentRedlineAccess.hxx>
@@ -5495,25 +5496,43 @@ void DocxAttributeOutput::SectionBreak( sal_uInt8 nC, const WW8_SepInfo* pSectio
// DocxExport::WriteMainText(), don't duplicate that here.
SwNodeIndex aCurrentNode(m_rExport.m_pCurPam->GetNode());
SwNodeIndex aLastNode(m_rExport.m_pDoc->GetNodes().GetEndOfContent(), -1);
+ bool bEmit = aCurrentNode != aLastNode;
- // Need to still emit an empty section at the end of the
- // document in case balanced columns are wanted, since the last
- // section in Word is always balanced.
- sal_uInt16 nColumns = 1;
- bool bBalance = false;
- if (const SwSectionFormat* pFormat = pSectionInfo->pSectionFormat)
+ if (!bEmit)
{
- if (pFormat != reinterpret_cast<SwSectionFormat*>(sal_IntPtr(-1)))
+ // Need to still emit an empty section at the end of the
+ // document in case balanced columns are wanted, since the last
+ // section in Word is always balanced.
+ sal_uInt16 nColumns = 1;
+ bool bBalance = false;
+ if (const SwSectionFormat* pFormat = pSectionInfo->pSectionFormat)
{
- nColumns = pFormat->GetCol().GetNumCols();
- const SwFormatNoBalancedColumns& rNoBalanced = pFormat->GetBalancedColumns();
- bBalance = !rNoBalanced.GetValue();
+ if (pFormat != reinterpret_cast<SwSectionFormat*>(sal_IntPtr(-1)))
+ {
+ nColumns = pFormat->GetCol().GetNumCols();
+ const SwFormatNoBalancedColumns& rNoBalanced = pFormat->GetBalancedColumns();
+ bBalance = !rNoBalanced.GetValue();
+ }
+ }
+ bEmit = (nColumns > 1 && bBalance);
+ }
+
+ if (!bEmit)
+ {
+ // Also need to emit if the page desc contains a header or
+ // footer, otherwise we go with the properties of the
+ // section (and not the page style), which never has
+ // headers/footers.
+ if (const SwPageDesc* pPageDesc = pSectionInfo->pPageDesc)
+ {
+ const auto& rMaster = pPageDesc->GetMaster();
+ bEmit = rMaster.GetHeader().IsActive() || rMaster.GetFooter().IsActive();
}
}
// don't add section properties if this will be the first
// paragraph in the document
- if ( !m_bParagraphOpened && !m_bIsFirstParagraph && (aCurrentNode != aLastNode || (nColumns > 1 && bBalance)))
+ if ( !m_bParagraphOpened && !m_bIsFirstParagraph && bEmit )
{
// Create a dummy paragraph if needed
m_pSerializer->startElementNS( XML_w, XML_p, FSEND );