LibreOffice Module slideshow (master) 1
basenode.hxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19#ifndef INCLUDED_SLIDESHOW_SOURCE_INC_BASENODE_HXX
20#define INCLUDED_SLIDESHOW_SOURCE_INC_BASENODE_HXX
21
24#include <osl/diagnose.hxx>
25
26#include "event.hxx"
27#include "animationnode.hxx"
28#include "slideshowcontext.hxx"
29#include "shapesubset.hxx"
30
31#include <utility>
32#include <vector>
33
34namespace slideshow::internal {
35
45{
47 const ::basegfx::B2DVector& rSlideSize )
48 : maContext(std::move( aContext )),
49 maSlideSize( rSlideSize ),
51 mnStartDelay(0.0),
53 {}
54
57
60
63
66
69};
70
72typedef ::std::shared_ptr< BaseContainerNode > BaseContainerNodeSharedPtr;
73
74class BaseNode;
75typedef ::std::shared_ptr< BaseNode > BaseNodeSharedPtr;
76
77
81class BaseNode : public AnimationNode,
82 public ::osl::DebugBase<BaseNode>
83{
84public:
85 BaseNode( css::uno::Reference<css::animations::XAnimationNode> const& xNode,
87 NodeContext const& rContext );
88 BaseNode(const BaseNode&) = delete;
89 BaseNode& operator=(const BaseNode&) = delete;
90
98 void setSelf( const BaseNodeSharedPtr& rSelf );
99
100
101#if defined(DBG_UTIL)
102 virtual void showState() const;
103 virtual const char* getDescription() const;
104#endif
105
106 const ::std::shared_ptr< BaseContainerNode >& getParentNode() const
107 { return mpParent; }
108
109 // Disposable:
110 virtual void dispose() override;
111
112 // AnimationNode:
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;
122 // nop:
123 virtual void notifyDeactivating( const AnimationNodeSharedPtr& rNotifier ) override;
124
126
128 sal_Int16 getFillMode();
129
130 virtual void removeEffect() override {}
131protected:
132 void scheduleDeactivationEvent( EventSharedPtr const& pEvent =
133 EventSharedPtr() );
134
135 SlideShowContext const& getContext() const { return maContext; }
136 ::std::shared_ptr<BaseNode> const& getSelf() const { return mpSelf; }
137
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!" );
142 return bRet;
143 }
144
145private:
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 );
152
153private:
158 void notifyEndListeners() const;
159
161 sal_Int16 getRestartMode();
162
169 sal_Int16 getRestartDefaultMode() const;
170
176 sal_Int16 getFillDefaultMode() const;
177
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!" );
182 return bRet;
183 }
184
185 bool inStateOrTransition( int mask ) const {
186 return ((meCurrState & mask) != 0 ||
187 (meCurrentStateTransition & mask) != 0);
188 }
189
190 class StateTransition;
191 friend class StateTransition;
192
193private:
195
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;
201 const double mnStartDelay;
206};
207
208} // namespace slideshow::internal
209
210#endif
211
212/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
This interface is used to mirror every XAnimateNode object in the presentation core.
NodeState
The current state of this AnimationNode.
@ INVALID
Invalid state, node is disposed or otherwise invalid.
This interface extends BaseNode with child handling methods.
This interface extends AnimationNode with some file-private accessor methods.
Definition: basenode.hxx:83
virtual void end() override
End the animation on this node.
Definition: basenode.cxx:597
const ::std::shared_ptr< BaseContainerNode > & getParentNode() const
Definition: basenode.hxx:106
bool isMainSequenceRootNode() const
Definition: basenode.hxx:125
bool inStateOrTransition(int mask) const
Definition: basenode.hxx:185
virtual void activate() override
Immediately start this node.
Definition: basenode.cxx:494
virtual void showState() const
Definition: basenode.cxx:688
SlideShowContext maContext
Definition: basenode.hxx:194
BaseNode(const BaseNode &)=delete
virtual css::uno::Reference< css::animations::XAnimationNode > getXAnimationNode() const override
Query the corresponding XAnimationNode.
Definition: basenode.cxx:408
SlideShowContext const & getContext() const
Definition: basenode.hxx:135
virtual void removeEffect() override
Called by the container to remove the animation effect to make the painted shape correct if it restar...
Definition: basenode.hxx:130
virtual bool init() override
Init this node.
Definition: basenode.cxx:413
::std::shared_ptr< BaseNode > mpSelf
Definition: basenode.hxx:199
bool isTransition(NodeState eFromState, NodeState eToState, bool debugAssert=true) const
Definition: basenode.hxx:178
sal_Int16 getFillMode()
Get the node's fill mode.
Definition: basenode.cxx:363
const int * mpStateTransitionTable
Definition: basenode.hxx:200
::std::shared_ptr< BaseContainerNode > mpParent
Definition: basenode.hxx:198
css::uno::Reference< css::animations::XAnimationNode > mxAnimationNode
Definition: basenode.hxx:197
void setSelf(const BaseNodeSharedPtr &rSelf)
Provide the node with a shared_ptr to itself.
Definition: basenode.cxx:674
::std::shared_ptr< BaseNode > const & getSelf() const
Definition: basenode.hxx:136
virtual void dispose() override
Dispose all object references.
Definition: basenode.cxx:339
virtual bool registerDeactivatingListener(const AnimationNodeSharedPtr &rNotifee) override
Register a deactivating listener.
Definition: basenode.cxx:660
EventSharedPtr mpCurrentEvent
Definition: basenode.hxx:204
void notifyEndListeners() const
notifies
Definition: basenode.cxx:634
virtual void deactivate_st(NodeState eDestState)
Definition: basenode.cxx:593
BaseNode & operator=(const BaseNode &)=delete
sal_Int16 getRestartMode()
Get the node's restart mode.
Definition: basenode.cxx:356
virtual const char * getDescription() const
Definition: basenode.cxx:743
virtual NodeState getState() const override
Query node state.
Definition: basenode.cxx:655
::std::vector< AnimationNodeSharedPtr > maDeactivatingListeners
Definition: basenode.hxx:196
BaseNode(css::uno::Reference< css::animations::XAnimationNode > const &xNode, BaseContainerNodeSharedPtr pParent, NodeContext const &rContext)
virtual bool resolve() override
Resolve node start time.
Definition: basenode.cxx:431
virtual void deactivate() override
Immediately stop this node.
Definition: basenode.cxx:564
sal_Int16 getRestartDefaultMode() const
Get the default restart mode.
Definition: basenode.cxx:397
sal_Int16 getFillDefaultMode() const
Get the default fill mode.
Definition: basenode.cxx:386
void scheduleDeactivationEvent(EventSharedPtr const &pEvent=EventSharedPtr())
Definition: basenode.cxx:519
virtual void notifyDeactivating(const AnimationNodeSharedPtr &rNotifier) override
Called to notify another AnimationNode's deactivation.
Definition: basenode.cxx:627
#define ENSURE_OR_THROW(c, m)
::std::shared_ptr< ShapeSubset > ShapeSubsetSharedPtr
Definition: shapesubset.hxx:30
::std::shared_ptr< BaseContainerNode > BaseContainerNodeSharedPtr
::std::shared_ptr< AnimationNode > AnimationNodeSharedPtr
::std::shared_ptr< Event > EventSharedPtr
Definition: event.hxx:76
::std::shared_ptr< BaseNode > BaseNodeSharedPtr
Definition: basenode.hxx:74
Context for every node.
Definition: basenode.hxx:45
NodeContext(SlideShowContext aContext, const ::basegfx::B2DVector &rSlideSize)
Definition: basenode.hxx:46
bool mbIsIndependentSubset
When true, subset must be created during slide initialization.
Definition: basenode.hxx:68
ShapeSubsetSharedPtr mpMasterShapeSubset
Shape to be used (provided by parent, e.g. for iterations)
Definition: basenode.hxx:62
SlideShowContext maContext
Context as passed to createAnimationNode()
Definition: basenode.hxx:56
::basegfx::B2DVector maSlideSize
Size in user coordinate space of the corresponding slide.
Definition: basenode.hxx:59
double mnStartDelay
Additional delay to node begin (to offset iterate effects)
Definition: basenode.hxx:65
Common arguments for slideshow objects.