[Libreoffice-commits] core.git: sd/inc sd/source

Julien Nabet serval2412 at yahoo.fr
Sun Nov 12 07:53:33 UTC 2017


 sd/inc/CustomAnimationEffect.hxx                |    7 +-
 sd/source/core/CustomAnimationEffect.cxx        |   71 ++++++++++--------------
 sd/source/ui/animations/CustomAnimationList.cxx |    8 +-
 sd/source/ui/animations/CustomAnimationPane.cxx |   12 +---
 4 files changed, 43 insertions(+), 55 deletions(-)

New commits:
commit 582182ad2ad9c399fd41bff2446507eb954730f7
Author: Julien Nabet <serval2412 at yahoo.fr>
Date:   Sat Nov 11 21:07:56 2017 +0100

    Replace list by vector for InteractiveSequence (sd)
    
    + use for range loops (there's still work about this)
    
    Change-Id: Ib1d1584f3f4456dfa79834f89c51b4528b776096
    Reviewed-on: https://gerrit.libreoffice.org/44642
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Julien Nabet <serval2412 at yahoo.fr>

diff --git a/sd/inc/CustomAnimationEffect.hxx b/sd/inc/CustomAnimationEffect.hxx
index e54644d13158..6322d365b293 100644
--- a/sd/inc/CustomAnimationEffect.hxx
+++ b/sd/inc/CustomAnimationEffect.hxx
@@ -31,6 +31,7 @@
 #include "sddllapi.h"
 
 #include <list>
+#include <vector>
 #include <map>
 #include <memory>
 
@@ -362,7 +363,7 @@ private:
 };
 
 typedef std::shared_ptr< InteractiveSequence > InteractiveSequencePtr;
-typedef std::list< InteractiveSequencePtr > InteractiveSequenceList;
+typedef std::vector< InteractiveSequencePtr > InteractiveSequenceVector;
 
 class MainSequence : public EffectSequenceHelper, public ISequenceListener
 {
@@ -389,7 +390,7 @@ public:
     virtual bool hasEffect( const css::uno::Reference< css::drawing::XShape >& xShape ) override;
     virtual void onTextChanged( const css::uno::Reference< css::drawing::XShape >& xShape ) override;
 
-    const InteractiveSequenceList& getInteractiveSequenceList() const { return maInteractiveSequenceList; }
+    const InteractiveSequenceVector& getInteractiveSequenceVector() const { return maInteractiveSequenceVector; }
 
     virtual void notify_change() override;
 
@@ -421,7 +422,7 @@ protected:
 
     InteractiveSequencePtr createInteractiveSequence( const css::uno::Reference< css::drawing::XShape >& xShape );
 
-    InteractiveSequenceList maInteractiveSequenceList;
+    InteractiveSequenceVector maInteractiveSequenceVector;
 
     css::uno::Reference< css::util::XChangesListener > mxChangesListener;
     css::uno::Reference< css::animations::XTimeContainer > mxTimingRootNode;
diff --git a/sd/source/core/CustomAnimationEffect.cxx b/sd/source/core/CustomAnimationEffect.cxx
index 33c7f895025d..1d6fe19dec82 100644
--- a/sd/source/core/CustomAnimationEffect.cxx
+++ b/sd/source/core/CustomAnimationEffect.cxx
@@ -3009,7 +3009,7 @@ void MainSequence::createMainSequence()
                 Reference< XTimeContainer > xInteractiveRoot( xChildNode, UNO_QUERY_THROW );
                 InteractiveSequencePtr pIS( new InteractiveSequence( xInteractiveRoot, this ) );
                 pIS->addListener( this );
-                maInteractiveSequenceList.push_back( pIS );
+                maInteractiveSequenceVector.push_back( pIS );
             }
         }
 
