diff options
author | Bjoern Michaelsen <bjoern.michaelsen@canonical.com> | 2016-12-11 01:54:46 +0100 |
---|---|---|
committer | Björn Michaelsen <bjoern.michaelsen@canonical.com> | 2016-12-12 11:35:24 +0000 |
commit | d2be1f90faa64cbbfe789eb62370555eb5400ae3 (patch) | |
tree | f19289d55f4ef9e8e2aab4cf44f430e8aeffd898 /sw | |
parent | be3cf47a5cc9a963fe61e04cd1ac1cad029facdf (diff) |
use message passing
Change-Id: I49c448c454f9bb820c3b9afa3825c58cb2dab978
Reviewed-on: https://gerrit.libreoffice.org/31863
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Björn Michaelsen <bjoern.michaelsen@canonical.com>
Diffstat (limited to 'sw')
-rw-r--r-- | sw/inc/frmfmt.hxx | 16 | ||||
-rw-r--r-- | sw/source/core/draw/dcontact.cxx | 62 | ||||
-rw-r--r-- | sw/source/core/layout/atrfrm.cxx | 1 | ||||
-rw-r--r-- | sw/source/filter/ww8/wrtw8esh.cxx | 149 |
4 files changed, 124 insertions, 104 deletions
diff --git a/sw/inc/frmfmt.hxx b/sw/inc/frmfmt.hxx index ce28dcd081db..6cf56197ac00 100644 --- a/sw/inc/frmfmt.hxx +++ b/sw/inc/frmfmt.hxx @@ -280,6 +280,22 @@ namespace sw CONV2COL_OR_PARA, CONV2CHAR_OR_LINE }; + struct WW8AnchorConvResult final + { + bool m_bHoriRelToTableCell; + bool m_bVertRelToTableCell; + bool m_bConverted; + Point m_aPos; + WW8AnchorConvResult() : m_bHoriRelToTableCell(false), m_bVertRelToTableCell(false), m_bConverted(false) {}; + }; + struct SW_DLLPUBLIC WW8AnchorConvHint final : SfxHint + { + WW8AnchorConvResult& m_rResult; + const WW8AnchorConv m_eHoriConv; + const WW8AnchorConv m_eVertConv; + WW8AnchorConvHint(WW8AnchorConvResult& rResult, WW8AnchorConv eHoriConv, WW8AnchorConv eVertConv) : m_rResult(rResult), m_eHoriConv(eHoriConv), m_eVertConv(eVertConv) {}; + virtual ~WW8AnchorConvHint() override; + }; } class SW_DLLPUBLIC SwDrawFrameFormat: public SwFrameFormat diff --git a/sw/source/core/draw/dcontact.cxx b/sw/source/core/draw/dcontact.cxx index 88015f5ab556..d1c7fc0b50d2 100644 --- a/sw/source/core/draw/dcontact.cxx +++ b/sw/source/core/draw/dcontact.cxx @@ -48,6 +48,7 @@ #include <flyfrm.hxx> #include <textboxhelper.hxx> #include <frmfmt.hxx> +#include <fmtfollowtextflow.hxx> #include <dflyobj.hxx> #include <dcontact.hxx> #include <unodraw.hxx> @@ -1517,6 +1518,67 @@ 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)) + { + const SwDrawFrameFormat& rFormat = static_cast<const SwDrawFrameFormat&>(rMod); + // 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 = 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: + ; + } + // 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_bConverted = true; + } } // #i26791# diff --git a/sw/source/core/layout/atrfrm.cxx b/sw/source/core/layout/atrfrm.cxx index 7211fc59cd20..935131261f61 100644 --- a/sw/source/core/layout/atrfrm.cxx +++ b/sw/source/core/layout/atrfrm.cxx @@ -3332,6 +3332,7 @@ namespace sw CheckDrawFrameFormatLayerHint::~CheckDrawFrameFormatLayerHint() {} ContactChangedHint::~ContactChangedHint() {} DrawFormatLayoutCopyHint::~DrawFormatLayoutCopyHint() {} + WW8AnchorConvHint::~WW8AnchorConvHint() {} } SwDrawFrameFormat::~SwDrawFrameFormat() diff --git a/sw/source/filter/ww8/wrtw8esh.cxx b/sw/source/filter/ww8/wrtw8esh.cxx index 64be7878a9b9..92e83bc8136f 100644 --- a/sw/source/filter/ww8/wrtw8esh.cxx +++ b/sw/source/filter/ww8/wrtw8esh.cxx @@ -2482,38 +2482,6 @@ bool WinwordAnchoring::ConvertPosition( SwFormatHoriOrient& _iorHoriOri, return false; } - // determine anchored object - SwAnchoredObject* pAnchoredObj( nullptr ); - { - const SwContact* pContact = _rFrameFormat.FindContactObj(); - if ( pContact ) - { - std::list<SwAnchoredObject*> aAnchoredObjs; - pContact->GetAnchoredObjs( aAnchoredObjs ); - if ( !aAnchoredObjs.empty() ) - { - pAnchoredObj = aAnchoredObjs.front(); - } - } - } - if ( !pAnchoredObj ) - { - // no anchored object found. Thus, the needed layout information can't - // be determined. --> no conversion - return false; - } - // 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 false; - } - - bool bConverted( false ); - // determine value of attribute 'Follow text flow', because positions aligned // at page areas have to be converted, if it's set. const bool bFollowTextFlow = _rFrameFormat.GetFollowTextFlow().GetValue(); @@ -2536,9 +2504,10 @@ bool WinwordAnchoring::ConvertPosition( SwFormatHoriOrient& _iorHoriOri, } } + sw::WW8AnchorConv eHoriConv(sw::WW8AnchorConv::NO_CONV); + sw::WW8AnchorConv eVertConv(sw::WW8AnchorConv::NO_CONV); // convert horizontal position, if needed { - sw::WW8AnchorConv eHoriConv(sw::WW8AnchorConv::NO_CONV); // determine, if conversion has to be performed due to the position orientation bool bConvDueToOrientation( false ); @@ -2602,46 +2571,10 @@ bool WinwordAnchoring::ConvertPosition( SwFormatHoriOrient& _iorHoriOri, OSL_FAIL( "<WinwordAnchoring::ConvertPosition(..)> - unknown horizontal relation" ); } } - if ( eHoriConv != sw::WW8AnchorConv::NO_CONV ) - { - _iorHoriOri.SetHoriOrient( text::HoriOrientation::NONE ); - SwTwips nPosX( 0L ); - { - Point aPos; - if ( eHoriConv == sw::WW8AnchorConv::CONV2PG ) - { - _iorHoriOri.SetRelationOrient( text::RelOrientation::PAGE_FRAME ); - // #i33818# - bool bRelToTableCell( false ); - aPos = pAnchoredObj->GetRelPosToPageFrame( bFollowTextFlow, - bRelToTableCell ); - if ( bRelToTableCell ) - { - _iorHoriOri.SetRelationOrient( text::RelOrientation::PAGE_PRINT_AREA ); - } - } - else if ( eHoriConv == sw::WW8AnchorConv::CONV2COL_OR_PARA ) - { - _iorHoriOri.SetRelationOrient( text::RelOrientation::FRAME ); - aPos = pAnchoredObj->GetRelPosToAnchorFrame(); - } - else if ( eHoriConv == sw::WW8AnchorConv::CONV2CHAR_OR_LINE ) - { - _iorHoriOri.SetRelationOrient( text::RelOrientation::CHAR ); - aPos = pAnchoredObj->GetRelPosToChar(); - } - // No distinction between layout directions, because of missing - // information about WW8 in vertical layout. - nPosX = aPos.X(); - } - _iorHoriOri.SetPos( nPosX ); - bConverted = true; - } } // convert vertical position, if needed { - sw::WW8AnchorConv eVertConv(sw::WW8AnchorConv::NO_CONV); // determine, if conversion has to be performed due to the position orientation bool bConvDueToOrientation( false ); @@ -2712,44 +2645,52 @@ bool WinwordAnchoring::ConvertPosition( SwFormatHoriOrient& _iorHoriOri, } } - if ( eVertConv != sw::WW8AnchorConv::NO_CONV ) + } + if(eVertConv != sw::WW8AnchorConv::NO_CONV || eHoriConv != sw::WW8AnchorConv::NO_CONV) + { + sw::WW8AnchorConvResult aResult; + _rFrameFormat.CallSwClientNotify(sw::WW8AnchorConvHint(aResult, eHoriConv, eVertConv)); + if(!aResult.m_bConverted) + return false; + switch(eHoriConv) { - _iorVertOri.SetVertOrient( text::VertOrientation::NONE ); - SwTwips nPosY( 0L ); - { - Point aPos; - if ( eVertConv == sw::WW8AnchorConv::CONV2PG ) - { - _iorVertOri.SetRelationOrient( text::RelOrientation::PAGE_FRAME ); - // #i33818# - bool bRelToTableCell( false ); - aPos = pAnchoredObj->GetRelPosToPageFrame( bFollowTextFlow, - bRelToTableCell ); - if ( bRelToTableCell ) - { - _iorVertOri.SetRelationOrient( text::RelOrientation::PAGE_PRINT_AREA ); - } - } - else if ( eVertConv == sw::WW8AnchorConv::CONV2COL_OR_PARA ) - { - _iorVertOri.SetRelationOrient( text::RelOrientation::FRAME ); - aPos = pAnchoredObj->GetRelPosToAnchorFrame(); - } - else if ( eVertConv == sw::WW8AnchorConv::CONV2CHAR_OR_LINE ) - { - _iorVertOri.SetRelationOrient( text::RelOrientation::TEXT_LINE ); - aPos = pAnchoredObj->GetRelPosToLine(); - } - // No distinction between layout directions, because of missing - // information about WW8 in vertical layout. - nPosY = aPos.Y(); - } - _iorVertOri.SetPos( nPosY ); - bConverted = true; + case sw::WW8AnchorConv::CONV2PG: + _iorHoriOri.SetRelationOrient(text::RelOrientation::PAGE_FRAME); + // #i33818# + if(aResult.m_bHoriRelToTableCell) + _iorHoriOri.SetRelationOrient(text::RelOrientation::PAGE_PRINT_AREA); + 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); + } + _iorHoriOri.SetPos(aResult.m_aPos.X()); + switch(eVertConv) + { + case sw::WW8AnchorConv::CONV2PG: + _iorVertOri.SetRelationOrient(text::RelOrientation::PAGE_FRAME); + // #i33818# + if(aResult.m_bVertRelToTableCell) + _iorVertOri.SetRelationOrient(text::RelOrientation::PAGE_PRINT_AREA); + 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); } + _iorVertOri.SetPos(aResult.m_aPos.Y()); + return true; } - - return bConverted; + return false; } void WinwordAnchoring::SetAnchoring(const SwFrameFormat& rFormat) |