1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
19 #ifndef INCLUDED_SLIDESHOW_SOURCE_ENGINE_ANIMATIONNODES_BASENODE_HXX
20 #define INCLUDED_SLIDESHOW_SOURCE_ENGINE_ANIMATIONNODES_BASENODE_HXX
22 #include <canvas/debug.hxx>
23 #include <tools/diagnose_ex.h>
24 #include <osl/diagnose.hxx>
27 #include "animationnode.hxx"
28 #include "slideshowcontext.hxx"
29 #include "shapesubset.hxx"
31 #include <boost/noncopyable.hpp>
37 /** Context for every node.
39 Besides the global AnimationNodeFactory::Context data,
40 this struct also contains the current DocTree subset
41 for this node. If start and end index of the
42 DocTreeNode are equal, the node should use the
47 NodeContext( const SlideShowContext
& rContext
,
48 const ::basegfx::B2DVector
& rSlideSize
)
49 : maContext( rContext
),
50 maSlideSize( rSlideSize
),
51 mpMasterShapeSubset(),
53 mbIsIndependentSubset( true )
59 mpMasterShapeSubset
.reset();
62 /// Context as passed to createAnimationNode()
63 SlideShowContext maContext
;
65 /// Size in user coordinate space of the corresponding slide
66 ::basegfx::B2DVector maSlideSize
;
68 /// Shape to be used (provided by parent, e.g. for iterations)
69 ShapeSubsetSharedPtr mpMasterShapeSubset
;
71 /// Additional delay to node begin (to offset iterate effects)
74 /// When true, subset must be created during slide initialization
75 bool mbIsIndependentSubset
;
78 class BaseContainerNode
;
80 /** This interface extends AnimationNode with some
81 file-private accessor methods.
83 class BaseNode
: public AnimationNode
,
84 public ::osl::DebugBase
<BaseNode
>,
85 private ::boost::noncopyable
88 BaseNode( ::com::sun::star::uno::Reference
<
89 ::com::sun::star::animations::XAnimationNode
> const& xNode
,
90 ::boost::shared_ptr
<BaseContainerNode
> const& pParent
,
91 NodeContext
const& rContext
);
93 /** Provide the node with a shared_ptr to itself.
95 Since implementation has to create objects which need
96 a shared_ptr to this node, and a pointee cannot
97 retrieve a shared_ptr to itself internally, have to
98 set that from the outside.
100 void setSelf( const ::boost::shared_ptr
< BaseNode
>& rSelf
);
103 #if OSL_DEBUG_LEVEL >= 2 && defined(DBG_UTIL)
104 virtual void showState() const;
105 virtual const char* getDescription() const;
108 const ::boost::shared_ptr
< BaseContainerNode
>& getParentNode() const
112 virtual void dispose() SAL_OVERRIDE
;
115 virtual bool init() SAL_OVERRIDE
;
116 virtual bool resolve() SAL_OVERRIDE
;
117 virtual bool activate() SAL_OVERRIDE
;
118 virtual void deactivate() SAL_OVERRIDE
;
119 virtual void end() SAL_OVERRIDE
;
120 virtual ::com::sun::star::uno::Reference
<
121 ::com::sun::star::animations::XAnimationNode
> getXAnimationNode() const SAL_OVERRIDE
;
122 virtual NodeState
getState() const SAL_OVERRIDE
;
123 virtual bool registerDeactivatingListener(
124 const AnimationNodeSharedPtr
& rNotifee
) SAL_OVERRIDE
;
126 virtual void notifyDeactivating( const AnimationNodeSharedPtr
& rNotifier
) SAL_OVERRIDE
;
128 bool isMainSequenceRootNode() const { return mbIsMainSequenceRootNode
; }
131 void scheduleDeactivationEvent( EventSharedPtr
const& pEvent
=
134 SlideShowContext
const& getContext() const { return maContext
; }
135 ::boost::shared_ptr
<BaseNode
> const& getSelf() const { return mpSelf
; }
137 bool checkValidNode() const {
138 ENSURE_OR_THROW( mpSelf
, "no self ptr set!" );
139 bool const bRet
= (meCurrState
!= INVALID
);
140 OSL_ENSURE( bRet
, "### INVALID node!" );
145 // all state affecting methods have "_st" counterparts being called at
146 // derived classes when in state transition: no-ops here at BaseNode...
147 virtual bool init_st();
148 virtual bool resolve_st();
149 virtual void activate_st();
150 virtual void deactivate_st( NodeState eDestState
);
154 /// - all registered deactivation listeners
155 /// - single animation end (every node)
156 /// - slide animations (if main sequence root node)
157 void notifyEndListeners() const;
159 /// Get the node's restart mode
160 sal_Int16
getRestartMode();
162 /** Get the default restart mode
164 If this node's default mode is
165 AnimationRestart::DEFAULT, this method recursively
166 calls the parent node.
168 sal_Int16
getRestartDefaultMode() const;
170 /// Get the node's fill mode
171 sal_Int16
getFillMode();
173 /** Get the default fill mode.
175 If this node's default mode is AnimationFill::DEFAULT,
176 this method recursively calls the parent node.
178 sal_Int16
getFillDefaultMode() const;
180 bool isTransition( NodeState eFromState
, NodeState eToState
,
181 bool debugAssert
= true ) const {
182 (void) debugAssert
; // avoid warning
183 bool const bRet
=((mpStateTransitionTable
[eFromState
] & eToState
) != 0);
184 OSL_ENSURE( !debugAssert
|| bRet
, "### state unreachable!" );
188 bool inStateOrTransition( int mask
) const {
189 return ((meCurrState
& mask
) != 0 ||
190 (meCurrentStateTransition
& mask
) != 0);
193 class StateTransition
;
194 friend class StateTransition
;
197 SlideShowContext maContext
;
199 typedef ::std::vector
< AnimationNodeSharedPtr
> ListenerVector
;
201 ListenerVector maDeactivatingListeners
;
202 ::com::sun::star::uno::Reference
<
203 ::com::sun::star::animations::XAnimationNode
> mxAnimationNode
;
204 ::boost::shared_ptr
< BaseContainerNode
> mpParent
;
205 ::boost::shared_ptr
< BaseNode
> mpSelf
;
206 const int* mpStateTransitionTable
;
207 const double mnStartDelay
;
208 NodeState meCurrState
;
209 int meCurrentStateTransition
;
210 EventSharedPtr mpCurrentEvent
;
211 const bool mbIsMainSequenceRootNode
;
214 typedef ::boost::shared_ptr
< BaseNode
> BaseNodeSharedPtr
;
216 } // namespace internal
217 } // namespace slideshow
219 #endif // INCLUDED_SLIDESHOW_SOURCE_ENGINE_ANIMATIONNODES_BASENODE_HXX
221 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */