LCOV - code coverage report
Current view: top level - svx/source/sdr/animation - animationstate.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 0 41 0.0 %
Date: 2014-11-03 Functions: 0 6 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : #include <svx/sdr/animation/animationstate.hxx>
      21             : #include <svx/sdr/contact/viewobjectcontact.hxx>
      22             : #include <svx/sdr/animation/objectanimator.hxx>
      23             : #include <svx/sdr/contact/objectcontact.hxx>
      24             : #include <svx/sdr/contact/viewcontact.hxx>
      25             : #include <drawinglayer/primitive2d/animatedprimitive2d.hxx>
      26             : #include <drawinglayer/animation/animationtiming.hxx>
      27             : 
      28             : 
      29             : 
      30             : namespace sdr
      31             : {
      32             :     namespace animation
      33             :     {
      34           0 :         double PrimitiveAnimation::getSmallestNextTime(double fCurrentTime)
      35             :         {
      36           0 :             double fRetval(0.0);
      37             : 
      38           0 :             if(maAnimatedPrimitives.hasElements())
      39             :             {
      40           0 :                 const sal_Int32 nCount(maAnimatedPrimitives.getLength());
      41             : 
      42           0 :                 for(sal_Int32 a(0L); a < nCount; a++)
      43             :                 {
      44           0 :                     const drawinglayer::primitive2d::Primitive2DReference xRef(maAnimatedPrimitives[a]);
      45           0 :                     const drawinglayer::primitive2d::AnimatedSwitchPrimitive2D* pCandidate = dynamic_cast< const drawinglayer::primitive2d::AnimatedSwitchPrimitive2D* >(xRef.get());
      46             :                     OSL_ENSURE(pCandidate, "PrimitiveAnimation::getSmallestNextTime: wrong primitive in animated list (!)");
      47             : 
      48           0 :                     if(pCandidate)
      49             :                     {
      50           0 :                         const drawinglayer::animation::AnimationEntry& rAnimEntry = pCandidate->getAnimationEntry();
      51           0 :                         const double fNextTime(rAnimEntry.getNextEventTime(fCurrentTime));
      52             : 
      53           0 :                         if(!::basegfx::fTools::equalZero(fNextTime))
      54             :                         {
      55           0 :                             if(::basegfx::fTools::equalZero(fRetval))
      56             :                             {
      57           0 :                                 fRetval = fNextTime;
      58             :                             }
      59           0 :                             else if(::basegfx::fTools::less(fNextTime, fRetval))
      60             :                             {
      61           0 :                                 fRetval = fNextTime;
      62             :                             }
      63             :                         }
      64             :                     }
      65           0 :                 }
      66             :             }
      67             : 
      68           0 :             return fRetval;
      69             :         }
      70             : 
      71           0 :         void PrimitiveAnimation::prepareNextEvent()
      72             :         {
      73           0 :             const double fCurrentTime(mrVOContact.GetObjectContact().getPrimitiveAnimator().GetTime());
      74           0 :             const double fNextTime(getSmallestNextTime(fCurrentTime));
      75             : 
      76             :             // getSmallestNextTime will be zero when animation ended. If not zero, a next step
      77             :             // exists
      78           0 :             if(!::basegfx::fTools::equalZero(fNextTime))
      79             :             {
      80             :                 // next time point exists, use it
      81             :                 sal_uInt32 nNextTime;
      82             : 
      83           0 :                 if(fNextTime >= (double)0xffffff00)
      84             :                 {
      85             :                     // take care for very late points in time, e.g. when a text animation stops
      86             :                     // in a defined AnimationEntryFixed with endless (0xffffffff) duration
      87           0 :                     nNextTime = GetTime() + (1000 * 60 * 60); // one hour, works with vcl timers, 0xffffff00 was too much...
      88             :                 }
      89             :                 else
      90             :                 {
      91           0 :                     nNextTime = (sal_uInt32)fNextTime;
      92             :                 }
      93             : 
      94             :                 // ensure step forward in integer timing, the floating step difference maybe smaller than 1.0. Use
      95             :                 // at least 25ms for next step
      96           0 :                 const sal_uInt32 nMinimumStepTime((sal_uInt32)fCurrentTime + 25L);
      97             : 
      98           0 :                 if(nNextTime <= nMinimumStepTime)
      99             :                 {
     100           0 :                     nNextTime = nMinimumStepTime;
     101             :                 }
     102             : 
     103             :                 // set time and reactivate by re-adding to the scheduler
     104           0 :                 SetTime(nNextTime);
     105           0 :                 mrVOContact.GetObjectContact().getPrimitiveAnimator().InsertEvent(this);
     106             :             }
     107           0 :         }
     108             : 
     109           0 :         PrimitiveAnimation::PrimitiveAnimation(sdr::contact::ViewObjectContact& rVOContact, const drawinglayer::primitive2d::Primitive2DSequence& rAnimatedPrimitives)
     110             :         :   Event(0L),
     111             :             mrVOContact(rVOContact),
     112           0 :             maAnimatedPrimitives(rAnimatedPrimitives)
     113             :         {
     114             :             // setup initially
     115           0 :             prepareNextEvent();
     116           0 :         }
     117             : 
     118           0 :         PrimitiveAnimation::~PrimitiveAnimation()
     119             :         {
     120             :             // ensure that Event member is removed from PrimitiveAnimator
     121           0 :             mrVOContact.GetObjectContact().getPrimitiveAnimator().RemoveEvent(this);
     122           0 :         }
     123             : 
     124             :         // execute event, from base class Event
     125           0 :         void PrimitiveAnimation::Trigger(sal_uInt32 /*nTime*/)
     126             :         {
     127             :             // schedule a repaint of associated object
     128           0 :             mrVOContact.ActionChanged();
     129             : 
     130             :             // re-setup
     131           0 :             prepareNextEvent();
     132           0 :         }
     133             :     } // end of namespace animation
     134             : } // end of namespace sdr
     135             : 
     136             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10