summaryrefslogtreecommitdiff
path: root/sw
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-15 15:10:04 +0100
commit10aab2a97c3959e50b831a7530cfea7e82c405e9 (patch)
tree4c0f22a70b5efc49150dc35cd4b4b144dfc30cdf /sw
parenta08e5729f052ebef3221a522a816033fa553d9b4 (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
Diffstat (limited to 'sw')
-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 fbcb01fe8f58..414bc472fb42 100644
--- a/sw/source/core/doc/docnum.cxx
+++ b/sw/source/core/doc/docnum.cxx
@@ -2129,7 +2129,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