diff options
author | Julien Nabet <serval2412@yahoo.fr> | 2018-03-03 23:26:43 +0100 |
---|---|---|
committer | Julien Nabet <serval2412@yahoo.fr> | 2018-03-04 00:38:16 +0100 |
commit | e108a31a8fee09c2fa4031e45e45ed73bbdb7c6f (patch) | |
tree | e334e8b5c11b621d59d8086b9fd853ebafb2ba61 /chart2/source/tools | |
parent | 4f4137d0e20e6693037846c870857c887979770b (diff) |
Modernize a bit chart2
mainly by using for range loops
+ by using empty() instead of comparing begin and iterator
or use size to test that a container has at least 2 elements
Change-Id: I81f168d8c36a8b4195fbb0c1aee4983dab25d22c
Reviewed-on: https://gerrit.libreoffice.org/50705
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Julien Nabet <serval2412@yahoo.fr>
Diffstat (limited to 'chart2/source/tools')
-rw-r--r-- | chart2/source/tools/InternalDataProvider.cxx | 24 | ||||
-rw-r--r-- | chart2/source/tools/NameContainer.cxx | 6 | ||||
-rw-r--r-- | chart2/source/tools/ReferenceSizeProvider.cxx | 14 | ||||
-rw-r--r-- | chart2/source/tools/RegressionCurveHelper.cxx | 10 | ||||
-rw-r--r-- | chart2/source/tools/RelativeSizeHelper.cxx | 7 | ||||
-rw-r--r-- | chart2/source/tools/WrappedPropertySet.cxx | 18 |
6 files changed, 34 insertions, 45 deletions
diff --git a/chart2/source/tools/InternalDataProvider.cxx b/chart2/source/tools/InternalDataProvider.cxx index f272c9feb9ce..7338822ff17b 100644 --- a/chart2/source/tools/InternalDataProvider.cxx +++ b/chart2/source/tools/InternalDataProvider.cxx @@ -661,12 +661,9 @@ namespace sal_Int32 lcl_getInnerLevelCount( const vector< vector< uno::Any > >& rLabels ) { sal_Int32 nCount = 1;//minimum is 1! - vector< vector< uno::Any > >::const_iterator aLevelIt( rLabels.begin() ); - vector< vector< uno::Any > >::const_iterator aLevelEnd( rLabels.end() ); - for( ;aLevelIt!=aLevelEnd; ++aLevelIt ) + for (auto const& elemLabel : rLabels) { - const vector< uno::Any >& rCurrentLevelLabels = *aLevelIt; - nCount = std::max<sal_Int32>( rCurrentLevelLabels.size(), nCount ); + nCount = std::max<sal_Int32>( elemLabel.size(), nCount ); } return nCount; } @@ -751,12 +748,10 @@ Reference< chart2::data::XDataSource > SAL_CALL InternalDataProvider::createData } //add left over data sequences to result - std::vector< Reference< chart2::data::XLabeledDataSequence > >::iterator aIt(aDataVec.begin()); - const std::vector< Reference< chart2::data::XLabeledDataSequence > >::const_iterator aEndIt(aDataVec.end()); - for( ;aIt!=aEndIt; ++aIt) + for (auto const& elem : aDataVec) { - if( aIt->is() ) - aResultLSeqVec.push_back( *aIt ); + if( elem.is() ) + aResultLSeqVec.push_back(elem); } return new DataSource( comphelper::containerToSequence(aResultLSeqVec) ); @@ -1355,13 +1350,12 @@ Sequence< double > SAL_CALL InternalDataProvider::getDateCategories() vector< vector< uno::Any > > aCategories( m_bDataInColumns ? m_aInternalData.getComplexRowLabels() : m_aInternalData.getComplexColumnLabels()); sal_Int32 nCount = aCategories.size(); Sequence< double > aDoubles( nCount ); - vector< vector< uno::Any > >::iterator aIt( aCategories.begin() ); - vector< vector< uno::Any > >::const_iterator aEnd( aCategories.end() ); - for(sal_Int32 nN=0; nN<nCount && aIt!=aEnd; ++nN, ++aIt ) + sal_Int32 nN=0; + for (auto const& category : aCategories) { - if( !( !aIt->empty() && ((*aIt)[0]>>=fValue) ) ) + if( !( !category.empty() && (category[0]>>=fValue) ) ) fValue = fNan; - aDoubles[nN]=fValue; + aDoubles[nN++]=fValue; } return aDoubles; } diff --git a/chart2/source/tools/NameContainer.cxx b/chart2/source/tools/NameContainer.cxx index 3f08fa0a9fb3..cbf128cd4f23 100644 --- a/chart2/source/tools/NameContainer.cxx +++ b/chart2/source/tools/NameContainer.cxx @@ -112,8 +112,10 @@ Sequence< OUString > SAL_CALL NameContainer::getElementNames() sal_Int32 nCount = m_aMap.size(); Sequence< OUString > aSeq(nCount); sal_Int32 nN = 0; - for( tContentMap::iterator aIter = m_aMap.begin(); aIter != m_aMap.end() && nN < nCount; ++aIter, ++nN ) - aSeq[nN]=aIter->first; + for (auto const& elem : m_aMap) + { + aSeq[nN++]=elem.first; + } return aSeq; } diff --git a/chart2/source/tools/ReferenceSizeProvider.cxx b/chart2/source/tools/ReferenceSizeProvider.cxx index b083f1e09323..37bbb1c441ae 100644 --- a/chart2/source/tools/ReferenceSizeProvider.cxx +++ b/chart2/source/tools/ReferenceSizeProvider.cxx @@ -97,10 +97,9 @@ void ReferenceSizeProvider::setValuesAtAllDataSeries() std::vector< Reference< XDataSeries > > aSeries( DiagramHelper::getDataSeriesFromDiagram( xDiagram )); - for( std::vector< Reference< XDataSeries > >::const_iterator aIt( aSeries.begin()); - aIt != aSeries.end(); ++aIt ) + for (auto const& elem : aSeries) { - Reference< beans::XPropertySet > xSeriesProp( *aIt, uno::UNO_QUERY ); + Reference< beans::XPropertySet > xSeriesProp(elem, uno::UNO_QUERY ); if( xSeriesProp.is()) { // data points @@ -111,7 +110,7 @@ void ReferenceSizeProvider::setValuesAtAllDataSeries() { for( sal_Int32 i=0; i< aPointIndexes.getLength(); ++i ) setValuesAtPropertySet( - (*aIt)->getDataPointByIndex( aPointIndexes[i] ) ); + elem->getDataPointByIndex( aPointIndexes[i] ) ); } } catch (const uno::Exception& ex) @@ -268,10 +267,9 @@ ReferenceSizeProvider::AutoResizeState ReferenceSizeProvider::getAutoResizeState std::vector< Reference< XDataSeries > > aSeries( DiagramHelper::getDataSeriesFromDiagram( xDiagram )); - for( std::vector< Reference< XDataSeries > >::const_iterator aIt( aSeries.begin()); - aIt != aSeries.end(); ++aIt ) + for (auto const& elem : aSeries) { - Reference< beans::XPropertySet > xSeriesProp( *aIt, uno::UNO_QUERY ); + Reference< beans::XPropertySet > xSeriesProp(elem, uno::UNO_QUERY); if( xSeriesProp.is()) { getAutoResizeFromPropSet( xSeriesProp, eResult ); @@ -287,7 +285,7 @@ ReferenceSizeProvider::AutoResizeState ReferenceSizeProvider::getAutoResizeState for( sal_Int32 i=0; i< aPointIndexes.getLength(); ++i ) { getAutoResizeFromPropSet( - (*aIt)->getDataPointByIndex( aPointIndexes[i] ), eResult ); + elem->getDataPointByIndex( aPointIndexes[i] ), eResult ); if( eResult == AUTO_RESIZE_AMBIGUOUS ) return eResult; } diff --git a/chart2/source/tools/RegressionCurveHelper.cxx b/chart2/source/tools/RegressionCurveHelper.cxx index 53b12b6397e9..6d397b1449bb 100644 --- a/chart2/source/tools/RegressionCurveHelper.cxx +++ b/chart2/source/tools/RegressionCurveHelper.cxx @@ -412,10 +412,9 @@ bool RegressionCurveHelper::removeAllExceptMeanValueLine( } } - for( std::vector< uno::Reference< chart2::XRegressionCurve > >::const_iterator aIt = aCurvesToDelete.begin(); - aIt != aCurvesToDelete.end(); ++aIt ) + for (auto const& curveToDelete : aCurvesToDelete) { - xRegCnt->removeRegressionCurve( *aIt ); + xRegCnt->removeRegressionCurve(curveToDelete); bRemovedSomething = true; } } @@ -686,10 +685,9 @@ std::vector< Reference< chart2::XRegressionCurve > > { std::vector< Reference< chart2::XRegressionCurve > > aResult; std::vector< Reference< chart2::XDataSeries > > aSeries( DiagramHelper::getDataSeriesFromDiagram( xDiagram )); - for( std::vector< Reference< chart2::XDataSeries > >::iterator aIt( aSeries.begin()); - aIt != aSeries.end(); ++aIt ) + for (auto const& elem : aSeries) { - Reference< chart2::XRegressionCurveContainer > xContainer( *aIt, uno::UNO_QUERY ); + Reference< chart2::XRegressionCurveContainer > xContainer(elem, uno::UNO_QUERY); if(xContainer.is()) { uno::Sequence< uno::Reference< chart2::XRegressionCurve > > aCurves(xContainer->getRegressionCurves()); diff --git a/chart2/source/tools/RelativeSizeHelper.cxx b/chart2/source/tools/RelativeSizeHelper.cxx index 7f9c63e94e86..1f155cb383df 100644 --- a/chart2/source/tools/RelativeSizeHelper.cxx +++ b/chart2/source/tools/RelativeSizeHelper.cxx @@ -63,15 +63,14 @@ void RelativeSizeHelper::adaptFontSizes( aProperties.emplace_back("CharHeightAsian" ); aProperties.emplace_back("CharHeightComplex" ); - for( vector< OUString >::const_iterator aIt = aProperties.begin(); - aIt != aProperties.end(); ++aIt ) + for (auto const& property : aProperties) { try { - if( xTargetProperties->getPropertyValue( *aIt ) >>= fFontHeight ) + if( xTargetProperties->getPropertyValue(property) >>= fFontHeight ) { xTargetProperties->setPropertyValue( - *aIt, + property, Any( static_cast< float >( calculate( fFontHeight, rOldReferenceSize, rNewReferenceSize )))); } diff --git a/chart2/source/tools/WrappedPropertySet.cxx b/chart2/source/tools/WrappedPropertySet.cxx index f7855233c5a7..a3a52817070c 100644 --- a/chart2/source/tools/WrappedPropertySet.cxx +++ b/chart2/source/tools/WrappedPropertySet.cxx @@ -53,10 +53,9 @@ void WrappedPropertySet::clearWrappedPropertySet() //delete all wrapped properties if(m_pWrappedPropertyMap) { - for( tWrappedPropertyMap::iterator aIt = m_pWrappedPropertyMap->begin() - ; aIt!= m_pWrappedPropertyMap->end(); ++aIt ) + for (auto const& elem : *m_pWrappedPropertyMap) { - const WrappedProperty* pWrappedProperty = (*aIt).second; + const WrappedProperty* pWrappedProperty = elem.second; DELETEZ(pWrappedProperty); } } @@ -426,26 +425,25 @@ tWrappedPropertyMap& WrappedPropertySet::getWrappedPropertyMap() std::vector< WrappedProperty* > aPropList( createWrappedProperties() ); p = new tWrappedPropertyMap; - for( std::vector< WrappedProperty* >::const_iterator aIt = aPropList.begin(); aIt!=aPropList.end(); ++aIt ) + for (auto const& elem : aPropList) { - WrappedProperty* pProperty = *aIt; - if(pProperty) + if(elem) { - sal_Int32 nHandle = getInfoHelper().getHandleByName( pProperty->getOuterName() ); + sal_Int32 nHandle = getInfoHelper().getHandleByName( elem->getOuterName() ); if( nHandle == -1 ) { OSL_FAIL( "missing property in property list" ); - delete pProperty;//we are owner or the created WrappedProperties + delete elem;//we are owner or the created WrappedProperties } else if( p->find( nHandle ) != p->end() ) { //duplicate Wrapped property OSL_FAIL( "duplicate Wrapped property" ); - delete pProperty;//we are owner or the created WrappedProperties + delete elem;//we are owner or the created WrappedProperties } else - (*p)[ nHandle ] = pProperty; + (*p)[ nHandle ] = elem; } } |