summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2015-02-13 13:47:30 +0100
committerMiklos Vajna <vmiklos@collabora.co.uk>2015-02-13 14:49:56 +0100
commit7e33cce05b2df3f1761bcc66606c4d3b2b2671e9 (patch)
tree2a93146bb21679198a906c6d93599b93d3e2deb4 /sw
parentcba3f9a144938317ff6c29144222a08ee6a169db (diff)
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
Diffstat (limited to 'sw')
-rw-r--r--sw/qa/extras/uiwriter/uiwriter.cxx15
-rw-r--r--sw/source/core/text/frmform.cxx8
2 files changed, 23 insertions, 0 deletions
diff --git a/sw/qa/extras/uiwriter/uiwriter.cxx b/sw/qa/extras/uiwriter/uiwriter.cxx
index 0fb6c821a881..0cce5f4705a2 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 da6d6220e44d..7e426fc6f4b6 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 );
}