diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2022-06-01 12:14:16 +0200 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2022-06-01 14:15:58 +0200 |
commit | acb65a60be43d5ac146c2fc16c6f2a5f6879be99 (patch) | |
tree | d10bc29c40383e1ea68057c763b61a0499f0eca3 /chart2/source/model | |
parent | aeeb0141aca4f1698b09bc8f06ded41247b54279 (diff) |
Use more appropriate index variable types
Change-Id: Ic2cf5512cabcda0ad476c43bcbc544d0d6dd2685
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/135231
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
Diffstat (limited to 'chart2/source/model')
6 files changed, 42 insertions, 26 deletions
diff --git a/chart2/source/model/template/BubbleDataInterpreter.cxx b/chart2/source/model/template/BubbleDataInterpreter.cxx index 3c3c33770ce5..7243b43aae96 100644 --- a/chart2/source/model/template/BubbleDataInterpreter.cxx +++ b/chart2/source/model/template/BubbleDataInterpreter.cxx @@ -17,6 +17,10 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ +#include <sal/config.h> + +#include <cstddef> + #include "BubbleDataInterpreter.hxx" #include <DataSeries.hxx> #include <DataSeriesHelper.hxx> @@ -114,7 +118,7 @@ InterpretedData BubbleDataInterpreter::interpretDataSource( } // create DataSeries - sal_Int32 nSeriesIndex = 0; + std::size_t nSeriesIndex = 0; vector< rtl::Reference< DataSeries > > aSeriesVec; aSeriesVec.reserve( aSizeValuesVector.size()); @@ -135,7 +139,7 @@ InterpretedData BubbleDataInterpreter::interpretDataSource( aNewData.push_back(aSizeValuesVector[nN]); rtl::Reference< DataSeries > xSeries; - if( nSeriesIndex < static_cast<sal_Int32>(aSeriesToReUse.size())) + if( nSeriesIndex < aSeriesToReUse.size()) xSeries = aSeriesToReUse[nSeriesIndex]; else xSeries = new DataSeries; diff --git a/chart2/source/model/template/ChartTypeTemplate.cxx b/chart2/source/model/template/ChartTypeTemplate.cxx index 0791ab59d8b2..bc27bea1e162 100644 --- a/chart2/source/model/template/ChartTypeTemplate.cxx +++ b/chart2/source/model/template/ChartTypeTemplate.cxx @@ -41,6 +41,7 @@ #include <comphelper/property.hxx> #include <algorithm> +#include <cstddef> using namespace ::com::sun::star; using namespace ::com::sun::star::chart2; @@ -257,9 +258,9 @@ void ChartTypeTemplate::changeDiagramData( xInterpreter->interpretDataSource( xDataSource, aArguments, aFlatSeriesSeq ); // data series - sal_Int32 i, j, nIndex = 0; - for( i=0; i<static_cast<sal_Int32>(aData.Series.size()); ++i ) - for( j=0; j<static_cast<sal_Int32>(aData.Series[i].size()); ++j, ++nIndex ) + sal_Int32 nIndex = 0; + for( std::size_t i=0; i<aData.Series.size(); ++i ) + for( std::size_t j=0; j<aData.Series[i].size(); ++j, ++nIndex ) { if( nIndex >= nFormerSeriesCount ) { @@ -274,7 +275,7 @@ void ChartTypeTemplate::changeDiagramData( std::vector< rtl::Reference< ChartType > > aChartTypes = DiagramHelper::getChartTypesFromDiagram( xDiagram ); sal_Int32 nMax = std::min( aChartTypes.size(), aData.Series.size()); - for( i=0; i<nMax; ++i ) + for( sal_Int32 i=0; i<nMax; ++i ) { aChartTypes[i]->setDataSeries( aData.Series[i] ); } @@ -310,13 +311,13 @@ bool ChartTypeTemplate::matchesTemplate( const OUString aChartTypeToMatch = xOldCT->getChartType(); const sal_Int32 nDimensionToMatch = getDimension(); - for( sal_Int32 nCooSysIdx=0; bResult && (nCooSysIdx < static_cast<sal_Int32>(aCooSysSeq.size())); ++nCooSysIdx ) + for( std::size_t nCooSysIdx=0; bResult && (nCooSysIdx < aCooSysSeq.size()); ++nCooSysIdx ) { // match dimension bResult = bResult && (aCooSysSeq[nCooSysIdx]->getDimension() == nDimensionToMatch); const std::vector< rtl::Reference< ChartType > > & aChartTypeSeq( aCooSysSeq[nCooSysIdx]->getChartTypes2()); - for( sal_Int32 nCTIdx=0; bResult && (nCTIdx < static_cast<sal_Int32>(aChartTypeSeq.size())); ++nCTIdx ) + for( std::size_t nCTIdx=0; bResult && (nCTIdx < aChartTypeSeq.size()); ++nCTIdx ) { // match chart type bResult = bResult && aChartTypeSeq[nCTIdx]->getChartType() == aChartTypeToMatch; @@ -393,7 +394,7 @@ void ChartTypeTemplate::applyStyles( const rtl::Reference< ::chart::Diagram >& x // apply chart-type specific styles, like "symbols on" for example std::vector< std::vector< rtl::Reference< DataSeries > > > aNewSeriesSeq( DiagramHelper::getDataSeriesGroups( xDiagram )); - for( sal_Int32 i=0; i<static_cast<sal_Int32>(aNewSeriesSeq.size()); ++i ) + for( std::size_t i=0; i<aNewSeriesSeq.size(); ++i ) { const sal_Int32 nNumSeries = aNewSeriesSeq[i].size(); for( sal_Int32 j=0; j<nNumSeries; ++j ) @@ -501,7 +502,7 @@ void ChartTypeTemplate::createCoordinateSystems( if( !aCoordinateSystems.empty() ) { bool bOk = true; - for( sal_Int32 i=0; bOk && i<static_cast<sal_Int32>(aCoordinateSystems.size()); ++i ) + for( std::size_t i=0; bOk && i<aCoordinateSystems.size(); ++i ) bOk = bOk && ( xCooSys->getCoordinateSystemType() == aCoordinateSystems[i]->getCoordinateSystemType() && (xCooSys->getDimension() == aCoordinateSystems[i]->getDimension()) ); // coordinate systems are ok @@ -729,7 +730,7 @@ void ChartTypeTemplate::createChartTypes( try { - sal_Int32 nCooSysIdx=0; + std::size_t nCooSysIdx=0; rtl::Reference< ChartType > xCT; if( aSeriesSeq.empty() ) { @@ -739,7 +740,7 @@ void ChartTypeTemplate::createChartTypes( } else { - for( sal_Int32 nSeriesIdx=0; nSeriesIdx<static_cast<sal_Int32>(aSeriesSeq.size()); ++nSeriesIdx ) + for( std::size_t nSeriesIdx=0; nSeriesIdx<aSeriesSeq.size(); ++nSeriesIdx ) { if( nSeriesIdx == nCooSysIdx ) { @@ -770,7 +771,7 @@ void ChartTypeTemplate::createChartTypes( } // spread the series over the available coordinate systems - if( static_cast<sal_Int32>(rCoordSys.size()) > (nCooSysIdx + 1) ) + if( rCoordSys.size() > (nCooSysIdx + 1) ) ++nCooSysIdx; } } diff --git a/chart2/source/model/template/DataInterpreter.cxx b/chart2/source/model/template/DataInterpreter.cxx index 36ead62dcf9e..5b8899dcc9f6 100644 --- a/chart2/source/model/template/DataInterpreter.cxx +++ b/chart2/source/model/template/DataInterpreter.cxx @@ -27,6 +27,7 @@ #include <tools/diagnose_ex.h> #include <algorithm> +#include <cstddef> using namespace ::com::sun::star; using namespace ::com::sun::star::chart2; @@ -100,7 +101,7 @@ InterpretedData DataInterpreter::interpretDataSource( } // create DataSeries - sal_Int32 nSeriesIndex = 0; + std::size_t nSeriesIndex = 0; vector< rtl::Reference< DataSeries > > aSeriesVec; aSeriesVec.reserve( aSequencesVec.size()); @@ -108,7 +109,7 @@ InterpretedData DataInterpreter::interpretDataSource( { std::vector< uno::Reference< chart2::data::XLabeledDataSequence > > aNewData { elem }; rtl::Reference< DataSeries > xSeries; - if( nSeriesIndex < static_cast<sal_Int32>(aSeriesToReUse.size())) + if( nSeriesIndex < aSeriesToReUse.size()) xSeries = aSeriesToReUse[nSeriesIndex]; else xSeries = new DataSeries; @@ -346,7 +347,7 @@ bool DataInterpreter::HasCategories( if( rArguments.hasElements() ) GetProperty( rArguments, u"HasCategories" ) >>= bHasCategories; - for( sal_Int32 nLSeqIdx=0; ! bHasCategories && nLSeqIdx<static_cast<sal_Int32>(rData.size()); ++nLSeqIdx ) + for( std::size_t nLSeqIdx=0; ! bHasCategories && nLSeqIdx<rData.size(); ++nLSeqIdx ) bHasCategories = ( rData[nLSeqIdx].is() && GetRole( rData[nLSeqIdx]->getValues() ) == "categories"); return bHasCategories; diff --git a/chart2/source/model/template/StockChartTypeTemplate.cxx b/chart2/source/model/template/StockChartTypeTemplate.cxx index fb514adfa75f..2798f0358b7c 100644 --- a/chart2/source/model/template/StockChartTypeTemplate.cxx +++ b/chart2/source/model/template/StockChartTypeTemplate.cxx @@ -35,6 +35,7 @@ #include <tools/diagnose_ex.h> #include <algorithm> +#include <cstddef> using namespace ::com::sun::star; using namespace ::com::sun::star::chart2; @@ -285,7 +286,7 @@ void StockChartTypeTemplate::createChartTypes( getFastPropertyValue( PROP_STOCKCHARTTYPE_TEMPLATE_JAPANESE ) >>= bJapaneseStyle; getFastPropertyValue( PROP_STOCKCHARTTYPE_TEMPLATE_LOW_HIGH ) >>= bShowHighLow; - sal_Int32 nSeriesIndex = 0; + std::size_t nSeriesIndex = 0; std::vector< rtl::Reference< ChartType > > aChartTypeVec; // Bars (Volume) @@ -295,7 +296,7 @@ void StockChartTypeTemplate::createChartTypes( rtl::Reference< ChartType > xCT = new ColumnChartType(); aChartTypeVec.push_back( xCT ); - if( static_cast<sal_Int32>(aSeriesSeq.size()) > nSeriesIndex && + if( aSeriesSeq.size() > nSeriesIndex && !aSeriesSeq[nSeriesIndex].empty() ) { xCT->setDataSeries( aSeriesSeq[ nSeriesIndex ] ); @@ -310,7 +311,7 @@ void StockChartTypeTemplate::createChartTypes( xCT->setPropertyValue( "ShowFirst", uno::Any( bShowFirst )); xCT->setPropertyValue( "ShowHighLow", uno::Any( bShowHighLow )); - if( static_cast<sal_Int32>(aSeriesSeq.size()) > nSeriesIndex && + if( aSeriesSeq.size() > nSeriesIndex && !aSeriesSeq[ nSeriesIndex ].empty() ) { xCT->setDataSeries( aSeriesSeq[ nSeriesIndex ] ); @@ -318,7 +319,7 @@ void StockChartTypeTemplate::createChartTypes( ++nSeriesIndex; // Lines (remaining series) - if( static_cast<sal_Int32>(aSeriesSeq.size()) > nSeriesIndex && + if( aSeriesSeq.size() > nSeriesIndex && !aSeriesSeq[ nSeriesIndex ].empty() ) { xCT = new LineChartType(); diff --git a/chart2/source/model/template/StockDataInterpreter.cxx b/chart2/source/model/template/StockDataInterpreter.cxx index f2d845a18d6d..d0d950b9a6a8 100644 --- a/chart2/source/model/template/StockDataInterpreter.cxx +++ b/chart2/source/model/template/StockDataInterpreter.cxx @@ -17,6 +17,10 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ +#include <sal/config.h> + +#include <cstddef> + #include "StockDataInterpreter.hxx" #include "StockChartTypeTemplate.hxx" #include <DataSeries.hxx> @@ -220,7 +224,8 @@ InterpretedData StockDataInterpreter::interpretDataSource( // create DataSeries std::vector< std::vector< rtl::Reference< DataSeries > > > aResultSeries( nNumberOfGroups ); - sal_Int32 nGroupIndex, nReUsedSeriesIdx = 0; + sal_Int32 nGroupIndex; + std::size_t nReUsedSeriesIdx = 0; for( nGroupIndex=0; nGroupIndex<nNumberOfGroups; ++nGroupIndex ) { const sal_Int32 nNumSeriesData = aSequences[nGroupIndex].size(); @@ -231,7 +236,7 @@ InterpretedData StockDataInterpreter::interpretDataSource( try { rtl::Reference< DataSeries > xSeries; - if( nReUsedSeriesIdx < static_cast<sal_Int32>(rSeriesToReUse.size())) + if( nReUsedSeriesIdx < rSeriesToReUse.size()) xSeries = rSeriesToReUse[nReUsedSeriesIdx]; else xSeries = new DataSeries; @@ -258,7 +263,7 @@ bool StockDataInterpreter::isDataCompatible( const InterpretedData& aInterpretedData ) { // high/low/close - sal_Int32 nNumberOfNecessarySequences = 3; + std::size_t nNumberOfNecessarySequences = 3; // open StockChartTypeTemplate::StockVariant eVar( GetStockVariant()); if( ( eVar == StockChartTypeTemplate::StockVariant::Open ) || @@ -292,7 +297,7 @@ bool StockDataInterpreter::isDataCompatible( { try { - if( static_cast<sal_Int32>(dataSeries->getDataSequences2().size()) != nNumberOfNecessarySequences ) + if( dataSeries->getDataSequences2().size() != nNumberOfNecessarySequences ) return false; } catch( const uno::Exception & ) diff --git a/chart2/source/model/template/XYDataInterpreter.cxx b/chart2/source/model/template/XYDataInterpreter.cxx index a4ac12b112cc..d77a3df396b7 100644 --- a/chart2/source/model/template/XYDataInterpreter.cxx +++ b/chart2/source/model/template/XYDataInterpreter.cxx @@ -17,6 +17,10 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ +#include <sal/config.h> + +#include <cstddef> + #include "XYDataInterpreter.hxx" #include <DataSeries.hxx> #include <DataSeriesHelper.hxx> @@ -105,7 +109,7 @@ InterpretedData XYDataInterpreter::interpretDataSource( Reference< data::XLabeledDataSequence > xClonedXValues = xValuesX; Reference< util::XCloneable > xCloneable( xValuesX, uno::UNO_QUERY ); - sal_Int32 nSeriesIndex = 0; + std::size_t nSeriesIndex = 0; for (auto const& elem : aSequencesVec) { vector< uno::Reference< chart2::data::XLabeledDataSequence > > aNewData; @@ -118,7 +122,7 @@ InterpretedData XYDataInterpreter::interpretDataSource( aNewData.push_back(elem); rtl::Reference< DataSeries > xSeries; - if( nSeriesIndex < static_cast<sal_Int32>(aSeriesToReUse.size())) + if( nSeriesIndex < aSeriesToReUse.size()) xSeries = aSeriesToReUse[nSeriesIndex]; else xSeries = new DataSeries; |