summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorBjoern Michaelsen <bjoern.michaelsen@canonical.com>2016-12-24 03:02:26 +0100
committerBjörn Michaelsen <bjoern.michaelsen@canonical.com>2016-12-24 12:09:18 +0000
commit4280607328c1c46b566719212ae3f802d511493b (patch)
treec0352b55c2d64bcf62a3318a713ffcaa4b7b1e38 /sw
parent09a0a1d760c9786c0cfb0911244892538838a284 (diff)
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/32392 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Björn Michaelsen <bjoern.michaelsen@canonical.com>
Diffstat (limited to 'sw')
-rw-r--r--sw/inc/dcontact.hxx5
-rw-r--r--sw/inc/frmfmt.hxx27
-rw-r--r--sw/source/core/draw/dcontact.cxx18
-rw-r--r--sw/source/core/layout/atrfrm.cxx14
4 files changed, 35 insertions, 29 deletions
diff --git a/sw/inc/dcontact.hxx b/sw/inc/dcontact.hxx
index 9c2b628d4bfe..ae84eee82acf 100644
--- a/sw/inc/dcontact.hxx
+++ b/sw/inc/dcontact.hxx
@@ -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:
diff --git a/sw/inc/frmfmt.hxx b/sw/inc/frmfmt.hxx
index f1ebc09e8c2c..fafa003e423f 100644
--- a/sw/inc/frmfmt.hxx
+++ b/sw/inc/frmfmt.hxx
@@ -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(); }
diff --git a/sw/source/core/draw/dcontact.cxx b/sw/source/core/draw/dcontact.cxx
index 0b084351e65e..d014583d3679 100644
--- a/sw/source/core/draw/dcontact.cxx
+++ b/sw/source/core/draw/dcontact.cxx
@@ -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.");
diff --git a/sw/source/core/layout/atrfrm.cxx b/sw/source/core/layout/atrfrm.cxx
index 37996b2cdf69..ee141ab05e27 100644
--- a/sw/source/core/layout/atrfrm.cxx
+++ b/sw/source/core/layout/atrfrm.cxx
@@ -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()