summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarkus Mohrhard <markus.mohrhard@googlemail.com>2016-03-30 02:15:07 +0200
committerAshod Nakashian <ashnakash@gmail.com>2016-05-22 03:35:01 +0000
commit5345c0f7ae6d2cad6814dc112c68ba3e6239fd8f (patch)
tree70b3eef284467583194d8bd96550be9dbd3939b5
parentb2a02da8e7866dd5ce61bf5cff56d6066f3e4a06 (diff)
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@libreoffice.org> Reviewed-by: Markus Mohrhard <markus.mohrhard@googlemail.com> (cherry picked from commit 36eec4d179898302578c428564f1b60406c0716c) Reviewed-on: https://gerrit.libreoffice.org/25287 Reviewed-by: Ashod Nakashian <ashnakash@gmail.com> Tested-by: Ashod Nakashian <ashnakash@gmail.com>
-rw-r--r--sc/source/core/data/fillinfo.cxx38
1 files changed, 17 insertions, 21 deletions
diff --git a/sc/source/core/data/fillinfo.cxx b/sc/source/core/data/fillinfo.cxx
index b29155059774..92c38bbaca5d 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 );