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

New commits:
commit 17db94f1e8425d6ccd430eeda3ec17b4acd1a3d9
Author:     Luboš Luňák <l.lu...@collabora.com>
AuthorDate: Sat Feb 26 12:08:50 2022 +0100
Commit:     Luboš Luňák <l.lu...@collabora.com>
CommitDate: Sat Feb 26 22:22:53 2022 +0100

    do not repeatedly call ColHidden()
    
    The function returns the last column that has the same return value,
    so reuse the return value until that column.
    
    Change-Id: I5d19478ee37068049d4ff035efcacdb5eb724e15
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/130606
    Tested-by: Jenkins
    Reviewed-by: Luboš Luňák <l.lu...@collabora.com>

diff --git a/sc/source/core/data/fillinfo.cxx b/sc/source/core/data/fillinfo.cxx
index db18514b7120..2dc6fbdb7ebe 100644
--- a/sc/source/core/data/fillinfo.cxx
+++ b/sc/source/core/data/fillinfo.cxx
@@ -413,6 +413,8 @@ void ScDocument::FillInfo(
     if (pCondFormList)
         pCondFormList->startRendering();
 
+    SCCOL nLastHiddenCheckedCol = -2;
+    bool bColHidden = false;
     for (SCCOL nCol=-1; nCol<=nCol2+1; nCol++)                    // left & 
right + 1
     {
         if (ValidCol(nCol))
@@ -420,10 +422,13 @@ void ScDocument::FillInfo(
             // #i58049#, #i57939# Hidden columns must be skipped here, or 
their attributes
             // will disturb the output
 
+            if (nCol > nLastHiddenCheckedCol)
+                bColHidden = ColHidden(nCol, nTab, nullptr, 
&nLastHiddenCheckedCol);
             // TODO: Optimize this loop.
-            if (!ColHidden(nCol, nTab))
+            if (!bColHidden)
             {
-                sal_uInt16 nThisWidth = 
static_cast<sal_uInt16>(std::clamp(GetColWidth( nCol, nTab ) * fColScale, 1.0, 
double(std::numeric_limits<sal_uInt16>::max())));
+                sal_uInt16 nColWidth = GetColWidth( nCol, nTab, false ); // 
false=no need to check for hidden, checked above
+                sal_uInt16 nThisWidth = 
static_cast<sal_uInt16>(std::clamp(nColWidth * fColScale, 1.0, 
double(std::numeric_limits<sal_uInt16>::max())));
 
                 pRowInfo[0].cellInfo(nCol).nWidth = nThisWidth;           
//TODO: this should be enough
 

Reply via email to