diff options
author | Bjoern Michaelsen <bjoern.michaelsen@canonical.com> | 2016-12-11 14:30:44 +0100 |
---|---|---|
committer | Björn Michaelsen <bjoern.michaelsen@canonical.com> | 2016-12-12 11:37:37 +0000 |
commit | 880e622d2e324a85a7b2b6ddc60e06cc423195b4 (patch) | |
tree | 00cfa66ef4fb592e844a06496451866fe9ca848b /sw | |
parent | d2be1f90faa64cbbfe789eb62370555eb5400ae3 (diff) |
refactor out lcl_GetWW8Pos
Change-Id: Ie7127668aceade312c68ed3d7f3398fbaf5e8df7
Reviewed-on: https://gerrit.libreoffice.org/31864
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.cxx | 65 |
1 files changed, 28 insertions, 37 deletions
diff --git a/sw/source/core/draw/dcontact.cxx b/sw/source/core/draw/dcontact.cxx index d1c7fc0b50d2..e6a448ecdbe0 100644 --- a/sw/source/core/draw/dcontact.cxx +++ b/sw/source/core/draw/dcontact.cxx @@ -1366,6 +1366,21 @@ namespace } return pAnchorFormat; } + Point lcl_GetWW8Pos(SwAnchoredObject* pAnchoredObj, const sw::WW8AnchorConv eConv, const bool bFollowTextFlow, const bool bHori, bool& bRelToTableCell) + { + switch(eConv) + { + case sw::WW8AnchorConv::CONV2PG: + return pAnchoredObj->GetRelPosToPageFrame(bFollowTextFlow, bRelToTableCell); + case sw::WW8AnchorConv::CONV2COL_OR_PARA: + return pAnchoredObj->GetRelPosToAnchorFrame(); + case sw::WW8AnchorConv::CONV2CHAR_OR_LINE: + return bHori ? pAnchoredObj->GetRelPosToChar() : pAnchoredObj->GetRelPosToLine(); + default: ; + } + assert(false); + return Point(); + } } void SwDrawContact::SwClientNotify(const SwModify& rMod, const SfxHint& rHint) @@ -1520,7 +1535,6 @@ void SwDrawContact::SwClientNotify(const SwModify& rMod, const SfxHint& rHint) } else if (auto pWW8AnchorConvHint = dynamic_cast<const sw::WW8AnchorConvHint*>(&rHint)) { - const SwDrawFrameFormat& rFormat = static_cast<const SwDrawFrameFormat&>(rMod); // determine anchored object SwAnchoredObject* pAnchoredObj(nullptr); { @@ -1539,44 +1553,21 @@ void SwDrawContact::SwClientNotify(const SwModify& rMod, const SfxHint& rHint) // header/footer of an *unused* page style. if(dynamic_cast<SwAnchoredDrawObject*>(pAnchoredObj) && !pAnchoredObj->GetAnchorFrame()) return; - const bool bFollowTextFlow = rFormat.GetFollowTextFlow().GetValue(); - Point aPos; - switch(pWW8AnchorConvHint->m_eHoriConv) - { - case sw::WW8AnchorConv::CONV2PG: - // #i33818# - aPos = pAnchoredObj->GetRelPosToPageFrame(bFollowTextFlow, pWW8AnchorConvHint->m_rResult.m_bHoriRelToTableCell); - break; - case sw::WW8AnchorConv::CONV2COL_OR_PARA: - aPos = pAnchoredObj->GetRelPosToAnchorFrame(); - break; - case sw::WW8AnchorConv::CONV2CHAR_OR_LINE: - aPos = pAnchoredObj->GetRelPosToChar(); - break; - default: - ; - } - // No distinction between layout directions, because of missing - // information about WW8 in vertical layout. - pWW8AnchorConvHint->m_rResult.m_aPos.setX(aPos.getX()); - switch(pWW8AnchorConvHint->m_eVertConv) - { - case sw::WW8AnchorConv::CONV2PG: - // #i33818# - aPos = pAnchoredObj->GetRelPosToPageFrame(bFollowTextFlow, pWW8AnchorConvHint->m_rResult.m_bVertRelToTableCell); - break; - case sw::WW8AnchorConv::CONV2COL_OR_PARA: - aPos = pAnchoredObj->GetRelPosToAnchorFrame(); - break; - case sw::WW8AnchorConv::CONV2CHAR_OR_LINE: - aPos = pAnchoredObj->GetRelPosToLine(); - break; - default: - ; - } + const bool bFollowTextFlow = static_cast<const SwDrawFrameFormat&>(rMod).GetFollowTextFlow().GetValue(); // No distinction between layout directions, because of missing // information about WW8 in vertical layout. - pWW8AnchorConvHint->m_rResult.m_aPos.setY(aPos.getY()); + pWW8AnchorConvHint->m_rResult.m_aPos.setX(lcl_GetWW8Pos( + pAnchoredObj, + pWW8AnchorConvHint->m_eHoriConv, + bFollowTextFlow, + true, + pWW8AnchorConvHint->m_rResult.m_bHoriRelToTableCell).getX()); + pWW8AnchorConvHint->m_rResult.m_aPos.setY(lcl_GetWW8Pos( + pAnchoredObj, + pWW8AnchorConvHint->m_eHoriConv, + bFollowTextFlow, + false, + pWW8AnchorConvHint->m_rResult.m_bVertRelToTableCell).getY()); pWW8AnchorConvHint->m_rResult.m_bConverted = true; } } |