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

kill FindContactObject and adapt FindSdrObject

- the latter is cheating for now, the FrameFormat should really actively bookkeep
  those

Change-Id: Icf64256ba5277dc4d1ec9ac8858bdc014b3f95f5
Reviewed-on: https://gerrit.libreoffice.org/32392Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarBjörn Michaelsen <bjoern.michaelsen@canonical.com>
üst 09a0a1d7
......@@ -66,7 +66,7 @@ SwContact* GetUserCall( const SdrObject* );
bool IsMarqueeTextObj( const SdrObject& rObj );
/// Base class for the following contact objects (frame + draw objects).
class SwContact : public SdrObjUserCall, public SwClient
class SW_DLLPUBLIC SwContact : public SdrObjUserCall, public SwClient
{
/** boolean, indicating destruction of contact object
important note: boolean has to be set at the beginning of each destructor
......@@ -100,6 +100,7 @@ class SwContact : public SdrObjUserCall, public SwClient
protected:
void SetInDTOR();
virtual void SwClientNotify(const SwModify&, const SfxHint& rHint) override;
public:
......@@ -190,8 +191,6 @@ class SW_DLLPUBLIC SwFlyDrawContact : public SwContact
private:
SwFlyDrawObj* mpMasterObj;
protected:
virtual void SwClientNotify(const SwModify&, const SfxHint& rHint) override;
public:
......
......@@ -33,7 +33,19 @@ class IMapObject;
class SwRect;
class SwContact;
class SdrObject;
namespace sw { class DocumentLayoutManager; }
namespace sw
{
class DocumentLayoutManager;
// This is cheating: we are not really decoupling much with this hint.
// SwDrawFrameFormat should probably bookkeep its SdrObject (and
// SwDrawFrameFormat too) as members
struct SW_DLLPUBLIC FindSdrObjectHint final : SfxHint
{
SdrObject** m_ppObject;
FindSdrObjectHint(SdrObject** ppObject) : m_ppObject(ppObject) {};
virtual ~FindSdrObjectHint() override;
};
}
class SwFrameFormats;
/// Style of a layout element.
......@@ -106,17 +118,16 @@ public:
SwRect FindLayoutRect( const bool bPrtArea = false,
const Point* pPoint = nullptr ) const;
/** Searches SdrObject. SdrObjUserCall is client of the format.
The UserCall knows its SdrObject. */
SwContact *FindContactObj();
const SwContact *FindContactObj() const
{ return const_cast<SwFrameFormat*>(this)->FindContactObj(); }
/** @return the SdrObject, that is connected to the ContactObject.
Only DrawFrameFormats are connected to the "real SdrObject". FlyFrameFormats
are connected to a Master and all FlyFrames has the "real SdrObject".
"Real SdrObject" has position and a Z-order. */
SdrObject *FindSdrObject();
SdrObject* FindSdrObject()
{
SdrObject* pObject(nullptr);
CallSwClientNotify(sw::FindSdrObjectHint(&pObject));
return pObject;
}
const SdrObject *FindSdrObject() const
{ return const_cast<SwFrameFormat*>(this)->FindSdrObject(); }
......
......@@ -378,6 +378,17 @@ sal_uInt32 SwContact::GetMaxOrdNum() const
return nMaxOrdNum;
}
void SwContact::SwClientNotify(const SwModify&, const SfxHint& rHint)
{
// this does not call SwClient::SwClientNotify and thus doesnt handle RES_OBJECTDYING as usual. Is this intentional?
if (auto pFindSdrObjectHint = dynamic_cast<const sw::FindSdrObjectHint*>(&rHint))
{
if(!*pFindSdrObjectHint->m_ppObject)
*pFindSdrObjectHint->m_ppObject = GetMaster();
}
}
SwFlyDrawContact::SwFlyDrawContact( SwFlyFrameFormat *pToRegisterIn, SdrModel * ) :
SwContact( pToRegisterIn )
{
......@@ -434,10 +445,6 @@ void SwFlyDrawContact::SetMaster( SdrObject* _pNewMaster )
mpMasterObj = static_cast<SwFlyDrawObj *>(_pNewMaster);
}
void SwFlyDrawContact::SwClientNotify(const SwModify&, const SfxHint&)
{
}
/**
* @note Overriding method to control Writer fly frames, which are linked, and
* to assure that all objects anchored at/inside the Writer fly frame are
......@@ -1382,7 +1389,8 @@ namespace
void SwDrawContact::SwClientNotify(const SwModify& rMod, const SfxHint& rHint)
{
SwClient::SwClientNotify(rMod, rHint);
SwClient::SwClientNotify(rMod, rHint); // needed as SwContact::SwClientNotify doesnt explicitly call SwClient::SwClientNotify
SwContact::SwClientNotify(rMod, rHint);
if (auto pLegacyHint = dynamic_cast<const sw::LegacyModifyHint*>(&rHint))
{
SAL_WARN_IF(mbDisconnectInProgress, "sw.core", "<SwDrawContact::Modify(..)> called during disconnection.");
......
......@@ -2739,19 +2739,6 @@ SwRect SwFrameFormat::FindLayoutRect( const bool bPrtArea, const Point* pPoint )
return aRet;
}
SwContact* SwFrameFormat::FindContactObj()
{
return SwIterator<SwContact,SwFormat>( *this ).First();
}
SdrObject* SwFrameFormat::FindSdrObject()
{
// #i30669# - use method <FindContactObj()> instead of
// duplicated code.
SwContact* pFoundContact = FindContactObj();
return pFoundContact ? pFoundContact->GetMaster() : nullptr;
}
SdrObject* SwFrameFormat::FindRealSdrObject()
{
if( RES_FLYFRMFMT == Which() )
......@@ -3335,6 +3322,7 @@ namespace sw
WW8AnchorConvHint::~WW8AnchorConvHint() {}
RestoreFlyAnchorHint::~RestoreFlyAnchorHint() {}
CreatePortionHint::~CreatePortionHint() {}
FindSdrObjectHint::~FindSdrObjectHint() {}
}
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