[Libreoffice-commits] core.git: sc/source

Kohei Yoshida kohei.yoshida at collabora.com
Fri Jan 31 08:46:53 PST 2014


 sc/source/core/data/table4.cxx |   50 ++++++++++++++++++++++++++---------------
 1 file changed, 32 insertions(+), 18 deletions(-)

New commits:
commit b74233d410b1d25c7fab3bf360dc61bf1f2c769c
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date:   Fri Jan 31 11:49:44 2014 -0500

    Slight optimization by avoiding to query for hidden state unnecessarily.
    
    Also removing static_cast during the loop speeds it up just a bit.
    
    Change-Id: I4644046c91da71f4b7305e9063a853d03c5921e0

diff --git a/sc/source/core/data/table4.cxx b/sc/source/core/data/table4.cxx
index 0755cd6..ca89428 100644
--- a/sc/source/core/data/table4.cxx
+++ b/sc/source/core/data/table4.cxx
@@ -1261,19 +1261,24 @@ void ScTable::IncDate(double& rVal, sal_uInt16& nDayOfMonth, double nStep, FillD
     rVal = aDate - aNullDate;
 }
 
-namespace
-{
+namespace {
 
-bool HiddenRowColumn(sal_uLong nRowColumn, bool bVertical, ScTable* pTable)
+bool HiddenRowColumn(ScTable* pTable, SCCOLROW nRowColumn, bool bVertical, SCCOLROW& rLastPos)
 {
+    bool bHidden = false;
     if(bVertical)
     {
-        return pTable->RowHidden(static_cast<SCROW>(nRowColumn));
+        SCROW nLast;
+        bHidden = pTable->RowHidden(nRowColumn, NULL, &nLast);
+        rLastPos = nLast;
     }
     else
     {
-        return pTable->ColHidden(static_cast<SCCOL>(nRowColumn));
+        SCCOL nLast;
+        bHidden = pTable->ColHidden(static_cast<SCCOL>(nRowColumn), NULL, &nLast);
+        rLastPos = nLast;
     }
+    return bHidden;
 }
 
 }
@@ -1290,15 +1295,15 @@ void ScTable::FillSeries( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
     bool bVertical = (eFillDir == FILL_TO_BOTTOM || eFillDir == FILL_TO_TOP);
     bool bPositive = (eFillDir == FILL_TO_BOTTOM || eFillDir == FILL_TO_RIGHT);
 
-    sal_uLong nCol = 0;
-    sal_uLong nRow = 0;
-    sal_uLong& rInner = bVertical ? nRow : nCol;        // loop variables
-    sal_uLong& rOuter = bVertical ? nCol : nRow;
-    sal_uLong nOStart;
-    sal_uLong nOEnd;
-    sal_uLong nIStart;
-    sal_uLong nIEnd;
-    sal_uLong nISource;
+    SCCOLROW nCol = 0;
+    SCCOLROW nRow = 0;
+    SCCOLROW& rInner = bVertical ? nRow : nCol;        // loop variables
+    SCCOLROW& rOuter = bVertical ? nCol : nRow;
+    SCCOLROW nOStart;
+    SCCOLROW nOEnd;
+    SCCOLROW nIStart;
+    SCCOLROW nIEnd;
+    SCCOLROW nISource;
     ScRange aFillRange;
 
     if (bVertical)
@@ -1346,8 +1351,8 @@ void ScTable::FillSeries( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
         }
     }
 
-    sal_uLong nIMin = nIStart;
-    sal_uLong nIMax = nIEnd;
+    SCCOLROW nIMin = nIStart;
+    SCCOLROW nIMax = nIEnd;
     PutInOrder(nIMin,nIMax);
     sal_uInt16 nDel = bAttribs ? IDF_AUTOFILL : (IDF_AUTOFILL & IDF_CONTENTS);
 
@@ -1444,12 +1449,18 @@ void ScTable::FillSeries( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
 
             if (eFillCmd == FILL_SIMPLE)                // copy
             {
+                bool bHidden = false;
+                SCCOLROW nHiddenValid = -1;
+
                 if (eCellType == CELLTYPE_FORMULA)
                 {
                     bool bFirst = true;
                     for (rInner = nIMin; rInner <= nIMax; rInner++)
                     {
-                        if(HiddenRowColumn(rInner, bVertical, this))
+                        if (rInner > nHiddenValid)
+                            bHidden = HiddenRowColumn(this, rInner, bVertical, nHiddenValid);
+
+                        if (bHidden)
                             continue;
                         sal_uLong nInd = nActFormCnt;
                         FillFormula(nInd, bFirst, aSrcCell.mpFormula,
@@ -1463,7 +1474,10 @@ void ScTable::FillSeries( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
                 {
                     for (rInner = nIMin; rInner <= nIMax; rInner++)
                     {
-                        if(HiddenRowColumn(rInner, bVertical, this))
+                        if (rInner > nHiddenValid)
+                            bHidden = HiddenRowColumn(this, rInner, bVertical, nHiddenValid);
+
+                        if (bHidden)
                             continue;
                         ScAddress aDestPos( static_cast<SCCOL>(nCol), static_cast<SCROW>(nRow), nTab );
                         aSrcCell.commit(aCol[nCol], aDestPos.Row());


More information about the Libreoffice-commits mailing list