summaryrefslogtreecommitdiff
path: root/slideshow
diff options
context:
space:
mode:
authorTakeshi Abe <tabe@fixedpoint.jp>2015-05-12 19:54:36 +0900
committerMichael Stahl <mstahl@redhat.com>2015-05-13 10:50:47 +0000
commit19ba9e08cab4ff75595f53b9689989495ff5f625 (patch)
treef57962ba2676494201a874777329ed949a3f7be8 /slideshow
parent595a109f8f5cd19cc72e1e44f2ae111427bb4330 (diff)
slideshow: simplify code by replacing std::find_if by std::any_of/std::none_of
Change-Id: Ib8eec5074e82127e11f4fba2c0b143ab8cef3bcc Reviewed-on: https://gerrit.libreoffice.org/15714 Reviewed-by: Michael Stahl <mstahl@redhat.com> Tested-by: Michael Stahl <mstahl@redhat.com>
Diffstat (limited to 'slideshow')
-rw-r--r--slideshow/source/engine/animationnodes/basecontainernode.cxx7
-rw-r--r--slideshow/source/engine/shapes/backgroundshape.cxx10
-rw-r--r--slideshow/source/engine/shapes/drawshape.cxx10
-rw-r--r--slideshow/source/engine/slide/layermanager.cxx14
-rw-r--r--slideshow/source/engine/tools.cxx14
-rw-r--r--slideshow/source/engine/unoviewcontainer.cxx9
-rw-r--r--slideshow/source/inc/listenercontainer.hxx8
-rw-r--r--slideshow/test/testshape.cxx4
8 files changed, 28 insertions, 48 deletions
diff --git a/slideshow/source/engine/animationnodes/basecontainernode.cxx b/slideshow/source/engine/animationnodes/basecontainernode.cxx
index cc1eb68b530e..a3c73e8e2c23 100644
--- a/slideshow/source/engine/animationnodes/basecontainernode.cxx
+++ b/slideshow/source/engine/animationnodes/basecontainernode.cxx
@@ -94,10 +94,9 @@ bool BaseContainerNode::hasPendingAnimation() const
// does any of our children returns "true" on
// AnimationNode::hasPendingAnimation()?
// If yes, we, too, return true
- VectorOfNodes::const_iterator const iEnd( maChildren.end() );
- return (std::find_if(
- maChildren.begin(), iEnd,
- boost::mem_fn(&AnimationNode::hasPendingAnimation) ) != iEnd);
+ return std::any_of(
+ maChildren.begin(), maChildren.end(),
+ boost::mem_fn(&AnimationNode::hasPendingAnimation) );
}
void BaseContainerNode::appendChildNode( AnimationNodeSharedPtr const& pNode )
diff --git a/slideshow/source/engine/shapes/backgroundshape.cxx b/slideshow/source/engine/shapes/backgroundshape.cxx
index f820a266295f..762c05c692b5 100644
--- a/slideshow/source/engine/shapes/backgroundshape.cxx
+++ b/slideshow/source/engine/shapes/backgroundshape.cxx
@@ -169,16 +169,14 @@ namespace slideshow
void BackgroundShape::addViewLayer( const ViewLayerSharedPtr& rNewLayer,
bool bRedrawLayer )
{
- ViewBackgroundShapeVector::iterator aEnd( maViewShapes.end() );
-
// already added?
- if( ::std::find_if( maViewShapes.begin(),
- aEnd,
- ::boost::bind<bool>(
+ if( ::std::any_of( maViewShapes.begin(),
+ maViewShapes.end(),
+ ::boost::bind<bool>(
::std::equal_to< ViewLayerSharedPtr >(),
::boost::bind( &ViewBackgroundShape::getViewLayer,
_1 ),
- ::boost::cref( rNewLayer ) ) ) != aEnd )
+ ::boost::cref( rNewLayer ) ) ) )
{
// yes, nothing to do
return;
diff --git a/slideshow/source/engine/shapes/drawshape.cxx b/slideshow/source/engine/shapes/drawshape.cxx
index 7c77a3c15f2b..875dffebb58c 100644
--- a/slideshow/source/engine/shapes/drawshape.cxx
+++ b/slideshow/source/engine/shapes/drawshape.cxx
@@ -632,16 +632,14 @@ namespace slideshow
void DrawShape::addViewLayer( const ViewLayerSharedPtr& rNewLayer,
bool bRedrawLayer )
{
- ViewShapeVector::iterator aEnd( maViewShapes.end() );
-
// already added?
- if( ::std::find_if( maViewShapes.begin(),
- aEnd,
- ::boost::bind<bool>(
+ if( ::std::any_of( maViewShapes.begin(),
+ maViewShapes.end(),
+ ::boost::bind<bool>(
::std::equal_to< ViewLayerSharedPtr >(),
::boost::bind( &ViewShape::getViewLayer,
_1 ),
- ::boost::cref( rNewLayer ) ) ) != aEnd )
+ ::boost::cref( rNewLayer ) ) ))
{
// yes, nothing to do
return;
diff --git a/slideshow/source/engine/slide/layermanager.cxx b/slideshow/source/engine/slide/layermanager.cxx
index c46b90245276..7e0279920b5d 100644
--- a/slideshow/source/engine/slide/layermanager.cxx
+++ b/slideshow/source/engine/slide/layermanager.cxx
@@ -488,13 +488,9 @@ namespace slideshow
if( mbLayerAssociationDirty || !maUpdateShapes.empty() )
return true;
- const LayerVector::const_iterator aEnd( maLayers.end() );
- if( std::find_if( maLayers.begin(),
- aEnd,
- boost::mem_fn(&Layer::isUpdatePending)) != aEnd )
- return true;
-
- return false;
+ return std::any_of( maLayers.begin(),
+ maLayers.end(),
+ boost::mem_fn(&Layer::isUpdatePending) );
}
bool LayerManager::updateSprites()
@@ -552,9 +548,9 @@ namespace slideshow
bRet = updateSprites();
// any non-sprite update areas left?
- if( std::find_if( maLayers.begin(),
+ if( std::none_of( maLayers.begin(),
maLayers.end(),
- boost::mem_fn( &Layer::isUpdatePending )) == maLayers.end() )
+ boost::mem_fn( &Layer::isUpdatePending ) ) )
return bRet; // nope, done.
// update each shape on each layer, that has
diff --git a/slideshow/source/engine/tools.cxx b/slideshow/source/engine/tools.cxx
index 3bd58aeaf077..ca98a899fc8e 100644
--- a/slideshow/source/engine/tools.cxx
+++ b/slideshow/source/engine/tools.cxx
@@ -439,17 +439,9 @@ namespace slideshow
const beans::NamedValue* pArray = rSequence.getConstArray();
const size_t nLen( rSequence.getLength() );
- if( nLen == 0 )
- return false;
-
- const beans::NamedValue* pFound = ::std::find_if( pArray,
- pArray + nLen,
- NamedValueComparator( rSearchKey ) );
-
- if( pFound == rSequence.getConstArray() + nLen )
- return false;
-
- return true;
+ return ::std::any_of( pArray,
+ pArray + nLen,
+ NamedValueComparator( rSearchKey ) );
}
basegfx::B2DRange calcRelativeShapeBounds( const basegfx::B2DVector& rPageSize,
diff --git a/slideshow/source/engine/unoviewcontainer.cxx b/slideshow/source/engine/unoviewcontainer.cxx
index f55193886b5a..7efee4a22220 100644
--- a/slideshow/source/engine/unoviewcontainer.cxx
+++ b/slideshow/source/engine/unoviewcontainer.cxx
@@ -44,17 +44,16 @@ namespace slideshow
bool UnoViewContainer::addView( const UnoViewSharedPtr& rView )
{
// check whether same view is already added
- const UnoViewVector::iterator aEnd( maViews.end() );
// already added?
- if( ::std::find_if( maViews.begin(),
- aEnd,
- ::boost::bind(
+ if( ::std::any_of( maViews.begin(),
+ maViews.end(),
+ ::boost::bind(
::std::equal_to< uno::Reference< presentation::XSlideShowView > >(),
rView->getUnoView(),
::boost::bind(
&UnoView::getUnoView,
- _1 ) ) ) != aEnd )
+ _1 ) ) ) )
{
// yes, nothing to do
return false;
diff --git a/slideshow/source/inc/listenercontainer.hxx b/slideshow/source/inc/listenercontainer.hxx
index e87a6a52f44e..2b7ae49b4eaa 100644
--- a/slideshow/source/inc/listenercontainer.hxx
+++ b/slideshow/source/inc/listenercontainer.hxx
@@ -89,13 +89,11 @@ template< typename ListenerT > struct ListenerOperations
static bool notifySingleListener( ContainerT& rContainer,
FuncT func )
{
- const typename ContainerT::const_iterator aEnd( rContainer.end() );
-
// true: a handler in this queue processed the event
// false: no handler in this queue finally processed the event
- return (std::find_if( rContainer.begin(),
- aEnd,
- func ) != aEnd);
+ return std::any_of( rContainer.begin(),
+ rContainer.end(),
+ func );
}
/// Notify all listeners
diff --git a/slideshow/test/testshape.cxx b/slideshow/test/testshape.cxx
index 687a953007e4..46173d9dcc5a 100644
--- a/slideshow/test/testshape.cxx
+++ b/slideshow/test/testshape.cxx
@@ -127,13 +127,13 @@ private:
}
virtual bool removeViewLayer( const target::ViewLayerSharedPtr& rNewLayer )
{
- if( std::find_if(
+ if( std::none_of(
maViewLayers.begin(),
maViewLayers.end(),
boost::bind( std::equal_to< target::ViewLayerSharedPtr >(),
boost::cref( rNewLayer ),
boost::bind( o3tl::select1st<ViewVector::value_type>(),
- _1 ))) == maViewLayers.end() )
+ _1 ))) )
throw std::exception();
maViewLayers.erase(