[Libreoffice-commits] core.git: include/tools sc/source sfx2/source sw/source tools/source writerfilter/source

Noel Grandin noelgrandin at gmail.com
Mon Jul 3 06:42:45 UTC 2017


 include/tools/datetime.hxx                        |   12 +++++------
 sc/source/filter/excel/xlroot.cxx                 |    2 -
 sfx2/source/doc/objcont.cxx                       |    8 +++----
 sw/source/filter/inc/msfilter.hxx                 |    2 -
 sw/source/filter/ww8/writerwordglue.cxx           |    8 +++----
 tools/source/datetime/datetime.cxx                |   24 +++++++++++-----------
 writerfilter/source/dmapper/DomainMapper_Impl.cxx |    2 -
 7 files changed, 29 insertions(+), 29 deletions(-)

New commits:
commit 1fe0dc7377300ad961438f5a69bd8bc023cc314d
Author: Noel Grandin <noelgrandin at gmail.com>
Date:   Sat Jul 1 16:20:44 2017 +0200

    use sal_Int64 in tools::DateTime
    
    instead of long which has platform-dependent bitlength
    
    Change-Id: I888458d7807027e237772940d4b2cc15c2971243
    Reviewed-on: https://gerrit.libreoffice.org/39434
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/include/tools/datetime.hxx b/include/tools/datetime.hxx
index d8588518bc94..4a7f70c29ea1 100644
--- a/include/tools/datetime.hxx
+++ b/include/tools/datetime.hxx
@@ -75,14 +75,14 @@ public:
     bool            operator >=( const DateTime& rDateTime ) const;
     bool            operator <=( const DateTime& rDateTime ) const;
 
-    long            GetSecFromDateTime( const Date& rDate ) const;
+    sal_Int64       GetSecFromDateTime( const Date& rDate ) const;
 
     void            ConvertToUTC()       { *this -= Time::GetUTCOffset(); }
     void            ConvertToLocalTime() { *this += Time::GetUTCOffset(); }
 
-    DateTime&       operator +=( long nDays )
+    DateTime&       operator +=( sal_Int32 nDays )
                         { Date::operator+=( nDays ); return *this; }
-    DateTime&       operator -=( long nDays )
+    DateTime&       operator -=( sal_Int32 nDays )
                         { Date::operator-=( nDays ); return *this; }
     DateTime&       operator +=( double fTimeInDays );
     DateTime&       operator -=( double fTimeInDays )
@@ -90,15 +90,15 @@ public:
     DateTime&       operator +=( const tools::Time& rTime );
     DateTime&       operator -=( const tools::Time& rTime );
 
-    TOOLS_DLLPUBLIC friend DateTime operator +( const DateTime& rDateTime, long nDays );
-    TOOLS_DLLPUBLIC friend DateTime operator -( const DateTime& rDateTime, long nDays );
+    TOOLS_DLLPUBLIC friend DateTime operator +( const DateTime& rDateTime, sal_Int32 nDays );
+    TOOLS_DLLPUBLIC friend DateTime operator -( const DateTime& rDateTime, sal_Int32 nDays );
     TOOLS_DLLPUBLIC friend DateTime operator +( const DateTime& rDateTime, double fTimeInDays );
     TOOLS_DLLPUBLIC friend DateTime operator -( const DateTime& rDateTime, double fTimeInDays )
                         { return operator+( rDateTime, -fTimeInDays ); }
     TOOLS_DLLPUBLIC friend DateTime operator +( const DateTime& rDateTime, const tools::Time& rTime );
     TOOLS_DLLPUBLIC friend DateTime operator -( const DateTime& rDateTime, const tools::Time& rTime );
     TOOLS_DLLPUBLIC friend double   operator -( const DateTime& rDateTime1, const DateTime& rDateTime2 );
-    TOOLS_DLLPUBLIC friend long     operator -( const DateTime& rDateTime, const Date& rDate )
+    TOOLS_DLLPUBLIC friend sal_Int64 operator -( const DateTime& rDateTime, const Date& rDate )
                         { return static_cast<const Date&>(rDateTime) - rDate; }
 
     DateTime&       operator =( const DateTime& rDateTime );
