From a811d6efe4e8e995102bb19f7a1d3008fc06be8d Mon Sep 17 00:00:00 2001 From: Daniel Robertson Date: Sun, 16 Aug 2015 13:55:51 -0400 Subject: slideshow: replace for_each with range-based for Replace ::std::for_each for a more readable range-based for loop in cases in which the function object to be applied by for_each is more readable as the body of a for loop. In addition, replace while loops with range-based for loops when possible and complex implementations of boost::bind with lambda expressions. Change-Id: I6adfb18197bd1b8627719adfca2e4c36d58a0e05 Reviewed-on: https://gerrit.libreoffice.org/17786 Reviewed-by: Thorsten Behrens Tested-by: Thorsten Behrens --- slideshow/source/engine/activitiesqueue.cxx | 26 ++-- .../source/engine/animationnodes/basenode.cxx | 7 +- slideshow/source/engine/pointersymbol.cxx | 40 +++--- .../source/engine/rehearsetimingsactivity.cxx | 7 +- slideshow/source/engine/screenupdater.cxx | 29 ++--- slideshow/source/engine/shapes/appletshape.cxx | 57 ++++----- slideshow/source/engine/shapes/drawshape.cxx | 137 +++++++-------------- .../source/engine/shapes/drawshapesubsetting.cxx | 9 +- slideshow/source/engine/shapes/mediashape.cxx | 66 ++++------ 9 files changed, 135 insertions(+), 243 deletions(-) (limited to 'slideshow') diff --git a/slideshow/source/engine/activitiesqueue.cxx b/slideshow/source/engine/activitiesqueue.cxx index 647bffe41078..5009dbe62681 100644 --- a/slideshow/source/engine/activitiesqueue.cxx +++ b/slideshow/source/engine/activitiesqueue.cxx @@ -26,7 +26,6 @@ #include "activity.hxx" #include "activitiesqueue.hxx" -#include #include #include @@ -51,12 +50,10 @@ namespace slideshow // dispose all queue entries try { - std::for_each( maCurrentActivitiesWaiting.begin(), - maCurrentActivitiesWaiting.end(), - boost::mem_fn( &Disposable::dispose ) ); - std::for_each( maCurrentActivitiesReinsert.begin(), - maCurrentActivitiesReinsert.end(), - boost::mem_fn( &Disposable::dispose ) ); + for( const auto& pActivity : maCurrentActivitiesWaiting ) + pActivity->dispose(); + for( const auto& pActivity : maCurrentActivitiesReinsert ) + pActivity->dispose(); } catch (uno::Exception &) { @@ -169,9 +166,8 @@ namespace slideshow void ActivitiesQueue::processDequeued() { // notify all dequeued activities from last round - ::std::for_each( maDequeuedActivities.begin(), - maDequeuedActivities.end(), - ::boost::mem_fn( &Activity::dequeued ) ); + for( const auto& pActivity : maDequeuedActivities ) + pActivity->dequeued(); maDequeuedActivities.clear(); } @@ -183,14 +179,12 @@ namespace slideshow void ActivitiesQueue::clear() { // dequeue all entries: - std::for_each( maCurrentActivitiesWaiting.begin(), - maCurrentActivitiesWaiting.end(), - boost::mem_fn( &Activity::dequeued ) ); + for( const auto& pActivity : maCurrentActivitiesWaiting ) + pActivity->dequeued(); ActivityQueue().swap( maCurrentActivitiesWaiting ); - std::for_each( maCurrentActivitiesReinsert.begin(), - maCurrentActivitiesReinsert.end(), - boost::mem_fn( &Activity::dequeued ) ); + for( const auto& pActivity : maCurrentActivitiesReinsert ) + pActivity->dequeued(); ActivityQueue().swap( maCurrentActivitiesReinsert ); } } diff --git a/slideshow/source/engine/animationnodes/basenode.cxx b/slideshow/source/engine/animationnodes/basenode.cxx index 6b6f62dd239a..f844521b81f4 100644 --- a/slideshow/source/engine/animationnodes/basenode.cxx +++ b/slideshow/source/engine/animationnodes/basenode.cxx @@ -34,7 +34,6 @@ #include "nodetools.hxx" #include "generateevent.hxx" -#include #include #include #include @@ -624,10 +623,8 @@ void BaseNode::notifyDeactivating( const AnimationNodeSharedPtr& rNotifier ) void BaseNode::notifyEndListeners() const { // notify all listeners - std::for_each( maDeactivatingListeners.begin(), - maDeactivatingListeners.end(), - boost::bind( &AnimationNode::notifyDeactivating, _1, - boost::cref(mpSelf) ) ); + for( const auto& rListner : maDeactivatingListeners ) + rListner->notifyDeactivating( mpSelf ); // notify state change maContext.mrEventMultiplexer.notifyAnimationEnd( mpSelf ); diff --git a/slideshow/source/engine/pointersymbol.cxx b/slideshow/source/engine/pointersymbol.cxx index c63f8fe80a63..2b50addcd71c 100644 --- a/slideshow/source/engine/pointersymbol.cxx +++ b/slideshow/source/engine/pointersymbol.cxx @@ -64,10 +64,8 @@ PointerSymbol::PointerSymbol( uno::Reference const & xBitm maPos(), mbVisible(false) { - std::for_each( rViewContainer.begin(), - rViewContainer.end(), - [this]( const UnoViewSharedPtr& sp ) - { this->viewAdded(sp); } ); + for( const auto& rView : rViewContainer ) + viewAdded( rView ); } void PointerSymbol::setVisible( const bool bVisible ) @@ -76,19 +74,15 @@ void PointerSymbol::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. @@ -173,14 +167,11 @@ void PointerSymbol::viewChanged( const UnoViewSharedPtr& rView ) void PointerSymbol::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 ) ); } } @@ -191,18 +182,15 @@ void PointerSymbol::viewsChanged(const geometry::RealPoint2D pos) maPos = pos; // 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 ) + if( rView.second ) { - aIter->second->movePixel( - calcSpritePos( aIter->first )); + rView.second->movePixel( + calcSpritePos( rView.first ) ); mrScreenUpdater.notifyUpdate(); mrScreenUpdater.commitUpdates(); } - ++aIter; } } } diff --git a/slideshow/source/engine/rehearsetimingsactivity.cxx b/slideshow/source/engine/rehearsetimingsactivity.cxx index 0bebe2aea039..2cabde3a3a97 100644 --- a/slideshow/source/engine/rehearsetimingsactivity.cxx +++ b/slideshow/source/engine/rehearsetimingsactivity.cxx @@ -167,11 +167,8 @@ RehearseTimingsActivity::RehearseTimingsActivity( const SlideShowContext& rConte maSpriteSizePixel.setY( metric.GetLineHeight() * 11 / 10 ); mnYOffset = (metric.GetAscent() + (metric.GetLineHeight() / 20)); - std::for_each( rContext.mrViewContainer.begin(), - rContext.mrViewContainer.end(), - boost::bind( &RehearseTimingsActivity::viewAdded, - this, - _1 )); + for( const auto& rView : rContext.mrViewContainer ) + viewAdded( rView ); } RehearseTimingsActivity::~RehearseTimingsActivity() diff --git a/slideshow/source/engine/screenupdater.cxx b/slideshow/source/engine/screenupdater.cxx index 5210182ed887..f2930530ba60 100644 --- a/slideshow/source/engine/screenupdater.cxx +++ b/slideshow/source/engine/screenupdater.cxx @@ -137,20 +137,18 @@ namespace internal mpImpl->mbUpdateAllRequest ) { // unconditionally update all views - std::for_each( mpImpl->mrViewContainer.begin(), - mpImpl->mrViewContainer.end(), - mpImpl->mbViewClobbered ? - boost::mem_fn(&View::paintScreen) : - boost::mem_fn(&View::updateScreen) ); + for( const auto& pView : mpImpl->mrViewContainer ) + { + if( mpImpl->mbViewClobbered ) + pView->paintScreen(); + else + pView->updateScreen(); + } } else if( !mpImpl->maViewUpdateRequests.empty() ) { // update notified views only - UpdateRequestVector::const_iterator aIter( - mpImpl->maViewUpdateRequests.begin() ); - const UpdateRequestVector::const_iterator aEnd( - mpImpl->maViewUpdateRequests.end() ); - while( aIter != aEnd ) + for( const auto& rViewUpdateRequest : mpImpl->maViewUpdateRequests ) { // TODO(P1): this is O(n^2) in the number of views, if // lots of views notify updates. @@ -159,15 +157,13 @@ namespace internal UnoViewVector::const_iterator aFoundView; if( (aFoundView=std::find(mpImpl->mrViewContainer.begin(), aEndOfViews, - aIter->first)) != aEndOfViews ) + rViewUpdateRequest.first)) != aEndOfViews ) { - if( aIter->second ) + if( rViewUpdateRequest.second ) (*aFoundView)->paintScreen(); // force-paint else (*aFoundView)->updateScreen(); // update changes only } - - ++aIter; } } @@ -195,9 +191,8 @@ namespace internal // TODO(F2): This will interfere with other updates, since it // happens out-of-sync with main animation loop. Might cause // artifacts. - std::for_each( mpImpl->mrViewContainer.begin(), - mpImpl->mrViewContainer.end(), - boost::mem_fn(&View::updateScreen) ); + for( auto const& pView : mpImpl->mrViewContainer ) + pView->updateScreen(); } void ScreenUpdater::lockUpdates() diff --git a/slideshow/source/engine/shapes/appletshape.cxx b/slideshow/source/engine/shapes/appletshape.cxx index e00244131343..cd7f14b2ce6e 100644 --- a/slideshow/source/engine/shapes/appletshape.cxx +++ b/slideshow/source/engine/shapes/appletshape.cxx @@ -28,7 +28,6 @@ #include "viewappletshape.hxx" #include "tools.hxx" -#include #include @@ -128,15 +127,12 @@ namespace slideshow void AppletShape::implViewChanged( const UnoViewSharedPtr& rView ) { + const ::basegfx::B2DRectangle& rBounds = getBounds(); // determine ViewAppletShape that needs update - ViewAppletShapeVector::const_iterator aIter(maViewAppletShapes.begin()); - ViewAppletShapeVector::const_iterator const aEnd (maViewAppletShapes.end()); - while( aIter != aEnd ) + for( const auto& pViewAppletShape : maViewAppletShapes ) { - if( (*aIter)->getViewLayer()->isOnView(rView) ) - (*aIter)->resize(getBounds()); - - ++aIter; + if( pViewAppletShape->getViewLayer()->isOnView( rView ) ) + pViewAppletShape->resize( rBounds ); } } @@ -145,12 +141,9 @@ namespace slideshow void AppletShape::implViewsChanged() { // resize all ViewShapes - ::std::for_each( maViewAppletShapes.begin(), - maViewAppletShapes.end(), - ::boost::bind( - &ViewAppletShape::resize, - _1, - AppletShape::getBounds()) ); + const ::basegfx::B2DRectangle& rBounds = getBounds(); + for( const auto& pViewAppletShape : maViewAppletShapes ) + pViewAppletShape->resize( rBounds ); } @@ -190,21 +183,18 @@ namespace slideshow OSL_ENSURE( ::std::count_if(maViewAppletShapes.begin(), aEnd, - ::boost::bind( - ::std::equal_to< ViewLayerSharedPtr >(), - ::boost::bind( &ViewAppletShape::getViewLayer, _1 ), - ::boost::cref( rLayer ) ) ) < 2, + [&rLayer] + ( const ViewAppletShapeSharedPtr& pShape ) + { return rLayer == pShape->getViewLayer(); } ) < 2, "AppletShape::removeViewLayer(): Duplicate ViewLayer entries!" ); ViewAppletShapeVector::iterator aIter; if( (aIter=::std::remove_if( maViewAppletShapes.begin(), aEnd, - ::boost::bind( - ::std::equal_to< ViewLayerSharedPtr >(), - ::boost::bind( &ViewAppletShape::getViewLayer, - _1 ), - ::boost::cref( rLayer ) ) )) == aEnd ) + [&rLayer] + ( const ViewAppletShapeSharedPtr& pShape ) + { return rLayer == pShape->getViewLayer(); } ) ) == aEnd ) { // view layer seemingly was not added, failed return false; @@ -231,10 +221,9 @@ namespace slideshow // redraw all view shapes, by calling their update() method if( ::std::count_if( maViewAppletShapes.begin(), maViewAppletShapes.end(), - ::boost::bind( - ::boost::mem_fn( &ViewAppletShape::render ), - _1, - ::boost::cref( rCurrBounds ) ) ) + [&rCurrBounds] + ( const ViewAppletShapeSharedPtr& pShape ) + { return pShape->render( rCurrBounds ); } ) != static_cast(maViewAppletShapes.size()) ) { // at least one of the ViewShape::update() calls did return @@ -249,11 +238,10 @@ namespace slideshow bool AppletShape::implStartIntrinsicAnimation() { - ::std::for_each( maViewAppletShapes.begin(), - maViewAppletShapes.end(), - ::boost::bind( &ViewAppletShape::startApplet, - _1, - getBounds()) ); + const ::basegfx::B2DRectangle& rBounds = getBounds(); + for( const auto& pViewAppletShape : maViewAppletShapes ) + pViewAppletShape->startApplet( rBounds ); + mbIsPlaying = true; return true; @@ -263,9 +251,8 @@ namespace slideshow bool AppletShape::implEndIntrinsicAnimation() { - ::std::for_each( maViewAppletShapes.begin(), - maViewAppletShapes.end(), - ::boost::mem_fn( &ViewAppletShape::endApplet ) ); + for( const auto& pViewAppletShape : maViewAppletShapes ) + pViewAppletShape->endApplet(); mbIsPlaying = false; diff --git a/slideshow/source/engine/shapes/drawshape.cxx b/slideshow/source/engine/shapes/drawshape.cxx index 7d1305a65a8e..36271d362b56 100644 --- a/slideshow/source/engine/shapes/drawshape.cxx +++ b/slideshow/source/engine/shapes/drawshape.cxx @@ -62,7 +62,6 @@ #include "gdimtftools.hxx" #include "drawinglayeranimation.hxx" -#include #include using namespace ::com::sun::star; @@ -166,19 +165,15 @@ namespace slideshow // redraw all view shapes, by calling their update() method ViewShape::RenderArgs renderArgs( getViewRenderArgs() ); + bool bVisible = isVisible(); if( ::std::count_if( maViewShapes.begin(), maViewShapes.end(), - ::boost::bind( - ::boost::mem_fn( &ViewShape::update ), // though _theoretically_, - // bind should eat this even - // with _1 being a shared_ptr, - // it does _not_ for MSVC without - // the extra mem_fn. WTF. - _1, - ::boost::cref( mpCurrMtf ), - ::boost::cref( renderArgs ), - nUpdateFlags, - isVisible() ) ) + [this, &bVisible, &renderArgs, &nUpdateFlags] + ( const ViewShapeSharedPtr& pShape ) + { return pShape->update( this->mpCurrMtf, + renderArgs, + nUpdateFlags, + bVisible ); } ) != static_cast(maViewShapes.size()) ) { // at least one of the ViewShape::update() calls did return @@ -319,8 +314,8 @@ namespace slideshow // restore old transformation when leaving the scope const ::comphelper::ScopeGuard aGuard( - boost::bind( &::cppcanvas::Canvas::setTransformation, - pDestinationCanvas, aOldTransform ) ); + [&pDestinationCanvas, &aOldTransform]() + { return pDestinationCanvas->setTransformation( aOldTransform ); } ); // retrieve bounds for subset of whole metafile @@ -330,15 +325,10 @@ namespace slideshow // cannot use ::boost::bind, ::basegfx::B2DRange::expand() // is overloaded. - VectorOfDocTreeNodes::const_iterator aCurr( rSubsets.begin() ); - const VectorOfDocTreeNodes::const_iterator aEnd( rSubsets.end() ); - while( aCurr != aEnd ) - { + for( const auto& rDocTreeNode : rSubsets ) aTotalBounds.expand( pRenderer->getSubsetArea( - aCurr->getStartIndex(), - aCurr->getEndIndex() ) ); - ++aCurr; - } + rDocTreeNode.getStartIndex(), + rDocTreeNode.getEndIndex() ) ); OSL_ENSURE( aTotalBounds.getMinX() >= -0.1 && aTotalBounds.getMinY() >= -0.1 && @@ -632,11 +622,9 @@ namespace slideshow // already added? if( ::std::any_of( maViewShapes.begin(), maViewShapes.end(), - ::boost::bind( - ::std::equal_to< ViewLayerSharedPtr >(), - ::boost::bind( &ViewShape::getViewLayer, - _1 ), - ::boost::cref( rNewLayer ) ) )) + [&rNewLayer] + ( const ViewShapeSharedPtr& pShape ) + { return rNewLayer == pShape->getViewLayer(); } ) ) { // yes, nothing to do return; @@ -669,22 +657,18 @@ namespace slideshow OSL_ENSURE( ::std::count_if(maViewShapes.begin(), aEnd, - ::boost::bind( - ::std::equal_to< ViewLayerSharedPtr >(), - ::boost::bind( &ViewShape::getViewLayer, - _1 ), - ::boost::cref( rLayer ) ) ) < 2, + [&rLayer] + ( const ViewShapeSharedPtr& pShape ) + { return rLayer == pShape->getViewLayer(); } ) < 2, "DrawShape::removeViewLayer(): Duplicate ViewLayer entries!" ); ViewShapeVector::iterator aIter; if( (aIter=::std::remove_if( maViewShapes.begin(), aEnd, - ::boost::bind( - ::std::equal_to< ViewLayerSharedPtr >(), - ::boost::bind( &ViewShape::getViewLayer, - _1 ), - ::boost::cref( rLayer ) ) )) == aEnd ) + [&rLayer] + ( const ViewShapeSharedPtr& pShape ) + { return rLayer == pShape->getViewLayer(); } ) ) == aEnd ) { // view layer seemingly was not added, failed return false; @@ -745,41 +729,6 @@ namespace slideshow return maBounds; } - namespace - { - /** Functor expanding AA border for each passed ViewShape - - Could not use ::boost::bind here, since - B2DRange::expand is overloaded (which yields one or - the other template type deduction ambiguous) - */ - class Expander - { - public: - explicit Expander( ::basegfx::B2DSize& rBounds ) : - mrBounds( rBounds ) - { - } - - void operator()( const ViewShapeSharedPtr& rShape ) const - { - const ::basegfx::B2DSize& rShapeBorder( rShape->getAntialiasingBorder() ); - - mrBounds.setX( - ::std::max( - rShapeBorder.getX(), - mrBounds.getX() ) ); - mrBounds.setY( - ::std::max( - rShapeBorder.getY(), - mrBounds.getY() ) ); - } - - private: - ::basegfx::B2DSize& mrBounds; - }; - } - ::basegfx::B2DRectangle DrawShape::getUpdateArea() const { ::basegfx::B2DRectangle aBounds; @@ -823,9 +772,17 @@ namespace slideshow // for every view, get AA border and 'expand' aAABorder // appropriately. - ::std::for_each( maViewShapes.begin(), - maViewShapes.end(), - Expander( aAABorder ) ); + for( const auto& rViewShape : maViewShapes ) + { + const ::basegfx::B2DSize rShapeBorder( rViewShape->getAntialiasingBorder() ); + + aAABorder.setX( ::std::max( + rShapeBorder.getX(), + aAABorder.getX() ) ); + aAABorder.setY( ::std::max( + rShapeBorder.getY(), + aAABorder.getY() ) ); + } // add calculated AA border to aBounds aBounds = ::basegfx::B2DRectangle( aBounds.getMinX() - aAABorder.getX(), @@ -996,10 +953,11 @@ namespace slideshow basegfx::B2DHomMatrix aTransform; pCanvas->setTransformation( aTransform /* empty */ ); + + ::cppcanvas::Canvas* pTmpCanvas = pCanvas.get(); comphelper::ScopeGuard const resetOldTransformation( - boost::bind( &cppcanvas::Canvas::setTransformation, - pCanvas.get(), - boost::cref(aOldTransform) )); + [&aOldTransform, &pTmpCanvas]() + { return pTmpCanvas->setTransformation( aOldTransform ); } ); aTransform.scale( maBounds.getWidth(), maBounds.getHeight() ); @@ -1022,19 +980,20 @@ namespace slideshow // slide-absolute position HyperlinkRegions aTranslatedRegions; + + // increase capacity to same size as the container for + // shape-relative hyperlink regions to avoid reallocation + aTranslatedRegions.reserve( maHyperlinkRegions.size() ); const basegfx::B2DPoint& rOffset(getBounds().getMinimum()); - HyperlinkRegions::const_iterator aIter( maHyperlinkRegions.begin() ); - HyperlinkRegions::const_iterator const aEnd ( maHyperlinkRegions.end() ); - while( aIter != aEnd ) + for( const auto& cp : maHyperlinkRegions ) { - basegfx::B2DRange const& relRegion( aIter->first ); + basegfx::B2DRange const& relRegion( cp.first ); aTranslatedRegions.push_back( std::make_pair( basegfx::B2DRange( relRegion.getMinimum() + rOffset, relRegion.getMaximum() + rOffset), - aIter->second) ); - ++aIter; + cp.second) ); } return aTranslatedRegions; @@ -1058,9 +1017,8 @@ namespace slideshow { // notify all ViewShapes, by calling their enterAnimationMode method. // We're now entering animation mode - ::std::for_each( maViewShapes.begin(), - maViewShapes.end(), - ::boost::mem_fn( &ViewShape::enterAnimationMode ) ); + for( const auto& rViewShape : maViewShapes ) + rViewShape->enterAnimationMode(); } ++mnIsAnimatedCount; @@ -1077,9 +1035,8 @@ namespace slideshow { // notify all ViewShapes, by calling their leaveAnimationMode method. // we're now leaving animation mode - ::std::for_each( maViewShapes.begin(), - maViewShapes.end(), - ::boost::mem_fn( &ViewShape::leaveAnimationMode ) ); + for( const auto& rViewShape : maViewShapes ) + rViewShape->leaveAnimationMode(); } } diff --git a/slideshow/source/engine/shapes/drawshapesubsetting.cxx b/slideshow/source/engine/shapes/drawshapesubsetting.cxx index 44539094d93c..1f4c7bc8b168 100644 --- a/slideshow/source/engine/shapes/drawshapesubsetting.cxx +++ b/slideshow/source/engine/shapes/drawshapesubsetting.cxx @@ -29,8 +29,6 @@ #include "drawshapesubsetting.hxx" #include "drawshape.hxx" -#include - #include #include #include @@ -400,11 +398,8 @@ namespace slideshow // the whole shape set // determine new subset range - ::std::for_each( maSubsetShapes.begin(), - maSubsetShapes.end(), - ::boost::bind(&DrawShapeSubsetting::updateSubsetBounds, - this, - _1 ) ); + for( const auto& pShape : maSubsetShapes ) + updateSubsetBounds( pShape ); updateSubsets(); diff --git a/slideshow/source/engine/shapes/mediashape.cxx b/slideshow/source/engine/shapes/mediashape.cxx index df5e918e882f..fe7165ae97a5 100644 --- a/slideshow/source/engine/shapes/mediashape.cxx +++ b/slideshow/source/engine/shapes/mediashape.cxx @@ -29,7 +29,6 @@ #include "shape.hxx" #include "tools.hxx" -#include #include @@ -105,29 +104,21 @@ namespace slideshow void MediaShape::implViewChanged( const UnoViewSharedPtr& rView ) { + const ::basegfx::B2DRectangle& rBounds = getBounds(); // determine ViewMediaShape that needs update - ViewMediaShapeVector::const_iterator aIter(maViewMediaShapes.begin()); - ViewMediaShapeVector::const_iterator const aEnd (maViewMediaShapes.end()); - while( aIter != aEnd ) - { - if( (*aIter)->getViewLayer()->isOnView(rView) ) - (*aIter)->resize(getBounds()); - - ++aIter; - } + for( const auto& pViewMediaShape : maViewMediaShapes ) + if( pViewMediaShape->getViewLayer()->isOnView( rView ) ) + pViewMediaShape->resize( rBounds ); } void MediaShape::implViewsChanged() { + const ::basegfx::B2DRectangle& rBounds = getBounds(); // resize all ViewShapes - ::std::for_each( maViewMediaShapes.begin(), - maViewMediaShapes.end(), - ::boost::bind( - &ViewMediaShape::resize, - _1, - getBounds()) ); + for( const auto& pViewMediaShape : maViewMediaShapes ) + pViewMediaShape->resize( rBounds ); } @@ -156,21 +147,18 @@ namespace slideshow OSL_ENSURE( ::std::count_if(maViewMediaShapes.begin(), aEnd, - ::boost::bind( - ::std::equal_to< ViewLayerSharedPtr >(), - ::boost::bind( &ViewMediaShape::getViewLayer, _1 ), - ::boost::cref( rLayer ) ) ) < 2, + [&rLayer] + ( const ViewMediaShapeSharedPtr& pShape ) + { return rLayer == pShape->getViewLayer(); } ) < 2, "MediaShape::removeViewLayer(): Duplicate ViewLayer entries!" ); ViewMediaShapeVector::iterator aIter; if( (aIter=::std::remove_if( maViewMediaShapes.begin(), aEnd, - ::boost::bind( - ::std::equal_to< ViewLayerSharedPtr >(), - ::boost::bind( &ViewMediaShape::getViewLayer, - _1 ), - ::boost::cref( rLayer ) ) )) == aEnd ) + [&rLayer] + ( const ViewMediaShapeSharedPtr& pShape ) + { return rLayer == pShape->getViewLayer(); } ) ) == aEnd ) { // view layer seemingly was not added, failed return false; @@ -197,10 +185,9 @@ namespace slideshow // redraw all view shapes, by calling their update() method if( ::std::count_if( maViewMediaShapes.begin(), maViewMediaShapes.end(), - ::boost::bind( - ::boost::mem_fn( &ViewMediaShape::render ), - _1, - ::boost::cref( rCurrBounds ) ) ) + [&rCurrBounds] + ( const ViewMediaShapeSharedPtr& pShape ) + { return pShape->render( rCurrBounds ); } ) != static_cast(maViewMediaShapes.size()) ) { // at least one of the ViewShape::update() calls did return @@ -215,9 +202,8 @@ namespace slideshow bool MediaShape::implStartIntrinsicAnimation() { - ::std::for_each( maViewMediaShapes.begin(), - maViewMediaShapes.end(), - ::boost::mem_fn( &ViewMediaShape::startMedia ) ); + for( const auto& pViewMediaShape : maViewMediaShapes ) + pViewMediaShape->startMedia(); mbIsPlaying = true; @@ -228,9 +214,8 @@ namespace slideshow bool MediaShape::implEndIntrinsicAnimation() { - ::std::for_each( maViewMediaShapes.begin(), - maViewMediaShapes.end(), - ::boost::mem_fn( &ViewMediaShape::endMedia ) ); + for( const auto& pViewMediaShape : maViewMediaShapes ) + pViewMediaShape->endMedia(); mbIsPlaying = false; @@ -241,9 +226,8 @@ namespace slideshow bool MediaShape::implPauseIntrinsicAnimation() { - ::std::for_each( maViewMediaShapes.begin(), - maViewMediaShapes.end(), - ::boost::mem_fn( &ViewMediaShape::pauseMedia ) ); + for( const auto& pViewMediaShape : maViewMediaShapes ) + pViewMediaShape->pauseMedia(); mbIsPlaying = false; @@ -261,10 +245,8 @@ namespace slideshow void MediaShape::implSetIntrinsicAnimationTime(double fTime) { - ::std::for_each( maViewMediaShapes.begin(), - maViewMediaShapes.end(), - ::boost::bind( &ViewMediaShape::setMediaTime, - _1, boost::cref(fTime)) ); + for( const auto& pViewMediaShape : maViewMediaShapes ) + pViewMediaShape->setMediaTime( fTime ); } -- cgit