@@ -3052,10 +3052,9 @@ void MainSequence::reset()
 {
     EffectSequenceHelper::reset();
 
-    InteractiveSequenceList::iterator aIter;
-    for( aIter = maInteractiveSequenceList.begin(); aIter != maInteractiveSequenceList.end(); ++aIter )
-        (*aIter)->reset();
-    maInteractiveSequenceList.clear();
+    for (auto const& interactiveSequence : maInteractiveSequenceVector)
+        interactiveSequence->reset();
+    maInteractiveSequenceVector.clear();
 
     try
     {
@@ -3087,7 +3086,7 @@ InteractiveSequencePtr MainSequence::createInteractiveSequence( const css::uno::
     pIS.reset( new InteractiveSequence( xISRoot, this) );
     pIS->setTriggerShape( xShape );
     pIS->addListener( this );
-    maInteractiveSequenceList.push_back( pIS );
+    maInteractiveSequenceVector.push_back( pIS );
     return pIS;
 }
 
@@ -3097,10 +3096,11 @@ CustomAnimationEffectPtr MainSequence::findEffect( const css::uno::Reference< cs
 
     if( pEffect.get() == nullptr )
     {
-        InteractiveSequenceList::const_iterator aIter;
-        for( aIter = maInteractiveSequenceList.begin(); (aIter != maInteractiveSequenceList.end()) && (pEffect.get() == nullptr); ++aIter )
+        for (auto const& interactiveSequence : maInteractiveSequenceVector)
         {
-            pEffect = (*aIter)->findEffect( xNode );
+            pEffect = interactiveSequence->findEffect( xNode );
+            if (pEffect.get())
+                break;
         }
     }
     return pEffect;
@@ -3115,14 +3115,13 @@ sal_Int32 MainSequence::getOffsetFromEffect( const CustomAnimationEffectPtr& pEf
 
     nOffset = EffectSequenceHelper::getCount();
 
-    InteractiveSequenceList::const_iterator aIter;
-    for( aIter = maInteractiveSequenceList.begin(); aIter != maInteractiveSequenceList.end(); ++aIter )
+    for (auto const& interactiveSequence : maInteractiveSequenceVector)
     {
-        sal_Int32 nTemp = (*aIter)->getOffsetFromEffect( pEffect );
+        sal_Int32 nTemp = interactiveSequence->getOffsetFromEffect( pEffect );
         if( nTemp != -1 )
             return nOffset + nTemp;
 
-        nOffset += (*aIter)->getCount();
+        nOffset += interactiveSequence->getCount();
     }
 
     return -1;
@@ -3137,12 +3136,12 @@ CustomAnimationEffectPtr MainSequence::getEffectFromOffset( sal_Int32 nOffset )
 
         nOffset -= getCount();
 
-        InteractiveSequenceList::const_iterator aIter( maInteractiveSequenceList.begin() );
+        auto aIter( maInteractiveSequenceVector.begin() );
 
-        while( (aIter != maInteractiveSequenceList.end()) && (nOffset > (*aIter)->getCount()) )
+        while( (aIter != maInteractiveSequenceVector.end()) && (nOffset > (*aIter)->getCount()) )
             nOffset -= (*aIter++)->getCount();
 
-        if( (aIter != maInteractiveSequenceList.end()) && (nOffset >= 0) )
+        if( (aIter != maInteractiveSequenceVector.end()) && (nOffset >= 0) )
             return (*aIter)->getEffectFromOffset( nOffset );
     }
 
@@ -3154,10 +3153,9 @@ bool MainSequence::disposeShape( const Reference< XShape >& xShape )
 {
     bool bChanges = EffectSequenceHelper::disposeShape( xShape );
 
-    InteractiveSequenceList::iterator aIter;
-    for( aIter = maInteractiveSequenceList.begin(); aIter != maInteractiveSequenceList.end();  )
+    for (auto const& iterativeSequence : maInteractiveSequenceVector)
     {
-            bChanges |= (*aIter++)->disposeShape( xShape );
+            bChanges |= iterativeSequence->disposeShape( xShape );
     }
 
     if( bChanges )
@@ -3171,13 +3169,12 @@ bool MainSequence::hasEffect( const css::uno::Reference< css::drawing::XShape >&
     if( EffectSequenceHelper::hasEffect( xShape ) )
         return true;
 
-    InteractiveSequenceList::iterator aIter;
-    for( aIter = maInteractiveSequenceList.begin(); aIter != maInteractiveSequenceList.end();  )
+    for (auto const& iterativeSequence : maInteractiveSequenceVector)
     {
-        if( (*aIter)->getTriggerShape() == xShape )
+        if( iterativeSequence->getTriggerShape() == xShape )
             return true;
 
-        if( (*aIter++)->hasEffect( xShape ) )
+        if( iterativeSequence->hasEffect( xShape ) )
             return true;
     }
 
@@ -3188,10 +3185,9 @@ void MainSequence::insertTextRange( const css::uno::Any& aTarget )
 {
     EffectSequenceHelper::insertTextRange( aTarget );
 
-    InteractiveSequenceList::iterator aIter;
-    for( aIter = maInteractiveSequenceList.begin(); aIter != maInteractiveSequenceList.end(); ++aIter )
+    for (auto const& iterativeSequence : maInteractiveSequenceVector)
     {
-        (*aIter)->insertTextRange( aTarget );
+        iterativeSequence->insertTextRange( aTarget );
     }
 }
 
@@ -3199,10 +3195,9 @@ void MainSequence::disposeTextRange( const css::uno::Any& aTarget )
 {
     EffectSequenceHelper::disposeTextRange( aTarget );
 
-    InteractiveSequenceList::iterator aIter;
-    for( aIter = maInteractiveSequenceList.begin(); aIter != maInteractiveSequenceList.end(); ++aIter )
+    for (auto const& iterativeSequence : maInteractiveSequenceVector)
     {
-        (*aIter)->disposeTextRange( aTarget );
+        iterativeSequence->disposeTextRange( aTarget );
     }
 }
 
@@ -3211,10 +3206,9 @@ void MainSequence::onTextChanged( const Reference< XShape >& xShape )
 {
     EffectSequenceHelper::onTextChanged( xShape );
 
-    InteractiveSequenceList::iterator aIter;
-    for( aIter = maInteractiveSequenceList.begin(); aIter != maInteractiveSequenceList.end(); ++aIter )
+    for (auto const& iterativeSequence : maInteractiveSequenceVector)
     {
-        (*aIter)->onTextChanged( xShape );
+        iterativeSequence->onTextChanged( xShape );
     }
 }
 
@@ -3268,15 +3262,14 @@ void MainSequence::implRebuild()
 
     EffectSequenceHelper::implRebuild();
 
-    InteractiveSequenceList::iterator aIter( maInteractiveSequenceList.begin() );
-    const InteractiveSequenceList::iterator aEnd( maInteractiveSequenceList.end() );
-    while( aIter != aEnd )
+    auto aIter( maInteractiveSequenceVector.begin() );
+    while( aIter != maInteractiveSequenceVector.end() )
     {
         InteractiveSequencePtr pIS( (*aIter) );
         if( pIS->maEffects.empty() )
         {
             // remove empty interactive sequences
-            aIter = maInteractiveSequenceList.erase( aIter );
+            aIter = maInteractiveSequenceVector.erase( aIter );
 
             Reference< XChild > xChild( mxSequenceRoot, UNO_QUERY_THROW );
             Reference< XTimeContainer > xParent( xChild->getParent(), UNO_QUERY_THROW );
@@ -3306,11 +3299,9 @@ bool MainSequence::setTrigger( const CustomAnimationEffectPtr& pEffect, const cs
     EffectSequenceHelper* pNewSequence = nullptr;
     if( xTriggerShape.is() )
     {
-        InteractiveSequenceList::iterator aIter( maInteractiveSequenceList.begin() );
-        const InteractiveSequenceList::iterator aEnd( maInteractiveSequenceList.end() );
-        while( aIter != aEnd )
+        for (auto const& iteractiveSequence : maInteractiveSequenceVector)
         {
-            InteractiveSequencePtr pIS( (*aIter++) );
+            InteractiveSequencePtr pIS(iteractiveSequence);
             if( pIS->getTriggerShape() == xTriggerShape )
             {
                 pNewSequence = pIS.get();
diff --git a/sd/source/ui/animations/CustomAnimationList.cxx b/sd/source/ui/animations/CustomAnimationList.cxx
index 981b61e36470..58d6d6b475b1 100644
--- a/sd/source/ui/animations/CustomAnimationList.cxx
+++ b/sd/source/ui/animations/CustomAnimationList.cxx
@@ -619,13 +619,11 @@ void CustomAnimationList::update()
         std::for_each( mpMainSequence->getBegin(), mpMainSequence->getEnd(), stl_append_effect_func( *this ) );
         mpLastParentEntry = nullptr;
 
-        const InteractiveSequenceList& rISL = mpMainSequence->getInteractiveSequenceList();
+        auto rInteractiveSequenceVector = mpMainSequence->getInteractiveSequenceVector();
 
-        InteractiveSequenceList::const_iterator aIter( rISL.begin() );
-        const InteractiveSequenceList::const_iterator aEnd( rISL.end() );
-        while( aIter != aEnd )
+        for (auto const& interactiveSequence : rInteractiveSequenceVector)
         {
-            InteractiveSequencePtr pIS( (*aIter++) );
+            InteractiveSequencePtr pIS( interactiveSequence );
 
             Reference< XShape > xShape( pIS->getTriggerShape() );
             if( xShape.is() )
diff --git a/sd/source/ui/animations/CustomAnimationPane.cxx b/sd/source/ui/animations/CustomAnimationPane.cxx
index aa74265556f3..c00aedf6c607 100644
--- a/sd/source/ui/animations/CustomAnimationPane.cxx
+++ b/sd/source/ui/animations/CustomAnimationPane.cxx
@@ -259,9 +259,8 @@ void CustomAnimationPane::dispose()
 
     MotionPathTagVector aTags;
     aTags.swap( maMotionPathTags );
-    MotionPathTagVector::iterator aIter;
-    for( aIter = aTags.begin(); aIter != aTags.end(); ++aIter )
-        (*aIter)->Dispose();
+    for (auto const& tag : aTags)
+        tag->Dispose();
 
     mpPBAddEffect.clear();
     mpPBRemoveEffect.clear();
@@ -828,11 +827,10 @@ void CustomAnimationPane::updateMotionPathTags()
     {
         bChanges = updateMotionPathImpl( *this, *pView, mpMainSequence->getBegin(), mpMainSequence->getEnd(), aTags, maMotionPathTags );
 
-        const InteractiveSequenceList& rISL = mpMainSequence->getInteractiveSequenceList();
-        InteractiveSequenceList::const_iterator aISI( rISL.begin() );
-        while( aISI != rISL.end() )
+        auto rInteractiveSequenceVector = mpMainSequence->getInteractiveSequenceVector();
+        for (auto const& interactiveSequence : rInteractiveSequenceVector)
         {
-            InteractiveSequencePtr pIS( (*aISI++) );
+            InteractiveSequencePtr pIS(interactiveSequence);
             bChanges |= updateMotionPathImpl( *this, *pView, pIS->getBegin(), pIS->getEnd(), aTags, maMotionPathTags );
         }
     }


More information about the Libreoffice-commits mailing list