summaryrefslogtreecommitdiff
path: root/sw/source/core/doc
diff options
context:
space:
mode:
Diffstat (limited to 'sw/source/core/doc')
-rw-r--r--sw/source/core/doc/docbm.cxx28
-rw-r--r--sw/source/core/doc/docredln.cxx29
2 files changed, 57 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(),
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