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: animationsetnode.cxx,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 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_slideshow.hxx"
34 #include <canvas/debug.hxx>
35 #include <canvas/verbosetrace.hxx>
37 #include "animationfactory.hxx"
38 #include "setactivity.hxx"
39 #include "animationsetnode.hxx"
40 #include "nodetools.hxx"
42 #include "delayevent.hxx"
44 #include <boost/bind.hpp>
46 using namespace com::sun::star
;
51 void AnimationSetNode::implScheduleDeactivationEvent()
53 scheduleDeactivationEvent();
56 AnimationActivitySharedPtr
AnimationSetNode::createActivity() const
58 ActivitiesFactory::CommonParameters
aParms( fillCommonParameters() );
59 uno::Reference
<animations::XAnimate
> const xAnimateNode
= getXAnimateNode();
60 rtl::OUString
const attrName( xAnimateNode
->getAttributeName() );
61 AttributableShapeSharedPtr
const pShape( getShape() );
63 // make deactivation a two-step procedure. Normally, we
64 // could solely rely on
65 // BaseNode::scheduleDeactivationEvent() to deactivate()
66 // us. Unfortunately, that method on the one hand ignores
67 // indefinite timing, on the other hand generates
68 // zero-timeout delays, which might get fired _before_ our
69 // set activity has taken place. Therefore, we enforce
70 // sequentiality by letting only the set activity schedule
71 // the deactivation event (and AnimationBaseNode
72 // takes care for the fact when mpActivity should be zero).
74 // AnimationBaseNode::fillCommonParameters() has set up
75 // immediate deactivation as default when activity ends, but
76 if (! isIndefiniteTiming( xAnimateNode
->getDuration() )) {
77 boost::shared_ptr
<AnimationSetNode
> const pSelf(
78 boost::dynamic_pointer_cast
<AnimationSetNode
>(getSelf()) );
80 pSelf
, "cannot cast getSelf() to my type!" );
81 aParms
.mpEndEvent
= makeEvent(
82 boost::bind( &AnimationSetNode::implScheduleDeactivationEvent
,
86 switch (AnimationFactory::classifyAttributeName( attrName
)) {
88 case AnimationFactory::CLASS_UNKNOWN_PROPERTY
:
90 false, "AnimationSetNode::createSetActivity(): "
91 "Unexpected attribute class" );
94 case AnimationFactory::CLASS_NUMBER_PROPERTY
:
96 NumberAnimation::ValueType aValue
;
100 xAnimateNode
->getTo(),
103 "AnimationSetNode::createSetActivity(): "
104 "Could not import numeric to value" );
106 return makeSetActivity(
108 AnimationFactory::createNumberPropertyAnimation(
111 getContext().mpSubsettableShapeManager
,
113 AnimationFactory::FLAG_NO_SPRITE
),
117 case AnimationFactory::CLASS_ENUM_PROPERTY
:
119 EnumAnimation::ValueType aValue
;
122 extractValue( aValue
,
123 xAnimateNode
->getTo(),
126 "AnimationSetNode::createSetActivity(): "
127 "Could not import enum to value" );
129 return makeSetActivity(
131 AnimationFactory::createEnumPropertyAnimation(
134 getContext().mpSubsettableShapeManager
,
136 AnimationFactory::FLAG_NO_SPRITE
),
140 case AnimationFactory::CLASS_COLOR_PROPERTY
:
142 ColorAnimation::ValueType aValue
;
145 extractValue( aValue
,
146 xAnimateNode
->getTo(),
149 "AnimationSetNode::createSetActivity(): "
150 "Could not import color to value" );
152 return makeSetActivity(
154 AnimationFactory::createColorPropertyAnimation(
157 getContext().mpSubsettableShapeManager
,
159 AnimationFactory::FLAG_NO_SPRITE
),
163 case AnimationFactory::CLASS_STRING_PROPERTY
:
165 StringAnimation::ValueType aValue
;
168 extractValue( aValue
,
169 xAnimateNode
->getTo(),
172 "AnimationSetNode::createSetActivity(): "
173 "Could not import string to value" );
175 return makeSetActivity(
177 AnimationFactory::createStringPropertyAnimation(
180 getContext().mpSubsettableShapeManager
,
182 AnimationFactory::FLAG_NO_SPRITE
),
186 case AnimationFactory::CLASS_BOOL_PROPERTY
:
188 BoolAnimation::ValueType aValue
;
191 extractValue( aValue
,
192 xAnimateNode
->getTo(),
195 "AnimationSetNode::createSetActivity(): "
196 "Could not import bool to value" );
198 return makeSetActivity(
200 AnimationFactory::createBoolPropertyAnimation(
203 getContext().mpSubsettableShapeManager
,
205 AnimationFactory::FLAG_NO_SPRITE
),
210 return AnimationActivitySharedPtr();
213 } // namespace internal
214 } // namespace slideshow