summaryrefslogtreecommitdiff
path: root/sw/source/core/doc/docredln.cxx
diff options
context:
space:
mode:
authorLászló Németh <nemeth@numbertext.org>2021-02-24 15:05:38 +0100
committerLászló Németh <nemeth@numbertext.org>2021-02-25 08:42:13 +0100
commitd325cd0c69b7c0cc4f47105749a98995de81cc9d (patch)
tree3932106b70b3c700d38f2ba0c447e98419f5eda1 /sw/source/core/doc/docredln.cxx
parentb5422296c55b3fe7b1f96920263feb9c2f97f51d (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/docredln.cxx')
-rw-r--r--sw/source/core/doc/docredln.cxx29
1 files changed, 29 insertions, 0 deletions
diff --git a/sw/source/core/doc/docredln.cxx b/sw/source/core/doc/docredln.cxx
index 207ed07dd95c..292600a171d6 100644
--- a/sw/source/core/doc/docredln.cxx
+++ b/sw/source/core/doc/docredln.cxx
@@ -1442,6 +1442,35 @@ void SwRangeRedline::CopyToSection()
SwNodeIndex aNdIdx( *pSttNd, 1 );
SwTextNode* pTextNd = aNdIdx.GetNode().GetTextNode();
SwPosition aPos( aNdIdx, SwIndex( pTextNd ));
+
+ // tdf#115815 keep original start position of collapsed annotation ranges
+ // as temporary bookmarks (removed after file saving and file loading)
+ auto & rDMA(*rDoc.getIDocumentMarkAccess());
+ for (auto iter = rDMA.getAnnotationMarksBegin();
+ iter != rDMA.getAnnotationMarksEnd(); )
+ {
+ SwPosition const& rStartPos((**iter).GetMarkStart());
+ if ( *pStt <= rStartPos && rStartPos < *pEnd )
+ {
+ // at start of redlines use a 1-character length bookmark range
+ // instead of a 0-character length bookmark position to avoid its losing
+ sal_Int32 nLen = (*pStt == rStartPos) ? 1 : 0;
+ SwPaM aPam( rStartPos.nNode, rStartPos.nContent.GetIndex(),
+ rStartPos.nNode, rStartPos.nContent.GetIndex() + nLen);
+ ::sw::mark::IMark* pMark = rDMA.makeMark(
+ aPam,
+ (**iter).GetName() + "____",
+ IDocumentMarkAccess::MarkType::BOOKMARK, sw::mark::InsertMode::New);
+ ::sw::mark::IBookmark* pBookmark = dynamic_cast< ::sw::mark::IBookmark* >(pMark);
+ if (pBookmark)
+ {
+ pBookmark->SetKeyCode(vcl::KeyCode());
+ pBookmark->SetShortName(OUString());
+ }
+ }
+ ++iter;
+ }
+
rDoc.getIDocumentContentOperations().CopyRange(*this, aPos, SwCopyFlags::CheckPosInFly);
// Take over the style from the EndNode if needed