diff options
author | Arkadiy Illarionov <qarkai@gmail.com> | 2018-09-16 13:53:43 +0300 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-09-17 08:12:03 +0200 |
commit | 30530afaaa715473a2f9c3f068beeed5f3a98daf (patch) | |
tree | 5d5b499a75c4b363eec63e11b822de0da3cd5f60 /xmloff/source/table | |
parent | ffe2b51a4919fb64a8debecb724d1e959abf343a (diff) |
Simplify containers iterations in xmloff/source/[f-t]*
Use range-based loop or replace with STL functions.
Change-Id: Ic94c7e292f44d460038d3ca99c7e4cc02958d8a3
Reviewed-on: https://gerrit.libreoffice.org/60549
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'xmloff/source/table')
-rw-r--r-- | xmloff/source/table/XMLTableExport.cxx | 24 | ||||
-rw-r--r-- | xmloff/source/table/XMLTableImport.cxx | 23 |
2 files changed, 17 insertions, 30 deletions
diff --git a/xmloff/source/table/XMLTableExport.cxx b/xmloff/source/table/XMLTableExport.cxx index 3a4f8a5752bf..8018f2b1bc3d 100644 --- a/xmloff/source/table/XMLTableExport.cxx +++ b/xmloff/source/table/XMLTableExport.cxx @@ -130,14 +130,12 @@ void StringStatisticHelper::add( const OUString& rStyleName ) sal_Int32 StringStatisticHelper::getModeString( OUString& rStyleName ) { sal_Int32 nMax = 0; - const std::map< OUString, sal_Int32 >::const_iterator aEnd( mStats.end() ); - for( std::map< OUString, sal_Int32 >::iterator iter( mStats.begin() ); - iter != aEnd; ++iter) + for( const auto& rStatsEntry : mStats ) { - if( (*iter).second > nMax ) + if( rStatsEntry.second > nMax ) { - rStyleName = (*iter).first; - nMax = (*iter).second; + rStyleName = rStatsEntry.first; + nMax = rStatsEntry.second; } } @@ -206,18 +204,8 @@ XMLTableExport::~XMLTableExport () static bool has_states( const std::vector< XMLPropertyState >& xPropStates ) { - if( !xPropStates.empty() ) - { - std::vector< XMLPropertyState >::const_iterator aIter( xPropStates.begin() ); - std::vector< XMLPropertyState >::const_iterator aEnd( xPropStates.end() ); - while( aIter != aEnd ) - { - if( aIter->mnIndex != -1 ) - return true; - ++aIter; - } - } - return false; + return std::any_of(xPropStates.cbegin(), xPropStates.cend(), + [](const XMLPropertyState& rPropertyState) { return rPropertyState.mnIndex != -1; }); } void XMLTableExport::collectTableAutoStyles(const Reference < XColumnRowRange >& xColumnRowRange) diff --git a/xmloff/source/table/XMLTableImport.cxx b/xmloff/source/table/XMLTableImport.cxx index b3c20b5bc7b3..9b2c646c3a09 100644 --- a/xmloff/source/table/XMLTableImport.cxx +++ b/xmloff/source/table/XMLTableImport.cxx @@ -270,10 +270,10 @@ void XMLTableImport::insertTabletemplate(const OUString& rsStyleName, bool bOver std::shared_ptr<XMLTableTemplate> xT(it->second); - for (auto aStyleIter=xT->begin(); aStyleIter != xT->end(); ++aStyleIter) try + for (const auto& rStyle : *xT) try { - const OUString sPropName((*aStyleIter).first); - const OUString sStyleName((*aStyleIter).second); + const OUString sPropName(rStyle.first); + const OUString sStyleName(rStyle.second); // Internally unassigned cell styles are stored by display name. // However table-template elements reference cell styles by its encoded name. // This loop is looking for cell style by their encoded names. @@ -323,17 +323,17 @@ void XMLTableImport::finishStyles() Reference< XSingleServiceFactory > xFactory( xTableFamily, UNO_QUERY_THROW ); - for( XMLTableTemplateMap::iterator aTemplateIter( maTableTemplates.begin() ); aTemplateIter != maTableTemplates.end(); ++aTemplateIter ) try + for( const auto& rTemplate : maTableTemplates ) try { - const OUString sTemplateName( (*aTemplateIter).first ); + const OUString sTemplateName( rTemplate.first ); Reference< XNameReplace > xTemplate( xFactory->createInstance(), UNO_QUERY_THROW ); - std::shared_ptr< XMLTableTemplate > xT( (*aTemplateIter).second ); + std::shared_ptr< XMLTableTemplate > xT( rTemplate.second ); - for( XMLTableTemplate::iterator aStyleIter( xT->begin() ); aStyleIter != xT->end(); ++aStyleIter ) try + for( const auto& rStyle : *xT ) try { - const OUString sPropName( (*aStyleIter).first ); - const OUString sStyleName( (*aStyleIter).second ); + const OUString sPropName( rStyle.first ); + const OUString sStyleName( rStyle.second ); xTemplate->replaceByName( sPropName, xCellFamily->getByName( sStyleName ) ); } catch( Exception& ) @@ -596,10 +596,9 @@ void XMLTableImportContext::EndElement() { if( !maMergeInfos.empty() ) { - MergeInfoVector::iterator aIter( maMergeInfos.begin() ); - while( aIter != maMergeInfos.end() ) + for( const auto& rMergeInfo : maMergeInfos ) { - std::shared_ptr< MergeInfo > xInfo( (*aIter++) ); + std::shared_ptr< MergeInfo > xInfo( rMergeInfo ); if( xInfo.get() ) try { |