Update ooo320-m1
[ooovba.git] / sdext / source / presenter / PresenterAnimation.cxx
blobfefef5181923ec68df9fccb291fb747dad398b62
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: PresenterAnimation.cxx,v $
11 * $Revision: 1.4 $
13 * This file is part of OpenOffice.org.
15 * OpenOffice.org is free software: you can redistribute it and/or modify
16 * it under the terms of the GNU Lesser General Public License version 3
17 * only, as published by the Free Software Foundation.
19 * OpenOffice.org is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU Lesser General Public License version 3 for more details
23 * (a copy is included in the LICENSE file that accompanied this code).
25 * You should have received a copy of the GNU Lesser General Public License
26 * version 3 along with OpenOffice.org. If not, see
27 * <http://www.openoffice.org/license.html>
28 * for a copy of the LGPLv3 License.
30 ************************************************************************/
32 // MARKER(update_precomp.py): autogen include statement, do not remove
33 #include "precompiled_sdext.hxx"
35 #include "PresenterAnimation.hxx"
37 #include <osl/time.h>
39 namespace sdext { namespace presenter {
41 sal_uInt64 GetCurrentTime (void)
43 TimeValue aTimeValue;
44 if (osl_getSystemTime(&aTimeValue))
45 return sal_uInt64(aTimeValue.Seconds * 1000.0 + aTimeValue.Nanosec / 1000000.0);
46 else
47 return 0;
53 PresenterAnimation::PresenterAnimation (
54 const sal_uInt64 nStartDelay,
55 const sal_uInt64 nTotalDuration,
56 const sal_uInt64 nStepDuration)
57 : mnStartTime(GetCurrentTime()+nStartDelay),
58 mnTotalDuration(nTotalDuration),
59 mnStepDuration(nStepDuration),
60 mpStartCallbacks(),
61 mpEndCallbacks()
68 PresenterAnimation::~PresenterAnimation (void)
75 sal_uInt64 PresenterAnimation::GetStartTime (void)
77 return mnStartTime;
83 sal_uInt64 PresenterAnimation::GetEndTime (void)
85 return mnStartTime + mnTotalDuration;
91 sal_uInt64 PresenterAnimation::GetStepDuration (void)
93 return mnStepDuration;
99 void PresenterAnimation::AddStartCallback (const Callback& rCallback)
101 if (mpStartCallbacks.get() == NULL)
102 mpStartCallbacks.reset(new ::std::vector<Callback>());
103 mpStartCallbacks->push_back(rCallback);
109 void PresenterAnimation::AddEndCallback (const Callback& rCallback)
111 if (mpEndCallbacks.get() == NULL)
112 mpEndCallbacks.reset(new ::std::vector<Callback>());
113 mpEndCallbacks->push_back(rCallback);
118 void PresenterAnimation::RunStartCallbacks (void)
120 if (mpStartCallbacks.get() != NULL)
122 ::std::vector<Callback>::const_iterator iCallback;
123 for (iCallback=mpStartCallbacks->begin(); iCallback!=mpStartCallbacks->end(); ++iCallback)
124 (*iCallback)();
131 void PresenterAnimation::RunEndCallbacks (void)
133 if (mpEndCallbacks.get() != NULL)
135 ::std::vector<Callback>::const_iterator iCallback;
136 for (iCallback=mpEndCallbacks->begin(); iCallback!=mpEndCallbacks->end(); ++iCallback)
137 (*iCallback)();
144 } } // end of namespace ::sdext::presenter