[Libreoffice-commits] core.git: sw/inc sw/source

Bjoern Michaelsen bjoern.michaelsen at canonical.com
Thu Feb 9 20:23:29 UTC 2017


 sw/inc/frmfmt.hxx                 |    9 +++++
 sw/source/core/draw/dcontact.cxx  |    4 ++
 sw/source/core/inc/frame.hxx      |    3 +
 sw/source/core/layout/atrfrm.cxx  |    1 
 sw/source/core/layout/fly.cxx     |   58 +++++++++++++++-----------------------
 sw/source/core/layout/pagechg.cxx |    2 -
 sw/source/core/layout/sectfrm.cxx |    2 -
 sw/source/core/layout/wsfrm.cxx   |   10 ++++++
 8 files changed, 51 insertions(+), 38 deletions(-)

New commits:
commit 1bc10ebd32513e5a497f229d9e76e4509a6a366f
Author: Bjoern Michaelsen <bjoern.michaelsen at canonical.com>
Date:   Mon Feb 6 18:27:47 2017 +0100

    use proper message passing
    
    Change-Id: Ic41c7acc73c2d275dfdb6b2ffcbb24fba5f8be72
    Reviewed-on: https://gerrit.libreoffice.org/33980
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Björn Michaelsen <bjoern.michaelsen at canonical.com>

diff --git a/sw/inc/frmfmt.hxx b/sw/inc/frmfmt.hxx
index c0f7e30..b55ca5d 100644
--- a/sw/inc/frmfmt.hxx
+++ b/sw/inc/frmfmt.hxx
@@ -35,6 +35,7 @@ class SwRect;
 class SwContact;
 class SdrObject;
 class SwRootFrame;
+class SwFlyDrawContact;
 namespace sw
 {
     class DocumentLayoutManager;
@@ -344,6 +345,14 @@ namespace sw
         GetObjectConnectedHint(bool& risConnected, const SwRootFrame* pRoot) : m_risConnected(risConnected), m_pRoot(pRoot) {};
         virtual ~GetObjectConnectedHint() override;
     };
+    struct SW_DLLPUBLIC KillDrawHint final : SfxHint
+    {
+        const SwFrame* m_pKillingFrame;
+        bool& m_rbOtherFramesAround;
+        SwFlyDrawContact*& m_rpContact;
+        KillDrawHint(const SwFrame* pKillingFrame, bool& rbOtherFramesAround, SwFlyDrawContact*& rpContact) : m_pKillingFrame(pKillingFrame), m_rbOtherFramesAround(rbOtherFramesAround), m_rpContact(rpContact) {};
+        virtual ~KillDrawHint() override;
+    };
 }
 
 class SW_DLLPUBLIC SwDrawFrameFormat: public SwFrameFormat
diff --git a/sw/source/core/draw/dcontact.cxx b/sw/source/core/draw/dcontact.cxx
index 266adad..66abcfc 100644
--- a/sw/source/core/draw/dcontact.cxx
+++ b/sw/source/core/draw/dcontact.cxx
@@ -590,6 +590,10 @@ void SwFlyDrawContact::SwClientNotify(const SwModify& rMod, const SfxHint& rHint
         if (pFormat && pFormat->Which() == RES_FLYFRMFMT && !pFormat->getIDocumentLayoutAccess().GetCurrentViewShell())
             pGetZOrdnerHint->m_rnZOrder = GetMaster()->GetOrdNum();
     }
+    else if (auto pKillDrawHint = dynamic_cast<const sw::KillDrawHint*>(&rHint))
+    {
+        pKillDrawHint->m_rpContact = this;
+    }
     else if (auto pDrawFrameFormatHint = dynamic_cast<const sw::DrawFrameFormatHint*>(&rHint))
     {
         switch(pDrawFrameFormatHint->m_eId)
diff --git a/sw/source/core/inc/frame.hxx b/sw/source/core/inc/frame.hxx
index f2aa34c..47c7835 100644
--- a/sw/source/core/inc/frame.hxx
+++ b/sw/source/core/inc/frame.hxx
@@ -321,7 +321,8 @@ protected:
 
     // draw shadow and borders
     void PaintShadow( const SwRect&, SwRect&, const SwBorderAttrs& ) const;
-    virtual void  Modify( const SfxPoolItem*, const SfxPoolItem* ) override;
+    virtual void Modify( const SfxPoolItem*, const SfxPoolItem* ) override;
+    virtual void SwClientNotify( const SwModify&, const SfxHint& rHint) override;
 
     virtual const IDocumentDrawModelAccess& getIDocumentDrawModelAccess( );
 
diff --git a/sw/source/core/layout/atrfrm.cxx b/sw/source/core/layout/atrfrm.cxx
index 7cd6734..1b420b7 100644
--- a/sw/source/core/layout/atrfrm.cxx
+++ b/sw/source/core/layout/atrfrm.cxx
@@ -3317,6 +3317,7 @@ namespace sw
     CollectTextObjectsHint::~CollectTextObjectsHint() {}
     GetZOrderHint::~GetZOrderHint() {}
     GetObjectConnectedHint::~GetObjectConnectedHint() {}
+    KillDrawHint::~KillDrawHint() {}
 }
 
 SwDrawFrameFormat::~SwDrawFrameFormat()
diff --git a/sw/source/core/layout/fly.cxx b/sw/source/core/layout/fly.cxx
index be4c7e5..55f1ac2 100644
--- a/sw/source/core/layout/fly.cxx
+++ b/sw/source/core/layout/fly.cxx
@@ -420,55 +420,46 @@ void SwFlyFrame::InitDrawObj()
 
 void SwFlyFrame::FinitDrawObj()
 {
-    if ( !GetVirtDrawObj() )
+    if(!GetVirtDrawObj() )
         return;
-
+    SwFormat* pFormat = GetFormat();
     // Deregister from SdrPageViews if the Objects is still selected there.
-    if ( !GetFormat()->GetDoc()->IsInDtor() )
+    if(!pFormat->GetDoc()->IsInDtor())
     {
-        SwViewShell *p1St = getRootFrame()->GetCurrShell();
-        if ( p1St )
+        SwViewShell* p1St = getRootFrame()->GetCurrShell();
+        if(p1St)
         {
             for(SwViewShell& rCurrentShell : p1St->GetRingContainer())
             {   // At the moment the Drawing can do just do an Unmark on everything,
                 // as the Object was already removed
-                if( rCurrentShell.HasDrawView() )
+                if(rCurrentShell.HasDrawView() )
                     rCurrentShell.Imp()->GetDrawView()->UnmarkAll();
             }
         }
     }
+    if(!pFormat)
+    {
+        GetVirtDrawObj()->SetUserCall(nullptr);
+        delete GetVirtDrawObj();
+        return;
+    }
+    bool bOtherFramesAround(false);
+    SwFlyDrawContact* pContact(nullptr);
+    pFormat->CallSwClientNotify(sw::KillDrawHint(this, bOtherFramesAround, pContact));
 
     // Take VirtObject to the grave.
     // If the last VirtObject is destroyed, the DrawObject and the DrawContact
     // also need to be destroyed.
-    SwFlyDrawContact *pMyContact = nullptr;
-    if ( GetFormat() )
-    {
-        bool bContinue = true;
-        SwIterator<SwFrame,SwFormat> aFrameIter( *GetFormat() );
-        for ( SwFrame* pFrame = aFrameIter.First(); pFrame; pFrame = aFrameIter.Next() )
-            if ( pFrame != this )
-            {
-                // don't delete Contact if there is still a Frame
-                bContinue = false;
-                break;
-            }
-
-        if ( bContinue )
-            // no Frame left, find Contact object to destroy
-            pMyContact = SwIterator<SwFlyDrawContact,SwFormat>( *GetFormat() ).First();
-    }
-
     // OD, OS 2004-03-31 #116203# - clear user call of Writer fly frame 'master'
     // <SdrObject> to assure, that a <SwXFrame::dispose()> doesn't delete the
     // Writer fly frame again.
-    if ( pMyContact )
-    {
-        pMyContact->GetMaster()->SetUserCall( nullptr );
-    }
-    GetVirtDrawObj()->SetUserCall( nullptr ); // Else calls delete of the ContactObj
+    if(bOtherFramesAround)
+        pContact = nullptr;
+    if(pContact)
+        pContact->GetMaster()->SetUserCall(nullptr);
+    GetVirtDrawObj()->SetUserCall(nullptr); // Else calls delete of the ContactObj
     delete GetVirtDrawObj();            // Deregisters itself at the Master
-    delete pMyContact;                  // Destroys the Master itself
+    delete pContact;                  // Destroys the Master itself
 }
 
 void SwFlyFrame::ChainFrames( SwFlyFrame *pMaster, SwFlyFrame *pFollow )
