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.grandin@collabora.co.uk>
(cherry picked from commit 6931a596350086d52ba32bf8a84cb36fbfdb34d6)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/165617
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
diff --git a/sc/source/core/data/table1.cxx b/sc/source/core/data/table1.cxx
index 93d023f..4df5d92 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;
    }