Kaydet (Commit) bd9009bd authored tarafından Bjoern Michaelsen's avatar Bjoern Michaelsen Kaydeden (comit) Björn Michaelsen

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/32466Reviewed-by: 's avatarBjörn Michaelsen <bjoern.michaelsen@canonical.com>
Tested-by: 's avatarBjörn Michaelsen <bjoern.michaelsen@canonical.com>
üst d019c7ff
......@@ -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
......
......@@ -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#
......
......@@ -3323,6 +3323,7 @@ namespace sw
RestoreFlyAnchorHint::~RestoreFlyAnchorHint() {}
CreatePortionHint::~CreatePortionHint() {}
FindSdrObjectHint::~FindSdrObjectHint() {}
CollectTextObjectsHint::~CollectTextObjectsHint() {}
}
SwDrawFrameFormat::~SwDrawFrameFormat()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment