sc/inc/compiler.hxx              |    4 +++-
 sc/source/core/tool/addincol.cxx |    7 ++++---
 sc/source/core/tool/compiler.cxx |   10 +++++++---
 3 files changed, 14 insertions(+), 7 deletions(-)

New commits:
commit 33c8c9d0dc8e76bc7dacb92175047a89f7d39a3c
Author:     Eike Rathke <er...@redhat.com>
AuthorDate: Mon Aug 8 20:52:25 2022 +0200
Commit:     Eike Rathke <er...@redhat.com>
CommitDate: Tue Aug 9 10:21:34 2022 +0200

    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 <er...@redhat.com>
    Tested-by: Jenkins

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;
 }

Reply via email to