include/svl/nfkeytab.hxx | 38 +++++++-------- svl/source/numbers/zforscan.cxx | 100 ++++++++++++---------------------------- 2 files changed, 49 insertions(+), 89 deletions(-)
New commits: commit 7d242f3bd7277236046f90d3f32b9792fd8ea97b Author: Eike Rathke <er...@redhat.com> AuthorDate: Tue Sep 18 17:31:25 2018 +0200 Commit: Eike Rathke <er...@redhat.com> CommitDate: Wed Sep 19 01:04:21 2018 +0200 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/60692 Reviewed-by: Eike Rathke <er...@redhat.com> Tested-by: Eike Rathke <er...@redhat.com> diff --git a/include/svl/nfkeytab.hxx b/include/svl/nfkeytab.hxx index 16dea80e99e2..fe1e3bb69ec5 100644 --- a/include/svl/nfkeytab.hxx +++ b/include/svl/nfkeytab.hxx @@ -24,9 +24,8 @@ #include <rtl/ustring.hxx> //! 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. -//! New keywords MUST NOT be inserted. // // This table is externally only to be used with method // OUString SvNumberformat::GetMappedFormatstring( const NfKeywordTable&, const LocaleDataWrapper& ); @@ -44,6 +43,7 @@ enum NfKeywordIndex NF_KEY_MM, // month 02 (!) NF_KEY_MMM, // month short name NF_KEY_MMMM, // month long name + NF_KEY_MMMMM, // month narrow name, first letter NF_KEY_H, // hour NF_KEY_HH, // hour 02 NF_KEY_S, // second @@ -57,14 +57,24 @@ enum NfKeywordIndex NF_KEY_YY, // year two digits NF_KEY_YYYY, // year four digits 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_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_GENERAL, // General / Standard - NF_KEY_LASTOLDKEYWORD = 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 - NF_KEY_MMMMM, // first letter of month name - NF_KEY_LASTKEYWORD = NF_KEY_MMMMM, + NF_KEY_LASTKEYWORD = NF_KEY_GENERAL, + + // Reserved words translated and color names follow: NF_KEY_TRUE, // boolean true NF_KEY_FALSE, // boolean false NF_KEY_BOOLEAN, // boolean @@ -81,19 +91,7 @@ enum NfKeywordIndex NF_KEY_YELLOW, 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 }; diff --git a/svl/source/numbers/zforscan.cxx b/svl/source/numbers/zforscan.cxx index 266937f8ec4c..104727c942b8 100644 --- a/svl/source/numbers/zforscan.cxx +++ b/svl/source/numbers/zforscan.cxx @@ -54,6 +54,7 @@ const NfKeywordTable ImpSvNumberformatScan::sEnglishKeyword = "MM", // NF_KEY_MM month 02 (!) "MMM", // NF_KEY_MMM month short name "MMMM", // NF_KEY_MMMM month long name + "MMMMM", // NF_KEY_MMMMM first letter of month name "H", // NF_KEY_H hour "HH", // NF_KEY_HH hour 02 "S", // NF_KEY_S Second @@ -67,12 +68,25 @@ const NfKeywordTable ImpSvNumberformatScan::sEnglishKeyword = "YY", // NF_KEY_YY year two digits "YYYY", // NF_KEY_YYYY year four digits "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 + "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 "GENERAL", // NF_KEY_GENERAL General / Standard - "NNN", // NF_KEY_NNN Day of week long - "WW", // NF_KEY_WW Week of year - "MMMMM", // NF_KEY_MMMMM first letter of month name + + // Reserved words translated and color names follow: "TRUE", // NF_KEY_TRUE boolean true "FALSE", // NF_KEY_FALSE boolean false "BOOLEAN", // NF_KEY_BOOLEAN boolean @@ -87,19 +101,8 @@ const NfKeywordTable ImpSvNumberformatScan::sEnglishKeyword = "BROWN", // NF_KEY_BROWN "GREY", // NF_KEY_GREY "YELLOW", // NF_KEY_YELLOW - "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 + "WHITE" // NF_KEY_WHITE +}; ::std::vector<Color> ImpSvNumberformatScan::StandardColor; bool ImpSvNumberformatScan::bStandardColorNeedInitialization = true; @@ -680,67 +683,26 @@ short ImpSvNumberformatScan::GetKeyWord( const OUString& sSymbol, sal_Int32 nPos rbFoundEnglish = true; return NF_KEY_GENERAL; } - //! MUST be a reverse search to find longer strings first - short i = NF_KEYWORD_ENTRIES_COUNT-1; - bool bFound = false; - for ( ; i > NF_KEY_LASTKEYWORD_SO5; --i ) + + // MUST be a reverse search to find longer strings first, + // new keywords take precedence over old keywords, + // skip colors et al after keywords. + short i = NF_KEY_LASTKEYWORD; + while (i > 0 && !sString.startsWith( rKeyword[i])) { - bFound = sString.startsWith(rKeyword[i]); - if ( bFound ) - { - break; - } + i--; } - // new keywords take precedence over old keywords - if ( !bFound ) + if (i == 0 && meKeywordLocalization == KeywordLocalization::AllowEnglish) { - // skip the gap of colors et al between new and old keywords and search on + // No localized (if so) keyword, try English keywords if keywords + // are localized. That was already checked in SetDependentKeywords(). i = NF_KEY_LASTKEYWORD; - while ( i > 0 && !sString.startsWith( rKeyword[i]) ) + while (i > 0 && !sString.startsWith( sEnglishKeyword[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) - { - // No localized (if so) keyword, try English keywords if keywords - // are localized. That was already checked in - // SetDependentKeywords(). - i = NF_KEY_LASTKEYWORD; - while ( i > 0 && !sString.startsWith( sEnglishKeyword[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. if (i == 0 && bConvertMode && sString[0] == 'T' && _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits