[Libreoffice-commits] core.git: sw/qa sw/source

Tamas Bunth tamas.bunth at collabora.co.uk
Thu Dec 14 22:00:31 UTC 2017


 sw/qa/extras/ooxmlexport/data/parasplit-on-section-border.odt |binary
 sw/qa/extras/ooxmlexport/ooxmlexport11.cxx                    |   13 +++++
 sw/source/filter/ww8/wrtw8nds.cxx                             |   26 +++++++---
 3 files changed, 33 insertions(+), 6 deletions(-)

New commits:
commit 2cf785591805395746d394ac56030a617e651a48
Author: Tamas Bunth <tamas.bunth at collabora.co.uk>
Date:   Thu Dec 14 15:20:29 2017 +0100

    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 at libreoffice.org>
    Reviewed-by: Tamás Bunth <btomi96 at gmail.com>

diff --git a/sw/qa/extras/ooxmlexport/data/parasplit-on-section-border.odt b/sw/qa/extras/ooxmlexport/data/parasplit-on-section-border.odt
new file mode 100644
index 000000000000..1d0b96f8bb96
Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/parasplit-on-section-border.odt differ
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();
 


More information about the Libreoffice-commits mailing list