sw/source/core/layout/flycnt.cxx |   12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

New commits:
commit 13728add48675b470d596c77fd186d3654b29525
Author:     Michael Stahl <michael.st...@allotropia.de>
AuthorDate: Fri Jun 7 14:16:23 2024 +0200
Commit:     Miklos Vajna <vmik...@collabora.com>
CommitDate: Tue Jun 11 14:26:56 2024 +0200

    tdf#161215 sw: layout: don't move into section frame on same page
    
    The problem is that in SwFrame::GetNextFlyLeaf() pLayLeaf is in the body
    on the same page as pFlyAnchor, so the MoveSubTree() effectively removes
    the pNext chain from the layout into a circular structure whose upper is
    an indirect lower, causing an infinite loop later.
    
    Change-Id: I08f96cf483205d6213d7cec7b239f750fff5d3ad
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/168529
    Tested-by: Jenkins
    Reviewed-by: Michael Stahl <michael.st...@allotropia.de>
    (cherry picked from commit 724c17602fac7476f068e6b66f30e9ef3c9f0940)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/168536
    Reviewed-by: Miklos Vajna <vmik...@collabora.com>

diff --git a/sw/source/core/layout/flycnt.cxx b/sw/source/core/layout/flycnt.cxx
index 2ed6fbf08942..7d4e4ca70218 100644
--- a/sw/source/core/layout/flycnt.cxx
+++ b/sw/source/core/layout/flycnt.cxx
@@ -1630,7 +1630,17 @@ SwLayoutFrame *SwFrame::GetNextFlyLeaf( MakePageType 
eMakePage )
             {
                 // Make sure the candidate is not inside the same body frame, 
that would prevent
                 // inserting a new page.
-                if (pFlyAnchor->FindBodyFrame() == pLayLeaf->FindBodyFrame())
+                SwBodyFrame const* pAnchorBody(pFlyAnchor->FindBodyFrame());
+                while (!pAnchorBody->IsPageBodyFrame())
+                {
+                    pAnchorBody = pAnchorBody->GetUpper()->FindBodyFrame();
+                };
+                SwBodyFrame const* pLeafBody(pLayLeaf->FindBodyFrame());
+                while (!pLeafBody->IsPageBodyFrame())
+                {
+                    pLeafBody = pLeafBody->GetUpper()->FindBodyFrame();
+                };
+                if (pAnchorBody == pLeafBody)
                 {
                     bSameBody = true;
                 }

Reply via email to