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 <tools/diagnose_ex.h> 30cdf0e10cSrcweir #include <tools/diagnose_ex.h> 31cdf0e10cSrcweir 32cdf0e10cSrcweir #include <comphelper/anytostring.hxx> 33cdf0e10cSrcweir #include <cppuhelper/exc_hlp.hxx> 34cdf0e10cSrcweir 35cdf0e10cSrcweir #include "slideanimations.hxx" 36cdf0e10cSrcweir #include "animationnodefactory.hxx" 37cdf0e10cSrcweir 38cdf0e10cSrcweir using namespace ::com::sun::star; 39cdf0e10cSrcweir 40cdf0e10cSrcweir namespace slideshow 41cdf0e10cSrcweir { 42cdf0e10cSrcweir namespace internal 43cdf0e10cSrcweir { 44cdf0e10cSrcweir SlideAnimations::SlideAnimations( const SlideShowContext& rContext, 45cdf0e10cSrcweir const ::basegfx::B2DVector& rSlideSize ) : 46cdf0e10cSrcweir maContext( rContext ), 47cdf0e10cSrcweir maSlideSize( rSlideSize ), 48cdf0e10cSrcweir mpRootNode() 49cdf0e10cSrcweir { 50cdf0e10cSrcweir ENSURE_OR_THROW( maContext.mpSubsettableShapeManager, 51cdf0e10cSrcweir "SlideAnimations::SlideAnimations(): Invalid SlideShowContext" ); 52cdf0e10cSrcweir } 53cdf0e10cSrcweir 54cdf0e10cSrcweir SlideAnimations::~SlideAnimations() 55cdf0e10cSrcweir { 56cdf0e10cSrcweir if( mpRootNode ) 57cdf0e10cSrcweir { 58cdf0e10cSrcweir SHOW_NODE_TREE( mpRootNode ); 59cdf0e10cSrcweir 60cdf0e10cSrcweir try 61cdf0e10cSrcweir { 62cdf0e10cSrcweir mpRootNode->dispose(); 63cdf0e10cSrcweir } 64cdf0e10cSrcweir catch (uno::Exception &) 65cdf0e10cSrcweir { 66cdf0e10cSrcweir OSL_ENSURE( false, rtl::OUStringToOString( 67cdf0e10cSrcweir comphelper::anyToString( 68cdf0e10cSrcweir cppu::getCaughtException() ), 69cdf0e10cSrcweir RTL_TEXTENCODING_UTF8 ).getStr() ); 70cdf0e10cSrcweir } 71cdf0e10cSrcweir } 72cdf0e10cSrcweir } 73cdf0e10cSrcweir 74cdf0e10cSrcweir bool SlideAnimations::importAnimations( const uno::Reference< animations::XAnimationNode >& xRootAnimationNode ) 75cdf0e10cSrcweir { 76cdf0e10cSrcweir mpRootNode = AnimationNodeFactory::createAnimationNode( 77cdf0e10cSrcweir xRootAnimationNode, 78cdf0e10cSrcweir maSlideSize, 79cdf0e10cSrcweir maContext ); 80cdf0e10cSrcweir 81cdf0e10cSrcweir SHOW_NODE_TREE( mpRootNode ); 82cdf0e10cSrcweir 83cdf0e10cSrcweir return mpRootNode; 84cdf0e10cSrcweir } 85cdf0e10cSrcweir 86cdf0e10cSrcweir bool SlideAnimations::isAnimated() const 87cdf0e10cSrcweir { 88cdf0e10cSrcweir if( !mpRootNode ) 89cdf0e10cSrcweir return false; // no animations there 90cdf0e10cSrcweir 91cdf0e10cSrcweir // query root node about pending animations 92cdf0e10cSrcweir return mpRootNode->hasPendingAnimation(); 93cdf0e10cSrcweir } 94cdf0e10cSrcweir 95cdf0e10cSrcweir bool SlideAnimations::start() 96cdf0e10cSrcweir { 97cdf0e10cSrcweir if( !mpRootNode ) 98cdf0e10cSrcweir return false; // no animations there 99cdf0e10cSrcweir 100cdf0e10cSrcweir // init all nodes 101cdf0e10cSrcweir if( !mpRootNode->init() ) 102cdf0e10cSrcweir return false; 103cdf0e10cSrcweir 104cdf0e10cSrcweir // resolve root node 105cdf0e10cSrcweir if( !mpRootNode->resolve() ) 106cdf0e10cSrcweir return false; 107cdf0e10cSrcweir 108cdf0e10cSrcweir return true; 109cdf0e10cSrcweir } 110cdf0e10cSrcweir 111cdf0e10cSrcweir void SlideAnimations::end() 112cdf0e10cSrcweir { 113cdf0e10cSrcweir if( !mpRootNode ) 114cdf0e10cSrcweir return; // no animations there 115cdf0e10cSrcweir 116cdf0e10cSrcweir // end root node 117cdf0e10cSrcweir mpRootNode->deactivate(); 118cdf0e10cSrcweir mpRootNode->end(); 119cdf0e10cSrcweir } 120cdf0e10cSrcweir 121cdf0e10cSrcweir void SlideAnimations::dispose() 122cdf0e10cSrcweir { 123cdf0e10cSrcweir mpRootNode.reset(); 124cdf0e10cSrcweir maContext.dispose(); 125cdf0e10cSrcweir } 126cdf0e10cSrcweir } 127cdf0e10cSrcweir } 128