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 <Michael.Stahl@cib.de>
This commit is contained in:
Michael Stahl
2019-03-01 18:24:40 +01:00
parent b891226dce
commit 60ea01af8c

View File

@@ -54,6 +54,7 @@
#include <charfmt.hxx>
#include <strings.hrc>
#include <bookmrk.hxx>
#include <crossrefbookmark.hxx>
#include <memory>
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<sw::mark::CrossRefHeadingBookmark const*>(&rBkmk));
}