diff options
-rw-r--r-- | sw/source/core/inc/UndoCore.hxx | 4 | ||||
-rw-r--r-- | sw/source/core/undo/undobj1.cxx | 21 |
2 files changed, 13 insertions, 12 deletions
diff --git a/sw/source/core/inc/UndoCore.hxx b/sw/source/core/inc/UndoCore.hxx index 002f2ebc1b2d..1699c5716041 100644 --- a/sw/source/core/inc/UndoCore.hxx +++ b/sw/source/core/inc/UndoCore.hxx @@ -188,8 +188,8 @@ public: class SwUndoSetFlyFormat : public SwUndo, public SwClient { SwFrameFormat* m_pFrameFormat; // saved FlyFormat - SwFrameFormat* const m_pOldFormat; - SwFrameFormat* m_pNewFormat; + const OUString m_DerivedFromFormatName; + const OUString m_NewFormatName; std::unique_ptr<SfxItemSet> m_pItemSet; // the re-/ set attributes sal_uLong m_nOldNode, m_nNewNode; sal_Int32 m_nOldContent, m_nNewContent; diff --git a/sw/source/core/undo/undobj1.cxx b/sw/source/core/undo/undobj1.cxx index f88611b0cf11..6a2387f8712f 100644 --- a/sw/source/core/undo/undobj1.cxx +++ b/sw/source/core/undo/undobj1.cxx @@ -457,7 +457,8 @@ void SwUndoDelLayFormat::RedoForRollback() SwUndoSetFlyFormat::SwUndoSetFlyFormat( SwFrameFormat& rFlyFormat, SwFrameFormat& rNewFrameFormat ) : SwUndo( SwUndoId::SETFLYFRMFMT, rFlyFormat.GetDoc() ), SwClient( &rFlyFormat ), m_pFrameFormat( &rFlyFormat ), - m_pOldFormat( static_cast<SwFrameFormat*>(rFlyFormat.DerivedFrom()) ), m_pNewFormat( &rNewFrameFormat ), + m_DerivedFromFormatName( rFlyFormat.IsDefault() ? "" : rFlyFormat.DerivedFrom()->GetName() ), + m_NewFormatName( rNewFrameFormat.GetName() ), m_pItemSet( new SfxItemSet( *rFlyFormat.GetAttrSet().GetPool(), rFlyFormat.GetAttrSet().GetRanges() )), m_nOldNode( 0 ), m_nNewNode( 0 ), @@ -470,8 +471,7 @@ SwRewriter SwUndoSetFlyFormat::GetRewriter() const { SwRewriter aRewriter; - if (m_pNewFormat) - aRewriter.AddRule(UndoArg1, m_pNewFormat->GetName()); + aRewriter.AddRule(UndoArg1, m_NewFormatName); return aRewriter; } @@ -532,13 +532,14 @@ void SwUndoSetFlyFormat::UndoImpl(::sw::UndoRedoContext & rContext) SwDoc & rDoc = rContext.GetDoc(); // Is the new Format still existent? - if (rDoc.GetFrameFormats()->IsAlive(m_pOldFormat)) + SwFrameFormat* pDerivedFromFrameFormat = rDoc.FindFrameFormatByName(m_DerivedFromFormatName); + if (pDerivedFromFrameFormat) { if( m_bAnchorChanged ) m_pFrameFormat->DelFrames(); - if( m_pFrameFormat->DerivedFrom() != m_pOldFormat ) - m_pFrameFormat->SetDerivedFrom( m_pOldFormat ); + if( m_pFrameFormat->DerivedFrom() != pDerivedFromFrameFormat) + m_pFrameFormat->SetDerivedFrom(pDerivedFromFrameFormat); SfxItemIter aIter( *m_pItemSet ); const SfxPoolItem* pItem = aIter.GetCurItem(); @@ -606,19 +607,19 @@ void SwUndoSetFlyFormat::RedoImpl(::sw::UndoRedoContext & rContext) SwDoc & rDoc = rContext.GetDoc(); // Is the new Format still existent? - if (rDoc.GetFrameFormats()->IsAlive(m_pNewFormat)) + SwFrameFormat* pNewFrameFormat = rDoc.FindFrameFormatByName(m_NewFormatName); + if (pNewFrameFormat) { - if( m_bAnchorChanged ) { SwFormatAnchor aNewAnchor( m_nNewAnchorType ); GetAnchor( aNewAnchor, m_nNewNode, m_nNewContent ); SfxItemSet aSet( rDoc.GetAttrPool(), aFrameFormatSetRange ); aSet.Put( aNewAnchor ); - rDoc.SetFrameFormatToFly( *m_pFrameFormat, *m_pNewFormat, &aSet ); + rDoc.SetFrameFormatToFly( *m_pFrameFormat, *pNewFrameFormat, &aSet ); } else - rDoc.SetFrameFormatToFly( *m_pFrameFormat, *m_pNewFormat ); + rDoc.SetFrameFormatToFly( *m_pFrameFormat, *pNewFrameFormat); rContext.SetSelections(m_pFrameFormat, nullptr); } |