summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBjoern Michaelsen <bjoern.michaelsen@canonical.com>2016-12-28 02:20:31 +0100
committerBjörn Michaelsen <bjoern.michaelsen@canonical.com>2016-12-30 04:13:27 +0000
commitbd9009bdadb2a35c0271f7c12384bb96831a9bf3 (patch)
treea5bf33cdee607081fa3e28548530bf6d4631b26f
parentd019c7ffa84104fe2583174a6c0a34e68bb4a1d4 (diff)
use proper message passing
- also skip extra GetMaster() null-check as it is only used for nullchecked dynamic_casts Change-Id: Iab51a6a3d5e40aa96f8f252d4ef5dce7d805549f Reviewed-on: https://gerrit.libreoffice.org/32466 Reviewed-by: Björn Michaelsen <bjoern.michaelsen@canonical.com> Tested-by: Björn Michaelsen <bjoern.michaelsen@canonical.com>
-rw-r--r--sw/inc/frmfmt.hxx8
-rw-r--r--sw/source/core/draw/dcontact.cxx60
-rw-r--r--sw/source/core/layout/atrfrm.cxx1
3 files changed, 36 insertions, 33 deletions
diff --git a/sw/inc/frmfmt.hxx b/sw/inc/frmfmt.hxx
index fafa003e423f..c9f869e6e1cd 100644
--- a/sw/inc/frmfmt.hxx
+++ b/sw/inc/frmfmt.hxx
@@ -24,6 +24,7 @@
#include <tools/gen.hxx>
#include <format.hxx>
#include "swdllapi.h"
+#include <list>
class SwFlyFrame;
class SwAnchoredObject;
@@ -248,6 +249,7 @@ public:
class SwDrawFrameFormat;
class SwDrawContact;
+class SdrTextObj;
namespace sw
{
@@ -321,6 +323,12 @@ namespace sw
CreatePortionHint(SwDrawContact** ppContact) : m_ppContact(ppContact) {};
virtual ~CreatePortionHint() override;
};
+ struct SW_DLLPUBLIC CollectTextObjectsHint final : SfxHint
+ {
+ std::list<SdrTextObj*>& m_rTextObjects;
+ CollectTextObjectsHint(std::list<SdrTextObj*>& rTextObjects) : m_rTextObjects(rTextObjects) {};
+ virtual ~CollectTextObjectsHint() override;
+ };
}
class SW_DLLPUBLIC SwDrawFrameFormat: public SwFrameFormat
diff --git a/sw/source/core/draw/dcontact.cxx b/sw/source/core/draw/dcontact.cxx
index 86bae3e109aa..fcc98d3aa246 100644
--- a/sw/source/core/draw/dcontact.cxx
+++ b/sw/source/core/draw/dcontact.cxx
@@ -657,41 +657,12 @@ SwDrawContact::~SwDrawContact()
}
}
-void SwDrawContact::GetTextObjectsFromFormat( std::list<SdrTextObj*>& rTextObjects, SwDoc* pDoc )
+void SwDrawContact::GetTextObjectsFromFormat(std::list<SdrTextObj*>& o_rTextObjects, SwDoc* pDoc)
{
- for( sal_Int32 n=0; n<(sal_Int32)pDoc->GetSpzFrameFormats()->size(); n++ )
+ for(auto& rpFly : *pDoc->GetSpzFrameFormats())
{
- const SwFrameFormat* pFly = (*pDoc->GetSpzFrameFormats())[n];
- if( dynamic_cast<const SwDrawFrameFormat*>( pFly ) != nullptr )
- {
- SwDrawContact* pContact = SwIterator<SwDrawContact,SwFrameFormat>(*pFly).First();
- if( pContact )
- {
- SdrObject* pSdrO = pContact->GetMaster();
- if ( pSdrO )
- {
- if ( dynamic_cast<const SdrObjGroup*>(pSdrO) != nullptr )
- {
- SdrObjListIter aListIter( *pSdrO, SdrIterMode::DeepNoGroups );
- //iterate inside of a grouped object
- while( aListIter.IsMore() )
- {
- SdrObject* pSdrOElement = aListIter.Next();
- if( pSdrOElement && dynamic_cast<const SdrTextObj*>(pSdrOElement) != nullptr &&
- static_cast<SdrTextObj*>( pSdrOElement)->HasText() )
- {
- rTextObjects.push_back(static_cast<SdrTextObj*>( pSdrOElement ));
- }
- }
- }
- else if( dynamic_cast<const SdrTextObj*>(pSdrO) != nullptr &&
- static_cast<SdrTextObj*>( pSdrO )->HasText() )
- {
- rTextObjects.push_back(static_cast<SdrTextObj*>( pSdrO ));
- }
- }
- }
- }
+ if(dynamic_cast<const SwDrawFrameFormat*>(rpFly))
+ rpFly->CallSwClientNotify(sw::CollectTextObjectsHint(o_rTextObjects));
}
}
@@ -1596,6 +1567,29 @@ void SwDrawContact::SwClientNotify(const SwModify& rMod, const SfxHint& rHint)
MoveObjToVisibleLayer(GetMaster());
}
}
+ else if (auto pCollectTextObjectsHint = dynamic_cast<const sw::CollectTextObjectsHint*>(&rHint))
+ {
+ auto pSdrO = GetMaster();
+ if(!pSdrO)
+ return;
+ if(dynamic_cast<const SdrObjGroup*>(pSdrO))
+ {
+ SdrObjListIter aListIter(*pSdrO, SdrIterMode::DeepNoGroups);
+ //iterate inside of a grouped object
+ while(aListIter.IsMore())
+ {
+ SdrObject* pSdrOElement = aListIter.Next();
+ auto pTextObj = const_cast<SdrTextObj*>(dynamic_cast<const SdrTextObj*>(pSdrOElement));
+ if(pTextObj && pTextObj->HasText())
+ pCollectTextObjectsHint->m_rTextObjects.push_back(pTextObj);
+ }
+ }
+ else if(auto pTextObj = const_cast<SdrTextObj*>(dynamic_cast<const SdrTextObj*>(pSdrO)))
+ {
+ if(pTextObj->HasText())
+ pCollectTextObjectsHint->m_rTextObjects.push_back(pTextObj);
+ }
+ }
}
// #i26791#
diff --git a/sw/source/core/layout/atrfrm.cxx b/sw/source/core/layout/atrfrm.cxx
index ee141ab05e27..fe18ee452214 100644
--- a/sw/source/core/layout/atrfrm.cxx
+++ b/sw/source/core/layout/atrfrm.cxx
@@ -3323,6 +3323,7 @@ namespace sw
RestoreFlyAnchorHint::~RestoreFlyAnchorHint() {}
CreatePortionHint::~CreatePortionHint() {}
FindSdrObjectHint::~FindSdrObjectHint() {}
+ CollectTextObjectsHint::~CollectTextObjectsHint() {}
}
SwDrawFrameFormat::~SwDrawFrameFormat()