From 9c0049cfae49c8e4ddef9125a69db2ad134c10c6 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Fri, 7 Jun 2024 13:48:25 +0200 Subject: Merging upstream version 4:24.2.4. Signed-off-by: Daniel Baumann --- sw/source/core/undo/undraw.cxx | 31 +++++++++++++++++++------------ sw/source/core/undo/unnum.cxx | 4 ++-- sw/source/core/undo/untblk.cxx | 6 +++++- 3 files changed, 26 insertions(+), 15 deletions(-) (limited to 'sw/source/core/undo') diff --git a/sw/source/core/undo/undraw.cxx b/sw/source/core/undo/undraw.cxx index 134c686297..73a58a0f52 100644 --- a/sw/source/core/undo/undraw.cxx +++ b/sw/source/core/undo/undraw.cxx @@ -274,6 +274,8 @@ void SwUndoDrawGroup::RedoImpl(::sw::UndoRedoContext &) SdrObject* pObj = rSave.pObj; SwDrawContact *pContact = static_cast(GetUserCall(pObj)); + if (!pContact) + continue; // Save the textboxes if (auto pOldTextBoxNode = rSave.pFormat->GetOtherTextBoxFormats()) @@ -350,23 +352,25 @@ SwUndoDrawUnGroup::SwUndoDrawUnGroup( SdrObjGroup* pObj, const SwDoc& rDoc ) m_nSize = o3tl::narrowing(pObj->GetSubList()->GetObjCount()) + 1; m_pObjArray.reset( new SwUndoGroupObjImpl[ m_nSize ] ); - SwDrawContact *pContact = static_cast(GetUserCall(pObj)); - SwDrawFrameFormat* pFormat = static_cast(pContact->GetFormat()); + if (SwDrawContact *pContact = static_cast(GetUserCall(pObj))) + { + SwDrawFrameFormat* pFormat = static_cast(pContact->GetFormat()); - m_pObjArray[0].pObj = pObj; - m_pObjArray[0].pFormat = pFormat; + m_pObjArray[0].pObj = pObj; + m_pObjArray[0].pFormat = pFormat; - // object will destroy itself - pContact->Changed( *pObj, SdrUserCallType::Delete, pObj->GetLastBoundRect() ); - pObj->SetUserCall( nullptr ); + // object will destroy itself + pContact->Changed( *pObj, SdrUserCallType::Delete, pObj->GetLastBoundRect() ); + pObj->SetUserCall( nullptr ); - ::lcl_SaveAnchor( pFormat, m_pObjArray[0].nNodeIdx ); + ::lcl_SaveAnchor( pFormat, m_pObjArray[0].nNodeIdx ); - pFormat->RemoveAllUnos(); + pFormat->RemoveAllUnos(); - // remove from array - sw::SpzFrameFormats& rFlyFormats = *pFormat->GetDoc()->GetSpzFrameFormats(); - rFlyFormats.erase( std::find( rFlyFormats.begin(), rFlyFormats.end(), pFormat )); + // remove from array + sw::SpzFrameFormats& rFlyFormats = *pFormat->GetDoc()->GetSpzFrameFormats(); + rFlyFormats.erase( std::find( rFlyFormats.begin(), rFlyFormats.end(), pFormat )); + } } SwUndoDrawUnGroup::~SwUndoDrawUnGroup() @@ -622,6 +626,9 @@ void SwUndoDrawDelete::RedoImpl(::sw::UndoRedoContext & rContext) SwUndoGroupObjImpl& rSave = m_pObjArray[n]; SdrObject *pObj = rSave.pObj; SwDrawContact *pContact = static_cast(GetUserCall(pObj)); + if (!pContact) + continue; + SwDrawFrameFormat *pFormat = static_cast(pContact->GetFormat()); // object will destroy itself diff --git a/sw/source/core/undo/unnum.cxx b/sw/source/core/undo/unnum.cxx index 1251635a31..a0aa39f3fc 100644 --- a/sw/source/core/undo/unnum.cxx +++ b/sw/source/core/undo/unnum.cxx @@ -112,7 +112,7 @@ void SwUndoInsNum::RedoImpl(::sw::UndoRedoContext & rContext) else { // #i42921# - adapt to changed signature - rDoc.SetNumRule(rPam, m_aNumRule, false); + rDoc.SetNumRule(rPam, m_aNumRule, SwDoc::SetNumRuleMode::Default); } } } @@ -131,7 +131,7 @@ void SwUndoInsNum::RepeatImpl(::sw::RepeatContext & rContext) if( m_sReplaceRule.isEmpty() ) { // #i42921# - adapt to changed signature - rDoc.SetNumRule(rContext.GetRepeatPaM(), m_aNumRule, false); + rDoc.SetNumRule(rContext.GetRepeatPaM(), m_aNumRule, SwDoc::SetNumRuleMode::Default); } } else diff --git a/sw/source/core/undo/untblk.cxx b/sw/source/core/undo/untblk.cxx index fd5c3239c0..c8967178c2 100644 --- a/sw/source/core/undo/untblk.cxx +++ b/sw/source/core/undo/untblk.cxx @@ -390,6 +390,10 @@ void SwUndoInserts::RedoImpl(::sw::UndoRedoContext & rContext) rPam.GetPoint()->GetNodeIndex())); ::std::optional oMvBkwrd = MovePtBackward(rPam); + bool const isMoveFlyAnchors(!oMvBkwrd // equivalent to bCanMoveBack + || m_oUndoNodeIndex->GetNode().IsTextNode() + || (oMvBkwrd->GetNode().IsStartNode() + && m_oUndoNodeIndex->GetNode().IsSectionNode())); // re-insert content again (first detach m_oUndoNodeIndex!) SwNodeOffset const nMvNd = m_oUndoNodeIndex->GetIndex(); @@ -403,7 +407,7 @@ void SwUndoInserts::RedoImpl(::sw::UndoRedoContext & rContext) // at-char anchors post SplitNode are on index 0 of 2nd node and will // remain there - move them back to the start (end would also work?) - if (pFlysAtInsPos) + if (pFlysAtInsPos && isMoveFlyAnchors) { for (SwFrameFormat * pFly : *pFlysAtInsPos) { -- cgit v1.2.3