1*aaef562fSAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*aaef562fSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*aaef562fSAndrew Rist * or more contributor license agreements. See the NOTICE file 5*aaef562fSAndrew Rist * distributed with this work for additional information 6*aaef562fSAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*aaef562fSAndrew Rist * to you under the Apache License, Version 2.0 (the 8*aaef562fSAndrew Rist * "License"); you may not use this file except in compliance 9*aaef562fSAndrew Rist * with the License. You may obtain a copy of the License at 10*aaef562fSAndrew Rist * 11*aaef562fSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12*aaef562fSAndrew Rist * 13*aaef562fSAndrew Rist * Unless required by applicable law or agreed to in writing, 14*aaef562fSAndrew Rist * software distributed under the License is distributed on an 15*aaef562fSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*aaef562fSAndrew Rist * KIND, either express or implied. See the License for the 17*aaef562fSAndrew Rist * specific language governing permissions and limitations 18*aaef562fSAndrew Rist * under the License. 19*aaef562fSAndrew Rist * 20*aaef562fSAndrew Rist *************************************************************/ 21*aaef562fSAndrew Rist 22*aaef562fSAndrew Rist 23cdf0e10cSrcweir #ifndef INCLUDED_SLIDESHOW_ANIMATIONNODE_HXX 24cdf0e10cSrcweir #define INCLUDED_SLIDESHOW_ANIMATIONNODE_HXX 25cdf0e10cSrcweir 26cdf0e10cSrcweir #include "disposable.hxx" 27cdf0e10cSrcweir 28cdf0e10cSrcweir #include <com/sun/star/animations/XAnimationNode.hpp> 29cdf0e10cSrcweir #include <boost/shared_ptr.hpp> 30cdf0e10cSrcweir 31cdf0e10cSrcweir namespace slideshow { 32cdf0e10cSrcweir namespace internal { 33cdf0e10cSrcweir 34cdf0e10cSrcweir /** This interface is used to mirror every XAnimateNode object 35cdf0e10cSrcweir in the presentation core. 36cdf0e10cSrcweir */ 37cdf0e10cSrcweir class AnimationNode : public Disposable 38cdf0e10cSrcweir { 39cdf0e10cSrcweir public: 40cdf0e10cSrcweir /** The current state of this AnimationNode 41cdf0e10cSrcweir */ 42cdf0e10cSrcweir enum NodeState { 43cdf0e10cSrcweir /// Invalid state, node is disposed or otherwise invalid 44cdf0e10cSrcweir INVALID =0, 45cdf0e10cSrcweir /// Unresolved start time 46cdf0e10cSrcweir UNRESOLVED =1, 47cdf0e10cSrcweir /// Resolved start time, node will start eventually 48cdf0e10cSrcweir RESOLVED =2, 49cdf0e10cSrcweir /// Node is active 50cdf0e10cSrcweir ACTIVE =4, 51cdf0e10cSrcweir /// Node is frozen (no longer active, but changes remain in place) 52cdf0e10cSrcweir FROZEN =8, 53cdf0e10cSrcweir /// Node has completed an active lifecycle, 54cdf0e10cSrcweir /// and any effect is removed from the document 55cdf0e10cSrcweir ENDED =16 56cdf0e10cSrcweir }; 57cdf0e10cSrcweir 58cdf0e10cSrcweir /** Query the corresponding XAnimationNode. 59cdf0e10cSrcweir */ 60cdf0e10cSrcweir virtual ::com::sun::star::uno::Reference< 61cdf0e10cSrcweir ::com::sun::star::animations::XAnimationNode > 62cdf0e10cSrcweir getXAnimationNode() const = 0; 63cdf0e10cSrcweir 64cdf0e10cSrcweir /** Init this node 65cdf0e10cSrcweir 66cdf0e10cSrcweir If this node is not in state INVALID, init() sets up the 67cdf0e10cSrcweir node state and schedules necessary events. 68cdf0e10cSrcweir If this node has children, they have their init() called, too. 69cdf0e10cSrcweir You will call this method whenever a slide is going to be 70cdf0e10cSrcweir shown. 71cdf0e10cSrcweir 72cdf0e10cSrcweir @return true, if init was successful; state has changed to UNRESOLVED 73cdf0e10cSrcweir */ 74cdf0e10cSrcweir virtual bool init() = 0; 75cdf0e10cSrcweir 76cdf0e10cSrcweir /** Resolve node start time 77cdf0e10cSrcweir 78cdf0e10cSrcweir Nodes can have unresolved start times, i.e. indefinite 79cdf0e10cSrcweir start time for container nodes, or child nodes whose 80cdf0e10cSrcweir parent has not yet started. Calling this method fixes 81cdf0e10cSrcweir the node's start time. This does not mean that this 82cdf0e10cSrcweir node immediately starts its animations, that is only 83cdf0e10cSrcweir the case for begin=0.0. The node will change its state 84cdf0e10cSrcweir to RESOLVED. 85cdf0e10cSrcweir 86cdf0e10cSrcweir @return true, if a start event was successfully scheduled. 87cdf0e10cSrcweir */ 88cdf0e10cSrcweir virtual bool resolve() = 0; 89cdf0e10cSrcweir 90cdf0e10cSrcweir /** Immediately start this node 91cdf0e10cSrcweir 92cdf0e10cSrcweir This method starts the animation on this node, without 93cdf0e10cSrcweir begin timeout. The node will change its state to ACTIVE. 94cdf0e10cSrcweir 95cdf0e10cSrcweir @return true, if start was successful. This method 96cdf0e10cSrcweir might return false, if e.g. a restart is not permitted 97cdf0e10cSrcweir on this node. 98cdf0e10cSrcweir */ 99cdf0e10cSrcweir virtual bool activate() = 0; 100cdf0e10cSrcweir 101cdf0e10cSrcweir /** Immediately stop this node 102cdf0e10cSrcweir 103cdf0e10cSrcweir This method stops the animation on this node. The node 104cdf0e10cSrcweir will change its state to either ENDED or FROZEN, 105cdf0e10cSrcweir depending on XAnimationNode attributes. 106cdf0e10cSrcweir */ 107cdf0e10cSrcweir virtual void deactivate() = 0; 108cdf0e10cSrcweir 109cdf0e10cSrcweir /** End the animation on this node 110cdf0e10cSrcweir 111cdf0e10cSrcweir This method force-ends animation on this node. Parents 112cdf0e10cSrcweir may call this for their children, if their active 113cdf0e10cSrcweir duration ends. An ended animation will no longer have 114cdf0e10cSrcweir any effect on the shape attributes. The node will 115cdf0e10cSrcweir change its state to ENDED. 116cdf0e10cSrcweir */ 117cdf0e10cSrcweir virtual void end() = 0; 118cdf0e10cSrcweir 119cdf0e10cSrcweir /** Query node state 120cdf0e10cSrcweir 121cdf0e10cSrcweir @return the current state of this animation node. 122cdf0e10cSrcweir */ 123cdf0e10cSrcweir virtual NodeState getState() const = 0; 124cdf0e10cSrcweir 125cdf0e10cSrcweir /** Register a deactivating listener 126cdf0e10cSrcweir 127cdf0e10cSrcweir This method registers another AnimationNode as an 128cdf0e10cSrcweir deactivating listener, which gets notified via a 129cdf0e10cSrcweir notifyDeactivating() call. The node calls all 130cdf0e10cSrcweir registered listener, when it leaves the ACTIVE state. 131cdf0e10cSrcweir 132cdf0e10cSrcweir @param rNotifee AnimationNode to notify 133cdf0e10cSrcweir */ 134cdf0e10cSrcweir virtual bool registerDeactivatingListener( 135cdf0e10cSrcweir const ::boost::shared_ptr< AnimationNode >& rNotifee ) = 0; 136cdf0e10cSrcweir 137cdf0e10cSrcweir /** Called to notify another AnimationNode's deactivation 138cdf0e10cSrcweir 139cdf0e10cSrcweir @param rNotifier The instance who calls this method. 140cdf0e10cSrcweir */ 141cdf0e10cSrcweir virtual void notifyDeactivating( 142cdf0e10cSrcweir const ::boost::shared_ptr< AnimationNode >& rNotifier ) = 0; 143cdf0e10cSrcweir 144cdf0e10cSrcweir /** Query node whether it has an animation pending. 145cdf0e10cSrcweir 146cdf0e10cSrcweir @return true, if this node (or at least one of its children) 147cdf0e10cSrcweir has an animation pending. Used to determine if the main 148cdf0e10cSrcweir sequence is actually empty, or contains effects 149cdf0e10cSrcweir */ 150cdf0e10cSrcweir virtual bool hasPendingAnimation() const = 0; 151cdf0e10cSrcweir }; 152cdf0e10cSrcweir 153cdf0e10cSrcweir typedef ::boost::shared_ptr< AnimationNode > AnimationNodeSharedPtr; 154cdf0e10cSrcweir 155cdf0e10cSrcweir } // namespace internal 156cdf0e10cSrcweir } // namespace presentation 157cdf0e10cSrcweir 158cdf0e10cSrcweir #endif /* INCLUDED_SLIDESHOW_ANIMATIONNODE_HXX */ 159cdf0e10cSrcweir 160