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

use message passing

Change-Id: I49c448c454f9bb820c3b9afa3825c58cb2dab978
Reviewed-on: https://gerrit.libreoffice.org/31863Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarBjörn Michaelsen <bjoern.michaelsen@canonical.com>
üst be3cf47a
...@@ -280,6 +280,22 @@ namespace sw ...@@ -280,6 +280,22 @@ namespace sw
CONV2COL_OR_PARA, CONV2COL_OR_PARA,
CONV2CHAR_OR_LINE 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 class SW_DLLPUBLIC SwDrawFrameFormat: public SwFrameFormat
......
...@@ -48,6 +48,7 @@ ...@@ -48,6 +48,7 @@
#include <flyfrm.hxx> #include <flyfrm.hxx>
#include <textboxhelper.hxx> #include <textboxhelper.hxx>
#include <frmfmt.hxx> #include <frmfmt.hxx>
#include <fmtfollowtextflow.hxx>
#include <dflyobj.hxx> #include <dflyobj.hxx>
#include <dcontact.hxx> #include <dcontact.hxx>
#include <unodraw.hxx> #include <unodraw.hxx>
...@@ -1517,6 +1518,67 @@ void SwDrawContact::SwClientNotify(const SwModify& rMod, const SfxHint& rHint) ...@@ -1517,6 +1518,67 @@ void SwDrawContact::SwClientNotify(const SwModify& rMod, const SfxHint& rHint)
if(rFormat.IsPosAttrSet()) if(rFormat.IsPosAttrSet())
pDrawFormatLayoutCopyHint->m_rDestFormat.PosAttrSet(); 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# // #i26791#
......
...@@ -3332,6 +3332,7 @@ namespace sw ...@@ -3332,6 +3332,7 @@ namespace sw
CheckDrawFrameFormatLayerHint::~CheckDrawFrameFormatLayerHint() {} CheckDrawFrameFormatLayerHint::~CheckDrawFrameFormatLayerHint() {}
ContactChangedHint::~ContactChangedHint() {} ContactChangedHint::~ContactChangedHint() {}
DrawFormatLayoutCopyHint::~DrawFormatLayoutCopyHint() {} DrawFormatLayoutCopyHint::~DrawFormatLayoutCopyHint() {}
WW8AnchorConvHint::~WW8AnchorConvHint() {}
} }
SwDrawFrameFormat::~SwDrawFrameFormat() SwDrawFrameFormat::~SwDrawFrameFormat()
......
...@@ -2482,38 +2482,6 @@ bool WinwordAnchoring::ConvertPosition( SwFormatHoriOrient& _iorHoriOri, ...@@ -2482,38 +2482,6 @@ bool WinwordAnchoring::ConvertPosition( SwFormatHoriOrient& _iorHoriOri,
return false; 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 // determine value of attribute 'Follow text flow', because positions aligned
// at page areas have to be converted, if it's set. // at page areas have to be converted, if it's set.
const bool bFollowTextFlow = _rFrameFormat.GetFollowTextFlow().GetValue(); const bool bFollowTextFlow = _rFrameFormat.GetFollowTextFlow().GetValue();
...@@ -2536,9 +2504,10 @@ bool WinwordAnchoring::ConvertPosition( SwFormatHoriOrient& _iorHoriOri, ...@@ -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 // convert horizontal position, if needed
{ {
sw::WW8AnchorConv eHoriConv(sw::WW8AnchorConv::NO_CONV);
// determine, if conversion has to be performed due to the position orientation // determine, if conversion has to be performed due to the position orientation
bool bConvDueToOrientation( false ); bool bConvDueToOrientation( false );
...@@ -2602,46 +2571,10 @@ bool WinwordAnchoring::ConvertPosition( SwFormatHoriOrient& _iorHoriOri, ...@@ -2602,46 +2571,10 @@ bool WinwordAnchoring::ConvertPosition( SwFormatHoriOrient& _iorHoriOri,
OSL_FAIL( "<WinwordAnchoring::ConvertPosition(..)> - unknown horizontal relation" ); 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 // convert vertical position, if needed
{ {
sw::WW8AnchorConv eVertConv(sw::WW8AnchorConv::NO_CONV);
// determine, if conversion has to be performed due to the position orientation // determine, if conversion has to be performed due to the position orientation
bool bConvDueToOrientation( false ); bool bConvDueToOrientation( false );
...@@ -2712,44 +2645,52 @@ bool WinwordAnchoring::ConvertPosition( SwFormatHoriOrient& _iorHoriOri, ...@@ -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 ); case sw::WW8AnchorConv::CONV2PG:
SwTwips nPosY( 0L ); _iorHoriOri.SetRelationOrient(text::RelOrientation::PAGE_FRAME);
{ // #i33818#
Point aPos; if(aResult.m_bHoriRelToTableCell)
if ( eVertConv == sw::WW8AnchorConv::CONV2PG ) _iorHoriOri.SetRelationOrient(text::RelOrientation::PAGE_PRINT_AREA);
{ break;
_iorVertOri.SetRelationOrient( text::RelOrientation::PAGE_FRAME ); case sw::WW8AnchorConv::CONV2COL_OR_PARA:
// #i33818# _iorHoriOri.SetRelationOrient(text::RelOrientation::FRAME);
bool bRelToTableCell( false ); break;
aPos = pAnchoredObj->GetRelPosToPageFrame( bFollowTextFlow, case sw::WW8AnchorConv::CONV2CHAR_OR_LINE:
bRelToTableCell ); _iorHoriOri.SetRelationOrient(text::RelOrientation::CHAR);
if ( bRelToTableCell ) break;
{ default:
_iorVertOri.SetRelationOrient( text::RelOrientation::PAGE_PRINT_AREA ); _iorHoriOri.SetHoriOrient(text::HoriOrientation::NONE);
} }
} _iorHoriOri.SetPos(aResult.m_aPos.X());
else if ( eVertConv == sw::WW8AnchorConv::CONV2COL_OR_PARA ) switch(eVertConv)
{ {
_iorVertOri.SetRelationOrient( text::RelOrientation::FRAME ); case sw::WW8AnchorConv::CONV2PG:
aPos = pAnchoredObj->GetRelPosToAnchorFrame(); _iorVertOri.SetRelationOrient(text::RelOrientation::PAGE_FRAME);
} // #i33818#
else if ( eVertConv == sw::WW8AnchorConv::CONV2CHAR_OR_LINE ) if(aResult.m_bVertRelToTableCell)
{ _iorVertOri.SetRelationOrient(text::RelOrientation::PAGE_PRINT_AREA);
_iorVertOri.SetRelationOrient( text::RelOrientation::TEXT_LINE ); break;
aPos = pAnchoredObj->GetRelPosToLine(); case sw::WW8AnchorConv::CONV2COL_OR_PARA:
} _iorVertOri.SetRelationOrient(text::RelOrientation::FRAME);
// No distinction between layout directions, because of missing break;
// information about WW8 in vertical layout. case sw::WW8AnchorConv::CONV2CHAR_OR_LINE:
nPosY = aPos.Y(); _iorVertOri.SetRelationOrient(text::RelOrientation::TEXT_LINE);
} break;
_iorVertOri.SetPos( nPosY ); default:
bConverted = true; _iorVertOri.SetVertOrient(text::VertOrientation::NONE);
} }
_iorVertOri.SetPos(aResult.m_aPos.Y());
return true;
} }
return false;
return bConverted;
} }
void WinwordAnchoring::SetAnchoring(const SwFrameFormat& rFormat) void WinwordAnchoring::SetAnchoring(const SwFrameFormat& rFormat)
......
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