diff options
author | Bjoern Michaelsen <bjoern.michaelsen@canonical.com> | 2016-12-11 15:50:42 +0100 |
---|---|---|
committer | Björn Michaelsen <bjoern.michaelsen@canonical.com> | 2016-12-12 11:40:45 +0000 |
commit | a4c6d5c8a05716e0f1a3237ef710b5955e28b6f0 (patch) | |
tree | 05d0d18077ceaee21652d6d7640bc69e4152497b /sw | |
parent | d505b5d884fd42e063c709125e0e28e0a56045c4 (diff) |
refactor out lcl_SetRelationOrient
Change-Id: I9759a0f21641b6f5ba5e456e5c45ac28238ca672
Reviewed-on: https://gerrit.libreoffice.org/31866
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/filter/ww8/wrtw8esh.cxx | 64 |
1 files changed, 28 insertions, 36 deletions
diff --git a/sw/source/filter/ww8/wrtw8esh.cxx b/sw/source/filter/ww8/wrtw8esh.cxx index a8b1ac270292..71f83fd63ad8 100644 --- a/sw/source/filter/ww8/wrtw8esh.cxx +++ b/sw/source/filter/ww8/wrtw8esh.cxx @@ -2445,6 +2445,32 @@ void SwEscherEx::FinishEscher() pEscherStrm = nullptr; } + +namespace +{ + template<typename OrientType> + void lcl_SetRelationOrient(OrientType& rOrient, const sw::WW8AnchorConv eConv, const bool bHori, std::function<void()> fDefault) + { + switch(eConv) + { + case sw::WW8AnchorConv::RELTOTABLECELL: + // #i33818# + rOrient.SetRelationOrient(text::RelOrientation::PAGE_PRINT_AREA); + break; + case sw::WW8AnchorConv::CONV2PG: + rOrient.SetRelationOrient(text::RelOrientation::PAGE_FRAME); + break; + case sw::WW8AnchorConv::CONV2COL_OR_PARA: + rOrient.SetRelationOrient(text::RelOrientation::FRAME); + break; + case sw::WW8AnchorConv::CONV2CHAR_OR_LINE: + rOrient.SetRelationOrient(bHori ? text::RelOrientation::CHAR : text::RelOrientation::TEXT_LINE); + break; + default: + fDefault();//rOrient.SetHoriOrient(text::HoriOrientation::NONE); + } + } +} /** method to perform conversion of positioning attributes with the help of corresponding layout information @@ -2652,43 +2678,9 @@ bool WinwordAnchoring::ConvertPosition( SwFormatHoriOrient& _iorHoriOri, _rFrameFormat.CallSwClientNotify(sw::WW8AnchorConvHint(aResult)); if(!aResult.m_bConverted) return false; - switch(eHoriConv) - { - case sw::WW8AnchorConv::RELTOTABLECELL: - // #i33818# - _iorHoriOri.SetRelationOrient(text::RelOrientation::PAGE_PRINT_AREA); - break; - case sw::WW8AnchorConv::CONV2PG: - _iorHoriOri.SetRelationOrient(text::RelOrientation::PAGE_FRAME); - break; - case sw::WW8AnchorConv::CONV2COL_OR_PARA: - _iorHoriOri.SetRelationOrient(text::RelOrientation::FRAME); - break; - case sw::WW8AnchorConv::CONV2CHAR_OR_LINE: - _iorHoriOri.SetRelationOrient(text::RelOrientation::CHAR); - break; - default: - _iorHoriOri.SetHoriOrient(text::HoriOrientation::NONE); - } + lcl_SetRelationOrient(_iorHoriOri, eHoriConv, true, [&_iorHoriOri]() {_iorHoriOri.SetHoriOrient(text::HoriOrientation::NONE);} ); _iorHoriOri.SetPos(aResult.m_aPos.X()); - switch(eVertConv) - { - case sw::WW8AnchorConv::RELTOTABLECELL: - // #i33818# - _iorVertOri.SetRelationOrient(text::RelOrientation::PAGE_PRINT_AREA); - break; - case sw::WW8AnchorConv::CONV2PG: - _iorVertOri.SetRelationOrient(text::RelOrientation::PAGE_FRAME); - break; - case sw::WW8AnchorConv::CONV2COL_OR_PARA: - _iorVertOri.SetRelationOrient(text::RelOrientation::FRAME); - break; - case sw::WW8AnchorConv::CONV2CHAR_OR_LINE: - _iorVertOri.SetRelationOrient(text::RelOrientation::TEXT_LINE); - break; - default: - _iorVertOri.SetVertOrient(text::VertOrientation::NONE); - } + lcl_SetRelationOrient(_iorVertOri, eVertConv, false, [&_iorVertOri]() {_iorVertOri.SetVertOrient(text::VertOrientation::NONE);} ); _iorVertOri.SetPos(aResult.m_aPos.Y()); return true; } |