diff options
author | László Németh <nemeth@numbertext.org> | 2021-11-03 12:46:41 +0100 |
---|---|---|
committer | László Németh <nemeth@numbertext.org> | 2021-11-03 14:14:58 +0100 |
commit | 643bbf9e47e909b2d4acefaee791c9dd7d9e4a8d (patch) | |
tree | cfb4b702c7c75fd1b58d91a527c2c29def84286a /sw/source/core/doc | |
parent | e72bbb8d41cdf3eec86804afa1a6dd527925be04 (diff) |
tdf#145311 sw track changes: fix moving over empty list item
which was changed to tracked insertion.
Follow-up to commit 4c982dbafdac900e233d7b68d95c9c99244defc1
"tdf#145225 sw track changes: fix bad insert at moving".
Change-Id: If3d70da71188e95b5aeea9b72e7c9de22d7c7150
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/124645
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')
-rw-r--r-- | sw/source/core/doc/docnum.cxx | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/sw/source/core/doc/docnum.cxx b/sw/source/core/doc/docnum.cxx index c496fa9db4dd..12b23c2fbb42 100644 --- a/sw/source/core/doc/docnum.cxx +++ b/sw/source/core/doc/docnum.cxx @@ -2172,6 +2172,12 @@ bool SwDoc::MoveParagraphImpl(SwPaM& rPam, SwNodeOffset const nOffset, --aIdx; // move before insertion + // adjust empty nodes later + SwTextNode const*const pIsEmptyNode(nOffset < SwNodeOffset(0) + ? aInsPos.nNode.GetNode().GetTextNode() + : aIdx.GetNode().GetTextNode()); + bool bIsEmptyNode = pIsEmptyNode && pIsEmptyNode->Len() == 0; + getIDocumentContentOperations().CopyRange(aPam, aInsPos, SwCopyFlags::CheckPosInFly); // now delete all the delete redlines that were copied @@ -2282,6 +2288,51 @@ bool SwDoc::MoveParagraphImpl(SwPaM& rPam, SwNodeOffset const nOffset, aPam.GetBound(false).nContent.Assign(aPam.GetBound(false).nNode.GetNode().GetContentNode(), 0); sw::UpdateFramesForAddDeleteRedline(*this, aPam); + // avoid setting empty nodes to tracked insertion + if ( bIsEmptyNode ) + { + SwRedlineTable& rTable = getIDocumentRedlineAccess().GetRedlineTable(); + SwRedlineTable::size_type nRedlPosWithEmpty = + getIDocumentRedlineAccess().GetRedlinePos( pStt->nNode.GetNode(), RedlineType::Insert ); + if ( SwRedlineTable::npos != nRedlPosWithEmpty ) + { + pOwnRedl = rTable[nRedlPosWithEmpty]; + SwPosition *pRPos = nOffset < SwNodeOffset(0) ? pOwnRedl->End() : pOwnRedl->Start(); + SwNodeIndex aIdx2 ( pRPos->nNode ); + SwTextNode const*const pEmptyNode0(aIdx2.GetNode().GetTextNode()); + if ( nOffset < SwNodeOffset(0) ) + { + // move up + --aIdx2; + SwTextNode const*const pEmptyNode(aIdx2.GetNode().GetTextNode()); + if ( pEmptyNode && pEmptyNode->Len() == 0 ) + { + --(pRPos->nNode); + pRPos->nContent.Assign( aIdx2.GetNode().GetContentNode(), 0 ); + } + } + else if ( pEmptyNode0 && pEmptyNode0->Len() == 0 ) + { + // move down + ++aIdx2; + SwTextNode const*const pEmptyNode(aIdx2.GetNode().GetTextNode()); + if (pEmptyNode) + { + ++(pRPos->nNode); + pRPos->nContent.Assign( aIdx2.GetNode().GetContentNode(), 0 ); + } + } + + // sort redlines, when the trimmed range results bad redline order + if ( nRedlPosWithEmpty + 1 < rTable.size() && + *rTable[nRedlPosWithEmpty + 1] < *rTable[nRedlPosWithEmpty] ) + { + rTable.Remove(nRedlPosWithEmpty); + rTable.Insert(pOwnRedl); + } + } + } + getIDocumentRedlineAccess().SetRedlineFlags( eOld ); GetIDocumentUndoRedo().EndUndo( SwUndoId::END, nullptr ); getIDocumentState().SetModified(); |