thread-safe ScGlobal::GetUnitConverter()

Triggered by sc/qa/unit/data/functions/mathematical/fods/convert_ooo.fods
with SC_FORCE_CALCULATION=threads.

Change-Id: Ibedb32ee03519911650a0deee67011efeda57c93
Reviewed-on: https://gerrit.libreoffice.org/63175
Tested-by: Jenkins
Reviewed-by: Luboš Luňák <l.lunak@collabora.com>
(cherry picked from commit 9553f2afd0527ba435dae7bf4506c620a943b150)
Reviewed-on: https://gerrit.libreoffice.org/63376
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
diff --git a/sc/inc/global.hxx b/sc/inc/global.hxx
index b9ef661..b888b52 100644
--- a/sc/inc/global.hxx
+++ b/sc/inc/global.hxx
@@ -519,7 +519,7 @@ class ScGlobal
    static ScFunctionList*  pStarCalcFunctionList;
    static ScFunctionMgr*   pStarCalcFunctionMgr;

    static ScUnitConverter* pUnitConverter;
    static std::atomic<ScUnitConverter*> pUnitConverter;

    static  SvNumberFormatter*  pEnglishFormatter;          // for UNO / XML export

diff --git a/sc/source/core/data/global.cxx b/sc/source/core/data/global.cxx
index f381973..cb5a13c 100644
--- a/sc/source/core/data/global.cxx
+++ b/sc/source/core/data/global.cxx
@@ -109,7 +109,7 @@ SvxBrushItem*   ScGlobal::pEmbeddedBrushItem = nullptr;
ScFunctionList* ScGlobal::pStarCalcFunctionList = nullptr;
ScFunctionMgr*  ScGlobal::pStarCalcFunctionMgr  = nullptr;

ScUnitConverter* ScGlobal::pUnitConverter = nullptr;
std::atomic<ScUnitConverter*> ScGlobal::pUnitConverter(nullptr);
SvNumberFormatter* ScGlobal::pEnglishFormatter = nullptr;
ScFieldEditEngine* ScGlobal::pFieldEditEngine = nullptr;

@@ -586,7 +586,7 @@ void ScGlobal::Clear()
    delete pLocale.load(); pLocale = nullptr;
    DELETEZ(pStrClipDocName);

    DELETEZ(pUnitConverter);
    delete pUnitConverter.load(); pUnitConverter = nullptr;
    DELETEZ(pFieldEditEngine);

    DELETEZ(pEmptyOUString);
@@ -676,11 +676,8 @@ void ScGlobal::ResetFunctionList()

ScUnitConverter* ScGlobal::GetUnitConverter()
{
    assert(!bThreadedGroupCalcInProgress);
    if ( !pUnitConverter )
        pUnitConverter = new ScUnitConverter;

    return pUnitConverter;
    return comphelper::doubleCheckedInit( pUnitConverter,
        []() { return new ScUnitConverter; });
}

const sal_Unicode* ScGlobal::UnicodeStrChr( const sal_Unicode* pStr,