summaryrefslogtreecommitdiff
path: root/sfx2
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 /sfx2
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 'sfx2')
-rw-r--r--sfx2/source/doc/objcont.cxx6
1 files changed, 3 insertions, 3 deletions
diff --git a/sfx2/source/doc/objcont.cxx b/sfx2/source/doc/objcont.cxx
index d2130979c9a6..6aa790d22fc4 100644
--- a/sfx2/source/doc/objcont.cxx
+++ b/sfx2/source/doc/objcont.cxx
@@ -263,8 +263,6 @@ void SfxObjectShell::UpdateTime_Impl(
// Initialize some local member! It's necessary for follow operations!
DateTime aNow( DateTime::SYSTEM ); // Date and time at current moment
- tools::Time n24Time (24,0,0,0) ; // Time-value for 24 hours - see follow calculation
- tools::Time nAddTime (0) ; // Value to add on aOldTime
// Save impossible cases!
// User has changed time to the past between last editing and now... it's not possible!!!
@@ -276,6 +274,7 @@ void SfxObjectShell::UpdateTime_Impl(
{
// Count of days between now and last editing
sal_Int32 nDays = aNow.GetSecFromDateTime(Date(pImpl->nTime.GetDate()))/86400 ;
+ tools::Time nAddTime(tools::Time::EMPTY); // Value to add on aOldTime
if (nDays==0)
{
@@ -289,8 +288,9 @@ void SfxObjectShell::UpdateTime_Impl(
// If 1 or up to 31 days between now and last editing - calculate time indirectly.
// nAddTime = (24h - nTime) + (nDays * 24h) + aNow
+ tools::Time n24Time (24,0,0,0); // Time-value for 24 hours
--nDays;
- nAddTime = tools::Time( nDays * n24Time.GetTime());
+ nAddTime.MakeTimeFromNS(nDays * n24Time.GetNSFromTime());
nAddTime += n24Time-static_cast<const tools::Time&>(pImpl->nTime);
nAddTime += aNow ;
}