summaryrefslogtreecommitdiff
path: root/slideshow
diff options
context:
space:
mode:
authorDaniel Robertson <danlrobertson89@gmail.com>2015-10-08 14:48:15 -0400
committerNoel Grandin <noelgrandin@gmail.com>2015-10-09 07:09:22 +0000
commit6e8f1a3bd1c9110fe0a1b7978991800377e2908e (patch)
tree59b35d7005763f9afdc46cc3ab0c90de404b0183 /slideshow
parentf0e3fe840b6f103c589f044bbde18b2faa345279 (diff)
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. Change-Id: I5798293cdd0d784cc4c95c67e3fc6a0b930db8bb Reviewed-on: https://gerrit.libreoffice.org/19261 Reviewed-by: Noel Grandin <noelgrandin@gmail.com> Tested-by: Noel Grandin <noelgrandin@gmail.com>
Diffstat (limited to 'slideshow')
-rw-r--r--slideshow/source/engine/slide/layer.cxx64
-rw-r--r--slideshow/source/engine/slide/layermanager.cxx56
-rw-r--r--slideshow/source/engine/slide/shapemanagerimpl.cxx12
-rw-r--r--slideshow/source/engine/slide/slideimpl.cxx64
-rw-r--r--slideshow/source/engine/slide/userpaintoverlay.cxx9
-rw-r--r--slideshow/source/engine/slideshowimpl.cxx21
-rw-r--r--slideshow/source/engine/transitions/slidechangebase.cxx7
-rw-r--r--slideshow/source/engine/transitions/slidetransitionfactory.cxx7
-rw-r--r--slideshow/source/engine/unoviewcontainer.cxx5
-rw-r--r--slideshow/source/engine/usereventqueue.cxx5
-rw-r--r--slideshow/source/engine/waitsymbol.cxx6
11 files changed, 82 insertions, 174 deletions
diff --git a/slideshow/source/engine/slide/layer.cxx b/slideshow/source/engine/slide/layer.cxx
index 61544aff06bb..5f6ebfadc965 100644
--- a/slideshow/source/engine/slide/layer.cxx
+++ b/slideshow/source/engine/slide/layer.cxx
@@ -129,25 +129,16 @@ namespace slideshow
{
rShape->clearAllViewLayers();
- std::for_each( maViewEntries.begin(),
- maViewEntries.end(),
- boost::bind(&Shape::addViewLayer,
- boost::cref(rShape),
- boost::bind(&ViewEntry::getViewLayer,
- _1),
- false ));
+ for( const auto& rViewEntry : maViewEntries )
+ rShape->addViewLayer( rViewEntry.getViewLayer(), false );
}
void Layer::setPriority( const ::basegfx::B1DRange& rPrioRange )
{
if( !mbBackgroundLayer )
{
- std::for_each( maViewEntries.begin(),
- maViewEntries.end(),
- boost::bind( &ViewLayer::setPriority,
- boost::bind( &ViewEntry::getViewLayer,
- _1 ),
- boost::cref(rPrioRange)));
+ for( const auto& rViewEntry : maViewEntries )
+ rViewEntry.getViewLayer()->setPriority( rPrioRange );
}
}
@@ -208,13 +199,8 @@ namespace slideshow
void Layer::clearContent()
{
// clear content on all view layers
- std::for_each( maViewEntries.begin(),
- maViewEntries.end(),
- boost::bind(
- &ViewLayer::clearAll,
- boost::bind(
- &ViewEntry::getViewLayer,
- _1)));
+ for( const auto& rViewEntry : maViewEntries )
+ rViewEntry.getViewLayer()->clearAll();
// layer content cleared, update areas are not sensible
// anymore.
@@ -250,24 +236,16 @@ namespace slideshow
// resulting clip polygon will be empty.
if( aClip.count() )
{
- // set clip to all view layers
- std::for_each( maViewEntries.begin(),
- maViewEntries.end(),
- boost::bind(
- &ViewLayer::setClip,
- boost::bind(
- &ViewEntry::getViewLayer,
- _1),
- boost::cref(aClip)));
-
- // clear update area on all view layers
- std::for_each( maViewEntries.begin(),
- maViewEntries.end(),
- boost::bind(
- &ViewLayer::clear,
- boost::bind(
- &ViewEntry::getViewLayer,
- _1)));
+ for( const auto& rViewEntry : maViewEntries )
+ {
+ ViewLayerSharedPtr pViewLayer = rViewEntry.getViewLayer();
+
+ // set clip to all view layers and
+ pViewLayer->setClip( aClip );
+
+ // clear update area on all view layers
+ pViewLayer->clear();
+ }
mbClipSet = true;
}
@@ -283,14 +261,8 @@ namespace slideshow
mbClipSet = false;
basegfx::B2DPolyPolygon aEmptyClip;
- std::for_each( maViewEntries.begin(),
- maViewEntries.end(),
- boost::bind(
- &ViewLayer::setClip,
- boost::bind(
- &ViewEntry::getViewLayer,
- _1),
- boost::cref(aEmptyClip)));
+ for( const auto& rViewEntry : maViewEntries )
+ rViewEntry.getViewLayer()->setClip( aEmptyClip );
}
clearUpdateRanges();
diff --git a/slideshow/source/engine/slide/layermanager.cxx b/slideshow/source/engine/slide/layermanager.cxx
index 3a2f07b9d5ac..aa555a84b4da 100644
--- a/slideshow/source/engine/slide/layermanager.cxx
+++ b/slideshow/source/engine/slide/layermanager.cxx
@@ -95,11 +95,8 @@ namespace slideshow
maPageBounds ));
// init views
- std::for_each( mrViews.begin(),
- mrViews.end(),
- ::boost::bind(&LayerManager::viewAdded,
- this,
- _1) );
+ for( const auto& rView : mrViews )
+ this->viewAdded( rView );
}
void LayerManager::activate( bool bSlideBackgoundPainted )
@@ -110,24 +107,19 @@ namespace slideshow
if( !bSlideBackgoundPainted )
{
- std::for_each(mrViews.begin(),
- mrViews.end(),
- boost::mem_fn(&View::clearAll));
+ for( const auto& pView : mrViews )
+ pView->clearAll();
// force update of whole slide area
- std::for_each( maLayers.begin(),
- maLayers.end(),
- boost::bind( &Layer::addUpdateRange,
- _1,
- boost::cref(maPageBounds) ));
+ for( const auto& pLayer : maLayers )
+ pLayer->addUpdateRange( maPageBounds );
}
else
{
// clear all possibly pending update areas - content
// is there, already
- std::for_each( maLayers.begin(),
- maLayers.end(),
- boost::mem_fn( &Layer::clearUpdateRanges ));
+ for( const auto& pLayer : maLayers )
+ pLayer->clearUpdateRanges();
}
updateShapeLayers( bSlideBackgoundPainted );
@@ -189,11 +181,8 @@ namespace slideshow
// in case we haven't reached all layers from the
// maAllShapes, issue addView again for good measure
- std::for_each( maLayers.begin(),
- maLayers.end(),
- boost::bind( &Layer::addView,
- _1,
- boost::cref(rView) ));
+ for( const auto& pLayer : maLayers )
+ pLayer->addView( rView );
}
void LayerManager::viewRemoved( const UnoViewSharedPtr& rView )
@@ -214,11 +203,8 @@ namespace slideshow
// in case we haven't reached all layers from the
// maAllShapes, issue removeView again for good measure
- std::for_each( maLayers.begin(),
- maLayers.end(),
- boost::bind( &Layer::removeView,
- _1,
- boost::cref(rView) ));
+ for( const auto& pLayer : maLayers )
+ pLayer->removeView( rView );
}
void LayerManager::viewChanged( const UnoViewSharedPtr& rView )
@@ -240,17 +226,14 @@ namespace slideshow
return;
// clear view area
- ::std::for_each( mrViews.begin(),
- mrViews.end(),
- ::boost::mem_fn(&View::clearAll) );
+ for( const auto& pView : mrViews )
+ pView->clearAll();
// TODO(F3): resize and repaint all layers
// render all shapes
- std::for_each( maAllShapes.begin(),
- maAllShapes.end(),
- []( const LayerShapeMap::value_type& cp )
- { cp.first->render(); } );
+ for( const auto& rShape : maAllShapes )
+ rShape.first->render();
}
void LayerManager::addShape( const ShapeSharedPtr& rShape )
@@ -744,11 +727,8 @@ namespace slideshow
// create ViewLayers for all registered views, and add to
// newly created layer.
- ::std::for_each( mrViews.begin(),
- mrViews.end(),
- boost::bind( &Layer::addView,
- boost::cref(pLayer),
- _1 ));
+ for( const auto& rView : mrViews )
+ pLayer->addView( rView );
return pLayer;
}
diff --git a/slideshow/source/engine/slide/shapemanagerimpl.cxx b/slideshow/source/engine/slide/shapemanagerimpl.cxx
index a74253f647d4..9867f09684b0 100644
--- a/slideshow/source/engine/slide/shapemanagerimpl.cxx
+++ b/slideshow/source/engine/slide/shapemanagerimpl.cxx
@@ -64,16 +64,12 @@ void ShapeManagerImpl::activate( bool bSlideBackgoundPainted )
// clone listener map
uno::Reference<presentation::XShapeEventListener> xDummyListener;
- std::for_each( mrGlobalListenersMap.begin(),
- mrGlobalListenersMap.end(),
- [&xDummyListener, this]( const ShapeEventListenerMap::value_type& cp )
- { this->listenerAdded(xDummyListener, cp.first); } );
+ for( const auto& rListener : mrGlobalListenersMap )
+ this->listenerAdded( xDummyListener, rListener.first );
// clone cursor map
- std::for_each( mrGlobalCursorMap.begin(),
- mrGlobalCursorMap.end(),
- [this]( const ShapeCursorMap::value_type& cp )
- { this->cursorChanged(cp.first, cp.second); } );
+ for( const auto& rListener : mrGlobalCursorMap )
+ this->cursorChanged( rListener.first, rListener.second );
if( mpLayerManager )
mpLayerManager->activate( bSlideBackgoundPainted );
diff --git a/slideshow/source/engine/slide/slideimpl.cxx b/slideshow/source/engine/slide/slideimpl.cxx
index 0d26285a5aec..4bb090b9e84a 100644
--- a/slideshow/source/engine/slide/slideimpl.cxx
+++ b/slideshow/source/engine/slide/slideimpl.cxx
@@ -64,7 +64,6 @@
#include <boost/bind.hpp>
#include <iterator>
-#include <algorithm>
#include <functional>
#include <iostream>
@@ -284,42 +283,30 @@ private:
-class SlideRenderer
+void slideRenderer( SlideImpl* pSlide, const UnoViewSharedPtr& rView )
{
-public:
- explicit SlideRenderer( SlideImpl& rSlide ) :
- mrSlide( rSlide )
- {
- }
-
- void operator()( const UnoViewSharedPtr& rView )
- {
- // fully clear view content to background color
- rView->clearAll();
-
- SlideBitmapSharedPtr pBitmap( mrSlide.getCurrentSlideBitmap( rView ) );
- ::cppcanvas::CanvasSharedPtr pCanvas( rView->getCanvas() );
+ // fully clear view content to background color
+ rView->clearAll();
- const ::basegfx::B2DHomMatrix aViewTransform( rView->getTransformation() );
- const ::basegfx::B2DPoint aOutPosPixel( aViewTransform * ::basegfx::B2DPoint() );
+ SlideBitmapSharedPtr pBitmap( pSlide->getCurrentSlideBitmap( rView ) );
+ ::cppcanvas::CanvasSharedPtr pCanvas( rView->getCanvas() );
- // setup a canvas with device coordinate space, the slide
- // bitmap already has the correct dimension.
- ::cppcanvas::CanvasSharedPtr pDevicePixelCanvas( pCanvas->clone() );
- pDevicePixelCanvas->setTransformation( ::basegfx::B2DHomMatrix() );
+ const ::basegfx::B2DHomMatrix aViewTransform( rView->getTransformation() );
+ const ::basegfx::B2DPoint aOutPosPixel( aViewTransform * ::basegfx::B2DPoint() );
- // render at given output position
- pBitmap->move( aOutPosPixel );
+ // setup a canvas with device coordinate space, the slide
+ // bitmap already has the correct dimension.
+ ::cppcanvas::CanvasSharedPtr pDevicePixelCanvas( pCanvas->clone() );
+ pDevicePixelCanvas->setTransformation( ::basegfx::B2DHomMatrix() );
- // clear clip (might have been changed, e.g. from comb
- // transition)
- pBitmap->clip( ::basegfx::B2DPolyPolygon() );
- pBitmap->draw( pDevicePixelCanvas );
- }
+ // render at given output position
+ pBitmap->move( aOutPosPixel );
-private:
- SlideImpl& mrSlide;
-};
+ // clear clip (might have been changed, e.g. from comb
+ // transition)
+ pBitmap->clip( ::basegfx::B2DPolyPolygon() );
+ pBitmap->draw( pDevicePixelCanvas );
+}
@@ -388,11 +375,8 @@ SlideImpl::SlideImpl( const uno::Reference< drawing::XDrawPage >& xDra
mbPaintOverlayActive( false )
{
// clone already existing views for slide bitmaps
- std::for_each( rViewContainer.begin(),
- rViewContainer.end(),
- boost::bind( &SlideImpl::viewAdded,
- this,
- _1 ));
+ for( const auto& rView : rViewContainer )
+ this->viewAdded( rView );
// register screen update (LayerManager needs to signal pending
// updates)
@@ -462,13 +446,9 @@ bool SlideImpl::show( bool bSlideBackgoundPainted )
// render slide to screen, if requested
if( !bSlideBackgoundPainted )
{
- std::for_each(maContext.mrViewContainer.begin(),
- maContext.mrViewContainer.end(),
- boost::mem_fn(&View::clearAll));
+ for( const auto& rContext : maContext.mrViewContainer )
+ slideRenderer( this, rContext );
- std::for_each( maContext.mrViewContainer.begin(),
- maContext.mrViewContainer.end(),
- SlideRenderer(*this) );
maContext.mrScreenUpdater.notifyUpdate();
}
diff --git a/slideshow/source/engine/slide/userpaintoverlay.cxx b/slideshow/source/engine/slide/userpaintoverlay.cxx
index 33899122264c..960794fbf1fa 100644
--- a/slideshow/source/engine/slide/userpaintoverlay.cxx
+++ b/slideshow/source/engine/slide/userpaintoverlay.cxx
@@ -36,7 +36,6 @@
#include "screenupdater.hxx"
#include "vieweventhandler.hxx"
-#include <boost/bind.hpp>
#include <boost/noncopyable.hpp>
#include "slide.hxx"
#include "cursormanager.hxx"
@@ -76,11 +75,9 @@ namespace slideshow
mnSize(100),
mbActive( bActive )
{
- std::for_each( rViews.begin(),
- rViews.end(),
- boost::bind( &PaintOverlayHandler::viewAdded,
- this,
- _1 ));
+ for( const auto& rView : rViews )
+ this->viewAdded( rView );
+
drawPolygons();
}
diff --git a/slideshow/source/engine/slideshowimpl.cxx b/slideshow/source/engine/slideshowimpl.cxx
index 3d127eb75b70..45befe07e8e4 100644
--- a/slideshow/source/engine/slideshowimpl.cxx
+++ b/slideshow/source/engine/slideshowimpl.cxx
@@ -1130,10 +1130,8 @@ void SlideShowImpl::displaySlide(
// push new transformation to all views, if size changed
if( !mpPreviousSlide || oldSlideSize != slideSize )
{
- std::for_each( maViewContainer.begin(),
- maViewContainer.end(),
- boost::bind( &View::setViewSize, _1,
- boost::cref(slideSize) ));
+ for( const auto& pView : maViewContainer )
+ pView->setViewSize( slideSize );
// explicitly notify view change here,
// because transformation might have changed:
@@ -1960,11 +1958,8 @@ bool SlideShowImpl::requestCursor( sal_Int16 nCursorShape )
const sal_Int16 nActualCursor = calcActiveCursor(mnCurrentCursor);
// change all views to the requested cursor ID
- std::for_each( maViewContainer.begin(),
- maViewContainer.end(),
- boost::bind( &View::setCursorShape,
- _1,
- nActualCursor ));
+ for( const auto& pView : maViewContainer )
+ pView->setCursorShape( nActualCursor );
return nActualCursor==nCursorShape;
}
@@ -1973,12 +1968,10 @@ void SlideShowImpl::resetCursor()
{
mnCurrentCursor = awt::SystemPointer::ARROW;
+ const sal_Int16 nActualCursor = calcActiveCursor( mnCurrentCursor );
// change all views to the default cursor ID
- std::for_each( maViewContainer.begin(),
- maViewContainer.end(),
- boost::bind( &View::setCursorShape,
- _1,
- calcActiveCursor(mnCurrentCursor) ));
+ for( const auto& pView : maViewContainer )
+ pView->setCursorShape( nActualCursor );
}
sal_Bool SlideShowImpl::update( double & nNextTimeout )
diff --git a/slideshow/source/engine/transitions/slidechangebase.cxx b/slideshow/source/engine/transitions/slidechangebase.cxx
index 4d77881b187c..cba1093f7360 100644
--- a/slideshow/source/engine/transitions/slidechangebase.cxx
+++ b/slideshow/source/engine/transitions/slidechangebase.cxx
@@ -180,11 +180,8 @@ void SlideChangeBase::prefetch( const AnimatableShapeSharedPtr&,
mrEventMultiplexer.addViewHandler( shared_from_this() );
// init views and create slide bitmaps
- std::for_each( mrViewContainer.begin(),
- mrViewContainer.end(),
- boost::bind( &SlideChangeBase::viewAdded,
- this,
- _1 ));
+ for( const auto& pView : mrViewContainer )
+ this->viewAdded( pView );
mbPrefetched = true;
}
diff --git a/slideshow/source/engine/transitions/slidetransitionfactory.cxx b/slideshow/source/engine/transitions/slidetransitionfactory.cxx
index fbe7001c0be4..3c894e31c1a6 100644
--- a/slideshow/source/engine/transitions/slidetransitionfactory.cxx
+++ b/slideshow/source/engine/transitions/slidetransitionfactory.cxx
@@ -45,7 +45,6 @@
#include "combtransition.hxx"
#include "tools.hxx"
-#include <boost/bind.hpp>
/***************************************************
@@ -189,10 +188,8 @@ public:
virtual bool operator()( double t ) SAL_OVERRIDE
{
- std::for_each(maTransitions.begin(),
- maTransitions.end(),
- boost::bind( &TransitionViewPair::update,
- _1, t) );
+ for( const auto& pTransition : maTransitions )
+ pTransition->update( t );
return true;
}
diff --git a/slideshow/source/engine/unoviewcontainer.cxx b/slideshow/source/engine/unoviewcontainer.cxx
index f51f104ca52e..5fc69456f097 100644
--- a/slideshow/source/engine/unoviewcontainer.cxx
+++ b/slideshow/source/engine/unoviewcontainer.cxx
@@ -106,9 +106,8 @@ namespace slideshow
void UnoViewContainer::dispose()
{
- ::std::for_each( maViews.begin(),
- maViews.end(),
- ::boost::mem_fn(&UnoView::_dispose) );
+ for( const auto& pView : maViews )
+ pView->_dispose();
maViews.clear();
}
}
diff --git a/slideshow/source/engine/usereventqueue.cxx b/slideshow/source/engine/usereventqueue.cxx
index 53f043ab03ef..6eb579c77017 100644
--- a/slideshow/source/engine/usereventqueue.cxx
+++ b/slideshow/source/engine/usereventqueue.cxx
@@ -143,9 +143,8 @@ public:
bRet = !rVec.empty();
// registered node found -> fire all events in the vector
- std::for_each( rVec.begin(), rVec.end(),
- boost::bind( &EventQueue::addEvent,
- boost::ref( mrEventQueue ), _1 ) );
+ for( const auto& pEvent : rVec )
+ mrEventQueue.addEvent( pEvent );
rVec.clear();
}
diff --git a/slideshow/source/engine/waitsymbol.cxx b/slideshow/source/engine/waitsymbol.cxx
index 48da4c702c9c..ab3dbbf29eb7 100644
--- a/slideshow/source/engine/waitsymbol.cxx
+++ b/slideshow/source/engine/waitsymbol.cxx
@@ -67,10 +67,8 @@ WaitSymbol::WaitSymbol( uno::Reference<rendering::XBitmap> const & xBitmap,
mrScreenUpdater( rScreenUpdater ),
mbVisible(false)
{
- std::for_each( rViewContainer.begin(),
- rViewContainer.end(),
- [this]( const UnoViewSharedPtr& sp )
- { this->viewAdded(sp); } );
+ for( const auto& pView : rViewContainer )
+ this->viewAdded( pView );
}
void WaitSymbol::setVisible( const bool bVisible )