[Libreoffice-commits] core.git: Branch 'libreoffice-5-4' - include/svx sc/source svx/source

Noel Grandin noelgrandin at gmail.com
Wed Apr 4 09:04:08 UTC 2018


 include/svx/sdr/animation/scheduler.hxx            |   13 ++-----
 include/svx/sdr/overlay/overlaymanager.hxx         |    2 -
 sc/source/ui/view/overlayobject.cxx                |    2 -
 svx/source/sdr/animation/animationstate.cxx        |    2 -
 svx/source/sdr/animation/scheduler.cxx             |   37 +++++++++------------
 svx/source/sdr/overlay/overlayanimatedbitmapex.cxx |    2 -
 svx/source/sdr/overlay/overlayrectangle.cxx        |    2 -
 7 files changed, 26 insertions(+), 34 deletions(-)

New commits:
commit 09ba4f15ec88b820fed66be339170da2fbbf11dd
Author: Noel Grandin <noelgrandin at gmail.com>
Date:   Sun Mar 25 15:23:47 2018 +0200

    tdf#112997 multiple animated gif only one frame
    
    Not sure what the problem is, but using a vector and just making sure
    we insert into the right spot for the sorting fixes it.
    
    Change-Id: I11c08e08a14c98ba7eb6a5d925c75bab891ecf63
    Reviewed-on: https://gerrit.libreoffice.org/51829
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>
    Tested-by: Noel Grandin <noel.grandin at collabora.co.uk>
    (cherry picked from commit d312ff2b52c0ea2e2864518a36f6b432653c8297)
    Reviewed-on: https://gerrit.libreoffice.org/52010
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>
    Tested-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/include/svx/sdr/animation/scheduler.hxx b/include/svx/sdr/animation/scheduler.hxx
index 15eaa344b9d6..1ab5c7a92237 100644
--- a/include/svx/sdr/animation/scheduler.hxx
+++ b/include/svx/sdr/animation/scheduler.hxx
@@ -23,7 +23,7 @@
 #include <sal/types.h>
 #include <vcl/timer.hxx>
 #include <svx/svxdllapi.h>
-#include <o3tl/sorted_vector.hxx>
+#include <vector>
 
 
 namespace sdr
@@ -49,11 +49,6 @@ namespace sdr
             virtual void Trigger(sal_uInt32 nTime) = 0;
         };
 
-        struct CompareEvent
-        {
-            bool operator()(Event* const& lhs, Event* const& rhs) const;
-        };
-
         class SVX_DLLPUBLIC Scheduler : public Timer
         {
             // time in ms
@@ -62,8 +57,8 @@ namespace sdr
             // next delta time
             sal_uInt32                                      mnDeltaTime;
 
-            // list of events
-            o3tl::sorted_vector<Event*, CompareEvent>       maList;
+            // list of events, sorted by time
+            std::vector<Event*>                             mvEvents;
 
             // Flag which remembers if this timer is paused. Default
             // is false.
@@ -90,7 +85,7 @@ namespace sdr
             SAL_DLLPRIVATE void checkTimeout();
 
             // insert/remove events, wrapper to EventList methods
-            void InsertEvent(Event* pNew);
+            void InsertEvent(Event& rNew);
             SAL_DLLPRIVATE void RemoveEvent(Event* pOld);
 
             // get/set pause
diff --git a/include/svx/sdr/overlay/overlaymanager.hxx b/include/svx/sdr/overlay/overlaymanager.hxx
index 47ccf96ec19f..698e5c2f18e3 100644
--- a/include/svx/sdr/overlay/overlaymanager.hxx
+++ b/include/svx/sdr/overlay/overlaymanager.hxx
@@ -131,7 +131,7 @@ namespace sdr
             // access to maDrawinglayerOpt
             const SvtOptionsDrawinglayer& getDrawinglayerOpt() const { return maDrawinglayerOpt; }
 
-            void InsertEvent(sdr::animation::Event* pNew) { Scheduler::InsertEvent(pNew); }
+            void InsertEvent(sdr::animation::Event& rNew) { Scheduler::InsertEvent(rNew); }
         };
     } // end of namespace overlay
 } // end of namespace sdr
diff --git a/sc/source/ui/view/overlayobject.cxx b/sc/source/ui/view/overlayobject.cxx
index cc688f4301e0..9aa60e932f1f 100644
--- a/sc/source/ui/view/overlayobject.cxx
+++ b/sc/source/ui/view/overlayobject.cxx
@@ -53,7 +53,7 @@ void ScOverlayDashedBorder::Trigger(sal_uInt32 nTime)
     {
         SetTime(nTime + DASH_UPDATE_INTERVAL);
         mbToggle = !mbToggle;
-        pMgr->InsertEvent(this);
+        pMgr->InsertEvent(*this);
         objectChange();
     }
 }
diff --git a/svx/source/sdr/animation/animationstate.cxx b/svx/source/sdr/animation/animationstate.cxx
index 85b94a664000..b0a3a6dc8830 100644
--- a/svx/source/sdr/animation/animationstate.cxx
+++ b/svx/source/sdr/animation/animationstate.cxx
@@ -102,7 +102,7 @@ namespace sdr
 
                 // set time and reactivate by re-adding to the scheduler
                 SetTime(nNextTime);
