Kaydet (Commit) 6e8f1a3b authored tarafından Daniel Robertson's avatar Daniel Robertson Kaydeden (comit) Noel Grandin

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/19261Reviewed-by: 's avatarNoel Grandin <noelgrandin@gmail.com>
Tested-by: 's avatarNoel Grandin <noelgrandin@gmail.com>
üst f0e3fe84
......@@ -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();
......
......@@ -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;
}
......
......@@ -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 );
......
......@@ -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();
}
......
......@@ -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();
}
......
......@@ -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 )
......
......@@ -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;
}
......
......@@ -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;
}
......
......@@ -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();
}
}
......
......@@ -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();
}
......
......@@ -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 )
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment