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_INC_BASENODE_HXX
20 #define INCLUDED_SLIDESHOW_SOURCE_INC_BASENODE_HXX
22 #include <basegfx/vector/b2dvector.hxx>
23 #include <comphelper/diagnose_ex.hxx>
24 #include <osl/diagnose.hxx>
27 #include "animationnode.hxx"
28 #include "slideshowcontext.hxx"
29 #include "shapesubset.hxx"
34 namespace slideshow::internal
{
36 /** Context for every node.
38 Besides the global AnimationNodeFactory::Context data,
39 this struct also contains the current DocTree subset
40 for this node. If start and end index of the
41 DocTreeNode are equal, the node should use the
46 NodeContext( SlideShowContext aContext
,
47 const ::basegfx::B2DVector
& rSlideSize
)
48 : maContext(std::move( aContext
)),
49 maSlideSize( rSlideSize
),
50 mpMasterShapeSubset(),
52 mbIsIndependentSubset( true )
55 /// Context as passed to createAnimationNode()
56 SlideShowContext maContext
;
58 /// Size in user coordinate space of the corresponding slide
59 ::basegfx::B2DVector maSlideSize
;
61 /// Shape to be used (provided by parent, e.g. for iterations)
62 ShapeSubsetSharedPtr mpMasterShapeSubset
;
64 /// Additional delay to node begin (to offset iterate effects)
67 /// When true, subset must be created during slide initialization
68 bool mbIsIndependentSubset
;
71 class BaseContainerNode
;
72 typedef ::std::shared_ptr
< BaseContainerNode
> BaseContainerNodeSharedPtr
;
75 typedef ::std::shared_ptr
< BaseNode
> BaseNodeSharedPtr
;
78 /** This interface extends AnimationNode with some
79 file-private accessor methods.
81 class BaseNode
: public AnimationNode
,
82 public ::osl::DebugBase
<BaseNode
>
85 BaseNode( css::uno::Reference
<css::animations::XAnimationNode
> const& xNode
,
86 BaseContainerNodeSharedPtr pParent
,
87 NodeContext
const& rContext
);
88 BaseNode(const BaseNode
&) = delete;
89 BaseNode
& operator=(const BaseNode
&) = delete;
91 /** Provide the node with a shared_ptr to itself.
93 Since implementation has to create objects which need
94 a shared_ptr to this node, and a pointee cannot
95 retrieve a shared_ptr to itself internally, have to
96 set that from the outside.
98 void setSelf( const BaseNodeSharedPtr
& rSelf
);
101 #if defined(DBG_UTIL)
102 virtual void showState() const;
103 virtual const char* getDescription() const;
106 const ::std::shared_ptr
< BaseContainerNode
>& getParentNode() const
110 virtual void dispose() override
;
113 virtual bool init() override
;
114 virtual bool resolve() override
;
115 virtual void activate() override
;
116 virtual void deactivate() override
;
117 virtual void end() override
;
118 virtual css::uno::Reference
<css::animations::XAnimationNode
> getXAnimationNode() const override
;
119 virtual NodeState
getState() const override
;
120 virtual bool registerDeactivatingListener(
121 const AnimationNodeSharedPtr
& rNotifee
) override
;
123 virtual void notifyDeactivating( const AnimationNodeSharedPtr
& rNotifier
) override
;
125 bool isMainSequenceRootNode() const { return mbIsMainSequenceRootNode
; }
127 /// Get the node's fill mode
128 sal_Int16
getFillMode();
130 virtual void removeEffect() override
{}
132 void scheduleDeactivationEvent( EventSharedPtr
const& pEvent
=
135 SlideShowContext
const& getContext() const { return maContext
; }
136 ::std::shared_ptr
<BaseNode
> const& getSelf() const { return mpSelf
; }
138 bool checkValidNode() const {
139 ENSURE_OR_THROW( mpSelf
, "no self ptr set!" );
140 bool const bRet
= (meCurrState
!= INVALID
);
141 OSL_ENSURE( bRet
, "### INVALID node!" );
146 // all state affecting methods have "_st" counterparts being called at
147 // derived classes when in state transition: no-ops here at BaseNode...
148 virtual bool init_st();
149 virtual bool resolve_st();
150 virtual void activate_st();
151 virtual void deactivate_st( NodeState eDestState
);
155 /// - all registered deactivation listeners
156 /// - single animation end (every node)
157 /// - slide animations (if main sequence root node)
158 void notifyEndListeners() const;
160 /// Get the node's restart mode
161 sal_Int16
getRestartMode();
163 /** Get the default restart mode
165 If this node's default mode is
166 AnimationRestart::DEFAULT, this method recursively
167 calls the parent node.
169 sal_Int16
getRestartDefaultMode() const;
171 /** Get the default fill mode.
173 If this node's default mode is AnimationFill::DEFAULT,
174 this method recursively calls the parent node.
176 sal_Int16
getFillDefaultMode() const;
178 bool isTransition( NodeState eFromState
, NodeState eToState
,
179 bool debugAssert
= true ) const {
180 bool const bRet
=((mpStateTransitionTable
[eFromState
] & eToState
) != 0);
181 OSL_ENSURE( !debugAssert
|| bRet
, "### state unreachable!" );
185 bool inStateOrTransition( int mask
) const {
186 return ((meCurrState
& mask
) != 0 ||
187 (meCurrentStateTransition
& mask
) != 0);
190 class StateTransition
;
191 friend class StateTransition
;
194 SlideShowContext maContext
;
196 ::std::vector
< AnimationNodeSharedPtr
> maDeactivatingListeners
;
197 css::uno::Reference
< css::animations::XAnimationNode
> mxAnimationNode
;
198 ::std::shared_ptr
< BaseContainerNode
> mpParent
;
199 ::std::shared_ptr
< BaseNode
> mpSelf
;
200 const int* mpStateTransitionTable
;
201 const double mnStartDelay
;
202 NodeState meCurrState
;
203 int meCurrentStateTransition
;
204 EventSharedPtr mpCurrentEvent
;
205 const bool mbIsMainSequenceRootNode
;
208 } // namespace slideshow::internal
212 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */