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

use proper message passing

Change-Id: I00b0446b1e5a1226566f4520ea45773251d61265
Reviewed-on: https://gerrit.libreoffice.org/32391Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarBjörn Michaelsen <bjoern.michaelsen@canonical.com>
üst 604cf702
...@@ -236,6 +236,8 @@ public: ...@@ -236,6 +236,8 @@ public:
class SwDrawFrameFormat; class SwDrawFrameFormat;
class SwDrawContact;
namespace sw namespace sw
{ {
enum class DrawFrameFormatHintId { enum class DrawFrameFormatHintId {
...@@ -302,6 +304,12 @@ namespace sw ...@@ -302,6 +304,12 @@ namespace sw
RestoreFlyAnchorHint(Point aPos) : m_aPos(aPos) {}; RestoreFlyAnchorHint(Point aPos) : m_aPos(aPos) {};
virtual ~RestoreFlyAnchorHint() override; 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 class SW_DLLPUBLIC SwDrawFrameFormat: public SwFrameFormat
......
...@@ -1572,6 +1572,19 @@ void SwDrawContact::SwClientNotify(const SwModify& rMod, const SfxHint& rHint) ...@@ -1572,6 +1572,19 @@ void SwDrawContact::SwClientNotify(const SwModify& rMod, const SfxHint& rHint)
} }
pObj->SetRelativePos(pRestoreFlyAnchorHint->m_aPos); 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# // #i26791#
......
...@@ -3334,6 +3334,7 @@ namespace sw ...@@ -3334,6 +3334,7 @@ namespace sw
DrawFormatLayoutCopyHint::~DrawFormatLayoutCopyHint() {} DrawFormatLayoutCopyHint::~DrawFormatLayoutCopyHint() {}
WW8AnchorConvHint::~WW8AnchorConvHint() {} WW8AnchorConvHint::~WW8AnchorConvHint() {}
RestoreFlyAnchorHint::~RestoreFlyAnchorHint() {} RestoreFlyAnchorHint::~RestoreFlyAnchorHint() {}
CreatePortionHint::~CreatePortionHint() {}
} }
SwDrawFrameFormat::~SwDrawFrameFormat() SwDrawFrameFormat::~SwDrawFrameFormat()
......
...@@ -2562,7 +2562,7 @@ SwFlyCntPortion *SwTextFormatter::NewFlyCntPortion( SwTextFormatInfo &rInf, ...@@ -2562,7 +2562,7 @@ SwFlyCntPortion *SwTextFormatter::NewFlyCntPortion( SwTextFormatInfo &rInf,
} }
else 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; return pRet;
} }
......
...@@ -267,17 +267,11 @@ sw::FlyContentPortion::FlyContentPortion(SwFlyInContentFrame* pFly) ...@@ -267,17 +267,11 @@ sw::FlyContentPortion::FlyContentPortion(SwFlyInContentFrame* pFly)
SAL_WARN_IF(!pFly, "sw.core", "SwFlyCntPortion::SwFlyCntPortion: no SwFlyInContentFrame!"); SAL_WARN_IF(!pFly, "sw.core", "SwFlyCntPortion::SwFlyCntPortion: no SwFlyInContentFrame!");
} }
sw::DrawFlyCntPortion::DrawFlyCntPortion(SwDrawContact* pContact) sw::DrawFlyCntPortion::DrawFlyCntPortion(SwFrameFormat& rFormat)
: m_pContact(pContact) : m_pContact(nullptr)
{ {
rFormat.CallSwClientNotify(sw::CreatePortionHint(&m_pContact));
assert(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) 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, ...@@ -287,9 +281,9 @@ sw::FlyContentPortion* sw::FlyContentPortion::Create(const SwTextFrame& rFrame,
return pNew; 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); pNew->SetBase(rFrame, rBase, nLnAscent, nLnDescent, nFlyAsc, nFlyDesc, nFlags | AsCharFlags::UlSpace | AsCharFlags::Init);
return pNew; return pNew;
} }
......
...@@ -83,8 +83,8 @@ namespace sw ...@@ -83,8 +83,8 @@ namespace sw
SwDrawContact* m_pContact; SwDrawContact* m_pContact;
virtual SdrObject* GetSdrObj(const SwTextFrame&) override; virtual SdrObject* GetSdrObj(const SwTextFrame&) override;
public: public:
DrawFlyCntPortion(SwDrawContact* pDrawContact); DrawFlyCntPortion(SwFrameFormat& rFormat);
static DrawFlyCntPortion* Create(const SwTextFrame& rFrame, SwDrawContact* pDrawContact, const Point& rBase, long nAsc, long nDescent, long nFlyAsc, long nFlyDesc, AsCharFlags nFlags); 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 void Paint(const SwTextPaintInfo& rInf) const override;
virtual ~DrawFlyCntPortion() override; virtual ~DrawFlyCntPortion() override;
}; };
......
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