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