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