tdf#136385 sw: fix Undo of changing anchor type
There were a few problems here:
1. the changes to positions in
SwAnchoredDrawObject::AdjustPositioningAttr() weren't recorded
2. the Undo of setting the anchor type ran last, which ended up calling
SwDrawContact::Changed_() via some callback, which changed the
position from the correct one to a wrong one
3. if the fixup for FLY_AT_PAGE is done after AdjustPositioningAttr()
then that doesn't need to take into account the anchor type
(regression from 1de2b0d323
)
Change-Id: If70408ad6140a5bec739dea176936ffcbfe3f5ed
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/104571
Tested-by: Jenkins
Reviewed-by: Michael Stahl <michael.stahl@cib.de>
This commit is contained in:
committed by
Michael Stahl
parent
09bcd75303
commit
1b3310a580
@@ -932,18 +932,6 @@ bool SwDoc::ChgAnchor( const SdrMarkList& _rMrkList,
|
||||
// #i26791# - Direct object positioning no longer needed. Apply
|
||||
// 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
|
||||
@@ -962,6 +950,20 @@ bool SwDoc::ChgAnchor( const SdrMarkList& _rMrkList,
|
||||
->AdjustPositioningAttr( pNewAnchorFrame );
|
||||
}
|
||||
}
|
||||
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(nRelOrient);
|
||||
SetAttr(item, *pContact->GetFormat());
|
||||
}
|
||||
}
|
||||
// tdf#136385 set the anchor last - otherwise it messes up the
|
||||
// position in SwDrawContact::Changed_() callback
|
||||
SetAttr(aNewAnch, *pContact->GetFormat());
|
||||
}
|
||||
|
||||
// we have changed the anchoring attributes, and those are used to
|
||||
|
@@ -793,11 +793,12 @@ void SwAnchoredDrawObject::AdjustPositioningAttr( const SwFrame* _pNewAnchorFram
|
||||
nVertRelPos = aObjRect.Top() - aAnchorPos.Y();
|
||||
}
|
||||
|
||||
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 ) );
|
||||
SwFormatHoriOrient hori(nHoriRelPos, text::HoriOrientation::NONE, text::RelOrientation::FRAME);
|
||||
SwFormatVertOrient vert(nVertRelPos, text::VertOrientation::NONE, text::RelOrientation::FRAME);
|
||||
SfxItemSet items(GetFrameFormat().GetDoc()->GetAttrPool(), svl::Items<RES_VERT_ORIENT, RES_HORI_ORIENT>());
|
||||
items.Put(hori);
|
||||
items.Put(vert);
|
||||
GetFrameFormat().GetDoc()->SetAttr(items, GetFrameFormat());
|
||||
}
|
||||
|
||||
// --> #i34748# - change return type.
|
||||
|
Reference in New Issue
Block a user