sw/qa/extras/uiwriter/uiwriter2.cxx | 33 +++++++++++++++++++++++++++++++++ sw/source/core/undo/unredln.cxx | 6 ++++++ 2 files changed, 39 insertions(+)
New commits: commit fe1fc9615511994ac128e52f9ad1cda4e86188f5 Author: László Németh <nem...@numbertext.org> AuthorDate: Thu Oct 22 17:49:56 2020 +0200 Commit: László Németh <nem...@numbertext.org> CommitDate: Sat Oct 24 14:26:51 2020 +0200 tdf#137684 sw ChangesInMargin: fix crash on Undo of characters deleted by pressing Delete. Follow-up of commit 62596e7f52492305b49dab70bdf81daf82b930a1 (tdf#137526 sw ChangesInMargin: fix Undo of deleted words). Change-Id: I1a3c3e446f67de94ff3b750b45421f9bc93e5cc2 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/104691 Tested-by: Jenkins Reviewed-by: László Németh <nem...@numbertext.org> diff --git a/sw/qa/extras/uiwriter/uiwriter2.cxx b/sw/qa/extras/uiwriter/uiwriter2.cxx index b59708576b6b..0d3b1aee820c 100644 --- a/sw/qa/extras/uiwriter/uiwriter2.cxx +++ b/sw/qa/extras/uiwriter/uiwriter2.cxx @@ -1892,6 +1892,39 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest2, testTdf137526) CPPUNIT_ASSERT(!pWrtShell->GetViewOptions()->IsShowChangesInMargin()); } +CPPUNIT_TEST_FIXTURE(SwUiWriterTest2, testTdf137684) +{ + load(DATA_DIRECTORY, "tdf132160.odt"); + + SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument*>(mxComponent.get()); + CPPUNIT_ASSERT(pTextDoc); + + // switch on "Show changes in margin" mode + dispatchCommand(mxComponent, ".uno:ShowChangesInMargin", {}); + + SwWrtShell* const pWrtShell = pTextDoc->GetDocShell()->GetWrtShell(); + CPPUNIT_ASSERT(pWrtShell->GetViewOptions()->IsShowChangesInMargin()); + + // select and delete a word letter by letter + for (int i = 0; i <= 10; ++i) + { + dispatchCommand(mxComponent, ".uno:Delete", {}); + } + CPPUNIT_ASSERT(getParagraph(1)->getString().startsWith("support")); + + // this would crash due to bad redline range + for (int i = 0; i <= 10; ++i) + { + dispatchCommand(mxComponent, ".uno:Undo", {}); + } + // TODO: fix order of the characters after Undo + CPPUNIT_ASSERT(getParagraph(1)->getString().startsWith(" noitpyrcnE")); + + // switch off "Show changes in margin" mode + dispatchCommand(mxComponent, ".uno:ShowChangesInMargin", {}); + CPPUNIT_ASSERT(!pWrtShell->GetViewOptions()->IsShowChangesInMargin()); +} + CPPUNIT_TEST_FIXTURE(SwUiWriterTest2, testTdf52391) { load(DATA_DIRECTORY, "tdf52391.fodt"); diff --git a/sw/source/core/undo/unredln.cxx b/sw/source/core/undo/unredln.cxx index d2d60b60841f..1d48861a4432 100644 --- a/sw/source/core/undo/unredln.cxx +++ b/sw/source/core/undo/unredln.cxx @@ -97,6 +97,12 @@ void SwUndoRedline::UndoImpl(::sw::UndoRedoContext & rContext) if ( pRedline && !pRedline->IsVisible() ) { const SwRedlineTable& rTable = rDoc.getIDocumentRedlineAccess().GetRedlineTable(); + // skip older redlines in the same position + while ( nCurRedlinePos + 1 < rTable.size() && + *pRedline->GetPoint() == *rTable[nCurRedlinePos + 1]->GetPoint() ) + { + ++nCurRedlinePos; + } SwRangeRedline * pHiddenRedline( rTable[nCurRedlinePos] ); pHiddenRedline->Show(0, rTable.GetPos(pHiddenRedline), /*bForced=*/true); pHiddenRedline->Show(1, rTable.GetPos(pHiddenRedline), /*bForced=*/true); _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits