summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorBjoern Michaelsen <bjoern.michaelsen@canonical.com>2016-12-24 03:56:46 +0100
committerBjörn Michaelsen <bjoern.michaelsen@canonical.com>2016-12-25 00:09:24 +0000
commit85a621be87c88d8c317eb0fa296ae64f2b3253a5 (patch)
tree3a4d2877e12d32162e20da61de89085c61fd4f65 /sw
parent85a1dda8ef9d5970adf881dca2bf9d1a652f7245 (diff)
move handling of pWW8AnchorConvHint from SwDrawContact to SwContact
... as the old code did not limit itself to SwDrawContacts either (possibly fixing regressions from d2be1f90faa64cbbfe789eb62370555eb5400ae3) Change-Id: Ia821a025979d7eb2b5e244802c708a42ab1256ed Reviewed-on: https://gerrit.libreoffice.org/32393 Reviewed-by: Björn Michaelsen <bjoern.michaelsen@canonical.com> Tested-by: Björn Michaelsen <bjoern.michaelsen@canonical.com>
Diffstat (limited to 'sw')
-rw-r--r--sw/source/core/draw/dcontact.cxx105
1 files changed, 54 insertions, 51 deletions
diff --git a/sw/source/core/draw/dcontact.cxx b/sw/source/core/draw/dcontact.cxx
index d014583d3679..86bae3e109aa 100644
--- a/sw/source/core/draw/dcontact.cxx
+++ b/sw/source/core/draw/dcontact.cxx
@@ -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();