[Libreoffice-commits] core.git: svl/source

Eike Rathke erack at redhat.com
Tue May 20 01:35:04 PDT 2014


 svl/source/numbers/zforfind.cxx |   85 +++++++++++++++++++++++++++-------------
 1 file changed, 59 insertions(+), 26 deletions(-)

New commits:
commit 43624d9370c4384f71c6b13fed900eaec222cf64
Author: Eike Rathke <erack at redhat.com>
Date:   Tue May 20 10:28:58 2014 +0200

    resolved fdo#34724 Jan1 or 1Jan without separating character is not date
    
    Change-Id: I2cf02a26b81fa634c842df455de669f1c60241bc

diff --git a/svl/source/numbers/zforfind.cxx b/svl/source/numbers/zforfind.cxx
index 6d6b9d5..fef69c5 100644
--- a/svl/source/numbers/zforfind.cxx
+++ b/svl/source/numbers/zforfind.cxx
@@ -2054,16 +2054,25 @@ bool ImpSvNumberInputScan::ScanStartString( const OUString& rString,
     }
     else
     {
-        nMonth = GetMonth(rString, nPos);
-        if ( nMonth )    // month (Jan 1)?
+        const sal_Int32 nMonthStart = nPos;
+        short nTempMonth = GetMonth(rString, nPos);
+        if ( nTempMonth )    // month (Jan 1)?
         {
-            eScannedType = NUMBERFORMAT_DATE;       // !!! it IS a date !!!
-            nMonthPos = 1;                          // month at the beginning
-            if ( nMonth < 0 )
+            if (nPos < rString.getLength())         // Jan1 without separator is not a date
             {
-                SkipChar( '.', rString, nPos );     // abbreviated
+                eScannedType = NUMBERFORMAT_DATE;   // !!! it IS a date !!!
+                nMonth = nTempMonth;
+                nMonthPos = 1;                      // month at the beginning
+                if ( nMonth < 0 )
+                {
+                    SkipChar( '.', rString, nPos ); // abbreviated
+                }
+                SkipBlanks(rString, nPos);
+            }
+            else
+            {
+                nPos = nMonthStart;                 // rewind month
             }
-            SkipBlanks(rString, nPos);
         }
         else
         {
@@ -2089,15 +2098,23 @@ bool ImpSvNumberInputScan::ScanStartString( const OUString& rString,
                         SkipString( pFormatter->GetLocaleData()->getLongDateDayOfWeekSep(), rString, nPos );
                     }
                     SkipBlanks(rString, nPos);
-                    nMonth = GetMonth(rString, nPos);
-                    if ( nMonth ) // month (Jan 1)?
+                    nTempMonth = GetMonth(rString, nPos);
+                    if ( nTempMonth ) // month (Jan 1)?
                     {
-                        nMonthPos = 1; // month a the beginning
-                        if ( nMonth < 0 )
+                        if (nPos < rString.getLength())         // Jan1 without separator is not a date
                         {
-                            SkipChar( '.', rString, nPos ); // abbreviated
+                            nMonth = nTempMonth;
+                            nMonthPos = 1; // month a the beginning
+                            if ( nMonth < 0 )
+                            {
+                                SkipChar( '.', rString, nPos ); // abbreviated
+                            }
+                            SkipBlanks(rString, nPos);
+                        }
+                        else
+                        {
+                            nPos = nMonthStart;                 // rewind month
                         }
-                        SkipBlanks(rString, nPos);
                     }
                 }
                 if (!nMonth)
@@ -2282,6 +2299,7 @@ bool ImpSvNumberInputScan::ScanMidString( const OUString& rString,
         }
     }
 
+    const sal_Int32 nMonthStart = nPos;
     short nTempMonth = GetMonth(rString, nPos);     // month in the middle (10 Jan 94)
     if (nTempMonth)
     {
@@ -2294,15 +2312,22 @@ bool ImpSvNumberInputScan::ScanMidString( const OUString& rString,
         {
             return MatchedReturn();
         }
-        eScannedType = NUMBERFORMAT_DATE;           // !!! it IS a date
-        nMonth = nTempMonth;
-        nMonthPos = 2;                              // month in the middle
-        if ( nMonth < 0 )
+        if (nMonthStart > 0 && nPos < rString.getLength())  // 10Jan or Jan94 without separator are not dates
+        {
+            eScannedType = NUMBERFORMAT_DATE;       // !!! it IS a date
+            nMonth = nTempMonth;
+            nMonthPos = 2;                          // month in the middle
+            if ( nMonth < 0 )
+            {
+                SkipChar( '.', rString, nPos );     // abbreviated
+            }
+            SkipString( pLoc->getLongDateMonthSep(), rString, nPos );
+            SkipBlanks(rString, nPos);
+        }
+        else
         {
-            SkipChar( '.', rString, nPos );         // abbreviated
+            nPos = nMonthStart;                     // rewind month
         }
-        SkipString( pLoc->getLongDateMonthSep(), rString, nPos );
-        SkipBlanks(rString, nPos);
     }
 
     if ( SkipChar('E', rString, nPos) ||            // 10E, 10e, 10,Ee
@@ -2630,6 +2655,7 @@ bool ImpSvNumberInputScan::ScanEndString( const OUString& rString,
         }
     }
 
+    const sal_Int32 nMonthStart = nPos;
     short nTempMonth = GetMonth(rString, nPos);     // 10 Jan
     if (nTempMonth)
     {
@@ -2642,14 +2668,21 @@ bool ImpSvNumberInputScan::ScanEndString( const OUString& rString,
         {
             return MatchedReturn();
         }
-        eScannedType = NUMBERFORMAT_DATE;
-        nMonth = nTempMonth;
-        nMonthPos = 3;                              // month at end
-        if ( nMonth < 0 )
+        if (nMonthStart > 0)                        // 10Jan without separator is not a date
+        {
+            eScannedType = NUMBERFORMAT_DATE;
+            nMonth = nTempMonth;
+            nMonthPos = 3;                          // month at end
+            if ( nMonth < 0 )
+            {
+                SkipChar( '.', rString, nPos );     // abbreviated
+            }
+            SkipBlanks(rString, nPos);
+        }
+        else
         {
-            SkipChar( '.', rString, nPos );         // abbreviated
+            nPos = nMonthStart;                     // rewind month
         }
-        SkipBlanks(rString, nPos);
     }
 
     sal_Int32 nOrigPos = nPos;


More information about the Libreoffice-commits mailing list