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