@@ -675,11 +666,8 @@ bool SwFlyFrame::FrameSizeChg( const SwFormatFrameSize &rFrameSize )
 
 void SwFlyFrame::SwClientNotify(const SwModify& rMod, const SfxHint& rHint)
 {
-    if (auto pLegacyHint = dynamic_cast<const sw::LegacyModifyHint*>(&rHint))
-    {
-        Modify(pLegacyHint->m_pOld, pLegacyHint->m_pNew);
-    }
-    else if(auto pGetZOrdnerHint = dynamic_cast<const sw::GetZOrderHint*>(&rHint))
+    SwFrame::SwClientNotify(rMod, rHint);
+    if(auto pGetZOrdnerHint = dynamic_cast<const sw::GetZOrderHint*>(&rHint))
     {
         auto pFormat(dynamic_cast<const SwFrameFormat*>(&rMod));
         if(pFormat->Which() == RES_FLYFRMFMT && pFormat->getIDocumentLayoutAccess().GetCurrentViewShell()) // #i11176#
diff --git a/sw/source/core/layout/pagechg.cxx b/sw/source/core/layout/pagechg.cxx
index 6ced59b..12e2868 100644
--- a/sw/source/core/layout/pagechg.cxx
+++ b/sw/source/core/layout/pagechg.cxx
@@ -533,7 +533,7 @@ void SwPageFrame::SwClientNotify(const SwModify& rModify, const SfxHint& rHint)
         static_cast<SwRootFrame*>(GetUpper())->RemoveFootnotes(nullptr, false, true);
     }
     else
-        SwClient::SwClientNotify(rModify, rHint);
+        SwFrame::SwClientNotify(rModify, rHint);
 }
 
 void SwPageFrame::UpdateAttr_( const SfxPoolItem *pOld, const SfxPoolItem *pNew,
diff --git a/sw/source/core/layout/sectfrm.cxx b/sw/source/core/layout/sectfrm.cxx
index db1e0e9..0662ee6 100644
--- a/sw/source/core/layout/sectfrm.cxx
+++ b/sw/source/core/layout/sectfrm.cxx
@@ -2294,7 +2294,7 @@ void SwSectionFrame::Modify( const SfxPoolItem* pOld, const SfxPoolItem * pNew )
 
 void SwSectionFrame::SwClientNotify( const SwModify& rMod, const SfxHint& rHint )
 {
-    SwClient::SwClientNotify(rMod, rHint);
+    SwFrame::SwClientNotify(rMod, rHint);
     // #i117863#
     const SwSectionFrameMoveAndDeleteHint* pHint =
                     dynamic_cast<const SwSectionFrameMoveAndDeleteHint*>(&rHint);
diff --git a/sw/source/core/layout/wsfrm.cxx b/sw/source/core/layout/wsfrm.cxx
index 0ae2350..050c00e 100644
--- a/sw/source/core/layout/wsfrm.cxx
+++ b/sw/source/core/layout/wsfrm.cxx
@@ -218,6 +218,16 @@ void SwTextFrame::CheckDirection( bool bVert )
               true, bBrowseMode );
 }
 
+void SwFrame::SwClientNotify(const SwModify& rMod, const SfxHint& rHint)
+{
+    SwClient::SwClientNotify(rMod, rHint);
+    if (auto pKillDrawHint = dynamic_cast<const sw::KillDrawHint*>(&rHint))
+    {
+        if(this != pKillDrawHint->m_pKillingFrame)
+            pKillDrawHint->m_rbOtherFramesAround = true;
+    }
+}
+
 void SwFrame::Modify( const SfxPoolItem* pOld, const SfxPoolItem * pNew )
 {
     sal_uInt8 nInvFlags = 0;


More information about the Libreoffice-commits mailing list