diff --git a/sc/source/filter/excel/xlroot.cxx b/sc/source/filter/excel/xlroot.cxx
index cd8ea057cab5..262f40b409ba 100644
--- a/sc/source/filter/excel/xlroot.cxx
+++ b/sc/source/filter/excel/xlroot.cxx
@@ -339,7 +339,7 @@ DateTime XclRoot::GetDateTimeFromDouble( double fValue ) const
     DateTime aDateTime = GetNullDate() + fValue;
     // adjust dates before 1900-03-01 to get correct time values
     if( aDateTime < DateTime( Date( 1, 3, 1900 ) ) )
-        aDateTime += 1L;
+        aDateTime += sal_Int32(1);
     return aDateTime;
 }
 
diff --git a/sfx2/source/doc/objcont.cxx b/sfx2/source/doc/objcont.cxx
index 44f779de7d00..9b83ffe426af 100644
--- a/sfx2/source/doc/objcont.cxx
+++ b/sfx2/source/doc/objcont.cxx
@@ -230,10 +230,10 @@ void SfxObjectShell::UpdateTime_Impl(
             secs/3600, (secs%3600)/60, secs%60, 0);
 
     // Initialize some local member! Its 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
-    sal_uIntPtr     nDays       = 0         ;   // Count of days between now and last editing
-    tools::Time        nAddTime    (0)         ;   // Value to add on aOldTime
+    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
+    sal_Int32    nDays       = 0         ;   // Count of days between now and last editing
+    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!!!
diff --git a/sw/source/filter/inc/msfilter.hxx b/sw/source/filter/inc/msfilter.hxx
index 95c84bba598b..1a1713982625 100644
--- a/sw/source/filter/inc/msfilter.hxx
+++ b/sw/source/filter/inc/msfilter.hxx
@@ -94,7 +94,7 @@ namespace sw
         /** Convert from DTTM to Writer's DateTime
 
         */
-        long DateTime2DTTM( const DateTime& rDT );
+        sal_uInt32 DateTime2DTTM( const DateTime& rDT );
 
         /** Convert from Word Date/Time field str to Writer's Date Time str
 
diff --git a/sw/source/filter/ww8/writerwordglue.cxx b/sw/source/filter/ww8/writerwordglue.cxx
index ed06ad119548..199e6f88107c 100644
--- a/sw/source/filter/ww8/writerwordglue.cxx
+++ b/sw/source/filter/ww8/writerwordglue.cxx
@@ -723,7 +723,7 @@ namespace sw
             return nRet;
         }
 
-        long DateTime2DTTM( const DateTime& rDT )
+        sal_uInt32 DateTime2DTTM( const DateTime& rDT )
         {
         /*
         mint    short   :6  0000003F    minutes (0-59)
@@ -740,9 +740,9 @@ namespace sw
                                                 Saturday=6)
         */
 
-            if ( rDT.GetDate() == 0L )
-                return 0L;
-            long nDT = ( rDT.GetDayOfWeek() + 1 ) % 7;
+            if ( rDT.GetDate() == 0 )
+                return 0;
+            sal_uInt32 nDT = ( rDT.GetDayOfWeek() + 1 ) % 7;
             nDT <<= 9;
             nDT += ( rDT.GetYear() - 1900 ) & 0x1ff;
             nDT <<= 4;
diff --git a/tools/source/datetime/datetime.cxx b/tools/source/datetime/datetime.cxx
index b30cdf9d3050..30cefe07322f 100644
--- a/tools/source/datetime/datetime.cxx
+++ b/tools/source/datetime/datetime.cxx
@@ -76,16 +76,16 @@ bool DateTime::operator <=( const DateTime& rDateTime ) const
         return false;
 }
 
-long DateTime::GetSecFromDateTime( const Date& rDate ) const
+sal_Int64 DateTime::GetSecFromDateTime( const Date& rDate ) const
 {
     if ( Date::operator<( rDate ) )
         return 0;
     else
     {
-        long nSec = Date( *this ) - rDate;
+        sal_Int64 nSec = Date( *this ) - rDate;
         nSec *= 24UL*60*60;
-        long nHour = GetHour();
-        long nMin  = GetMin();
+        sal_Int64 nHour = GetHour();
+        sal_Int64 nMin  = GetMin();
         nSec += (nHour*3600)+(nMin*60)+GetSec();
         return nSec;
     }
@@ -149,14 +149,14 @@ DateTime& DateTime::operator -=( const tools::Time& rTime )
     return *this;
 }
 
