1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: setactivity.hxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
30 #ifndef INCLUDED_SLIDESHOW_SETACTIVITY_HXX
31 #define INCLUDED_SLIDESHOW_SETACTIVITY_HXX
34 #include <canvas/debug.hxx>
35 #include <tools/diagnose_ex.h>
36 #include <canvas/verbosetrace.hxx>
38 #include "animationactivity.hxx"
39 #include "animation.hxx"
40 #include "animatableshape.hxx"
41 #include "shapeattributelayer.hxx"
42 #include "activitiesfactory.hxx"
47 /** Templated setter for animation values
49 This template class implements the AnimationActivity
50 interface, but only the perform() and
51 setAttributeLayer() methods are functional. To be used for set animations.
53 @see AnimationSetNode.
55 template <class AnimationT
>
56 class SetActivity
: public AnimationActivity
59 typedef ::boost::shared_ptr
< AnimationT
> AnimationSharedPtrT
;
60 typedef typename
AnimationT::ValueType ValueT
;
62 SetActivity( const ActivitiesFactory::CommonParameters
& rParms
,
63 const AnimationSharedPtrT
& rAnimation
,
64 const ValueT
& rToValue
)
65 : mpAnimation( rAnimation
),
68 mpEndEvent( rParms
.mpEndEvent
),
69 mrEventQueue( rParms
.mrEventQueue
),
70 maToValue( rToValue
),
73 ENSURE_OR_THROW( mpAnimation
, "Invalid animation" );
76 virtual void dispose()
81 mpAttributeLayer
.reset();
82 // discharge end event:
83 if (mpEndEvent
&& mpEndEvent
->isCharged())
84 mpEndEvent
->dispose();
88 virtual double calcTimeLag() const
93 virtual bool perform()
97 // we're going inactive immediately:
100 if (mpAnimation
&& mpAttributeLayer
&& mpShape
) {
101 mpAnimation
->start( mpShape
, mpAttributeLayer
);
102 (*mpAnimation
)(maToValue
);
105 // fire end event, if any
107 mrEventQueue
.addEvent( mpEndEvent
);
109 return false; // don't reinsert
112 virtual bool isActive() const
117 virtual void dequeued()
126 virtual void setTargets( const AnimatableShapeSharedPtr
& rShape
,
127 const ShapeAttributeLayerSharedPtr
& rAttrLayer
)
129 ENSURE_OR_THROW( rShape
, "Invalid shape" );
130 ENSURE_OR_THROW( rAttrLayer
, "Invalid attribute layer" );
133 mpAttributeLayer
= rAttrLayer
;
137 AnimationSharedPtrT mpAnimation
;
138 AnimatableShapeSharedPtr mpShape
;
139 ShapeAttributeLayerSharedPtr mpAttributeLayer
;
140 EventSharedPtr mpEndEvent
;
141 EventQueue
& mrEventQueue
;
146 template <class AnimationT
> AnimationActivitySharedPtr
makeSetActivity(
147 const ActivitiesFactory::CommonParameters
& rParms
,
148 const ::boost::shared_ptr
< AnimationT
>& rAnimation
,
149 const typename
AnimationT::ValueType
& rToValue
)
151 return AnimationActivitySharedPtr(
152 new SetActivity
<AnimationT
>(rParms
,rAnimation
,rToValue
) );
155 } // namespace internal
156 } // namespace presentation
158 #endif /* INCLUDED_SLIDESHOW_SETACTIVITY_HXX */