Kaydet (Commit) 48d7d093 authored tarafından Eike Rathke's avatar Eike Rathke

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
üst 8fca0c44
......@@ -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) :
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment