summaryrefslogtreecommitdiff
path: root/svtools
diff options
context:
space:
mode:
authorEike Rathke <er@openoffice.org>2001-04-11 15:02:40 +0000
committerEike Rathke <er@openoffice.org>2001-04-11 15:02:40 +0000
commitd325ea1a9fa66f59a9561e63534bee3831755cce (patch)
tree7f1b9955eac71a80738f7781ac1ff5e6202d8b10 /svtools
parentd794cbf481154454e115a25125ea2e5ebdd53753 (diff)
maintain cached table of default format keys
Diffstat (limited to 'svtools')
-rw-r--r--svtools/source/numbers/zforlist.cxx87
1 files changed, 56 insertions, 31 deletions
diff --git a/svtools/source/numbers/zforlist.cxx b/svtools/source/numbers/zforlist.cxx
index f385c57555af..d387ab37012e 100644
--- a/svtools/source/numbers/zforlist.cxx
+++ b/svtools/source/numbers/zforlist.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: zforlist.cxx,v $
*
- * $Revision: 1.24 $
+ * $Revision: 1.25 $
*
- * last change: $Author: er $ $Date: 2001-04-06 18:02:47 $
+ * last change: $Author: er $ $Date: 2001-04-11 16:02:40 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -198,7 +198,6 @@ void SvNumberFormatter::ImpConstruct( LanguageType eLang )
ActLnge = eLang;
eEvalDateFormat = NF_EVALDATEFORMAT_INTL;
nDefaultSystemCurrencyFormat = NUMBERFORMAT_ENTRY_NOT_FOUND;
- nDefaultCurrencyFormat = NUMBERFORMAT_ENTRY_NOT_FOUND;
aLocale = ConvertLanguageToLocale( eLang );
pCharClass = new CharClass( xServiceManager, aLocale );
@@ -226,7 +225,6 @@ void SvNumberFormatter::ChangeIntl(LanguageType eLnge)
if (ActLnge != eLnge)
{
ActLnge = eLnge;
- nDefaultCurrencyFormat = NUMBERFORMAT_ENTRY_NOT_FOUND;
aLocale = ConvertLanguageToLocale( eLnge );
pCharClass->setLocale( aLocale );
@@ -1057,11 +1055,31 @@ BOOL SvNumberFormatter::IsCompatible(short eOldType,
ULONG SvNumberFormatter::ImpGetDefaultFormat( short nType )
{
-//! TODO: cache every default format similar to ImpGetDefaultCurrencyFormat().
-//! Should be a table bearing all touched locales, DefaultCurrency included.
-//! The current performance is very poor.
ULONG CLOffset = ImpGetCLOffset( ActLnge );
- ULONG nDefaultFormat = NUMBERFORMAT_ENTRY_NOT_FOUND;
+ ULONG nSearch;
+ switch( nType )
+ {
+ case NUMBERFORMAT_DATE :
+ nSearch = CLOffset + ZF_STANDARD_DATE;
+ break;
+ case NUMBERFORMAT_TIME :
+ nSearch = CLOffset + ZF_STANDARD_TIME;
+ break;
+ case NUMBERFORMAT_DATETIME :
+ nSearch = CLOffset + ZF_STANDARD_DATETIME;
+ break;
+ case NUMBERFORMAT_PERCENT :
+ nSearch = CLOffset + ZF_STANDARD_PERCENT;
+ break;
+ case NUMBERFORMAT_SCIENTIFIC:
+ nSearch = CLOffset + ZF_STANDARD_SCIENTIFIC;
+ break;
+ default:
+ nSearch = CLOffset + ZF_STANDARD;
+ }
+ ULONG nDefaultFormat = (ULONG) aDefaultFormatKeys.Get( nSearch );
+ if ( !nDefaultFormat )
+ nDefaultFormat = NUMBERFORMAT_ENTRY_NOT_FOUND;
if ( nDefaultFormat == NUMBERFORMAT_ENTRY_NOT_FOUND )
{ // look for a defined standard
ULONG nStopKey = CLOffset + SV_COUNTRY_LANGUAGE_OFFSET;
@@ -1078,30 +1096,31 @@ ULONG SvNumberFormatter::ImpGetDefaultFormat( short nType )
}
aFTable.Next();
}
- }
- if ( nDefaultFormat == NUMBERFORMAT_ENTRY_NOT_FOUND )
- { // none found, use old fixed standards
- switch( nType )
- {
- case NUMBERFORMAT_DATE :
- nDefaultFormat = CLOffset + ZF_STANDARD_DATE;
- break;
- case NUMBERFORMAT_TIME :
- nDefaultFormat = CLOffset + ZF_STANDARD_TIME+1;
- break;
- case NUMBERFORMAT_DATETIME :
- nDefaultFormat = CLOffset + ZF_STANDARD_DATETIME;
- break;
- case NUMBERFORMAT_PERCENT :
- nDefaultFormat = CLOffset + ZF_STANDARD_PERCENT+1;
- break;
- case NUMBERFORMAT_SCIENTIFIC:
- nDefaultFormat = CLOffset + ZF_STANDARD_SCIENTIFIC;
- break;
- default:
- nDefaultFormat = CLOffset + ZF_STANDARD;
+ if ( nDefaultFormat == NUMBERFORMAT_ENTRY_NOT_FOUND )
+ { // none found, use old fixed standards
+ switch( nType )
+ {
+ case NUMBERFORMAT_DATE :
+ nDefaultFormat = CLOffset + ZF_STANDARD_DATE;
+ break;
+ case NUMBERFORMAT_TIME :
+ nDefaultFormat = CLOffset + ZF_STANDARD_TIME+1;
+ break;
+ case NUMBERFORMAT_DATETIME :
+ nDefaultFormat = CLOffset + ZF_STANDARD_DATETIME;
+ break;
+ case NUMBERFORMAT_PERCENT :
+ nDefaultFormat = CLOffset + ZF_STANDARD_PERCENT+1;
+ break;
+ case NUMBERFORMAT_SCIENTIFIC:
+ nDefaultFormat = CLOffset + ZF_STANDARD_SCIENTIFIC;
+ break;
+ default:
+ nDefaultFormat = CLOffset + ZF_STANDARD;
+ }
}
+ aDefaultFormatKeys.Insert( nSearch, (void*) nDefaultFormat );
}
return nDefaultFormat;
}
@@ -2605,9 +2624,13 @@ ULONG SvNumberFormatter::ImpGetDefaultSystemCurrencyFormat()
ULONG SvNumberFormatter::ImpGetDefaultCurrencyFormat()
{
+ ULONG CLOffset = ImpGetCLOffset( ActLnge );
+ ULONG nDefaultCurrencyFormat =
+ (ULONG) aDefaultFormatKeys.Get( CLOffset + ZF_STANDARD_CURRENCY );
+ if ( !nDefaultCurrencyFormat )
+ nDefaultCurrencyFormat = NUMBERFORMAT_ENTRY_NOT_FOUND;
if ( nDefaultCurrencyFormat == NUMBERFORMAT_ENTRY_NOT_FOUND )
{
- ULONG CLOffset = ImpGetCLOffset( ActLnge );
// look for a defined standard
ULONG nStopKey = CLOffset + SV_COUNTRY_LANGUAGE_OFFSET;
ULONG nKey;
@@ -2652,6 +2675,8 @@ ULONG SvNumberFormatter::ImpGetDefaultCurrencyFormat()
pEntry->SetStandard();
}
}
+ aDefaultFormatKeys.Insert( CLOffset + ZF_STANDARD_CURRENCY,
+ (void*) nDefaultCurrencyFormat );
}
return nDefaultCurrencyFormat;
}