170f497fbSAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 370f497fbSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 470f497fbSAndrew Rist * or more contributor license agreements. See the NOTICE file 570f497fbSAndrew Rist * distributed with this work for additional information 670f497fbSAndrew Rist * regarding copyright ownership. The ASF licenses this file 770f497fbSAndrew Rist * to you under the Apache License, Version 2.0 (the 870f497fbSAndrew Rist * "License"); you may not use this file except in compliance 970f497fbSAndrew Rist * with the License. You may obtain a copy of the License at 1070f497fbSAndrew Rist * 1170f497fbSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 1270f497fbSAndrew Rist * 1370f497fbSAndrew Rist * Unless required by applicable law or agreed to in writing, 1470f497fbSAndrew Rist * software distributed under the License is distributed on an 1570f497fbSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 1670f497fbSAndrew Rist * KIND, either express or implied. See the License for the 1770f497fbSAndrew Rist * specific language governing permissions and limitations 1870f497fbSAndrew Rist * under the License. 1970f497fbSAndrew Rist * 2070f497fbSAndrew Rist *************************************************************/ 2170f497fbSAndrew Rist 2270f497fbSAndrew 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 { SlideAnimations(const SlideShowContext & rContext,const::basegfx::B2DVector & rSlideSize)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 ~SlideAnimations()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 importAnimations(const uno::Reference<animations::XAnimationNode> & xRootAnimationNode)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 83*0ca1f900SHerbert Dürr return (mpRootNode.get() != NULL); 84cdf0e10cSrcweir } 85cdf0e10cSrcweir isAnimated() const86cdf0e10cSrcweir 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 start()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 end()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 dispose()121cdf0e10cSrcweir void SlideAnimations::dispose() 122cdf0e10cSrcweir { 123cdf0e10cSrcweir mpRootNode.reset(); 124cdf0e10cSrcweir maContext.dispose(); 125cdf0e10cSrcweir } 126cdf0e10cSrcweir } 127cdf0e10cSrcweir } 128