-DateTime operator +( const DateTime& rDateTime, long nDays )
+DateTime operator +( const DateTime& rDateTime, sal_Int32 nDays )
 {
     DateTime aDateTime( rDateTime );
     aDateTime += nDays;
     return aDateTime;
 }
 
-DateTime operator -( const DateTime& rDateTime, long nDays )
+DateTime operator -( const DateTime& rDateTime, sal_Int32 nDays )
 {
     DateTime aDateTime( rDateTime );
     aDateTime -= nDays;
@@ -190,7 +190,7 @@ DateTime& DateTime::operator +=( double fTimeInDays )
         fInt = ::rtl::math::approxFloor( fTimeInDays );
         fFrac = fInt >= fTimeInDays ? 0.0 : fTimeInDays - fInt;
     }
-    Date::operator+=( long(fInt) );     // full days
+    Date::operator+=( sal_Int32(fInt) );     // full days
     if ( fFrac )
     {
         tools::Time aTime(0);  // default ctor calls system time, we don't need that
@@ -210,7 +210,7 @@ DateTime operator +( const DateTime& rDateTime, double fTimeInDays )
 
 double operator -( const DateTime& rDateTime1, const DateTime& rDateTime2 )
 {
-    long nDays = static_cast<const Date&>(rDateTime1)
+    sal_Int32 nDays = static_cast<const Date&>(rDateTime1)
         - static_cast<const Date&>(rDateTime2);
     sal_Int64 nTime = rDateTime1.GetNSFromTime() - rDateTime2.GetNSFromTime();
     if ( nTime )
@@ -243,7 +243,7 @@ void DateTime::GetWin32FileDateTime( sal_uInt32 & rLower, sal_uInt32 & rUpper )
     SAL_WARN_IF( nYear < 1601, "tools.datetime", "DateTime::GetWin32FileDateTime - year < 1601: " << nYear);
 
     sal_Int64 aTime = (nYear < 1601 ? 0 : (
-        a100nPerDay * static_cast<sal_Int64>(*this - Date(1,1,1601)) +
+        a100nPerDay * (*this - Date(1,1,1601)) +
         GetNSFromTime()/100));
 
     rLower = sal_uInt32( aTime % SAL_CONST_UINT64( 0x100000000 ) );
@@ -266,11 +266,11 @@ DateTime DateTime::CreateFromWin32FileDateTime( sal_uInt32 rLower, sal_uInt32 rU
     sal_uInt64 nDays = aTime / a100nPerDay;
 
     Date aDate(1,1,1601);
-    // (0xffffffffffffffff / a100nPerDay = 21350398) fits into long
+    // (0xffffffffffffffff / a100nPerDay = 21350398) fits into sal_Int32
     // (0x7fffffff = 2147483647)
-    aDate += static_cast<long>(nDays);
+    aDate += static_cast<sal_Int32>(nDays);
 
-    SAL_WARN_IF( aDate - Date(1,1,1601) != static_cast<long>(nDays), "tools.datetime",
+    SAL_WARN_IF( aDate - Date(1,1,1601) != static_cast<sal_Int32>(nDays), "tools.datetime",
             "DateTime::CreateFromWin32FileDateTime - date truncated to max");
 
     sal_uInt64 nNanos = (aTime - (nDays * a100nPerDay)) * 100;
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
index 89783dde0597..40a99feb0864 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
@@ -4456,7 +4456,7 @@ static util::DateTime lcl_dateTimeFromSerial(const double& dSerial)
     const sal_uInt16 secondsPerHour = 3600;
 
     DateTime d(Date(30, 12, 1899));
-    d += (long)dSerial;
+    d += (sal_Int32)dSerial;
 
     double frac = dSerial - (long)dSerial;
     sal_uInt32 seconds = frac * secondsPerDay;


More information about the Libreoffice-commits mailing list