sw/source/core/doc/textboxhelper.cxx |   20 ++++----------------
 1 file changed, 4 insertions(+), 16 deletions(-)

New commits:
commit 750a77bf3df5813c6b7ca7ca38cf4f41474a7395
Author:     Noel Grandin <noel.gran...@collabora.co.uk>
AuthorDate: Tue Jun 25 15:23:45 2024 +0200
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Wed Jun 26 14:50:52 2024 +0200

    simplify logic in DoTextBoxZOrderCorrection
    
    which is doing things in an unnecessarily complex way.
    
    The simpler way makes a complex DOCX file load 20% faster
    
    Change-Id: I507e2bfd5e315f50e4fa790711286785e0f11445
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/169529
    Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk>
    Tested-by: Jenkins

diff --git a/sw/source/core/doc/textboxhelper.cxx 
b/sw/source/core/doc/textboxhelper.cxx
index a1391fe34a5b..4bc8b08092e6 100644
--- a/sw/source/core/doc/textboxhelper.cxx
+++ b/sw/source/core/doc/textboxhelper.cxx
@@ -1536,26 +1536,14 @@ bool 
SwTextBoxHelper::DoTextBoxZOrderCorrection(SwFrameFormat* pShape, const Sdr
                 auto pPage = pDrawModel->GetPage(0);
                 // Recalc all Z-orders
                 pPage->RecalcObjOrdNums();
-                // Here is a counter avoiding running to in infinity:
-                sal_uInt16 nIterator = 0;
                 // If the shape is behind the frame, is good, but if there are 
some objects
                 // between of them that is wrong so put the frame exactly one 
level higher
                 // than the shape.
-                if (pFrmObj->GetOrdNum() > pShpObj->GetOrdNum())
+                if (pFrmObj->GetOrdNum() != pShpObj->GetOrdNum() + 1)
+                {
                     pPage->SetObjectOrdNum(pFrmObj->GetOrdNum(), 
pShpObj->GetOrdNum() + 1);
-                else
-                    // Else, if the frame is behind the shape, bring to the 
front of it.
-                    while (pFrmObj->GetOrdNum() <= pShpObj->GetOrdNum())
-                    {
-                        pPage->SetObjectOrdNum(pFrmObj->GetOrdNum(), 
pFrmObj->GetOrdNum() + 1);
-                        // If there is any problem with the indexes, do not 
run over the infinity
-                        if (pPage->GetObjCount() == pFrmObj->GetOrdNum())
-                            break;
-                        ++nIterator;
-                        if (nIterator > 300)
-                            break; // Do not run to infinity
-                    }
-                pPage->RecalcObjOrdNums();
+                    pPage->RecalcObjOrdNums();
+                }
                 return true; // Success
             }
             SAL_WARN("sw.core", "SwTextBoxHelper::DoTextBoxZOrderCorrection(): 
"

Reply via email to