Kaydet (Commit) 7d242f3b authored tarafından Eike Rathke's avatar Eike Rathke

Bin more binfilter cruft

As the requirement for persistent keyword index values is gone,
let's rearrange the keywords to a more logical and also gapless
order, which allows to get rid of the cumbersome multiple loops in
ImpSvNumberformatScan::GetKeyWord().

Change-Id: Ic1a034acc5f42f593b147a1baf377f1600fac118
Reviewed-on: https://gerrit.libreoffice.org/60692Reviewed-by: 's avatarEike Rathke <erack@redhat.com>
Tested-by: 's avatarEike Rathke <erack@redhat.com>
üst 28b4f4ae
...@@ -24,9 +24,8 @@ ...@@ -24,9 +24,8 @@
#include <rtl/ustring.hxx> #include <rtl/ustring.hxx>
//! For ImpSvNumberformatScan: first the short symbols, then the long symbols! //! For ImpSvNumberformatScan: first the short symbols, then the long symbols!
//! e.g. first TT then TTTT //! e.g. first YY then YYYY
//! The internal order is essential for the format code string scanner. //! The internal order is essential for the format code string scanner.
//! New keywords MUST NOT be inserted.
// //
// This table is externally only to be used with method // This table is externally only to be used with method
// OUString SvNumberformat::GetMappedFormatstring( const NfKeywordTable&, const LocaleDataWrapper& ); // OUString SvNumberformat::GetMappedFormatstring( const NfKeywordTable&, const LocaleDataWrapper& );
...@@ -44,6 +43,7 @@ enum NfKeywordIndex ...@@ -44,6 +43,7 @@ enum NfKeywordIndex
NF_KEY_MM, // month 02 (!) NF_KEY_MM, // month 02 (!)
NF_KEY_MMM, // month short name NF_KEY_MMM, // month short name
NF_KEY_MMMM, // month long name NF_KEY_MMMM, // month long name
NF_KEY_MMMMM, // month narrow name, first letter
NF_KEY_H, // hour NF_KEY_H, // hour
NF_KEY_HH, // hour 02 NF_KEY_HH, // hour 02
NF_KEY_S, // second NF_KEY_S, // second
...@@ -57,14 +57,24 @@ enum NfKeywordIndex ...@@ -57,14 +57,24 @@ enum NfKeywordIndex
NF_KEY_YY, // year two digits NF_KEY_YY, // year two digits
NF_KEY_YYYY, // year four digits NF_KEY_YYYY, // year four digits
NF_KEY_NN, // day of week short NF_KEY_NN, // day of week short
NF_KEY_NNN, // day of week long without separator, as of version 6, 10.10.97
NF_KEY_NNNN, // day of week long with separator NF_KEY_NNNN, // day of week long with separator
NF_KEY_AAA, // abbreviated day name from Japanese Xcl, same as DDD or NN English
NF_KEY_AAAA, // full day name from Japanese Xcl, same as DDDD or NNN English
NF_KEY_EC, // E non-gregorian calendar year without preceding 0
NF_KEY_EEC, // EE non-gregorian calendar year with preceding 0 (two digit)
NF_KEY_G, // abbreviated era name, latin characters M T S or H for Gengou calendar
NF_KEY_GG, // abbreviated era name
NF_KEY_GGG, // full era name
NF_KEY_R, // acts as EE (Xcl) => GR==GEE, GGR==GGEE, GGGR==GGGEE
NF_KEY_RR, // acts as GGGEE (Xcl)
NF_KEY_WW, // week of year, as of version 8, 19.06.98
NF_KEY_THAI_T, // Thai T modifier, speciality of Thai Excel, only used with Thai locale and converted to [NatNum1]
NF_KEY_CCC, // currency bank symbol (old version) NF_KEY_CCC, // currency bank symbol (old version)
NF_KEY_GENERAL, // General / Standard NF_KEY_GENERAL, // General / Standard
NF_KEY_LASTOLDKEYWORD = NF_KEY_GENERAL, NF_KEY_LASTKEYWORD = NF_KEY_GENERAL,
NF_KEY_NNN, // day of week long without separator, as of version 6, 10.10.97
NF_KEY_WW, // week of year, as of version 8, 19.06.98 // Reserved words translated and color names follow:
NF_KEY_MMMMM, // first letter of month name
NF_KEY_LASTKEYWORD = NF_KEY_MMMMM,
NF_KEY_TRUE, // boolean true NF_KEY_TRUE, // boolean true
NF_KEY_FALSE, // boolean false NF_KEY_FALSE, // boolean false
NF_KEY_BOOLEAN, // boolean NF_KEY_BOOLEAN, // boolean
...@@ -81,19 +91,7 @@ enum NfKeywordIndex ...@@ -81,19 +91,7 @@ enum NfKeywordIndex
NF_KEY_YELLOW, NF_KEY_YELLOW,
NF_KEY_WHITE, NF_KEY_WHITE,
NF_KEY_LASTCOLOR = NF_KEY_WHITE, NF_KEY_LASTCOLOR = NF_KEY_WHITE,
NF_KEY_LASTKEYWORD_SO5 = NF_KEY_LASTCOLOR,
//! Keys from here on can't be saved in SO5 file format and MUST be
//! converted to string which means losing any information.
NF_KEY_AAA, // abbreviated day name from Japanese Xcl, same as DDD or NN English
NF_KEY_AAAA, // full day name from Japanese Xcl, same as DDDD or NNN English
NF_KEY_EC, // E non-gregorian calendar year without preceding 0
NF_KEY_EEC, // EE non-gregorian calendar year with preceding 0 (two digit)
NF_KEY_G, // abbreviated era name, latin characters M T S or H for Gengou calendar
NF_KEY_GG, // abbreviated era name
NF_KEY_GGG, // full era name
NF_KEY_R, // acts as EE (Xcl) => GR==GEE, GGR==GGEE, GGGR==GGGEE
NF_KEY_RR, // acts as GGGEE (Xcl)
NF_KEY_THAI_T, // Thai T modifier, speciality of Thai Excel, only used with Thai locale and converted to [NatNum1]
NF_KEYWORD_ENTRIES_COUNT NF_KEYWORD_ENTRIES_COUNT
}; };
......
...@@ -54,6 +54,7 @@ const NfKeywordTable ImpSvNumberformatScan::sEnglishKeyword = ...@@ -54,6 +54,7 @@ const NfKeywordTable ImpSvNumberformatScan::sEnglishKeyword =
"MM", // NF_KEY_MM month 02 (!) "MM", // NF_KEY_MM month 02 (!)
"MMM", // NF_KEY_MMM month short name "MMM", // NF_KEY_MMM month short name
"MMMM", // NF_KEY_MMMM month long name "MMMM", // NF_KEY_MMMM month long name
"MMMMM", // NF_KEY_MMMMM first letter of month name
"H", // NF_KEY_H hour "H", // NF_KEY_H hour
"HH", // NF_KEY_HH hour 02 "HH", // NF_KEY_HH hour 02
"S", // NF_KEY_S Second "S", // NF_KEY_S Second
...@@ -67,12 +68,25 @@ const NfKeywordTable ImpSvNumberformatScan::sEnglishKeyword = ...@@ -67,12 +68,25 @@ const NfKeywordTable ImpSvNumberformatScan::sEnglishKeyword =
"YY", // NF_KEY_YY year two digits "YY", // NF_KEY_YY year two digits
"YYYY", // NF_KEY_YYYY year four digits "YYYY", // NF_KEY_YYYY year four digits
"NN", // NF_KEY_NN Day of week short "NN", // NF_KEY_NN Day of week short
"NNN", // NF_KEY_NNN Day of week long
"NNNN", // NF_KEY_NNNN Day of week long incl. separator "NNNN", // NF_KEY_NNNN Day of week long incl. separator
"AAA", // NF_KEY_AAA
"AAAA", // NF_KEY_AAAA
"E", // NF_KEY_EC
"EE", // NF_KEY_EEC
"G", // NF_KEY_G
"GG", // NF_KEY_GG
"GGG", // NF_KEY_GGG
"R", // NF_KEY_R
"RR", // NF_KEY_RR
"WW", // NF_KEY_WW Week of year
"t", // NF_KEY_THAI_T Thai T modifier, speciality of Thai Excel, only
// used with Thai locale and converted to [NatNum1], only
// exception as lowercase
"CCC", // NF_KEY_CCC Currency abbreviation "CCC", // NF_KEY_CCC Currency abbreviation
"GENERAL", // NF_KEY_GENERAL General / Standard "GENERAL", // NF_KEY_GENERAL General / Standard
"NNN", // NF_KEY_NNN Day of week long
"WW", // NF_KEY_WW Week of year // Reserved words translated and color names follow:
"MMMMM", // NF_KEY_MMMMM first letter of month name
"TRUE", // NF_KEY_TRUE boolean true "TRUE", // NF_KEY_TRUE boolean true
"FALSE", // NF_KEY_FALSE boolean false "FALSE", // NF_KEY_FALSE boolean false
"BOOLEAN", // NF_KEY_BOOLEAN boolean "BOOLEAN", // NF_KEY_BOOLEAN boolean
...@@ -87,19 +101,8 @@ const NfKeywordTable ImpSvNumberformatScan::sEnglishKeyword = ...@@ -87,19 +101,8 @@ const NfKeywordTable ImpSvNumberformatScan::sEnglishKeyword =
"BROWN", // NF_KEY_BROWN "BROWN", // NF_KEY_BROWN
"GREY", // NF_KEY_GREY "GREY", // NF_KEY_GREY
"YELLOW", // NF_KEY_YELLOW "YELLOW", // NF_KEY_YELLOW
"WHITE", // NF_KEY_WHITE "WHITE" // NF_KEY_WHITE
// preset new calendar keywords };
"AAA", // NF_KEY_AAA
"AAAA", // NF_KEY_AAAA
"E", // NF_KEY_EC
"EE", // NF_KEY_EEC
"G", // NF_KEY_G
"GG", // NF_KEY_GG
"GGG", // NF_KEY_GGG
"R", // NF_KEY_R
"RR", // NF_KEY_RR
"t" // NF_KEY_THAI_T Thai T modifier, speciality of Thai Excel, only used with Thai locale and converted to [NatNum1]
}; // only exception as lowercase
::std::vector<Color> ImpSvNumberformatScan::StandardColor; ::std::vector<Color> ImpSvNumberformatScan::StandardColor;
bool ImpSvNumberformatScan::bStandardColorNeedInitialization = true; bool ImpSvNumberformatScan::bStandardColorNeedInitialization = true;
...@@ -680,67 +683,26 @@ short ImpSvNumberformatScan::GetKeyWord( const OUString& sSymbol, sal_Int32 nPos ...@@ -680,67 +683,26 @@ short ImpSvNumberformatScan::GetKeyWord( const OUString& sSymbol, sal_Int32 nPos
rbFoundEnglish = true; rbFoundEnglish = true;
return NF_KEY_GENERAL; return NF_KEY_GENERAL;
} }
//! MUST be a reverse search to find longer strings first
short i = NF_KEYWORD_ENTRIES_COUNT-1; // MUST be a reverse search to find longer strings first,
bool bFound = false; // new keywords take precedence over old keywords,
for ( ; i > NF_KEY_LASTKEYWORD_SO5; --i ) // skip colors et al after keywords.
{ short i = NF_KEY_LASTKEYWORD;
bFound = sString.startsWith(rKeyword[i]); while (i > 0 && !sString.startsWith( rKeyword[i]))
if ( bFound )
{
break;
}
}
// new keywords take precedence over old keywords
if ( !bFound )
{
// skip the gap of colors et al between new and old keywords and search on
i = NF_KEY_LASTKEYWORD;
while ( i > 0 && !sString.startsWith( rKeyword[i]) )
{ {
i--; i--;
} }
if ( i > NF_KEY_LASTOLDKEYWORD && sString != rKeyword[i] )
{
// found something, but maybe it's something else?
// e.g. new NNN is found in NNNN, for NNNN we must search on
short j = i - 1;
while ( j > 0 && !sString.startsWith( rKeyword[j]) )
{
j--;
}
if ( j && rKeyword[j].getLength() > rKeyword[i].getLength() )
{
return j;
}
}
if (i == 0 && meKeywordLocalization == KeywordLocalization::AllowEnglish) if (i == 0 && meKeywordLocalization == KeywordLocalization::AllowEnglish)
{ {
// No localized (if so) keyword, try English keywords if keywords // No localized (if so) keyword, try English keywords if keywords
// are localized. That was already checked in // are localized. That was already checked in SetDependentKeywords().
// SetDependentKeywords().
i = NF_KEY_LASTKEYWORD; i = NF_KEY_LASTKEYWORD;
while ( i > 0 && !sString.startsWith( sEnglishKeyword[i]) ) while (i > 0 && !sString.startsWith( sEnglishKeyword[i]))
{ {
i--; i--;
} }
if ( i > NF_KEY_LASTOLDKEYWORD && sString != sEnglishKeyword[i] )
{
// found something, but maybe it's something else?
// e.g. new NNN is found in NNNN, for NNNN we must search on
short j = i - 1;
while ( j > 0 && !sString.startsWith( sEnglishKeyword[j]) )
{
j--;
}
if ( j && sEnglishKeyword[j].getLength() > sEnglishKeyword[i].getLength() )
{
rbFoundEnglish = true;
return j;
}
}
}
} }
// The Thai T NatNum modifier during Xcl import. // The Thai T NatNum modifier during Xcl import.
if (i == 0 && bConvertMode && if (i == 0 && bConvertMode &&
sString[0] == 'T' && sString[0] == 'T' &&
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment