avmedia/source/framework/MediaControlBase.cxx |    7 +++++--
 include/unotools/localedatawrapper.hxx        |    8 ++++++--
 sd/source/ui/slideshow/showwin.cxx            |    3 ++-
 sfx2/source/dialog/dinfdlg.cxx                |   10 ++++++----
 unotools/source/i18n/localedatawrapper.cxx    |   21 +++++++++++++--------
 vcl/source/control/field2.cxx                 |    9 +++++++--
 6 files changed, 39 insertions(+), 19 deletions(-)

New commits:
commit c20337889469e41cec89bd421fab533f16b4b451
Author:     Eike Rathke <er...@redhat.com>
AuthorDate: Fri Jun 23 14:44:44 2023 +0200
Commit:     Eike Rathke <er...@redhat.com>
CommitDate: Sat Jun 24 01:20:12 2023 +0200

    Change LocaleDataWrapper::getDuration() parameter to tools::Duration
    
    ... instead of tools::Time
    
    Change-Id: I8e49de43a1870541d75add34089eec67b7a8be31
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/153533
    Reviewed-by: Eike Rathke <er...@redhat.com>
    Tested-by: Jenkins

diff --git a/avmedia/source/framework/MediaControlBase.cxx 
b/avmedia/source/framework/MediaControlBase.cxx
index d2c254293811..fb8f91066b67 100644
--- a/avmedia/source/framework/MediaControlBase.cxx
+++ b/avmedia/source/framework/MediaControlBase.cxx
@@ -20,6 +20,7 @@
 #include <avmedia/mediaplayer.hxx>
 #include <avmedia/mediaitem.hxx>
 #include <tools/time.hxx>
+#include <tools/duration.hxx>
 #include <unotools/localedatawrapper.hxx>
 #include <strings.hrc>
 #include <helpids.h>
