summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sw/source/core/doc/DocumentContentOperationsManager.cxx22
-rw-r--r--sw/source/core/doc/doccorr.cxx7
-rw-r--r--sw/source/filter/xml/XMLRedlineImportHelper.cxx5
3 files changed, 26 insertions, 8 deletions
diff --git a/sw/source/core/doc/DocumentContentOperationsManager.cxx b/sw/source/core/doc/DocumentContentOperationsManager.cxx
index 1722a52dc312..c6a1dae2a0e2 100644
--- a/sw/source/core/doc/DocumentContentOperationsManager.cxx
+++ b/sw/source/core/doc/DocumentContentOperationsManager.cxx
@@ -1972,6 +1972,18 @@ DocumentContentOperationsManager::CopyRange( SwPaM& rPam, SwPosition& rPos, cons
return bRet;
}
+static auto GetCorrPosition(SwPaM const& rPam) -> SwPosition
+{
+ // tdf#152710 target position must be on node that survives deletion
+ // so that PaMCorrAbs can invalidate SwUnoCursors properly
+ return rPam.GetPoint()->nNode.GetNode().IsContentNode()
+ ? *rPam.GetPoint()
+ : rPam.GetMark()->nNode.GetNode().IsContentNode()
+ ? *rPam.GetMark()
+ // this would be the result in SwNodes::RemoveNode()
+ : SwPosition(SwNodeIndex(rPam.End()->nNode.GetNode(), +1));
+}
+
/// Delete a full Section of the NodeArray.
/// The passed Node is located somewhere in the designated Section.
void DocumentContentOperationsManager::DeleteSection( SwNode *pNode )
@@ -1989,8 +2001,9 @@ void DocumentContentOperationsManager::DeleteSection( SwNode *pNode )
{
// move all Cursor/StackCursor/UnoCursor out of the to-be-deleted area
- SwNodeIndex aMvStt( aSttIdx, 1 );
- SwDoc::CorrAbs( aMvStt, aEndIdx, SwPosition( aSttIdx ), true );
+ SwPaM const range(aSttIdx, aEndIdx);
+ SwPosition const pos(GetCorrPosition(range));
+ ::PaMCorrAbs(range, pos);
}
m_rDoc.GetNodes().DelNodes( aSttIdx, aEndIdx.GetIndex() - aSttIdx.GetIndex() + 1 );
@@ -4098,7 +4111,10 @@ bool DocumentContentOperationsManager::DeleteRangeImpl(SwPaM & rPam, SwDeleteFla
// Move all cursors out of the deleted range, but first copy the
// passed PaM, because it could be a cursor that would be moved!
SwPaM aDelPam( *rPam.GetMark(), *rPam.GetPoint() );
- ::PaMCorrAbs( aDelPam, *aDelPam.GetPoint() );
+ {
+ SwPosition const pos(GetCorrPosition(aDelPam));
+ ::PaMCorrAbs(aDelPam, pos);
+ }
bool const bSuccess( DeleteRangeImplImpl(aDelPam, flags) );
if (bSuccess)
diff --git a/sw/source/core/doc/doccorr.cxx b/sw/source/core/doc/doccorr.cxx
index 8e2769b353e5..a2564119ce06 100644
--- a/sw/source/core/doc/doccorr.cxx
+++ b/sw/source/core/doc/doccorr.cxx
@@ -33,11 +33,14 @@ namespace
/// returns NULL if no restrictions apply
const SwStartNode* lcl_FindUnoCursorSection( const SwNode& rNode )
{
- const SwStartNode* pStartNode = rNode.StartOfSectionNode();
+ const SwStartNode* pStartNode = rNode.IsStartNode() ? rNode.GetStartNode() : rNode.StartOfSectionNode();
while( ( pStartNode != nullptr ) &&
( pStartNode->StartOfSectionNode() != pStartNode ) &&
- ( pStartNode->GetStartNodeType() == SwNormalStartNode ) )
+ // section node is only start node allowing overlapped delete
+ pStartNode->IsSectionNode() )
+ {
pStartNode = pStartNode->StartOfSectionNode();
+ }
return pStartNode;
}
diff --git a/sw/source/filter/xml/XMLRedlineImportHelper.cxx b/sw/source/filter/xml/XMLRedlineImportHelper.cxx
index 0a0c75bc9816..b42a28eeacb7 100644
--- a/sw/source/filter/xml/XMLRedlineImportHelper.cxx
+++ b/sw/source/filter/xml/XMLRedlineImportHelper.cxx
@@ -726,9 +726,8 @@ void XMLRedlineImportHelper::InsertIntoDocument(RedlineInfo* pRedlineInfo)
SAL_WARN("sw.xml", "Recursive change tracking, removing");
// reuse aPaM to remove it from nodes that will be deleted
*aPaM.GetPoint() = SwPosition(pRedlineInfo->pContentIndex->GetNode());
- aPaM.SetMark();
- *aPaM.GetMark() = SwPosition(*pRedlineInfo->pContentIndex->GetNode().EndOfSectionNode());
- pDoc->getIDocumentContentOperations().DeleteRange(aPaM);
+ aPaM.DeleteMark();
+ pDoc->getIDocumentContentOperations().DeleteSection(&aPaM.GetPoint()->nNode.GetNode());
}
else
{