summaryrefslogtreecommitdiff
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-14 09:06:57 +0200
commit378b97e8f071485ee1086b66f1ab94fedb8b8d49 (patch)
treee72ad55e869984af0616b28814fb538952bcf780
parent1fa8a49fed1bf44b2449a8825d6f6ec16f60e6f5 (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. (cherry picked from commit 2a73e7d88c19cab69733a4f6433d8576856285ac) Change-Id: I4abd7895436e4d2e08fd7b7ff4aabbac8d65f7fb Reviewed-on: https://gerrit.libreoffice.org/38742 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk>
-rw-r--r--sw/qa/extras/ooxmlexport/data/tdf107618.docbin0 -> 28160 bytes
-rw-r--r--sw/qa/extras/ooxmlexport/ooxmlexport9.cxx7
-rw-r--r--sw/source/filter/ww8/docxattributeoutput.cxx41
3 files changed, 37 insertions, 11 deletions
diff --git a/sw/qa/extras/ooxmlexport/data/tdf107618.doc b/sw/qa/extras/ooxmlexport/data/tdf107618.doc
new file mode 100644
index 000000000000..8a6972f45b8e
--- /dev/null
+++ b/sw/qa/extras/ooxmlexport/data/tdf107618.doc
Binary files differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx
index 38582f9f93f0..d63a6183c5ba 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx
@@ -581,6 +581,13 @@ DECLARE_OOXMLEXPORT_TEST(testTdf107684, "tdf107684.odt")
assertXPath(pXmlDoc, "//w:style[@w:styleId='Heading1']/w:pPr/w:outlineLvl", 1);
}
+DECLARE_OOXMLEXPORT_TEST(testTdf107618, "tdf107618.doc")
+{
+ // This was false, header was lost on export.
+ uno::Reference<beans::XPropertySet> xPageStyle(getStyles("PageStyles")->getByName("Standard"), uno::UNO_QUERY);
+ CPPUNIT_ASSERT_EQUAL(true, getProperty<bool>(xPageStyle, "HeaderIsOn"));
+}
+
CPPUNIT_PLUGIN_IMPLEMENT();
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx
index 89597ef3baf6..b42aa62f47db 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 );