diff options
author | Michael Stahl <Michael.Stahl@cib.de> | 2020-08-04 19:09:38 +0200 |
---|---|---|
committer | Thorsten Behrens <Thorsten.Behrens@CIB.de> | 2020-08-07 00:40:51 +0200 |
commit | 0de435962fc2ffbbcf3dc4a9bac13894372dfd5e (patch) | |
tree | 25b1e9e6d20f08371197b23b55a7af01eda68560 | |
parent | 378537536a135a80d97752368a032814b81cabca (diff) |
tdf#135464 sw: avoid invalid combinations of HoriOrientRelation and FLY_AT_PAGE
... when using Anchor->To Page context menu.
For shapes, in SwDoc::ChgAnchor() and for sw flys in
SwDoc::SetFlyFrameAnchor().
Change-Id: I7d747b2558ef69df99636ea0fb0409deb461a79a
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/100131
Tested-by: Jenkins
Reviewed-by: Michael Stahl <michael.stahl@cib.de>
(cherry picked from commit 1de2b0d3234462b488db54d36ebc17e2b579b0f0)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/100215
Reviewed-by: Thorsten Behrens <Thorsten.Behrens@CIB.de>
-rw-r--r-- | sw/source/core/doc/docfly.cxx | 28 | ||||
-rw-r--r-- | sw/source/core/layout/anchoreddrawobject.cxx | 5 |
2 files changed, 32 insertions, 1 deletions
diff --git a/sw/source/core/doc/docfly.cxx b/sw/source/core/doc/docfly.cxx index ad65549c6fa1..e435920da879 100644 --- a/sw/source/core/doc/docfly.cxx +++ b/sw/source/core/doc/docfly.cxx @@ -373,6 +373,7 @@ sal_Int8 SwDoc::SetFlyFrameAnchor( SwFrameFormat& rFormat, SfxItemSet& rSet, boo pItem = nullptr; SwFormatHoriOrient aOldH( rFormat.GetHoriOrient() ); + bool bPutOldH(false); if( text::HoriOrientation::NONE == aOldH.GetHoriOrient() && ( !pItem || aOldH.GetPos() == static_cast<const SwFormatHoriOrient*>(pItem)->GetPos() )) @@ -387,6 +388,22 @@ sal_Int8 SwDoc::SetFlyFrameAnchor( SwFrameFormat& rFormat, SfxItemSet& rSet, boo aOldH.SetRelationOrient( pH->GetRelationOrient() ); } aOldH.SetPos( nPos ); + bPutOldH = true; + } + if (nNew == RndStdIds::FLY_AT_PAGE) + { + sal_Int16 nRelOrient(pItem + ? static_cast<const SwFormatHoriOrient*>(pItem)->GetRelationOrient() + : aOldH.GetRelationOrient()); + if (sw::GetAtPageRelOrientation(nRelOrient, false)) + { + SAL_INFO("sw.ui", "fixing horizontal RelOrientation for at-page anchor"); + aOldH.SetRelationOrient(nRelOrient); + bPutOldH = true; + } + } + if (bPutOldH) + { rSet.Put( aOldH ); } @@ -916,6 +933,17 @@ bool SwDoc::ChgAnchor( const SdrMarkList& _rMrkList, // of attributes (method call <SetAttr(..)>) takes care of the // invalidation of the object position. SetAttr( aNewAnch, *pContact->GetFormat() ); + if (aNewAnch.GetAnchorId() == RndStdIds::FLY_AT_PAGE) + { + SwFormatHoriOrient item(pContact->GetFormat()->GetHoriOrient()); + sal_Int16 nRelOrient(item.GetRelationOrient()); + if (sw::GetAtPageRelOrientation(nRelOrient, false)) + { + SAL_INFO("sw.ui", "fixing horizontal RelOrientation for at-page anchor"); + item.SetRelationOrient(text::RelOrientation::PAGE_FRAME); + SetAttr(item, *pContact->GetFormat()); + } + } if ( _bPosCorr ) { // #i33313# - consider not connected 'virtual' drawing diff --git a/sw/source/core/layout/anchoreddrawobject.cxx b/sw/source/core/layout/anchoreddrawobject.cxx index 1af32ed2fa80..d3be5402febf 100644 --- a/sw/source/core/layout/anchoreddrawobject.cxx +++ b/sw/source/core/layout/anchoreddrawobject.cxx @@ -776,7 +776,10 @@ void SwAnchoredDrawObject::AdjustPositioningAttr( const SwFrame* _pNewAnchorFram nVertRelPos = aObjRect.Top() - aAnchorPos.Y(); } - GetFrameFormat().SetFormatAttr( SwFormatHoriOrient( nHoriRelPos, text::HoriOrientation::NONE, text::RelOrientation::FRAME ) ); + GetFrameFormat().SetFormatAttr( SwFormatHoriOrient( nHoriRelPos, text::HoriOrientation::NONE, + GetFrameFormat().GetAnchor().GetAnchorId() == RndStdIds::FLY_AT_PAGE + ? text::RelOrientation::PAGE_FRAME + : text::RelOrientation::FRAME ) ); GetFrameFormat().SetFormatAttr( SwFormatVertOrient( nVertRelPos, text::VertOrientation::NONE, text::RelOrientation::FRAME ) ); } |