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

New commits:
commit d094c0fbdf9efd5b037f8933fd0c5000ab3f2533
Author:     Didier Vidal <[email protected]>
AuthorDate: Tue Mar 3 20:32:22 2026 +0100
Commit:     Miklos Vajna <[email protected]>
CommitDate: Wed Mar 4 09:09:47 2026 +0100

    tdf#164218 time to insert an image increases the further the image
    
    When an image is inserted with Insert/Image a virtual frame
    representing the selection is created at the FAR_AWAY position.
    Further in the process, while setting a format to the inserted graphic,
    an anchor search is performed for that position, starting from the
    layoutFrame of the insertion point. That search includes a search in
    the up chain of the layout that can be very long (more than a minute)
    if the insertions page is at a page number larger than a few hundreds,
    and that always fails when the point is FAR_AWAY.
    The fix deactivates this upward anchor search when the point
    to anchor is FAR AWAY (which means not inserted yet in the
    document)
    
    (cherry picked from commit 49c81d7de23be67f31d6c29281c0e52a84d1e6a1)
    
    Change-Id: Ia99e356187a93973ff1d9ce826d7e143fb477a72
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/200924
    Tested-by: Jenkins CollaboraOffice <[email protected]>
    Reviewed-by: Miklos Vajna <[email protected]>

diff --git a/sw/source/core/layout/flycnt.cxx b/sw/source/core/layout/flycnt.cxx
index 80c01412b479..25c354dc24cc 100644
--- a/sw/source/core/layout/flycnt.cxx
+++ b/sw/source/core/layout/flycnt.cxx
@@ -1140,6 +1140,9 @@ const SwContentFrame *FindAnchor( const SwFrame 
*pOldAnch, const Point &rNew,
     ::lcl_CalcDownDist( nUp, aNew, pUpFrame );
     SwDistance nDown = nUp;
     bool bNegAllowed = true;// Make it possible to leave the negative section 
once.
+    // if rNew is FAR_AWAY the up search will always fail and can be very long
+    // on large documents
+    const bool bNewFarAway = rNew.getX() == FAR_AWAY  && rNew.getY() == 
FAR_AWAY;
     do
     {
         pUpLst = pUpFrame; nUpLst = nUp;
@@ -1174,7 +1177,7 @@ const SwContentFrame *FindAnchor( const SwFrame 
*pOldAnch, const Point &rNew,
                 nUpLst = nUp;
             }
         }
-    } while (pUpFrame && ((bNegAllowed && nUp.m_nMain < 0) || (nUp <= 
nUpLst)));
+    } while (!bNewFarAway && pUpFrame && ((bNegAllowed && nUp.m_nMain < 0) || 
(nUp <= nUpLst)));
 
     const SwContentFrame *pDownLst;
     const SwContentFrame *pDownFrame = pCnt;

Reply via email to