summaryrefslogtreecommitdiff
path: root/editeng/source/misc
diff options
context:
space:
mode:
authorMike Kaganski <mike.kaganski@collabora.com>2024-10-20 22:51:02 +0500
committerMike Kaganski <mike.kaganski@collabora.com>2024-10-21 10:30:58 +0200
commit7e5f69aa33509a359b547b9a4a6569a55cd5d5c9 (patch)
treed5956d0364044238979ef22319259d8c4a97b46f /editeng/source/misc
parent04921e20b4d3d08a4b78dbafe26c983075fe5630 (diff)
Make tools::Time ctor taking sal_Int64 private
This ctor is meant to set the value of nTime directly; and that value is not nanoseconds, but an encoded value, using SEC_/MIN_/HOUR_MASK. But in some places, this ctor was misused for setting of nanoseconds, which would only accidentally work for values less than one second. All places that initialized tools::Time with 0, now use EMPTY. This makes the ctor private; and for the very few cases where really the encoded value of nTime is stored / restored, fromEncodedTime is introduced. Change-Id: I1f1994bd9aab1b51a41b1de637619049fe820da4 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/175283 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Diffstat (limited to 'editeng/source/misc')
-rw-r--r--editeng/source/misc/svxacorr.cxx13
1 files changed, 9 insertions, 4 deletions
diff --git a/editeng/source/misc/svxacorr.cxx b/editeng/source/misc/svxacorr.cxx
index 055d46879aa6..0c3540051e49 100644
--- a/editeng/source/misc/svxacorr.cxx
+++ b/editeng/source/misc/svxacorr.cxx
@@ -1891,12 +1891,17 @@ bool SvxAutoCorrect::CreateLanguageFile( const LanguageTag& rLanguageTag, bool b
SvxAutoCorrectLanguageLists* pLists = nullptr;
- tools::Time nMinTime( 0, 2 ), nAktTime( tools::Time::SYSTEM ), nLastCheckTime( tools::Time::EMPTY );
+ tools::Time nAktTime(tools::Time::SYSTEM);
auto nFndPos = aLastFileTable.find(rLanguageTag);
- if(nFndPos != aLastFileTable.end() &&
- (nLastCheckTime.SetTime(nFndPos->second), nLastCheckTime < nAktTime) &&
- nAktTime - nLastCheckTime < nMinTime)
+ bool lastCheckLessThan2MinutesAgo = nFndPos != aLastFileTable.end();
+ if (lastCheckLessThan2MinutesAgo)
+ {
+ const tools::Time nLastCheckTime(tools::Time::fromEncodedTime(nFndPos->second));
+ lastCheckLessThan2MinutesAgo
+ = nLastCheckTime < nAktTime && nAktTime - nLastCheckTime < tools::Time(0, 2);
+ }
+ if (lastCheckLessThan2MinutesAgo)
{
// no need to test the file, because the last check is not older then
// 2 minutes.