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. In addition, replace while loops with range-based for loops when possible and complex implementations of boost::bind with lambda expressions. Change-Id: I6adfb18197bd1b8627719adfca2e4c36d58a0e05 Reviewed-on: https://gerrit.libreoffice.org/17786 Reviewed-by: Thorsten Behrens <Thorsten.Behrens@CIB.de> Tested-by: Thorsten Behrens <Thorsten.Behrens@CIB.de>
This commit is contained in:
committed by
Thorsten Behrens
parent
b190574b6a
commit
a811d6efe4
@@ -26,7 +26,6 @@
|
|||||||
#include "activity.hxx"
|
#include "activity.hxx"
|
||||||
#include "activitiesqueue.hxx"
|
#include "activitiesqueue.hxx"
|
||||||
|
|
||||||
#include <boost/mem_fn.hpp>
|
|
||||||
#include <boost/shared_ptr.hpp>
|
#include <boost/shared_ptr.hpp>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
@@ -51,12 +50,10 @@ namespace slideshow
|
|||||||
// dispose all queue entries
|
// dispose all queue entries
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
std::for_each( maCurrentActivitiesWaiting.begin(),
|
for( const auto& pActivity : maCurrentActivitiesWaiting )
|
||||||
maCurrentActivitiesWaiting.end(),
|
pActivity->dispose();
|
||||||
boost::mem_fn( &Disposable::dispose ) );
|
for( const auto& pActivity : maCurrentActivitiesReinsert )
|
||||||
std::for_each( maCurrentActivitiesReinsert.begin(),
|
pActivity->dispose();
|
||||||
maCurrentActivitiesReinsert.end(),
|
|
||||||
boost::mem_fn( &Disposable::dispose ) );
|
|
||||||
}
|
}
|
||||||
catch (uno::Exception &)
|
catch (uno::Exception &)
|
||||||
{
|
{
|
||||||
@@ -169,9 +166,8 @@ namespace slideshow
|
|||||||
void ActivitiesQueue::processDequeued()
|
void ActivitiesQueue::processDequeued()
|
||||||
{
|
{
|
||||||
// notify all dequeued activities from last round
|
// notify all dequeued activities from last round
|
||||||
::std::for_each( maDequeuedActivities.begin(),
|
for( const auto& pActivity : maDequeuedActivities )
|
||||||
maDequeuedActivities.end(),
|
pActivity->dequeued();
|
||||||
::boost::mem_fn( &Activity::dequeued ) );
|
|
||||||
maDequeuedActivities.clear();
|
maDequeuedActivities.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -183,14 +179,12 @@ namespace slideshow
|
|||||||
void ActivitiesQueue::clear()
|
void ActivitiesQueue::clear()
|
||||||
{
|
{
|
||||||
// dequeue all entries:
|
// dequeue all entries:
|
||||||
std::for_each( maCurrentActivitiesWaiting.begin(),
|
for( const auto& pActivity : maCurrentActivitiesWaiting )
|
||||||
maCurrentActivitiesWaiting.end(),
|
pActivity->dequeued();
|
||||||
boost::mem_fn( &Activity::dequeued ) );
|
|
||||||
ActivityQueue().swap( maCurrentActivitiesWaiting );
|
ActivityQueue().swap( maCurrentActivitiesWaiting );
|
||||||
|
|
||||||
std::for_each( maCurrentActivitiesReinsert.begin(),
|
for( const auto& pActivity : maCurrentActivitiesReinsert )
|
||||||
maCurrentActivitiesReinsert.end(),
|
pActivity->dequeued();
|
||||||
boost::mem_fn( &Activity::dequeued ) );
|
|
||||||
ActivityQueue().swap( maCurrentActivitiesReinsert );
|
ActivityQueue().swap( maCurrentActivitiesReinsert );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -34,7 +34,6 @@
|
|||||||
#include "nodetools.hxx"
|
#include "nodetools.hxx"
|
||||||
#include "generateevent.hxx"
|
#include "generateevent.hxx"
|
||||||
|
|
||||||
#include <boost/bind.hpp>
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <iterator>
|
#include <iterator>
|
||||||
@@ -624,10 +623,8 @@ void BaseNode::notifyDeactivating( const AnimationNodeSharedPtr& rNotifier )
|
|||||||
void BaseNode::notifyEndListeners() const
|
void BaseNode::notifyEndListeners() const
|
||||||
{
|
{
|
||||||
// notify all listeners
|
// notify all listeners
|
||||||
std::for_each( maDeactivatingListeners.begin(),
|
for( const auto& rListner : maDeactivatingListeners )
|
||||||
maDeactivatingListeners.end(),
|
rListner->notifyDeactivating( mpSelf );
|
||||||
boost::bind( &AnimationNode::notifyDeactivating, _1,
|
|
||||||
boost::cref(mpSelf) ) );
|
|
||||||
|
|
||||||
// notify state change
|
// notify state change
|
||||||
maContext.mrEventMultiplexer.notifyAnimationEnd( mpSelf );
|
maContext.mrEventMultiplexer.notifyAnimationEnd( mpSelf );
|
||||||
|
@@ -64,10 +64,8 @@ PointerSymbol::PointerSymbol( uno::Reference<rendering::XBitmap> const & xBitm
|
|||||||
maPos(),
|
maPos(),
|
||||||
mbVisible(false)
|
mbVisible(false)
|
||||||
{
|
{
|
||||||
std::for_each( rViewContainer.begin(),
|
for( const auto& rView : rViewContainer )
|
||||||
rViewContainer.end(),
|
viewAdded( rView );
|
||||||
[this]( const UnoViewSharedPtr& sp )
|
|
||||||
{ this->viewAdded(sp); } );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void PointerSymbol::setVisible( const bool bVisible )
|
void PointerSymbol::setVisible( const bool bVisible )
|
||||||
@@ -76,19 +74,15 @@ void PointerSymbol::setVisible( const bool bVisible )
|
|||||||
{
|
{
|
||||||
mbVisible = bVisible;
|
mbVisible = bVisible;
|
||||||
|
|
||||||
ViewsVecT::const_iterator aIter( maViews.begin() );
|
for( const auto& rView : maViews )
|
||||||
ViewsVecT::const_iterator const aEnd ( maViews.end() );
|
|
||||||
while( aIter != aEnd )
|
|
||||||
{
|
{
|
||||||
if( aIter->second )
|
if( rView.second )
|
||||||
{
|
{
|
||||||
if( bVisible )
|
if( bVisible )
|
||||||
aIter->second->show();
|
rView.second->show();
|
||||||
else
|
else
|
||||||
aIter->second->hide();
|
rView.second->hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
++aIter;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// sprites changed, need a screen update for this frame.
|
// sprites changed, need a screen update for this frame.
|
||||||
@@ -173,14 +167,11 @@ void PointerSymbol::viewChanged( const UnoViewSharedPtr& rView )
|
|||||||
void PointerSymbol::viewsChanged()
|
void PointerSymbol::viewsChanged()
|
||||||
{
|
{
|
||||||
// reposition sprites on all views
|
// reposition sprites on all views
|
||||||
ViewsVecT::const_iterator aIter( maViews.begin() );
|
for( const auto& rView : maViews )
|
||||||
ViewsVecT::const_iterator const aEnd ( maViews.end() );
|
|
||||||
while( aIter != aEnd )
|
|
||||||
{
|
{
|
||||||
if( aIter->second )
|
if( rView.second )
|
||||||
aIter->second->movePixel(
|
rView.second->movePixel(
|
||||||
calcSpritePos( aIter->first ));
|
calcSpritePos( rView.first ) );
|
||||||
++aIter;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -191,18 +182,15 @@ void PointerSymbol::viewsChanged(const geometry::RealPoint2D pos)
|
|||||||
maPos = pos;
|
maPos = pos;
|
||||||
|
|
||||||
// reposition sprites on all views
|
// reposition sprites on all views
|
||||||
ViewsVecT::const_iterator aIter( maViews.begin() );
|
for( const auto& rView : maViews )
|
||||||
ViewsVecT::const_iterator const aEnd ( maViews.end() );
|
|
||||||
while( aIter != aEnd )
|
|
||||||
{
|
{
|
||||||
if( aIter->second )
|
if( rView.second )
|
||||||
{
|
{
|
||||||
aIter->second->movePixel(
|
rView.second->movePixel(
|
||||||
calcSpritePos( aIter->first ));
|
calcSpritePos( rView.first ) );
|
||||||
mrScreenUpdater.notifyUpdate();
|
mrScreenUpdater.notifyUpdate();
|
||||||
mrScreenUpdater.commitUpdates();
|
mrScreenUpdater.commitUpdates();
|
||||||
}
|
}
|
||||||
++aIter;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -167,11 +167,8 @@ RehearseTimingsActivity::RehearseTimingsActivity( const SlideShowContext& rConte
|
|||||||
maSpriteSizePixel.setY( metric.GetLineHeight() * 11 / 10 );
|
maSpriteSizePixel.setY( metric.GetLineHeight() * 11 / 10 );
|
||||||
mnYOffset = (metric.GetAscent() + (metric.GetLineHeight() / 20));
|
mnYOffset = (metric.GetAscent() + (metric.GetLineHeight() / 20));
|
||||||
|
|
||||||
std::for_each( rContext.mrViewContainer.begin(),
|
for( const auto& rView : rContext.mrViewContainer )
|
||||||
rContext.mrViewContainer.end(),
|
viewAdded( rView );
|
||||||
boost::bind( &RehearseTimingsActivity::viewAdded,
|
|
||||||
this,
|
|
||||||
_1 ));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
RehearseTimingsActivity::~RehearseTimingsActivity()
|
RehearseTimingsActivity::~RehearseTimingsActivity()
|
||||||
|
@@ -137,20 +137,18 @@ namespace internal
|
|||||||
mpImpl->mbUpdateAllRequest )
|
mpImpl->mbUpdateAllRequest )
|
||||||
{
|
{
|
||||||
// unconditionally update all views
|
// unconditionally update all views
|
||||||
std::for_each( mpImpl->mrViewContainer.begin(),
|
for( const auto& pView : mpImpl->mrViewContainer )
|
||||||
mpImpl->mrViewContainer.end(),
|
{
|
||||||
mpImpl->mbViewClobbered ?
|
if( mpImpl->mbViewClobbered )
|
||||||
boost::mem_fn(&View::paintScreen) :
|
pView->paintScreen();
|
||||||
boost::mem_fn(&View::updateScreen) );
|
else
|
||||||
|
pView->updateScreen();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if( !mpImpl->maViewUpdateRequests.empty() )
|
else if( !mpImpl->maViewUpdateRequests.empty() )
|
||||||
{
|
{
|
||||||
// update notified views only
|
// update notified views only
|
||||||
UpdateRequestVector::const_iterator aIter(
|
for( const auto& rViewUpdateRequest : mpImpl->maViewUpdateRequests )
|
||||||
mpImpl->maViewUpdateRequests.begin() );
|
|
||||||
const UpdateRequestVector::const_iterator aEnd(
|
|
||||||
mpImpl->maViewUpdateRequests.end() );
|
|
||||||
while( aIter != aEnd )
|
|
||||||
{
|
{
|
||||||
// TODO(P1): this is O(n^2) in the number of views, if
|
// TODO(P1): this is O(n^2) in the number of views, if
|
||||||
// lots of views notify updates.
|
// lots of views notify updates.
|
||||||
@@ -159,15 +157,13 @@ namespace internal
|
|||||||
UnoViewVector::const_iterator aFoundView;
|
UnoViewVector::const_iterator aFoundView;
|
||||||
if( (aFoundView=std::find(mpImpl->mrViewContainer.begin(),
|
if( (aFoundView=std::find(mpImpl->mrViewContainer.begin(),
|
||||||
aEndOfViews,
|
aEndOfViews,
|
||||||
aIter->first)) != aEndOfViews )
|
rViewUpdateRequest.first)) != aEndOfViews )
|
||||||
{
|
{
|
||||||
if( aIter->second )
|
if( rViewUpdateRequest.second )
|
||||||
(*aFoundView)->paintScreen(); // force-paint
|
(*aFoundView)->paintScreen(); // force-paint
|
||||||
else
|
else
|
||||||
(*aFoundView)->updateScreen(); // update changes only
|
(*aFoundView)->updateScreen(); // update changes only
|
||||||
}
|
}
|
||||||
|
|
||||||
++aIter;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -195,9 +191,8 @@ namespace internal
|
|||||||
// TODO(F2): This will interfere with other updates, since it
|
// TODO(F2): This will interfere with other updates, since it
|
||||||
// happens out-of-sync with main animation loop. Might cause
|
// happens out-of-sync with main animation loop. Might cause
|
||||||
// artifacts.
|
// artifacts.
|
||||||
std::for_each( mpImpl->mrViewContainer.begin(),
|
for( auto const& pView : mpImpl->mrViewContainer )
|
||||||
mpImpl->mrViewContainer.end(),
|
pView->updateScreen();
|
||||||
boost::mem_fn(&View::updateScreen) );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScreenUpdater::lockUpdates()
|
void ScreenUpdater::lockUpdates()
|
||||||
|
@@ -28,7 +28,6 @@
|
|||||||
#include "viewappletshape.hxx"
|
#include "viewappletshape.hxx"
|
||||||
#include "tools.hxx"
|
#include "tools.hxx"
|
||||||
|
|
||||||
#include <boost/bind.hpp>
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
|
|
||||||
@@ -128,15 +127,12 @@ namespace slideshow
|
|||||||
|
|
||||||
void AppletShape::implViewChanged( const UnoViewSharedPtr& rView )
|
void AppletShape::implViewChanged( const UnoViewSharedPtr& rView )
|
||||||
{
|
{
|
||||||
|
const ::basegfx::B2DRectangle& rBounds = getBounds();
|
||||||
// determine ViewAppletShape that needs update
|
// determine ViewAppletShape that needs update
|
||||||
ViewAppletShapeVector::const_iterator aIter(maViewAppletShapes.begin());
|
for( const auto& pViewAppletShape : maViewAppletShapes )
|
||||||
ViewAppletShapeVector::const_iterator const aEnd (maViewAppletShapes.end());
|
|
||||||
while( aIter != aEnd )
|
|
||||||
{
|
{
|
||||||
if( (*aIter)->getViewLayer()->isOnView(rView) )
|
if( pViewAppletShape->getViewLayer()->isOnView( rView ) )
|
||||||
(*aIter)->resize(getBounds());
|
pViewAppletShape->resize( rBounds );
|
||||||
|
|
||||||
++aIter;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -145,12 +141,9 @@ namespace slideshow
|
|||||||
void AppletShape::implViewsChanged()
|
void AppletShape::implViewsChanged()
|
||||||
{
|
{
|
||||||
// resize all ViewShapes
|
// resize all ViewShapes
|
||||||
::std::for_each( maViewAppletShapes.begin(),
|
const ::basegfx::B2DRectangle& rBounds = getBounds();
|
||||||
maViewAppletShapes.end(),
|
for( const auto& pViewAppletShape : maViewAppletShapes )
|
||||||
::boost::bind(
|
pViewAppletShape->resize( rBounds );
|
||||||
&ViewAppletShape::resize,
|
|
||||||
_1,
|
|
||||||
AppletShape::getBounds()) );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -190,21 +183,18 @@ namespace slideshow
|
|||||||
|
|
||||||
OSL_ENSURE( ::std::count_if(maViewAppletShapes.begin(),
|
OSL_ENSURE( ::std::count_if(maViewAppletShapes.begin(),
|
||||||
aEnd,
|
aEnd,
|
||||||
::boost::bind<bool>(
|
[&rLayer]
|
||||||
::std::equal_to< ViewLayerSharedPtr >(),
|
( const ViewAppletShapeSharedPtr& pShape )
|
||||||
::boost::bind( &ViewAppletShape::getViewLayer, _1 ),
|
{ return rLayer == pShape->getViewLayer(); } ) < 2,
|
||||||
::boost::cref( rLayer ) ) ) < 2,
|
|
||||||
"AppletShape::removeViewLayer(): Duplicate ViewLayer entries!" );
|
"AppletShape::removeViewLayer(): Duplicate ViewLayer entries!" );
|
||||||
|
|
||||||
ViewAppletShapeVector::iterator aIter;
|
ViewAppletShapeVector::iterator aIter;
|
||||||
|
|
||||||
if( (aIter=::std::remove_if( maViewAppletShapes.begin(),
|
if( (aIter=::std::remove_if( maViewAppletShapes.begin(),
|
||||||
aEnd,
|
aEnd,
|
||||||
::boost::bind<bool>(
|
[&rLayer]
|
||||||
::std::equal_to< ViewLayerSharedPtr >(),
|
( const ViewAppletShapeSharedPtr& pShape )
|
||||||
::boost::bind( &ViewAppletShape::getViewLayer,
|
{ return rLayer == pShape->getViewLayer(); } ) ) == aEnd )
|
||||||
_1 ),
|
|
||||||
::boost::cref( rLayer ) ) )) == aEnd )
|
|
||||||
{
|
{
|
||||||
// view layer seemingly was not added, failed
|
// view layer seemingly was not added, failed
|
||||||
return false;
|
return false;
|
||||||
@@ -231,10 +221,9 @@ namespace slideshow
|
|||||||
// redraw all view shapes, by calling their update() method
|
// redraw all view shapes, by calling their update() method
|
||||||
if( ::std::count_if( maViewAppletShapes.begin(),
|
if( ::std::count_if( maViewAppletShapes.begin(),
|
||||||
maViewAppletShapes.end(),
|
maViewAppletShapes.end(),
|
||||||
::boost::bind<bool>(
|
[&rCurrBounds]
|
||||||
::boost::mem_fn( &ViewAppletShape::render ),
|
( const ViewAppletShapeSharedPtr& pShape )
|
||||||
_1,
|
{ return pShape->render( rCurrBounds ); } )
|
||||||
::boost::cref( rCurrBounds ) ) )
|
|
||||||
!= static_cast<ViewAppletShapeVector::difference_type>(maViewAppletShapes.size()) )
|
!= static_cast<ViewAppletShapeVector::difference_type>(maViewAppletShapes.size()) )
|
||||||
{
|
{
|
||||||
// at least one of the ViewShape::update() calls did return
|
// at least one of the ViewShape::update() calls did return
|
||||||
@@ -249,11 +238,10 @@ namespace slideshow
|
|||||||
|
|
||||||
bool AppletShape::implStartIntrinsicAnimation()
|
bool AppletShape::implStartIntrinsicAnimation()
|
||||||
{
|
{
|
||||||
::std::for_each( maViewAppletShapes.begin(),
|
const ::basegfx::B2DRectangle& rBounds = getBounds();
|
||||||
maViewAppletShapes.end(),
|
for( const auto& pViewAppletShape : maViewAppletShapes )
|
||||||
::boost::bind( &ViewAppletShape::startApplet,
|
pViewAppletShape->startApplet( rBounds );
|
||||||
_1,
|
|
||||||
getBounds()) );
|
|
||||||
mbIsPlaying = true;
|
mbIsPlaying = true;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@@ -263,9 +251,8 @@ namespace slideshow
|
|||||||
|
|
||||||
bool AppletShape::implEndIntrinsicAnimation()
|
bool AppletShape::implEndIntrinsicAnimation()
|
||||||
{
|
{
|
||||||
::std::for_each( maViewAppletShapes.begin(),
|
for( const auto& pViewAppletShape : maViewAppletShapes )
|
||||||
maViewAppletShapes.end(),
|
pViewAppletShape->endApplet();
|
||||||
::boost::mem_fn( &ViewAppletShape::endApplet ) );
|
|
||||||
|
|
||||||
mbIsPlaying = false;
|
mbIsPlaying = false;
|
||||||
|
|
||||||
|
@@ -62,7 +62,6 @@
|
|||||||
#include "gdimtftools.hxx"
|
#include "gdimtftools.hxx"
|
||||||
#include "drawinglayeranimation.hxx"
|
#include "drawinglayeranimation.hxx"
|
||||||
|
|
||||||
#include <boost/bind.hpp>
|
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
|
||||||
using namespace ::com::sun::star;
|
using namespace ::com::sun::star;
|
||||||
@@ -166,19 +165,15 @@ namespace slideshow
|
|||||||
|
|
||||||
// redraw all view shapes, by calling their update() method
|
// redraw all view shapes, by calling their update() method
|
||||||
ViewShape::RenderArgs renderArgs( getViewRenderArgs() );
|
ViewShape::RenderArgs renderArgs( getViewRenderArgs() );
|
||||||
|
bool bVisible = isVisible();
|
||||||
if( ::std::count_if( maViewShapes.begin(),
|
if( ::std::count_if( maViewShapes.begin(),
|
||||||
maViewShapes.end(),
|
maViewShapes.end(),
|
||||||
::boost::bind<bool>(
|
[this, &bVisible, &renderArgs, &nUpdateFlags]
|
||||||
::boost::mem_fn( &ViewShape::update ), // though _theoretically_,
|
( const ViewShapeSharedPtr& pShape )
|
||||||
// bind should eat this even
|
{ return pShape->update( this->mpCurrMtf,
|
||||||
// with _1 being a shared_ptr,
|
renderArgs,
|
||||||
// it does _not_ for MSVC without
|
nUpdateFlags,
|
||||||
// the extra mem_fn. WTF.
|
bVisible ); } )
|
||||||
_1,
|
|
||||||
::boost::cref( mpCurrMtf ),
|
|
||||||
::boost::cref( renderArgs ),
|
|
||||||
nUpdateFlags,
|
|
||||||
isVisible() ) )
|
|
||||||
!= static_cast<ViewShapeVector::difference_type>(maViewShapes.size()) )
|
!= static_cast<ViewShapeVector::difference_type>(maViewShapes.size()) )
|
||||||
{
|
{
|
||||||
// at least one of the ViewShape::update() calls did return
|
// at least one of the ViewShape::update() calls did return
|
||||||
@@ -319,8 +314,8 @@ namespace slideshow
|
|||||||
|
|
||||||
// restore old transformation when leaving the scope
|
// restore old transformation when leaving the scope
|
||||||
const ::comphelper::ScopeGuard aGuard(
|
const ::comphelper::ScopeGuard aGuard(
|
||||||
boost::bind( &::cppcanvas::Canvas::setTransformation,
|
[&pDestinationCanvas, &aOldTransform]()
|
||||||
pDestinationCanvas, aOldTransform ) );
|
{ return pDestinationCanvas->setTransformation( aOldTransform ); } );
|
||||||
|
|
||||||
|
|
||||||
// retrieve bounds for subset of whole metafile
|
// retrieve bounds for subset of whole metafile
|
||||||
@@ -330,15 +325,10 @@ namespace slideshow
|
|||||||
|
|
||||||
// cannot use ::boost::bind, ::basegfx::B2DRange::expand()
|
// cannot use ::boost::bind, ::basegfx::B2DRange::expand()
|
||||||
// is overloaded.
|
// is overloaded.
|
||||||
VectorOfDocTreeNodes::const_iterator aCurr( rSubsets.begin() );
|
for( const auto& rDocTreeNode : rSubsets )
|
||||||
const VectorOfDocTreeNodes::const_iterator aEnd( rSubsets.end() );
|
|
||||||
while( aCurr != aEnd )
|
|
||||||
{
|
|
||||||
aTotalBounds.expand( pRenderer->getSubsetArea(
|
aTotalBounds.expand( pRenderer->getSubsetArea(
|
||||||
aCurr->getStartIndex(),
|
rDocTreeNode.getStartIndex(),
|
||||||
aCurr->getEndIndex() ) );
|
rDocTreeNode.getEndIndex() ) );
|
||||||
++aCurr;
|
|
||||||
}
|
|
||||||
|
|
||||||
OSL_ENSURE( aTotalBounds.getMinX() >= -0.1 &&
|
OSL_ENSURE( aTotalBounds.getMinX() >= -0.1 &&
|
||||||
aTotalBounds.getMinY() >= -0.1 &&
|
aTotalBounds.getMinY() >= -0.1 &&
|
||||||
@@ -632,11 +622,9 @@ namespace slideshow
|
|||||||
// already added?
|
// already added?
|
||||||
if( ::std::any_of( maViewShapes.begin(),
|
if( ::std::any_of( maViewShapes.begin(),
|
||||||
maViewShapes.end(),
|
maViewShapes.end(),
|
||||||
::boost::bind<bool>(
|
[&rNewLayer]
|
||||||
::std::equal_to< ViewLayerSharedPtr >(),
|
( const ViewShapeSharedPtr& pShape )
|
||||||
::boost::bind( &ViewShape::getViewLayer,
|
{ return rNewLayer == pShape->getViewLayer(); } ) )
|
||||||
_1 ),
|
|
||||||
::boost::cref( rNewLayer ) ) ))
|
|
||||||
{
|
{
|
||||||
// yes, nothing to do
|
// yes, nothing to do
|
||||||
return;
|
return;
|
||||||
@@ -669,22 +657,18 @@ namespace slideshow
|
|||||||
|
|
||||||
OSL_ENSURE( ::std::count_if(maViewShapes.begin(),
|
OSL_ENSURE( ::std::count_if(maViewShapes.begin(),
|
||||||
aEnd,
|
aEnd,
|
||||||
::boost::bind<bool>(
|
[&rLayer]
|
||||||
::std::equal_to< ViewLayerSharedPtr >(),
|
( const ViewShapeSharedPtr& pShape )
|
||||||
::boost::bind( &ViewShape::getViewLayer,
|
{ return rLayer == pShape->getViewLayer(); } ) < 2,
|
||||||
_1 ),
|
|
||||||
::boost::cref( rLayer ) ) ) < 2,
|
|
||||||
"DrawShape::removeViewLayer(): Duplicate ViewLayer entries!" );
|
"DrawShape::removeViewLayer(): Duplicate ViewLayer entries!" );
|
||||||
|
|
||||||
ViewShapeVector::iterator aIter;
|
ViewShapeVector::iterator aIter;
|
||||||
|
|
||||||
if( (aIter=::std::remove_if( maViewShapes.begin(),
|
if( (aIter=::std::remove_if( maViewShapes.begin(),
|
||||||
aEnd,
|
aEnd,
|
||||||
::boost::bind<bool>(
|
[&rLayer]
|
||||||
::std::equal_to< ViewLayerSharedPtr >(),
|
( const ViewShapeSharedPtr& pShape )
|
||||||
::boost::bind( &ViewShape::getViewLayer,
|
{ return rLayer == pShape->getViewLayer(); } ) ) == aEnd )
|
||||||
_1 ),
|
|
||||||
::boost::cref( rLayer ) ) )) == aEnd )
|
|
||||||
{
|
{
|
||||||
// view layer seemingly was not added, failed
|
// view layer seemingly was not added, failed
|
||||||
return false;
|
return false;
|
||||||
@@ -745,41 +729,6 @@ namespace slideshow
|
|||||||
return maBounds;
|
return maBounds;
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace
|
|
||||||
{
|
|
||||||
/** Functor expanding AA border for each passed ViewShape
|
|
||||||
|
|
||||||
Could not use ::boost::bind here, since
|
|
||||||
B2DRange::expand is overloaded (which yields one or
|
|
||||||
the other template type deduction ambiguous)
|
|
||||||
*/
|
|
||||||
class Expander
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
explicit Expander( ::basegfx::B2DSize& rBounds ) :
|
|
||||||
mrBounds( rBounds )
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void operator()( const ViewShapeSharedPtr& rShape ) const
|
|
||||||
{
|
|
||||||
const ::basegfx::B2DSize& rShapeBorder( rShape->getAntialiasingBorder() );
|
|
||||||
|
|
||||||
mrBounds.setX(
|
|
||||||
::std::max(
|
|
||||||
rShapeBorder.getX(),
|
|
||||||
mrBounds.getX() ) );
|
|
||||||
mrBounds.setY(
|
|
||||||
::std::max(
|
|
||||||
rShapeBorder.getY(),
|
|
||||||
mrBounds.getY() ) );
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
::basegfx::B2DSize& mrBounds;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
::basegfx::B2DRectangle DrawShape::getUpdateArea() const
|
::basegfx::B2DRectangle DrawShape::getUpdateArea() const
|
||||||
{
|
{
|
||||||
::basegfx::B2DRectangle aBounds;
|
::basegfx::B2DRectangle aBounds;
|
||||||
@@ -823,9 +772,17 @@ namespace slideshow
|
|||||||
|
|
||||||
// for every view, get AA border and 'expand' aAABorder
|
// for every view, get AA border and 'expand' aAABorder
|
||||||
// appropriately.
|
// appropriately.
|
||||||
::std::for_each( maViewShapes.begin(),
|
for( const auto& rViewShape : maViewShapes )
|
||||||
maViewShapes.end(),
|
{
|
||||||
Expander( aAABorder ) );
|
const ::basegfx::B2DSize rShapeBorder( rViewShape->getAntialiasingBorder() );
|
||||||
|
|
||||||
|
aAABorder.setX( ::std::max(
|
||||||
|
rShapeBorder.getX(),
|
||||||
|
aAABorder.getX() ) );
|
||||||
|
aAABorder.setY( ::std::max(
|
||||||
|
rShapeBorder.getY(),
|
||||||
|
aAABorder.getY() ) );
|
||||||
|
}
|
||||||
|
|
||||||
// add calculated AA border to aBounds
|
// add calculated AA border to aBounds
|
||||||
aBounds = ::basegfx::B2DRectangle( aBounds.getMinX() - aAABorder.getX(),
|
aBounds = ::basegfx::B2DRectangle( aBounds.getMinX() - aAABorder.getX(),
|
||||||
@@ -996,10 +953,11 @@ namespace slideshow
|
|||||||
basegfx::B2DHomMatrix aTransform;
|
basegfx::B2DHomMatrix aTransform;
|
||||||
pCanvas->setTransformation( aTransform /* empty */ );
|
pCanvas->setTransformation( aTransform /* empty */ );
|
||||||
|
|
||||||
|
|
||||||
|
::cppcanvas::Canvas* pTmpCanvas = pCanvas.get();
|
||||||
comphelper::ScopeGuard const resetOldTransformation(
|
comphelper::ScopeGuard const resetOldTransformation(
|
||||||
boost::bind( &cppcanvas::Canvas::setTransformation,
|
[&aOldTransform, &pTmpCanvas]()
|
||||||
pCanvas.get(),
|
{ return pTmpCanvas->setTransformation( aOldTransform ); } );
|
||||||
boost::cref(aOldTransform) ));
|
|
||||||
|
|
||||||
aTransform.scale( maBounds.getWidth(),
|
aTransform.scale( maBounds.getWidth(),
|
||||||
maBounds.getHeight() );
|
maBounds.getHeight() );
|
||||||
@@ -1022,19 +980,20 @@ namespace slideshow
|
|||||||
// slide-absolute position
|
// slide-absolute position
|
||||||
|
|
||||||
HyperlinkRegions aTranslatedRegions;
|
HyperlinkRegions aTranslatedRegions;
|
||||||
|
|
||||||
|
// increase capacity to same size as the container for
|
||||||
|
// shape-relative hyperlink regions to avoid reallocation
|
||||||
|
aTranslatedRegions.reserve( maHyperlinkRegions.size() );
|
||||||
const basegfx::B2DPoint& rOffset(getBounds().getMinimum());
|
const basegfx::B2DPoint& rOffset(getBounds().getMinimum());
|
||||||
HyperlinkRegions::const_iterator aIter( maHyperlinkRegions.begin() );
|
for( const auto& cp : maHyperlinkRegions )
|
||||||
HyperlinkRegions::const_iterator const aEnd ( maHyperlinkRegions.end() );
|
|
||||||
while( aIter != aEnd )
|
|
||||||
{
|
{
|
||||||
basegfx::B2DRange const& relRegion( aIter->first );
|
basegfx::B2DRange const& relRegion( cp.first );
|
||||||
aTranslatedRegions.push_back(
|
aTranslatedRegions.push_back(
|
||||||
std::make_pair(
|
std::make_pair(
|
||||||
basegfx::B2DRange(
|
basegfx::B2DRange(
|
||||||
relRegion.getMinimum() + rOffset,
|
relRegion.getMinimum() + rOffset,
|
||||||
relRegion.getMaximum() + rOffset),
|
relRegion.getMaximum() + rOffset),
|
||||||
aIter->second) );
|
cp.second) );
|
||||||
++aIter;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return aTranslatedRegions;
|
return aTranslatedRegions;
|
||||||
@@ -1058,9 +1017,8 @@ namespace slideshow
|
|||||||
{
|
{
|
||||||
// notify all ViewShapes, by calling their enterAnimationMode method.
|
// notify all ViewShapes, by calling their enterAnimationMode method.
|
||||||
// We're now entering animation mode
|
// We're now entering animation mode
|
||||||
::std::for_each( maViewShapes.begin(),
|
for( const auto& rViewShape : maViewShapes )
|
||||||
maViewShapes.end(),
|
rViewShape->enterAnimationMode();
|
||||||
::boost::mem_fn( &ViewShape::enterAnimationMode ) );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
++mnIsAnimatedCount;
|
++mnIsAnimatedCount;
|
||||||
@@ -1077,9 +1035,8 @@ namespace slideshow
|
|||||||
{
|
{
|
||||||
// notify all ViewShapes, by calling their leaveAnimationMode method.
|
// notify all ViewShapes, by calling their leaveAnimationMode method.
|
||||||
// we're now leaving animation mode
|
// we're now leaving animation mode
|
||||||
::std::for_each( maViewShapes.begin(),
|
for( const auto& rViewShape : maViewShapes )
|
||||||
maViewShapes.end(),
|
rViewShape->leaveAnimationMode();
|
||||||
::boost::mem_fn( &ViewShape::leaveAnimationMode ) );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -29,8 +29,6 @@
|
|||||||
#include "drawshapesubsetting.hxx"
|
#include "drawshapesubsetting.hxx"
|
||||||
#include "drawshape.hxx"
|
#include "drawshape.hxx"
|
||||||
|
|
||||||
#include <boost/bind.hpp>
|
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <functional>
|
#include <functional>
|
||||||
#include <limits>
|
#include <limits>
|
||||||
@@ -400,11 +398,8 @@ namespace slideshow
|
|||||||
// the whole shape set
|
// the whole shape set
|
||||||
|
|
||||||
// determine new subset range
|
// determine new subset range
|
||||||
::std::for_each( maSubsetShapes.begin(),
|
for( const auto& pShape : maSubsetShapes )
|
||||||
maSubsetShapes.end(),
|
updateSubsetBounds( pShape );
|
||||||
::boost::bind(&DrawShapeSubsetting::updateSubsetBounds,
|
|
||||||
this,
|
|
||||||
_1 ) );
|
|
||||||
|
|
||||||
updateSubsets();
|
updateSubsets();
|
||||||
|
|
||||||
|
@@ -29,7 +29,6 @@
|
|||||||
#include "shape.hxx"
|
#include "shape.hxx"
|
||||||
#include "tools.hxx"
|
#include "tools.hxx"
|
||||||
|
|
||||||
#include <boost/bind.hpp>
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
|
|
||||||
@@ -105,29 +104,21 @@ namespace slideshow
|
|||||||
|
|
||||||
void MediaShape::implViewChanged( const UnoViewSharedPtr& rView )
|
void MediaShape::implViewChanged( const UnoViewSharedPtr& rView )
|
||||||
{
|
{
|
||||||
|
const ::basegfx::B2DRectangle& rBounds = getBounds();
|
||||||
// determine ViewMediaShape that needs update
|
// determine ViewMediaShape that needs update
|
||||||
ViewMediaShapeVector::const_iterator aIter(maViewMediaShapes.begin());
|
for( const auto& pViewMediaShape : maViewMediaShapes )
|
||||||
ViewMediaShapeVector::const_iterator const aEnd (maViewMediaShapes.end());
|
if( pViewMediaShape->getViewLayer()->isOnView( rView ) )
|
||||||
while( aIter != aEnd )
|
pViewMediaShape->resize( rBounds );
|
||||||
{
|
|
||||||
if( (*aIter)->getViewLayer()->isOnView(rView) )
|
|
||||||
(*aIter)->resize(getBounds());
|
|
||||||
|
|
||||||
++aIter;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void MediaShape::implViewsChanged()
|
void MediaShape::implViewsChanged()
|
||||||
{
|
{
|
||||||
|
const ::basegfx::B2DRectangle& rBounds = getBounds();
|
||||||
// resize all ViewShapes
|
// resize all ViewShapes
|
||||||
::std::for_each( maViewMediaShapes.begin(),
|
for( const auto& pViewMediaShape : maViewMediaShapes )
|
||||||
maViewMediaShapes.end(),
|
pViewMediaShape->resize( rBounds );
|
||||||
::boost::bind(
|
|
||||||
&ViewMediaShape::resize,
|
|
||||||
_1,
|
|
||||||
getBounds()) );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -156,21 +147,18 @@ namespace slideshow
|
|||||||
|
|
||||||
OSL_ENSURE( ::std::count_if(maViewMediaShapes.begin(),
|
OSL_ENSURE( ::std::count_if(maViewMediaShapes.begin(),
|
||||||
aEnd,
|
aEnd,
|
||||||
::boost::bind<bool>(
|
[&rLayer]
|
||||||
::std::equal_to< ViewLayerSharedPtr >(),
|
( const ViewMediaShapeSharedPtr& pShape )
|
||||||
::boost::bind( &ViewMediaShape::getViewLayer, _1 ),
|
{ return rLayer == pShape->getViewLayer(); } ) < 2,
|
||||||
::boost::cref( rLayer ) ) ) < 2,
|
|
||||||
"MediaShape::removeViewLayer(): Duplicate ViewLayer entries!" );
|
"MediaShape::removeViewLayer(): Duplicate ViewLayer entries!" );
|
||||||
|
|
||||||
ViewMediaShapeVector::iterator aIter;
|
ViewMediaShapeVector::iterator aIter;
|
||||||
|
|
||||||
if( (aIter=::std::remove_if( maViewMediaShapes.begin(),
|
if( (aIter=::std::remove_if( maViewMediaShapes.begin(),
|
||||||
aEnd,
|
aEnd,
|
||||||
::boost::bind<bool>(
|
[&rLayer]
|
||||||
::std::equal_to< ViewLayerSharedPtr >(),
|
( const ViewMediaShapeSharedPtr& pShape )
|
||||||
::boost::bind( &ViewMediaShape::getViewLayer,
|
{ return rLayer == pShape->getViewLayer(); } ) ) == aEnd )
|
||||||
_1 ),
|
|
||||||
::boost::cref( rLayer ) ) )) == aEnd )
|
|
||||||
{
|
{
|
||||||
// view layer seemingly was not added, failed
|
// view layer seemingly was not added, failed
|
||||||
return false;
|
return false;
|
||||||
@@ -197,10 +185,9 @@ namespace slideshow
|
|||||||
// redraw all view shapes, by calling their update() method
|
// redraw all view shapes, by calling their update() method
|
||||||
if( ::std::count_if( maViewMediaShapes.begin(),
|
if( ::std::count_if( maViewMediaShapes.begin(),
|
||||||
maViewMediaShapes.end(),
|
maViewMediaShapes.end(),
|
||||||
::boost::bind<bool>(
|
[&rCurrBounds]
|
||||||
::boost::mem_fn( &ViewMediaShape::render ),
|
( const ViewMediaShapeSharedPtr& pShape )
|
||||||
_1,
|
{ return pShape->render( rCurrBounds ); } )
|
||||||
::boost::cref( rCurrBounds ) ) )
|
|
||||||
!= static_cast<ViewMediaShapeVector::difference_type>(maViewMediaShapes.size()) )
|
!= static_cast<ViewMediaShapeVector::difference_type>(maViewMediaShapes.size()) )
|
||||||
{
|
{
|
||||||
// at least one of the ViewShape::update() calls did return
|
// at least one of the ViewShape::update() calls did return
|
||||||
@@ -215,9 +202,8 @@ namespace slideshow
|
|||||||
|
|
||||||
bool MediaShape::implStartIntrinsicAnimation()
|
bool MediaShape::implStartIntrinsicAnimation()
|
||||||
{
|
{
|
||||||
::std::for_each( maViewMediaShapes.begin(),
|
for( const auto& pViewMediaShape : maViewMediaShapes )
|
||||||
maViewMediaShapes.end(),
|
pViewMediaShape->startMedia();
|
||||||
::boost::mem_fn( &ViewMediaShape::startMedia ) );
|
|
||||||
|
|
||||||
mbIsPlaying = true;
|
mbIsPlaying = true;
|
||||||
|
|
||||||
@@ -228,9 +214,8 @@ namespace slideshow
|
|||||||
|
|
||||||
bool MediaShape::implEndIntrinsicAnimation()
|
bool MediaShape::implEndIntrinsicAnimation()
|
||||||
{
|
{
|
||||||
::std::for_each( maViewMediaShapes.begin(),
|
for( const auto& pViewMediaShape : maViewMediaShapes )
|
||||||
maViewMediaShapes.end(),
|
pViewMediaShape->endMedia();
|
||||||
::boost::mem_fn( &ViewMediaShape::endMedia ) );
|
|
||||||
|
|
||||||
mbIsPlaying = false;
|
mbIsPlaying = false;
|
||||||
|
|
||||||
@@ -241,9 +226,8 @@ namespace slideshow
|
|||||||
|
|
||||||
bool MediaShape::implPauseIntrinsicAnimation()
|
bool MediaShape::implPauseIntrinsicAnimation()
|
||||||
{
|
{
|
||||||
::std::for_each( maViewMediaShapes.begin(),
|
for( const auto& pViewMediaShape : maViewMediaShapes )
|
||||||
maViewMediaShapes.end(),
|
pViewMediaShape->pauseMedia();
|
||||||
::boost::mem_fn( &ViewMediaShape::pauseMedia ) );
|
|
||||||
|
|
||||||
mbIsPlaying = false;
|
mbIsPlaying = false;
|
||||||
|
|
||||||
@@ -261,10 +245,8 @@ namespace slideshow
|
|||||||
|
|
||||||
void MediaShape::implSetIntrinsicAnimationTime(double fTime)
|
void MediaShape::implSetIntrinsicAnimationTime(double fTime)
|
||||||
{
|
{
|
||||||
::std::for_each( maViewMediaShapes.begin(),
|
for( const auto& pViewMediaShape : maViewMediaShapes )
|
||||||
maViewMediaShapes.end(),
|
pViewMediaShape->setMediaTime( fTime );
|
||||||
::boost::bind( &ViewMediaShape::setMediaTime,
|
|
||||||
_1, boost::cref(fTime)) );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user