diff options
author | László Németh <nemeth@numbertext.org> | 2021-02-24 15:05:38 +0100 |
---|---|---|
committer | László Németh <nemeth@numbertext.org> | 2021-02-25 08:42:13 +0100 |
commit | d325cd0c69b7c0cc4f47105749a98995de81cc9d (patch) | |
tree | 3932106b70b3c700d38f2ba0c447e98419f5eda1 /sw/source/core/doc/docbm.cxx | |
parent | b5422296c55b3fe7b1f96920263feb9c2f97f51d (diff) |
tdf#115815 sw: fix lost annotation ranges of redlines
Annotations of tracked deletions lost their ranges
during ODF export, according to the limitation of
ODF or its recent implementation. As a workaround,
save and restore the start of the annotation ranges
using temporary bookmarks (which can be part of
text:deletion).
Note: maybe it's possible to split redline ranges
regarding to the start of the annotation ranges,
mixing tracked deletions with normal text or
tracked insertions, but this would be a not backward
compatible solution, because the ODF import of this
file inserts extra (not tracked) spaces around the
annotation, losing the original text content.
Change-Id: I786993a05ee1683076e213374a92969d1856cf8c
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/111489
Tested-by: László Németh <nemeth@numbertext.org>
Reviewed-by: László Németh <nemeth@numbertext.org>
Diffstat (limited to 'sw/source/core/doc/docbm.cxx')
-rw-r--r-- | sw/source/core/doc/docbm.cxx | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/sw/source/core/doc/docbm.cxx b/sw/source/core/doc/docbm.cxx index 7adb634b281b..9061e7b853d1 100644 --- a/sw/source/core/doc/docbm.cxx +++ b/sw/source/core/doc/docbm.cxx @@ -1641,6 +1641,34 @@ namespace sw::mark CompareIMarkStartsAfter()); } + // restore text ranges of annotations of tracked deletions + // based on the helper bookmarks (which can survive I/O and hiding redlines) + void MarkManager::restoreAnnotationMarks() + { + for (auto iter = getBookmarksBegin(); + iter != getBookmarksEnd(); ) + { + const OUString & rBookmarkName = (**iter).GetName(); + sal_Int32 nPos; + if ( rBookmarkName.startsWith("__Annotation__") && + (nPos = rBookmarkName.indexOf("____")) > -1 ) + { + ::sw::UndoGuard const undoGuard(m_rDoc.GetIDocumentUndoRedo()); + IDocumentMarkAccess::const_iterator_t pMark = findAnnotationMark(rBookmarkName.copy(0, nPos)); + if ( pMark != getAnnotationMarksEnd() ) + { + const SwPaM aPam((**iter).GetMarkStart(), (**pMark).GetMarkEnd()); + repositionMark(*pMark, aPam); + } + deleteMark(&**iter); + // this invalidates iter, have to start over... + iter = getBookmarksBegin(); + } + else + ++iter; + } + } + OUString MarkManager::getUniqueMarkName(const OUString& rName) const { OSL_ENSURE(rName.getLength(), |