diff options
author | Oliver-Rainer Wittmann <od@openoffice.org> | 2011-05-13 15:44:49 +0200 |
---|---|---|
committer | Cédric Bosdonnat <cedric.bosdonnat.ooo@free.fr> | 2011-05-13 15:47:24 +0200 |
commit | d3fc7a8f4d0f6f8062eb046f0ccf43b6b06fe639 (patch) | |
tree | b3be6f1ed2af51ad4d0fd96b94126885a79c12f5 | |
parent | 07aedcbb2492e2e47167c8e059467ece5f01d383 (diff) |
fdo#36524: fix crash when deleting TOX
sw34bf06: #i117863# - use hint which allows to specify, if content is
saved or not for deletion of <SwFrm> instances triggered from <SwSectionNode>
resp. <SwSectionFmt> methods
Signed-off-by: Cédric Bosdonnat <cedric.bosdonnat.ooo@free.fr>
-rw-r--r-- | sw/inc/section.hxx | 23 | ||||
-rw-r--r-- | sw/source/core/docnode/ndsect.cxx | 3 | ||||
-rw-r--r-- | sw/source/core/docnode/section.cxx | 6 | ||||
-rw-r--r-- | sw/source/core/layout/sectfrm.cxx | 9 |
4 files changed, 35 insertions, 6 deletions
diff --git a/sw/inc/section.hxx b/sw/inc/section.hxx index 4716ca95af..678e5df484 100644 --- a/sw/inc/section.hxx +++ b/sw/inc/section.hxx @@ -36,6 +36,7 @@ #include <tools/rtti.hxx> #include <tools/ref.hxx> #include <svl/svarray.hxx> +#include <svl/smplhint.hxx> #include <sfx2/lnkbase.hxx> #include <sfx2/Metadatable.hxx> @@ -267,6 +268,28 @@ public: }; +/** Hint used to notify the deletion of SwSectionFrm objects with or without + keeping the content of the frame #i117863#. + */ +class SwSectionFrmMoveAndDeleteHint : public SfxSimpleHint +{ + public: + SwSectionFrmMoveAndDeleteHint( const sal_Bool bSaveCntnt ) + : SfxSimpleHint( SFX_HINT_DYING ) + , mbSaveCntnt( bSaveCntnt ) + {} + + ~SwSectionFrmMoveAndDeleteHint() + {} + + sal_Bool IsSaveCntnt() const + { + return mbSaveCntnt; + } + + private: + const sal_Bool mbSaveCntnt; +}; enum SectionSort { SORTSECT_NOT, SORTSECT_NAME, SORTSECT_POS }; diff --git a/sw/source/core/docnode/ndsect.cxx b/sw/source/core/docnode/ndsect.cxx index 1a9a64bb43..daeca265b5 100644 --- a/sw/source/core/docnode/ndsect.cxx +++ b/sw/source/core/docnode/ndsect.cxx @@ -1066,7 +1066,8 @@ SwFrm* SwClearDummies( SwFrm* pFrm ) SwSectionNode::~SwSectionNode() { // mba: test if iteration works as clients will be removed in callback - m_pSection->GetFmt()->CallSwClientNotify( SfxSimpleHint( SFX_HINT_DYING ) ); + // use hint which allows to specify, if the content shall be saved or not + m_pSection->GetFmt()->CallSwClientNotify( SwSectionFrmMoveAndDeleteHint( sal_True ) ); SwSectionFmt* pFmt = m_pSection->GetFmt(); if( pFmt ) { diff --git a/sw/source/core/docnode/section.cxx b/sw/source/core/docnode/section.cxx index 3643fb75fc..bda3044fc8 100644 --- a/sw/source/core/docnode/section.cxx +++ b/sw/source/core/docnode/section.cxx @@ -686,7 +686,8 @@ SwSectionFmt::~SwSectionFmt() } } // mba: test iteration; objects are removed while iterating - CallSwClientNotify( SfxSimpleHint(SFX_HINT_DYING) ); + // use hint which allows to specify, if the content shall be saved or not + CallSwClientNotify( SwSectionFrmMoveAndDeleteHint( sal_True ) ); // hebe die Section doch mal auf SwNodeRange aRg( *pSectNd, 0, *pSectNd->EndOfSectionNode() ); @@ -716,7 +717,8 @@ void SwSectionFmt::DelFrms() { // #147431# : First delete the <SwSectionFrm> of the <SwSectionFmt> instance // mba: test iteration as objects are removed in iteration - CallSwClientNotify( SfxSimpleHint(SFX_HINT_DYING) ); + // use hint which allows to specify, if the content shall be saved or not + CallSwClientNotify( SwSectionFrmMoveAndDeleteHint( sal_False ) ); // Then delete frames of the nested <SwSectionFmt> instances SwIterator<SwSectionFmt,SwSectionFmt> aIter( *this ); diff --git a/sw/source/core/layout/sectfrm.cxx b/sw/source/core/layout/sectfrm.cxx index 2eff30538e..6f8bf2f3d8 100644 --- a/sw/source/core/layout/sectfrm.cxx +++ b/sw/source/core/layout/sectfrm.cxx @@ -2441,10 +2441,13 @@ void SwSectionFrm::Modify( const SfxPoolItem* pOld, const SfxPoolItem * pNew ) void SwSectionFrm::SwClientNotify( const SwModify& rMod, const SfxHint& rHint ) { - const SfxSimpleHint* pSimpleHint = dynamic_cast<const SfxSimpleHint*>(&rHint); - if ( pSimpleHint && pSimpleHint->GetId() == SFX_HINT_DYING && &rMod == GetRegisteredIn() ) + // #i117863#: The hint needs to indicate whether to keep the SwSectionFrm + // content or not. + const SwSectionFrmMoveAndDeleteHint* pHint = + dynamic_cast<const SwSectionFrmMoveAndDeleteHint*>(&rHint); + if ( pHint && pHint->GetId() == SFX_HINT_DYING && &rMod == GetRegisteredIn() ) { - SwSectionFrm::MoveCntntAndDelete( this, sal_False ); + SwSectionFrm::MoveCntntAndDelete( this, pHint->IsSaveCntnt() ); } } |