summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Stahl <Michael.Stahl@cib.de>2018-11-01 19:25:04 +0100
committerMichael Stahl <Michael.Stahl@cib.de>2018-11-10 19:47:00 +0100
commit9a1830d494b2c899dc59d7e63a6acbcc6aee373e (patch)
tree2f584dea06d4adf70c4fc09fd455dee4718ca26f
parent4b7aa86716c12d9ec9310689c73c0862c3fae814 (diff)
sw_redlinehide_3: fix SwDoc::MoveParagraph copying of redlined text
If redlining is enabled, the selection is copied and so delete redlines become insert redline; better to delete the delete redlines so the insert redline consists only of the visible text. Change-Id: I5f7da96dd957262ccc2b83d0abe6add258b7067f
-rw-r--r--sw/source/core/doc/docnum.cxx41
1 files changed, 41 insertions, 0 deletions
diff --git a/sw/source/core/doc/docnum.cxx b/sw/source/core/doc/docnum.cxx
index e1a3844a44ac..204cd1fd8b58 100644
--- a/sw/source/core/doc/docnum.cxx
+++ b/sw/source/core/doc/docnum.cxx
@@ -2140,7 +2140,48 @@ bool SwDoc::MoveParagraphImpl(SwPaM& rPam, long const nOffset,
}
}
+ --aIdx; // move before insertion
+
getIDocumentContentOperations().CopyRange( aPam, aInsPos, /*bCopyAll=*/false, /*bCheckPos=*/true );
+
+ // now delete all the delete redlines that were copied
+#ifndef NDEBUG
+ size_t nRedlines(getIDocumentRedlineAccess().GetRedlineTable().size());
+#endif
+ if (nOffset > 0)
+ assert(aPam.End()->nNode.GetIndex() - aPam.Start()->nNode.GetIndex() + nOffset == aInsPos.nNode.GetIndex() - aPam.End()->nNode.GetIndex());
+ else
+ assert(aPam.Start()->nNode.GetIndex() - aPam.End()->nNode.GetIndex() + nOffset == aInsPos.nNode.GetIndex() - aPam.End()->nNode.GetIndex());
+ SwRedlineTable::size_type i;
+ getIDocumentRedlineAccess().GetRedline(*aPam.End(), &i);
+ for ( ; 0 < i; --i)
+ { // iterate backwards and offset via the start nodes difference
+ SwRangeRedline const*const pRedline = getIDocumentRedlineAccess().GetRedlineTable()[i - 1];
+ if (*pRedline->End() < *aPam.Start())
+ {
+ break;
+ }
+ if (pRedline->GetType() == nsRedlineType_t::REDLINE_DELETE)
+ {
+ assert(*aPam.Start() <= *pRedline->Start()); // caller's fault
+ SwRangeRedline* pNewRedline;
+ {
+ SwPaM pam(*pRedline, nullptr);
+ sal_uLong const nCurrentOffset(
+ aIdx.GetIndex() + 1 - aPam.Start()->nNode.GetIndex());
+ pam.GetPoint()->nNode += nCurrentOffset;
+ pam.GetPoint()->nContent.Assign(pam.GetPoint()->nNode.GetNode().GetContentNode(), pam.GetPoint()->nContent.GetIndex());
+ pam.GetMark()->nNode += nCurrentOffset;
+ pam.GetMark()->nContent.Assign(pam.GetMark()->nNode.GetNode().GetContentNode(), pam.GetMark()->nContent.GetIndex());
+
+ pNewRedline = new SwRangeRedline( nsRedlineType_t::REDLINE_DELETE, pam );
+ }
+ // note: effectively this will DeleteAndJoin the pam!
+ getIDocumentRedlineAccess().AppendRedline(pNewRedline, true);
+ assert(getIDocumentRedlineAccess().GetRedlineTable().size() <= nRedlines);
+ }
+ }
+
if( bDelLastPara )
{
// We need to remove the last empty Node again