From 60ea01af8c57f9b03ee1da1196284fa10025c22c Mon Sep 17 00:00:00 2001 From: Michael Stahl Date: Fri, 1 Mar 2019 18:24:40 +0100 Subject: [PATCH] tdf#123313 sw: workaround Undo problem with ToX Update The problem is that when ToX is updated, CrossRefHeadingBookmarks will be created for the heading nodes, and SwUndoInsBookmark will be created at that time, but then nodes will be created for later entries in the ToX and if the heading is below the ToX then the node index in SwUndoInsBookmark will not match the node index of the CrossRefHeadingBookmark. Thus SwHistoryBookmark::IsEqualBookmark() will cause the mark to be skipped during Undo instead of deleted, and then it can cause trouble. Work around that by having SwHistoryBookmark::IsEqualBookmark() not check the position if it's a CrossRefHeadingBookmark. Change-Id: I9277978844837accdda35195a863c6163a839b6e Reviewed-on: https://gerrit.libreoffice.org/68596 Tested-by: Jenkins Reviewed-by: Michael Stahl --- sw/source/core/undo/rolbck.cxx | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/sw/source/core/undo/rolbck.cxx b/sw/source/core/undo/rolbck.cxx index b8048539f459..51a4bcdd813f 100644 --- a/sw/source/core/undo/rolbck.cxx +++ b/sw/source/core/undo/rolbck.cxx @@ -54,6 +54,7 @@ #include #include #include +#include #include OUString SwHistoryHint::GetDescription() const @@ -669,9 +670,11 @@ void SwHistoryBookmark::SetInDoc( SwDoc* pDoc, bool ) bool SwHistoryBookmark::IsEqualBookmark(const ::sw::mark::IMark& rBkmk) { - return m_nNode == rBkmk.GetMarkPos().nNode.GetIndex() - && m_nContent == rBkmk.GetMarkPos().nContent.GetIndex() - && m_aName == rBkmk.GetName(); + return m_aName == rBkmk.GetName() + && ( ( m_nNode == rBkmk.GetMarkPos().nNode.GetIndex() + && m_nContent == rBkmk.GetMarkPos().nContent.GetIndex()) + // tdf#123313 these are created in middle of ToX update + || dynamic_cast(&rBkmk)); }