26#include <rtl/ustring.hxx>
28#include <com/sun/star/uno/Sequence.hxx>
30using ::com::sun::star::uno::Sequence;
38 LOCALE_MATCH_NONE = 0,
40 LOCALE_MATCH_LANG_SCRIPT,
41 LOCALE_MATCH_LANG_SCRIPT_COUNTRY,
49 LocaleMatch eMatchLevel = LOCALE_MATCH_NONE;
53 eMatchLevel = LOCALE_MATCH_LANG;
58 eMatchLevel = LOCALE_MATCH_LANG_SCRIPT;
63 eMatchLevel = LOCALE_MATCH_LANG_SCRIPT_COUNTRY;
67 if (aLanguageTag1 == rLanguageTag2)
68 return LOCALE_MATCH_ALL;
83 OpCode eOpCode,
const lang::Locale* pLocale)
85 ScCellKeywordHashMap::const_iterator itrEnd =
aMap.end();
86 ScCellKeywordHashMap::const_iterator itr =
aMap.find(rName);
88 if ( itr == itrEnd || itr->second.empty() )
96 rName = OUString::createFromAscii( itr->second.front().mpName );
101 const char* aBestMatchName = itr->second.front().mpName;
102 LocaleMatch eLocaleMatchLevel = LOCALE_MATCH_NONE;
103 bool bOpCodeMatched =
false;
105 for (
auto const& elem : itr->second)
109 if (elem.meOpCode == eOpCode)
112 if ( eLevel == LOCALE_MATCH_ALL )
115 rName = OUString::createFromAscii( elem.mpName );
118 else if ( eLevel > eLocaleMatchLevel )
121 eLocaleMatchLevel = eLevel;
122 aBestMatchName = elem.mpName;
124 else if ( !bOpCodeMatched )
126 aBestMatchName = elem.mpName;
128 bOpCodeMatched =
true;
133 if ( elem.meOpCode == eOpCode )
136 rName = OUString::createFromAscii( elem.mpName );
143 if ( eLevel == LOCALE_MATCH_ALL )
146 rName = OUString::createFromAscii( elem.mpName );
149 else if ( eLevel > eLocaleMatchLevel )
152 eLocaleMatchLevel = eLevel;
153 aBestMatchName = elem.mpName;
159 rName = OUString::createFromAscii(aBestMatchName);
169 Sequence<sal_Int32> aOffsets;
170 rName =
spInstance->maTransWrapper.transliterate(rName, nLang, 0, rName.getLength(), &aOffsets);
212 std::vector<ScCellKeyword> aVector { aKeyItem };
216 itr->second.push_back(aKeyItem);
221 for (sal_uInt16 i = 0; pItems[
i].
from !=
nullptr; ++
i)
222 addToMap(OUString(pItems[i].from), pItems[i].
to, rLocale, pItems[i].func);
static LocaleMatch lclLocaleCompare(const lang::Locale &rLocale1, const LanguageTag &rLanguageTag2)
static void lclMatchKeyword(OUString &rName, const ScCellKeywordHashMap &aMap, OpCode eOpCode, const lang::Locale *pLocale)
std::unordered_map< OUString, ::std::vector< ScCellKeyword > > ScCellKeywordHashMap
LanguageType getLanguageType(bool bResolveSystem=true) const
OUString getLanguage() const
OUString getScript() const
LanguageTag & makeFallback()
OUString getCountry() const
Translate cell function keywords.
void addToMap(const OUString &rKey, const char *pName, const css::lang::Locale &rLocale, OpCode eOpCode)
static void transKeyword(OUString &rName, const css::lang::Locale *pLocale, OpCode eOpCode)
static ::std::unique_ptr< ScCellKeywordTranslator > spInstance
ScCellKeywordTranslator()
~ScCellKeywordTranslator()
ScCellKeywordHashMap maStringNameMap
static std::optional< SvtSysLocale > oSysLocale
Reference< XComponentContext > getProcessComponentContext()
HashMap_OWString_Interface aMap
ScCellKeyword(const char *pName, OpCode eOpCode, const css::lang::Locale &rLocale)