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 // MARKER(update_precomp.py): autogen include statement, do not remove 29 #include "precompiled_sdext.hxx" 30 31 #include "PresenterAnimation.hxx" 32 33 #include <osl/time.h> 34 35 namespace sdext { namespace presenter { 36 37 sal_uInt64 GetCurrentTime (void) 38 { 39 TimeValue aTimeValue; 40 if (osl_getSystemTime(&aTimeValue)) 41 return sal_uInt64(aTimeValue.Seconds * 1000.0 + aTimeValue.Nanosec / 1000000.0); 42 else 43 return 0; 44 } 45 46 47 48 49 PresenterAnimation::PresenterAnimation ( 50 const sal_uInt64 nStartDelay, 51 const sal_uInt64 nTotalDuration, 52 const sal_uInt64 nStepDuration) 53 : mnStartTime(GetCurrentTime()+nStartDelay), 54 mnTotalDuration(nTotalDuration), 55 mnStepDuration(nStepDuration), 56 mpStartCallbacks(), 57 mpEndCallbacks() 58 { 59 } 60 61 62 63 64 PresenterAnimation::~PresenterAnimation (void) 65 { 66 } 67 68 69 70 71 sal_uInt64 PresenterAnimation::GetStartTime (void) 72 { 73 return mnStartTime; 74 } 75 76 77 78 79 sal_uInt64 PresenterAnimation::GetEndTime (void) 80 { 81 return mnStartTime + mnTotalDuration; 82 } 83 84 85 86 87 sal_uInt64 PresenterAnimation::GetStepDuration (void) 88 { 89 return mnStepDuration; 90 } 91 92 93 94 95 void PresenterAnimation::AddStartCallback (const Callback& rCallback) 96 { 97 if (mpStartCallbacks.get() == NULL) 98 mpStartCallbacks.reset(new ::std::vector<Callback>()); 99 mpStartCallbacks->push_back(rCallback); 100 } 101 102 103 104 105 void PresenterAnimation::AddEndCallback (const Callback& rCallback) 106 { 107 if (mpEndCallbacks.get() == NULL) 108 mpEndCallbacks.reset(new ::std::vector<Callback>()); 109 mpEndCallbacks->push_back(rCallback); 110 } 111 112 113 114 void PresenterAnimation::RunStartCallbacks (void) 115 { 116 if (mpStartCallbacks.get() != NULL) 117 { 118 ::std::vector<Callback>::const_iterator iCallback; 119 for (iCallback=mpStartCallbacks->begin(); iCallback!=mpStartCallbacks->end(); ++iCallback) 120 (*iCallback)(); 121 } 122 } 123 124 125 126 127 void PresenterAnimation::RunEndCallbacks (void) 128 { 129 if (mpEndCallbacks.get() != NULL) 130 { 131 ::std::vector<Callback>::const_iterator iCallback; 132 for (iCallback=mpEndCallbacks->begin(); iCallback!=mpEndCallbacks->end(); ++iCallback) 133 (*iCallback)(); 134 } 135 } 136 137 138 139 140 } } // end of namespace ::sdext::presenter 141