Bump version to 6.0-36
[LibreOffice.git] / slideshow / source / engine / animationnodes / animationsetnode.cxx
blobc2eda0ddc990168c5a8dd450e9445c3d38979882
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 <animationfactory.hxx>
22 #include "setactivity.hxx"
23 #include "animationsetnode.hxx"
24 #include "nodetools.hxx"
25 #include <tools.hxx>
26 #include <delayevent.hxx>
28 using namespace com::sun::star;
30 namespace slideshow {
31 namespace internal {
33 AnimationActivitySharedPtr AnimationSetNode::createActivity() const
35 ActivitiesFactory::CommonParameters aParms( fillCommonParameters() );
36 uno::Reference<animations::XAnimate> const xAnimateNode = getXAnimateNode();
37 OUString const attrName( xAnimateNode->getAttributeName() );
38 AttributableShapeSharedPtr const pShape( getShape() );
40 // make deactivation a two-step procedure. Normally, we
41 // could solely rely on
42 // BaseNode::scheduleDeactivationEvent() to deactivate()
43 // us. Unfortunately, that method on the one hand ignores
44 // indefinite timing, on the other hand generates
45 // zero-timeout delays, which might get fired _before_ our
46 // set activity has taken place. Therefore, we enforce
47 // sequentiality by letting only the set activity schedule
48 // the deactivation event (and AnimationBaseNode
49 // takes care for the fact when mpActivity should be zero).
51 // AnimationBaseNode::fillCommonParameters() has set up
52 // immediate deactivation as default when activity ends, but
53 if (! isIndefiniteTiming( xAnimateNode->getDuration() )) {
54 std::shared_ptr<AnimationSetNode> const pSelf(
55 std::dynamic_pointer_cast<AnimationSetNode>(getSelf()) );
56 ENSURE_OR_THROW(
57 pSelf, "cannot cast getSelf() to my type!" );
58 aParms.mpEndEvent = makeEvent(
59 [pSelf] () { pSelf->scheduleDeactivationEvent(); },
60 "AnimationSetNode::scheduleDeactivationEvent");
63 switch (AnimationFactory::classifyAttributeName( attrName )) {
64 default:
65 case AnimationFactory::CLASS_UNKNOWN_PROPERTY:
66 ENSURE_OR_THROW(
67 false, "AnimationSetNode::createSetActivity(): "
68 "Unexpected attribute class" );
69 break;
71 case AnimationFactory::CLASS_NUMBER_PROPERTY:
73 NumberAnimation::ValueType aValue;
75 ENSURE_OR_THROW(
76 extractValue( aValue,
77 xAnimateNode->getTo(),
78 pShape,
79 getSlideSize() ),
80 "AnimationSetNode::createSetActivity(): "
81 "Could not import numeric to value" );
83 return makeSetActivity(
84 aParms,
85 AnimationFactory::createNumberPropertyAnimation(
86 attrName,
87 pShape,
88 getContext().mpSubsettableShapeManager,
89 getSlideSize(),
90 AnimationFactory::FLAG_NO_SPRITE ),
91 aValue );
94 case AnimationFactory::CLASS_ENUM_PROPERTY:
96 EnumAnimation::ValueType aValue;
98 ENSURE_OR_THROW(
99 extractValue( aValue,
100 xAnimateNode->getTo(),
101 pShape,
102 getSlideSize() ),
103 "AnimationSetNode::createSetActivity(): "
104 "Could not import enum to value" );
106 return makeSetActivity(
107 aParms,
108 AnimationFactory::createEnumPropertyAnimation(
109 attrName,
110 pShape,
111 getContext().mpSubsettableShapeManager,
112 getSlideSize(),
113 AnimationFactory::FLAG_NO_SPRITE ),
114 aValue );
117 case AnimationFactory::CLASS_COLOR_PROPERTY:
119 ColorAnimation::ValueType aValue;
121 ENSURE_OR_THROW(
122 extractValue( aValue,
123 xAnimateNode->getTo(),
124 pShape,
125 getSlideSize() ),
126 "AnimationSetNode::createSetActivity(): "
127 "Could not import color to value" );
129 return makeSetActivity(
130 aParms,
131 AnimationFactory::createColorPropertyAnimation(
132 attrName,
133 pShape,
134 getContext().mpSubsettableShapeManager,
135 getSlideSize(),
136 AnimationFactory::FLAG_NO_SPRITE ),
137 aValue );
140 case AnimationFactory::CLASS_STRING_PROPERTY:
142 StringAnimation::ValueType aValue;
144 ENSURE_OR_THROW(
145 extractValue( aValue,
146 xAnimateNode->getTo(),
147 pShape,
148 getSlideSize() ),
149 "AnimationSetNode::createSetActivity(): "
150 "Could not import string to value" );
152 return makeSetActivity(
153 aParms,
154 AnimationFactory::createStringPropertyAnimation(
155 attrName,
156 pShape,
157 getContext().mpSubsettableShapeManager,
158 getSlideSize(),
159 AnimationFactory::FLAG_NO_SPRITE ),
160 aValue );
163 case AnimationFactory::CLASS_BOOL_PROPERTY:
165 BoolAnimation::ValueType aValue;
167 ENSURE_OR_THROW(
168 extractValue( aValue,
169 xAnimateNode->getTo(),
170 pShape,
171 getSlideSize() ),
172 "AnimationSetNode::createSetActivity(): "
173 "Could not import bool to value" );
175 return makeSetActivity(
176 aParms,
177 AnimationFactory::createBoolPropertyAnimation(
178 attrName,
179 pShape,
180 getContext().mpSubsettableShapeManager,
181 getSlideSize(),
182 AnimationFactory::FLAG_NO_SPRITE ),
183 aValue );
187 return AnimationActivitySharedPtr();
190 } // namespace internal
191 } // namespace slideshow
193 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */