1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #ifndef INCLUDED_SLIDESHOW_ACCUMULATION_HXX
25 #define INCLUDED_SLIDESHOW_ACCUMULATION_HXX
26 
27 #include <sal/types.h>
28 #include <rtl/ustring.hxx>
29 
30 
31 namespace slideshow
32 {
33     namespace internal
34     {
35         /** Generic accumulation.
36 
37         	This template handles value accumulation across repeated
38         	effect runs: returned is the end value times the repeat
39         	count, plus the current value.
40 
41         	@param rEndValue
42             End value of the simple animation.
43 
44             @param nRepeatCount
45             Number of completed repeats (i.e. 0 during the first
46             effect run)
47 
48             @param rCurrValue
49             Current animation value
50          */
accumulate(const ValueType & rEndValue,sal_uInt32 nRepeatCount,const ValueType & rCurrValue)51         template< typename ValueType > ValueType accumulate( const ValueType& 	rEndValue,
52                                                              sal_uInt32 		nRepeatCount,
53                                                              const ValueType& 	rCurrValue )
54         {
55             return nRepeatCount*rEndValue + rCurrValue;
56         }
57 
58         /// Specialization for non-addable enums/constant values
accumulate(const sal_Int16 &,sal_uInt32,const sal_Int16 & rCurrValue)59         template<> sal_Int16 accumulate< sal_Int16 >( const sal_Int16&,
60                                                       sal_uInt32,
61                                                       const sal_Int16& 	rCurrValue )
62         {
63             // always return rCurrValue, it's forbidden to add enums/constant values...
64             return rCurrValue;
65         }
66 
67         /// Specialization for non-addable strings
accumulate(const::rtl::OUString &,sal_uInt32,const::rtl::OUString & rCurrValue)68         template<> ::rtl::OUString accumulate< ::rtl::OUString >( const ::rtl::OUString&,
69                                                                   sal_uInt32,
70                                                                   const ::rtl::OUString& 	rCurrValue )
71         {
72             // always return rCurrValue, it's impossible to add strings...
73             return rCurrValue;
74         }
75 
76         /// Specialization for non-addable bools
accumulate(const bool &,sal_uInt32,const bool & bCurrValue)77         template<> bool accumulate< bool >( const bool&,
78                                             sal_uInt32,
79                                             const bool&	 	bCurrValue )
80         {
81             // always return bCurrValue, SMIL spec requires to ignore
82             // cumulative behaviour for bools.
83             return bCurrValue;
84         }
85     }
86 }
87 
88 #endif /* INCLUDED_SLIDESHOW_ACCUMULATION_HXX */
89