sc/source/core/data/table1.cxx |   16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)

New commits:
commit 02b100e8ecbe47bd8d70d81dbefcb24be0501b8b
Author:     Noel Grandin <noel.gran...@collabora.co.uk>
AuthorDate: Thu Mar 28 13:17:50 2024 +0200
Commit:     Xisco Fauli <xiscofa...@libreoffice.org>
CommitDate: Mon Apr 8 16:54:28 2024 +0200

    tdf#160399 speed up print preview
    
    takes time from 11s to 5s for me
    
    Change-Id: Ic874b9168f9caaf697007e586df8499a849ccfd6
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/165460
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk>
    (cherry picked from commit 6931a596350086d52ba32bf8a84cb36fbfdb34d6)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/165617
    Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org>

diff --git a/sc/source/core/data/table1.cxx b/sc/source/core/data/table1.cxx
index 93d023f96246..4df5d92ec5e5 100644
--- a/sc/source/core/data/table1.cxx
+++ b/sc/source/core/data/table1.cxx
@@ -2091,17 +2091,19 @@ void ScTable::ExtendPrintArea( OutputDevice* pDev,
         else
         {
             // These columns are visible.  Check for empty columns.
-            for (SCCOL j = i; j <= nLastCol; ++j)
+            SCCOL nEmptyCount = 0;
+            SCCOL j = i;
+            for (; j <= nLastCol; ++j)
             {
                 if ( j >= aCol.size() )
-                {
-                    aSkipCols.setTrue( j, rDocument.MaxCol() );
                     break;
-                }
-                if (aCol[j].GetCellCount() == 0)
-                    // empty
-                    aSkipCols.setTrue(j,j);
+                if (aCol[j].GetCellCount() == 0) // empty
+                    nEmptyCount++;
             }
+            if (nEmptyCount)
+                aSkipCols.setTrue(i,i+nEmptyCount);
+            if ( j >= aCol.size() )
+                aSkipCols.setTrue( j, rDocument.MaxCol() );
         }
         i = nLastCol;
     }

Reply via email to