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