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