summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2017-03-21 09:03:53 +0100
committerMiklos Vajna <vmiklos@collabora.co.uk>2017-03-21 10:47:24 +0000
commitb6e62dc0dc2b284c825f1182a67bb2f9259a30ce (patch)
treeae3742a6c8357db90a17efba6f930f1e84459c10
parent63f7da77985674ddf59bb566bdada9c41893e822 (diff)
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 <vmiklos@collabora.co.uk> Tested-by: Jenkins <ci@libreoffice.org>
-rw-r--r--sw/qa/extras/ooxmlexport/data/tdf106492.docxbin0 -> 7896 bytes
-rw-r--r--sw/qa/extras/ooxmlexport/ooxmlexport9.cxx7
-rw-r--r--sw/source/filter/ww8/docxattributeoutput.cxx8
3 files changed, 14 insertions, 1 deletions
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
--- /dev/null
+++ b/sw/qa/extras/ooxmlexport/data/tdf106492.docx
Binary files 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 );