Files
loongoffice/sw/source/core/objectpositioning
Miklos Vajna ddfb800e60 sw: fix anchoring in SwFrame::GetNextFlyLeaf()
The core of this change is in SwFrame::GetNextFlyLeaf(), which used to
assume that there is a next frame after the fly's anchor, but it's
perfectly valid to not have such a frame. Instead if a fly is split,
then also split its anchor, so effectively only the last follow of such
anchor hosts content, all the others are empty and only serve as an
anchor of a non-last member of a split fly frame chain.

Once this anchoring is changed, adjustments are needed at other places,
so a sample split fly frame (2 paragraphs, 1st para on first page, 2nd
para on second page) is still layout out correctly:

- SwAnchoredObject::FindAnchorCharFrame(): return the right follow text
  frame for follow flys. This is needed because flys have to be anchored
  to masters, and then this function can find the frame that's used for
  positioning.

- SwFlyFrame::Format(): get the rectangle of the correct body frame,
  otherwise we would get the bottom of the 1st body frame instead of the
  2nd body frame for the follow fly, leading to a negative height of the
  follow fly frame.

- SwToContentAnchoredObjectPosition::CalcPosition(): position against
  the right follow text frame, similar to
  SwAnchoredObject::FindAnchorCharFrame().

- SwTextFrame::AdjustFollow_(): don't join a master with its follow if
  there is a split fly frame anchored in the master. The assumption is
  that first the fly has to be moved away, then we can do such a join.

- Introduce a SwTextFrame::GetSplitFlyDrawObjs() to avoid copy&paste in
  SwTextFrame::AdjustFollow_() & SwTextFormatter::FormatLine().

With this, a sample split fly frame is split to two pages with correct
anchors if SW_FORCE_FLY_SPLIT=1 is set. The anchor frame has duplicated
text on the 1st and 2nd page still, though.

Towards an initial working layout for multi-page fly frames.

Change-Id: Ie99b13c2e318ec63f69c8a47bbc604771509e24a
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/146607
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Tested-by: Jenkins
2023-02-07 13:39:52 +00:00
..