svl/source/numbers/zforfind.cxx |   13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

New commits:
commit bd33e2673b3d97a6f1d7ab16eb8f83faae09d980
Author:     Eike Rathke <er...@redhat.com>
AuthorDate: Thu Aug 6 01:40:04 2020 +0200
Commit:     Adolfo Jayme Barrientos <fit...@ubuntu.com>
CommitDate: Thu Aug 6 05:33:06 2020 +0200

    Resolves: tdf#135249 Duration input 0:123 or 0:0:123 or 0:123:59 is valid
    
    Change-Id: Ie624b324822495192edc65d046945eb92356550b
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/100192
    Reviewed-by: Eike Rathke <er...@redhat.com>
    Tested-by: Jenkins
    (cherry picked from commit 1616b53292cdc22c04d07bb21e71bf43dcd22299)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/100211
    Reviewed-by: Adolfo Jayme Barrientos <fit...@ubuntu.com>

diff --git a/svl/source/numbers/zforfind.cxx b/svl/source/numbers/zforfind.cxx
index 42ffbd325bac..0803604e553a 100644
--- a/svl/source/numbers/zforfind.cxx
+++ b/svl/source/numbers/zforfind.cxx
@@ -989,6 +989,9 @@ bool ImpSvNumberInputScan::GetTimeRef( double& fOutNumber,
         SAL_WARN( "svl.numbers", "ImpSvNumberInputScan::GetTimeRef: bad number 
index");
     }
 
+    // 0:123 or 0:0:123 or 0:123:59 is valid
+    bool bAllowDuration = (nHour == 0 && !nAmPm);
+
     if (nAmPm && nHour > 12) // not a valid AM/PM clock time
     {
         bRet = false;
@@ -1009,16 +1012,18 @@ bool ImpSvNumberInputScan::GetTimeRef( double& 
fOutNumber,
     else if (nIndex - nStartIndex < nCnt)
     {
         nMinute = 
static_cast<sal_uInt16>(sStrArray[nNums[nIndex++]].toInt32());
-        if (!(eInputOptions & SvNumInputOptions::LAX_TIME)
+        if (!(eInputOptions & SvNumInputOptions::LAX_TIME) && !bAllowDuration
                 && nIndex > 1 && nMinute > 59)
-            bRet = false;   // 1:60 or 1:123 is invalid, 123:1 is valid
+            bRet = false;   // 1:60 or 1:123 is invalid, 123:1 or 0:123 is 
valid
+        if (bAllowDuration)
+            bAllowDuration = (nMinute == 0);
     }
     if (nIndex - nStartIndex < nCnt)
     {
         nSecond = 
static_cast<sal_uInt16>(sStrArray[nNums[nIndex++]].toInt32());
-        if (!(eInputOptions & SvNumInputOptions::LAX_TIME)
+        if (!(eInputOptions & SvNumInputOptions::LAX_TIME) && !bAllowDuration
                 && nIndex > 1 && nSecond > 59 && !(nHour == 23 && nMinute == 
59 && nSecond == 60))
-            bRet = false;   // 1:60 or 1:123 or 1:1:123 is invalid, 123:1 or 
123:1:1 is valid, or leap second
+            bRet = false;   // 1:60 or 1:123 or 1:1:123 is invalid, 123:1 or 
123:1:1 or 0:0:123 is valid, or leap second
     }
     if (nIndex - nStartIndex < nCnt)
     {
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to