[Libreoffice-commits] core.git: sc/source
Markus Mohrhard
markus.mohrhard at googlemail.com
Wed Mar 30 03:45:35 UTC 2016
sc/source/core/data/fillinfo.cxx | 38 +++++++++++++++++---------------------
1 file changed, 17 insertions(+), 21 deletions(-)
New commits:
commit 36eec4d179898302578c428564f1b60406c0716c
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>
diff --git a/sc/source/core/data/fillinfo.cxx b/sc/source/core/data/fillinfo.cxx
index 07aafe7..e367088 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 );
More information about the Libreoffice-commits
mailing list