summaryrefslogtreecommitdiff
path: root/svl
diff options
context:
space:
mode:
authorEike Rathke <erack@redhat.com>2014-05-20 10:28:58 +0200
committerEike Rathke <erack@redhat.com>2014-05-20 10:34:42 +0200
commit43624d9370c4384f71c6b13fed900eaec222cf64 (patch)
treeb6a873506c9a933459f2a89be4c37f78e09529a9 /svl
parentd2a19aad658cc0e8939c16b5137c15727c3cdff9 (diff)
resolved fdo#34724 Jan1 or 1Jan without separating character is not date
Change-Id: I2cf02a26b81fa634c842df455de669f1c60241bc
Diffstat (limited to 'svl')
-rw-r--r--svl/source/numbers/zforfind.cxx85
1 files changed, 59 insertions, 26 deletions
diff --git a/svl/source/numbers/zforfind.cxx b/svl/source/numbers/zforfind.cxx
index 6d6b9d5c186f..fef69c5e2d8c 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;