cache FormulaError::NoRef error string (tdf#144249)

Those COUNTIF() may call it a huge number of times, and the translation
of the string each time then actually is a noticeable impact. And
ScGlobal already does one-time intialization of objects based
on the locale, so one-time initializing a string there should be fine
too.

Change-Id: I0daeb50ccb43f780d99cf3838cfd1bf790c5f6cc
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/121856
Tested-by: Jenkins
Reviewed-by: Luboš Luňák <l.lunak@collabora.com>
(cherry picked from commit b4c1bb2f91e9ae47820c289e2c08f640a958cf05)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/121984
Reviewed-by: Adolfo Jayme Barrientos <fitojb@ubuntu.com>
diff --git a/sc/inc/global.hxx b/sc/inc/global.hxx
index 50041b3..d66801a 100644
--- a/sc/inc/global.hxx
+++ b/sc/inc/global.hxx
@@ -509,6 +509,7 @@
    static std::unique_ptr<ScUserList> xUserList;
    static SC_DLLPUBLIC const OUString aEmptyOUString;
    static OUString         aStrClipDocName;
    static OUString         aStrErrorStringNoRef;
    static std::unique_ptr<SvxBrushItem> xEmptyBrushItem;
    static std::unique_ptr<SvxBrushItem> xButtonBrushItem;

diff --git a/sc/source/core/data/global.cxx b/sc/source/core/data/global.cxx
index 55415f1f..8295b80 100644
--- a/sc/source/core/data/global.cxx
+++ b/sc/source/core/data/global.cxx
@@ -88,6 +88,7 @@
css::uno::Reference< css::i18n::XOrdinalSuffix> ScGlobal::xOrdinalSuffix;
const OUString  ScGlobal::aEmptyOUString;
OUString        ScGlobal::aStrClipDocName;
OUString        ScGlobal::aStrErrorStringNoRef;

std::unique_ptr<SvxBrushItem> ScGlobal::xEmptyBrushItem;
std::unique_ptr<SvxBrushItem> ScGlobal::xButtonBrushItem;
@@ -304,8 +305,8 @@
    switch (nErr)
    {
        case FormulaError::NoRef:
            pErrNumber = STR_NO_REF_TABLE;
            break;
            // tdf#144249 This may get called very extensively, so cached.
            return aStrErrorStringNoRef;
        case FormulaError::NoAddin:
            pErrNumber = STR_NO_ADDIN;
            break;
@@ -451,6 +452,7 @@
    InitAddIns();

    aStrClipDocName = ScResId( SCSTR_NONAME ) + "1";
    aStrErrorStringNoRef = ScResId( STR_NO_REF_TABLE );

    //  ScDocumentPool::InitVersionMaps() has been called earlier already
}