[Libreoffice-commits] core.git: sw/source
Michael Stahl (via logerrit)
logerrit at kemper.freedesktop.org
Thu Aug 6 09:26:26 UTC 2020
sw/source/core/doc/docfly.cxx | 28 +++++++++++++++++++++++++++
sw/source/core/layout/anchoreddrawobject.cxx | 5 +++-
2 files changed, 32 insertions(+), 1 deletion(-)
New commits:
commit 1de2b0d3234462b488db54d36ebc17e2b579b0f0
Author: Michael Stahl <Michael.Stahl at cib.de>
AuthorDate: Tue Aug 4 19:09:38 2020 +0200
Commit: Michael Stahl <michael.stahl at cib.de>
CommitDate: Thu Aug 6 11:25:35 2020 +0200
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 at cib.de>
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 8960d4075ad9..23334a44a01b 100644
--- a/sw/source/core/layout/anchoreddrawobject.cxx
+++ b/sw/source/core/layout/anchoreddrawobject.cxx
@@ -787,7 +787,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 ) );
}
More information about the Libreoffice-commits
mailing list