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 ...@@ -129,25 +129,16 @@ namespace slideshow
{ {
rShape->clearAllViewLayers(); rShape->clearAllViewLayers();
std::for_each( maViewEntries.begin(), for( const auto& rViewEntry : maViewEntries )
maViewEntries.end(), rShape->addViewLayer( rViewEntry.getViewLayer(), false );
boost::bind(&Shape::addViewLayer,
boost::cref(rShape),
boost::bind(&ViewEntry::getViewLayer,
_1),
false ));
} }
void Layer::setPriority( const ::basegfx::B1DRange& rPrioRange ) void Layer::setPriority( const ::basegfx::B1DRange& rPrioRange )
{ {
if( !mbBackgroundLayer ) if( !mbBackgroundLayer )
{ {
std::for_each( maViewEntries.begin(), for( const auto& rViewEntry : maViewEntries )
maViewEntries.end(), rViewEntry.getViewLayer()->setPriority( rPrioRange );
boost::bind( &ViewLayer::setPriority,
boost::bind( &ViewEntry::getViewLayer,
_1 ),
boost::cref(rPrioRange)));
} }
} }
...@@ -208,13 +199,8 @@ namespace slideshow ...@@ -208,13 +199,8 @@ namespace slideshow
void Layer::clearContent() void Layer::clearContent()
{ {
// clear content on all view layers // clear content on all view layers
std::for_each( maViewEntries.begin(), for( const auto& rViewEntry : maViewEntries )
maViewEntries.end(), rViewEntry.getViewLayer()->clearAll();
boost::bind(
&ViewLayer::clearAll,
boost::bind(
&ViewEntry::getViewLayer,
_1)));
// layer content cleared, update areas are not sensible // layer content cleared, update areas are not sensible
// anymore. // anymore.
...@@ -250,24 +236,16 @@ namespace slideshow ...@@ -250,24 +236,16 @@ namespace slideshow
// resulting clip polygon will be empty. // resulting clip polygon will be empty.
if( aClip.count() ) if( aClip.count() )
{ {
// set clip to all view layers for( const auto& rViewEntry : maViewEntries )
std::for_each( maViewEntries.begin(), {
maViewEntries.end(), ViewLayerSharedPtr pViewLayer = rViewEntry.getViewLayer();
boost::bind(
&ViewLayer::setClip, // set clip to all view layers and
boost::bind( pViewLayer->setClip( aClip );
&ViewEntry::getViewLayer,
_1), // clear update area on all view layers
boost::cref(aClip))); pViewLayer->clear();
}
// clear update area on all view layers
std::for_each( maViewEntries.begin(),
maViewEntries.end(),
boost::bind(
&ViewLayer::clear,
boost::bind(
&ViewEntry::getViewLayer,
_1)));
mbClipSet = true; mbClipSet = true;
} }
...@@ -283,14 +261,8 @@ namespace slideshow ...@@ -283,14 +261,8 @@ namespace slideshow
mbClipSet = false; mbClipSet = false;
basegfx::B2DPolyPolygon aEmptyClip; basegfx::B2DPolyPolygon aEmptyClip;
std::for_each( maViewEntries.begin(), for( const auto& rViewEntry : maViewEntries )
maViewEntries.end(), rViewEntry.getViewLayer()->setClip( aEmptyClip );
boost::bind(
&ViewLayer::setClip,
boost::bind(
&ViewEntry::getViewLayer,
_1),
boost::cref(aEmptyClip)));
} }
clearUpdateRanges(); clearUpdateRanges();
......
...@@ -95,11 +95,8 @@ namespace slideshow ...@@ -95,11 +95,8 @@ namespace slideshow
maPageBounds )); maPageBounds ));
// init views // init views
std::for_each( mrViews.begin(), for( const auto& rView : mrViews )
mrViews.end(), this->viewAdded( rView );
::boost::bind(&LayerManager::viewAdded,
this,
_1) );
} }
void LayerManager::activate( bool bSlideBackgoundPainted ) void LayerManager::activate( bool bSlideBackgoundPainted )
...@@ -110,24 +107,19 @@ namespace slideshow ...@@ -110,24 +107,19 @@ namespace slideshow
if( !bSlideBackgoundPainted ) if( !bSlideBackgoundPainted )
{ {
std::for_each(mrViews.begin(), for( const auto& pView : mrViews )
mrViews.end(), pView->clearAll();
boost::mem_fn(&View::clearAll));
// force update of whole slide area // force update of whole slide area
std::for_each( maLayers.begin(), for( const auto& pLayer : maLayers )
maLayers.end(), pLayer->addUpdateRange( maPageBounds );
boost::bind( &Layer::addUpdateRange,
_1,
boost::cref(maPageBounds) ));
} }
else else
{ {
// clear all possibly pending update areas - content // clear all possibly pending update areas - content
// is there, already // is there, already
std::for_each( maLayers.begin(), for( const auto& pLayer : maLayers )
maLayers.end(), pLayer->clearUpdateRanges();
boost::mem_fn( &Layer::clearUpdateRanges ));
} }
updateShapeLayers( bSlideBackgoundPainted ); updateShapeLayers( bSlideBackgoundPainted );
...@@ -189,11 +181,8 @@ namespace slideshow ...@@ -189,11 +181,8 @@ namespace slideshow
// in case we haven't reached all layers from the // in case we haven't reached all layers from the
// maAllShapes, issue addView again for good measure // maAllShapes, issue addView again for good measure
std::for_each( maLayers.begin(), for( const auto& pLayer : maLayers )
maLayers.end(), pLayer->addView( rView );
boost::bind( &Layer::addView,
_1,
boost::cref(rView) ));
} }
void LayerManager::viewRemoved( const UnoViewSharedPtr& rView ) void LayerManager::viewRemoved( const UnoViewSharedPtr& rView )
...@@ -214,11 +203,8 @@ namespace slideshow ...@@ -214,11 +203,8 @@ namespace slideshow
// in case we haven't reached all layers from the // in case we haven't reached all layers from the
// maAllShapes, issue removeView again for good measure // maAllShapes, issue removeView again for good measure
std::for_each( maLayers.begin(), for( const auto& pLayer : maLayers )
maLayers.end(), pLayer->removeView( rView );
boost::bind( &Layer::removeView,
_1,
boost::cref(rView) ));
} }
void LayerManager::viewChanged( const UnoViewSharedPtr& rView ) void LayerManager::viewChanged( const UnoViewSharedPtr& rView )
...@@ -240,17 +226,14 @@ namespace slideshow ...@@ -240,17 +226,14 @@ namespace slideshow
return; return;
// clear view area // clear view area
::std::for_each( mrViews.begin(), for( const auto& pView : mrViews )
mrViews.end(), pView->clearAll();
::boost::mem_fn(&View::clearAll) );
// TODO(F3): resize and repaint all layers // TODO(F3): resize and repaint all layers
// render all shapes // render all shapes
std::for_each( maAllShapes.begin(), for( const auto& rShape : maAllShapes )
maAllShapes.end(), rShape.first->render();
[]( const LayerShapeMap::value_type& cp )
{ cp.first->render(); } );
} }
void LayerManager::addShape( const ShapeSharedPtr& rShape ) void LayerManager::addShape( const ShapeSharedPtr& rShape )
...@@ -744,11 +727,8 @@ namespace slideshow ...@@ -744,11 +727,8 @@ namespace slideshow
// create ViewLayers for all registered views, and add to // create ViewLayers for all registered views, and add to
// newly created layer. // newly created layer.
::std::for_each( mrViews.begin(), for( const auto& rView : mrViews )
mrViews.end(), pLayer->addView( rView );
boost::bind( &Layer::addView,
boost::cref(pLayer),
_1 ));
return pLayer; return pLayer;
} }
......
...@@ -64,16 +64,12 @@ void ShapeManagerImpl::activate( bool bSlideBackgoundPainted ) ...@@ -64,16 +64,12 @@ void ShapeManagerImpl::activate( bool bSlideBackgoundPainted )
// clone listener map // clone listener map
uno::Reference<presentation::XShapeEventListener> xDummyListener; uno::Reference<presentation::XShapeEventListener> xDummyListener;
std::for_each( mrGlobalListenersMap.begin(), for( const auto& rListener : mrGlobalListenersMap )
mrGlobalListenersMap.end(), this->listenerAdded( xDummyListener, rListener.first );
[&xDummyListener, this]( const ShapeEventListenerMap::value_type& cp )
{ this->listenerAdded(xDummyListener, cp.first); } );
// clone cursor map // clone cursor map
std::for_each( mrGlobalCursorMap.begin(), for( const auto& rListener : mrGlobalCursorMap )
mrGlobalCursorMap.end(), this->cursorChanged( rListener.first, rListener.second );
[this]( const ShapeCursorMap::value_type& cp )
{ this->cursorChanged(cp.first, cp.second); } );
if( mpLayerManager ) if( mpLayerManager )
mpLayerManager->activate( bSlideBackgoundPainted ); mpLayerManager->activate( bSlideBackgoundPainted );
......
...@@ -64,7 +64,6 @@ ...@@ -64,7 +64,6 @@
#include <boost/bind.hpp> #include <boost/bind.hpp>
#include <iterator> #include <iterator>
#include <algorithm>
#include <functional> #include <functional>
#include <iostream> #include <iostream>
...@@ -284,42 +283,30 @@ private: ...@@ -284,42 +283,30 @@ private:
class SlideRenderer void slideRenderer( SlideImpl* pSlide, const UnoViewSharedPtr& rView )
{ {
public: // fully clear view content to background color
explicit SlideRenderer( SlideImpl& rSlide ) : rView->clearAll();
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() );
const ::basegfx::B2DHomMatrix aViewTransform( rView->getTransformation() ); SlideBitmapSharedPtr pBitmap( pSlide->getCurrentSlideBitmap( rView ) );
const ::basegfx::B2DPoint aOutPosPixel( aViewTransform * ::basegfx::B2DPoint() ); ::cppcanvas::CanvasSharedPtr pCanvas( rView->getCanvas() );
// setup a canvas with device coordinate space, the slide const ::basegfx::B2DHomMatrix aViewTransform( rView->getTransformation() );
// bitmap already has the correct dimension. const ::basegfx::B2DPoint aOutPosPixel( aViewTransform * ::basegfx::B2DPoint() );
::cppcanvas::CanvasSharedPtr pDevicePixelCanvas( pCanvas->clone() );
pDevicePixelCanvas->setTransformation( ::basegfx::B2DHomMatrix() );
// render at given output position // setup a canvas with device coordinate space, the slide
pBitmap->move( aOutPosPixel ); // 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 // render at given output position
// transition) pBitmap->move( aOutPosPixel );
pBitmap->clip( ::basegfx::B2DPolyPolygon() );
pBitmap->draw( pDevicePixelCanvas );
}
private: // clear clip (might have been changed, e.g. from comb
SlideImpl& mrSlide; // transition)
}; pBitmap->clip( ::basegfx::B2DPolyPolygon() );
pBitmap->draw( pDevicePixelCanvas );
}
...@@ -388,11 +375,8 @@ SlideImpl::SlideImpl( const uno::Reference< drawing::XDrawPage >& xDra ...@@ -388,11 +375,8 @@ SlideImpl::SlideImpl( const uno::Reference< drawing::XDrawPage >& xDra
mbPaintOverlayActive( false ) mbPaintOverlayActive( false )
{ {
// clone already existing views for slide bitmaps // clone already existing views for slide bitmaps
std::for_each( rViewContainer.begin(), for( const auto& rView : rViewContainer )
rViewContainer.end(), this->viewAdded( rView );
boost::bind( &SlideImpl::viewAdded,
this,
_1 ));
// register screen update (LayerManager needs to signal pending // register screen update (LayerManager needs to signal pending
// updates) // updates)
...@@ -462,13 +446,9 @@ bool SlideImpl::show( bool bSlideBackgoundPainted ) ...@@ -462,13 +446,9 @@ bool SlideImpl::show( bool bSlideBackgoundPainted )
// render slide to screen, if requested // render slide to screen, if requested
if( !bSlideBackgoundPainted ) if( !bSlideBackgoundPainted )
{ {
std::for_each(maContext.mrViewContainer.begin(), for( const auto& rContext : maContext.mrViewContainer )
maContext.mrViewContainer.end(), slideRenderer( this, rContext );
boost::mem_fn(&View::clearAll));
std::for_each( maContext.mrViewContainer.begin(),
maContext.mrViewContainer.end(),
SlideRenderer(*this) );
maContext.mrScreenUpdater.notifyUpdate(); maContext.mrScreenUpdater.notifyUpdate();
} }
......
...@@ -36,7 +36,6 @@ ...@@ -36,7 +36,6 @@
#include "screenupdater.hxx" #include "screenupdater.hxx"
#include "vieweventhandler.hxx" #include "vieweventhandler.hxx"
#include <boost/bind.hpp>
#include <boost/noncopyable.hpp> #include <boost/noncopyable.hpp>
#include "slide.hxx" #include "slide.hxx"
#include "cursormanager.hxx" #include "cursormanager.hxx"
...@@ -76,11 +75,9 @@ namespace slideshow ...@@ -76,11 +75,9 @@ namespace slideshow
mnSize(100), mnSize(100),
mbActive( bActive ) mbActive( bActive )
{ {
std::for_each( rViews.begin(), for( const auto& rView : rViews )
rViews.end(), this->viewAdded( rView );
boost::bind( &PaintOverlayHandler::viewAdded,
this,
_1 ));
drawPolygons(); drawPolygons();
} }
......
...@@ -1130,10 +1130,8 @@ void SlideShowImpl::displaySlide( ...@@ -1130,10 +1130,8 @@ void SlideShowImpl::displaySlide(
// push new transformation to all views, if size changed // push new transformation to all views, if size changed
if( !mpPreviousSlide || oldSlideSize != slideSize ) if( !mpPreviousSlide || oldSlideSize != slideSize )
{ {
std::for_each( maViewContainer.begin(), for( const auto& pView : maViewContainer )
maViewContainer.end(), pView->setViewSize( slideSize );
boost::bind( &View::setViewSize, _1,
boost::cref(slideSize) ));
// explicitly notify view change here, // explicitly notify view change here,
// because transformation might have changed: // because transformation might have changed:
...@@ -1960,11 +1958,8 @@ bool SlideShowImpl::requestCursor( sal_Int16 nCursorShape ) ...@@ -1960,11 +1958,8 @@ bool SlideShowImpl::requestCursor( sal_Int16 nCursorShape )
const sal_Int16 nActualCursor = calcActiveCursor(mnCurrentCursor); const sal_Int16 nActualCursor = calcActiveCursor(mnCurrentCursor);
// change all views to the requested cursor ID // change all views to the requested cursor ID
std::for_each( maViewContainer.begin(), for( const auto& pView : maViewContainer )
maViewContainer.end(), pView->setCursorShape( nActualCursor );
boost::bind( &View::setCursorShape,
_1,
nActualCursor ));
return nActualCursor==nCursorShape; return nActualCursor==nCursorShape;
} }
...@@ -1973,12 +1968,10 @@ void SlideShowImpl::resetCursor() ...@@ -1973,12 +1968,10 @@ void SlideShowImpl::resetCursor()
{ {
mnCurrentCursor = awt::SystemPointer::ARROW; mnCurrentCursor = awt::SystemPointer::ARROW;
const sal_Int16 nActualCursor = calcActiveCursor( mnCurrentCursor );
// change all views to the default cursor ID // change all views to the default cursor ID
std::for_each( maViewContainer.begin(), for( const auto& pView : maViewContainer )
maViewContainer.end(), pView->setCursorShape( nActualCursor );
boost::bind( &View::setCursorShape,
_1,
calcActiveCursor(mnCurrentCursor) ));
} }
sal_Bool SlideShowImpl::update( double & nNextTimeout ) sal_Bool SlideShowImpl::update( double & nNextTimeout )
......
...@@ -180,11 +180,8 @@ void SlideChangeBase::prefetch( const AnimatableShapeSharedPtr&, ...@@ -180,11 +180,8 @@ void SlideChangeBase::prefetch( const AnimatableShapeSharedPtr&,
mrEventMultiplexer.addViewHandler( shared_from_this() ); mrEventMultiplexer.addViewHandler( shared_from_this() );
// init views and create slide bitmaps // init views and create slide bitmaps
std::for_each( mrViewContainer.begin(), for( const auto& pView : mrViewContainer )
mrViewContainer.end(), this->viewAdded( pView );
boost::bind( &SlideChangeBase::viewAdded,
this,
_1 ));
mbPrefetched = true; mbPrefetched = true;
} }
......
...@@ -45,7 +45,6 @@ ...@@ -45,7 +45,6 @@
#include "combtransition.hxx" #include "combtransition.hxx"
#include "tools.hxx" #include "tools.hxx"
#include <boost/bind.hpp>
/*************************************************** /***************************************************
...@@ -189,10 +188,8 @@ public: ...@@ -189,10 +188,8 @@ public:
virtual bool operator()( double t ) SAL_OVERRIDE virtual bool operator()( double t ) SAL_OVERRIDE
{ {
std::for_each(maTransitions.begin(), for( const auto& pTransition : maTransitions )
maTransitions.end(), pTransition->update( t );
boost::bind( &TransitionViewPair::update,
_1, t) );
return true; return true;
} }
......
...@@ -106,9 +106,8 @@ namespace slideshow ...@@ -106,9 +106,8 @@ namespace slideshow
void UnoViewContainer::dispose() void UnoViewContainer::dispose()
{ {
::std::for_each( maViews.begin(), for( const auto& pView : maViews )
maViews.end(), pView->_dispose();
::boost::mem_fn(&UnoView::_dispose) );
maViews.clear(); maViews.clear();
} }
} }
......
...@@ -143,9 +143,8 @@ public: ...@@ -143,9 +143,8 @@ public:
bRet = !rVec.empty(); bRet = !rVec.empty();
// registered node found -> fire all events in the vector // registered node found -> fire all events in the vector
std::for_each( rVec.begin(), rVec.end(), for( const auto& pEvent : rVec )
boost::bind( &EventQueue::addEvent, mrEventQueue.addEvent( pEvent );
boost::ref( mrEventQueue ), _1 ) );
rVec.clear(); rVec.clear();
} }
......
...@@ -67,10 +67,8 @@ WaitSymbol::WaitSymbol( uno::Reference<rendering::XBitmap> const & xBitmap, ...@@ -67,10 +67,8 @@ WaitSymbol::WaitSymbol( uno::Reference<rendering::XBitmap> const & xBitmap,
mrScreenUpdater( rScreenUpdater ), mrScreenUpdater( rScreenUpdater ),
mbVisible(false) mbVisible(false)
{ {
std::for_each( rViewContainer.begin(), for( const auto& pView : rViewContainer )
rViewContainer.end(), this->viewAdded( pView );
[this]( const UnoViewSharedPtr& sp )
{ this->viewAdded(sp); } );
} }
void WaitSymbol::setVisible( const bool bVisible ) 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