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 28 // MARKER(update_precomp.py): autogen include statement, do not remove 29 #include "precompiled_slideshow.hxx" 30 31 // must be first 32 #include <canvas/debug.hxx> 33 #include <canvas/verbosetrace.hxx> 34 35 #include <com/sun/star/animations/Timing.hpp> 36 37 #include <tools.hxx> 38 #include <nodetools.hxx> 39 40 41 using namespace ::com::sun::star; 42 43 namespace slideshow 44 { 45 namespace internal 46 { 47 #if defined(VERBOSE) && defined(DBG_UTIL) 48 int& debugGetCurrentOffset() 49 { 50 static int lcl_nOffset = 0; // to make each tree output distinct 51 52 return lcl_nOffset; 53 } 54 55 void debugNodesShowTree( const BaseNode* pNode ) 56 { 57 if( pNode ) 58 pNode->showState(); 59 60 ++debugGetCurrentOffset(); 61 } 62 63 void debugNodesShowTreeWithin( const BaseNode* pNode ) 64 { 65 if( pNode ) 66 pNode->showTreeFromWithin(); 67 68 ++debugGetCurrentOffset(); 69 } 70 #endif 71 72 AttributableShapeSharedPtr lookupAttributableShape( const ShapeManagerSharedPtr& rShapeManager, 73 const uno::Reference< drawing::XShape >& xShape ) 74 { 75 ENSURE_OR_THROW( rShapeManager, 76 "lookupAttributableShape(): invalid ShapeManager" ); 77 78 ShapeSharedPtr pShape( rShapeManager->lookupShape( xShape ) ); 79 80 ENSURE_OR_THROW( pShape, 81 "lookupAttributableShape(): no shape found for given XShape" ); 82 83 AttributableShapeSharedPtr pRes( 84 ::boost::dynamic_pointer_cast< AttributableShape >( pShape ) ); 85 86 // TODO(E3): Cannot throw here, people might set animation info 87 // for non-animatable shapes from the API. AnimationNodes must catch 88 // the exception and handle that differently 89 ENSURE_OR_THROW( pRes, 90 "lookupAttributableShape(): shape found does not implement AttributableShape interface" ); 91 92 return pRes; 93 } 94 95 bool isIndefiniteTiming( const uno::Any& rAny ) 96 { 97 if( !rAny.hasValue() ) 98 return true; 99 100 animations::Timing eTiming; 101 102 if( !(rAny >>= eTiming) || 103 eTiming != animations::Timing_INDEFINITE ) 104 { 105 return false; 106 } 107 108 return true; 109 } 110 111 /// Extract the node type from the user data 112 bool getNodeType( sal_Int16& o_rNodeType, 113 const uno::Sequence< beans::NamedValue >& rValues ) 114 { 115 beans::NamedValue aNamedValue; 116 117 if( findNamedValue( &aNamedValue, 118 rValues, 119 ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("node-type") ) ) ) 120 { 121 if( (aNamedValue.Value >>= o_rNodeType) ) 122 return true; 123 } 124 125 return false; 126 } 127 } 128 } 129