1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
21 #include <canvas/debug.hxx>
22 #include <canvas/verbosetrace.hxx>
24 #include "animationfactory.hxx"
25 #include "setactivity.hxx"
26 #include "animationsetnode.hxx"
27 #include "nodetools.hxx"
29 #include "delayevent.hxx"
31 #include <boost/bind.hpp>
33 using namespace com::sun::star
;
38 void AnimationSetNode::implScheduleDeactivationEvent()
40 scheduleDeactivationEvent();
43 AnimationActivitySharedPtr
AnimationSetNode::createActivity() const
45 ActivitiesFactory::CommonParameters
aParms( fillCommonParameters() );
46 uno::Reference
<animations::XAnimate
> const xAnimateNode
= getXAnimateNode();
47 OUString
const attrName( xAnimateNode
->getAttributeName() );
48 AttributableShapeSharedPtr
const pShape( getShape() );
50 // make deactivation a two-step procedure. Normally, we
51 // could solely rely on
52 // BaseNode::scheduleDeactivationEvent() to deactivate()
53 // us. Unfortunately, that method on the one hand ignores
54 // indefinite timing, on the other hand generates
55 // zero-timeout delays, which might get fired _before_ our
56 // set activity has taken place. Therefore, we enforce
57 // sequentiality by letting only the set activity schedule
58 // the deactivation event (and AnimationBaseNode
59 // takes care for the fact when mpActivity should be zero).
61 // AnimationBaseNode::fillCommonParameters() has set up
62 // immediate deactivation as default when activity ends, but
63 if (! isIndefiniteTiming( xAnimateNode
->getDuration() )) {
64 boost::shared_ptr
<AnimationSetNode
> const pSelf(
65 boost::dynamic_pointer_cast
<AnimationSetNode
>(getSelf()) );
67 pSelf
, "cannot cast getSelf() to my type!" );
68 aParms
.mpEndEvent
= makeEvent(
69 boost::bind( &AnimationSetNode::implScheduleDeactivationEvent
,
71 "AnimationSetNode::implScheduleDeactivationEvent");
74 switch (AnimationFactory::classifyAttributeName( attrName
)) {
76 case AnimationFactory::CLASS_UNKNOWN_PROPERTY
:
78 false, "AnimationSetNode::createSetActivity(): "
79 "Unexpected attribute class" );
82 case AnimationFactory::CLASS_NUMBER_PROPERTY
:
84 NumberAnimation::ValueType aValue
;
88 xAnimateNode
->getTo(),
91 "AnimationSetNode::createSetActivity(): "
92 "Could not import numeric to value" );
94 return makeSetActivity(
96 AnimationFactory::createNumberPropertyAnimation(
99 getContext().mpSubsettableShapeManager
,
101 AnimationFactory::FLAG_NO_SPRITE
),
105 case AnimationFactory::CLASS_ENUM_PROPERTY
:
107 EnumAnimation::ValueType aValue
;
110 extractValue( aValue
,
111 xAnimateNode
->getTo(),
114 "AnimationSetNode::createSetActivity(): "
115 "Could not import enum to value" );
117 return makeSetActivity(
119 AnimationFactory::createEnumPropertyAnimation(
122 getContext().mpSubsettableShapeManager
,
124 AnimationFactory::FLAG_NO_SPRITE
),
128 case AnimationFactory::CLASS_COLOR_PROPERTY
:
130 ColorAnimation::ValueType aValue
;
133 extractValue( aValue
,
134 xAnimateNode
->getTo(),
137 "AnimationSetNode::createSetActivity(): "
138 "Could not import color to value" );
140 return makeSetActivity(
142 AnimationFactory::createColorPropertyAnimation(
145 getContext().mpSubsettableShapeManager
,
147 AnimationFactory::FLAG_NO_SPRITE
),
151 case AnimationFactory::CLASS_STRING_PROPERTY
:
153 StringAnimation::ValueType aValue
;
156 extractValue( aValue
,
157 xAnimateNode
->getTo(),
160 "AnimationSetNode::createSetActivity(): "
161 "Could not import string to value" );
163 return makeSetActivity(
165 AnimationFactory::createStringPropertyAnimation(
168 getContext().mpSubsettableShapeManager
,
170 AnimationFactory::FLAG_NO_SPRITE
),
174 case AnimationFactory::CLASS_BOOL_PROPERTY
:
176 BoolAnimation::ValueType aValue
;
179 extractValue( aValue
,
180 xAnimateNode
->getTo(),
183 "AnimationSetNode::createSetActivity(): "
184 "Could not import bool to value" );
186 return makeSetActivity(
188 AnimationFactory::createBoolPropertyAnimation(
191 getContext().mpSubsettableShapeManager
,
193 AnimationFactory::FLAG_NO_SPRITE
),
198 return AnimationActivitySharedPtr();
201 } // namespace internal
202 } // namespace slideshow
204 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */