1*70f497fbSAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*70f497fbSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*70f497fbSAndrew Rist * or more contributor license agreements. See the NOTICE file 5*70f497fbSAndrew Rist * distributed with this work for additional information 6*70f497fbSAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*70f497fbSAndrew Rist * to you under the Apache License, Version 2.0 (the 8*70f497fbSAndrew Rist * "License"); you may not use this file except in compliance 9*70f497fbSAndrew Rist * with the License. You may obtain a copy of the License at 10*70f497fbSAndrew Rist * 11*70f497fbSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12*70f497fbSAndrew Rist * 13*70f497fbSAndrew Rist * Unless required by applicable law or agreed to in writing, 14*70f497fbSAndrew Rist * software distributed under the License is distributed on an 15*70f497fbSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*70f497fbSAndrew Rist * KIND, either express or implied. See the License for the 17*70f497fbSAndrew Rist * specific language governing permissions and limitations 18*70f497fbSAndrew Rist * under the License. 19*70f497fbSAndrew Rist * 20*70f497fbSAndrew Rist *************************************************************/ 21*70f497fbSAndrew Rist 22*70f497fbSAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 25cdf0e10cSrcweir #include "precompiled_slideshow.hxx" 26cdf0e10cSrcweir 27cdf0e10cSrcweir // must be first 28cdf0e10cSrcweir #include <canvas/debug.hxx> 29cdf0e10cSrcweir #include <canvas/verbosetrace.hxx> 30cdf0e10cSrcweir 31cdf0e10cSrcweir #include <com/sun/star/animations/Timing.hpp> 32cdf0e10cSrcweir 33cdf0e10cSrcweir #include <tools.hxx> 34cdf0e10cSrcweir #include <nodetools.hxx> 35cdf0e10cSrcweir 36cdf0e10cSrcweir 37cdf0e10cSrcweir using namespace ::com::sun::star; 38cdf0e10cSrcweir 39cdf0e10cSrcweir namespace slideshow 40cdf0e10cSrcweir { 41cdf0e10cSrcweir namespace internal 42cdf0e10cSrcweir { 43cdf0e10cSrcweir #if defined(VERBOSE) && defined(DBG_UTIL) debugGetCurrentOffset()44cdf0e10cSrcweir int& debugGetCurrentOffset() 45cdf0e10cSrcweir { 46cdf0e10cSrcweir static int lcl_nOffset = 0; // to make each tree output distinct 47cdf0e10cSrcweir 48cdf0e10cSrcweir return lcl_nOffset; 49cdf0e10cSrcweir } 50cdf0e10cSrcweir debugNodesShowTree(const BaseNode * pNode)51cdf0e10cSrcweir void debugNodesShowTree( const BaseNode* pNode ) 52cdf0e10cSrcweir { 53cdf0e10cSrcweir if( pNode ) 54cdf0e10cSrcweir pNode->showState(); 55cdf0e10cSrcweir 56cdf0e10cSrcweir ++debugGetCurrentOffset(); 57cdf0e10cSrcweir } 58cdf0e10cSrcweir debugNodesShowTreeWithin(const BaseNode * pNode)59cdf0e10cSrcweir void debugNodesShowTreeWithin( const BaseNode* pNode ) 60cdf0e10cSrcweir { 61cdf0e10cSrcweir if( pNode ) 62cdf0e10cSrcweir pNode->showTreeFromWithin(); 63cdf0e10cSrcweir 64cdf0e10cSrcweir ++debugGetCurrentOffset(); 65cdf0e10cSrcweir } 66cdf0e10cSrcweir #endif 67cdf0e10cSrcweir lookupAttributableShape(const ShapeManagerSharedPtr & rShapeManager,const uno::Reference<drawing::XShape> & xShape)68cdf0e10cSrcweir AttributableShapeSharedPtr lookupAttributableShape( const ShapeManagerSharedPtr& rShapeManager, 69cdf0e10cSrcweir const uno::Reference< drawing::XShape >& xShape ) 70cdf0e10cSrcweir { 71cdf0e10cSrcweir ENSURE_OR_THROW( rShapeManager, 72cdf0e10cSrcweir "lookupAttributableShape(): invalid ShapeManager" ); 73cdf0e10cSrcweir 74cdf0e10cSrcweir ShapeSharedPtr pShape( rShapeManager->lookupShape( xShape ) ); 75cdf0e10cSrcweir 76cdf0e10cSrcweir ENSURE_OR_THROW( pShape, 77cdf0e10cSrcweir "lookupAttributableShape(): no shape found for given XShape" ); 78cdf0e10cSrcweir 79cdf0e10cSrcweir AttributableShapeSharedPtr pRes( 80cdf0e10cSrcweir ::boost::dynamic_pointer_cast< AttributableShape >( pShape ) ); 81cdf0e10cSrcweir 82cdf0e10cSrcweir // TODO(E3): Cannot throw here, people might set animation info 83cdf0e10cSrcweir // for non-animatable shapes from the API. AnimationNodes must catch 84cdf0e10cSrcweir // the exception and handle that differently 85cdf0e10cSrcweir ENSURE_OR_THROW( pRes, 86cdf0e10cSrcweir "lookupAttributableShape(): shape found does not implement AttributableShape interface" ); 87cdf0e10cSrcweir 88cdf0e10cSrcweir return pRes; 89cdf0e10cSrcweir } 90cdf0e10cSrcweir isIndefiniteTiming(const uno::Any & rAny)91cdf0e10cSrcweir bool isIndefiniteTiming( const uno::Any& rAny ) 92cdf0e10cSrcweir { 93cdf0e10cSrcweir if( !rAny.hasValue() ) 94cdf0e10cSrcweir return true; 95cdf0e10cSrcweir 96cdf0e10cSrcweir animations::Timing eTiming; 97cdf0e10cSrcweir 98cdf0e10cSrcweir if( !(rAny >>= eTiming) || 99cdf0e10cSrcweir eTiming != animations::Timing_INDEFINITE ) 100cdf0e10cSrcweir { 101cdf0e10cSrcweir return false; 102cdf0e10cSrcweir } 103cdf0e10cSrcweir 104cdf0e10cSrcweir return true; 105cdf0e10cSrcweir } 106cdf0e10cSrcweir 107cdf0e10cSrcweir /// Extract the node type from the user data getNodeType(sal_Int16 & o_rNodeType,const uno::Sequence<beans::NamedValue> & rValues)108cdf0e10cSrcweir bool getNodeType( sal_Int16& o_rNodeType, 109cdf0e10cSrcweir const uno::Sequence< beans::NamedValue >& rValues ) 110cdf0e10cSrcweir { 111cdf0e10cSrcweir beans::NamedValue aNamedValue; 112cdf0e10cSrcweir 113cdf0e10cSrcweir if( findNamedValue( &aNamedValue, 114cdf0e10cSrcweir rValues, 115cdf0e10cSrcweir ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("node-type") ) ) ) 116cdf0e10cSrcweir { 117cdf0e10cSrcweir if( (aNamedValue.Value >>= o_rNodeType) ) 118cdf0e10cSrcweir return true; 119cdf0e10cSrcweir } 120cdf0e10cSrcweir 121cdf0e10cSrcweir return false; 122cdf0e10cSrcweir } 123cdf0e10cSrcweir } 124cdf0e10cSrcweir } 125