sw layout: invalidate margins of body content when moving a fly from page
commitcf2c070de2bafeec3b476c6bff7bb4ac87ba46db
authorMiklos Vajna <vmiklos@collabora.com>
Fri, 9 Dec 2022 15:52:48 +0000 (9 16:52 +0100)
committerMiklos Vajna <vmiklos@collabora.com>
Fri, 9 Dec 2022 18:08:59 +0000 (9 18:08 +0000)
treebe0fb5eead094f07e715caa12a08ff01a9e9bc6d
parent31084ebb59093be7dfe5ab53a20fdb3bcfde34b6
sw layout: invalidate margins of body content when moving a fly from page

The (simplified) bugdoc has 9 pages, and once the ToC is updated, the
two tables below the (only) bookmark in the document has a 5879 twips
gap between them for no reason. Adding a new paragraph to the second
table "fixes" the incremental layout.

What seems to happen is that there is an anchored image on page 8, but
the layout decides that it doesn't fit there so it gets moved to page 9.
Before this move happens, SwTabFrame::Format() handles the outer of the
nested table below the unwanted gap and its CalcFlyOffsets() notices
that a large upper margin is wanted so that the table wraps around the
anchored image. Later the image gets moved to the next page, but the
removal doesn't invalidate the print area of the table with the large
top margin, so the unwanted gap appears.

Fix the problem by looking at the old page in SwPageFrame::MoveFly() and
walking through the immediate children of the body frame: if the frame
print area is invalidated, then SetYMargins() is called from
SwTabFrame::Format(), which also invalidates the size of the outer table
frame, so it will use Shrink() to have a correct size.

This appears to be a regression from commit
b9ef71476fd70bc13f50ebe80390e0730d1b7afb (tdf#134298 sw: layout: remove
left-over page frame without content, 2020-11-13).

Change-Id: I0424d9eea4d8a030959f8534985950c7efad4686
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/143881
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Tested-by: Jenkins
sw/qa/core/layout/data/page-remove-fly-table.odt [new file with mode: 0644]
sw/qa/core/layout/layout.cxx
sw/source/core/layout/flylay.cxx