1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: basenode.hxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
30 #ifndef INCLUDED_SLIDESHOW_BASENODE_HXX
31 #define INCLUDED_SLIDESHOW_BASENODE_HXX
33 #include <canvas/debug.hxx>
34 #include <tools/diagnose_ex.h>
35 #include <osl/diagnose.hxx>
38 #include "animationnode.hxx"
39 #include "slideshowcontext.hxx"
40 #include "shapesubset.hxx"
42 #include <boost/noncopyable.hpp>
48 /** Context for every node.
50 Besides the global AnimationNodeFactory::Context data,
51 this struct also contains the current DocTree subset
52 for this node. If start and end index of the
53 DocTreeNode are equal, the node should use the
58 NodeContext( const SlideShowContext
& rContext
,
59 const ::basegfx::B2DVector
& rSlideSize
)
60 : maContext( rContext
),
61 maSlideSize( rSlideSize
),
62 mpMasterShapeSubset(),
64 mbIsIndependentSubset( true )
70 mpMasterShapeSubset
.reset();
73 /// Context as passed to createAnimationNode()
74 SlideShowContext maContext
;
76 /// Size in user coordinate space of the corresponding slide
77 ::basegfx::B2DVector maSlideSize
;
79 /// Shape to be used (provided by parent, e.g. for iterations)
80 ShapeSubsetSharedPtr mpMasterShapeSubset
;
82 /// Additional delay to node begin (to offset iterate effects)
85 /// When true, subset must be created during slide initialization
86 bool mbIsIndependentSubset
;
89 class BaseContainerNode
;
91 /** This interface extends AnimationNode with some
92 file-private accessor methods.
94 class BaseNode
: public AnimationNode
,
95 protected ::osl::DebugBase
<BaseNode
>,
96 private ::boost::noncopyable
99 BaseNode( ::com::sun::star::uno::Reference
<
100 ::com::sun::star::animations::XAnimationNode
> const& xNode
,
101 ::boost::shared_ptr
<BaseContainerNode
> const& pParent
,
102 NodeContext
const& rContext
);
104 /** Provide the node with a shared_ptr to itself.
106 Since implementation has to create objects which need
107 a shared_ptr to this node, and a pointee cannot
108 retrieve a shared_ptr to itself internally, have to
109 set that from the outside.
111 void setSelf( const ::boost::shared_ptr
< BaseNode
>& rSelf
);
114 #if defined(VERBOSE) && defined(DBG_UTIL)
115 virtual void showState() const;
116 virtual const char* getDescription() const;
117 void showTreeFromWithin() const;
120 const ::boost::shared_ptr
< BaseContainerNode
>& getParentNode() const
124 virtual void dispose();
128 virtual bool resolve();
129 virtual bool activate();
130 virtual void deactivate();
132 virtual ::com::sun::star::uno::Reference
<
133 ::com::sun::star::animations::XAnimationNode
> getXAnimationNode() const;
134 virtual NodeState
getState() const;
135 virtual bool registerDeactivatingListener(
136 const AnimationNodeSharedPtr
& rNotifee
);
138 virtual void notifyDeactivating( const AnimationNodeSharedPtr
& rNotifier
);
140 bool isMainSequenceRootNode() const { return mbIsMainSequenceRootNode
; }
143 void scheduleDeactivationEvent( EventSharedPtr
const& pEvent
=
146 SlideShowContext
const& getContext() const { return maContext
; }
147 ::boost::shared_ptr
<BaseNode
> const& getSelf() const { return mpSelf
; }
149 bool checkValidNode() const {
150 ENSURE_OR_THROW( mpSelf
, "no self ptr set!" );
151 bool const bRet
= (meCurrState
!= INVALID
);
152 OSL_ENSURE( bRet
, "### INVALID node!" );
157 // all state affecting methods have "_st" counterparts being called at
158 // derived classes when in state transistion: no-ops here at BaseNode...
159 virtual bool init_st();
160 virtual bool resolve_st();
161 virtual void activate_st();
162 virtual void deactivate_st( NodeState eDestState
);
166 /// - all registered deactivation listeners
167 /// - single animation end (every node)
168 /// - slide animations (if main sequence root node)
169 void notifyEndListeners() const;
171 /// Get the node's restart mode
172 sal_Int16
getRestartMode();
174 /** Get the default restart mode
176 If this node's default mode is
177 AnimationRestart::DEFAULT, this method recursively
178 calls the parent node.
180 sal_Int16
getRestartDefaultMode() const;
182 /// Get the node's fill mode
183 sal_Int16
getFillMode();
185 /** Get the default fill mode.
187 If this node's default mode is AnimationFill::DEFAULT,
188 this method recursively calls the parent node.
190 sal_Int16
getFillDefaultMode() const;
192 bool isTransition( NodeState eFromState
, NodeState eToState
,
193 bool debugAssert
= true ) const {
194 (void) debugAssert
; // avoid warning
195 bool const bRet
=((mpStateTransitionTable
[eFromState
] & eToState
) != 0);
196 OSL_ENSURE( !debugAssert
|| bRet
, "### state unreachable!" );
200 bool inStateOrTransition( int mask
) const {
201 return ((meCurrState
& mask
) != 0 ||
202 (meCurrentStateTransition
& mask
) != 0);
205 class StateTransition
;
206 friend class StateTransition
;
209 SlideShowContext maContext
;
211 typedef ::std::vector
< AnimationNodeSharedPtr
> ListenerVector
;
213 ListenerVector maDeactivatingListeners
;
214 ::com::sun::star::uno::Reference
<
215 ::com::sun::star::animations::XAnimationNode
> mxAnimationNode
;
216 ::boost::shared_ptr
< BaseContainerNode
> mpParent
;
217 ::boost::shared_ptr
< BaseNode
> mpSelf
;
218 const int* mpStateTransitionTable
;
219 const double mnStartDelay
;
220 NodeState meCurrState
;
221 int meCurrentStateTransition
;
222 EventSharedPtr mpCurrentEvent
;
223 const bool mbIsMainSequenceRootNode
;
226 typedef ::boost::shared_ptr
< BaseNode
> BaseNodeSharedPtr
;
228 } // namespace internal
229 } // namespace slideshow
231 #endif /* INCLUDED_SLIDESHOW_BASENODE_HXX */