summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEike Rathke <erack@redhat.com>2022-08-08 20:52:25 +0200
committerEike Rathke <erack@redhat.com>2022-08-09 10:21:34 +0200
commit33c8c9d0dc8e76bc7dacb92175047a89f7d39a3c (patch)
tree1a51e2ef980ae8bac7f1def19dd8061a6c122acf
parent8f0e5308fac99f4c47fae98674f29a6a6a2948e5 (diff)
Use CharClass::uppercase() for AddIns' English UI names, tdf#135993 follow-up
... instead of OUString::toAsciiUpperCase(). English names should consist of ASCII alphanumeric only, but we don't know what an AddIn's author comes up with. Lookup in ScCompiler is done with CharClass as well. For this, use the static ScCompiler::GetCharClassEnglish() instance made public and guard creation with a mutex. Change-Id: Icb79d49d4c7339c8d01b141de2a34715d794dd92 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/138004 Reviewed-by: Eike Rathke <erack@redhat.com> Tested-by: Jenkins
-rw-r--r--sc/inc/compiler.hxx4
-rw-r--r--sc/source/core/tool/addincol.cxx7
-rw-r--r--sc/source/core/tool/compiler.cxx10
3 files changed, 14 insertions, 7 deletions
diff --git a/sc/inc/compiler.hxx b/sc/inc/compiler.hxx
index 0cd48fccc92e..5f6c521d11cf 100644
--- a/sc/inc/compiler.hxx
+++ b/sc/inc/compiler.hxx
@@ -257,6 +257,7 @@ public:
private:
+ static osl::Mutex maMutex;
static const CharClass *pCharClassEnglish; // character classification for en_US locale
static const CharClass *pCharClassLocalized; // character classification for UI locale
static const Convention *pConventions[ formula::FormulaGrammar::CONV_LAST ];
@@ -377,8 +378,9 @@ private:
bool HasPossibleNamedRangeConflict(SCTAB nTab) const;
- static const CharClass* GetCharClassEnglish();
static const CharClass* GetCharClassLocalized();
+public:
+ static const CharClass* GetCharClassEnglish();
public:
ScCompiler( sc::CompileFormulaContext& rCxt, const ScAddress& rPos,
diff --git a/sc/source/core/tool/addincol.cxx b/sc/source/core/tool/addincol.cxx
index cc444e808e9c..1ffb1e5bc1d7 100644
--- a/sc/source/core/tool/addincol.cxx
+++ b/sc/source/core/tool/addincol.cxx
@@ -60,6 +60,7 @@
#include <funcdesc.hxx>
#include <svl/sharedstring.hxx>
#include <formulaopt.hxx>
+#include <compiler.hxx>
#include <memory>
using namespace com::sun::star;
@@ -142,7 +143,7 @@ void ScUnoAddInFuncData::SetCompNames( ::std::vector< ScUnoAddInFuncData::Locali
void ScUnoAddInFuncData::SetEnglishName( const OUString& rEnglishName )
{
if (!rEnglishName.isEmpty())
- aUpperEnglish = rEnglishName.toAsciiUpperCase();
+ aUpperEnglish = ScCompiler::GetCharClassEnglish()->uppercase(rEnglishName);
else
{
// A dumb fallback to not have an empty name, mainly just for the
@@ -558,7 +559,7 @@ void ScUnoAddInCollection::ReadConfiguration()
else
{
pEnglishHashMap->emplace(
- aEnglishName.toAsciiUpperCase(),
+ ScCompiler::GetCharClassEnglish()->uppercase(aEnglishName),
pData );
}
pData->SetEnglishName(aEnglishName); // takes care of handling empty
@@ -950,7 +951,7 @@ void ScUnoAddInCollection::ReadFromAddIn( const uno::Reference<uno::XInterface>&
else
{
pEnglishHashMap->emplace(
- aEnglishName.toAsciiUpperCase(),
+ ScCompiler::GetCharClassEnglish()->uppercase(aEnglishName),
pData );
}
pData->SetEnglishName(aEnglishName); // takes care of handling empty
diff --git a/sc/source/core/tool/compiler.cxx b/sc/source/core/tool/compiler.cxx
index 2b1d70280926..d4ee9a19fd14 100644
--- a/sc/source/core/tool/compiler.cxx
+++ b/sc/source/core/tool/compiler.cxx
@@ -77,6 +77,7 @@ using namespace formula;
using namespace ::com::sun::star;
using ::std::vector;
+osl::Mutex ScCompiler::maMutex;
const CharClass* ScCompiler::pCharClassEnglish = nullptr;
const CharClass* ScCompiler::pCharClassLocalized = nullptr;
const ScCompiler::Convention* ScCompiler::pConventions[ ] = { nullptr, nullptr, nullptr, nullptr, nullptr, nullptr };
@@ -225,9 +226,12 @@ const CharClass* ScCompiler::GetCharClassEnglish()
{
if (!pCharClassEnglish)
{
- css::lang::Locale aLocale( "en", "US", "");
- pCharClassEnglish = new CharClass(
- ::comphelper::getProcessComponentContext(), LanguageTag( aLocale));
+ osl::MutexGuard aGuard(maMutex);
+ if (!pCharClassEnglish)
+ {
+ pCharClassEnglish = new CharClass( ::comphelper::getProcessComponentContext(),
+ LanguageTag( LANGUAGE_ENGLISH_US));
+ }
}
return pCharClassEnglish;
}