sc/source/core/data/table1.cxx | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-)
New commits: commit 371f8bd277deb78d1fe8f1201360849fd32ff127 Author: Luboš Luňák <[email protected]> AuthorDate: Fri Jun 10 17:39:46 2022 +0200 Commit: Xisco Fauli <[email protected]> CommitDate: Mon Jun 13 17:14:43 2022 +0200 find last data row before searching for first data row GetLastDataRow() is more efficient than iterating every cell with HasDataAt(), so first reduce the row range from the end (in case the whole range is empty cells it's just one call). Change-Id: Idc494795f68492ed8b05b2cd575598a9c5868b7f Reviewed-on: https://gerrit.libreoffice.org/c/core/+/135605 Tested-by: Jenkins Reviewed-by: Luboš Luňák <[email protected]> (cherry picked from commit 7689bf445264d1b54038ec0b8d134c26847af40f) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/135704 Reviewed-by: Xisco Fauli <[email protected]> diff --git a/sc/source/core/data/table1.cxx b/sc/source/core/data/table1.cxx index 4a293f5068de..0eaf10c786da 100644 --- a/sc/source/core/data/table1.cxx +++ b/sc/source/core/data/table1.cxx @@ -1118,6 +1118,18 @@ bool ScTable::ShrinkToUsedDataArea( bool& o_bShrunk, SCCOL& rStartCol, SCROW& rS if (!bColumnsOnly) { + while (rStartRow < rEndRow) + { + SCROW nLastDataRow = GetLastDataRow(rStartCol, rEndCol, rEndRow, pDataAreaExtras); + if (0 <= nLastDataRow && nLastDataRow < rEndRow) + { + rEndRow = std::max( rStartRow, nLastDataRow); + o_bShrunk = true; + } + else + break; // while + } + if (!bStickyTopRow) { while (rStartRow < rEndRow) @@ -1137,18 +1149,6 @@ bool ScTable::ShrinkToUsedDataArea( bool& o_bShrunk, SCCOL& rStartCol, SCROW& rS break; // while } } - - while (rStartRow < rEndRow) - { - SCROW nLastDataRow = GetLastDataRow(rStartCol, rEndCol, rEndRow, pDataAreaExtras); - if (0 <= nLastDataRow && nLastDataRow < rEndRow) - { - rEndRow = std::max( rStartRow, nLastDataRow); - o_bShrunk = true; - } - else - break; // while - } } return rStartCol != rEndCol || (bColumnsOnly ?
