sw/source/core/docnode/ndsect.cxx |   62 +++++++++++++++++---------------------
 1 file changed, 28 insertions(+), 34 deletions(-)

New commits:
commit b77775de1ab530912153a9fcc571efb300c2888e
Author:     Arnaud VERSINI <arnaud.vers...@libreoffice.org>
AuthorDate: Mon Apr 10 19:32:38 2023 +0200
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Tue Apr 11 19:06:06 2023 +0200

    sw : small code simplification in lcl_IsInSameTableBox
    
    Change-Id: Ic72a49deee17d907639e67ef31e0ca932bf66215
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/150188
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk>

diff --git a/sw/source/core/docnode/ndsect.cxx 
b/sw/source/core/docnode/ndsect.cxx
index f4fe9b9a3ec4..cf96e1d5094b 100644
--- a/sw/source/core/docnode/ndsect.cxx
+++ b/sw/source/core/docnode/ndsect.cxx
@@ -75,42 +75,36 @@ static bool lcl_IsInSameTableBox( SwNodes const & _rNds,
 
     // determine index to be checked. Its assumed that a previous/next exist.
     SwNodeIndex aChkIdx( _rNd );
+
+    // determine index of previous/next - skip hidden ones, which are
+    // inside the table.
+    // If found one is before/after table, this one isn't in the same
+    // table box as <_rNd>.
+    for(;;)
     {
-        // determine index of previous/next - skip hidden ones, which are
-        // inside the table.
-        // If found one is before/after table, this one isn't in the same
-        // table box as <_rNd>.
-        bool bFound = false;
-        do
+        if ( _bPrev
+                ? !SwNodes::GoPrevSection( &aChkIdx, false, false )
+                : !_rNds.GoNextSection( &aChkIdx, false, false ) )
         {
-            if ( _bPrev
-                 ? !SwNodes::GoPrevSection( &aChkIdx, false, false )
-                 : !_rNds.GoNextSection( &aChkIdx, false, false ) )
-            {
-                OSL_FAIL( "<lcl_IsInSameTableBox(..)> - no previous/next!" );
-                return false;
-            }
-            else
-            {
-                if ( aChkIdx < pTableNd->GetIndex() ||
-                     aChkIdx > pTableNd->EndOfSectionNode()->GetIndex() )
-                {
-                    return false;
-                }
-                else
-                {
-                    // check, if found one isn't inside a hidden section, which
-                    // is also inside the table.
-                    SwSectionNode* pSectNd = 
aChkIdx.GetNode().FindSectionNode();
-                    if ( !pSectNd ||
-                         pSectNd->GetIndex() < pTableNd->GetIndex() ||
-                         !pSectNd->GetSection().IsHiddenFlag() )
-                    {
-                        bFound = true;
-                    }
-                }
-            }
-        } while ( !bFound );
+            OSL_FAIL( "<lcl_IsInSameTableBox(..)> - no previous/next!" );
+            return false;
+        }
+
+        if ( aChkIdx < pTableNd->GetIndex() ||
+                aChkIdx > pTableNd->EndOfSectionNode()->GetIndex() )
+        {
+            return false;
+        }
+
+        // check, if found one isn't inside a hidden section, which
+        // is also inside the table.
+        SwSectionNode* pSectNd = aChkIdx.GetNode().FindSectionNode();
+        if ( !pSectNd ||
+                pSectNd->GetIndex() < pTableNd->GetIndex() ||
+                !pSectNd->GetSection().IsHiddenFlag() )
+        {
+            break;
+        }
     }
 
     // Find the Box's StartNode

Reply via email to