@@ -46,9 +47,11 @@ void MediaControlBase::UpdateTimeField( MediaItem const & 
aMediaItem, double fTi
     SvtSysLocale aSysLocale;
     const LocaleDataWrapper& rLocaleData = aSysLocale.GetLocaleData();
 
-    aTimeString += rLocaleData.getDuration( tools::Time( 0, 0, static_cast< 
sal_uInt32 >( floor( fTime ) ) ) ) +
+    aTimeString += rLocaleData.getDuration(
+            tools::Duration( 0, 0, 0, static_cast<sal_uInt32>( floor( fTime 
)), 0)) +
         " / " +
-        rLocaleData.getDuration( tools::Time( 0, 0, static_cast< sal_uInt32 >( 
floor( aMediaItem.getDuration() ) )) );
+        rLocaleData.getDuration(
+                tools::Duration( 0, 0, 0, static_cast<sal_uInt32>( floor( 
aMediaItem.getDuration())), 0));
 
     if( mxTimeEdit->get_text() != aTimeString )
         mxTimeEdit->set_text( aTimeString );
diff --git a/include/unotools/localedatawrapper.hxx 
b/include/unotools/localedatawrapper.hxx
index 5fbdcd0782b7..d6eeb174e735 100644
--- a/include/unotools/localedatawrapper.hxx
+++ b/include/unotools/localedatawrapper.hxx
@@ -42,7 +42,11 @@ namespace com::sun::star::i18n { struct FormatElement; }
 namespace com::sun::star::i18n { struct CalendarItem2; }
 
 class Date;
-namespace tools { class Time; }
+namespace tools
+{
+class Time;
+class Duration;
+}
 class CalendarWrapper;
 
 enum class DateOrder {
@@ -311,7 +315,7 @@ public:
     OUString       getDate( const Date& rDate ) const;
     OUString       getTime( const tools::Time& rTime, bool bSec = true,
                             bool b100Sec = false ) const;
-    OUString       getDuration( const tools::Time& rTime,
+    OUString       getDuration( const tools::Duration& rDuration,
                             bool bSec = true, bool b100Sec = false ) const;
 
                         /** Simple number formatting
diff --git a/sd/source/ui/slideshow/showwin.cxx 
b/sd/source/ui/slideshow/showwin.cxx
index 8e1f8a6d49cd..4bc0d414307c 100644
--- a/sd/source/ui/slideshow/showwin.cxx
+++ b/sd/source/ui/slideshow/showwin.cxx
@@ -38,6 +38,7 @@
 #include <utility>
 #include <vcl/settings.hxx>
 #include <vcl/virdev.hxx>
+#include <tools/duration.hxx>
 
 using namespace ::com::sun::star;
 
@@ -512,7 +513,7 @@ void ShowWindow::DrawPauseScene( bool bTimeoutOnly )
             SvtSysLocale                aSysLocale;
             const LocaleDataWrapper&    aLocaleData = 
aSysLocale.GetLocaleData();
 
-            aText += " ( " + aLocaleData.getDuration( ::tools::Time( 0, 0, 
mnPauseTimeout ) ) + " )";
+            aText += " ( " + aLocaleData.getDuration( ::tools::Duration( 0, 0, 
0, mnPauseTimeout, 0 )) + " )";
             pVDev->DrawText( Point( aOffset.Width(), 0 ), aText );
             GetOutDev()->DrawOutDev( Point( aOutOrg.X(), aOffset.Height() ), 
aVDevSize, Point(), aVDevSize, *pVDev );
             bDrawn = true;
diff --git a/sfx2/source/dialog/dinfdlg.cxx b/sfx2/source/dialog/dinfdlg.cxx
index f702c2ec10c1..5c564af981a2 100644
--- a/sfx2/source/dialog/dinfdlg.cxx
+++ b/sfx2/source/dialog/dinfdlg.cxx
@@ -19,6 +19,7 @@
 
 #include <svl/eitem.hxx>
 #include <tools/datetime.hxx>
+#include <tools/duration.hxx>
 #include <tools/debug.hxx>
 #include <tools/urlobj.hxx>
 #include <utility>
@@ -745,8 +746,7 @@ IMPL_LINK_NOARG(SfxDocumentPage, DeleteHdl, weld::Button&, 
void)
     m_xCreateValFt->set_label( ConvertDateTime_Impl( aName, uDT, 
rLocaleWrapper ) );
     m_xChangeValFt->set_label( "" );
     m_xPrintValFt->set_label( "" );
-    const tools::Time aTime( 0 );
-    m_xTimeLogValFt->set_label( rLocaleWrapper.getDuration( aTime ) );
+    m_xTimeLogValFt->set_label( rLocaleWrapper.getDuration( tools::Duration() 
) );
     m_xDocNoValFt->set_label(OUString('1'));
     bHandleDelete = true;
 }
@@ -1065,8 +1065,10 @@ void SfxDocumentPage::Reset( const SfxItemSet* rSet )
     const tools::Long nTime = rInfoItem.getEditingDuration();
     if ( bUseUserData )
     {
-        const tools::Time aT( nTime/3600, (nTime%3600)/60, nTime%60 );
-        m_xTimeLogValFt->set_label( rLocaleWrapper.getDuration( aT ) );
+        assert(SAL_MIN_INT32 <= nTime/86400 && nTime/86400 <= SAL_MAX_INT32);
+        const tools::Duration aD( static_cast<sal_Int32>(nTime)/86400,
+                (nTime%86400)/3600, (nTime%3600)/60, nTime%60, 0);
+        m_xTimeLogValFt->set_label( rLocaleWrapper.getDuration( aD ) );
         m_xDocNoValFt->set_label( OUString::number(
             rInfoItem.getEditingCycles() ) );
     }
diff --git a/unotools/source/i18n/localedatawrapper.cxx 
b/unotools/source/i18n/localedatawrapper.cxx
index 56524372e21f..87299810ab6b 100644
--- a/unotools/source/i18n/localedatawrapper.cxx
+++ b/unotools/source/i18n/localedatawrapper.cxx
@@ -41,6 +41,7 @@
 #include <rtl/math.hxx>
 #include <tools/date.hxx>
 #include <tools/time.hxx>
+#include <tools/duration.hxx>
 #include <o3tl/string_view.hxx>
 #include <utility>
 
@@ -1173,28 +1174,32 @@ OUString LocaleDataWrapper::getTime( const tools::Time& 
rTime, bool bSec, bool b
     return aBuf.makeStringAndClear();
 }
 
-OUString LocaleDataWrapper::getDuration( const tools::Time& rTime, bool bSec, 
bool b100Sec ) const
+OUString LocaleDataWrapper::getDuration( const tools::Duration& rDuration, 
bool bSec, bool b100Sec ) const
 {
     OUStringBuffer aBuf(128);
 
-    if ( rTime < tools::Time( 0 ) )
-        aBuf.append(' ' );
+    if ( rDuration.IsNegative() )
+        aBuf.append(' ');
 
+    sal_Int64 nHours = static_cast<sal_Int64>(rDuration.GetDays()) * 24 +
+        (rDuration.IsNegative() ?
+         -static_cast<sal_Int64>(rDuration.GetTime().GetHour()) :
+         rDuration.GetTime().GetHour());
     if ( (true) /* IsTimeLeadingZero() */ )
-        ImplAddUNum( aBuf, rTime.GetHour(), 2 );
+        ImplAddNum( aBuf, nHours, 2 );
     else
-        ImplAddUNum( aBuf, rTime.GetHour() );
+        ImplAddNum( aBuf, nHours, 1 );
     aBuf.append( aLocaleDataItem.timeSeparator );
-    ImplAdd2UNum( aBuf, rTime.GetMin() );
+    ImplAdd2UNum( aBuf, rDuration.GetTime().GetMin() );
     if ( bSec )
     {
         aBuf.append( aLocaleDataItem.timeSeparator );
-        ImplAdd2UNum( aBuf, rTime.GetSec() );
+        ImplAdd2UNum( aBuf, rDuration.GetTime().GetSec() );
 
         if ( b100Sec )
         {
             aBuf.append( aLocaleDataItem.time100SecSeparator );
-            ImplAdd9UNum( aBuf, rTime.GetNanoSec() );
+            ImplAdd9UNum( aBuf, rDuration.GetTime().GetNanoSec() );
         }
     }
 
diff --git a/vcl/source/control/field2.cxx b/vcl/source/control/field2.cxx
index 3142106609ed..8552d2510d24 100644
--- a/vcl/source/control/field2.cxx
+++ b/vcl/source/control/field2.cxx
@@ -44,6 +44,7 @@
 #include <unotools/charclass.hxx>
 #include <svl/numformat.hxx>
 #include <svl/zforlist.hxx>
+#include <tools/duration.hxx>
 
 using namespace ::com::sun::star;
 using namespace ::comphelper;
@@ -2556,7 +2557,10 @@ void TimeFormatter::ImplTimeReformat( 
std::u16string_view rStr, OUString& rOutSt
         rOutStr += OUString::createFromAscii(ostr.str());
     }
     else if ( mbDuration )
-        rOutStr = ImplGetLocaleDataWrapper().getDuration( aTempTime, bSecond, 
b100Sec );
+    {
+        tools::Duration aDuration( 0, aTempTime);
+        rOutStr = ImplGetLocaleDataWrapper().getDuration( aDuration, bSecond, 
b100Sec );
+    }
     else
     {
         rOutStr = ImplGetLocaleDataWrapper().getTime( aTempTime, bSecond, 
b100Sec );
@@ -2788,7 +2792,8 @@ OUString TimeFormatter::FormatTime(const tools::Time& 
rNewTime, TimeFieldFormat
     }
     else if ( bDuration )
     {
-        aStr = rLocaleData.getDuration( rNewTime, bSec, b100Sec );
+        tools::Duration aDuration( 0, rNewTime);
+        aStr = rLocaleData.getDuration( aDuration, bSec, b100Sec );
     }
     else
     {

Reply via email to