diff options
author | Arkadiy Illarionov <qarkai@gmail.com> | 2018-11-27 22:17:40 +0300 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-11-29 12:06:44 +0100 |
commit | 0ded54c33f01d18d2cd06547bd8307bd140cf28f (patch) | |
tree | e250a9a8bb89b2042d9a0bc09f80bf65757eec19 /slideshow | |
parent | 7d311ea864e7cfeb1c8f4ca417911db20d13361e (diff) |
Simplify containers iterations in slideshow, sot, starmath, stoc
Use range-based loop or replace with STL functions
Change-Id: I94792c28b283a0998bf813317e5beb37d93e0c23
Reviewed-on: https://gerrit.libreoffice.org/64125
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'slideshow')
-rw-r--r-- | slideshow/source/engine/activitiesqueue.cxx | 8 | ||||
-rw-r--r-- | slideshow/source/engine/eventqueue.cxx | 12 | ||||
-rw-r--r-- | slideshow/source/engine/slide/shapemanagerimpl.cxx | 75 | ||||
-rw-r--r-- | slideshow/source/engine/slide/slideimpl.cxx | 9 | ||||
-rw-r--r-- | slideshow/source/engine/slide/userpaintoverlay.cxx | 38 | ||||
-rw-r--r-- | slideshow/source/engine/slideshowimpl.cxx | 28 | ||||
-rw-r--r-- | slideshow/source/engine/transitions/slidetransitionfactory.cxx | 12 | ||||
-rw-r--r-- | slideshow/source/engine/usereventqueue.cxx | 29 | ||||
-rw-r--r-- | slideshow/source/inc/basecontainernode.hxx | 5 |
9 files changed, 82 insertions, 134 deletions
diff --git a/slideshow/source/engine/activitiesqueue.cxx b/slideshow/source/engine/activitiesqueue.cxx index 8eadd83428e8..484c04283236 100644 --- a/slideshow/source/engine/activitiesqueue.cxx +++ b/slideshow/source/engine/activitiesqueue.cxx @@ -81,13 +81,9 @@ namespace slideshow // accumulate time lag for all activities, and lag time // base if necessary: - ActivityQueue::const_iterator iPos( - maCurrentActivitiesWaiting.begin() ); - const ActivityQueue::const_iterator iEnd( - maCurrentActivitiesWaiting.end() ); double fLag = 0.0; - for ( ; iPos != iEnd; ++iPos ) - fLag = std::max<double>( fLag, (*iPos)->calcTimeLag() ); + for ( const auto& rxActivity : maCurrentActivitiesWaiting ) + fLag = std::max<double>( fLag, rxActivity->calcTimeLag() ); if (fLag > 0.0) { mpTimer->adjustTimer( -fLag ); diff --git a/slideshow/source/engine/eventqueue.cxx b/slideshow/source/engine/eventqueue.cxx index e1c53c4da4f6..33955faa61e4 100644 --- a/slideshow/source/engine/eventqueue.cxx +++ b/slideshow/source/engine/eventqueue.cxx @@ -59,11 +59,9 @@ namespace slideshow EventQueue::~EventQueue() { // add in all that have been added explicitly for this round: - EventEntryVector::const_iterator const iEnd( maNextEvents.end() ); - for ( EventEntryVector::const_iterator iPos( maNextEvents.begin() ); - iPos != iEnd; ++iPos ) + for ( const auto& rEvent : maNextEvents ) { - maEvents.push(*iPos); + maEvents.push(rEvent); } EventEntryVector().swap( maNextEvents ); @@ -166,10 +164,8 @@ namespace slideshow SAL_INFO("slideshow.verbose", "EventQueue: heartbeat" ); // add in all that have been added explicitly for this round: - EventEntryVector::const_iterator const iEnd( maNextEvents.end() ); - for ( EventEntryVector::const_iterator iPos( maNextEvents.begin() ); - iPos != iEnd; ++iPos ) { - maEvents.push(*iPos); + for ( const auto& rEvent : maNextEvents ) { + maEvents.push(rEvent); } EventEntryVector().swap( maNextEvents ); diff --git a/slideshow/source/engine/slide/shapemanagerimpl.cxx b/slideshow/source/engine/slide/shapemanagerimpl.cxx index 3b8f730eb2c0..e6a3bea58c1e 100644 --- a/slideshow/source/engine/slide/shapemanagerimpl.cxx +++ b/slideshow/source/engine/slide/shapemanagerimpl.cxx @@ -128,35 +128,30 @@ bool ShapeManagerImpl::handleMouseReleased( awt::MouseEvent const& e ) // find matching shape (scan reversely, to coarsely match // paint order) - ShapeToListenersMap::reverse_iterator aCurrBroadcaster( - maShapeListenerMap.rbegin() ); - ShapeToListenersMap::reverse_iterator const aEndBroadcasters( - maShapeListenerMap.rend() ); - while( aCurrBroadcaster != aEndBroadcasters ) + auto aCurrBroadcaster = std::find_if(maShapeListenerMap.rbegin(), maShapeListenerMap.rend(), + [&aPosition](const ShapeToListenersMap::value_type& rBroadcaster) { + // TODO(F2): Get proper geometry polygon from the + // shape, to avoid having areas outside the shape + // react on the mouse + return rBroadcaster.first->getBounds().isInside( aPosition ) + && rBroadcaster.first->isVisible(); + }); + if (aCurrBroadcaster != maShapeListenerMap.rend()) { - // TODO(F2): Get proper geometry polygon from the - // shape, to avoid having areas outside the shape - // react on the mouse - if( aCurrBroadcaster->first->getBounds().isInside( aPosition ) && - aCurrBroadcaster->first->isVisible() ) - { - // shape hit, and shape is visible. Raise - // event. + // shape hit, and shape is visible. Raise + // event. - std::shared_ptr<comphelper::OInterfaceContainerHelper2> const pCont( - aCurrBroadcaster->second ); - uno::Reference<drawing::XShape> const xShape( - aCurrBroadcaster->first->getXShape() ); + std::shared_ptr<comphelper::OInterfaceContainerHelper2> const pCont( + aCurrBroadcaster->second ); + uno::Reference<drawing::XShape> const xShape( + aCurrBroadcaster->first->getXShape() ); - // DON'T do anything with /this/ after this point! - pCont->forEach<presentation::XShapeEventListener>( - [&xShape, &e]( const uno::Reference< presentation::XShapeEventListener >& rListener ) - { return rListener->click( xShape, e ); } ); + // DON'T do anything with /this/ after this point! + pCont->forEach<presentation::XShapeEventListener>( + [&xShape, &e]( const uno::Reference< presentation::XShapeEventListener >& rListener ) + { return rListener->click( xShape, e ); } ); - return true; // handled this event - } - - ++aCurrBroadcaster; + return true; // handled this event } return false; // did not handle this event @@ -185,25 +180,19 @@ bool ShapeManagerImpl::handleMouseMoved( const awt::MouseEvent& e ) { // find matching shape (scan reversely, to coarsely match // paint order) - ShapeToCursorMap::reverse_iterator aCurrCursor( - maShapeCursorMap.rbegin() ); - ShapeToCursorMap::reverse_iterator const aEndCursors( - maShapeCursorMap.rend() ); - while( aCurrCursor != aEndCursors ) + auto aCurrCursor = std::find_if(maShapeCursorMap.rbegin(), maShapeCursorMap.rend(), + [&aPosition](const ShapeToCursorMap::value_type& rCursor) { + // TODO(F2): Get proper geometry polygon from the + // shape, to avoid having areas outside the shape + // react on the mouse + return rCursor.first->getBounds().isInside( aPosition ) + && rCursor.first->isVisible(); + }); + if (aCurrCursor != maShapeCursorMap.rend()) { - // TODO(F2): Get proper geometry polygon from the - // shape, to avoid having areas outside the shape - // react on the mouse - if( aCurrCursor->first->getBounds().isInside( aPosition ) && - aCurrCursor->first->isVisible() ) - { - // shape found, and it's visible. set - // requested cursor to shape's - nNewCursor = aCurrCursor->second; - break; - } - - ++aCurrCursor; + // shape found, and it's visible. set + // requested cursor to shape's + nNewCursor = aCurrCursor->second; } } diff --git a/slideshow/source/engine/slide/slideimpl.cxx b/slideshow/source/engine/slide/slideimpl.cxx index f762768b4dad..931eea2211b7 100644 --- a/slideshow/source/engine/slide/slideimpl.cxx +++ b/slideshow/source/engine/slide/slideimpl.cxx @@ -816,13 +816,8 @@ void SlideImpl::drawPolygons() const void SlideImpl::addPolygons(const PolyPolygonVector& rPolygons) { - for( PolyPolygonVector::const_iterator aIter = rPolygons.begin(), - aEnd = rPolygons.end(); - aIter!=aEnd; - ++aIter ) - { - maPolygons.push_back(*aIter); - } + for (const auto& rxPolygon : rPolygons) + maPolygons.push_back(rxPolygon); } bool SlideImpl::isPaintOverlayActive() const diff --git a/slideshow/source/engine/slide/userpaintoverlay.cxx b/slideshow/source/engine/slide/userpaintoverlay.cxx index 2f866e32ece1..9dc527a10727 100644 --- a/slideshow/source/engine/slide/userpaintoverlay.cxx +++ b/slideshow/source/engine/slide/userpaintoverlay.cxx @@ -129,18 +129,16 @@ namespace slideshow void repaintWithoutPolygons() { // must get access to the instance to erase all polygon - for( UnoViewVector::iterator aIter=maViews.begin(), aEnd=maViews.end(); - aIter!=aEnd; - ++aIter ) + for( const auto& rxView : maViews ) { // fully clear view content to background color - //(*aIter)->getCanvas()->clear(); + //rxView->getCanvas()->clear(); //get via SlideImpl instance the bitmap of the slide unmodified to redraw it - SlideBitmapSharedPtr pBitmap( mrSlide.getCurrentSlideBitmap( *aIter ) ); - ::cppcanvas::CanvasSharedPtr pCanvas( (*aIter)->getCanvas() ); + SlideBitmapSharedPtr pBitmap( mrSlide.getCurrentSlideBitmap( rxView ) ); + ::cppcanvas::CanvasSharedPtr pCanvas( rxView->getCanvas() ); - const ::basegfx::B2DHomMatrix aViewTransform( (*aIter)->getTransformation() ); + const ::basegfx::B2DHomMatrix aViewTransform( rxView->getTransformation() ); const ::basegfx::B2DPoint aOutPosPixel( aViewTransform * ::basegfx::B2DPoint() ); // setup a canvas with device coordinate space, the slide @@ -157,7 +155,7 @@ namespace slideshow pBitmap->clip( ::basegfx::B2DPolyPolygon() ); pBitmap->draw( pDevicePixelCanvas ); - mrScreenUpdater.notifyUpdate(*aIter,true); + mrScreenUpdater.notifyUpdate(rxView,true); } } @@ -213,11 +211,9 @@ namespace slideshow //Draw all registered polygons. void drawPolygons() { - for( PolyPolygonVector::iterator aIter=maPolygons.begin(), aEnd=maPolygons.end(); - aIter!=aEnd; - ++aIter ) + for( auto& rxPolygon : maPolygons ) { - (*aIter)->draw(); + rxPolygon->draw(); } // screen update necessary to show painting mrScreenUpdater.notifyUpdate(); @@ -333,16 +329,14 @@ namespace slideshow //The point is to redraw the LastPoint the way it was originally on the bitmap, //of the slide - for( UnoViewVector::iterator aIter=maViews.begin(), aEnd=maViews.end(); - aIter!=aEnd; - ++aIter ) + for (const auto& rxView : maViews) { //get via SlideImpl instance the bitmap of the slide unmodified to redraw it - SlideBitmapSharedPtr pBitmap( mrSlide.getCurrentSlideBitmap( *aIter ) ); - ::cppcanvas::CanvasSharedPtr pCanvas( (*aIter)->getCanvas() ); + SlideBitmapSharedPtr pBitmap( mrSlide.getCurrentSlideBitmap( rxView ) ); + ::cppcanvas::CanvasSharedPtr pCanvas( rxView->getCanvas() ); - ::basegfx::B2DHomMatrix aViewTransform( (*aIter)->getTransformation() ); + ::basegfx::B2DHomMatrix aViewTransform( rxView->getTransformation() ); const ::basegfx::B2DPoint aOutPosPixel( aViewTransform * ::basegfx::B2DPoint() ); // setup a canvas with device coordinate space, the slide @@ -361,7 +355,7 @@ namespace slideshow pBitmap->clip(aPolyPoly); pBitmap->draw( pDevicePixelCanvas ); - mrScreenUpdater.notifyUpdate(*aIter,true); + mrScreenUpdater.notifyUpdate(rxView,true); } } @@ -384,12 +378,10 @@ namespace slideshow aPoly.append( maLastPoint ); // paint to all views - for( UnoViewVector::iterator aIter=maViews.begin(), aEnd=maViews.end(); - aIter!=aEnd; - ++aIter ) + for (const auto& rxView : maViews) { ::cppcanvas::PolyPolygonSharedPtr pPolyPoly( - ::cppcanvas::BaseGfxFactory::createPolyPolygon( (*aIter)->getCanvas(), + ::cppcanvas::BaseGfxFactory::createPolyPolygon( rxView->getCanvas(), aPoly ) ); if( pPolyPoly ) diff --git a/slideshow/source/engine/slideshowimpl.cxx b/slideshow/source/engine/slideshowimpl.cxx index 9b7eadb65cd6..b2437e4b147d 100644 --- a/slideshow/source/engine/slideshowimpl.cxx +++ b/slideshow/source/engine/slideshowimpl.cxx @@ -870,14 +870,7 @@ ActivitySharedPtr SlideShowImpl::createSlideTransition( PolygonMap::iterator SlideShowImpl::findPolygons( uno::Reference<drawing::XDrawPage> const& xDrawPage) { // TODO(P2): optimize research in the map. - PolygonMap::iterator aEnd = maPolygons.end(); - for( PolygonMap::iterator aIter = maPolygons.begin(); - aIter != aEnd; - ++aIter ) - if( aIter->first == xDrawPage ) - return aIter; - - return aEnd; + return maPolygons.find(xDrawPage); } SlideSharedPtr SlideShowImpl::makeSlide( @@ -1769,19 +1762,14 @@ sal_Bool SlideShowImpl::setProperty( beans::PropertyValue const& rProperty ) && (aValues[1] >>= bValue)) { // Look up the view. - for (UnoViewVector::const_iterator - iView (maViewContainer.begin()), - iEnd (maViewContainer.end()); - iView!=iEnd; - ++iView) + auto iView = std::find_if(maViewContainer.begin(), maViewContainer.end(), + [&xView](const UnoViewSharedPtr& rxView) { return rxView && rxView->getUnoView() == xView; }); + if (iView != maViewContainer.end()) { - if (*iView && (*iView)->getUnoView()==xView) - { - // Store the flag at the view so that media shapes have - // access to it. - (*iView)->setIsSoundEnabled(bValue); - return true; - } + // Store the flag at the view so that media shapes have + // access to it. + (*iView)->setIsSoundEnabled(bValue); + return true; } } } diff --git a/slideshow/source/engine/transitions/slidetransitionfactory.cxx b/slideshow/source/engine/transitions/slidetransitionfactory.cxx index 75abacdbbfbf..db39e543b4a1 100644 --- a/slideshow/source/engine/transitions/slidetransitionfactory.cxx +++ b/slideshow/source/engine/transitions/slidetransitionfactory.cxx @@ -205,14 +205,12 @@ public: SAL_INFO("slideshow", "PluginSlideChange viewRemoved"); SlideChangeBase::viewRemoved( rView ); - for( auto aIter = maTransitions.begin(); aIter != maTransitions.end(); ++aIter ) + auto aIter = std::find_if(maTransitions.begin(), maTransitions.end(), + [&rView](const std::unique_ptr<TransitionViewPair>& rxTransition) { return rxTransition->mpView == rView; }); + if (aIter != maTransitions.end()) { - if( ( *aIter )->mpView == rView ) - { - SAL_INFO("slideshow", "view removed" ); - maTransitions.erase( aIter ); - break; - } + SAL_INFO("slideshow", "view removed" ); + maTransitions.erase( aIter ); } } diff --git a/slideshow/source/engine/usereventqueue.cxx b/slideshow/source/engine/usereventqueue.cxx index 6ae688351a48..9c976717b510 100644 --- a/slideshow/source/engine/usereventqueue.cxx +++ b/slideshow/source/engine/usereventqueue.cxx @@ -314,23 +314,20 @@ protected: // find matching shape (scan reversely, to coarsely match // paint order) - ImpShapeEventMap::reverse_iterator aCurrShape(maShapeEventMap.rbegin()); - const ImpShapeEventMap::reverse_iterator aEndShape( maShapeEventMap.rend() ); - while( aCurrShape != aEndShape ) + auto aCurrShape = std::find_if(maShapeEventMap.rbegin(), maShapeEventMap.rend(), + [&aPosition](const ImpShapeEventMap::value_type& rShape) { + // TODO(F2): Get proper geometry polygon from the + // shape, to avoid having areas outside the shape + // react on the mouse + return rShape.first->getBounds().isInside( aPosition ) + && rShape.first->isVisible(); + }); + if (aCurrShape != maShapeEventMap.rend()) { - // TODO(F2): Get proper geometry polygon from the - // shape, to avoid having areas outside the shape - // react on the mouse - if( aCurrShape->first->getBounds().isInside( aPosition ) && - aCurrShape->first->isVisible() ) - { - // shape hit, and shape is visible - report a - // hit - o_rHitShape = aCurrShape; - return true; - } - - ++aCurrShape; + // shape hit, and shape is visible - report a + // hit + o_rHitShape = aCurrShape; + return true; } return false; // nothing hit diff --git a/slideshow/source/inc/basecontainernode.hxx b/slideshow/source/inc/basecontainernode.hxx index 6338fb026c7c..94547302d7e6 100644 --- a/slideshow/source/inc/basecontainernode.hxx +++ b/slideshow/source/inc/basecontainernode.hxx @@ -72,10 +72,7 @@ protected: void forEachChildNode( FuncT func, int nodeStateMask ) const { - VectorOfNodes::const_iterator iPos( maChildren.begin() ); - VectorOfNodes::const_iterator const iEnd( maChildren.end() ); - for ( ; iPos != iEnd; ++iPos ) { - AnimationNodeSharedPtr const& pNode = *iPos; + for (AnimationNodeSharedPtr const& pNode : maChildren) { if (nodeStateMask != -1 && (pNode->getState() & nodeStateMask) == 0) continue; func(pNode); |