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

Miklos Vajna vmiklos at collabora.co.uk
Fri Feb 13 05:50:59 PST 2015


 sw/qa/extras/uiwriter/uiwriter.cxx |   15 +++++++++++++++
 sw/source/core/text/frmform.cxx    |    8 ++++++++
 2 files changed, 23 insertions(+)

New commits:
commit 7e33cce05b2df3f1761bcc66606c4d3b2b2671e9
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Fri Feb 13 13:47:30 2015 +0100

    cp#1000115 SwTxtFrm: don't join follow just because it has no content
    
    The problem was that the bugdoc had a table, and inside the table there
    was a long paragraph that flows to the next page, but only the paragraph
    mark of it does so. We first split the frame to have space for the
    paragraph mark, but later decided that all the content would fit the
    first frame, and this way the last hard line break and the paragraph
    mark was painted on each other.
    
    This is normally not a problem without tables, because
    SwTxtFrm::FormatAdjust() just calls SplitFrm(), sets its nNew flag to
    non-zero make sure that later SwTxtFrm::_AdjustFollow() doesn't try to
    join it, and we're ready. However, when the paragraph is inside a table,
    then the paragraph was formatted multiple times, and next time when we
    already had a follow nNew was not set, so even if there was a correct
    split first, the new frame was joined later.
    
    Fix the problem by explicitly setting nNew for the "in a table and
    paragraph ends with a hard line break" case, that way we don't blindly
    join the frame, only in case there is enough space for the follow in the
    master.
    
    Change-Id: Iede654740dcb0d8aa768d742ee330208291a383a

diff --git a/sw/qa/extras/uiwriter/uiwriter.cxx b/sw/qa/extras/uiwriter/uiwriter.cxx
index 0fb6c82..0cce5f4 100644
--- a/sw/qa/extras/uiwriter/uiwriter.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter.cxx
@@ -79,6 +79,7 @@ public:
     void testFdo85876();
     void testFdo87448();
     void testTdf68183();
+    void testCp1000115();
 
     CPPUNIT_TEST_SUITE(SwUiWriterTest);
     CPPUNIT_TEST(testReplaceForward);
@@ -110,6 +111,7 @@ public:
     CPPUNIT_TEST(testFdo85876);
     CPPUNIT_TEST(testFdo87448);
     CPPUNIT_TEST(testTdf68183);
+    CPPUNIT_TEST(testCp1000115);
 
     CPPUNIT_TEST_SUITE_END();
 
@@ -831,6 +833,19 @@ void SwUiWriterTest::testTdf68183()
     CPPUNIT_ASSERT_EQUAL(true, pTxtNode->GetSwAttrSet().HasItem(RES_PARATR_RSID));
 }
 
+void SwUiWriterTest::testCp1000115()
+{
+    createDoc("cp1000115.fodt");
+    xmlDocPtr pXmlDoc = parseLayoutDump();
+    xmlXPathObjectPtr pXmlObj = getXPathNode(pXmlDoc, "/root/page[2]/body/tab/row/cell[2]/txt");
+    xmlNodeSetPtr pXmlNodes = pXmlObj->nodesetval;
+    // This was 1: the long paragraph in the B1 cell did flow over to the
+    // second page, so there was only one paragraph in the second cell of the
+    // second page.
+    CPPUNIT_ASSERT_EQUAL(2, xmlXPathNodeSetGetLength(pXmlNodes));
+    xmlXPathFreeObject(pXmlObj);
+}
+
 CPPUNIT_TEST_SUITE_REGISTRATION(SwUiWriterTest);
 CPPUNIT_PLUGIN_IMPLEMENT();
 
diff --git a/sw/source/core/text/frmform.cxx b/sw/source/core/text/frmform.cxx
index da6d622..7e426fc 100644
--- a/sw/source/core/text/frmform.cxx
+++ b/sw/source/core/text/frmform.cxx
@@ -1056,6 +1056,14 @@ void SwTxtFrm::FormatAdjust( SwTxtFormatter &rLine,
             {
                 nNew |= 3;
             }
+            else if (FindTabFrm() && nEnd > 0 && rLine.GetInfo().GetChar(nEnd - 1) == CH_BREAK)
+            {
+                // We are in a table, the paragraph has a follow and the text
+                // ends with a hard line break. Don't join the follow just
+                // because the follow would have no content, we may still need it
+                // for the paragraph mark.
+                nNew |= 1;
+            }
             CHG_OFFSET( GetFollow(), nEnd )
             GetFollow()->ManipOfst( nEnd );
         }


More information about the Libreoffice-commits mailing list