1c142477cSAndrew Rist /**************************************************************
2*6d8c2cf3Smseidel *
3c142477cSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
4c142477cSAndrew Rist * or more contributor license agreements. See the NOTICE file
5c142477cSAndrew Rist * distributed with this work for additional information
6c142477cSAndrew Rist * regarding copyright ownership. The ASF licenses this file
7c142477cSAndrew Rist * to you under the Apache License, Version 2.0 (the
8c142477cSAndrew Rist * "License"); you may not use this file except in compliance
9c142477cSAndrew Rist * with the License. You may obtain a copy of the License at
10*6d8c2cf3Smseidel *
11c142477cSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
12*6d8c2cf3Smseidel *
13c142477cSAndrew Rist * Unless required by applicable law or agreed to in writing,
14c142477cSAndrew Rist * software distributed under the License is distributed on an
15c142477cSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16c142477cSAndrew Rist * KIND, either express or implied. See the License for the
17c142477cSAndrew Rist * specific language governing permissions and limitations
18c142477cSAndrew Rist * under the License.
19*6d8c2cf3Smseidel *
20c142477cSAndrew Rist *************************************************************/
21c142477cSAndrew Rist
22c142477cSAndrew Rist
23cdf0e10cSrcweir
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_sdext.hxx"
26cdf0e10cSrcweir
27cdf0e10cSrcweir #include "PresenterAnimation.hxx"
28cdf0e10cSrcweir
29cdf0e10cSrcweir #include <osl/time.h>
30cdf0e10cSrcweir
31cdf0e10cSrcweir namespace sdext { namespace presenter {
32cdf0e10cSrcweir
GetCurrentTime(void)33cdf0e10cSrcweir sal_uInt64 GetCurrentTime (void)
34cdf0e10cSrcweir {
35*6d8c2cf3Smseidel TimeValue aTimeValue;
36*6d8c2cf3Smseidel if (osl_getSystemTime(&aTimeValue))
37*6d8c2cf3Smseidel return sal_uInt64(aTimeValue.Seconds * 1000.0 + aTimeValue.Nanosec / 1000000.0);
38*6d8c2cf3Smseidel else
39*6d8c2cf3Smseidel return 0;
40cdf0e10cSrcweir }
41cdf0e10cSrcweir
42cdf0e10cSrcweir
43cdf0e10cSrcweir
44cdf0e10cSrcweir
PresenterAnimation(const sal_uInt64 nStartDelay,const sal_uInt64 nTotalDuration,const sal_uInt64 nStepDuration)45cdf0e10cSrcweir PresenterAnimation::PresenterAnimation (
46*6d8c2cf3Smseidel const sal_uInt64 nStartDelay,
47*6d8c2cf3Smseidel const sal_uInt64 nTotalDuration,
48*6d8c2cf3Smseidel const sal_uInt64 nStepDuration)
49*6d8c2cf3Smseidel : mnStartTime(GetCurrentTime()+nStartDelay),
50*6d8c2cf3Smseidel mnTotalDuration(nTotalDuration),
51*6d8c2cf3Smseidel mnStepDuration(nStepDuration),
52*6d8c2cf3Smseidel mpStartCallbacks(),
53*6d8c2cf3Smseidel mpEndCallbacks()
54cdf0e10cSrcweir {
55cdf0e10cSrcweir }
56cdf0e10cSrcweir
57cdf0e10cSrcweir
58cdf0e10cSrcweir
59cdf0e10cSrcweir
~PresenterAnimation(void)60cdf0e10cSrcweir PresenterAnimation::~PresenterAnimation (void)
61cdf0e10cSrcweir {
62cdf0e10cSrcweir }
63cdf0e10cSrcweir
64cdf0e10cSrcweir
65cdf0e10cSrcweir
66cdf0e10cSrcweir
GetStartTime(void)67cdf0e10cSrcweir sal_uInt64 PresenterAnimation::GetStartTime (void)
68cdf0e10cSrcweir {
69*6d8c2cf3Smseidel return mnStartTime;
70cdf0e10cSrcweir }
71cdf0e10cSrcweir
72cdf0e10cSrcweir
73cdf0e10cSrcweir
74cdf0e10cSrcweir
GetEndTime(void)75cdf0e10cSrcweir sal_uInt64 PresenterAnimation::GetEndTime (void)
76cdf0e10cSrcweir {
77*6d8c2cf3Smseidel return mnStartTime + mnTotalDuration;
78cdf0e10cSrcweir }
79cdf0e10cSrcweir
80cdf0e10cSrcweir
81cdf0e10cSrcweir
82cdf0e10cSrcweir
GetStepDuration(void)83cdf0e10cSrcweir sal_uInt64 PresenterAnimation::GetStepDuration (void)
84cdf0e10cSrcweir {
85*6d8c2cf3Smseidel return mnStepDuration;
86cdf0e10cSrcweir }
87cdf0e10cSrcweir
88cdf0e10cSrcweir
89cdf0e10cSrcweir
90cdf0e10cSrcweir
AddStartCallback(const Callback & rCallback)91cdf0e10cSrcweir void PresenterAnimation::AddStartCallback (const Callback& rCallback)
92cdf0e10cSrcweir {
93*6d8c2cf3Smseidel if (mpStartCallbacks.get() == NULL)
94*6d8c2cf3Smseidel mpStartCallbacks.reset(new ::std::vector<Callback>());
95*6d8c2cf3Smseidel mpStartCallbacks->push_back(rCallback);
96cdf0e10cSrcweir }
97cdf0e10cSrcweir
98cdf0e10cSrcweir
99cdf0e10cSrcweir
100cdf0e10cSrcweir
AddEndCallback(const Callback & rCallback)101cdf0e10cSrcweir void PresenterAnimation::AddEndCallback (const Callback& rCallback)
102cdf0e10cSrcweir {
103*6d8c2cf3Smseidel if (mpEndCallbacks.get() == NULL)
104*6d8c2cf3Smseidel mpEndCallbacks.reset(new ::std::vector<Callback>());
105*6d8c2cf3Smseidel mpEndCallbacks->push_back(rCallback);
106cdf0e10cSrcweir }
107cdf0e10cSrcweir
108cdf0e10cSrcweir
109cdf0e10cSrcweir
RunStartCallbacks(void)110cdf0e10cSrcweir void PresenterAnimation::RunStartCallbacks (void)
111cdf0e10cSrcweir {
112*6d8c2cf3Smseidel if (mpStartCallbacks.get() != NULL)
113*6d8c2cf3Smseidel {
114*6d8c2cf3Smseidel ::std::vector<Callback>::const_iterator iCallback;
115*6d8c2cf3Smseidel for (iCallback=mpStartCallbacks->begin(); iCallback!=mpStartCallbacks->end(); ++iCallback)
116*6d8c2cf3Smseidel (*iCallback)();
117*6d8c2cf3Smseidel }
118cdf0e10cSrcweir }
119cdf0e10cSrcweir
120cdf0e10cSrcweir
121cdf0e10cSrcweir
122cdf0e10cSrcweir
RunEndCallbacks(void)123cdf0e10cSrcweir void PresenterAnimation::RunEndCallbacks (void)
124cdf0e10cSrcweir {
125*6d8c2cf3Smseidel if (mpEndCallbacks.get() != NULL)
126*6d8c2cf3Smseidel {
127*6d8c2cf3Smseidel ::std::vector<Callback>::const_iterator iCallback;
128*6d8c2cf3Smseidel for (iCallback=mpEndCallbacks->begin(); iCallback!=mpEndCallbacks->end(); ++iCallback)
129*6d8c2cf3Smseidel (*iCallback)();
130*6d8c2cf3Smseidel }
131cdf0e10cSrcweir }
132cdf0e10cSrcweir
133cdf0e10cSrcweir
134cdf0e10cSrcweir
135cdf0e10cSrcweir
136cdf0e10cSrcweir } } // end of namespace ::sdext::presenter
137