1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 #ifndef INCLUDED_SLIDESHOW_BASECONTAINERNODE_HXX
28 #define INCLUDED_SLIDESHOW_BASECONTAINERNODE_HXX
29 
30 #include "basenode.hxx"
31 
32 namespace slideshow {
33 namespace internal {
34 
35 /** This interface extends BaseNode with child handling methods.
36     Used for XAnimationNode objects which have children
37 */
38 class BaseContainerNode : public BaseNode
39 {
40 public:
41     BaseContainerNode(
42         ::com::sun::star::uno::Reference<
43         ::com::sun::star::animations::XAnimationNode> const& xNode,
44         ::boost::shared_ptr<BaseContainerNode> const& pParent,
45         NodeContext const& rContext );
46 
47     /** Add given child node to this container
48      */
49     void appendChildNode( AnimationNodeSharedPtr const& pNode );
50 
51 #if defined(VERBOSE) && defined(DBG_UTIL)
52     virtual void showState() const;
53     virtual const char* getDescription() const { return "BaseContainerNode"; }
54 #endif
55 
56 protected:
57     // overrides from BaseNode
58     virtual void dispose();
59 
60 private:
61     virtual bool init_st();
62     virtual void deactivate_st( NodeState eDestState );
63     virtual bool hasPendingAnimation() const;
64     // force to be implemented by derived class:
65     virtual void activate_st() = 0;
66     virtual void notifyDeactivating(
67         AnimationNodeSharedPtr const& rNotifier ) = 0;
68 
69 protected:
70     bool isDurationIndefinite() const { return mbDurationIndefinite; }
71 
72     bool isChildNode( AnimationNodeSharedPtr const& pNode ) const;
73 
74     /// @return true: if all children have been deactivated
75     bool notifyDeactivatedChild( AnimationNodeSharedPtr const& pChildNode );
76 
77     template <typename FuncT>
78     inline void forEachChildNode( FuncT const& func,
79                                   int nodeStateMask = -1 ) const
80     {
81         VectorOfNodes::const_iterator iPos( maChildren.begin() );
82         VectorOfNodes::const_iterator const iEnd( maChildren.end() );
83         for ( ; iPos != iEnd; ++iPos ) {
84             AnimationNodeSharedPtr const& pNode = *iPos;
85             if (nodeStateMask != -1 && (pNode->getState() & nodeStateMask) == 0)
86                 continue;
87             func(pNode);
88         }
89     }
90 
91     typedef ::std::vector<AnimationNodeSharedPtr> VectorOfNodes;
92     VectorOfNodes       maChildren;
93     ::std::size_t       mnFinishedChildren;
94 
95 private:
96     const bool          mbDurationIndefinite;
97 };
98 
99 typedef ::boost::shared_ptr< BaseContainerNode > BaseContainerNodeSharedPtr;
100 
101 } // namespace interface
102 } // namespace presentation
103 
104 #endif /* INCLUDED_SLIDESHOW_BASECONTAINERNODE_HXX */
105 
106