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 <tools/diagnose_ex.h>
34 #include <canvas/verbosetrace.hxx>
35 
36 #include <continuouskeytimeactivitybase.hxx>
37 
38 #include <boost/tuple/tuple.hpp>
39 #include <algorithm>
40 #include <iterator>
41 
42 
43 namespace slideshow
44 {
45     namespace internal
46     {
47         ContinuousKeyTimeActivityBase::ContinuousKeyTimeActivityBase( const ActivityParameters& rParms ) :
48             SimpleContinuousActivityBase( rParms ),
49             maLerper( rParms.maDiscreteTimes )
50         {
51             ENSURE_OR_THROW( rParms.maDiscreteTimes.size() > 1,
52                               "ContinuousKeyTimeActivityBase::ContinuousKeyTimeActivityBase(): key times vector must have two entries or more" );
53             ENSURE_OR_THROW( rParms.maDiscreteTimes.front() == 0.0,
54                               "ContinuousKeyTimeActivityBase::ContinuousKeyTimeActivityBase(): key times vector first entry must be zero" );
55             ENSURE_OR_THROW( rParms.maDiscreteTimes.back() <= 1.0,
56                               "ContinuousKeyTimeActivityBase::ContinuousKeyTimeActivityBase(): key times vector last entry must be less or equal 1" );
57         }
58 
59         void ContinuousKeyTimeActivityBase::simplePerform( double 		nSimpleTime,
60                                                            sal_uInt32 	nRepeatCount ) const
61         {
62             // calc simple time from global time - sweep through the
63             // array multiple times for repeated animations (according to
64             // SMIL spec).
65             double fAlpha( calcAcceleratedTime( nSimpleTime ) );
66             std::ptrdiff_t nIndex;
67 
68             boost::tuples::tie(nIndex,fAlpha) = maLerper.lerp(fAlpha);
69 
70             perform(
71                 nIndex,
72                 fAlpha,
73                 nRepeatCount );
74         }
75     }
76 }
77