[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-5.0' - 2 commits - sc/source

Markus Mohrhard markus.mohrhard at googlemail.com
Sun May 22 03:35:07 UTC 2016


 sc/source/core/data/fillinfo.cxx |   73 +++++++++++++++++++--------------------
 1 file changed, 37 insertions(+), 36 deletions(-)

New commits:
commit 5345c0f7ae6d2cad6814dc112c68ba3e6239fd8f
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Wed Mar 30 02:15:07 2016 +0200

    limit the scope of a few variable in ScDocument::FillInfo
    
    This makes the code at least a little bit easier to read as we can now
    see much easier when a variable is used to transport state between loops
    and when it is just a variable local to a loop
    
    Change-Id: Ib92ff1596bda35f9892accc820bc3596bafb7d96
    Reviewed-on: https://gerrit.libreoffice.org/23632
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Markus Mohrhard <markus.mohrhard at googlemail.com>
    (cherry picked from commit 36eec4d179898302578c428564f1b60406c0716c)
    Reviewed-on: https://gerrit.libreoffice.org/25287
    Reviewed-by: Ashod Nakashian <ashnakash at gmail.com>
    Tested-by: Ashod Nakashian <ashnakash at gmail.com>

diff --git a/sc/source/core/data/fillinfo.cxx b/sc/source/core/data/fillinfo.cxx
index b291550..92c38bb 100644
--- a/sc/source/core/data/fillinfo.cxx
+++ b/sc/source/core/data/fillinfo.cxx
@@ -209,27 +209,28 @@ bool isRotateItemUsed(ScDocumentPool *pPool)
     return false;
 }
 
