tdf#155002 sw floattable, split but not yet moved follow: fix GetNextFlyLeaf()
commit4b73937c75be1c9338d90ee7616995bc1d521476
authorMiklos Vajna <vmiklos@collabora.com>
Tue, 23 May 2023 13:04:22 +0000 (23 15:04 +0200)
committerAndras Timar <andras.timar@collabora.com>
Thu, 25 May 2023 07:07:43 +0000 (25 09:07 +0200)
tree5beba123ebc7853b9909267e61e3d0051a48bcee
parentac8b4ad344c23c31392444f66843b4ccf2073dde
tdf#155002 sw floattable, split but not yet moved follow: fix GetNextFlyLeaf()

Trying to open the bugdoc resulted in a layout loop since commit
b47401e12d9c45386899df0aa26653bd26c9abd4 (sw floattable: fix assert fail
when object formatter gets the wrong anchor, 2023-05-22), previously
could not open due to an assertion failure.

What happened is that the anchor hosted a fly frame with a table, but
the anchor was inside a section. Instead of splitting the fly and moving
part of it to a next page, we constantly created and deleted new pages,
without moving anything, which is a layout loop.

In fact crating a new page in SwFrame::GetNextFlyLeaf() is not correct:
we should realize that we're inside a section and let GetNextSctLeaf()
handle the page (and section) creation. Once the anchor code is improved
to detect that we're in a section, GetNextSctLeaf() creates the follow
section, and later in GetNextFlyLeaf() the call to GetNextLayoutLeaf()
will find the new follow section. Which means we have a place for the
follow anchor and don't create any new page, fixing the loop.

The import result of the bugdoc is still not perfect, but at least we
don't crash or hang while opening the document.

(cherry picked from commit 807ad65661c122a33fccb4fd3453ef92c0e9129d)

Change-Id: Ic0717dddbcd0949df7d4ae766f3cc0dbbbcff27a
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/152188
Reviewed-by: Andras Timar <andras.timar@collabora.com>
Tested-by: Andras Timar <andras.timar@collabora.com>
sw/qa/core/layout/data/floattable-next-leaf-in-section.docx [new file with mode: 0644]
sw/qa/core/layout/flycnt.cxx
sw/source/core/layout/flycnt.cxx