Kaydet (Commit) 19ba9e08 authored tarafından Takeshi Abe's avatar Takeshi Abe Kaydeden (comit) Michael Stahl

slideshow: simplify code by replacing std::find_if by std::any_of/std::none_of

Change-Id: Ib8eec5074e82127e11f4fba2c0b143ab8cef3bcc
Reviewed-on: https://gerrit.libreoffice.org/15714Reviewed-by: 's avatarMichael Stahl <mstahl@redhat.com>
Tested-by: 's avatarMichael Stahl <mstahl@redhat.com>
üst 595a109f
...@@ -94,10 +94,9 @@ bool BaseContainerNode::hasPendingAnimation() const ...@@ -94,10 +94,9 @@ bool BaseContainerNode::hasPendingAnimation() const
// does any of our children returns "true" on // does any of our children returns "true" on
// AnimationNode::hasPendingAnimation()? // AnimationNode::hasPendingAnimation()?
// If yes, we, too, return true // If yes, we, too, return true
VectorOfNodes::const_iterator const iEnd( maChildren.end() ); return std::any_of(
return (std::find_if( maChildren.begin(), maChildren.end(),
maChildren.begin(), iEnd, boost::mem_fn(&AnimationNode::hasPendingAnimation) );
boost::mem_fn(&AnimationNode::hasPendingAnimation) ) != iEnd);
} }
void BaseContainerNode::appendChildNode( AnimationNodeSharedPtr const& pNode ) void BaseContainerNode::appendChildNode( AnimationNodeSharedPtr const& pNode )
......
...@@ -169,16 +169,14 @@ namespace slideshow ...@@ -169,16 +169,14 @@ namespace slideshow
void BackgroundShape::addViewLayer( const ViewLayerSharedPtr& rNewLayer, void BackgroundShape::addViewLayer( const ViewLayerSharedPtr& rNewLayer,
bool bRedrawLayer ) bool bRedrawLayer )
{ {
ViewBackgroundShapeVector::iterator aEnd( maViewShapes.end() );
// already added? // already added?
if( ::std::find_if( maViewShapes.begin(), if( ::std::any_of( maViewShapes.begin(),
aEnd, maViewShapes.end(),
::boost::bind<bool>( ::boost::bind<bool>(
::std::equal_to< ViewLayerSharedPtr >(), ::std::equal_to< ViewLayerSharedPtr >(),
::boost::bind( &ViewBackgroundShape::getViewLayer, ::boost::bind( &ViewBackgroundShape::getViewLayer,
_1 ), _1 ),
::boost::cref( rNewLayer ) ) ) != aEnd ) ::boost::cref( rNewLayer ) ) ) )
{ {
// yes, nothing to do // yes, nothing to do
return; return;
......
...@@ -632,16 +632,14 @@ namespace slideshow ...@@ -632,16 +632,14 @@ namespace slideshow
void DrawShape::addViewLayer( const ViewLayerSharedPtr& rNewLayer, void DrawShape::addViewLayer( const ViewLayerSharedPtr& rNewLayer,
bool bRedrawLayer ) bool bRedrawLayer )
{ {
ViewShapeVector::iterator aEnd( maViewShapes.end() );
// already added? // already added?
if( ::std::find_if( maViewShapes.begin(), if( ::std::any_of( maViewShapes.begin(),
aEnd, maViewShapes.end(),
::boost::bind<bool>( ::boost::bind<bool>(
::std::equal_to< ViewLayerSharedPtr >(), ::std::equal_to< ViewLayerSharedPtr >(),
::boost::bind( &ViewShape::getViewLayer, ::boost::bind( &ViewShape::getViewLayer,
_1 ), _1 ),
::boost::cref( rNewLayer ) ) ) != aEnd ) ::boost::cref( rNewLayer ) ) ))
{ {
// yes, nothing to do // yes, nothing to do
return; return;
......
...@@ -488,13 +488,9 @@ namespace slideshow ...@@ -488,13 +488,9 @@ namespace slideshow
if( mbLayerAssociationDirty || !maUpdateShapes.empty() ) if( mbLayerAssociationDirty || !maUpdateShapes.empty() )
return true; return true;
const LayerVector::const_iterator aEnd( maLayers.end() ); return std::any_of( maLayers.begin(),
if( std::find_if( maLayers.begin(), maLayers.end(),
aEnd, boost::mem_fn(&Layer::isUpdatePending) );
boost::mem_fn(&Layer::isUpdatePending)) != aEnd )
return true;
return false;
} }
bool LayerManager::updateSprites() bool LayerManager::updateSprites()
...@@ -552,9 +548,9 @@ namespace slideshow ...@@ -552,9 +548,9 @@ namespace slideshow
bRet = updateSprites(); bRet = updateSprites();
// any non-sprite update areas left? // any non-sprite update areas left?
if( std::find_if( maLayers.begin(), if( std::none_of( maLayers.begin(),
maLayers.end(), maLayers.end(),
boost::mem_fn( &Layer::isUpdatePending )) == maLayers.end() ) boost::mem_fn( &Layer::isUpdatePending ) ) )
return bRet; // nope, done. return bRet; // nope, done.
// update each shape on each layer, that has // update each shape on each layer, that has
......
...@@ -439,17 +439,9 @@ namespace slideshow ...@@ -439,17 +439,9 @@ namespace slideshow
const beans::NamedValue* pArray = rSequence.getConstArray(); const beans::NamedValue* pArray = rSequence.getConstArray();
const size_t nLen( rSequence.getLength() ); const size_t nLen( rSequence.getLength() );
if( nLen == 0 ) return ::std::any_of( pArray,
return false;
const beans::NamedValue* pFound = ::std::find_if( pArray,
pArray + nLen, pArray + nLen,
NamedValueComparator( rSearchKey ) ); NamedValueComparator( rSearchKey ) );
if( pFound == rSequence.getConstArray() + nLen )
return false;
return true;
} }
basegfx::B2DRange calcRelativeShapeBounds( const basegfx::B2DVector& rPageSize, basegfx::B2DRange calcRelativeShapeBounds( const basegfx::B2DVector& rPageSize,
......
...@@ -44,17 +44,16 @@ namespace slideshow ...@@ -44,17 +44,16 @@ namespace slideshow
bool UnoViewContainer::addView( const UnoViewSharedPtr& rView ) bool UnoViewContainer::addView( const UnoViewSharedPtr& rView )
{ {
// check whether same view is already added // check whether same view is already added
const UnoViewVector::iterator aEnd( maViews.end() );
// already added? // already added?
if( ::std::find_if( maViews.begin(), if( ::std::any_of( maViews.begin(),
aEnd, maViews.end(),
::boost::bind( ::boost::bind(
::std::equal_to< uno::Reference< presentation::XSlideShowView > >(), ::std::equal_to< uno::Reference< presentation::XSlideShowView > >(),
rView->getUnoView(), rView->getUnoView(),
::boost::bind( ::boost::bind(
&UnoView::getUnoView, &UnoView::getUnoView,
_1 ) ) ) != aEnd ) _1 ) ) ) )
{ {
// yes, nothing to do // yes, nothing to do
return false; return false;
......
...@@ -89,13 +89,11 @@ template< typename ListenerT > struct ListenerOperations ...@@ -89,13 +89,11 @@ template< typename ListenerT > struct ListenerOperations
static bool notifySingleListener( ContainerT& rContainer, static bool notifySingleListener( ContainerT& rContainer,
FuncT func ) FuncT func )
{ {
const typename ContainerT::const_iterator aEnd( rContainer.end() );
// true: a handler in this queue processed the event // true: a handler in this queue processed the event
// false: no handler in this queue finally processed the event // false: no handler in this queue finally processed the event
return (std::find_if( rContainer.begin(), return std::any_of( rContainer.begin(),
aEnd, rContainer.end(),
func ) != aEnd); func );
} }
/// Notify all listeners /// Notify all listeners
......
...@@ -127,13 +127,13 @@ private: ...@@ -127,13 +127,13 @@ private:
} }
virtual bool removeViewLayer( const target::ViewLayerSharedPtr& rNewLayer ) virtual bool removeViewLayer( const target::ViewLayerSharedPtr& rNewLayer )
{ {
if( std::find_if( if( std::none_of(
maViewLayers.begin(), maViewLayers.begin(),
maViewLayers.end(), maViewLayers.end(),
boost::bind( std::equal_to< target::ViewLayerSharedPtr >(), boost::bind( std::equal_to< target::ViewLayerSharedPtr >(),
boost::cref( rNewLayer ), boost::cref( rNewLayer ),
boost::bind( o3tl::select1st<ViewVector::value_type>(), boost::bind( o3tl::select1st<ViewVector::value_type>(),
_1 ))) == maViewLayers.end() ) _1 ))) )
throw std::exception(); throw std::exception();
maViewLayers.erase( maViewLayers.erase(
......
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