summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorMichael Stahl <mstahl@redhat.com>2017-07-28 23:44:53 +0200
committerCaolán McNamara <caolanm@redhat.com>2017-08-02 10:13:04 +0200
commitdbd147d3acbe537d56765b966ae5003e51172c19 (patch)
tree0084afc1381067ad4961ac5beed82fd789cac08a /sw
parentadf049390cceb11df6ba438f30138d6f92d13b41 (diff)
tdf#105705 sw: sort bookmarks in ContentIdxStoreImpl::RestoreBkmks()
The problem here is that the SplitNode() calls in SwRTFReader::Read() destroy the order of the bookmarks, which causes an assert later from the std::lower_bound() when a new mark is created. The 2 marks that cause the problem are: SwPosition (node 5, offset 0) SwPosition (node 5, offset 0), SwPosition (node 5, offset 0) During the 2 SplitNode calls, the second one is corrected by ContentIdxStore and remains on 5, but the first one is not and becomes: SwPosition (node 7, offset 0) ContentIdxStoreImpl::SaveBkmks() does different things when a mark position is exactly on the parameter position: if it has only one position, it is ignored, but if it has a second position, then both its positions are corrected. It is not possible to change the sort order so that marks with one position are sorted behind marks with 2 positions, because while SplitNode() corrects marks "backward", JoinNode() uses ContentIdxStore to correct marks "forward"; hence manually sort the marks. Change-Id: If5b35f18bfd47ffe98c0f67e84d380ca801411a3 (cherry picked from commit f2d2093b2198bd4c65475a60329a5a6a7a8575f1) Reviewed-on: https://gerrit.libreoffice.org/40543 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'sw')
-rw-r--r--sw/source/core/doc/CntntIdxStore.cxx6
-rw-r--r--sw/source/core/inc/MarkManager.hxx2
2 files changed, 8 insertions, 0 deletions
diff --git a/sw/source/core/doc/CntntIdxStore.cxx b/sw/source/core/doc/CntntIdxStore.cxx
index 14775d1e050a..89628faa0918 100644
--- a/sw/source/core/doc/CntntIdxStore.cxx
+++ b/sw/source/core/doc/CntntIdxStore.cxx
@@ -22,6 +22,7 @@
#include <doc.hxx>
#include <IDocumentRedlineAccess.hxx>
#include <IDocumentLayoutAccess.hxx>
+#include <MarkManager.hxx>
#include <docary.hxx>
#include <editsh.hxx>
#include <fmtanchr.hxx>
@@ -265,6 +266,11 @@ void ContentIdxStoreImpl::RestoreBkmks(SwDoc* pDoc, updater_t& rUpdater)
SetRightMarkPos(pMark, aEntry.m_bOther, &aNewPos);
}
}
+ if (!m_aBkmkEntries.empty())
+ { // tdf#105705 sort bookmarks because SaveBkmks special handling of
+ // "bMarkPosEqual" may destroy sort order
+ dynamic_cast<sw::mark::MarkManager*>(pMarkAccess)->sortMarks();
+ }
}
void ContentIdxStoreImpl::SaveRedlines(SwDoc* pDoc, sal_uLong nNode, sal_Int32 nContent)
diff --git a/sw/source/core/inc/MarkManager.hxx b/sw/source/core/inc/MarkManager.hxx
index bc0aecd6064a..093e11855bcb 100644
--- a/sw/source/core/inc/MarkManager.hxx
+++ b/sw/source/core/inc/MarkManager.hxx
@@ -101,7 +101,9 @@ namespace sw {
// make names
OUString getUniqueMarkName(const OUString& rName) const;
+ public: // FIXME should be private, needs refactor
void sortMarks();
+ private:
void sortSubsetMarks();
// container for all marks