summaryrefslogtreecommitdiff
path: root/svl/source/numbers/zforfind.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'svl/source/numbers/zforfind.cxx')
-rw-r--r--svl/source/numbers/zforfind.cxx55
1 files changed, 47 insertions, 8 deletions
diff --git a/svl/source/numbers/zforfind.cxx b/svl/source/numbers/zforfind.cxx
index 31f9c2cb8461..eae56daf0eb5 100644
--- a/svl/source/numbers/zforfind.cxx
+++ b/svl/source/numbers/zforfind.cxx
@@ -1021,12 +1021,6 @@ bool ImpSvNumberInputScan::CanForceToIso8601( DateFormat eDateFormat )
break;
}
- if (pFormatter->GetDateSep() != '-')
- {
- nCanForceToIso8601 = 2; // date separator does not interfere
- break;
- }
-
sal_Int32 n;
switch (eDateFormat)
{
@@ -1300,6 +1294,18 @@ DateFormat ImpSvNumberInputScan::GetDateOrder()
return DMY;
}
break;
+ default:
+ case 0:
+ switch ((nOrder & 0xff))
+ {
+ case 'Y':
+ return YMD;
+ case 'M':
+ return MDY;
+ case 'D':
+ return DMY;
+ }
+ break;
}
}
SAL_WARN( "nf.date", "ImpSvNumberInputScan::GetDateOrder: undefined, falling back to locale's default");
@@ -1440,8 +1446,30 @@ input for the following reasons:
nCounter = 1;
switch (nMonthPos) // where is the month
{
- case 0: // not found => only day entered
- pCal->setValue( CalendarFieldIndex::DAY_OF_MONTH, ImplGetDay(0) );
+ case 0: // not found
+ {
+ // If input matched a date pattern, use the pattern
+ // to determine if it is a day, month or year. The
+ // pattern should have only one single value then,
+ // 'D-', 'M-' or 'Y-'. If input did not match a
+ // pattern assume the usual day of current month.
+ sal_uInt32 nDateOrder = (bFormatTurn ?
+ pFormat->GetExactDateOrder() :
+ GetDatePatternOrder());
+ switch (nDateOrder)
+ {
+ case 'Y':
+ pCal->setValue( CalendarFieldIndex::YEAR, ImplGetYear(0) );
+ break;
+ case 'M':
+ pCal->setValue( CalendarFieldIndex::MONTH, ImplGetMonth(0) );
+ break;
+ case 'D':
+ default:
+ pCal->setValue( CalendarFieldIndex::DAY_OF_MONTH, ImplGetDay(0) );
+ break;
+ }
+ }
break;
case 1: // month at the beginning (Jan 01)
pCal->setValue( CalendarFieldIndex::MONTH, Abs(nMonth)-1 );
@@ -2233,6 +2261,7 @@ bool ImpSvNumberInputScan::ScanEndString( const String& rString,
}
}
+ bool bSignDetectedHere = false;
if ( nSign == 0 // conflict - not signed
&& eScannedType != NUMBERFORMAT_DATE) // and not date
//!? catch time too?
@@ -2240,6 +2269,8 @@ bool ImpSvNumberInputScan::ScanEndString( const String& rString,
nSign = GetSign(rString, nPos); // 1- DM
if (nNegCheck) // '(' as sign
return MatchedReturn();
+ if (nSign)
+ bSignDetectedHere = true;
}
SkipBlanks(rString, nPos);
@@ -2310,6 +2341,8 @@ bool ImpSvNumberInputScan::ScanEndString( const String& rString,
const String& rDate = pFormatter->GetDateSep();
bDate = SkipString( rDate, rString, nPos); // 10. 10- 10/
}
+ if (bDate && bSignDetectedHere)
+ nSign = 0; // 'D-' takes precedence over signed date
if (bDate
|| ((MayBeIso8601() || MayBeMonthDate())
&& SkipChar( '-', rString, nPos)))
@@ -2877,6 +2910,12 @@ void ImpSvNumberInputScan::ChangeIntl()
cDecSep == pFormatter->GetDateSep().GetChar(0) );
bTextInitialized = false;
aUpperCurrSymbol.Erase();
+ InvalidateDateAcceptancePatterns();
+}
+
+
+void ImpSvNumberInputScan::InvalidateDateAcceptancePatterns()
+{
if (sDateAcceptancePatterns.getLength())
sDateAcceptancePatterns = ::com::sun::star::uno::Sequence< ::rtl::OUString >();
}