bump product version to 5.0.4.1
[LibreOffice.git] / slideshow / source / engine / animationnodes / animationsetnode.cxx
blob2b1230a6e6491c5fc87160dd7917fb8a2f3bf594
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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"
28 #include "tools.hxx"
29 #include "delayevent.hxx"
31 #include <boost/bind.hpp>
33 using namespace com::sun::star;
35 namespace slideshow {
36 namespace internal {
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()) );
66 ENSURE_OR_THROW(
67 pSelf, "cannot cast getSelf() to my type!" );
68 aParms.mpEndEvent = makeEvent(
69 boost::bind( &AnimationSetNode::implScheduleDeactivationEvent,
70 pSelf ),
71 "AnimationSetNode::implScheduleDeactivationEvent");
74 switch (AnimationFactory::classifyAttributeName( attrName )) {
75 default:
76 case AnimationFactory::CLASS_UNKNOWN_PROPERTY:
77 ENSURE_OR_THROW(
78 false, "AnimationSetNode::createSetActivity(): "
79 "Unexpected attribute class" );
80 break;
82 case AnimationFactory::CLASS_NUMBER_PROPERTY:
84 NumberAnimation::ValueType aValue;
86 ENSURE_OR_THROW(
87 extractValue( aValue,
88 xAnimateNode->getTo(),
89 pShape,
90 getSlideSize() ),
91 "AnimationSetNode::createSetActivity(): "
92 "Could not import numeric to value" );
94 return makeSetActivity(
95 aParms,
96 AnimationFactory::createNumberPropertyAnimation(
97 attrName,
98 pShape,
99 getContext().mpSubsettableShapeManager,
100 getSlideSize(),
101 AnimationFactory::FLAG_NO_SPRITE ),
102 aValue );
105 case AnimationFactory::CLASS_ENUM_PROPERTY:
107 EnumAnimation::ValueType aValue;
109 ENSURE_OR_THROW(
110 extractValue( aValue,
111 xAnimateNode->getTo(),
112 pShape,
113 getSlideSize() ),
114 "AnimationSetNode::createSetActivity(): "
115 "Could not import enum to value" );
117 return makeSetActivity(
118 aParms,
119 AnimationFactory::createEnumPropertyAnimation(
120 attrName,
121 pShape,
122 getContext().mpSubsettableShapeManager,
123 getSlideSize(),
124 AnimationFactory::FLAG_NO_SPRITE ),
125 aValue );
128 case AnimationFactory::CLASS_COLOR_PROPERTY:
130 ColorAnimation::ValueType aValue;
132 ENSURE_OR_THROW(
133 extractValue( aValue,
134 xAnimateNode->getTo(),
135 pShape,
136 getSlideSize() ),
137 "AnimationSetNode::createSetActivity(): "
138 "Could not import color to value" );
140 return makeSetActivity(
141 aParms,
142 AnimationFactory::createColorPropertyAnimation(
143 attrName,
144 pShape,
145 getContext().mpSubsettableShapeManager,
146 getSlideSize(),
147 AnimationFactory::FLAG_NO_SPRITE ),
148 aValue );
151 case AnimationFactory::CLASS_STRING_PROPERTY:
153 StringAnimation::ValueType aValue;
155 ENSURE_OR_THROW(
156 extractValue( aValue,
157 xAnimateNode->getTo(),
158 pShape,
159 getSlideSize() ),
160 "AnimationSetNode::createSetActivity(): "
161 "Could not import string to value" );
163 return makeSetActivity(
164 aParms,
165 AnimationFactory::createStringPropertyAnimation(
166 attrName,
167 pShape,
168 getContext().mpSubsettableShapeManager,
169 getSlideSize(),
170 AnimationFactory::FLAG_NO_SPRITE ),
171 aValue );
174 case AnimationFactory::CLASS_BOOL_PROPERTY:
176 BoolAnimation::ValueType aValue;
178 ENSURE_OR_THROW(
179 extractValue( aValue,
180 xAnimateNode->getTo(),
181 pShape,
182 getSlideSize() ),
183 "AnimationSetNode::createSetActivity(): "
184 "Could not import bool to value" );
186 return makeSetActivity(
187 aParms,
188 AnimationFactory::createBoolPropertyAnimation(
189 attrName,
190 pShape,
191 getContext().mpSubsettableShapeManager,
192 getSlideSize(),
193 AnimationFactory::FLAG_NO_SPRITE ),
194 aValue );
198 return AnimationActivitySharedPtr();
201 } // namespace internal
202 } // namespace slideshow
204 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */