summaryrefslogtreecommitdiffstats
path: root/slideshow
diff options
context:
space:
mode:
authorDaniel Robertson <danlrobertson89@gmail.com>2015-10-09 09:21:20 -0400
committerNoel Grandin <noelgrandin@gmail.com>2015-10-11 06:13:15 +0000
commitb6297280853a7325ac0fa226b783652b22daebd0 (patch)
tree776739246232bc937d913d019841e3902423ed78 /slideshow
parentmove extracting assets to Java & use AssetManager to access assets (diff)
downloadcore-b6297280853a7325ac0fa226b783652b22daebd0.tar.gz
core-b6297280853a7325ac0fa226b783652b22daebd0.zip
Replace simple while loops with range-based for
Replace simple while loops with range-based for-loops when apropriate. There should be no side effects due to this change. Change-Id: I0c39d4c10c991354248e864a09333144974c953c Reviewed-on: https://gerrit.libreoffice.org/19281 Reviewed-by: Noel Grandin <noelgrandin@gmail.com> Tested-by: Noel Grandin <noelgrandin@gmail.com>
Diffstat (limited to 'slideshow')
-rw-r--r--slideshow/source/engine/shapes/shapeimporter.cxx7
-rw-r--r--slideshow/source/engine/shapes/viewshape.cxx10
-rw-r--r--slideshow/source/engine/slide/layermanager.cxx46
-rw-r--r--slideshow/source/engine/slide/targetpropertiescreator.cxx16
-rw-r--r--slideshow/source/engine/slideshowimpl.cxx48
-rw-r--r--slideshow/source/engine/slideview.cxx22
-rw-r--r--slideshow/source/engine/transitions/slidechangebase.cxx10
-rw-r--r--slideshow/source/engine/transitions/slidetransitionfactory.cxx73
-rw-r--r--slideshow/source/engine/waitsymbol.cxx23
-rw-r--r--slideshow/source/inc/listenercontainer.hxx34
10 files changed, 94 insertions, 195 deletions
diff --git a/slideshow/source/engine/shapes/shapeimporter.cxx b/slideshow/source/engine/shapes/shapeimporter.cxx
index c92e27a204be..21322f64c1ef 100644
--- a/slideshow/source/engine/shapes/shapeimporter.cxx
+++ b/slideshow/source/engine/shapes/shapeimporter.cxx
@@ -490,12 +490,10 @@ void ShapeImporter::importPolygons(uno::Reference<beans::XPropertySet> const& xP
aPoint.setY((*pInnerSequence).Y);
aPoly.append( aPoint );
}
- UnoViewVector::const_iterator aIter=(mrContext.mrViewContainer).begin();
- UnoViewVector::const_iterator aEnd=(mrContext.mrViewContainer).end();
- while(aIter != aEnd)
+ for( const auto& pView : mrContext.mrViewContainer )
{
::cppcanvas::PolyPolygonSharedPtr pPolyPoly(
- ::cppcanvas::BaseGfxFactory::createPolyPolygon( (*aIter)->getCanvas(),
+ ::cppcanvas::BaseGfxFactory::createPolyPolygon( pView->getCanvas(),
aPoly ) );
if( pPolyPoly )
{
@@ -504,7 +502,6 @@ void ShapeImporter::importPolygons(uno::Reference<beans::XPropertySet> const& xP
pPolyPoly->draw();
maPolygons.push_back(pPolyPoly);
}
- ++aIter;
}
}
diff --git a/slideshow/source/engine/shapes/viewshape.cxx b/slideshow/source/engine/shapes/viewshape.cxx
index 9847882f3fe3..05507e53afff 100644
--- a/slideshow/source/engine/shapes/viewshape.cxx
+++ b/slideshow/source/engine/shapes/viewshape.cxx
@@ -231,15 +231,11 @@ namespace slideshow
bool bRet(true);
- VectorOfDocTreeNodes::const_iterator aIter( rSubsets.begin() );
- const VectorOfDocTreeNodes::const_iterator aEnd ( rSubsets.end() );
- while( aIter != aEnd )
+ for( const auto& rSubset : rSubsets )
{
- if( !pRenderer->drawSubset( aIter->getStartIndex(),
- aIter->getEndIndex() ) )
+ if( !pRenderer->drawSubset( rSubset.getStartIndex(),
+ rSubset.getEndIndex() ) )
bRet = false;
-
- ++aIter;
}
return bRet;
diff --git a/slideshow/source/engine/slide/layermanager.cxx b/slideshow/source/engine/slide/layermanager.cxx
index aa555a84b4da..3dbb554a53bb 100644
--- a/slideshow/source/engine/slide/layermanager.cxx
+++ b/slideshow/source/engine/slide/layermanager.cxx
@@ -53,11 +53,9 @@ namespace slideshow
{
LayerSharedPtr pCurrLayer;
ViewLayerSharedPtr pCurrViewLayer;
- LayerShapeMap::const_iterator aIter( maAllShapes.begin() );
- const LayerShapeMap::const_iterator aEnd ( maAllShapes.end() );
- while( aIter != aEnd )
+ for( const auto& rShape : maAllShapes )
{
- LayerSharedPtr pLayer = aIter->second.lock();
+ LayerSharedPtr pLayer = rShape.second.lock();
if( pLayer && pLayer != pCurrLayer )
{
pCurrLayer = pLayer;
@@ -65,9 +63,7 @@ namespace slideshow
}
if( pCurrViewLayer )
- shapeFunc(aIter->first,pCurrViewLayer);
-
- ++aIter;
+ shapeFunc(rShape.first,pCurrViewLayer);
}
}
@@ -470,16 +466,14 @@ namespace slideshow
// send update() calls to every shape in the
// maUpdateShapes set, which is _animated_ (i.e. a
// sprite).
- const ShapeUpdateSet::const_iterator aEnd=maUpdateShapes.end();
- ShapeUpdateSet::const_iterator aCurrShape=maUpdateShapes.begin();
- while( aCurrShape != aEnd )
+ for( const auto& pShape : maUpdateShapes )
{
- if( (*aCurrShape)->isBackgroundDetached() )
+ if( pShape->isBackgroundDetached() )
{
// can update shape directly, without
// affecting layer content (shape is
// currently displayed in a sprite)
- if( !(*aCurrShape)->update() )
+ if( !pShape->update() )
bRet = false; // delay error exit
}
else
@@ -492,10 +486,8 @@ namespace slideshow
// cannot update shape directly, it's not
// animated and update() calls will prolly
// overwrite other page content.
- addUpdateArea( *aCurrShape );
+ addUpdateArea( pShape );
}
-
- ++aCurrShape;
}
maUpdateShapes.clear();
@@ -528,11 +520,9 @@ namespace slideshow
bool bIsCurrLayerUpdating(false);
Layer::EndUpdater aEndUpdater;
LayerSharedPtr pCurrLayer;
- LayerShapeMap::const_iterator aIter( maAllShapes.begin() );
- const LayerShapeMap::const_iterator aEnd ( maAllShapes.end() );
- while( aIter != aEnd )
+ for( const auto& rShape : maAllShapes )
{
- LayerSharedPtr pLayer = aIter->second.lock();
+ LayerSharedPtr pLayer = rShape.second.lock();
if( pLayer != pCurrLayer )
{
pCurrLayer = pLayer;
@@ -543,14 +533,12 @@ namespace slideshow
}
if( bIsCurrLayerUpdating &&
- !aIter->first->isBackgroundDetached() &&
- pCurrLayer->isInsideUpdateArea(aIter->first) )
+ !rShape.first->isBackgroundDetached() &&
+ pCurrLayer->isInsideUpdateArea(rShape.first) )
{
- if( !aIter->first->render() )
+ if( !rShape.first->render() )
bRet = false;
}
-
- ++aIter;
}
return bRet;
@@ -639,9 +627,7 @@ namespace slideshow
bool bRet( true );
ViewLayerSharedPtr pTmpLayer( new DummyLayer( rTargetCanvas ) );
- LayerShapeMap::const_iterator aIter( maAllShapes.begin() );
- const LayerShapeMap::const_iterator aEnd ( maAllShapes.end() );
- while( aIter != aEnd )
+ for( const auto& rShape : maAllShapes )
{
try
{
@@ -650,11 +636,11 @@ namespace slideshow
// ViewLayer. Since we add the shapes in the
// maShapeSet order (which is also the render order),
// this is equivalent to a subsequent render() call)
- aIter->first->addViewLayer( pTmpLayer,
+ rShape.first->addViewLayer( pTmpLayer,
true );
// and remove again, this is only temporary
- aIter->first->removeViewLayer( pTmpLayer );
+ rShape.first->removeViewLayer( pTmpLayer );
}
catch( uno::Exception& )
{
@@ -667,8 +653,6 @@ namespace slideshow
// at least one shape could not be rendered
bRet = false;
}
-
- ++aIter;
}
return bRet;
diff --git a/slideshow/source/engine/slide/targetpropertiescreator.cxx b/slideshow/source/engine/slide/targetpropertiescreator.cxx
index d1877c6c222d..5e44c8313304 100644
--- a/slideshow/source/engine/slide/targetpropertiescreator.cxx
+++ b/slideshow/source/engine/slide/targetpropertiescreator.cxx
@@ -332,27 +332,23 @@ namespace internal
uno::Sequence< animations::TargetProperties > aRes( aShapeHash.size() );
::std::size_t nCurrIndex(0);
- XShapeHash::const_iterator aCurr( aShapeHash.begin() );
- const XShapeHash::const_iterator aEnd ( aShapeHash.end() );
- while( aCurr != aEnd )
+ for( const auto& rIter : aShapeHash )
{
animations::TargetProperties& rCurrProps( aRes[ nCurrIndex++ ] );
- if( aCurr->first.mnParagraphIndex == -1 )
+ if( rIter.first.mnParagraphIndex == -1 )
{
- rCurrProps.Target = uno::makeAny( aCurr->first.mxRef );
+ rCurrProps.Target = uno::makeAny( rIter.first.mxRef );
}
else
{
rCurrProps.Target = uno::makeAny(
presentation::ParagraphTarget(
- aCurr->first.mxRef,
- aCurr->first.mnParagraphIndex ) );
+ rIter.first.mxRef,
+ rIter.first.mnParagraphIndex ) );
}
- rCurrProps.Properties = ::comphelper::containerToSequence( aCurr->second );
-
- ++aCurr;
+ rCurrProps.Properties = ::comphelper::containerToSequence( rIter.second );
}
return aRes;
diff --git a/slideshow/source/engine/slideshowimpl.cxx b/slideshow/source/engine/slideshowimpl.cxx
index 45befe07e8e4..2144d33b9512 100644
--- a/slideshow/source/engine/slideshowimpl.cxx
+++ b/slideshow/source/engine/slideshowimpl.cxx
@@ -885,18 +885,14 @@ ActivitySharedPtr SlideShowImpl::createSlideTransition(
PolygonMap::iterator SlideShowImpl::findPolygons( uno::Reference<drawing::XDrawPage> const& xDrawPage)
{
// TODO(P2) : Optimze research in the map.
- bool bFound = false;
- PolygonMap::iterator aIter=maPolygons.begin();
-
- while(aIter!=maPolygons.end() && !bFound)
- {
- if(aIter->first == xDrawPage)
- bFound = true;
- else
- ++aIter;
- }
-
- return aIter;
+ PolygonMap::iterator aEnd = maPolygons.end();
+ for( PolygonMap::iterator aIter = maPolygons.begin();
+ aIter != aEnd;
+ ++aIter )
+ if( aIter->first == xDrawPage )
+ return aIter;
+
+ return aEnd;
}
SlideSharedPtr SlideShowImpl::makeSlide(
@@ -1444,25 +1440,16 @@ void SlideShowImpl::registerUserPaintPolygons( const uno::Reference< lang::XMult
aPropLayer <<= false;
xLayerPropSet->setPropertyValue("IsLocked", aPropLayer);
- PolygonMap::iterator aIter=maPolygons.begin();
-
- PolyPolygonVector aPolygons;
- ::cppcanvas::PolyPolygonSharedPtr pPolyPoly;
- ::basegfx::B2DPolyPolygon b2DPolyPoly;
-
//Register polygons for each slide
- while(aIter!=maPolygons.end())
+ for( const auto& rPoly : maPolygons )
{
- aPolygons = aIter->second;
+ PolyPolygonVector aPolygons = rPoly.second;
//Get shapes for the slide
- ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes > Shapes(aIter->first, ::com::sun::star::uno::UNO_QUERY);
+ ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes > Shapes(rPoly.first, ::com::sun::star::uno::UNO_QUERY);
//Retrieve polygons for one slide
- for( PolyPolygonVector::iterator aIterPoly=aPolygons.begin(),
- aEnd=aPolygons.end();
- aIterPoly!=aEnd; ++aIterPoly )
+ for( const auto pPolyPoly : aPolygons )
{
- pPolyPoly = (*aIterPoly);
- b2DPolyPoly = ::basegfx::unotools::b2DPolyPolygonFromXPolyPolygon2D(pPolyPoly->getUNOPolyPolygon());
+ ::basegfx::B2DPolyPolygon b2DPolyPoly = ::basegfx::unotools::b2DPolyPolygonFromXPolyPolygon2D(pPolyPoly->getUNOPolyPolygon());
//Normally there is only one polygon
for(sal_uInt32 i=0; i< b2DPolyPoly.count();i++)
@@ -1531,7 +1518,6 @@ void SlideShowImpl::registerUserPaintPolygons( const uno::Reference< lang::XMult
}
}
}
- ++aIter;
}
}
@@ -2113,13 +2099,11 @@ sal_Bool SlideShowImpl::update( double & nNextTimeout )
(!bRet ||
nNextTimeout > 1.0) )
{
- UnoViewVector::const_iterator aCurr(maViewContainer.begin());
- const UnoViewVector::const_iterator aEnd(maViewContainer.end());
- while( aCurr != aEnd )
+ for( const auto& pView : maViewContainer )
{
try
{
- uno::Reference< presentation::XSlideShowView > xView( (*aCurr)->getUnoView(),
+ uno::Reference< presentation::XSlideShowView > xView( pView->getUnoView(),
uno::UNO_QUERY_THROW );
uno::Reference< util::XUpdatable > xUpdatable( xView->getCanvas(),
uno::UNO_QUERY_THROW );
@@ -2135,8 +2119,6 @@ sal_Bool SlideShowImpl::update( double & nNextTimeout )
comphelper::anyToString( cppu::getCaughtException() ),
RTL_TEXTENCODING_UTF8 ).getStr() );
}
-
- ++aCurr;
}
mbSlideShowIdle = true;
diff --git a/slideshow/source/engine/slideview.cxx b/slideshow/source/engine/slideview.cxx
index b1755989c70c..236f3a5d0e77 100644
--- a/slideshow/source/engine/slideview.cxx
+++ b/slideshow/source/engine/slideview.cxx
@@ -283,23 +283,19 @@ class LayerSpriteContainer
SpriteVector aValidSprites;
// check all sprites for validity and set new priority
- SpriteVector::iterator aCurrSprite( maSprites.begin() );
- const SpriteVector::iterator aEnd( maSprites.end() );
- while( aCurrSprite != aEnd )
+ for( const auto& rSprite : maSprites )
{
- cppcanvas::CustomSpriteSharedPtr pCurrSprite( aCurrSprite->mpSprite.lock() );
+ cppcanvas::CustomSpriteSharedPtr pCurrSprite( rSprite.mpSprite.lock() );
if( pCurrSprite )
{
// only copy still valid sprites over to the refreshed
// sprite vector.
- aValidSprites.push_back( *aCurrSprite );
+ aValidSprites.push_back( rSprite );
pCurrSprite->setPriority(
getSpritePriority( aValidSprites.size()-1 ));
}
-
- ++aCurrSprite;
}
// replace sprite list with pruned one
@@ -1173,22 +1169,18 @@ void SlideView::pruneLayers( bool bWithViewLayerUpdate ) const
getTransformation() );
// check all layers for validity, and retain only the live ones
- ViewLayerVector::const_iterator aCurr( maViewLayers.begin() );
- const ViewLayerVector::const_iterator aEnd( maViewLayers.end() );
- while( aCurr != aEnd )
+ for( const auto& rView : maViewLayers )
{
- std::shared_ptr< SlideViewLayer > xCurrLayer( aCurr->lock() );
+ std::shared_ptr< SlideViewLayer > xCurrLayer( rView.lock() );
- if (xCurrLayer)
+ if ( xCurrLayer )
{
- aValidLayers.push_back(xCurrLayer);
+ aValidLayers.push_back( xCurrLayer );
if( bWithViewLayerUpdate )
xCurrLayer->updateView( rCurrTransform,
maUserSize );
}
-
- ++aCurr;
}
// replace layer list with pruned one
diff --git a/slideshow/source/engine/transitions/slidechangebase.cxx b/slideshow/source/engine/transitions/slidechangebase.cxx
index cba1093f7360..941d0ab1128d 100644
--- a/slideshow/source/engine/transitions/slidechangebase.cxx
+++ b/slideshow/source/engine/transitions/slidechangebase.cxx
@@ -453,16 +453,12 @@ void SlideChangeBase::viewsChanged()
if( mbFinished )
return;
- ViewsVecT::iterator aIter( maViewData.begin() );
- ViewsVecT::iterator const aEnd ( maViewData.end() );
- while( aIter != aEnd )
+ for( auto& pView : maViewData )
{
// clear stale info (both bitmaps and sprites prolly need a
// resize)
- clearViewEntry( *aIter );
- addSprites( *aIter );
-
- ++aIter;
+ clearViewEntry( pView );
+ addSprites( pView );
}
}
diff --git a/slideshow/source/engine/transitions/slidetransitionfactory.cxx b/slideshow/source/engine/transitions/slidetransitionfactory.cxx
index 3c894e31c1a6..6e991add5280 100644
--- a/slideshow/source/engine/transitions/slidetransitionfactory.cxx
+++ b/slideshow/source/engine/transitions/slidetransitionfactory.cxx
@@ -141,16 +141,13 @@ public:
mxFactory( xFactory )
{
// create one transition per view
- UnoViewVector::const_iterator aCurrView (rViewContainer.begin());
- const UnoViewVector::const_iterator aEnd(rViewContainer.end());
- while( aCurrView != aEnd )
+ for( const auto& rView : rViewContainer )
{
- if(! addTransition( *aCurrView ) )
+ if( !addTransition( rView ) )
return;
ENSURE_OR_THROW(maTransitions.back() && maTransitions.back()->mxTransition.is(),
"Failed to create plugin transition");
- ++aCurrView;
}
mbSuccess = true;
}
@@ -159,13 +156,11 @@ public:
{
mxFactory.clear();
- ::std::vector< TransitionViewPair* >::const_iterator aCurrView (maTransitions.begin());
- ::std::vector< TransitionViewPair* >::const_iterator aEnd(maTransitions.end());
- while( aCurrView != aEnd )
+ for( const auto& pCurrView : maTransitions )
{
- delete (*aCurrView);
- ++aCurrView;
+ delete pCurrView;
}
+
maTransitions.clear();
}
@@ -204,24 +199,14 @@ public:
OSL_TRACE("PluginSlideChange viewAdded");
SlideChangeBase::viewAdded( rView );
- ::std::vector< TransitionViewPair* >::const_iterator aCurrView (maTransitions.begin());
- ::std::vector< TransitionViewPair* >::const_iterator aEnd(maTransitions.end());
- bool bKnown = false;
- while( aCurrView != aEnd )
+ for( const auto& pCurrView : maTransitions )
{
- if( (*aCurrView)->mpView == rView )
- {
- bKnown = true;
- break;
- }
- ++aCurrView;
+ if( pCurrView->mpView == rView )
+ return;
}
- if( !bKnown )
- {
- OSL_TRACE("need to be added");
- addTransition( rView );
- }
+ OSL_TRACE( "need to be added" );
+ addTransition( rView );
}
virtual void viewRemoved( const UnoViewSharedPtr& rView ) SAL_OVERRIDE
@@ -229,18 +214,18 @@ public:
OSL_TRACE("PluginSlideChange viewRemoved");
SlideChangeBase::viewRemoved( rView );
- ::std::vector< TransitionViewPair* >::iterator aCurrView (maTransitions.begin());
::std::vector< TransitionViewPair* >::const_iterator aEnd(maTransitions.end());
- while( aCurrView != aEnd )
+ for( ::std::vector< TransitionViewPair* >::iterator aIter =maTransitions.begin();
+ aIter != aEnd;
+ ++aIter )
{
- if( (*aCurrView)->mpView == rView )
+ if( ( *aIter )->mpView == rView )
{
OSL_TRACE( "view removed" );
- delete (*aCurrView);
- maTransitions.erase( aCurrView );
+ delete ( *aIter );
+ maTransitions.erase( aIter );
break;
}
- ++aCurrView;
}
}
@@ -249,21 +234,17 @@ public:
OSL_TRACE("PluginSlideChange viewChanged");
SlideChangeBase::viewChanged( rView );
- ::std::vector< TransitionViewPair* >::const_iterator aCurrView (maTransitions.begin());
- ::std::vector< TransitionViewPair* >::const_iterator aEnd(maTransitions.end());
- while( aCurrView != aEnd )
+ for( const auto& pCurrView : maTransitions )
{
- if( (*aCurrView)->mpView == rView )
+ if( pCurrView->mpView == rView )
{
OSL_TRACE( "view changed" );
- (*aCurrView)->mxTransition->viewChanged( rView->getUnoView(),
- getLeavingBitmap(ViewEntry(rView))->getXBitmap(),
- getEnteringBitmap(ViewEntry(rView))->getXBitmap() );
+ pCurrView->mxTransition->viewChanged( rView->getUnoView(),
+ getLeavingBitmap(ViewEntry(rView))->getXBitmap(),
+ getEnteringBitmap(ViewEntry(rView))->getXBitmap() );
}
else
OSL_TRACE( "view did not changed" );
-
- ++aCurrView;
}
}
@@ -272,15 +253,13 @@ public:
OSL_TRACE("PluginSlideChange viewsChanged");
SlideChangeBase::viewsChanged();
- ::std::vector< TransitionViewPair* >::const_iterator aCurrView (maTransitions.begin());
- ::std::vector< TransitionViewPair* >::const_iterator aEnd(maTransitions.end());
- while( aCurrView != aEnd )
+ for( const auto& pCurrView : maTransitions )
{
OSL_TRACE( "view changed" );
- (*aCurrView)->mxTransition->viewChanged( (*aCurrView)->mpView->getUnoView(),
- getLeavingBitmap(ViewEntry((*aCurrView)->mpView))->getXBitmap(),
- getEnteringBitmap(ViewEntry((*aCurrView)->mpView))->getXBitmap() );
- ++aCurrView;
+ UnoViewSharedPtr pView = pCurrView->mpView;
+ pCurrView->mxTransition->viewChanged( pView->getUnoView(),
+ getLeavingBitmap(ViewEntry(pView))->getXBitmap(),
+ getEnteringBitmap(ViewEntry(pView))->getXBitmap() );
}
}
diff --git a/slideshow/source/engine/waitsymbol.cxx b/slideshow/source/engine/waitsymbol.cxx
index ab3dbbf29eb7..5e4209ab8d51 100644
--- a/slideshow/source/engine/waitsymbol.cxx
+++ b/slideshow/source/engine/waitsymbol.cxx
@@ -77,19 +77,15 @@ void WaitSymbol::setVisible( const bool bVisible )
{
mbVisible = bVisible;
- ViewsVecT::const_iterator aIter( maViews.begin() );
- ViewsVecT::const_iterator const aEnd ( maViews.end() );
- while( aIter != aEnd )
+ for( const auto& rView : maViews )
{
- if( aIter->second )
+ if( rView.second )
{
if( bVisible )
- aIter->second->show();
+ rView.second->show();
else
- aIter->second->hide();
+ rView.second->hide();
}
-
- ++aIter;
}
// sprites changed, need a screen update for this frame.
@@ -176,14 +172,11 @@ void WaitSymbol::viewChanged( const UnoViewSharedPtr& rView )
void WaitSymbol::viewsChanged()
{
// reposition sprites on all views
- ViewsVecT::const_iterator aIter( maViews.begin() );
- ViewsVecT::const_iterator const aEnd ( maViews.end() );
- while( aIter != aEnd )
+ for( const auto& rView : maViews )
{
- if( aIter->second )
- aIter->second->movePixel(
- calcSpritePos( aIter->first ));
- ++aIter;
+ if( rView.second )
+ rView.second->movePixel(
+ calcSpritePos( rView.first ) );
}
}
diff --git a/slideshow/source/inc/listenercontainer.hxx b/slideshow/source/inc/listenercontainer.hxx
index 8317ac97f258..4d45dbaf8f2d 100644
--- a/slideshow/source/inc/listenercontainer.hxx
+++ b/slideshow/source/inc/listenercontainer.hxx
@@ -102,19 +102,15 @@ template< typename ListenerT > struct ListenerOperations
FuncT func )
{
bool bRet(false);
- typename ContainerT::const_iterator aCurr( rContainer.begin() );
- typename ContainerT::const_iterator const aEnd ( rContainer.end() );
- while( aCurr != aEnd )
+ for( const auto& rCurr : rContainer )
{
if( FunctionApply< typename FuncT::result_type,
typename ContainerT::value_type >::apply(
func,
- *aCurr) )
+ rCurr) )
{
bRet = true;
}
-
- ++aCurr;
}
// true: at least one handler returned true
@@ -137,16 +133,12 @@ struct ListenerOperations< boost::weak_ptr<ListenerTargetT> >
static bool notifySingleListener( ContainerT& rContainer,
FuncT func )
{
- typename ContainerT::const_iterator aCurr( rContainer.begin() );
- typename ContainerT::const_iterator const aEnd ( rContainer.end() );
- while( aCurr != aEnd )
+ for( const auto& rCurr : rContainer )
{
- boost::shared_ptr<ListenerTargetT> pListener( aCurr->lock() );
+ boost::shared_ptr<ListenerTargetT> pListener( rCurr.lock() );
if( pListener && func(pListener) )
return true;
-
- ++aCurr;
}
return false;
@@ -158,11 +150,9 @@ struct ListenerOperations< boost::weak_ptr<ListenerTargetT> >
FuncT func )
{
bool bRet(false);
- typename ContainerT::const_iterator aCurr( rContainer.begin() );
- typename ContainerT::const_iterator const aEnd ( rContainer.end() );
- while( aCurr != aEnd )
+ for( const auto& rCurr : rContainer )
{
- boost::shared_ptr<ListenerTargetT> pListener( aCurr->lock() );
+ boost::shared_ptr<ListenerTargetT> pListener( rCurr.lock() );
if( pListener.get() &&
FunctionApply< typename FuncT::result_type,
@@ -170,8 +160,6 @@ struct ListenerOperations< boost::weak_ptr<ListenerTargetT> >
{
bRet = true;
}
-
- ++aCurr;
}
return bRet;
@@ -186,14 +174,10 @@ struct ListenerOperations< boost::weak_ptr<ListenerTargetT> >
ContainerT aAliveListeners;
aAliveListeners.reserve(rContainer.size());
- typename ContainerT::const_iterator aCurr( rContainer.begin() );
- typename ContainerT::const_iterator const aEnd ( rContainer.end() );
- while( aCurr != aEnd )
+ for( const auto& rCurr : rContainer )
{
- if( !aCurr->expired() )
- aAliveListeners.push_back( *aCurr );
-
- ++aCurr;
+ if( !rCurr.expired() )
+ aAliveListeners.push_back( rCurr );
}
std::swap( rContainer, aAliveListeners );