[Libreoffice-commits] core.git: sc/source

Eike Rathke erack at redhat.com
Tue May 5 08:18:51 PDT 2015


 sc/source/core/data/table1.cxx |   68 ++++++++++++++++++++---------------------
 1 file changed, 34 insertions(+), 34 deletions(-)

New commits:
commit 48d7d093bae06b7883434161882cb9d5f2ce08ae
Author: Eike Rathke <erack at redhat.com>
Date:   Tue May 5 17:12:45 2015 +0200

    rework the twisted ShrinkToUsedDataArea logic
    
    It is unnecessary to check the remaining columns/rows twice if they
    really contain data, and that even for every empty row removed.
    Also, put loops inside conditions instead of conditions inside loop.
    
    Change-Id: Idbb1a647d99806ebab26a17a83b455cacc157c18

diff --git a/sc/source/core/data/table1.cxx b/sc/source/core/data/table1.cxx
index b665e9f..d93d1f4 100644
--- a/sc/source/core/data/table1.cxx
+++ b/sc/source/core/data/table1.cxx
@@ -927,65 +927,65 @@ bool ScTable::ShrinkToUsedDataArea( bool& o_bShrunk, SCCOL& rStartCol, SCROW& rS
     if (rEndRow > MAXROW)
         rEndRow = MAXROW, o_bShrunk = true;
 
-    bool bChanged;
-    do
+    while (rStartCol < rEndCol)
     {
-        bChanged = false;
+        if (aCol[rEndCol].IsEmptyBlock( rStartRow, rEndRow))
+        {
+            --rEndCol;
+            o_bShrunk = true;
+        }
+        else
+            break;  // while
+    }
 
+    if (!bStickyLeftCol)
+    {
         while (rStartCol < rEndCol)
         {
-            if (aCol[rEndCol].IsEmptyBlock( rStartRow, rEndRow))
+            if (aCol[rStartCol].IsEmptyBlock( rStartRow, rEndRow))
             {
-                --rEndCol;
-                bChanged = true;
+                ++rStartCol;
+                o_bShrunk = true;
             }
             else
                 break;  // while
         }
+    }
 
-        if (!bStickyLeftCol)
-        {
-            while (rStartCol < rEndCol)
-            {
-                if (aCol[rStartCol].IsEmptyBlock( rStartRow, rEndRow))
-                {
-                    ++rStartCol;
-                    bChanged = true;
-                }
-                else
-                    break;  // while
-            }
-        }
-
-        if (!bColumnsOnly)
+    if (!bColumnsOnly)
+    {
+        if (!bStickyTopRow)
         {
-            if (!bStickyTopRow && rStartRow < rEndRow)
+            while (rStartRow < rEndRow)
             {
                 bool bFound = false;
                 for (SCCOL i=rStartCol; i<=rEndCol && !bFound; i++)
+                {
                     if (aCol[i].HasDataAt( rStartRow))
                         bFound = true;
+                }
                 if (!bFound)
                 {
                     ++rStartRow;
-                    bChanged = true;
+                    o_bShrunk = true;
                 }
+                else
+                    break;  // while
             }
+        }
 
-            if (rStartRow < rEndRow)
+        while (rStartRow < rEndRow)
+        {
+            SCROW nLastDataRow = GetLastDataRow( rStartCol, rEndCol, rEndRow);
+            if (0 <= nLastDataRow && nLastDataRow < rEndRow)
             {
-                SCROW nLastDataRow = GetLastDataRow( rStartCol, rEndCol, rEndRow);
-                if (0 <= nLastDataRow && nLastDataRow < rEndRow)
-                {
-                    rEndRow = std::max( rStartRow, nLastDataRow);
-                    bChanged = true;
-                }
+                rEndRow = std::max( rStartRow, nLastDataRow);
+                o_bShrunk = true;
             }
+            else
+                break;  // while
         }
-
-        if (bChanged)
-            o_bShrunk = true;
-    } while( bChanged );
+    }
 
     return rStartCol != rEndCol || (bColumnsOnly ?
             !aCol[rStartCol].IsEmptyBlock( rStartRow, rEndRow) :


More information about the Libreoffice-commits mailing list