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

Bjoern Michaelsen bjoern.michaelsen at canonical.com
Sat Jan 7 12:44:04 UTC 2017


 sw/inc/frmfmt.hxx                 |    8 ++++++++
 sw/source/core/draw/dcontact.cxx  |    4 ++++
 sw/source/core/layout/atrfrm.cxx  |    1 +
 sw/source/core/layout/fly.cxx     |    8 +++++++-
 sw/source/core/layout/frmtool.cxx |   24 +++++-------------------
 5 files changed, 25 insertions(+), 20 deletions(-)

New commits:
commit f2d9e2984155fa383adb33a52fec69be70a84cb7
Author: Bjoern Michaelsen <bjoern.michaelsen at canonical.com>
Date:   Sat Jan 7 03:54:22 2017 +0100

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

diff --git a/sw/inc/frmfmt.hxx b/sw/inc/frmfmt.hxx
index f5e8140..f8ee778 100644
--- a/sw/inc/frmfmt.hxx
+++ b/sw/inc/frmfmt.hxx
@@ -34,6 +34,7 @@ class IMapObject;
 class SwRect;
 class SwContact;
 class SdrObject;
+class SwRootFrame;
 namespace sw
 {
     class DocumentLayoutManager;
@@ -335,6 +336,13 @@ namespace sw
         GetZOrderHint(sal_uInt32& rnZOrder) : m_rnZOrder(rnZOrder) {};
         virtual ~GetZOrderHint() override;
     };
+    struct SW_DLLPUBLIC GetObjectConnectedHint final : SfxHint
+    {
+        bool& m_risConnected;
+        const SwRootFrame* m_pRoot;
+        GetObjectConnectedHint(bool& risConnected, const SwRootFrame* pRoot) : m_risConnected(risConnected), m_pRoot(pRoot) {};
+        virtual ~GetObjectConnectedHint() override;
+    };
 }
 
 class SW_DLLPUBLIC SwDrawFrameFormat: public SwFrameFormat
diff --git a/sw/source/core/draw/dcontact.cxx b/sw/source/core/draw/dcontact.cxx
index c0755c0..714dc40 100644
--- a/sw/source/core/draw/dcontact.cxx
+++ b/sw/source/core/draw/dcontact.cxx
@@ -1609,6 +1609,10 @@ void SwDrawContact::SwClientNotify(const SwModify& rMod, const SfxHint& rHint)
         if(pFormat->Which() == RES_DRAWFRMFMT)
             pGetZOrdnerHint->m_rnZOrder = GetMaster()->GetOrdNum();
     }
+    else if (auto pConnectedHint = dynamic_cast<const sw::GetObjectConnectedHint*>(&rHint))
+    {
+        pConnectedHint->m_risConnected |= (GetAnchorFrame() != nullptr);
+    }
 }
 
 // #i26791#
diff --git a/sw/source/core/layout/atrfrm.cxx b/sw/source/core/layout/atrfrm.cxx
index 8df92d3..6ca6ef1 100644
--- a/sw/source/core/layout/atrfrm.cxx
+++ b/sw/source/core/layout/atrfrm.cxx
@@ -3325,6 +3325,7 @@ namespace sw
     FindSdrObjectHint::~FindSdrObjectHint() {}
     CollectTextObjectsHint::~CollectTextObjectsHint() {}
     GetZOrderHint::~GetZOrderHint() {}
+    GetObjectConnectedHint::~GetObjectConnectedHint() {}
 }
 
 SwDrawFrameFormat::~SwDrawFrameFormat()
diff --git a/sw/source/core/layout/fly.cxx b/sw/source/core/layout/fly.cxx
index 651dbcc..be4c7e5 100644
--- a/sw/source/core/layout/fly.cxx
+++ b/sw/source/core/layout/fly.cxx
@@ -684,7 +684,13 @@ void SwFlyFrame::SwClientNotify(const SwModify& rMod, const SfxHint& rHint)
         auto pFormat(dynamic_cast<const SwFrameFormat*>(&rMod));
         if(pFormat->Which() == RES_FLYFRMFMT && pFormat->getIDocumentLayoutAccess().GetCurrentViewShell()) // #i11176#
             pGetZOrdnerHint->m_rnZOrder = GetVirtDrawObj()->GetOrdNum();
-     }
+    }
+    else if(auto pConnectedHint = dynamic_cast<const sw::GetObjectConnectedHint*>(&rHint))
+    {
+        auto pFormat(dynamic_cast<const SwFrameFormat*>(&rMod));
+        if(!pConnectedHint->m_risConnected && pFormat->Which() == RES_FLYFRMFMT && (!pConnectedHint->m_pRoot || pConnectedHint->m_pRoot == getRootFrame()))
+            pConnectedHint->m_risConnected = true;
+    }
 };
 
 void SwFlyFrame::Modify( const SfxPoolItem* pOld, const SfxPoolItem * pNew )
diff --git a/sw/source/core/layout/frmtool.cxx b/sw/source/core/layout/frmtool.cxx
index f8b126d..e574c5b 100644
--- a/sw/source/core/layout/frmtool.cxx
+++ b/sw/source/core/layout/frmtool.cxx
@@ -1071,26 +1071,12 @@ void AppendObjs( const SwFrameFormats *pTable, sal_uLong nIndex,
 #endif
 }
 
-static bool lcl_ObjConnected( const SwFrameFormat *pFormat, const SwFrame* pSib )
+static inline bool lcl_ObjConnected(const SwFrameFormat* pFormat, const SwFrame* pSib)
 {
-    if ( RES_FLYFRMFMT == pFormat->Which() )
-    {
-        SwIterator<SwFlyFrame,SwFormat> aIter( *pFormat );
-        const SwRootFrame* pRoot = pSib ? pSib->getRootFrame() : nullptr;
-        const SwFlyFrame* pTmpFrame;
-        for( pTmpFrame = aIter.First(); pTmpFrame; pTmpFrame = aIter.Next() )
-        {
-            if(! pRoot || pRoot == pTmpFrame->getRootFrame() )
-                return true;
-        }
-    }
-    else
-    {
-        SwDrawContact *pContact = SwIterator<SwDrawContact,SwFormat>(*pFormat).First();
-        if ( pContact )
-            return pContact->GetAnchorFrame() != nullptr;
-    }
-    return false;
+    const SwRootFrame* pRoot = pSib ? pSib->getRootFrame() : nullptr;
+    bool isConnected(false);
+    pFormat->CallSwClientNotify(sw::GetObjectConnectedHint(isConnected, pRoot));
+    return isConnected;
 }
 
 /** helper method to determine, if a <SwFrameFormat>, which has an object connected,


More information about the Libreoffice-commits mailing list