sw/qa/extras/ooxmlexport/data/tdf106492.docx |binary sw/qa/extras/ooxmlexport/ooxmlexport9.cxx | 7 +++++++ sw/source/filter/ww8/docxattributeoutput.cxx | 8 +++++++- 3 files changed, 14 insertions(+), 1 deletion(-)
New commits: commit b6e62dc0dc2b284c825f1182a67bb2f9259a30ce Author: Miklos Vajna <vmik...@collabora.co.uk> Date: Tue Mar 21 09:03:53 2017 +0100 tdf#106492 DOCX export: fix duplicated section break at doc end There is always a section break at the end of a DOCX document, so in the rare case when there is no text node between the end of a Writer section and the end of the document make sure no duplicated section break is written. Change-Id: I3fcd852c1a63e2d707822ad08603e2d37386e439 Reviewed-on: https://gerrit.libreoffice.org/35499 Reviewed-by: Miklos Vajna <vmik...@collabora.co.uk> Tested-by: Jenkins <c...@libreoffice.org> diff --git a/sw/qa/extras/ooxmlexport/data/tdf106492.docx b/sw/qa/extras/ooxmlexport/data/tdf106492.docx new file mode 100644 index 000000000000..72ff4be5d0a6 Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/tdf106492.docx differ diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx index 678e0923637d..e7bc9cbb03ff 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx @@ -420,6 +420,13 @@ DECLARE_OOXMLEXPORT_TEST(testUnbalancedColumns, "unbalanced-columns.docx") CPPUNIT_ASSERT_EQUAL(true, getProperty<bool>(xTextSections->getByIndex(2), "DontBalanceTextColumns")); } +DECLARE_OOXMLEXPORT_TEST(testTdf106492, "tdf106492.docx") +{ + if (xmlDocPtr pXmlDoc = parseExport()) + // This was 4: an additional sectPr was added to the document. + assertXPath(pXmlDoc, "//w:sectPr", 3); +} + 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 c4057cd4766b..88acbf8b93e7 100644 --- a/sw/source/filter/ww8/docxattributeoutput.cxx +++ b/sw/source/filter/ww8/docxattributeoutput.cxx @@ -5449,9 +5449,15 @@ void DocxAttributeOutput::SectionBreak( sal_uInt8 nC, const WW8_SepInfo* pSectio case msword::PageBreak: if ( pSectionInfo ) { + // Detect when the current node is the last node in the + // document: the last section is written explicitly in + // DocxExport::WriteMainText(), don't duplicate that here. + SwNodeIndex aCurrentNode(m_rExport.m_pCurPam->GetNode()); + SwNodeIndex aLastNode(m_rExport.m_pDoc->GetNodes().GetEndOfContent(), -1); + // don't add section properties if this will be the first // paragraph in the document - if ( !m_bParagraphOpened && !m_bIsFirstParagraph) + if ( !m_bParagraphOpened && !m_bIsFirstParagraph && aCurrentNode != aLastNode) { // Create a dummy paragraph if needed m_pSerializer->startElementNS( XML_w, XML_p, FSEND ); _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits