[Libreoffice-commits] .: Branch 'libreoffice-3-4' - sw/inc sw/source

Cédric Bosdonnat cbosdo at kemper.freedesktop.org
Fri May 13 06:47:44 PDT 2011


 sw/inc/section.hxx                 |   23 +++++++++++++++++++++++
 sw/source/core/docnode/ndsect.cxx  |    3 ++-
 sw/source/core/docnode/section.cxx |    6 ++++--
 sw/source/core/layout/sectfrm.cxx  |    9 ++++++---
 4 files changed, 35 insertions(+), 6 deletions(-)

New commits:
commit d3fc7a8f4d0f6f8062eb046f0ccf43b6b06fe639
Author: Oliver-Rainer Wittmann <od at openoffice.org>
Date:   Fri May 13 15:44:49 2011 +0200

    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 at free.fr>

diff --git a/sw/inc/section.hxx b/sw/inc/section.hxx
index 4716ca9..678e5df 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 1a9a64b..daeca26 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 3643fb7..bda3044 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 2eff305..6f8bf2f 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() );
     }
 }
 


More information about the Libreoffice-commits mailing list