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