Gtk-WARNING gtktreestore.c:1047: Invalid column number 1 added to iter
[LibreOffice.git] / slideshow / source / engine / animationnodes / animationsetnode.cxx
blob45a6005c6f4860813b4576611473bac0a983d1d9
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::internal {
32 AnimationActivitySharedPtr AnimationSetNode::createActivity() const
34 ActivitiesFactory::CommonParameters aParms( fillCommonParameters() );
35 uno::Reference<animations::XAnimate> const xAnimateNode = getXAnimateNode();
36 OUString const attrName( xAnimateNode->getAttributeName() );
37 AttributableShapeSharedPtr const pShape( getShape() );
39 // make deactivation a two-step procedure. Normally, we
40 // could solely rely on
41 // BaseNode::scheduleDeactivationEvent() to deactivate()
42 // us. Unfortunately, that method on the one hand ignores
43 // indefinite timing, on the other hand generates
44 // zero-timeout delays, which might get fired _before_ our
45 // set activity has taken place. Therefore, we enforce
46 // sequentiality by letting only the set activity schedule
47 // the deactivation event (and AnimationBaseNode
48 // takes care for the fact when mpActivity should be zero).
50 // AnimationBaseNode::fillCommonParameters() has set up
51 // immediate deactivation as default when activity ends, but
52 if (! isIndefiniteTiming( xAnimateNode->getDuration() )) {
53 std::shared_ptr<AnimationSetNode> const pSelf(
54 std::dynamic_pointer_cast<AnimationSetNode>(getSelf()) );
55 ENSURE_OR_THROW(
56 pSelf, "cannot cast getSelf() to my type!" );
57 aParms.mpEndEvent = makeEvent(
58 [pSelf] () { pSelf->scheduleDeactivationEvent(); },
59 u"AnimationSetNode::scheduleDeactivationEvent"_ustr);
62 switch (AnimationFactory::classifyAttributeName( attrName )) {
63 default:
64 case AnimationFactory::CLASS_UNKNOWN_PROPERTY:
65 ENSURE_OR_THROW(
66 false, "AnimationSetNode::createSetActivity(): "
67 "Unexpected attribute class" );
68 break;
70 case AnimationFactory::CLASS_NUMBER_PROPERTY:
72 NumberAnimation::ValueType aValue;
74 ENSURE_OR_THROW(
75 extractValue( aValue,
76 xAnimateNode->getTo(),
77 pShape,
78 getSlideSize() ),
79 "AnimationSetNode::createSetActivity(): "
80 "Could not import numeric to value" );
82 return makeSetActivity(
83 aParms,
84 AnimationFactory::createNumberPropertyAnimation(
85 attrName,
86 pShape,
87 getContext().mpSubsettableShapeManager,
88 getSlideSize(),
89 getContext().mpBox2DWorld,
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 getContext().mpBox2DWorld,
114 AnimationFactory::FLAG_NO_SPRITE ),
115 aValue );
118 case AnimationFactory::CLASS_COLOR_PROPERTY:
120 ColorAnimation::ValueType aValue;
122 ENSURE_OR_THROW(
123 extractValue( aValue,
124 xAnimateNode->getTo(),
125 pShape,
126 getSlideSize() ),
127 "AnimationSetNode::createSetActivity(): "
128 "Could not import color to value" );
130 return makeSetActivity(
131 aParms,
132 AnimationFactory::createColorPropertyAnimation(
133 attrName,
134 pShape,
135 getContext().mpSubsettableShapeManager,
136 getSlideSize(),
137 getContext().mpBox2DWorld,
138 AnimationFactory::FLAG_NO_SPRITE ),
139 aValue );
142 case AnimationFactory::CLASS_STRING_PROPERTY:
144 StringAnimation::ValueType aValue;
146 ENSURE_OR_THROW(
147 extractValue( aValue,
148 xAnimateNode->getTo(),
149 pShape,
150 getSlideSize() ),
151 "AnimationSetNode::createSetActivity(): "
152 "Could not import string to value" );
154 return makeSetActivity(
155 aParms,
156 AnimationFactory::createStringPropertyAnimation(
157 attrName,
158 pShape,
159 getContext().mpSubsettableShapeManager,
160 getSlideSize(),
161 getContext().mpBox2DWorld,
162 AnimationFactory::FLAG_NO_SPRITE ),
163 aValue );
166 case AnimationFactory::CLASS_BOOL_PROPERTY:
168 BoolAnimation::ValueType aValue;
170 ENSURE_OR_THROW(
171 extractValue( aValue,
172 xAnimateNode->getTo(),
173 pShape,
174 getSlideSize() ),
175 "AnimationSetNode::createSetActivity(): "
176 "Could not import bool to value" );
178 return makeSetActivity(
179 aParms,
180 AnimationFactory::createBoolPropertyAnimation(
181 attrName,
182 pShape,
183 getContext().mpSubsettableShapeManager,
184 getSlideSize(),
185 getContext().mpBox2DWorld,
186 AnimationFactory::FLAG_NO_SPRITE ),
187 aValue );
191 return AnimationActivitySharedPtr();
194 } // namespace slideshow::internal
196 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */