lok: IME: preserve formatting when inserting at the end of paragraph
[LibreOffice.git] / include / canvas / elapsedtime.hxx
blob7519b024c87f17c67c25f3f109ccd8f0b0b43368
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #ifndef INCLUDED_CANVAS_ELAPSEDTIME_HXX
21 #define INCLUDED_CANVAS_ELAPSEDTIME_HXX
23 #include <canvas/canvastoolsdllapi.h>
24 #include <memory>
26 namespace canvas::tools
28 /** Calculate elapsed time.
30 This class provides several time-measurement and
31 -management functions. In its simplest use-case, it
32 measures the time from its creation.
34 class CANVASTOOLS_DLLPUBLIC ElapsedTime
36 public:
37 /** Create a new ElapsedTime object
39 The moment of construction starts the time
40 measurement. That means, a subsequent getElapsedTime()
41 call will return the time difference between object
42 creation and getElapsedTime() call.
44 ElapsedTime();
46 /** Creates a new ElapsedTime object based on another
47 timer.
49 The moment of construction starts the time
50 measurement. That means, a subsequent getElapsedTime()
51 call will return the time difference between object
52 creation and getElapsedTime() call. All time values
53 are not taken from the system's time base, but from
54 the provided timer.
56 ElapsedTime( std::shared_ptr<ElapsedTime> const & pTimeBase );
58 /** Reset the time
60 The instance of the reset() call starts the time
61 measurement from scratch. That means, a subsequent
62 getElapsedTime() call will return the time difference
63 between reset() and getElapsedTime() call.
65 void reset();
67 /** Query the elapsed time
69 This method returns the elapsed time in seconds
70 between either the construction of this object, or the
71 last reset() call, if any (but see the time modulation
72 methods below, for means to modify the otherwise
73 continuous flow of time).
75 @return the elapsed time in seconds.
77 double getElapsedTime() const;
79 /** Pauses the running timer.
81 This method stops the time, as returned by this
82 object, until continueTimer() is called. During this
83 period, getElapsedTime() will always return the same
84 time value (i.e. the instant when pauseTimer() was
85 called).
87 void pauseTimer();
89 /** Continues the paused timer.
91 This method re-enables the time flow, that is, time
92 starts running again for clients calling
93 getElapsedTime(). The (subtle) difference to the
94 holdTimer/releaseTimer() methods below is, that there
95 is no perceived time 'jump' between the pauseTimer()
96 call and the continueTimer() call, i.e. the time
97 starts over with the same value it has stopped on
98 pauseTimer().
100 void continueTimer();
102 /** Adjusts the timer, hold and pause times.
104 This method modifies the time as returned by this
105 object by the specified amount. This affects the time
106 as returned by getElapsedTime(), regardless of the
107 mode (e.g. paused, or on hold).
109 @param fOffset
110 This value will be added to the current time, i.e. the
111 next call to getElapsedTime() (when performed
112 immediately) will be adjusted by fOffset.
114 void adjustTimer( double fOffset );
116 /** Holds the current time.
118 This call makes the timer hold the current time
119 (e.g. getElapsedTime() will return the time when
120 holdTimer() was called), while the underlying time is
121 running on. When releaseTimer() is called, the time
122 will 'jump' to the then-current, underlying time. This
123 is equivalent to pressing the "interim time" button on
124 a stop watch, which shows this stopped time, while the
125 clock keeps running internally.
127 void holdTimer();
129 /** Releases a held timer.
131 After this call, the timer again returns the running
132 time on getElapsedTime().
134 void releaseTimer();
136 private:
137 static double getSystemTime();
138 double getCurrentTime() const;
139 double getElapsedTimeImpl() const; // does not set m_fLastQueriedTime
141 const std::shared_ptr<ElapsedTime> m_pTimeBase;
143 /// To validate adjustTimer() calls with bLimitToLastQueriedTime=true
144 mutable double m_fLastQueriedTime;
146 /// Start time, from which the difference to the time base is returned
147 double m_fStartTime;
149 /// Instant, when last pause or hold started, relative to m_fStartTime
150 double m_fFrozenTime;
152 /// True, when in pause mode
153 bool m_bInPauseMode;
155 /// True, when in hold mode
156 bool m_bInHoldMode;
161 #endif /* INCLUDED_CANVAS_ELAPSEDTIME_HXX */
163 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */