diff options
author | Noel Grandin <noelgrandin@gmail.com> | 2015-10-12 07:45:01 +0200 |
---|---|---|
committer | Noel Grandin <noelgrandin@gmail.com> | 2015-10-12 06:52:56 +0000 |
commit | ccc5ea08d64c38a9ce925d448c3010aca19ed35c (patch) | |
tree | e50c45ee596185f9a030641465796394c71ad410 /sc | |
parent | 898aff0d190b09d16cce866909b64cf023cba43f (diff) |
cppcheck:variableScope
Change-Id: I037feb335499629300309851dcda3bb661f03d4f
Reviewed-on: https://gerrit.libreoffice.org/19316
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noelgrandin@gmail.com>
Diffstat (limited to 'sc')
-rw-r--r-- | sc/qa/unit/ucalc.cxx | 7 | ||||
-rw-r--r-- | sc/source/core/data/document.cxx | 6 | ||||
-rw-r--r-- | sc/source/core/data/table1.cxx | 3 | ||||
-rw-r--r-- | sc/source/core/data/table2.cxx | 6 | ||||
-rw-r--r-- | sc/source/core/tool/interpr2.cxx | 2 | ||||
-rw-r--r-- | sc/source/filter/excel/excimp8.cxx | 5 | ||||
-rw-r--r-- | sc/source/filter/xml/XMLStylesExportHelper.cxx | 76 |
7 files changed, 48 insertions, 57 deletions
diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx index 0dda665f5e3c..9e5e5774fed4 100644 --- a/sc/qa/unit/ucalc.cxx +++ b/sc/qa/unit/ucalc.cxx @@ -1216,17 +1216,14 @@ void Test::testValueIterator() for (SCCOL i = 1; i <= 3; ++i) m_pDoc->SetValue(ScAddress(i,2,0), i); - double fVal; - sal_uInt16 nErr; - { const double aChecks[] = { 1.0, 2.0, 3.0 }; size_t nCheckLen = SAL_N_ELEMENTS(aChecks); - ScValueIterator aIter(m_pDoc, ScRange(1,2,0,3,2,0)); bool bHas = false; - size_t nCheckPos = 0; + double fVal; + sal_uInt16 nErr; for (bHas = aIter.GetFirst(fVal, nErr); bHas; bHas = aIter.GetNext(fVal, nErr), ++nCheckPos) { CPPUNIT_ASSERT_MESSAGE("Iteration longer than expected.", nCheckPos < nCheckLen); diff --git a/sc/source/core/data/document.cxx b/sc/source/core/data/document.cxx index 8fafa7b3b3dc..221c1d6f612c 100644 --- a/sc/source/core/data/document.cxx +++ b/sc/source/core/data/document.cxx @@ -5798,10 +5798,9 @@ void ScDocument::UpdStlShtPtrsFrmNms() ScDocumentPool* pPool = xPoolHelper->GetDocPool(); sal_uInt32 nCount = pPool->GetItemCount2(ATTR_PATTERN); - ScPatternAttr* pPattern; for (sal_uInt32 i=0; i<nCount; i++) { - pPattern = const_cast<ScPatternAttr*>(static_cast<const ScPatternAttr*>(pPool->GetItem2(ATTR_PATTERN, i))); + ScPatternAttr* pPattern = const_cast<ScPatternAttr*>(static_cast<const ScPatternAttr*>(pPool->GetItem2(ATTR_PATTERN, i))); if (pPattern) pPattern->UpdateStyleSheet(this); } @@ -5813,10 +5812,9 @@ void ScDocument::StylesToNames() ScDocumentPool* pPool = xPoolHelper->GetDocPool(); sal_uInt32 nCount = pPool->GetItemCount2(ATTR_PATTERN); - ScPatternAttr* pPattern; for (sal_uInt32 i=0; i<nCount; i++) { - pPattern = const_cast<ScPatternAttr*>(static_cast<const ScPatternAttr*>(pPool->GetItem2(ATTR_PATTERN, i))); + ScPatternAttr* pPattern = const_cast<ScPatternAttr*>(static_cast<const ScPatternAttr*>(pPool->GetItem2(ATTR_PATTERN, i))); if (pPattern) pPattern->StyleToName(); } diff --git a/sc/source/core/data/table1.cxx b/sc/source/core/data/table1.cxx index 3ad5b2ff335d..df81cfd9ca6e 100644 --- a/sc/source/core/data/table1.cxx +++ b/sc/source/core/data/table1.cxx @@ -1800,7 +1800,6 @@ void ScTable::MaybeAddExtraColumn(SCCOL& rCol, SCROW nRow, OutputDevice* pDev, d if (!aCell.hasString()) return; - bool bFormula = false; //TODO: pass as parameter long nPixel = aCol[rCol].GetTextWidth(nRow); // Width already calculated in Idle-Handler ? @@ -1808,7 +1807,7 @@ void ScTable::MaybeAddExtraColumn(SCCOL& rCol, SCROW nRow, OutputDevice* pDev, d { ScNeededSizeOptions aOptions; aOptions.bTotalSize = true; - aOptions.bFormula = bFormula; + aOptions.bFormula = false; //TODO: pass as parameter aOptions.bSkipMerged = false; Fraction aZoom(1,1); diff --git a/sc/source/core/data/table2.cxx b/sc/source/core/data/table2.cxx index 1b6a5bc16815..b4f143e65346 100644 --- a/sc/source/core/data/table2.cxx +++ b/sc/source/core/data/table2.cxx @@ -931,8 +931,6 @@ void ScTable::TransposeClip( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, void ScTable::TransposeColNotes(ScTable* pTransClip, SCCOL nCol1, SCCOL nCol, SCROW nRow1, SCROW nRow2) { - bool bCloneCaption = true; - sc::CellNoteStoreType::const_iterator itBlk = aCol[nCol].maCellNotes.begin(), itBlkEnd = aCol[nCol].maCellNotes.end(); // Locate the top row position. @@ -979,7 +977,7 @@ void ScTable::TransposeColNotes(ScTable* pTransClip, SCCOL nCol1, SCCOL nCol, SC ScPostIt* pNote = *itData; if (pNote) { - ScPostIt* pClonedNote = pNote->Clone( ScAddress(nCol, curRow, nTab), *pTransClip->pDocument, aDestPos, bCloneCaption ); + ScPostIt* pClonedNote = pNote->Clone( ScAddress(nCol, curRow, nTab), *pTransClip->pDocument, aDestPos, true ); pTransClip->pDocument->SetNote(aDestPos, pClonedNote); } } @@ -996,7 +994,7 @@ void ScTable::TransposeColNotes(ScTable* pTransClip, SCCOL nCol1, SCCOL nCol, SC ScPostIt* pNote = *itData; if (pNote) { - ScPostIt* pClonedNote = pNote->Clone( ScAddress(nCol, curRow, nTab), *pTransClip->pDocument, aDestPos, bCloneCaption ); + ScPostIt* pClonedNote = pNote->Clone( ScAddress(nCol, curRow, nTab), *pTransClip->pDocument, aDestPos, true ); pTransClip->pDocument->SetNote(aDestPos, pClonedNote); } } diff --git a/sc/source/core/tool/interpr2.cxx b/sc/source/core/tool/interpr2.cxx index 0c0001b3d724..5a59e5c33285 100644 --- a/sc/source/core/tool/interpr2.cxx +++ b/sc/source/core/tool/interpr2.cxx @@ -1742,9 +1742,9 @@ bool ScInterpreter::RateIteration( double fNper, double fPayment, double fPv, if (fNper == ::rtl::math::round( fNper, 0, rtl_math_RoundingMode_Corrected )) { // Nper is an integer value fX = fGuess; - double fPowN, fPowNminus1; // for (1.0+fX)^Nper and (1.0+fX)^(Nper-1) while (!bFound && nCount < nIterationsMax) { + double fPowN, fPowNminus1; // for (1.0+fX)^Nper and (1.0+fX)^(Nper-1) fPowNminus1 = pow( 1.0+fX, fNper-1.0); fPowN = fPowNminus1 * (1.0+fX); if (rtl::math::approxEqual( fabs(fX), 0.0)) diff --git a/sc/source/filter/excel/excimp8.cxx b/sc/source/filter/excel/excimp8.cxx index e1ecf4b0ab2c..73e02d7986dc 100644 --- a/sc/source/filter/excel/excimp8.cxx +++ b/sc/source/filter/excel/excimp8.cxx @@ -637,8 +637,7 @@ void XclImpAutoFilterData::ReadAutoFilter( sal_uInt8 nType, nOper, nBoolErr, nVal; sal_Int32 nRK; - double fVal; - bool bIgnore; + double fVal; sal_uInt8 nStrLen[2] = { 0, 0 }; ScQueryEntry aEntries[2]; @@ -647,7 +646,7 @@ void XclImpAutoFilterData::ReadAutoFilter( { ScQueryEntry& rEntry = aEntries[nE]; ScQueryEntry::Item& rItem = rEntry.GetQueryItem(); - bIgnore = false; + bool bIgnore = false; nType = rStrm.ReaduInt8(); nOper = rStrm.ReaduInt8(); diff --git a/sc/source/filter/xml/XMLStylesExportHelper.cxx b/sc/source/filter/xml/XMLStylesExportHelper.cxx index ae5927008536..0ac150c62003 100644 --- a/sc/source/filter/xml/XMLStylesExportHelper.cxx +++ b/sc/source/filter/xml/XMLStylesExportHelper.cxx @@ -594,53 +594,53 @@ void ScRowFormatRanges::AddRange(ScMyRowFormatRange& rFormatRange) return; sal_Int32 nPrevIndex = -1; bool bPrevAutoStyle = true; + + sal_uInt32 nPrevStartCol(rFormatRange.nStartColumn); + OSL_ENSURE( static_cast<size_t>(nPrevStartCol) < pColDefaults->size(), "nPrevStartCol out of bounds"); + sal_uInt32 nRepeat; + if (static_cast<size_t>(nPrevStartCol) < pColDefaults->size()) { - sal_uInt32 nPrevStartCol(rFormatRange.nStartColumn); - OSL_ENSURE( static_cast<size_t>(nPrevStartCol) < pColDefaults->size(), "nPrevStartCol out of bounds"); - sal_uInt32 nRepeat; - if (static_cast<size_t>(nPrevStartCol) < pColDefaults->size()) + nRepeat = (*pColDefaults)[nPrevStartCol].nRepeat; + nPrevIndex = (*pColDefaults)[nPrevStartCol].nIndex; + bPrevAutoStyle = (*pColDefaults)[nPrevStartCol].bIsAutoStyle; + } + else + { + /* Again, this is to prevent out-of-bounds accesses, so FIXME + * elsewhere! */ + if (pColDefaults->empty()) { - nRepeat = (*pColDefaults)[nPrevStartCol].nRepeat; - nPrevIndex = (*pColDefaults)[nPrevStartCol].nIndex; - bPrevAutoStyle = (*pColDefaults)[nPrevStartCol].bIsAutoStyle; + nRepeat = 1; + nPrevIndex = -1; + bPrevAutoStyle = false; } else { - /* Again, this is to prevent out-of-bounds accesses, so FIXME - * elsewhere! */ - if (pColDefaults->empty()) - { - nRepeat = 1; - nPrevIndex = -1; - bPrevAutoStyle = false; - } - else - { - nRepeat = (*pColDefaults)[pColDefaults->size()-1].nRepeat; - nPrevIndex = (*pColDefaults)[pColDefaults->size()-1].nIndex; - bPrevAutoStyle = (*pColDefaults)[pColDefaults->size()-1].bIsAutoStyle; - } + nRepeat = (*pColDefaults)[pColDefaults->size()-1].nRepeat; + nPrevIndex = (*pColDefaults)[pColDefaults->size()-1].nIndex; + bPrevAutoStyle = (*pColDefaults)[pColDefaults->size()-1].bIsAutoStyle; } - sal_uInt32 nEnd = nPrevStartCol + rFormatRange.nRepeatColumns; - for(sal_uInt32 i = nPrevStartCol + nRepeat; i < nEnd && i < pColDefaults->size(); i += (*pColDefaults)[i].nRepeat) + } + sal_uInt32 nEnd = nPrevStartCol + rFormatRange.nRepeatColumns; + for(sal_uInt32 i = nPrevStartCol + nRepeat; i < nEnd && i < pColDefaults->size(); i += (*pColDefaults)[i].nRepeat) + { + OSL_ENSURE(sal_uInt32(nPrevStartCol + nRepeat) <= nEnd, "something wents wrong"); + if ((nPrevIndex != (*pColDefaults)[i].nIndex) || + (bPrevAutoStyle != (*pColDefaults)[i].bIsAutoStyle)) { - OSL_ENSURE(sal_uInt32(nPrevStartCol + nRepeat) <= nEnd, "something wents wrong"); - if ((nPrevIndex != (*pColDefaults)[i].nIndex) || - (bPrevAutoStyle != (*pColDefaults)[i].bIsAutoStyle)) - { - AddRange(nPrevStartCol, nRepeat, nPrevIndex, bPrevAutoStyle, rFormatRange); - nPrevStartCol = i; - nRepeat = (*pColDefaults)[i].nRepeat; - nPrevIndex = (*pColDefaults)[i].nIndex; - bPrevAutoStyle = (*pColDefaults)[i].bIsAutoStyle; - } - else - nRepeat += (*pColDefaults)[i].nRepeat; + AddRange(nPrevStartCol, nRepeat, nPrevIndex, bPrevAutoStyle, rFormatRange); + nPrevStartCol = i; + nRepeat = (*pColDefaults)[i].nRepeat; + nPrevIndex = (*pColDefaults)[i].nIndex; + bPrevAutoStyle = (*pColDefaults)[i].bIsAutoStyle; } - if (sal_uInt32(nPrevStartCol + nRepeat) > nEnd) - nRepeat = nEnd - nPrevStartCol; - AddRange(nPrevStartCol, nRepeat, nPrevIndex, bPrevAutoStyle, rFormatRange); + else + nRepeat += (*pColDefaults)[i].nRepeat; } + if (sal_uInt32(nPrevStartCol + nRepeat) > nEnd) + nRepeat = nEnd - nPrevStartCol; + AddRange(nPrevStartCol, nRepeat, nPrevIndex, bPrevAutoStyle, rFormatRange); + } bool ScRowFormatRanges::GetNext(ScMyRowFormatRange& aFormatRange) |