1 /**************************************************************
2 *
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance
9 * with the License. You may obtain a copy of the License at
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing,
14 * software distributed under the License is distributed on an
15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 * KIND, either express or implied. See the License for the
17 * specific language governing permissions and limitations
18 * under the License.
19 *
20 *************************************************************/
21
22
23
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_slideshow.hxx"
26
27 #include <canvas/debug.hxx>
28 #include <canvas/verbosetrace.hxx>
29
30 #include "animationfactory.hxx"
31 #include "setactivity.hxx"
32 #include "animationsetnode.hxx"
33 #include "nodetools.hxx"
34 #include "tools.hxx"
35 #include "delayevent.hxx"
36
37 #include <boost/bind.hpp>
38
39 using namespace com::sun::star;
40
41 namespace slideshow {
42 namespace internal {
43
implScheduleDeactivationEvent()44 void AnimationSetNode::implScheduleDeactivationEvent()
45 {
46 scheduleDeactivationEvent();
47 }
48
createActivity() const49 AnimationActivitySharedPtr AnimationSetNode::createActivity() const
50 {
51 ActivitiesFactory::CommonParameters aParms( fillCommonParameters() );
52 uno::Reference<animations::XAnimate> const xAnimateNode = getXAnimateNode();
53 rtl::OUString const attrName( xAnimateNode->getAttributeName() );
54 AttributableShapeSharedPtr const pShape( getShape() );
55
56 // make deactivation a two-step procedure. Normally, we
57 // could solely rely on
58 // BaseNode::scheduleDeactivationEvent() to deactivate()
59 // us. Unfortunately, that method on the one hand ignores
60 // indefinite timing, on the other hand generates
61 // zero-timeout delays, which might get fired _before_ our
62 // set activity has taken place. Therefore, we enforce
63 // sequentiality by letting only the set activity schedule
64 // the deactivation event (and AnimationBaseNode
65 // takes care for the fact when mpActivity should be zero).
66
67 // AnimationBaseNode::fillCommonParameters() has set up
68 // immediate deactivation as default when activity ends, but
69 if (! isIndefiniteTiming( xAnimateNode->getDuration() )) {
70 boost::shared_ptr<AnimationSetNode> const pSelf(
71 boost::dynamic_pointer_cast<AnimationSetNode>(getSelf()) );
72 ENSURE_OR_THROW(
73 pSelf, "cannot cast getSelf() to my type!" );
74 aParms.mpEndEvent = makeEvent(
75 boost::bind( &AnimationSetNode::implScheduleDeactivationEvent,
76 pSelf ),
77 "AnimationSetNode::implScheduleDeactivationEvent");
78 }
79
80 switch (AnimationFactory::classifyAttributeName( attrName )) {
81 default:
82 case AnimationFactory::CLASS_UNKNOWN_PROPERTY:
83 ENSURE_OR_THROW(
84 false, "AnimationSetNode::createSetActivity(): "
85 "Unexpected attribute class" );
86 break;
87
88 case AnimationFactory::CLASS_NUMBER_PROPERTY:
89 {
90 NumberAnimation::ValueType aValue;
91
92 ENSURE_OR_THROW(
93 extractValue( aValue,
94 xAnimateNode->getTo(),
95 pShape,
96 getSlideSize() ),
97 "AnimationSetNode::createSetActivity(): "
98 "Could not import numeric to value" );
99
100 return makeSetActivity(
101 aParms,
102 AnimationFactory::createNumberPropertyAnimation(
103 attrName,
104 pShape,
105 getContext().mpSubsettableShapeManager,
106 getSlideSize(),
107 AnimationFactory::FLAG_NO_SPRITE ),
108 aValue );
109 }
110
111 case AnimationFactory::CLASS_ENUM_PROPERTY:
112 {
113 EnumAnimation::ValueType aValue;
114
115 ENSURE_OR_THROW(
116 extractValue( aValue,
117 xAnimateNode->getTo(),
118 pShape,
119 getSlideSize() ),
120 "AnimationSetNode::createSetActivity(): "
121 "Could not import enum to value" );
122
123 return makeSetActivity(
124 aParms,
125 AnimationFactory::createEnumPropertyAnimation(
126 attrName,
127 pShape,
128 getContext().mpSubsettableShapeManager,
129 getSlideSize(),
130 AnimationFactory::FLAG_NO_SPRITE ),
131 aValue );
132 }
133
134 case AnimationFactory::CLASS_COLOR_PROPERTY:
135 {
136 ColorAnimation::ValueType aValue;
137
138 ENSURE_OR_THROW(
139 extractValue( aValue,
140 xAnimateNode->getTo(),
141 pShape,
142 getSlideSize() ),
143 "AnimationSetNode::createSetActivity(): "
144 "Could not import color to value" );
145
146 return makeSetActivity(
147 aParms,
148 AnimationFactory::createColorPropertyAnimation(
149 attrName,
150 pShape,
151 getContext().mpSubsettableShapeManager,
152 getSlideSize(),
153 AnimationFactory::FLAG_NO_SPRITE ),
154 aValue );
155 }
156
157 case AnimationFactory::CLASS_STRING_PROPERTY:
158 {
159 StringAnimation::ValueType aValue;
160
161 ENSURE_OR_THROW(
162 extractValue( aValue,
163 xAnimateNode->getTo(),
164 pShape,
165 getSlideSize() ),
166 "AnimationSetNode::createSetActivity(): "
167 "Could not import string to value" );
168
169 return makeSetActivity(
170 aParms,
171 AnimationFactory::createStringPropertyAnimation(
172 attrName,
173 pShape,
174 getContext().mpSubsettableShapeManager,
175 getSlideSize(),
176 AnimationFactory::FLAG_NO_SPRITE ),
177 aValue );
178 }
179
180 case AnimationFactory::CLASS_BOOL_PROPERTY:
181 {
182 BoolAnimation::ValueType aValue;
183
184 ENSURE_OR_THROW(
185 extractValue( aValue,
186 xAnimateNode->getTo(),
187 pShape,
188 getSlideSize() ),
189 "AnimationSetNode::createSetActivity(): "
190 "Could not import bool to value" );
191
192 return makeSetActivity(
193 aParms,
194 AnimationFactory::createBoolPropertyAnimation(
195 attrName,
196 pShape,
197 getContext().mpSubsettableShapeManager,
198 getSlideSize(),
199 AnimationFactory::FLAG_NO_SPRITE ),
200 aValue );
201 }
202 }
203
204 return AnimationActivitySharedPtr();
205 }
206
207 } // namespace internal
208 } // namespace slideshow
209
210