summaryrefslogtreecommitdiff
path: root/sc
diff options
context:
space:
mode:
authorEike Rathke <erack@redhat.com>2015-05-05 17:12:45 +0200
committerEike Rathke <erack@redhat.com>2015-05-05 17:17:56 +0200
commit48d7d093bae06b7883434161882cb9d5f2ce08ae (patch)
tree2e4aac24b92b83769b78a4dc75dd867158525dc6 /sc
parent8fca0c44e8f21fa2ee1000665856292d5a1c44e9 (diff)
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
Diffstat (limited to 'sc')
-rw-r--r--sc/source/core/data/table1.cxx68
1 files changed, 34 insertions, 34 deletions
diff --git a/sc/source/core/data/table1.cxx b/sc/source/core/data/table1.cxx
index b665e9fa6d22..d93d1f4d7ed3 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) :