Update ooo320-m1
[ooovba.git] / slideshow / source / engine / animationnodes / animationsetnode.cxx
blob9800074ef3b07559f4d683684508c533eb74d695
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: animationsetnode.cxx,v $
10 * $Revision: 1.11 $
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"
41 #include "tools.hxx"
42 #include "delayevent.hxx"
44 #include <boost/bind.hpp>
46 using namespace com::sun::star;
48 namespace slideshow {
49 namespace internal {
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()) );
79 ENSURE_OR_THROW(
80 pSelf, "cannot cast getSelf() to my type!" );
81 aParms.mpEndEvent = makeEvent(
82 boost::bind( &AnimationSetNode::implScheduleDeactivationEvent,
83 pSelf ) );
86 switch (AnimationFactory::classifyAttributeName( attrName )) {
87 default:
88 case AnimationFactory::CLASS_UNKNOWN_PROPERTY:
89 ENSURE_OR_THROW(
90 false, "AnimationSetNode::createSetActivity(): "
91 "Unexpected attribute class" );
92 break;
94 case AnimationFactory::CLASS_NUMBER_PROPERTY:
96 NumberAnimation::ValueType aValue;
98 ENSURE_OR_THROW(
99 extractValue( aValue,
100 xAnimateNode->getTo(),
101 pShape,
102 getSlideSize() ),
103 "AnimationSetNode::createSetActivity(): "
104 "Could not import numeric to value" );
106 return makeSetActivity(
107 aParms,
108 AnimationFactory::createNumberPropertyAnimation(
109 attrName,
110 pShape,
111 getContext().mpSubsettableShapeManager,
112 getSlideSize(),
113 AnimationFactory::FLAG_NO_SPRITE ),
114 aValue );
117 case AnimationFactory::CLASS_ENUM_PROPERTY:
119 EnumAnimation::ValueType aValue;
121 ENSURE_OR_THROW(
122 extractValue( aValue,
123 xAnimateNode->getTo(),
124 pShape,
125 getSlideSize() ),
126 "AnimationSetNode::createSetActivity(): "
127 "Could not import enum to value" );
129 return makeSetActivity(
130 aParms,
131 AnimationFactory::createEnumPropertyAnimation(
132 attrName,
133 pShape,
134 getContext().mpSubsettableShapeManager,
135 getSlideSize(),
136 AnimationFactory::FLAG_NO_SPRITE ),
137 aValue );
140 case AnimationFactory::CLASS_COLOR_PROPERTY:
142 ColorAnimation::ValueType aValue;
144 ENSURE_OR_THROW(
145 extractValue( aValue,
146 xAnimateNode->getTo(),
147 pShape,
148 getSlideSize() ),
149 "AnimationSetNode::createSetActivity(): "
150 "Could not import color to value" );
152 return makeSetActivity(
153 aParms,
154 AnimationFactory::createColorPropertyAnimation(
155 attrName,
156 pShape,
157 getContext().mpSubsettableShapeManager,
158 getSlideSize(),
159 AnimationFactory::FLAG_NO_SPRITE ),
160 aValue );
163 case AnimationFactory::CLASS_STRING_PROPERTY:
165 StringAnimation::ValueType aValue;
167 ENSURE_OR_THROW(
168 extractValue( aValue,
169 xAnimateNode->getTo(),
170 pShape,
171 getSlideSize() ),
172 "AnimationSetNode::createSetActivity(): "
173 "Could not import string to value" );
175 return makeSetActivity(
176 aParms,
177 AnimationFactory::createStringPropertyAnimation(
178 attrName,
179 pShape,
180 getContext().mpSubsettableShapeManager,
181 getSlideSize(),
182 AnimationFactory::FLAG_NO_SPRITE ),
183 aValue );
186 case AnimationFactory::CLASS_BOOL_PROPERTY:
188 BoolAnimation::ValueType aValue;
190 ENSURE_OR_THROW(
191 extractValue( aValue,
192 xAnimateNode->getTo(),
193 pShape,
194 getSlideSize() ),
195 "AnimationSetNode::createSetActivity(): "
196 "Could not import bool to value" );
198 return makeSetActivity(
199 aParms,
200 AnimationFactory::createBoolPropertyAnimation(
201 attrName,
202 pShape,
203 getContext().mpSubsettableShapeManager,
204 getSlideSize(),
205 AnimationFactory::FLAG_NO_SPRITE ),
206 aValue );
210 return AnimationActivitySharedPtr();
213 } // namespace internal
214 } // namespace slideshow