diff options
author | Miklos Vajna <vmiklos@collabora.co.uk> | 2017-07-14 14:20:36 +0200 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.co.uk> | 2017-07-14 15:14:32 +0200 |
commit | 850bf99e7d1abcf2e0cce731b6715f87420d0ee6 (patch) | |
tree | 79985a7b2d26106c1489efce1965fa459cf89fa1 /sw/qa | |
parent | 62ee21cb463d80a28c4c41a488f85e07abafbc69 (diff) |
tdf#108524 sw: handle sections inside tables in SwFrame::GetPrevSctLeaf()
This addresses the sub-problem described in comment 12 of the bug, i.e.
text frames are now moved to the first page from the second one when
text frames are deleted on the first page.
Change-Id: Ic0ede45381fb84b13d1ac02e4d1f39d817650616
Reviewed-on: https://gerrit.libreoffice.org/39946
Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk>
Tested-by: Jenkins <ci@libreoffice.org>
Diffstat (limited to 'sw/qa')
-rw-r--r-- | sw/qa/extras/uiwriter/uiwriter.cxx | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/sw/qa/extras/uiwriter/uiwriter.cxx b/sw/qa/extras/uiwriter/uiwriter.cxx index d69f682cb8fa..042ae9cee4a8 100644 --- a/sw/qa/extras/uiwriter/uiwriter.cxx +++ b/sw/qa/extras/uiwriter/uiwriter.cxx @@ -259,6 +259,7 @@ public: void testTableInSection(); void testTableInNestedSection(); void testLinesInSectionInTable(); + void testLinesMoveBackwardsInSectionInTable(); CPPUNIT_TEST_SUITE(SwUiWriterTest); CPPUNIT_TEST(testReplaceForward); @@ -404,6 +405,7 @@ public: CPPUNIT_TEST(testTableInSection); CPPUNIT_TEST(testTableInNestedSection); CPPUNIT_TEST(testLinesInSectionInTable); + CPPUNIT_TEST(testLinesMoveBackwardsInSectionInTable); CPPUNIT_TEST_SUITE_END(); private: @@ -4983,6 +4985,33 @@ void SwUiWriterTest::testLinesInSectionInTable() assertXPath(pXmlDoc, "/root/page[2]/body/tab/row/cell/section", 1); } +void SwUiWriterTest::testLinesMoveBackwardsInSectionInTable() +{ + // Assert that paragraph "4" is on page 1 and "5" is on page 2. + SwDoc* pDoc = createDoc("lines-in-section-in-table.odt"); + xmlDocPtr pXmlDoc = parseLayoutDump(); + assertXPath(pXmlDoc, "/root/page", 2); + sal_uInt32 nPara4Node = getXPath(pXmlDoc, "/root/page[1]/body/tab/row/cell[1]/section/txt[last()]", "txtNodeIndex").toUInt32(); + CPPUNIT_ASSERT_EQUAL(OUString("4"), pDoc->GetNodes()[nPara4Node]->GetTextNode()->GetText()); + sal_uInt32 nPara5Node = getXPath(pXmlDoc, "/root/page[2]/body/tab/row/cell[1]/section/txt[1]", "txtNodeIndex").toUInt32(); + CPPUNIT_ASSERT_EQUAL(OUString("5"), pDoc->GetNodes()[nPara5Node]->GetTextNode()->GetText()); + + // Remove paragraph "4". + SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell(); + while (pWrtShell->GetCursor()->GetNode().GetIndex() < nPara4Node) + pWrtShell->Down(/*bSelect=*/false); + pWrtShell->EndPara(); + pWrtShell->Up(/*bSelect=*/true); + pWrtShell->DelLeft(); + + // Assert that paragraph "5" is now moved back to page 1 and is the last paragraph there. + discardDumpedLayout(); + pXmlDoc = parseLayoutDump(); + sal_uInt32 nPage1LastNode = getXPath(pXmlDoc, "/root/page[1]/body/tab/row/cell[1]/section/txt[last()]", "txtNodeIndex").toUInt32(); + // This was "3", paragraph "4" was deleted, but "5" was not moved backwards from page 2. + CPPUNIT_ASSERT_EQUAL(OUString("5"), pDoc->GetNodes()[nPage1LastNode]->GetTextNode()->GetText()); +} + void SwUiWriterTest::testTableInSection() { // The document has a section, containing a table that spans over 2 pages. |