diff options
author | Tamas Bunth <tamas.bunth@collabora.co.uk> | 2017-12-14 15:20:29 +0100 |
---|---|---|
committer | Tamás Bunth <btomi96@gmail.com> | 2017-12-14 22:57:22 +0100 |
commit | 2cf785591805395746d394ac56030a617e651a48 (patch) | |
tree | 47af98cd1d8f566ebaaecf0881d030b3cce64b29 | |
parent | f8399f442d7bf5abf3861e0285997d13f355eb6a (diff) |
tdf#41650 doc(x) export split paragraph
Fix for documents with one paragraph only.
Add unit test for splitting paragraph on section border.
Change-Id: I224f60ed362deae7b67dde79e04f26f949de034a
Reviewed-on: https://gerrit.libreoffice.org/46457
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Tamás Bunth <btomi96@gmail.com>
-rw-r--r-- | sw/qa/extras/ooxmlexport/data/parasplit-on-section-border.odt | bin | 0 -> 17550 bytes | |||
-rw-r--r-- | sw/qa/extras/ooxmlexport/ooxmlexport11.cxx | 13 | ||||
-rw-r--r-- | sw/source/filter/ww8/wrtw8nds.cxx | 26 |
3 files changed, 33 insertions, 6 deletions
diff --git a/sw/qa/extras/ooxmlexport/data/parasplit-on-section-border.odt b/sw/qa/extras/ooxmlexport/data/parasplit-on-section-border.odt Binary files differnew file mode 100644 index 000000000000..1d0b96f8bb96 --- /dev/null +++ b/sw/qa/extras/ooxmlexport/data/parasplit-on-section-border.odt diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx index a4796900f9bd..d705a7e013be 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx @@ -99,6 +99,19 @@ DECLARE_OOXMLEXPORT_TEST(testTdf67207_MERGEFIELD, "mailmerge.docx") CPPUNIT_ASSERT_EQUAL(OUString("com.sun.star.text.fieldmaster.DataBase.Name"), sValue); } +DECLARE_OOXMLEXPORT_TEST(testParagraphSplitOnSectionBorder, "parasplit-on-section-border.odt") +{ + xmlDocPtr pXmlDoc = parseExport("word/document.xml"); + + if(!pXmlDoc) + return; + + // Test document has only one paragraph. After splitting, it should contain + // two of them. + assertXPath(pXmlDoc, "//w:sectPr", 2); + assertXPath(pXmlDoc, "//w:p", 2); +} + DECLARE_OOXMLEXPORT_TEST(testTdf44832_testSectionWithDifferentHeader, "tdf44832_section_new_header.odt") { xmlDocPtr pXmlDoc = parseExport("word/document.xml"); diff --git a/sw/source/filter/ww8/wrtw8nds.cxx b/sw/source/filter/ww8/wrtw8nds.cxx index a9cf06d2974a..5f1efbc0d59b 100644 --- a/sw/source/filter/ww8/wrtw8nds.cxx +++ b/sw/source/filter/ww8/wrtw8nds.cxx @@ -2665,18 +2665,32 @@ void MSWordExportBase::OutputTextNode( SwTextNode& rNode ) while ( nAktPos < nEnd ); // if paragraph is split, put the section break between the parts - // else check if section break needed after the paragraph - if( !bNeedParaSplit || *aBreakIt != rNode.GetText().getLength() ) + if( bNeedParaSplit && *aBreakIt != rNode.GetText().getLength() ) { - AttrOutput().SectionBreaks(rNode); SwNodeIndex aNextIndex( rNode, 1 ); const SwNode& pNextNode = aNextIndex.GetNode(); - if( pNextNode.IsTextNode() && bNeedParaSplit ) + // if there is a next node, use its attributes to create the new + // section + if( pNextNode.IsTextNode() ) + { + const SwTextNode& rNextNode = *static_cast<SwTextNode*>( + &aNextIndex.GetNode() ); + OutputSectionBreaks(rNextNode.GetpSwAttrSet(), rNextNode); + } + else if (pNextNode.IsEndNode() ) { - SectionBreaksAndFrames( *static_cast<SwTextNode*>( - &aNextIndex.GetNode() )); + // In this case the same paragraph holds the next page style + // too. + const SwPageDesc* pNextPageDesc = m_pAktPageDesc->GetFollow(); + assert(pNextPageDesc); + PrepareNewPageDesc( rNode.GetpSwAttrSet(), rNode, nullptr , pNextPageDesc); } } + else + { + // else check if section break needed after the paragraph + AttrOutput().SectionBreaks(rNode); + } AttrOutput().StartParagraphProperties(); |