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

move handling of pWW8AnchorConvHint from SwDrawContact to SwContact

... as the old code did not limit itself to SwDrawContacts either

(possibly fixing regressions from d2be1f90)

Change-Id: Ia821a025979d7eb2b5e244802c708a42ab1256ed
Reviewed-on: https://gerrit.libreoffice.org/32393Reviewed-by: 's avatarBjörn Michaelsen <bjoern.michaelsen@canonical.com>
Tested-by: 's avatarBjörn Michaelsen <bjoern.michaelsen@canonical.com>
üst 85a1dda8
......@@ -378,7 +378,32 @@ sal_uInt32 SwContact::GetMaxOrdNum() const
return nMaxOrdNum;
}
void SwContact::SwClientNotify(const SwModify&, const SfxHint& rHint)
namespace
{
Point lcl_GetWW8Pos(SwAnchoredObject* pAnchoredObj, const bool bFollowTextFlow, sw::WW8AnchorConv& reConv)
{
switch(reConv)
{
case sw::WW8AnchorConv::CONV2PG:
{
bool bRelToTableCell(false);
Point aPos(pAnchoredObj->GetRelPosToPageFrame(bFollowTextFlow, bRelToTableCell));
if(bRelToTableCell)
reConv = sw::WW8AnchorConv::RELTOTABLECELL;
return aPos;
}
case sw::WW8AnchorConv::CONV2COL_OR_PARA:
return pAnchoredObj->GetRelPosToAnchorFrame();
case sw::WW8AnchorConv::CONV2CHAR:
return pAnchoredObj->GetRelPosToChar();
case sw::WW8AnchorConv::CONV2LINE:
return pAnchoredObj->GetRelPosToLine();
default: ;
}
return Point();
}
}
void SwContact::SwClientNotify(const SwModify& rMod, 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))
......@@ -386,6 +411,34 @@ void SwContact::SwClientNotify(const SwModify&, const SfxHint& rHint)
if(!*pFindSdrObjectHint->m_ppObject)
*pFindSdrObjectHint->m_ppObject = GetMaster();
}
else if (auto pWW8AnchorConvHint = dynamic_cast<const sw::WW8AnchorConvHint*>(&rHint))
{
// determine anchored object
SwAnchoredObject* pAnchoredObj(nullptr);
{
std::list<SwAnchoredObject*> aAnchoredObjs;
GetAnchoredObjs(aAnchoredObjs);
if(!aAnchoredObjs.empty())
pAnchoredObj = aAnchoredObjs.front();
}
// no anchored object found. Thus, the needed layout information can't
// be determined. --> no conversion
if(!pAnchoredObj)
return;
// no conversion for anchored drawing object, which aren't attached to an
// anchor frame.
// This is the case for drawing objects, which are anchored inside a page
// header/footer of an *unused* page style.
if(dynamic_cast<SwAnchoredDrawObject*>(pAnchoredObj) && !pAnchoredObj->GetAnchorFrame())
return;
const bool bFollowTextFlow = static_cast<const SwFrameFormat&>(rMod).GetFollowTextFlow().GetValue();
sw::WW8AnchorConvResult& rResult(pWW8AnchorConvHint->m_rResult);
// No distinction between layout directions, because of missing
// information about WW8 in vertical layout.
rResult.m_aPos.setX(lcl_GetWW8Pos(pAnchoredObj, bFollowTextFlow, rResult.m_eHoriConv).getX());
rResult.m_aPos.setY(lcl_GetWW8Pos(pAnchoredObj, bFollowTextFlow, rResult.m_eVertConv).getY());
rResult.m_bConverted = true;
}
}
......@@ -1363,28 +1416,6 @@ namespace
}
return pAnchorFormat;
}
Point lcl_GetWW8Pos(SwAnchoredObject* pAnchoredObj, const bool bFollowTextFlow, sw::WW8AnchorConv& reConv)
{
switch(reConv)
{
case sw::WW8AnchorConv::CONV2PG:
{
bool bRelToTableCell(false);
Point aPos(pAnchoredObj->GetRelPosToPageFrame(bFollowTextFlow, bRelToTableCell));
if(bRelToTableCell)
reConv = sw::WW8AnchorConv::RELTOTABLECELL;
return aPos;
}
case sw::WW8AnchorConv::CONV2COL_OR_PARA:
return pAnchoredObj->GetRelPosToAnchorFrame();
case sw::WW8AnchorConv::CONV2CHAR:
return pAnchoredObj->GetRelPosToChar();
case sw::WW8AnchorConv::CONV2LINE:
return pAnchoredObj->GetRelPosToLine();
default: ;
}
return Point();
}
}
void SwDrawContact::SwClientNotify(const SwModify& rMod, const SfxHint& rHint)
......@@ -1541,34 +1572,6 @@ void SwDrawContact::SwClientNotify(const SwModify& rMod, const SfxHint& rHint)
if(rFormat.IsPosAttrSet())
pDrawFormatLayoutCopyHint->m_rDestFormat.PosAttrSet();
}
else if (auto pWW8AnchorConvHint = dynamic_cast<const sw::WW8AnchorConvHint*>(&rHint))
{
// determine anchored object
SwAnchoredObject* pAnchoredObj(nullptr);
{
std::list<SwAnchoredObject*> aAnchoredObjs;
GetAnchoredObjs(aAnchoredObjs);
if(!aAnchoredObjs.empty())
pAnchoredObj = aAnchoredObjs.front();
}
// no anchored object found. Thus, the needed layout information can't
// be determined. --> no conversion
if(!pAnchoredObj)
return;
// no conversion for anchored drawing object, which aren't attached to an
// anchor frame.
// This is the case for drawing objects, which are anchored inside a page
// header/footer of an *unused* page style.
if(dynamic_cast<SwAnchoredDrawObject*>(pAnchoredObj) && !pAnchoredObj->GetAnchorFrame())
return;
const bool bFollowTextFlow = static_cast<const SwDrawFrameFormat&>(rMod).GetFollowTextFlow().GetValue();
sw::WW8AnchorConvResult& rResult(pWW8AnchorConvHint->m_rResult);
// No distinction between layout directions, because of missing
// information about WW8 in vertical layout.
rResult.m_aPos.setX(lcl_GetWW8Pos(pAnchoredObj, bFollowTextFlow, rResult.m_eHoriConv).getX());
rResult.m_aPos.setY(lcl_GetWW8Pos(pAnchoredObj, bFollowTextFlow, rResult.m_eVertConv).getY());
rResult.m_bConverted = true;
}
else if (auto pRestoreFlyAnchorHint = dynamic_cast<const sw::RestoreFlyAnchorHint*>(&rHint))
{
SdrObject* pObj = GetMaster();
......
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