-                mrVOContact.GetObjectContact().getPrimitiveAnimator().InsertEvent(this);
+                mrVOContact.GetObjectContact().getPrimitiveAnimator().InsertEvent(*this);
             }
         }
 
diff --git a/svx/source/sdr/animation/scheduler.cxx b/svx/source/sdr/animation/scheduler.cxx
index 9936dfdb4be6..9446ede19271 100644
--- a/svx/source/sdr/animation/scheduler.cxx
+++ b/svx/source/sdr/animation/scheduler.cxx
@@ -19,6 +19,7 @@
 
 #include <svx/sdr/animation/scheduler.hxx>
 
+#include <algorithm>
 #include <vector>
 
 
@@ -45,12 +46,6 @@ namespace sdr
             }
         }
 
-        bool CompareEvent::operator()(Event* const& lhs, Event* const& rhs) const
-        {
-            return lhs->GetTime() < rhs->GetTime();
-        }
-
-
         Scheduler::Scheduler()
         :   mnTime(0L),
             mnDeltaTime(0L),
@@ -78,17 +73,17 @@ namespace sdr
 
         void Scheduler::triggerEvents()
         {
-            if (maList.empty())
+            if (mvEvents.empty())
                 return;
 
             // copy events which need to be executed to a vector. Remove them from
             // the scheduler
             ::std::vector< Event* > aToBeExecutedList;
 
-            while(!maList.empty() && maList[0]->GetTime() <= mnTime)
+            while(!mvEvents.empty() && mvEvents.front()->GetTime() <= mnTime)
             {
-                Event* pNextEvent = maList.front();
-                maList.erase(maList.begin());
+                Event* pNextEvent = mvEvents.front();
+                mvEvents.erase(mvEvents.begin());
                 aToBeExecutedList.push_back(pNextEvent);
             }
 
@@ -105,9 +100,9 @@ namespace sdr
         void Scheduler::checkTimeout()
         {
             // re-start or stop timer according to event list
-            if(!IsPaused() && !maList.empty())
+            if(!IsPaused() && !mvEvents.empty())
             {
-                mnDeltaTime = maList.front()->GetTime() - mnTime;
+                mnDeltaTime = mvEvents.front()->GetTime() - mnTime;
 
                 if(0L != mnDeltaTime)
                 {
@@ -129,11 +124,11 @@ namespace sdr
             Stop();
             mnTime = nTime;
 
-            if (maList.empty())
+            if (mvEvents.empty())
                 return;
 
             // reset event time points
-            for (auto & rEvent : maList)
+            for (auto & rEvent : mvEvents)
             {
                 rEvent->SetTime(nTime);
             }
@@ -148,19 +143,21 @@ namespace sdr
              }
         }
 
-        void Scheduler::InsertEvent(Event* pNew)
+        void Scheduler::InsertEvent(Event& rNew)
         {
-            maList.insert(pNew);
+            // insert maintaining time ordering
+            auto it = mvEvents.begin();
+            while (it != mvEvents.end() && rNew.GetTime() >= (*it)->GetTime())
+                it++;
+            mvEvents.insert(it, &rNew);
             checkTimeout();
         }
 
         void Scheduler::RemoveEvent(Event* pOld)
         {
-            if(!maList.empty())
+            if(!mvEvents.empty())
             {
-                auto it = maList.find(pOld);
-                if (it != maList.end())
-                    maList.erase(it);
+                mvEvents.erase(std::remove(mvEvents.begin(), mvEvents.end(), pOld), mvEvents.end());
                 checkTimeout();
             }
         }
diff --git a/svx/source/sdr/overlay/overlayanimatedbitmapex.cxx b/svx/source/sdr/overlay/overlayanimatedbitmapex.cxx
index 46ff77d897ce..ef23e626f07e 100644
--- a/svx/source/sdr/overlay/overlayanimatedbitmapex.cxx
+++ b/svx/source/sdr/overlay/overlayanimatedbitmapex.cxx
@@ -105,7 +105,7 @@ namespace sdr
                 }
 
                 // re-insert me as event
-                getOverlayManager()->InsertEvent(this);
+                getOverlayManager()->InsertEvent(*this);
 
                 // register change (after change)
                 objectChange();
diff --git a/svx/source/sdr/overlay/overlayrectangle.cxx b/svx/source/sdr/overlay/overlayrectangle.cxx
index 7c72884205c0..8561d3f306cc 100644
--- a/svx/source/sdr/overlay/overlayrectangle.cxx
+++ b/svx/source/sdr/overlay/overlayrectangle.cxx
@@ -108,7 +108,7 @@ namespace sdr
                 }
 
                 // re-insert me as event
-                getOverlayManager()->InsertEvent(this);
+                getOverlayManager()->InsertEvent(*this);
 
                 // register change (after change)
                 objectChange();


More information about the Libreoffice-commits mailing list