sw/qa/extras/uiwriter/uiwriter5.cxx | 2 -- sw/source/core/undo/untbl.cxx | 15 ++++++++++++++- 2 files changed, 14 insertions(+), 3 deletions(-)
New commits: commit 873af30a36504751c6923d4235abd4de040e0001 Author: Michael Stahl <michael.st...@allotropia.de> AuthorDate: Thu Mar 14 12:14:28 2024 +0100 Commit: Michael Stahl <michael.st...@allotropia.de> CommitDate: Thu Mar 14 14:16:08 2024 +0100 sw: fix ~SwIndexReg assert in testTdf149498 The problem is that a SwNavigationMgr thingy has a cursor in one of the table cells, and the text node is moved to the undo nodes array in SwUndoTableCpyTable::AddBoxBefore() and deleted in SwUndoTableCpyTable::UndoImpl(). SwUndoTableCpyTable needs to move the cursors out of the way because SwUndoDelete doesn't do it. Change-Id: I75e271c84a6624ffb0df151b171acb1e1f743928 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/164807 Tested-by: Jenkins Reviewed-by: Michael Stahl <michael.st...@allotropia.de> diff --git a/sw/qa/extras/uiwriter/uiwriter5.cxx b/sw/qa/extras/uiwriter/uiwriter5.cxx index c6353f980d29..702f6d7dd30e 100644 --- a/sw/qa/extras/uiwriter/uiwriter5.cxx +++ b/sw/qa/extras/uiwriter/uiwriter5.cxx @@ -3007,7 +3007,6 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest5, testTdf156487) assertXPath(pXmlDoc, "/metafile/push/push/push/textarray/text"_ostr, 1); } -#ifndef DBG_UTIL CPPUNIT_TEST_FIXTURE(SwUiWriterTest5, testTdf149498) { // load a table, and delete the first column with enabled change tracking: @@ -3023,7 +3022,6 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest5, testTdf149498) // this would crash due to bookmark over cell boundary dispatchCommand(mxComponent, ".uno:Undo", {}); } -#endif CPPUNIT_TEST_FIXTURE(SwUiWriterTest5, testTdf150673_RedlineTableColumnDeletionWithExport) { diff --git a/sw/source/core/undo/untbl.cxx b/sw/source/core/undo/untbl.cxx index e38abcecd000..5c5c88f74c24 100644 --- a/sw/source/core/undo/untbl.cxx +++ b/sw/source/core/undo/untbl.cxx @@ -2599,11 +2599,17 @@ void SwUndoTableCpyTable::AddBoxBefore( const SwTableBox& rBox, bool bDelContent if( bDelContent ) { SwNodeIndex aInsIdx( *rBox.GetSttNd(), 1 ); - pDoc->GetNodes().MakeTextNode( aInsIdx.GetNode(), pDoc->GetDfltTextFormatColl() ); + SwTextNode *const pNewNode(pDoc->GetNodes().MakeTextNode(aInsIdx.GetNode(), pDoc->GetDfltTextFormatColl())); SwPaM aPam( aInsIdx.GetNode(), *rBox.GetSttNd()->EndOfSectionNode() ); if( !pDoc->getIDocumentRedlineAccess().IsRedlineOn() ) + { + { // move cursors to new node which precedes aPam + SwPosition const pos(*pNewNode, 0); + ::PaMCorrAbs(aPam, pos); + } pEntry->pUndo = std::make_unique<SwUndoDelete>(aPam, SwDeleteFlags::Default, true); + } } pEntry->pBoxNumAttr = std::make_unique<SfxItemSetFixed< @@ -2627,6 +2633,13 @@ void SwUndoTableCpyTable::AddBoxAfter( const SwTableBox& rBox, const SwNodeIndex SwDoc* pDoc = rBox.GetFrameFormat()->GetDoc(); DEBUG_REDLINE( pDoc ) + { // move cursors to first node which was inserted + SwPaM pam(SwNodeIndex(*rBox.GetSttNd(), 1)); + assert(pam.GetPoint()->GetNode().IsTextNode()); + pam.SetMark(); + pam.Move(fnMoveForward, GoInContent); + ::PaMCorrAbs(pam, *pam.GetPoint()); + } if( pDoc->getIDocumentRedlineAccess().IsRedlineOn() ) { SwPosition aTmpPos( rIdx );