Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 :
20 :
21 : // must be first
22 : #include <canvas/debug.hxx>
23 : #include <tools/diagnose_ex.h>
24 :
25 : #include <comphelper/anytostring.hxx>
26 : #include <cppuhelper/exc_hlp.hxx>
27 :
28 : #include "slideanimations.hxx"
29 : #include "animationnodefactory.hxx"
30 :
31 : using namespace ::com::sun::star;
32 :
33 : namespace slideshow
34 : {
35 : namespace internal
36 : {
37 0 : SlideAnimations::SlideAnimations( const SlideShowContext& rContext,
38 : const ::basegfx::B2DVector& rSlideSize ) :
39 : maContext( rContext ),
40 : maSlideSize( rSlideSize ),
41 0 : mpRootNode()
42 : {
43 0 : ENSURE_OR_THROW( maContext.mpSubsettableShapeManager,
44 : "SlideAnimations::SlideAnimations(): Invalid SlideShowContext" );
45 0 : }
46 :
47 0 : SlideAnimations::~SlideAnimations()
48 : {
49 0 : if( mpRootNode )
50 : {
51 : SHOW_NODE_TREE( mpRootNode );
52 :
53 : try
54 : {
55 0 : mpRootNode->dispose();
56 : }
57 0 : catch (uno::Exception &)
58 : {
59 : OSL_FAIL( OUStringToOString(
60 : comphelper::anyToString(
61 : cppu::getCaughtException() ),
62 : RTL_TEXTENCODING_UTF8 ).getStr() );
63 : }
64 : }
65 0 : }
66 :
67 0 : bool SlideAnimations::importAnimations( const uno::Reference< animations::XAnimationNode >& xRootAnimationNode )
68 : {
69 0 : mpRootNode = AnimationNodeFactory::createAnimationNode(
70 : xRootAnimationNode,
71 : maSlideSize,
72 0 : maContext );
73 :
74 : SHOW_NODE_TREE( mpRootNode );
75 :
76 0 : return static_cast< bool >(mpRootNode);
77 : }
78 :
79 0 : bool SlideAnimations::isAnimated() const
80 : {
81 0 : if( !mpRootNode )
82 0 : return false; // no animations there
83 :
84 : // query root node about pending animations
85 0 : return mpRootNode->hasPendingAnimation();
86 : }
87 :
88 0 : bool SlideAnimations::start()
89 : {
90 0 : if( !mpRootNode )
91 0 : return false; // no animations there
92 :
93 : // init all nodes
94 0 : if( !mpRootNode->init() )
95 0 : return false;
96 :
97 : // resolve root node
98 0 : if( !mpRootNode->resolve() )
99 0 : return false;
100 :
101 0 : return true;
102 : }
103 :
104 0 : void SlideAnimations::end()
105 : {
106 0 : if( !mpRootNode )
107 0 : return; // no animations there
108 :
109 : // end root node
110 0 : mpRootNode->deactivate();
111 0 : mpRootNode->end();
112 : }
113 :
114 : }
115 : }
116 :
117 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|