diff options
author | Arkadiy Illarionov <qarkai@gmail.com> | 2019-02-16 18:39:23 +0300 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2019-02-18 07:41:05 +0100 |
commit | 44841a6778821be3e68ab15819b39064b20e968f (patch) | |
tree | 8e9119cf35764f18f5b008e7758c6f950306fb8c /filter | |
parent | bcfbd24be02d2de5d4d27c147dc58c4515a9a0f5 (diff) |
Simplify containers iterations in [f-l]*
Use range-based loop or replace with STL functions
Change-Id: Ib3fab47318d1bfbb4df8f886a8cd9596525a420f
Reviewed-on: https://gerrit.libreoffice.org/67914
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Tested-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'filter')
-rw-r--r-- | filter/source/graphicfilter/icgm/elements.cxx | 10 | ||||
-rw-r--r-- | filter/source/msfilter/escherex.cxx | 11 | ||||
-rw-r--r-- | filter/source/msfilter/msdffimp.cxx | 39 | ||||
-rw-r--r-- | filter/source/msfilter/svdfppt.cxx | 13 | ||||
-rw-r--r-- | filter/source/xsltdialog/typedetectionimport.cxx | 9 |
5 files changed, 29 insertions, 53 deletions
diff --git a/filter/source/graphicfilter/icgm/elements.cxx b/filter/source/graphicfilter/icgm/elements.cxx index 8d324b68340c..915edc363630 100644 --- a/filter/source/graphicfilter/icgm/elements.cxx +++ b/filter/source/graphicfilter/icgm/elements.cxx @@ -320,12 +320,10 @@ Bundle* CGMElements::InsertBundle( BundleList& rList, Bundle& rBundle ) Bundle* pBundle = GetBundle( rList, rBundle.GetIndex() ); if ( pBundle ) { - for ( BundleList::iterator it = rList.begin(); it != rList.end(); ++it ) { - if ( it->get() == pBundle ) { - rList.erase( it ); - break; - } - } + auto it = std::find_if(rList.begin(), rList.end(), + [&pBundle](const std::unique_ptr<Bundle>& rxBundle) { return rxBundle.get() == pBundle; }); + if (it != rList.end()) + rList.erase( it ); } rList.push_back( rBundle.Clone() ); return rList.back().get(); diff --git a/filter/source/msfilter/escherex.cxx b/filter/source/msfilter/escherex.cxx index 50e10a4af1fb..32756294d391 100644 --- a/filter/source/msfilter/escherex.cxx +++ b/filter/source/msfilter/escherex.cxx @@ -3794,13 +3794,10 @@ void EscherPersistTable::PtInsert( sal_uInt32 nID, sal_uInt32 nOfs ) void EscherPersistTable::PtDelete( sal_uInt32 nID ) { - for(auto it = maPersistTable.begin(); it != maPersistTable.end() ; ++it) - { - if ( (*it)->mnID == nID ) { - maPersistTable.erase( it ); - break; - } - } + auto it = std::find_if(maPersistTable.begin(), maPersistTable.end(), + [&nID](const std::unique_ptr<EscherPersistEntry>& rxEntry) { return rxEntry->mnID == nID; }); + if (it != maPersistTable.end()) + maPersistTable.erase( it ); } sal_uInt32 EscherPersistTable::PtGetOffsetByID( sal_uInt32 nID ) diff --git a/filter/source/msfilter/msdffimp.cxx b/filter/source/msfilter/msdffimp.cxx index 45c8836f9d10..df759c529693 100644 --- a/filter/source/msfilter/msdffimp.cxx +++ b/filter/source/msfilter/msdffimp.cxx @@ -1176,30 +1176,22 @@ static void ApplyRectangularGradientAsBitmap( const SvxMSDffManager& rManager, S if ( fD != 0.0 ) fDist /= fD; - std::vector< ShadeColor >::const_iterator aIter( rShadeColors.begin() ); double fA = 0.0; - Color aColorA = aIter->aColor; + Color aColorA = rShadeColors.front().aColor; double fB = 1.0; Color aColorB( aColorA ); - while ( aIter != rShadeColors.end() ) + for ( const auto& rShadeColor : rShadeColors ) { - if ( aIter->fDist <= fDist ) + if ( fA <= rShadeColor.fDist && rShadeColor.fDist <= fDist ) { - if ( aIter->fDist >= fA ) - { - fA = aIter->fDist; - aColorA = aIter->aColor; - } + fA = rShadeColor.fDist; + aColorA = rShadeColor.aColor; } - if ( aIter->fDist > fDist ) + if ( fDist < rShadeColor.fDist && rShadeColor.fDist <= fB ) { - if ( aIter->fDist <= fB ) - { - fB = aIter->fDist; - aColorB = aIter->aColor; - } + fB = rShadeColor.fDist; + aColorB = rShadeColor.aColor; } - ++aIter; } double fRed = aColorA.GetRed(), fGreen = aColorA.GetGreen(), fBlue = aColorA.GetBlue(); double fD1 = fB - fA; @@ -7501,17 +7493,10 @@ void SvxMSDffManager::insertShapeId( sal_Int32 nShapeId, SdrObject* pShape ) void SvxMSDffManager::removeShapeId( SdrObject const * pShape ) { - SvxMSDffShapeIdContainer::iterator aIter( maShapeIdContainer.begin() ); - const SvxMSDffShapeIdContainer::iterator aEnd( maShapeIdContainer.end() ); - while( aIter != aEnd ) - { - if( (*aIter).second == pShape ) - { - maShapeIdContainer.erase( aIter ); - break; - } - ++aIter; - } + SvxMSDffShapeIdContainer::iterator aIter = std::find_if(maShapeIdContainer.begin(), maShapeIdContainer.end(), + [&pShape](const SvxMSDffShapeIdContainer::value_type& rEntry) { return rEntry.second == pShape; }); + if (aIter != maShapeIdContainer.end()) + maShapeIdContainer.erase( aIter ); } SdrObject* SvxMSDffManager::getShapeForId( sal_Int32 nShapeId ) diff --git a/filter/source/msfilter/svdfppt.cxx b/filter/source/msfilter/svdfppt.cxx index 8321b494d598..2f92c28b5822 100644 --- a/filter/source/msfilter/svdfppt.cxx +++ b/filter/source/msfilter/svdfppt.cxx @@ -6903,12 +6903,9 @@ PPTTextObj::PPTTextObj( SvStream& rIn, SdrPowerPointImport& rSdrPowerPointImport if (xEntry) { // sorting fields ( hi >> lo ) - auto it = FieldList.begin(); - for( ; it != FieldList.end(); ++it ) { - if ( (*it)->nPos < xEntry->nPos ) { - break; - } - } + auto it = std::find_if(FieldList.begin(), FieldList.end(), + [&xEntry](const std::unique_ptr<PPTFieldEntry>& rxField) { + return rxField->nPos < xEntry->nPos; }); if ( it != FieldList.end() ) { FieldList.insert(it, std::move(xEntry)); } else { @@ -6935,8 +6932,8 @@ PPTTextObj::PPTTextObj( SvStream& rIn, SdrPowerPointImport& rSdrPowerPointImport while ( ( FE < FieldList.end() ) && nCount-- ) { nPos--; - while ( ( FE < FieldList.end() ) && ( (*FE)->nPos > nPos ) ) - ++FE; + FE = std::find_if(FE, FieldList.end(), + [&nPos](const std::unique_ptr<PPTFieldEntry>& rxField) {return rxField->nPos <= nPos;}); if ( !(FE < FieldList.end()) ) break; diff --git a/filter/source/xsltdialog/typedetectionimport.cxx b/filter/source/xsltdialog/typedetectionimport.cxx index e1c3d8147b9d..5a0ebdb8c05a 100644 --- a/filter/source/xsltdialog/typedetectionimport.cxx +++ b/filter/source/xsltdialog/typedetectionimport.cxx @@ -115,11 +115,10 @@ static OUString getSubdata( int index, sal_Unicode delimiter, const OUString& rD Node* TypeDetectionImporter::findTypeNode( const OUString& rType ) { - for (auto aIter(maTypeNodes.begin()), aEnd(maTypeNodes.end()); aIter != aEnd; ++aIter) - { - if( (*aIter)->maName == rType ) - return aIter->get(); - } + auto aIter = std::find_if(maTypeNodes.begin(), maTypeNodes.end(), + [&rType](const std::unique_ptr<Node>& rxNode) { return rxNode->maName == rType; }); + if (aIter != maTypeNodes.end()) + return aIter->get(); return nullptr; } |