summaryrefslogtreecommitdiff
path: root/svl
diff options
context:
space:
mode:
Diffstat (limited to 'svl')
-rw-r--r--svl/inc/svl/zforlist.hxx4
-rw-r--r--svl/source/numbers/zforfind.cxx55
-rw-r--r--svl/source/numbers/zforfind.hxx2
-rw-r--r--svl/source/numbers/zforlist.cxx37
4 files changed, 77 insertions, 21 deletions
diff --git a/svl/inc/svl/zforlist.hxx b/svl/inc/svl/zforlist.hxx
index 701216468f0d..2dfa273df6da 100644
--- a/svl/inc/svl/zforlist.hxx
+++ b/svl/inc/svl/zforlist.hxx
@@ -953,6 +953,10 @@ public:
// called by SvNumberFormatterRegistry_Impl::Notify if the default system currency changes
void ResetDefaultSystemCurrency();
+ // Called by SvNumberFormatterRegistry_Impl::Notify if the system locale's
+ // date acceptence patterns change.
+ void InvalidateDateAcceptancePatterns();
+
// Replace the SYSTEM language/country format codes. Called upon change of
// the user configurable locale.
// Old compatibility codes are replaced, user defined are converted, and
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 >();
}
diff --git a/svl/source/numbers/zforfind.hxx b/svl/source/numbers/zforfind.hxx
index 7c2e8eb09122..233b012a4983 100644
--- a/svl/source/numbers/zforfind.hxx
+++ b/svl/source/numbers/zforfind.hxx
@@ -83,6 +83,8 @@ public:
*/
bool CanForceToIso8601( DateFormat eDateFormat );
+ void InvalidateDateAcceptancePatterns();
+
private:
SvNumberFormatter* pFormatter;
String* pUpperMonthText; // Array of month names, uppercase
diff --git a/svl/source/numbers/zforlist.cxx b/svl/source/numbers/zforlist.cxx
index 7c8a49ca727b..8cd59f850386 100644
--- a/svl/source/numbers/zforlist.cxx
+++ b/svl/source/numbers/zforlist.cxx
@@ -151,19 +151,24 @@ void SvNumberFormatterRegistry_Impl::ConfigurationChanged(
utl::ConfigurationBroadcaster*,
sal_uInt32 nHint)
{
- if ( nHint & SYSLOCALEOPTIONS_HINT_LOCALE )
- {
- ::osl::MutexGuard aGuard( SvNumberFormatter::GetMutex() );
- for( size_t i = 0, n = aFormatters.size(); i < n; ++i )
- aFormatters[ i ]->ReplaceSystemCL( eSysLanguage );
- eSysLanguage = MsLangId::getRealLanguage( LANGUAGE_SYSTEM );
- }
- if ( nHint & SYSLOCALEOPTIONS_HINT_CURRENCY )
- {
- ::osl::MutexGuard aGuard( SvNumberFormatter::GetMutex() );
- for( size_t i = 0, n = aFormatters.size(); i < n; ++i )
- aFormatters[ i ]->ResetDefaultSystemCurrency();
- }
+ ::osl::MutexGuard aGuard( SvNumberFormatter::GetMutex() );
+
+ if ( nHint & SYSLOCALEOPTIONS_HINT_LOCALE )
+ {
+ for( size_t i = 0, n = aFormatters.size(); i < n; ++i )
+ aFormatters[ i ]->ReplaceSystemCL( eSysLanguage );
+ eSysLanguage = MsLangId::getRealLanguage( LANGUAGE_SYSTEM );
+ }
+ if ( nHint & SYSLOCALEOPTIONS_HINT_CURRENCY )
+ {
+ for( size_t i = 0, n = aFormatters.size(); i < n; ++i )
+ aFormatters[ i ]->ResetDefaultSystemCurrency();
+ }
+ if ( nHint & SYSLOCALEOPTIONS_HINT_DATEPATTERNS )
+ {
+ for( size_t i = 0, n = aFormatters.size(); i < n; ++i )
+ aFormatters[ i ]->InvalidateDateAcceptancePatterns();
+ }
}
@@ -3183,6 +3188,12 @@ void SvNumberFormatter::ResetDefaultSystemCurrency()
}
+void SvNumberFormatter::InvalidateDateAcceptancePatterns()
+{
+ pStringScanner->InvalidateDateAcceptancePatterns();
+}
+
+
sal_uInt32 SvNumberFormatter::ImpGetDefaultSystemCurrencyFormat()
{
if ( nDefaultSystemCurrencyFormat == NUMBERFORMAT_ENTRY_NOT_FOUND )