Update ooo320-m1
[ooovba.git] / slideshow / source / engine / animationnodes / nodetools.cxx
blobb1ad8143e7ea1c9655da538861bfe26ac23ca419
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: nodetools.cxx,v $
10 * $Revision: 1.9 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_slideshow.hxx"
34 // must be first
35 #include <canvas/debug.hxx>
36 #include <canvas/verbosetrace.hxx>
38 #include <com/sun/star/animations/Timing.hpp>
40 #include <tools.hxx>
41 #include <nodetools.hxx>
44 using namespace ::com::sun::star;
46 namespace slideshow
48 namespace internal
50 #if defined(VERBOSE) && defined(DBG_UTIL)
51 int& debugGetCurrentOffset()
53 static int lcl_nOffset = 0; // to make each tree output distinct
55 return lcl_nOffset;
58 void debugNodesShowTree( const BaseNode* pNode )
60 if( pNode )
61 pNode->showState();
63 ++debugGetCurrentOffset();
66 void debugNodesShowTreeWithin( const BaseNode* pNode )
68 if( pNode )
69 pNode->showTreeFromWithin();
71 ++debugGetCurrentOffset();
73 #endif
75 AttributableShapeSharedPtr lookupAttributableShape( const ShapeManagerSharedPtr& rShapeManager,
76 const uno::Reference< drawing::XShape >& xShape )
78 ENSURE_OR_THROW( rShapeManager,
79 "lookupAttributableShape(): invalid ShapeManager" );
81 ShapeSharedPtr pShape( rShapeManager->lookupShape( xShape ) );
83 ENSURE_OR_THROW( pShape,
84 "lookupAttributableShape(): no shape found for given XShape" );
86 AttributableShapeSharedPtr pRes(
87 ::boost::dynamic_pointer_cast< AttributableShape >( pShape ) );
89 // TODO(E3): Cannot throw here, people might set animation info
90 // for non-animatable shapes from the API. AnimationNodes must catch
91 // the exception and handle that differently
92 ENSURE_OR_THROW( pRes,
93 "lookupAttributableShape(): shape found does not implement AttributableShape interface" );
95 return pRes;
98 bool isIndefiniteTiming( const uno::Any& rAny )
100 if( !rAny.hasValue() )
101 return true;
103 animations::Timing eTiming;
105 if( !(rAny >>= eTiming) ||
106 eTiming != animations::Timing_INDEFINITE )
108 return false;
111 return true;
114 /// Extract the node type from the user data
115 bool getNodeType( sal_Int16& o_rNodeType,
116 const uno::Sequence< beans::NamedValue >& rValues )
118 beans::NamedValue aNamedValue;
120 if( findNamedValue( &aNamedValue,
121 rValues,
122 ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("node-type") ) ) )
124 if( (aNamedValue.Value >>= o_rNodeType) )
125 return true;
128 return false;