LCOV - code coverage report
Current view: top level - slideshow/source/engine/animationnodes - basenode.hxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 0 20 0.0 %
Date: 2014-11-03 Functions: 0 12 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       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_ENGINE_ANIMATIONNODES_BASENODE_HXX
      20             : #define INCLUDED_SLIDESHOW_SOURCE_ENGINE_ANIMATIONNODES_BASENODE_HXX
      21             : 
      22             : #include <canvas/debug.hxx>
      23             : #include <tools/diagnose_ex.h>
      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 <boost/noncopyable.hpp>
      32             : #include <vector>
      33             : 
      34             : namespace slideshow {
      35             : namespace internal {
      36             : 
      37             : /** Context for every node.
      38             : 
      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
      43             :     complete shape.
      44             : */
      45           0 : struct NodeContext
      46             : {
      47           0 :     NodeContext( const SlideShowContext&                 rContext,
      48             :                  const ::basegfx::B2DVector&             rSlideSize )
      49             :         : maContext( rContext ),
      50             :           maSlideSize( rSlideSize ),
      51             :           mpMasterShapeSubset(),
      52             :           mnStartDelay(0.0),
      53           0 :           mbIsIndependentSubset( true )
      54           0 :         {}
      55             : 
      56             :     void dispose()
      57             :     {
      58             :         maContext.dispose();
      59             :         mpMasterShapeSubset.reset();
      60             :     }
      61             : 
      62             :     /// Context as passed to createAnimationNode()
      63             :     SlideShowContext                 maContext;
      64             : 
      65             :     /// Size in user coordinate space of the corresponding slide
      66             :     ::basegfx::B2DVector             maSlideSize;
      67             : 
      68             :     /// Shape to be used (provided by parent, e.g. for iterations)
      69             :     ShapeSubsetSharedPtr             mpMasterShapeSubset;
      70             : 
      71             :     /// Additional delay to node begin (to offset iterate effects)
      72             :     double                           mnStartDelay;
      73             : 
      74             :     /// When true, subset must be created during slide initialization
      75             :     bool                             mbIsIndependentSubset;
      76             : };
      77             : 
      78             : class BaseContainerNode;
      79             : 
      80             : /** This interface extends AnimationNode with some
      81             :     file-private accessor methods.
      82             : */
      83           0 : class BaseNode : public AnimationNode,
      84             :                  public  ::osl::DebugBase<BaseNode>,
      85             :                  private ::boost::noncopyable
      86             : {
      87             : public:
      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 );
      92             : 
      93             :     /** Provide the node with a shared_ptr to itself.
      94             : 
      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.
      99             :     */
     100             :     void setSelf( const ::boost::shared_ptr< BaseNode >& rSelf );
     101             : 
     102             : 
     103             : #if OSL_DEBUG_LEVEL >= 2 && defined(DBG_UTIL)
     104             :     virtual void showState() const;
     105             :     virtual const char* getDescription() const;
     106             : #endif
     107             : 
     108           0 :     const ::boost::shared_ptr< BaseContainerNode >& getParentNode() const
     109           0 :         { return mpParent; }
     110             : 
     111             :     // Disposable:
     112             :     virtual void dispose() SAL_OVERRIDE;
     113             : 
     114             :     // AnimationNode:
     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;
     125             :     // nop:
     126             :     virtual void notifyDeactivating( const AnimationNodeSharedPtr& rNotifier ) SAL_OVERRIDE;
     127             : 
     128           0 :     bool isMainSequenceRootNode() const { return mbIsMainSequenceRootNode; }
     129             : 
     130             : protected:
     131             :     void scheduleDeactivationEvent( EventSharedPtr const& pEvent =
     132             :                                     EventSharedPtr() );
     133             : 
     134           0 :     SlideShowContext const&                 getContext() const { return maContext; }
     135           0 :     ::boost::shared_ptr<BaseNode> const&    getSelf() const { return mpSelf; }
     136             : 
     137           0 :     bool checkValidNode() const {
     138           0 :         ENSURE_OR_THROW( mpSelf, "no self ptr set!" );
     139           0 :         bool const bRet = (meCurrState != INVALID);
     140             :         OSL_ENSURE( bRet, "### INVALID node!" );
     141           0 :         return bRet;
     142             :     }
     143             : 
     144             : private:
     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 );
     151             : 
     152             : private:
     153             :     /// notifies
     154             :     /// - all registered deactivation listeners
     155             :     /// - single animation end (every node)
     156             :     /// - slide animations (if main sequence root node)
     157             :     void notifyEndListeners() const;
     158             : 
     159             :     /// Get the node's restart mode
     160             :     sal_Int16 getRestartMode();
     161             : 
     162             :     /** Get the default restart mode
     163             : 
     164             :         If this node's default mode is
     165             :         AnimationRestart::DEFAULT, this method recursively
     166             :         calls the parent node.
     167             :     */
     168             :     sal_Int16 getRestartDefaultMode() const;
     169             : 
     170             :     /// Get the node's fill mode
     171             :     sal_Int16 getFillMode();
     172             : 
     173             :     /** Get the default fill mode.
     174             : 
     175             :         If this node's default mode is AnimationFill::DEFAULT,
     176             :         this method recursively calls the parent node.
     177             :     */
     178             :     sal_Int16 getFillDefaultMode() const;
     179             : 
     180           0 :     bool isTransition( NodeState eFromState, NodeState eToState,
     181             :                        bool debugAssert = true ) const {
     182             :         (void) debugAssert; // avoid warning
     183           0 :         bool const bRet =((mpStateTransitionTable[eFromState] & eToState) != 0);
     184             :         OSL_ENSURE( !debugAssert || bRet, "### state unreachable!" );
     185           0 :         return bRet;
     186             :     }
     187             : 
     188           0 :     bool inStateOrTransition( int mask ) const {
     189           0 :         return ((meCurrState & mask) != 0 ||
     190           0 :                 (meCurrentStateTransition & mask) != 0);
     191             :     }
     192             : 
     193             :     class StateTransition;
     194             :     friend class StateTransition;
     195             : 
     196             : private:
     197             :     SlideShowContext                                   maContext;
     198             : 
     199             :     typedef ::std::vector< AnimationNodeSharedPtr >    ListenerVector;
     200             : 
     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;
     212             : };
     213             : 
     214             : typedef ::boost::shared_ptr< BaseNode > BaseNodeSharedPtr;
     215             : 
     216             : } // namespace internal
     217             : } // namespace slideshow
     218             : 
     219             : #endif // INCLUDED_SLIDESHOW_SOURCE_ENGINE_ANIMATIONNODES_BASENODE_HXX
     220             : 
     221             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10