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 #ifndef INCLUDED_SLIDESHOW_ACCUMULATION_HXX
29 #define INCLUDED_SLIDESHOW_ACCUMULATION_HXX
30 
31 #include <sal/types.h>
32 #include <rtl/ustring.hxx>
33 
34 
35 namespace slideshow
36 {
37     namespace internal
38     {
39         /** Generic accumulation.
40 
41         	This template handles value accumulation across repeated
42         	effect runs: returned is the end value times the repeat
43         	count, plus the current value.
44 
45         	@param rEndValue
46             End value of the simple animation.
47 
48             @param nRepeatCount
49             Number of completed repeats (i.e. 0 during the first
50             effect run)
51 
52             @param rCurrValue
53             Current animation value
54          */
55         template< typename ValueType > ValueType accumulate( const ValueType& 	rEndValue,
56                                                              sal_uInt32 		nRepeatCount,
57                                                              const ValueType& 	rCurrValue )
58         {
59             return nRepeatCount*rEndValue + rCurrValue;
60         }
61 
62         /// Specialization for non-addable enums/constant values
63         template<> sal_Int16 accumulate< sal_Int16 >( const sal_Int16&,
64                                                       sal_uInt32,
65                                                       const sal_Int16& 	rCurrValue )
66         {
67             // always return rCurrValue, it's forbidden to add enums/constant values...
68             return rCurrValue;
69         }
70 
71         /// Specialization for non-addable strings
72         template<> ::rtl::OUString accumulate< ::rtl::OUString >( const ::rtl::OUString&,
73                                                                   sal_uInt32,
74                                                                   const ::rtl::OUString& 	rCurrValue )
75         {
76             // always return rCurrValue, it's impossible to add strings...
77             return rCurrValue;
78         }
79 
80         /// Specialization for non-addable bools
81         template<> bool accumulate< bool >( const bool&,
82                                             sal_uInt32,
83                                             const bool&	 	bCurrValue )
84         {
85             // always return bCurrValue, SMIL spec requires to ignore
86             // cumulative behaviour for bools.
87             return bCurrValue;
88         }
89     }
90 }
91 
92 #endif /* INCLUDED_SLIDESHOW_ACCUMULATION_HXX */
93