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