From 0c60f87ceaa9f33cc55ad3362c950163fbacb05c Mon Sep 17 00:00:00 2001
From: Jesso Clarence Murugan <jmurugan@kacst.edu.sa>
Date: Mon, 9 Jul 2012 14:04:19 +0300
Subject: [PATCH] Improved for loop in ExpandColumnSelection function in
 swnewtable.cxx

Change-Id: Ia906dd8bc6b86143b9e91b9416f323033475ea7e
---
 sw/source/core/table/swnewtable.cxx |   28 +++++++++-------------------
 1 file changed, 9 insertions(+), 19 deletions(-)

diff --git a/sw/source/core/table/swnewtable.cxx b/sw/source/core/table/swnewtable.cxx
index 644b38c..53247e1 100644
--- a/sw/source/core/table/swnewtable.cxx
+++ b/sw/source/core/table/swnewtable.cxx
@@ -1810,34 +1810,24 @@ void SwTable::ExpandColumnSelection( SwSelBoxes& rBoxes, long &rMin, long &rMax
     sal_uInt16 nLineCnt = aLines.size();
     sal_uInt16 nBoxCnt = rBoxes.Count();
     sal_uInt16 nBox = 0;
-    for( sal_uInt16 nRow = 0; nRow < nLineCnt && nBox < nBoxCnt; ++nRow )
-    {
-        SwTableLine* pLine = aLines[nRow];
-        OSL_ENSURE( pLine, "Missing table line" );
-        sal_uInt16 nCols = pLine->GetTabBoxes().size();
-        for( sal_uInt16 nCol = 0; nCol < nCols; ++nCol )
-        {
-            SwTableBox* pBox = pLine->GetTabBoxes()[nCol];
-            OSL_ENSURE( pBox, "Missing table box" );
-            if( pBox == rBoxes[nBox] )
-            {
-                lcl_CheckMinMax( rMin, rMax, *pLine, nCol, nBox == 0 );
-                if( ++nBox >= nBoxCnt )
-                    break;
-            }
-        }
-    }
-    nBox = 0;
     for( sal_uInt16 nRow = 0; nRow < nLineCnt; ++nRow )
     {
         SwTableLine* pLine = aLines[nRow];
+        OSL_ENSURE( pLine, "Missing table line" );
         sal_uInt16 nCols = pLine->GetTabBoxes().size();
         long nLeft = 0;
         long nRight = 0;
         for( sal_uInt16 nCurrBox = 0; nCurrBox < nCols; ++nCurrBox )
         {
-            nLeft = nRight;
             SwTableBox* pBox = pLine->GetTabBoxes()[nCurrBox];
+            OSL_ENSURE( pBox, "Missing table box" );
+            if( nBox < nBoxCnt)
+            {
+                if( pBox == rBoxes[nBox] )
+                    lcl_CheckMinMax( rMin, rMax, *pLine, nCurrBox, nBox == 0 );
+                ++nBox;
+            }
+            nLeft = nRight;
             nRight += pBox->GetFrmFmt()->GetFrmSize().GetWidth();
             if( nLeft >= rMin && nRight <= rMax )
                 rBoxes.Insert( pBox );
-- 
1.7.9.5

