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* ); ...@@ -66,7 +66,7 @@ SwContact* GetUserCall( const SdrObject* );
bool IsMarqueeTextObj( const SdrObject& rObj ); bool IsMarqueeTextObj( const SdrObject& rObj );
/// Base class for the following contact objects (frame + draw objects). /// 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 /** boolean, indicating destruction of contact object
important note: boolean has to be set at the beginning of each destructor important note: boolean has to be set at the beginning of each destructor
...@@ -100,6 +100,7 @@ class SwContact : public SdrObjUserCall, public SwClient ...@@ -100,6 +100,7 @@ class SwContact : public SdrObjUserCall, public SwClient
protected: protected:
void SetInDTOR(); void SetInDTOR();
virtual void SwClientNotify(const SwModify&, const SfxHint& rHint) override;
public: public:
...@@ -190,8 +191,6 @@ class SW_DLLPUBLIC SwFlyDrawContact : public SwContact ...@@ -190,8 +191,6 @@ class SW_DLLPUBLIC SwFlyDrawContact : public SwContact
private: private:
SwFlyDrawObj* mpMasterObj; SwFlyDrawObj* mpMasterObj;
protected:
virtual void SwClientNotify(const SwModify&, const SfxHint& rHint) override;
public: public:
......
...@@ -33,7 +33,19 @@ class IMapObject; ...@@ -33,7 +33,19 @@ class IMapObject;
class SwRect; class SwRect;
class SwContact; class SwContact;
class SdrObject; 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; class SwFrameFormats;
/// Style of a layout element. /// Style of a layout element.
...@@ -106,17 +118,16 @@ public: ...@@ -106,17 +118,16 @@ public:
SwRect FindLayoutRect( const bool bPrtArea = false, SwRect FindLayoutRect( const bool bPrtArea = false,
const Point* pPoint = nullptr ) const; 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. /** @return the SdrObject, that is connected to the ContactObject.
Only DrawFrameFormats are connected to the "real SdrObject". FlyFrameFormats Only DrawFrameFormats are connected to the "real SdrObject". FlyFrameFormats
are connected to a Master and all FlyFrames has the "real SdrObject". are connected to a Master and all FlyFrames has the "real SdrObject".
"Real SdrObject" has position and a Z-order. */ "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 const SdrObject *FindSdrObject() const
{ return const_cast<SwFrameFormat*>(this)->FindSdrObject(); } { return const_cast<SwFrameFormat*>(this)->FindSdrObject(); }
......
...@@ -378,6 +378,17 @@ sal_uInt32 SwContact::GetMaxOrdNum() const ...@@ -378,6 +378,17 @@ sal_uInt32 SwContact::GetMaxOrdNum() const
return nMaxOrdNum; 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 * ) : SwFlyDrawContact::SwFlyDrawContact( SwFlyFrameFormat *pToRegisterIn, SdrModel * ) :
SwContact( pToRegisterIn ) SwContact( pToRegisterIn )
{ {
...@@ -434,10 +445,6 @@ void SwFlyDrawContact::SetMaster( SdrObject* _pNewMaster ) ...@@ -434,10 +445,6 @@ void SwFlyDrawContact::SetMaster( SdrObject* _pNewMaster )
mpMasterObj = static_cast<SwFlyDrawObj *>(_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 * @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 * to assure that all objects anchored at/inside the Writer fly frame are
...@@ -1382,7 +1389,8 @@ namespace ...@@ -1382,7 +1389,8 @@ namespace
void SwDrawContact::SwClientNotify(const SwModify& rMod, const SfxHint& rHint) 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)) if (auto pLegacyHint = dynamic_cast<const sw::LegacyModifyHint*>(&rHint))
{ {
SAL_WARN_IF(mbDisconnectInProgress, "sw.core", "<SwDrawContact::Modify(..)> called during disconnection."); SAL_WARN_IF(mbDisconnectInProgress, "sw.core", "<SwDrawContact::Modify(..)> called during disconnection.");
......
...@@ -2739,19 +2739,6 @@ SwRect SwFrameFormat::FindLayoutRect( const bool bPrtArea, const Point* pPoint ) ...@@ -2739,19 +2739,6 @@ SwRect SwFrameFormat::FindLayoutRect( const bool bPrtArea, const Point* pPoint )
return aRet; 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() SdrObject* SwFrameFormat::FindRealSdrObject()
{ {
if( RES_FLYFRMFMT == Which() ) if( RES_FLYFRMFMT == Which() )
...@@ -3335,6 +3322,7 @@ namespace sw ...@@ -3335,6 +3322,7 @@ namespace sw
WW8AnchorConvHint::~WW8AnchorConvHint() {} WW8AnchorConvHint::~WW8AnchorConvHint() {}
RestoreFlyAnchorHint::~RestoreFlyAnchorHint() {} RestoreFlyAnchorHint::~RestoreFlyAnchorHint() {}
CreatePortionHint::~CreatePortionHint() {} CreatePortionHint::~CreatePortionHint() {}
FindSdrObjectHint::~FindSdrObjectHint() {}
} }
SwDrawFrameFormat::~SwDrawFrameFormat() 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