diff options
author | Bjoern Michaelsen <bjoern.michaelsen@canonical.com> | 2017-01-07 03:54:22 +0100 |
---|---|---|
committer | Björn Michaelsen <bjoern.michaelsen@canonical.com> | 2017-01-07 12:43:41 +0000 |
commit | f2d9e2984155fa383adb33a52fec69be70a84cb7 (patch) | |
tree | 4468ce47ef9f791fef05d4afefa8369dc728dffa | |
parent | 776aec70ba22b4a658b3b7abb5660c809129f54b (diff) |
use proper message passing
Change-Id: I5655dd4c07769d3c9832a3e7246e750cd2f1908d
Reviewed-on: https://gerrit.libreoffice.org/32806
Reviewed-by: Björn Michaelsen <bjoern.michaelsen@canonical.com>
Tested-by: Björn Michaelsen <bjoern.michaelsen@canonical.com>
-rw-r--r-- | sw/inc/frmfmt.hxx | 8 | ||||
-rw-r--r-- | sw/source/core/draw/dcontact.cxx | 4 | ||||
-rw-r--r-- | sw/source/core/layout/atrfrm.cxx | 1 | ||||
-rw-r--r-- | sw/source/core/layout/fly.cxx | 8 | ||||
-rw-r--r-- | sw/source/core/layout/frmtool.cxx | 24 |
5 files changed, 25 insertions, 20 deletions
diff --git a/sw/inc/frmfmt.hxx b/sw/inc/frmfmt.hxx index f5e8140f971b..f8ee778f2c7b 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 c0755c057966..714dc405d941 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 8df92d3b6486..6ca6ef19c343 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 651dbcc409ae..be4c7e593a38 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 f8b126d2c2a6..e574c5b4987d 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, |