diff options
author | Miklos Vajna <vmiklos@collabora.com> | 2023-06-05 20:07:56 +0200 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.com> | 2023-06-06 13:30:45 +0200 |
commit | 5a25d9252791409f5e73616ff752a9ae8227aaf7 (patch) | |
tree | 4b85da1e889776ea470a585dd561e09fde09d792 /sw/source | |
parent | f66d5331c1f55dfc88b1439f1b8e10ebe41d3f98 (diff) |
tdf#140066 sw: fix bad position of textbox after anchor type change + undo
The bugdoc has a to-char anchored textbox. Changing the ancor type +
undo resulted in a new textbox position, which is not expected.
This is a problem since 7596e26fd259ce5445212949403e7cd32303b2bd (Add
SwTextBoxHelper::findShapes, 2014-06-24), previously the codepath was
not hit, since shape + content from DOCX was a fly format, not a draw
format + fly format.
Looking at the undo item implementation, in
SwUndoFormatAttr::RestoreFlyAnchor(), aDrawSavePt is initialized from
the old format (that we try to restore on undo), so in case that already
matches aFormatPos (which is initialized from the new format / doc
model), then adjusting the same position looks safe to skip, and that
solves our problem as well.
The whole problem area could be avoided if the draw layer would store
absolute positions in its undo actions, because then it would be harder
to get the abs Writer and the rel Draw undo actions out of sync, but
that would a larger rework.
Change-Id: Ia1c9f486e54f5967a34a1a269f8d234ae96d5bb6
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/152627
Tested-by: Jenkins
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Diffstat (limited to 'sw/source')
-rw-r--r-- | sw/source/core/undo/unattr.cxx | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/sw/source/core/undo/unattr.cxx b/sw/source/core/undo/unattr.cxx index ef729671d936..9b6a12a43707 100644 --- a/sw/source/core/undo/unattr.cxx +++ b/sw/source/core/undo/unattr.cxx @@ -505,7 +505,16 @@ bool SwUndoFormatAttr::RestoreFlyAnchor(::sw::UndoRedoContext & rContext) // The Draw model also prepared an Undo object for its right positioning // which unfortunately is relative. Therefore block here a position // change of the Contact object by setting the anchor. - pFrameFormat->CallSwClientNotify(sw::RestoreFlyAnchorHint(aDrawSavePt)); + const SwFormatVertOrient& rVertOrient = pFrameFormat->GetVertOrient(); + const SwFormatHoriOrient& rHoriOrient = pFrameFormat->GetHoriOrient(); + Point aFormatPos(rHoriOrient.GetPos(), rVertOrient.GetPos()); + if (aDrawSavePt != aFormatPos) + { + // If the position would be the same, then skip the call: either it would do nothing or + // it would just go wrong. + pFrameFormat->CallSwClientNotify(sw::RestoreFlyAnchorHint(aDrawSavePt)); + } + // cache the old value again m_oOldSet->Put(SwFormatFrameSize(SwFrameSize::Variable, aDrawOldPt.X(), aDrawOldPt.Y())); } |