sc/source/core/data/table1.cxx |   21 +++++++++++++++++----
 sc/source/ui/view/printfun.cxx |    6 +++---
 2 files changed, 20 insertions(+), 7 deletions(-)

New commits:
commit 153c4c7e6ab066c6b1c06704e08e5be815cfc024
Author:     Serge Krot <serge.k...@cib.de>
AuthorDate: Fri Feb 7 18:16:49 2020 +0100
Commit:     Thorsten Behrens <thorsten.behr...@cib.de>
CommitDate: Sat Feb 8 18:09:59 2020 +0100

    tdf#128873 speed up switching into page layout
    
    Change-Id: I993fdafe226680ac718f4611cfb1f842bc99f385
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/88231
    Tested-by: Jenkins
    Reviewed-by: Thorsten Behrens <thorsten.behr...@cib.de>

diff --git a/sc/source/core/data/table1.cxx b/sc/source/core/data/table1.cxx
old mode 100644
new mode 100755
index 7b6f1f771eb8..0b25f838d676
--- a/sc/source/core/data/table1.cxx
+++ b/sc/source/core/data/table1.cxx
@@ -2039,11 +2039,24 @@ void ScTable::ExtendPrintArea( OutputDevice* pDev,
 
 void ScTable::MaybeAddExtraColumn(SCCOL& rCol, SCROW nRow, OutputDevice* pDev, 
double nPPTX, double nPPTY)
 {
-    ScRefCellValue aCell = aCol[rCol].GetCellValue(nRow);
+    // tdf#128873 we do not need to calculate text width (heavy operation)
+    // when we for sure know that an additional column will not be added
+    if (GetAllocatedColumnsCount() > rCol + 1)
+    {
+        ScRefCellValue aNextCell = aCol[rCol + 1].GetCellValue(nRow);
+        if (!aNextCell.isEmpty())
+        {
+            // return rCol as is
+            return;
+        }
+    }
+
+    ScColumn& rColumn = aCol[rCol];
+    ScRefCellValue aCell = rColumn.GetCellValue(nRow);
     if (!aCell.hasString())
         return;
 
-    long nPixel = aCol[rCol].GetTextWidth(nRow);
+    long nPixel = rColumn.GetTextWidth(nRow);
 
     // Width already calculated in Idle-Handler ?
     if ( TEXTWIDTH_DIRTY == nPixel )
@@ -2054,10 +2067,10 @@ void ScTable::MaybeAddExtraColumn(SCCOL& rCol, SCROW 
nRow, OutputDevice* pDev, d
         aOptions.bSkipMerged = false;
 
         Fraction aZoom(1,1);
-        nPixel = aCol[rCol].GetNeededSize(
+        nPixel = rColumn.GetNeededSize(
             nRow, pDev, nPPTX, nPPTY, aZoom, aZoom, true, aOptions, nullptr );
 
-        aCol[rCol].SetTextWidth(nRow, static_cast<sal_uInt16>(nPixel));
+        rColumn.SetTextWidth(nRow, static_cast<sal_uInt16>(nPixel));
     }
 
     long nTwips = static_cast<long>(nPixel / nPPTX);
diff --git a/sc/source/ui/view/printfun.cxx b/sc/source/ui/view/printfun.cxx
index dc1930baff27..799f5fa3ae0c 100644
--- a/sc/source/ui/view/printfun.cxx
+++ b/sc/source/ui/view/printfun.cxx
@@ -421,13 +421,13 @@ static void lcl_HidePrint( const ScTableInfo& rTabInfo, 
SCCOL nX1, SCCOL nX2 )
         RowInfo* pThisRowInfo = &rTabInfo.mpRowInfo[nArrY];
         for (SCCOL nX=nX1; nX<=nX2; nX++)
         {
-            const CellInfo& rCellInfo = pThisRowInfo->pCellInfo[nX+1];
+            CellInfo& rCellInfo = pThisRowInfo->pCellInfo[nX+1];
             if (!rCellInfo.bEmptyCellText)
                 if (rCellInfo.pPatternAttr->
                             GetItem(ATTR_PROTECTION, 
rCellInfo.pConditionSet).GetHidePrint())
                 {
-                    pThisRowInfo->pCellInfo[nX+1].maCell.clear();
-                    pThisRowInfo->pCellInfo[nX+1].bEmptyCellText = true;
+                    rCellInfo.maCell.clear();
+                    rCellInfo.bEmptyCellText = true;
                 }
         }
     }
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to