summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVladimir Glazounov <vg@openoffice.org>2008-08-19 22:03:16 +0000
committerVladimir Glazounov <vg@openoffice.org>2008-08-19 22:03:16 +0000
commitaf75efdc89667d8935e6a8c23adf0eb34ae59e99 (patch)
tree7b6d7e3cb0bdc3c10690d2d5970bbc806196849a
parent19133382e9b3df791a7c2ba4949aaa5206c1387b (diff)
INTEGRATION: CWS aw033 (1.4.16); FILE MERGED
2008/05/16 10:54:55 aw 1.4.16.8: adaptions after resync 2008/05/14 13:59:39 aw 1.4.16.7: RESYNC: (1.5-1.6); FILE MERGED 2008/01/22 12:29:29 aw 1.4.16.6: adaptions and 1st stripping 2006/12/11 17:40:56 aw 1.4.16.5: #i39532# changes after resync 2006/11/07 15:52:19 aw 1.4.16.4: #i39532# changed various aspevcts of XPrimitive2D implementations 2006/10/19 10:58:23 aw 1.4.16.3: #i39532# primitive 2006/09/26 19:19:18 aw 1.4.16.2: RESYNC: (1.4-1.5); FILE MERGED 2006/08/09 17:08:56 aw 1.4.16.1: #i39532#
-rw-r--r--svx/source/sdr/animation/animationstate.cxx120
1 files changed, 83 insertions, 37 deletions
diff --git a/svx/source/sdr/animation/animationstate.cxx b/svx/source/sdr/animation/animationstate.cxx
index 5db49354d010..39d4777fc60c 100644
--- a/svx/source/sdr/animation/animationstate.cxx
+++ b/svx/source/sdr/animation/animationstate.cxx
@@ -7,7 +7,7 @@
* OpenOffice.org - a multi-platform office productivity suite
*
* $RCSfile: animationstate.cxx,v $
- * $Revision: 1.6 $
+ * $Revision: 1.7 $
*
* This file is part of OpenOffice.org.
*
@@ -34,9 +34,10 @@
#include <tools/debug.hxx>
#include <svx/sdr/contact/viewobjectcontact.hxx>
#include <svx/sdr/animation/objectanimator.hxx>
-#include <svx/sdr/animation/animationinfo.hxx>
#include <svx/sdr/contact/objectcontact.hxx>
#include <svx/sdr/contact/viewcontact.hxx>
+#include <drawinglayer/primitive2d/animatedprimitive2d.hxx>
+#include <drawinglayer/animation/animationtiming.hxx>
//////////////////////////////////////////////////////////////////////////////
@@ -44,59 +45,104 @@ namespace sdr
{
namespace animation
{
- // get associated AnimationInfo
- AnimationInfo& AnimationState::GetAnimationInfo() const
+ double PrimitiveAnimation::getSmallestNextTime(double fCurrentTime)
{
- return *(mrVOContact.GetViewContact().GetAnimationInfo());
- }
+ double fRetval(0.0);
- // get associated ObectAnimator
- ObjectAnimator& AnimationState::GetObjectAnimator() const
- {
- return mrVOContact.GetObjectContact().GetObjectAnimator();
+ if(maAnimatedPrimitives.hasElements())
+ {
+ const sal_Int32 nCount(maAnimatedPrimitives.getLength());
+
+ for(sal_Int32 a(0L); a < nCount; a++)
+ {
+ const drawinglayer::primitive2d::Primitive2DReference xRef(maAnimatedPrimitives[a]);
+ const drawinglayer::primitive2d::AnimatedSwitchPrimitive2D* pCandidate = dynamic_cast< const drawinglayer::primitive2d::AnimatedSwitchPrimitive2D* >(xRef.get());
+ OSL_ENSURE(pCandidate, "PrimitiveAnimation::getSmallestNextTime: wrong primitive in animated list (!)");
+
+ if(pCandidate)
+ {
+ const drawinglayer::animation::AnimationEntry& rAnimEntry = pCandidate->getAnimationEntry();
+ const double fNextTime(rAnimEntry.getNextEventTime(fCurrentTime));
+
+ if(!::basegfx::fTools::equalZero(fNextTime))
+ {
+ if(::basegfx::fTools::equalZero(fRetval))
+ {
+ fRetval = fNextTime;
+ }
+ else if(::basegfx::fTools::less(fNextTime, fRetval))
+ {
+ fRetval = fNextTime;
+ }
+ }
+ }
+ }
+ }
+
+ return fRetval;
}
- AnimationState::AnimationState(
- sdr::contact::ViewObjectContact& rVOContact)
- : Event(0L),
- mrVOContact(rVOContact)
+ void PrimitiveAnimation::prepareNextEvent()
{
- const sal_uInt32 nStartTime(GetAnimationInfo().GetStartTime());
+ const double fCurrentTime(mrVOContact.GetObjectContact().getPrimitiveAnimator().GetTime());
+ const double fNextTime(getSmallestNextTime(fCurrentTime));
- if(0L != nStartTime)
+ // getSmallestNextTime will be zero when animation ended. If not zero, a next step
+ // exists
+ if(!::basegfx::fTools::equalZero(fNextTime))
{
- SetTime(nStartTime);
+ // next time point exists, use it
+ sal_uInt32 nNextTime;
+
+ if(fNextTime >= (double)0xffffff00)
+ {
+ // take care for very late points in time, e.g. when a text animation stops
+ // in a defined AnimationEntryFixed with endless (0xffffffff) duration
+ nNextTime = GetTime() + (1000 * 60 * 60); // one hour, works with vcl timers, 0xffffff00 was too much...
+ }
+ else
+ {
+ nNextTime = (sal_uInt32)fNextTime;
+ }
+
+ // ensure step forward in integer timing, the floating step difference maybe smaller than 1.0. Use
+ // at least 25ms for next step
+ const sal_uInt32 nMinimumStepTime((sal_uInt32)fCurrentTime + 25L);
+
+ if(nNextTime <= nMinimumStepTime)
+ {
+ nNextTime = nMinimumStepTime;
+ }
+
+ // set time and reactivate by re-adding to the scheduler
+ SetTime(nNextTime);
+ mrVOContact.GetObjectContact().getPrimitiveAnimator().InsertEvent(this);
}
}
- AnimationState::~AnimationState()
+ PrimitiveAnimation::PrimitiveAnimation(sdr::contact::ViewObjectContact& rVOContact, const drawinglayer::primitive2d::Primitive2DSequence& rAnimatedPrimitives)
+ : Event(0L),
+ mrVOContact(rVOContact),
+ maAnimatedPrimitives(rAnimatedPrimitives)
+ {
+ // setup initially
+ prepareNextEvent();
+ }
+
+ PrimitiveAnimation::~PrimitiveAnimation()
{
- // ensure that Event member is removed from ObjectAnimator
- GetObjectAnimator().RemoveEvent(this);
+ // ensure that Event member is removed from PrimitiveAnimator
+ mrVOContact.GetObjectContact().getPrimitiveAnimator().RemoveEvent(this);
}
// execute event, from base class Event
- void AnimationState::Trigger(sal_uInt32 nTime)
+ void PrimitiveAnimation::Trigger(sal_uInt32 /*nTime*/)
{
// schedule a repaint of associated object
mrVOContact.ActionChanged();
- // need to produce event after nTime?
- sal_uInt32 nNewTime(nTime);
-
- if(GetAnimationInfo().DoRegisterAgain(nTime, nNewTime, *this))
- {
- SetTime(nNewTime);
- }
- else
- {
- // #i38135# Advance 10 minutes
- nNewTime = nTime + (10L * 60000L);
- SetTime(nNewTime);
- }
-
- // insert event again
- GetObjectAnimator().InsertEvent(this);
+ // re-setup
+ prepareNextEvent();
}
} // end of namespace animation
} // end of namespace sdr