diff options
author | Bjoern Michaelsen <bjoern.michaelsen@canonical.com> | 2016-12-24 02:10:25 +0100 |
---|---|---|
committer | Björn Michaelsen <bjoern.michaelsen@canonical.com> | 2016-12-24 12:09:08 +0000 |
commit | 09a0a1d760c9786c0cfb0911244892538838a284 (patch) | |
tree | 1c349727221d9acfea75a16933e582401d8ca495 | |
parent | 604cf7024fce29143150ab77b2f14b59a45e61eb (diff) |
use proper message passing
Change-Id: I00b0446b1e5a1226566f4520ea45773251d61265
Reviewed-on: https://gerrit.libreoffice.org/32391
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Björn Michaelsen <bjoern.michaelsen@canonical.com>
-rw-r--r-- | sw/inc/frmfmt.hxx | 8 | ||||
-rw-r--r-- | sw/source/core/draw/dcontact.cxx | 13 | ||||
-rw-r--r-- | sw/source/core/layout/atrfrm.cxx | 1 | ||||
-rw-r--r-- | sw/source/core/text/itrform2.cxx | 2 | ||||
-rw-r--r-- | sw/source/core/text/porfly.cxx | 16 | ||||
-rw-r--r-- | sw/source/core/text/porfly.hxx | 4 |
6 files changed, 30 insertions, 14 deletions
diff --git a/sw/inc/frmfmt.hxx b/sw/inc/frmfmt.hxx index b24536e830a6..f1ebc09e8c2c 100644 --- a/sw/inc/frmfmt.hxx +++ b/sw/inc/frmfmt.hxx @@ -236,6 +236,8 @@ public: class SwDrawFrameFormat; +class SwDrawContact; + namespace sw { enum class DrawFrameFormatHintId { @@ -302,6 +304,12 @@ namespace sw RestoreFlyAnchorHint(Point aPos) : m_aPos(aPos) {}; virtual ~RestoreFlyAnchorHint() override; }; + struct SW_DLLPUBLIC CreatePortionHint final : SfxHint + { + SwDrawContact** m_ppContact; + CreatePortionHint(SwDrawContact** ppContact) : m_ppContact(ppContact) {}; + virtual ~CreatePortionHint() override; + }; } class SW_DLLPUBLIC SwDrawFrameFormat: public SwFrameFormat diff --git a/sw/source/core/draw/dcontact.cxx b/sw/source/core/draw/dcontact.cxx index b3b5ad1f1194..0b084351e65e 100644 --- a/sw/source/core/draw/dcontact.cxx +++ b/sw/source/core/draw/dcontact.cxx @@ -1572,6 +1572,19 @@ void SwDrawContact::SwClientNotify(const SwModify& rMod, const SfxHint& rHint) } pObj->SetRelativePos(pRestoreFlyAnchorHint->m_aPos); } + else if (auto pCreatePortionHint = dynamic_cast<const sw::CreatePortionHint*>(&rHint)) + { + if(*pCreatePortionHint->m_ppContact) + return; + *pCreatePortionHint->m_ppContact = this; // This is kind of rediculous: the FrameFormat doesnt even hold a pointer to the contact itself, but here we are leaking it out randomly + if(!GetAnchorFrame()) + { + // No direct positioning needed any more + ConnectToLayout(); + // Move object to visible layer + MoveObjToVisibleLayer(GetMaster()); + } + } } // #i26791# diff --git a/sw/source/core/layout/atrfrm.cxx b/sw/source/core/layout/atrfrm.cxx index 9c1d17a55758..37996b2cdf69 100644 --- a/sw/source/core/layout/atrfrm.cxx +++ b/sw/source/core/layout/atrfrm.cxx @@ -3334,6 +3334,7 @@ namespace sw DrawFormatLayoutCopyHint::~DrawFormatLayoutCopyHint() {} WW8AnchorConvHint::~WW8AnchorConvHint() {} RestoreFlyAnchorHint::~RestoreFlyAnchorHint() {} + CreatePortionHint::~CreatePortionHint() {} } SwDrawFrameFormat::~SwDrawFrameFormat() diff --git a/sw/source/core/text/itrform2.cxx b/sw/source/core/text/itrform2.cxx index 667b4575082b..32c50352ee98 100644 --- a/sw/source/core/text/itrform2.cxx +++ b/sw/source/core/text/itrform2.cxx @@ -2562,7 +2562,7 @@ SwFlyCntPortion *SwTextFormatter::NewFlyCntPortion( SwTextFormatInfo &rInf, } else { - pRet = sw::DrawFlyCntPortion::Create(*rInf.GetTextFrame(), static_cast<SwDrawContact*>(pFrameFormat->FindContactObj()), aTmpBase, nTmpAscent, nTmpDescent, nFlyAsc, nFlyDesc, nMode); + pRet = sw::DrawFlyCntPortion::Create(*rInf.GetTextFrame(), *pFrameFormat, aTmpBase, nTmpAscent, nTmpDescent, nFlyAsc, nFlyDesc, nMode); } return pRet; } diff --git a/sw/source/core/text/porfly.cxx b/sw/source/core/text/porfly.cxx index 7cf1f9e53368..5386a500808d 100644 --- a/sw/source/core/text/porfly.cxx +++ b/sw/source/core/text/porfly.cxx @@ -267,17 +267,11 @@ sw::FlyContentPortion::FlyContentPortion(SwFlyInContentFrame* pFly) SAL_WARN_IF(!pFly, "sw.core", "SwFlyCntPortion::SwFlyCntPortion: no SwFlyInContentFrame!"); } -sw::DrawFlyCntPortion::DrawFlyCntPortion(SwDrawContact* pContact) - : m_pContact(pContact) +sw::DrawFlyCntPortion::DrawFlyCntPortion(SwFrameFormat& rFormat) + : m_pContact(nullptr) { + rFormat.CallSwClientNotify(sw::CreatePortionHint(&m_pContact)); assert(m_pContact); - if(!m_pContact->GetAnchorFrame()) - { - // No direct positioning needed any more - m_pContact->ConnectToLayout(); - // Move object to visible layer - m_pContact->MoveObjToVisibleLayer(m_pContact->GetMaster()); - } } sw::FlyContentPortion* sw::FlyContentPortion::Create(const SwTextFrame& rFrame, SwFlyInContentFrame* pFly, const Point& rBase, long nLnAscent, long nLnDescent, long nFlyAsc, long nFlyDesc, AsCharFlags nFlags) @@ -287,9 +281,9 @@ sw::FlyContentPortion* sw::FlyContentPortion::Create(const SwTextFrame& rFrame, return pNew; } -sw::DrawFlyCntPortion* sw::DrawFlyCntPortion::Create(const SwTextFrame& rFrame, SwDrawContact* pContact, const Point& rBase, long nLnAscent, long nLnDescent, long nFlyAsc, long nFlyDesc, AsCharFlags nFlags) +sw::DrawFlyCntPortion* sw::DrawFlyCntPortion::Create(const SwTextFrame& rFrame, SwFrameFormat& rFormat, const Point& rBase, long nLnAscent, long nLnDescent, long nFlyAsc, long nFlyDesc, AsCharFlags nFlags) { - auto pNew(new DrawFlyCntPortion(pContact)); + auto pNew(new DrawFlyCntPortion(rFormat)); pNew->SetBase(rFrame, rBase, nLnAscent, nLnDescent, nFlyAsc, nFlyDesc, nFlags | AsCharFlags::UlSpace | AsCharFlags::Init); return pNew; } diff --git a/sw/source/core/text/porfly.hxx b/sw/source/core/text/porfly.hxx index 090ee7f4cb8f..1434b5e5289e 100644 --- a/sw/source/core/text/porfly.hxx +++ b/sw/source/core/text/porfly.hxx @@ -83,8 +83,8 @@ namespace sw SwDrawContact* m_pContact; virtual SdrObject* GetSdrObj(const SwTextFrame&) override; public: - DrawFlyCntPortion(SwDrawContact* pDrawContact); - static DrawFlyCntPortion* Create(const SwTextFrame& rFrame, SwDrawContact* pDrawContact, const Point& rBase, long nAsc, long nDescent, long nFlyAsc, long nFlyDesc, AsCharFlags nFlags); + DrawFlyCntPortion(SwFrameFormat& rFormat); + static DrawFlyCntPortion* Create(const SwTextFrame& rFrame, SwFrameFormat& rFormat, const Point& rBase, long nAsc, long nDescent, long nFlyAsc, long nFlyDesc, AsCharFlags nFlags); virtual void Paint(const SwTextPaintInfo& rInf) const override; virtual ~DrawFlyCntPortion() override; }; |