-void initRowInfo(ScDocument* pDoc, RowInfo* pRowInfo, SCROW& rY,
+void initRowInfo(ScDocument* pDoc, RowInfo* pRowInfo,
         double fRowScale, SCROW nRow1, SCTAB nTab, SCROW& rYExtra, SCSIZE& rArrRow, SCROW& rRow2)
 {
     sal_uInt16 nDocHeight = ScGlobal::nStdRowHeight;
     SCROW nDocHeightEndRow = -1;
     for (SCsROW nSignedY=((SCsROW)nRow1)-1; nSignedY<=(SCsROW)rYExtra; nSignedY++)
     {
+        SCROW nY;
         if (nSignedY >= 0)
-            rY = (SCROW) nSignedY;
+            nY = (SCROW) nSignedY;
         else
-            rY = MAXROW+1;          // invalid
+            nY = MAXROW+1;          // invalid
 
-        if (rY > nDocHeightEndRow)
+        if (nY > nDocHeightEndRow)
         {
-            if (ValidRow(rY))
-                nDocHeight = pDoc->GetRowHeight( rY, nTab, nullptr, &nDocHeightEndRow );
+            if (ValidRow(nY))
+                nDocHeight = pDoc->GetRowHeight( nY, nTab, nullptr, &nDocHeightEndRow );
             else
                 nDocHeight = ScGlobal::nStdRowHeight;
         }
 
-        if ( rArrRow==0 || nDocHeight || rY > MAXROW )
+        if ( rArrRow==0 || nDocHeight || nY > MAXROW )
         {
             RowInfo* pThisRowInfo = &pRowInfo[rArrRow];
             pThisRowInfo->pCellInfo = nullptr;                 // is loaded below
@@ -238,7 +239,7 @@ void initRowInfo(ScDocument* pDoc, RowInfo* pRowInfo, SCROW& rY,
             if (!nHeight)
                 nHeight = 1;
 
-            pThisRowInfo->nRowNo        = rY;               //TODO: case < 0 ?
+            pThisRowInfo->nRowNo        = nY;               //TODO: case < 0 ?
             pThisRowInfo->nHeight       = nHeight;
             pThisRowInfo->bEmptyBack    = true;
             pThisRowInfo->bEmptyText    = true;
@@ -360,11 +361,6 @@ void ScDocument::FillInfo(
     const SvxShadowItem* pDefShadow =
             static_cast<const SvxShadowItem*>( &pPool->GetDefaultItem( ATTR_SHADOW ) );
 
-    SCROW nThisRow;
-    SCCOL nX;
-    SCROW nY;
-    SCsROW nSignedY;
-    SCCOL nArrCol;
     SCSIZE nArrRow;
     SCSIZE nArrCount;
     bool bAnyMerged = false;
@@ -402,7 +398,7 @@ void ScDocument::FillInfo(
 
     nArrRow=0;
     SCROW nYExtra = nRow2+1;
-    initRowInfo(this, pRowInfo, nY, fRowScale, nRow1,
+    initRowInfo(this, pRowInfo, fRowScale, nRow1,
             nTab, nYExtra, nArrRow, nRow2);
     nArrCount = nArrRow;                                      // incl. Dummys
 
@@ -437,9 +433,9 @@ void ScDocument::FillInfo(
     if(pCondFormList)
         pCondFormList->startRendering();
 
-    for (nArrCol=0; nArrCol<=nCol2+2; nArrCol++)                    // left & right + 1
+    for (SCCOL nArrCol=0; nArrCol<=nCol2+2; nArrCol++)                    // left & right + 1
     {
-        nX = (nArrCol>0) ? nArrCol-1 : MAXCOL+1;                    // negative -> invalid
+        SCCOL nX = (nArrCol>0) ? nArrCol-1 : MAXCOL+1;                    // negative -> invalid
 
         if ( ValidCol(nX) )
         {
@@ -475,7 +471,7 @@ void ScDocument::FillInfo(
                         --nCurRow;                      // 1 more on top
                     else
                         nArrRow = 1;
-                    nThisRow=nCurRow;                   // end of range
+                    SCROW nThisRow = nCurRow;                   // end of range
                     SCSIZE  nIndex;
                     (void) pThisAttrArr->Search( nCurRow, nIndex );
 
@@ -712,7 +708,7 @@ void ScDocument::FillInfo(
     {
         for (nArrRow=0; nArrRow<nArrCount; nArrRow++)
         {
-            for (nArrCol=nCol1; nArrCol<=nCol2+2; nArrCol++)                  // 1 more left and right
+            for (SCCOL nArrCol=nCol1; nArrCol<=nCol2+2; nArrCol++)                  // 1 more left and right
             {
                 CellInfo* pInfo = &pRowInfo[nArrRow].pCellInfo[nArrCol];
                 SCCOL nCol = (nArrCol>0) ? nArrCol-1 : MAXCOL+1;
@@ -775,9 +771,9 @@ void ScDocument::FillInfo(
         for (nArrRow=0; nArrRow<nArrCount; nArrRow++)
         {
             RowInfo* pThisRowInfo = &pRowInfo[nArrRow];
-            nSignedY = nArrRow ? pThisRowInfo->nRowNo : ((SCsROW)nRow1)-1;
+            SCsROW nSignedY = nArrRow ? pThisRowInfo->nRowNo : ((SCsROW)nRow1)-1;
 
-            for (nArrCol=nCol1; nArrCol<=nCol2+2; nArrCol++)                  // 1 more left and right
+            for (SCCOL nArrCol=nCol1; nArrCol<=nCol2+2; nArrCol++)                  // 1 more left and right
             {
                 SCsCOL nSignedX = ((SCsCOL) nArrCol) - 1;
                 CellInfo* pInfo = &pThisRowInfo->pCellInfo[nArrCol];
@@ -840,7 +836,7 @@ void ScDocument::FillInfo(
             bool bTop = ( nArrRow == 0 );
             bool bBottom = ( nArrRow+1 == nArrCount );
 
-            for (nArrCol=nCol1; nArrCol<=nCol2+2; nArrCol++)                  // 1 more left and right
+            for (SCCOL nArrCol=nCol1; nArrCol<=nCol2+2; nArrCol++)                  // 1 more left and right
             {
                 bool bLeft = ( nArrCol == nCol1 );
                 bool bRight = ( nArrCol == nCol2+2 );
commit b2a02da8e7866dd5ce61bf5cff56d6066f3e4a06
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Wed Mar 30 01:50:53 2016 +0200

    extract another function from ScDocument::FillInfo
    
    Change-Id: Iac607e1fe915c8bc90316508c98855a60117d435
    Reviewed-on: https://gerrit.libreoffice.org/23631
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Markus Mohrhard <markus.mohrhard at googlemail.com>
    (cherry picked from commit 772e66406b90bdb898e73b4fa944a6e55a42683b)
    Reviewed-on: https://gerrit.libreoffice.org/25286
    Reviewed-by: Ashod Nakashian <ashnakash at gmail.com>
    Tested-by: Ashod Nakashian <ashnakash at gmail.com>

diff --git a/sc/source/core/data/fillinfo.cxx b/sc/source/core/data/fillinfo.cxx
index 6e5dc7b..b291550 100644
--- a/sc/source/core/data/fillinfo.cxx
+++ b/sc/source/core/data/fillinfo.cxx
@@ -318,6 +318,25 @@ void initCellInfo(RowInfo* pRowInfo, SCSIZE nArrCount, SCCOL nRotMax, bool bPain
     }
 }
 
+void initColWidths(RowInfo* pRowInfo, ScDocument* pDoc, double fColScale, SCTAB nTab, SCCOL nCol2, SCCOL nRotMax)
+{
+    for (SCCOL nArrCol=nCol2+3; nArrCol<=nRotMax+2; nArrCol++)    // Add remaining widths
+    {
+        SCCOL nX = nArrCol-1;
+        if ( ValidCol(nX) )
+        {
+            if (!pDoc->ColHidden(nX, nTab))
+            {
+                sal_uInt16 nThisWidth = (sal_uInt16) (pDoc->GetColWidth( nX, nTab ) * fColScale);
+                if (!nThisWidth)
+                    nThisWidth = 1;
+
+                pRowInfo[0].pCellInfo[nArrCol].nWidth = nThisWidth;
+            }
+        }
+    }
+}
+
 }
 
 void ScDocument::FillInfo(
@@ -412,21 +431,7 @@ void ScDocument::FillInfo(
     initCellInfo(pRowInfo, nArrCount, nRotMax, bPaintMarks, pDefShadow,
             nBlockStartY, nBlockEndY, nBlockStartX, nBlockEndX);
 
-    for (nArrCol=nCol2+3; nArrCol<=nRotMax+2; nArrCol++)    // Add remaining widths
-    {
-        nX = nArrCol-1;
-        if ( ValidCol(nX) )
-        {
-            if (!ColHidden(nX, nTab))
-            {
-                sal_uInt16 nThisWidth = (sal_uInt16) (GetColWidth( nX, nTab ) * fColScale);
-                if (!nThisWidth)
-                    nThisWidth = 1;
-
-                pRowInfo[0].pCellInfo[nArrCol].nWidth = nThisWidth;
-            }
-        }
-    }
+    initColWidths(pRowInfo, this, fColScale, nTab, nCol2, nRotMax);
 
     ScConditionalFormatList* pCondFormList = GetCondFormList(nTab);
     if(pCondFormList)


More information about the Libreoffice-commits mailing list