summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sw/qa/extras/uiwriter/uiwriter.cxx29
-rw-r--r--sw/source/core/layout/sectfrm.cxx16
2 files changed, 43 insertions, 2 deletions
diff --git a/sw/qa/extras/uiwriter/uiwriter.cxx b/sw/qa/extras/uiwriter/uiwriter.cxx
index d536d1e92f65..bef73ba6eeff 100644
--- a/sw/qa/extras/uiwriter/uiwriter.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter.cxx
@@ -204,6 +204,7 @@ public:
void testTableInSection();
void testTableInNestedSection();
void testLinesInSectionInTable();
+ void testLinesMoveBackwardsInSectionInTable();
CPPUNIT_TEST_SUITE(SwUiWriterTest);
CPPUNIT_TEST(testReplaceForward);
@@ -311,6 +312,7 @@ public:
CPPUNIT_TEST(testTableInSection);
CPPUNIT_TEST(testTableInNestedSection);
CPPUNIT_TEST(testLinesInSectionInTable);
+ CPPUNIT_TEST(testLinesMoveBackwardsInSectionInTable);
CPPUNIT_TEST_SUITE_END();
private:
@@ -3765,6 +3767,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.
diff --git a/sw/source/core/layout/sectfrm.cxx b/sw/source/core/layout/sectfrm.cxx
index ed15376a99ef..dcf60c14df3c 100644
--- a/sw/source/core/layout/sectfrm.cxx
+++ b/sw/source/core/layout/sectfrm.cxx
@@ -1726,11 +1726,24 @@ SwLayoutFrame *SwFrame::GetPrevSctLeaf( MakePageType )
if( bJump ) // Did we skip a blank page?
SwFlowFrame::SetMoveBwdJump( true );
+ SwSectionFrame *pSect = FindSctFrame();
+ if (!pCol && pSect && IsInTab() && !IsInTableInSection(this))
+ {
+ // We don't have a previous section yet, and we're in a
+ // section-in-table.
+ if (SwFlowFrame* pPrecede = pSect->GetPrecede())
+ {
+ // Our section has a precede, work with that.
+ if (pPrecede->GetFrame().IsLayoutFrame())
+ pCol = static_cast<SwLayoutFrame*>(&pPrecede->GetFrame());
+ }
+ }
+
// Within sections in tables or section in headers/footers there can
// be only one column change be made, one of the above shortcuts should
// have applied, also when the section has a pPrev.
// Now we even consider an empty column...
- OSL_ENSURE( FindSctFrame(), "GetNextSctLeaf: Missing SectionFrame" );
+ OSL_ENSURE( pSect, "GetNextSctLeaf: Missing SectionFrame" );
if( ( IsInTab() && !IsTabFrame() ) || FindFooterOrHeader() )
return pCol;
@@ -1738,7 +1751,6 @@ SwLayoutFrame *SwFrame::GetPrevSctLeaf( MakePageType )
// Precondition, which needs to be hold, is that the <this> frame can be
// inside a table, but then the found section frame <pSect> is also inside
// this table.
- SwSectionFrame *pSect = FindSctFrame();
// #i95698#
// A table cell containing directly a section does not break - see lcl_FindSectionsInRow(..)