svl/source/numbers/zforfind.cxx |   13 +++++++++----
 svl/source/numbers/zforfind.hxx |    6 +++++-
 2 files changed, 14 insertions(+), 5 deletions(-)

New commits:
commit 803b5513eff8f8c185a91e91aee235dfab38d3bc
Author: Eike Rathke <er...@redhat.com>
Date:   Thu May 10 16:19:44 2012 +0200

    resolved fdo#46233 value >12 with AM/PM can't be clock time

diff --git a/svl/source/numbers/zforfind.cxx b/svl/source/numbers/zforfind.cxx
index cce08f9..31f9c2c 100644
--- a/svl/source/numbers/zforfind.cxx
+++ b/svl/source/numbers/zforfind.cxx
@@ -860,11 +860,12 @@ inline bool ImpSvNumberInputScan::GetNextNumber( 
sal_uInt16& i, sal_uInt16& j )
 //---------------------------------------------------------------------------
 //      GetTimeRef
 
-void ImpSvNumberInputScan::GetTimeRef(
+bool ImpSvNumberInputScan::GetTimeRef(
         double& fOutNumber,
         sal_uInt16 nIndex,          // j-value of the first numeric time part 
of input, default 0
         sal_uInt16 nAnz )           // count of numeric time parts
 {
+    bool bRet = true;
     sal_uInt16 nHour;
     sal_uInt16 nMinute = 0;
     sal_uInt16 nSecond = 0;
@@ -893,6 +894,7 @@ void ImpSvNumberInputScan::GetTimeRef(
     else
     {
         nHour = 0;
+        bRet = false;
         SAL_WARN( "svl.items", "ImpSvNumberInputScan::GetTimeRef: bad number 
index");
     }
     if (nDecPos == 2 && nAnz == 2)                  // 45.5
@@ -903,7 +905,9 @@ void ImpSvNumberInputScan::GetTimeRef(
         nSecond = (sal_uInt16) sStrArray[nNums[nIndex++]].ToInt32();
     if (nIndex - nStartIndex < nAnz)
         fSecond100 = StringToDouble( sStrArray[nNums[nIndex]], true );
-    if (nAmPm == -1 && nHour != 12)             // PM
+    if (nAmPm && nHour > 12)                    // not a valid AM/PM clock time
+        bRet = false;
+    else if (nAmPm == -1 && nHour != 12)        // PM
         nHour += 12;
     else if (nAmPm == 1 && nHour == 12)         // 12 AM
         nHour = 0;
@@ -912,6 +916,7 @@ void ImpSvNumberInputScan::GetTimeRef(
                   (double)nMinute*60 +
                   (double)nSecond +
                   fSecond100)/86400.0;
+    return bRet;
 }
 
 
@@ -3171,7 +3176,7 @@ bool ImpSvNumberInputScan::IsNumberFormat(
                 break;
 
             case NUMBERFORMAT_TIME:
-                GetTimeRef(fOutNumber, 0, nAnzNums);
+                res = GetTimeRef(fOutNumber, 0, nAnzNums);
                 if ( nSign < 0 )
                     fOutNumber = -fOutNumber;
                 break;
@@ -3190,7 +3195,7 @@ bool ImpSvNumberInputScan::IsNumberFormat(
                 if ( res )
                 {
                     double fTime;
-                    GetTimeRef( fTime, nCounter, nAnzNums - nCounter );
+                    res = GetTimeRef( fTime, nCounter, nAnzNums - nCounter );
                     fOutNumber += fTime;
                 }
             }
diff --git a/svl/source/numbers/zforfind.hxx b/svl/source/numbers/zforfind.hxx
index c57c90a..7c2e8eb 100644
--- a/svl/source/numbers/zforfind.hxx
+++ b/svl/source/numbers/zforfind.hxx
@@ -294,7 +294,11 @@ private:
             sal_uInt16& i,
             sal_uInt16& j );
 
-    void GetTimeRef(                                // Converts time -> double 
(only decimals)
+    /** Converts time -> double (only decimals)
+
+        @return TRUE if time, FALSE if not (e.g. hours >12 with AM/PM)
+     */
+    bool GetTimeRef(
             double& fOutNumber,                     // result as double
             sal_uInt16 nIndex,                      // Index of hour in input
             sal_uInt16 nAnz );                      // Count of time 
substrings in input
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to