sw/qa/extras/uiwriter/data/table-in-table.fodt | 29 +++++++++++++++++++++++++ sw/qa/extras/uiwriter/uiwriter9.cxx | 16 ++++++++++++- sw/source/core/crsr/crsrsh.cxx | 12 +++++++--- 3 files changed, 53 insertions(+), 4 deletions(-)
New commits: commit 278845dddefbd1359b8bd28f87c42f4124be50ca Author: Mike Kaganski <mike.kagan...@collabora.com> AuthorDate: Thu May 2 09:11:25 2024 +0500 Commit: Xisco Fauli <xiscofa...@libreoffice.org> CommitDate: Tue May 7 10:06:53 2024 +0200 tdf#160898: check for nullptr Regression after commit d81379db730a163c5ff75d4f3a3cddbd7b5eddda (tdf#154877 sw: generalise ExtendedSelectAll(), 2023-05-09) Change-Id: I9289171647fca8bd1b696399ff7c43a2ac7b8b30 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/166990 Reviewed-by: Mike Kaganski <mike.kagan...@collabora.com> Tested-by: Jenkins Signed-off-by: Xisco Fauli <xiscofa...@libreoffice.org> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/166997 Reviewed-by: Michael Stahl <michael.st...@allotropia.de> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/167037 diff --git a/sw/qa/extras/uiwriter/data/table-in-table.fodt b/sw/qa/extras/uiwriter/data/table-in-table.fodt new file mode 100644 index 000000000000..e055d343b847 --- /dev/null +++ b/sw/qa/extras/uiwriter/data/table-in-table.fodt @@ -0,0 +1,29 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<office:document xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0" office:version="1.3" office:mimetype="application/vnd.oasis.opendocument.text"> + <office:automatic-styles> + <style:style style:name="border" style:family="table-cell"> + <style:table-cell-properties fo:padding="1mm" fo:border="0.5pt solid #000000"/> + </style:style> + </office:automatic-styles> + <office:body> + <office:text> + <text:p/> + <table:table> + <table:table-column/> + <table:table-row> + <table:table-cell table:style-name="border"> + <table:table> + <table:table-column/> + <table:table-row> + <table:table-cell table:style-name="border"/> + </table:table-row> + </table:table> + <text:p/> + </table:table-cell> + </table:table-row> + </table:table> + <text:p/> + </office:text> + </office:body> +</office:document> \ No newline at end of file diff --git a/sw/qa/extras/uiwriter/uiwriter9.cxx b/sw/qa/extras/uiwriter/uiwriter9.cxx index 9f961b1def60..bd69d2616a6d 100644 --- a/sw/qa/extras/uiwriter/uiwriter9.cxx +++ b/sw/qa/extras/uiwriter/uiwriter9.cxx @@ -109,7 +109,21 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest9, testTdf159816) xTransfer->PrivateDrop(*pWrtShell, ptTo, /*bMove=*/true, /*bXSelection=*/true); } -} // end of anonymouse namespace +CPPUNIT_TEST_FIXTURE(SwUiWriterTest9, testTdf160898) +{ + // Given a document with a 1-cell table in another 1-cell table: + createSwDoc("table-in-table.fodt"); + SwXTextDocument* pXTextDocument = dynamic_cast<SwXTextDocument*>(mxComponent.get()); + SwDocShell* pDocShell = pXTextDocument->GetDocShell(); + SwWrtShell* pWrtShell = pDocShell->GetWrtShell(); + + // Move to the normally hidden paragraph inside the outer table cell, following the inner table + pWrtShell->Down(false, 2); + // Without the fix, this would crash: + pWrtShell->SelAll(); +} + +} // end of anonymous namespace CPPUNIT_PLUGIN_IMPLEMENT(); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/crsr/crsrsh.cxx b/sw/source/core/crsr/crsrsh.cxx index 04b263cda754..b7b7a8997f8c 100644 --- a/sw/source/core/crsr/crsrsh.cxx +++ b/sw/source/core/crsr/crsrsh.cxx @@ -738,9 +738,15 @@ bool SwCursorShell::MoveStartText() SwTableNode const*const pTable(pStartNode->FindTableNode()); m_pCurrentCursor->GetPoint()->Assign(*pStartNode); GetDoc()->GetNodes().GoNext(m_pCurrentCursor->GetPoint()); - while (m_pCurrentCursor->GetPoint()->GetNode().FindTableNode() != pTable - && (!pTable || pTable->GetIndex() < m_pCurrentCursor->GetPoint()->GetNode().FindTableNode()->GetIndex()) - && MoveOutOfTable()); + while (auto* pFoundTable = m_pCurrentCursor->GetPoint()->GetNode().FindTableNode()) + { + if (pFoundTable == pTable) + break; + if (pTable && pTable->GetIndex() >= pFoundTable->GetIndex()) + break; + if (!MoveOutOfTable()) + break; + } UpdateCursor(SwCursorShell::SCROLLWIN|SwCursorShell::CHKRANGE|SwCursorShell::READONLY); return old != *m_pCurrentCursor->GetPoint(); }