diff options
author | Jan Holesovsky <kendy@collabora.com> | 2015-10-08 15:35:06 +0200 |
---|---|---|
committer | Jan Holesovsky <kendy@collabora.com> | 2015-10-08 15:35:47 +0200 |
commit | 862bd364390a05ad0b07f9280fb9a0f8b2cc4ed6 (patch) | |
tree | b2e86b04abc1cb675eb17ff09bbfbf8a453bb3a8 /slideshow/source/engine/slide | |
parent | bd0e0dc7bdf0b4e027a93ff0db330472e0b90897 (diff) |
tdf#94222: Revert "slideshow: replace for_each with range-based loop"
This reverts commit ead5bc3cfb07a4e96e367e7904dc674ee5f5ccd6.
Change-Id: Icc2778cf904a71c4deaff4575d0de231acfc1335
Diffstat (limited to 'slideshow/source/engine/slide')
-rw-r--r-- | slideshow/source/engine/slide/layer.cxx | 92 | ||||
-rw-r--r-- | slideshow/source/engine/slide/layermanager.cxx | 102 | ||||
-rw-r--r-- | slideshow/source/engine/slide/shapemanagerimpl.cxx | 12 | ||||
-rw-r--r-- | slideshow/source/engine/slide/slideimpl.cxx | 81 | ||||
-rw-r--r-- | slideshow/source/engine/slide/targetpropertiescreator.cxx | 16 | ||||
-rw-r--r-- | slideshow/source/engine/slide/userpaintoverlay.cxx | 9 |
6 files changed, 214 insertions, 98 deletions
diff --git a/slideshow/source/engine/slide/layer.cxx b/slideshow/source/engine/slide/layer.cxx index b51fcf3f3203..61544aff06bb 100644 --- a/slideshow/source/engine/slide/layer.cxx +++ b/slideshow/source/engine/slide/layer.cxx @@ -29,6 +29,9 @@ #include "layer.hxx" +#include <boost/bind.hpp> + + using namespace ::com::sun::star; namespace slideshow @@ -66,8 +69,10 @@ namespace slideshow const ViewEntryVector::iterator aEnd( maViewEntries.end() ); if( (aIter=std::find_if( maViewEntries.begin(), aEnd, - [&rNewView]( const ViewEntry& rViewEntry ) - { return rNewView == rViewEntry.getView(); } ) ) != aEnd ) + boost::bind<bool>( + std::equal_to< ViewSharedPtr >(), + boost::bind( &ViewEntry::getView, _1 ), + boost::cref( rNewView )))) != aEnd ) { // already added - just return existing layer return aIter->mpViewLayer; @@ -97,8 +102,10 @@ namespace slideshow const ViewEntryVector::iterator aEnd( maViewEntries.end() ); if( (aIter=std::find_if( maViewEntries.begin(), aEnd, - [&rView]( const ViewEntry& rViewEntry ) - { return rView == rViewEntry.getView(); } ) ) == aEnd ) + boost::bind<bool>( + std::equal_to< ViewSharedPtr >(), + boost::bind( &ViewEntry::getView, _1 ), + boost::cref( rView )))) == aEnd ) { // View was not added/is already removed return ViewLayerSharedPtr(); @@ -106,8 +113,10 @@ namespace slideshow OSL_ENSURE( std::count_if( maViewEntries.begin(), aEnd, - [&rView]( const ViewEntry& rViewEntry ) - { return rView == rViewEntry.getView(); } ) == 1, + boost::bind<bool>( + std::equal_to< ViewSharedPtr >(), + boost::bind( &ViewEntry::getView, _1 ), + boost::cref( rView ))) == 1, "Layer::removeView(): view added multiple times" ); ViewLayerSharedPtr pRet( aIter->mpViewLayer ); @@ -120,16 +129,25 @@ namespace slideshow { rShape->clearAllViewLayers(); - for( const auto& rViewEntry : maViewEntries ) - rShape->addViewLayer( rViewEntry.getViewLayer(), false ); + std::for_each( maViewEntries.begin(), + maViewEntries.end(), + boost::bind(&Shape::addViewLayer, + boost::cref(rShape), + boost::bind(&ViewEntry::getViewLayer, + _1), + false )); } void Layer::setPriority( const ::basegfx::B1DRange& rPrioRange ) { if( !mbBackgroundLayer ) { - for( const auto& rViewEntry : maViewEntries ) - rViewEntry.getViewLayer()->setPriority( rPrioRange ); + std::for_each( maViewEntries.begin(), + maViewEntries.end(), + boost::bind( &ViewLayer::setPriority, + boost::bind( &ViewEntry::getViewLayer, + _1 ), + boost::cref(rPrioRange))); } } @@ -165,12 +183,12 @@ namespace slideshow return false; maBounds = maNewBounds; - if( std::count_if( maViewEntries.begin(), maViewEntries.end(), - [this](const ViewEntry& rViewEntry) - { return rViewEntry.getViewLayer()->resize( this->maBounds ); } - ) == 0 ) + boost::bind( &ViewLayer::resize, + boost::bind( &ViewEntry::getViewLayer, + _1 ), + boost::cref(maBounds)) ) == 0 ) { return false; } @@ -190,8 +208,13 @@ namespace slideshow void Layer::clearContent() { // clear content on all view layers - for( const auto& rViewEntry : maViewEntries ) - rViewEntry.getViewLayer()->clearAll(); + std::for_each( maViewEntries.begin(), + maViewEntries.end(), + boost::bind( + &ViewLayer::clearAll, + boost::bind( + &ViewEntry::getViewLayer, + _1))); // layer content cleared, update areas are not sensible // anymore. @@ -227,15 +250,24 @@ namespace slideshow // resulting clip polygon will be empty. if( aClip.count() ) { - for( const auto& rViewEntry : maViewEntries ) { - ViewLayerSharedPtr pViewLayer = rViewEntry.getViewLayer(); - - // set clip to all view layers - pViewLayer->setClip( aClip ); - - // clear update area of view layer - pViewLayer->clear(); - } + // 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))); mbClipSet = true; } @@ -251,8 +283,14 @@ namespace slideshow mbClipSet = false; basegfx::B2DPolyPolygon aEmptyClip; - for( const auto& rViewEntry : maViewEntries ) - rViewEntry.getViewLayer()->setClip( aEmptyClip ); + std::for_each( maViewEntries.begin(), + maViewEntries.end(), + boost::bind( + &ViewLayer::setClip, + boost::bind( + &ViewEntry::getViewLayer, + _1), + boost::cref(aEmptyClip))); } clearUpdateRanges(); diff --git a/slideshow/source/engine/slide/layermanager.cxx b/slideshow/source/engine/slide/layermanager.cxx index 2c78e7866d6c..3a2f07b9d5ac 100644 --- a/slideshow/source/engine/slide/layermanager.cxx +++ b/slideshow/source/engine/slide/layermanager.cxx @@ -53,9 +53,11 @@ namespace slideshow { LayerSharedPtr pCurrLayer; ViewLayerSharedPtr pCurrViewLayer; - for( const auto& rShape : maAllShapes ) + LayerShapeMap::const_iterator aIter( maAllShapes.begin() ); + const LayerShapeMap::const_iterator aEnd ( maAllShapes.end() ); + while( aIter != aEnd ) { - LayerSharedPtr pLayer = rShape.second.lock(); + LayerSharedPtr pLayer = aIter->second.lock(); if( pLayer && pLayer != pCurrLayer ) { pCurrLayer = pLayer; @@ -63,7 +65,9 @@ namespace slideshow } if( pCurrViewLayer ) - shapeFunc( rShape.first, pCurrViewLayer ); + shapeFunc(aIter->first,pCurrViewLayer); + + ++aIter; } } @@ -91,8 +95,11 @@ namespace slideshow maPageBounds )); // init views - for( const auto& rView : mrViews ) - this->viewAdded( rView ); + std::for_each( mrViews.begin(), + mrViews.end(), + ::boost::bind(&LayerManager::viewAdded, + this, + _1) ); } void LayerManager::activate( bool bSlideBackgoundPainted ) @@ -103,19 +110,24 @@ namespace slideshow if( !bSlideBackgoundPainted ) { - for( const auto& rView : mrViews ) - rView->clearAll(); + std::for_each(mrViews.begin(), + mrViews.end(), + boost::mem_fn(&View::clearAll)); // force update of whole slide area - for( const auto& pLayer : maLayers ) - pLayer->addUpdateRange( maPageBounds ); + std::for_each( maLayers.begin(), + maLayers.end(), + boost::bind( &Layer::addUpdateRange, + _1, + boost::cref(maPageBounds) )); } else { // clear all possibly pending update areas - content // is there, already - for( const auto& pLayer : maLayers ) - pLayer->clearUpdateRanges(); + std::for_each( maLayers.begin(), + maLayers.end(), + boost::mem_fn( &Layer::clearUpdateRanges )); } updateShapeLayers( bSlideBackgoundPainted ); @@ -177,8 +189,11 @@ namespace slideshow // in case we haven't reached all layers from the // maAllShapes, issue addView again for good measure - for( const auto& pLayer : maLayers ) - pLayer->addView( rView ); + std::for_each( maLayers.begin(), + maLayers.end(), + boost::bind( &Layer::addView, + _1, + boost::cref(rView) )); } void LayerManager::viewRemoved( const UnoViewSharedPtr& rView ) @@ -199,8 +214,11 @@ namespace slideshow // in case we haven't reached all layers from the // maAllShapes, issue removeView again for good measure - for( const auto& pLayer : maLayers ) - pLayer->removeView( rView ); + std::for_each( maLayers.begin(), + maLayers.end(), + boost::bind( &Layer::removeView, + _1, + boost::cref(rView) )); } void LayerManager::viewChanged( const UnoViewSharedPtr& rView ) @@ -222,14 +240,17 @@ namespace slideshow return; // clear view area - for( const auto& rView : mrViews ) - rView->clearAll(); + ::std::for_each( mrViews.begin(), + mrViews.end(), + ::boost::mem_fn(&View::clearAll) ); // TODO(F3): resize and repaint all layers // render all shapes - for( const auto& rShape : maAllShapes ) - rShape.first->render(); + std::for_each( maAllShapes.begin(), + maAllShapes.end(), + []( const LayerShapeMap::value_type& cp ) + { cp.first->render(); } ); } void LayerManager::addShape( const ShapeSharedPtr& rShape ) @@ -466,14 +487,16 @@ namespace slideshow // send update() calls to every shape in the // maUpdateShapes set, which is _animated_ (i.e. a // sprite). - for( const auto& pShape : maUpdateShapes ) + const ShapeUpdateSet::const_iterator aEnd=maUpdateShapes.end(); + ShapeUpdateSet::const_iterator aCurrShape=maUpdateShapes.begin(); + while( aCurrShape != aEnd ) { - if( pShape->isBackgroundDetached() ) + if( (*aCurrShape)->isBackgroundDetached() ) { // can update shape directly, without // affecting layer content (shape is // currently displayed in a sprite) - if( !pShape->update() ) + if( !(*aCurrShape)->update() ) bRet = false; // delay error exit } else @@ -486,8 +509,10 @@ namespace slideshow // cannot update shape directly, it's not // animated and update() calls will prolly // overwrite other page content. - addUpdateArea( pShape ); + addUpdateArea( *aCurrShape ); } + + ++aCurrShape; } maUpdateShapes.clear(); @@ -520,9 +545,11 @@ namespace slideshow bool bIsCurrLayerUpdating(false); Layer::EndUpdater aEndUpdater; LayerSharedPtr pCurrLayer; - for( const auto& rShape : maAllShapes ) + LayerShapeMap::const_iterator aIter( maAllShapes.begin() ); + const LayerShapeMap::const_iterator aEnd ( maAllShapes.end() ); + while( aIter != aEnd ) { - LayerSharedPtr pLayer = rShape.second.lock(); + LayerSharedPtr pLayer = aIter->second.lock(); if( pLayer != pCurrLayer ) { pCurrLayer = pLayer; @@ -533,12 +560,14 @@ namespace slideshow } if( bIsCurrLayerUpdating && - rShape.first->isBackgroundDetached() && - pCurrLayer->isInsideUpdateArea( rShape.first ) ) + !aIter->first->isBackgroundDetached() && + pCurrLayer->isInsideUpdateArea(aIter->first) ) { - if( rShape.first->render() ) + if( !aIter->first->render() ) bRet = false; } + + ++aIter; } return bRet; @@ -627,7 +656,9 @@ namespace slideshow bool bRet( true ); ViewLayerSharedPtr pTmpLayer( new DummyLayer( rTargetCanvas ) ); - for( const auto& rShape : maAllShapes ) + LayerShapeMap::const_iterator aIter( maAllShapes.begin() ); + const LayerShapeMap::const_iterator aEnd ( maAllShapes.end() ); + while( aIter != aEnd ) { try { @@ -636,11 +667,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) - rShape.first->addViewLayer( pTmpLayer, + aIter->first->addViewLayer( pTmpLayer, true ); // and remove again, this is only temporary - rShape.first->removeViewLayer( pTmpLayer ); + aIter->first->removeViewLayer( pTmpLayer ); } catch( uno::Exception& ) { @@ -653,6 +684,8 @@ namespace slideshow // at least one shape could not be rendered bRet = false; } + + ++aIter; } return bRet; @@ -711,8 +744,11 @@ namespace slideshow // create ViewLayers for all registered views, and add to // newly created layer. - for( const auto& rView : mrViews ) - pLayer->addView( rView ); + ::std::for_each( mrViews.begin(), + mrViews.end(), + boost::bind( &Layer::addView, + boost::cref(pLayer), + _1 )); return pLayer; } diff --git a/slideshow/source/engine/slide/shapemanagerimpl.cxx b/slideshow/source/engine/slide/shapemanagerimpl.cxx index 9867f09684b0..a74253f647d4 100644 --- a/slideshow/source/engine/slide/shapemanagerimpl.cxx +++ b/slideshow/source/engine/slide/shapemanagerimpl.cxx @@ -64,12 +64,16 @@ void ShapeManagerImpl::activate( bool bSlideBackgoundPainted ) // clone listener map uno::Reference<presentation::XShapeEventListener> xDummyListener; - for( const auto& rListener : mrGlobalListenersMap ) - this->listenerAdded( xDummyListener, rListener.first ); + std::for_each( mrGlobalListenersMap.begin(), + mrGlobalListenersMap.end(), + [&xDummyListener, this]( const ShapeEventListenerMap::value_type& cp ) + { this->listenerAdded(xDummyListener, cp.first); } ); // clone cursor map - for( const auto& rListener : mrGlobalCursorMap ) - this->cursorChanged( rListener.first, rListener.second ); + std::for_each( mrGlobalCursorMap.begin(), + mrGlobalCursorMap.end(), + [this]( const ShapeCursorMap::value_type& cp ) + { this->cursorChanged(cp.first, cp.second); } ); if( mpLayerManager ) mpLayerManager->activate( bSlideBackgoundPainted ); diff --git a/slideshow/source/engine/slide/slideimpl.cxx b/slideshow/source/engine/slide/slideimpl.cxx index 9a6e83c06dbf..0d26285a5aec 100644 --- a/slideshow/source/engine/slide/slideimpl.cxx +++ b/slideshow/source/engine/slide/slideimpl.cxx @@ -61,6 +61,8 @@ #include "targetpropertiescreator.hxx" #include "tools.hxx" + +#include <boost/bind.hpp> #include <iterator> #include <algorithm> #include <functional> @@ -280,6 +282,49 @@ private: + + +class SlideRenderer +{ +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() ); + + const ::basegfx::B2DHomMatrix aViewTransform( rView->getTransformation() ); + const ::basegfx::B2DPoint aOutPosPixel( aViewTransform * ::basegfx::B2DPoint() ); + + // setup a canvas with device coordinate space, the slide + // bitmap already has the correct dimension. + ::cppcanvas::CanvasSharedPtr pDevicePixelCanvas( pCanvas->clone() ); + pDevicePixelCanvas->setTransformation( ::basegfx::B2DHomMatrix() ); + + // render at given output position + pBitmap->move( aOutPosPixel ); + + // clear clip (might have been changed, e.g. from comb + // transition) + pBitmap->clip( ::basegfx::B2DPolyPolygon() ); + pBitmap->draw( pDevicePixelCanvas ); + } + +private: + SlideImpl& mrSlide; +}; + + + + + SlideImpl::SlideImpl( const uno::Reference< drawing::XDrawPage >& xDrawPage, const uno::Reference<drawing::XDrawPagesSupplier>& xDrawPages, const uno::Reference< animations::XAnimationNode >& xRootNode, @@ -343,8 +388,11 @@ SlideImpl::SlideImpl( const uno::Reference< drawing::XDrawPage >& xDra mbPaintOverlayActive( false ) { // clone already existing views for slide bitmaps - for( const auto& rView : rViewContainer ) - this->viewAdded( rView ); + std::for_each( rViewContainer.begin(), + rViewContainer.end(), + boost::bind( &SlideImpl::viewAdded, + this, + _1 )); // register screen update (LayerManager needs to signal pending // updates) @@ -414,30 +462,13 @@ bool SlideImpl::show( bool bSlideBackgoundPainted ) // render slide to screen, if requested if( !bSlideBackgoundPainted ) { - for( const auto& rView : maContext.mrViewContainer ) { - // fully clear view content to background color - rView->clearAll(); - - SlideBitmapSharedPtr pBitmap( this->getCurrentSlideBitmap( rView ) ); - ::cppcanvas::CanvasSharedPtr pCanvas( rView->getCanvas() ); - - const ::basegfx::B2DHomMatrix aViewTransform( rView->getTransformation() ); - const ::basegfx::B2DPoint aOutPosPixel( aViewTransform * ::basegfx::B2DPoint() ); - - // setup a canvas with device coordinate space, the slide - // bitmap already has the correct dimension. - ::cppcanvas::CanvasSharedPtr pDevicePixelCanvas( pCanvas->clone() ); - pDevicePixelCanvas->setTransformation( ::basegfx::B2DHomMatrix() ); - - // render at given output position - pBitmap->move( aOutPosPixel ); - - // clear clip (might have been changed, e.g. from comb - // transition) - pBitmap->clip( ::basegfx::B2DPolyPolygon() ); - pBitmap->draw( pDevicePixelCanvas ); - } + std::for_each(maContext.mrViewContainer.begin(), + maContext.mrViewContainer.end(), + boost::mem_fn(&View::clearAll)); + std::for_each( maContext.mrViewContainer.begin(), + maContext.mrViewContainer.end(), + SlideRenderer(*this) ); maContext.mrScreenUpdater.notifyUpdate(); } diff --git a/slideshow/source/engine/slide/targetpropertiescreator.cxx b/slideshow/source/engine/slide/targetpropertiescreator.cxx index 2eafaf15235f..d1877c6c222d 100644 --- a/slideshow/source/engine/slide/targetpropertiescreator.cxx +++ b/slideshow/source/engine/slide/targetpropertiescreator.cxx @@ -332,23 +332,27 @@ namespace internal uno::Sequence< animations::TargetProperties > aRes( aShapeHash.size() ); ::std::size_t nCurrIndex(0); - for( const auto& rShapeHash : aShapeHash ) + XShapeHash::const_iterator aCurr( aShapeHash.begin() ); + const XShapeHash::const_iterator aEnd ( aShapeHash.end() ); + while( aCurr != aEnd ) { animations::TargetProperties& rCurrProps( aRes[ nCurrIndex++ ] ); - if( rShapeHash.first.mnParagraphIndex == -1 ) + if( aCurr->first.mnParagraphIndex == -1 ) { - rCurrProps.Target = uno::makeAny( rShapeHash.first.mxRef ); + rCurrProps.Target = uno::makeAny( aCurr->first.mxRef ); } else { rCurrProps.Target = uno::makeAny( presentation::ParagraphTarget( - rShapeHash.first.mxRef, - rShapeHash.first.mnParagraphIndex ) ); + aCurr->first.mxRef, + aCurr->first.mnParagraphIndex ) ); } - rCurrProps.Properties = ::comphelper::containerToSequence( rShapeHash.second ); + rCurrProps.Properties = ::comphelper::containerToSequence( aCurr->second ); + + ++aCurr; } return aRes; diff --git a/slideshow/source/engine/slide/userpaintoverlay.cxx b/slideshow/source/engine/slide/userpaintoverlay.cxx index 960794fbf1fa..33899122264c 100644 --- a/slideshow/source/engine/slide/userpaintoverlay.cxx +++ b/slideshow/source/engine/slide/userpaintoverlay.cxx @@ -36,6 +36,7 @@ #include "screenupdater.hxx" #include "vieweventhandler.hxx" +#include <boost/bind.hpp> #include <boost/noncopyable.hpp> #include "slide.hxx" #include "cursormanager.hxx" @@ -75,9 +76,11 @@ namespace slideshow mnSize(100), mbActive( bActive ) { - for( const auto& rView : rViews ) - this->viewAdded( rView ); - + std::for_each( rViews.begin(), + rViews.end(), + boost::bind( &PaintOverlayHandler::viewAdded, + this, + _1 )); drawPolygons(); } |