diff options
author | Jochen Nitschke <j.nitschke+logerrit@ok.de> | 2018-09-16 17:26:51 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-09-17 09:25:18 +0200 |
commit | 3d57e965d31a3bf2dc5fe5d9dc87d857f5149745 (patch) | |
tree | a58e8b4f138be2920b545784279c7f2c256188a7 | |
parent | 206b5b2661be37efdff3c6aedb6f248c4636be79 (diff) |
cppcheck: variableScope in sc
Change-Id: I9fe9c042a4990c6399765819f6b8e80c17dba9d2
Reviewed-on: https://gerrit.libreoffice.org/60551
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
-rw-r--r-- | sc/source/core/data/dptabres.cxx | 5 | ||||
-rw-r--r-- | sc/source/core/tool/compiler.cxx | 4 | ||||
-rw-r--r-- | sc/source/core/tool/scmatrix.cxx | 3 | ||||
-rw-r--r-- | sc/source/filter/excel/excform.cxx | 3 | ||||
-rw-r--r-- | sc/source/filter/xml/xmlexprt.cxx | 4 | ||||
-rw-r--r-- | sc/source/ui/docshell/impex.cxx | 5 | ||||
-rw-r--r-- | sc/source/ui/vba/vbarange.cxx | 5 | ||||
-rw-r--r-- | sc/source/ui/vba/vbaworksheet.cxx | 9 | ||||
-rw-r--r-- | sc/source/ui/vba/vbaworksheets.cxx | 5 | ||||
-rw-r--r-- | sc/source/ui/view/drawview.cxx | 3 | ||||
-rw-r--r-- | sc/source/ui/view/gridwin2.cxx | 3 | ||||
-rw-r--r-- | sc/source/ui/view/tabview.cxx | 8 |
12 files changed, 21 insertions, 36 deletions
diff --git a/sc/source/core/data/dptabres.cxx b/sc/source/core/data/dptabres.cxx index 2d5952d1c461..e5bef46c3256 100644 --- a/sc/source/core/data/dptabres.cxx +++ b/sc/source/core/data/dptabres.cxx @@ -1619,11 +1619,12 @@ void ScDPResultMember::FillDataResults( nMemberMeasure = SC_DPMEASURE_ALL; OSL_ENSURE( rFilterCxt.mnRow < rSequence.getLength(), "bumm" ); - uno::Sequence<sheet::DataResult>& rSubSeq = rSequence.getArray()[rFilterCxt.mnRow]; rFilterCxt.mnCol = 0; if (pRefMember->IsVisible()) + { + uno::Sequence<sheet::DataResult>& rSubSeq = rSequence.getArray()[rFilterCxt.mnRow]; pDataRoot->FillDataRow(pRefMember, rFilterCxt, rSubSeq, nMemberMeasure, bHasChild, aSubState); - + } rFilterCxt.mnRow += 1; } } diff --git a/sc/source/core/tool/compiler.cxx b/sc/source/core/tool/compiler.cxx index 64622c674301..a271166f476e 100644 --- a/sc/source/core/tool/compiler.cxx +++ b/sc/source/core/tool/compiler.cxx @@ -5592,9 +5592,7 @@ bool ScCompiler::HandleTableRef() } bool bColumnRange = false; bool bCol1Rel = false; - bool bCol2Rel = false; bool bCol1RelName = false; - bool bCol2RelName = false; int nLevel = 0; if (bForwardToClose && GetTokenIfOpCode( ocTableRefOpen)) { @@ -5671,6 +5669,8 @@ bool ScCompiler::HandleTableRef() ScTokenArray* pNew = new ScTokenArray(); if (nError == FormulaError::NONE || nError == FormulaError::NoValue) { + bool bCol2Rel = false; + bool bCol2RelName = false; // The FormulaError::NoValue case generates a thisrow reference that can be // used to save named expressions in A1 syntax notation. if (bColumnRange) diff --git a/sc/source/core/tool/scmatrix.cxx b/sc/source/core/tool/scmatrix.cxx index 1d95650cac26..d5d3940ce9c8 100644 --- a/sc/source/core/tool/scmatrix.cxx +++ b/sc/source/core/tool/scmatrix.cxx @@ -1832,8 +1832,6 @@ public: void operator() (const MatrixImplType::element_block_node_type& node) { - sc::Compare::Cell& rCell = mrComp.maCells[0]; - switch (node.type) { case mdds::mtm::element_numeric: @@ -1865,6 +1863,7 @@ public: for (; it != itEnd; ++it) { const svl::SharedString& rStr = *it; + sc::Compare::Cell& rCell = mrComp.maCells[0]; rCell.mbValue = false; rCell.mbEmpty = false; rCell.maStr = rStr; diff --git a/sc/source/filter/excel/excform.cxx b/sc/source/filter/excel/excform.cxx index 16bbe6a83585..57038e36bd2d 100644 --- a/sc/source/filter/excel/excform.cxx +++ b/sc/source/filter/excel/excform.cxx @@ -905,7 +905,6 @@ ConvErr ExcelToSc::Convert( ScRangeListTabs& rRangeList, XclImpStream& aIn, std: { RootData& rR = GetOldRoot(); sal_uInt8 nOp, nLen; - std::size_t nIgnore; bool bError = false; const bool bRangeName = eFT == FT_RangeName; const bool bSharedFormula = eFT == FT_SharedFormula; @@ -930,7 +929,7 @@ ConvErr ExcelToSc::Convert( ScRangeListTabs& rRangeList, XclImpStream& aIn, std: while( (aIn.GetRecPos() < nEndPos) && !bError ) { nOp = aIn.ReaduInt8(); - nIgnore = 0; + std::size_t nIgnore = 0; // always reset flags aSRD.InitFlags(); diff --git a/sc/source/filter/xml/xmlexprt.cxx b/sc/source/filter/xml/xmlexprt.cxx index 27e8a2ec499e..379efb569410 100644 --- a/sc/source/filter/xml/xmlexprt.cxx +++ b/sc/source/filter/xml/xmlexprt.cxx @@ -3174,8 +3174,7 @@ void ScXMLExport::WriteCell(ScMyCell& aCell, sal_Int32 nEqualCellCount) AddAttribute(sAttrStyleName, pCellStyles->GetStyleNameByIndex(aCell.nStyleIndex, aCell.bIsAutoStyle)); if (aCell.nValidationIndex > -1) AddAttribute(XML_NAMESPACE_TABLE, XML_CONTENT_VALIDATION_NAME, pValidationsContainer->GetValidationName(aCell.nValidationIndex)); - bool bIsMatrix(aCell.bIsMatrixBase || aCell.bIsMatrixCovered); - bool bIsFirstMatrixCell(aCell.bIsMatrixBase); + const bool bIsFirstMatrixCell(aCell.bIsMatrixBase); if (bIsFirstMatrixCell) { SCCOL nColumns( aCell.aMatrixRange.aEnd.Col() - aCell.aMatrixRange.aStart.Col() + 1 ); @@ -3215,6 +3214,7 @@ void ScXMLExport::WriteCell(ScMyCell& aCell, sal_Int32 nEqualCellCount) { if (aCell.maBaseCell.meType == CELLTYPE_FORMULA) { + const bool bIsMatrix(bIsFirstMatrixCell || aCell.bIsMatrixCovered); ScFormulaCell* pFormulaCell = aCell.maBaseCell.mpFormula; if (!bIsMatrix || bIsFirstMatrixCell) { diff --git a/sc/source/ui/docshell/impex.cxx b/sc/source/ui/docshell/impex.cxx index 324d147293ed..0e80e499411d 100644 --- a/sc/source/ui/docshell/impex.cxx +++ b/sc/source/ui/docshell/impex.cxx @@ -1791,14 +1791,15 @@ bool ScImportExport::Sylk2Doc( SvStream& rStrm ) break; bool bInvalidCol = false; bool bInvalidRow = false; - bool bInvalidRefCol = false; - bool bInvalidRefRow = false; const sal_Unicode* p = aLine.getStr(); sal_Unicode cTag = *p++; if( cTag == 'C' ) // Content { if( *p++ != ';' ) return false; + + bool bInvalidRefCol = false; + bool bInvalidRefRow = false; while( *p ) { sal_Unicode ch = *p++; diff --git a/sc/source/ui/vba/vbarange.cxx b/sc/source/ui/vba/vbarange.cxx index 0dd27507bc96..2cc08802e24f 100644 --- a/sc/source/ui/vba/vbarange.cxx +++ b/sc/source/ui/vba/vbarange.cxx @@ -4479,13 +4479,12 @@ ScVbaRange::AutoFilter( const uno::Any& aField, const uno::Any& Criteria1, const // in this case we just call the core calc functionality - if ( Field >>= nField ) { - bool bAll = false; - bool bAcceptCriteria2 = true; - uno::Reference< sheet::XSheetFilterDescriptor2 > xDesc( xDataBaseRange->getFilterDescriptor(), uno::UNO_QUERY ); if ( xDesc.is() ) { + bool bAcceptCriteria2 = true; + bool bAll = false; uno::Sequence< sheet::TableFilterField2 > sTabFilts; uno::Reference< beans::XPropertySet > xDescProps( xDesc, uno::UNO_QUERY_THROW ); if ( Criteria1.hasValue() ) diff --git a/sc/source/ui/vba/vbaworksheet.cxx b/sc/source/ui/vba/vbaworksheet.cxx index 2299c022220e..87052e0155ad 100644 --- a/sc/source/ui/vba/vbaworksheet.cxx +++ b/sc/source/ui/vba/vbaworksheet.cxx @@ -1038,20 +1038,13 @@ ScVbaWorksheet::getSheetID() } void SAL_CALL -ScVbaWorksheet::PrintOut( const uno::Any& From, const uno::Any& To, const uno::Any& Copies, const uno::Any& Preview, const uno::Any& ActivePrinter, const uno::Any& PrintToFile, const uno::Any& Collate, const uno::Any& PrToFileName, const uno::Any& IgnorePrintAreas ) +ScVbaWorksheet::PrintOut( const uno::Any& From, const uno::Any& To, const uno::Any& Copies, const uno::Any& Preview, const uno::Any& ActivePrinter, const uno::Any& PrintToFile, const uno::Any& Collate, const uno::Any& PrToFileName, const uno::Any& ) { sal_Int32 nTo = 0; sal_Int32 nFrom = 0; - sal_Int16 nCopies = 1; - bool bCollate = false; bool bSelection = false; - bool bIgnorePrintAreas = false; From >>= nFrom; To >>= nTo; - Copies >>= nCopies; - IgnorePrintAreas >>= bIgnorePrintAreas; - if ( nCopies > 1 ) // Collate only useful when more that 1 copy - Collate >>= bCollate; if ( !( nFrom || nTo ) ) bSelection = true; diff --git a/sc/source/ui/vba/vbaworksheets.cxx b/sc/source/ui/vba/vbaworksheets.cxx index 9bd77903d994..80b9e84d72d7 100644 --- a/sc/source/ui/vba/vbaworksheets.cxx +++ b/sc/source/ui/vba/vbaworksheets.cxx @@ -312,14 +312,9 @@ ScVbaWorksheets::PrintOut( const uno::Any& From, const uno::Any& To, const uno:: { sal_Int32 nTo = 0; sal_Int32 nFrom = 0; - sal_Int16 nCopies = 1; - bool bCollate = false; bool bSelection = false; From >>= nFrom; To >>= nTo; - Copies >>= nCopies; - if ( nCopies > 1 ) // Collate only useful when more that 1 copy - Collate >>= bCollate; if ( !( nFrom || nTo ) ) if ( isSelectedSheets() ) diff --git a/sc/source/ui/view/drawview.cxx b/sc/source/ui/view/drawview.cxx index cda4d3b3ffb3..670dba85023c 100644 --- a/sc/source/ui/view/drawview.cxx +++ b/sc/source/ui/view/drawview.cxx @@ -673,7 +673,6 @@ void ScDrawView::SelectCurrentViewObject( const OUString& rName ) { sal_uInt16 nObjectTab = 0; SdrObject* pFound = nullptr; - bool bUnMark = false; SfxObjectShell* pShell = pDoc->GetDocumentShell(); if (pShell) { @@ -716,7 +715,7 @@ void ScDrawView::SelectCurrentViewObject( const OUString& rName ) SetLayerLocked( pLayer->GetName(), false ); } SdrPageView* pPV = GetSdrPageView(); - bUnMark = IsObjMarked(pFound); + const bool bUnMark = IsObjMarked(pFound); MarkObj( pFound, pPV, bUnMark); } } diff --git a/sc/source/ui/view/gridwin2.cxx b/sc/source/ui/view/gridwin2.cxx index 216f838b748a..66e1a83ee25c 100644 --- a/sc/source/ui/view/gridwin2.cxx +++ b/sc/source/ui/view/gridwin2.cxx @@ -597,8 +597,6 @@ void ScGridWindow::UpdateDPFromFieldPopupMenu() bool ScGridWindow::UpdateVisibleRange() { - ScDocument& rDoc = *pViewData->GetDocument(); - SCCOL nPosX = 0; SCROW nPosY = 0; SCCOL nXRight = MAXCOL; @@ -608,6 +606,7 @@ bool ScGridWindow::UpdateVisibleRange() { // entire table in the tiled rendering case SCTAB nTab = pViewData->GetTabNo(); + ScDocument const& rDoc = *pViewData->GetDocument(); SCCOL nEndCol = 0; SCROW nEndRow = 0; diff --git a/sc/source/ui/view/tabview.cxx b/sc/source/ui/view/tabview.cxx index 12e05ed32aaa..f9b0ae4b7d8b 100644 --- a/sc/source/ui/view/tabview.cxx +++ b/sc/source/ui/view/tabview.cxx @@ -2481,12 +2481,8 @@ OUString ScTabView::getRowColumnHeaders(const tools::Rectangle& rRectangle) SCTAB nTab = aViewData.GetTabNo(); SCROW nStartRow = -1; SCROW nEndRow = -1; - long nStartHeightPx = 0; - long nEndHeightPx = 0; SCCOL nStartCol = -1; SCCOL nEndCol = -1; - long nStartWidthPx = 0; - long nEndWidthPx = 0; tools::Rectangle aOldVisArea( mnLOKStartHeaderCol + 1, mnLOKStartHeaderRow + 1, @@ -2499,6 +2495,8 @@ OUString ScTabView::getRowColumnHeaders(const tools::Rectangle& rRectangle) if (rRectangle.Top() < rRectangle.Bottom()) { SAL_INFO("sc.lok.header", "Row Header: compute start/end rows."); + long nStartHeightPx = 0; + long nEndHeightPx = 0; long nRectTopPx = rRectangle.Top() / TWIPS_PER_PIXEL; long nRectBottomPx = rRectangle.Bottom() / TWIPS_PER_PIXEL; @@ -2641,6 +2639,8 @@ OUString ScTabView::getRowColumnHeaders(const tools::Rectangle& rRectangle) if (rRectangle.Left() < rRectangle.Right()) { SAL_INFO("sc.lok.header", "Column Header: compute start/end columns."); + long nStartWidthPx = 0; + long nEndWidthPx = 0; long nRectLeftPx = rRectangle.Left() / TWIPS_PER_PIXEL; long nRectRightPx = rRectangle.Right() / TWIPS_PER_PIXEL; |