include/svl/nfengine.hxx            |  432 +++++++
 include/svl/numformat.hxx           |  151 --
 include/svl/zformat.hxx             |   81 -
 sc/source/ui/view/output2.cxx       |    4 
 sc/source/ui/view/viewfunc.cxx      |    2 
 svl/source/numbers/zforfind.cxx     |  115 +-
 svl/source/numbers/zforfind.hxx     |    7 
 svl/source/numbers/zforlist.cxx     | 1971 ++++++++++++++++++++++--------------
 svl/source/numbers/zformat.cxx      |  267 ++--
 svl/source/numbers/zforscan.cxx     |   91 -
 svl/source/numbers/zforscan.hxx     |   20 
 sw/source/uibase/utlui/numfmtlb.cxx |    2 
 xmloff/source/style/xmlnumfe.cxx    |    2 
 13 files changed, 2018 insertions(+), 1127 deletions(-)

New commits:
commit c6c6126aa3e8de256091b829b98b5943db6a8be6
Author:     Caolán McNamara <caolan.mcnam...@collabora.com>
AuthorDate: Thu Mar 21 17:25:35 2024 +0000
Commit:     Caolán McNamara <caolan.mcnam...@collabora.com>
CommitDate: Fri Mar 22 21:50:59 2024 +0100

    Related: tdf#160056 refactor SvNumberFormatter
    
    to split it into two constituent parts
    
    SvNFFormatData which is the data store for number formats it generally
    operates on.
    
    SvNFLanguageData for data around the current language in use.
    
    and then a SvNFEngine which implements the interaction between those
    parts
    
    SvNFEngine has two policies, the typical RW mode and a new RO mode where
    the SvNFFormatData doesn't change, all formats needed in this mode must
    already exist.
    
    Change-Id: I56b070ccd2e556a0cb1fe609a2fae28e18277c8c
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/165146
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <caolan.mcnam...@collabora.com>

diff --git a/include/svl/nfengine.hxx b/include/svl/nfengine.hxx
new file mode 100644
index 000000000000..aa57d731fbac
--- /dev/null
+++ b/include/svl/nfengine.hxx
@@ -0,0 +1,432 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ *   Licensed to the Apache Software Foundation (ASF) under one or more
+ *   contributor license agreements. See the NOTICE file distributed
+ *   with this work for additional information regarding copyright
+ *   ownership. The ASF licenses this file to you under the Apache
+ *   License, Version 2.0 (the "License"); you may not use this file
+ *   except in compliance with the License. You may obtain a copy of
+ *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+#pragma once
+
+#include <svl/svldllapi.h>
+#include <com/sun/star/i18n/XNumberFormatCode.hpp>
+#include <com/sun/star/uno/XComponentContext.hpp>
+#include <i18nlangtag/lang.h>
+#include <tools/link.hxx>
+#include <svl/nfkeytab.hxx>
+#include <svl/ondemand.hxx>
+#include <svl/zforlist.hxx>
+#include <unotools/charclass.hxx>
+
+#include <functional>
+#include <map>
+
+class Color;
+class ImpSvNumberformatScan;
+class ImpSvNumberInputScan;
+class SvNumberFormatterRegistry_Impl;
+class SvNumberFormatter;
+class NfCurrencyTable;
+
+class SVL_DLLPUBLIC SvNFLanguageData
+{
+public:
+    SvNFLanguageData(const css::uno::Reference<css::uno::XComponentContext>& 
rxContext,
+                     LanguageType eLang, const SvNumberFormatter& 
rColorCallback);
+    SvNFLanguageData(const SvNFLanguageData& rOther);
+    ~SvNFLanguageData();
+
+    const css::uno::Reference<css::uno::XComponentContext>& 
GetComponentContext() const
+    {
+        return xContext;
+    }
+
+    // return the corresponding LocaleData wrapper
+    const LocaleDataWrapper* GetLocaleData() const;
+
+    // return the corresponding CharacterClassification wrapper
+    const CharClass* GetCharClass() const;
+
+    // return the corresponding Calendar wrapper
+    CalendarWrapper* GetCalendar() const;
+
+    // return corresponding Transliteration wrapper
+    const ::utl::TransliterationWrapper* GetTransliteration() const;
+
+    //! The following method is not to be used from outside but must be
+    //! public for the InputScanner.
+    // return the current FormatScanner
+    const ImpSvNumberformatScan* GetFormatScanner() const;
+
+    // return current (!) Locale
+    const LanguageTag& GetLanguageTag() const;
+
+    /// Get compatibility ("automatic" old style) currency from I18N locale 
data
+    void GetCompatibilityCurrency(OUString& rSymbol, OUString& rAbbrev) const;
+
+    // cached locale data items
+
+    // return the corresponding decimal separator
+    const OUString& GetNumDecimalSep() const;
+
+    // return the corresponding decimal separator alternative
+    const OUString& GetNumDecimalSepAlt() const;
+
+    // return the corresponding group (AKA thousand) separator
+    const OUString& GetNumThousandSep() const;
+
+    // return the corresponding date separator
+    const OUString& GetDateSep() const;
+
+    // checks for decimal separator and optional alternative
+    bool IsDecimalSep(std::u16string_view rStr) const;
+
+    /// Return the decimal separator matching the given locale / LanguageType.
+    OUString GetLangDecimalSep(LanguageType nLang) const;
+
+    /// Change language/country, also input and format scanner
+    void ChangeIntl(LanguageType eLnge);
+
+    /** Set evaluation type and order of input date strings
+        @see NfEvalDateFormat
+     */
+    void SetEvalDateFormat(NfEvalDateFormat eEDF) { eEvalDateFormat = eEDF; }
+    NfEvalDateFormat GetEvalDateFormat() const { return eEvalDateFormat; }
+
+    struct InputScannerPrivateAccess
+    {
+        friend class ImpSvNumberInputScan;
+
+    private:
+        InputScannerPrivateAccess() {}
+    };
+    /** Access for input scanner to temporarily (!) switch locales. */
+    OnDemandLocaleDataWrapper& GetOnDemandLocaleDataWrapper(const 
InputScannerPrivateAccess&)
+    {
+        return xLocaleData;
+    }
+
+    /** The language with which the formatter was initialized (system setting),
+        NOT the current language after a ChangeIntl() */
+    LanguageType GetIniLanguage() const { return IniLnge; }
+
+    LanguageType ImpResolveLanguage(LanguageType eLnge) const;
+
+    /// Return the reference date
+    const Date& GetNullDate() const;
+
+    sal_uInt16 GetCurrencyFormatStrings(NfWSStringsDtor&, const 
NfCurrencyEntry&, bool bBank) const;
+
+    void ChangeStandardPrec(short nPrec);
+
+    sal_uInt16 ExpandTwoDigitYear(sal_uInt16 nYear) const;
+
+private:
+    friend class SvNFEngine;
+    friend class SvNFFormatData;
+    friend class SvNumberFormatter;
+
+    css::uno::Reference<css::uno::XComponentContext> xContext;
+
+    const LanguageType IniLnge; // Initial language/country setting
+    LanguageType ActLnge; // Current language/country setting
+    LanguageTag aLanguageTag;
+    OnDemandCharClass xCharClass; // CharacterClassification
+    OnDemandLocaleDataWrapper xLocaleData; // LocaleData switched between 
SYSTEM, ENGLISH and other
+    OnDemandTransliterationWrapper xTransliteration; // Transliteration loaded 
on demand
+    OnDemandCalendarWrapper xCalendar; // Calendar loaded on demand
+    std::unique_ptr<ImpSvNumberInputScan> pStringScanner; // Input string 
scanner
+    std::unique_ptr<ImpSvNumberformatScan> pFormatScanner; // Format code 
string scanner
+
+    // cached locale data items needed almost every time
+    OUString aDecimalSep;
+    OUString aDecimalSepAlt;
+    OUString aThousandSep;
+    OUString aDateSep;
+
+    NfEvalDateFormat eEvalDateFormat; // DateFormat evaluation
+};
+
+class SVL_DLLPUBLIC SvNFFormatData
+{
+private:
+    typedef std::map<sal_uInt32, std::unique_ptr<SvNumberformat>> 
FormatEntryMap;
+    FormatEntryMap aFTable; // Table of format keys to format entries
+    typedef std::map<sal_uInt32, sal_uInt32> DefaultFormatKeysMap;
+    DefaultFormatKeysMap aDefaultFormatKeys; // Table of default standard to 
format keys
+    sal_uInt32 MaxCLOffset; // Max language/country offset used
+    sal_uInt32 nDefaultSystemCurrencyFormat; // NewCurrency matching SYSTEM 
locale
+    bool bNoZero; // Zero value suppression
+
+public:
+    SvNFFormatData();
+    ~SvNFFormatData();
+
+public:
+    const SvNumberformat* GetFormatEntry(sal_uInt32 nKey) const;
+
+    SvNumFormatType GetType(sal_uInt32 nFIndex) const;
+
+    /// Whether format index nFIndex is of type text or not
+    bool IsTextFormat(sal_uInt32 nFIndex) const;
+
+    OUString GetCalcCellReturn(sal_uInt32 nFormat) const;
+
+    /** Whether nFormat is of type css::util::NumberFormat::CURRENCY and the 
format code
+        contains a new SYMBOLTYPE_CURRENCY and if so which one [$xxx-nnn].
+        If ppEntry is not NULL and exactly one entry is found, a [$xxx-nnn] is
+        returned, even if the format code only contains [$xxx] !
+     */
+    bool GetNewCurrencySymbolString(sal_uInt32 nFormat, OUString& rSymbol,
+                                    const NfCurrencyEntry** ppEntry, bool* 
pBank = nullptr) const;
+
+private:
+    SvNFFormatData(const SvNFFormatData&) = delete;
+    SvNFFormatData& operator=(const SvNFFormatData&) = delete;
+
+    friend class SvNFEngine;
+    friend class SvNumberFormatter;
+
+    SVL_DLLPRIVATE sal_uInt32 GetStandardFormat(SvNFLanguageData& 
rCurrentLanguage,
+                                                const NativeNumberWrapper* 
pNatNum,
+                                                SvNumFormatType eType, 
LanguageType eLnge);
+
+    // Obtain the format entry for a given key index.
+    SVL_DLLPRIVATE SvNumberformat* GetFormatEntry(sal_uInt32 nKey);
+
+    SVL_DLLPRIVATE SvNumberformat* GetEntry(sal_uInt32 nKey) const;
+
+    /// Return whether zero suppression is switched on
+    SVL_DLLPRIVATE bool GetNoZero() const { return bNoZero; }
+    SVL_DLLPRIVATE void SetNoZero(bool bNZ) { bNoZero = bNZ; }
+
+    SVL_DLLPRIVATE sal_uInt32 ImpIsEntry(std::u16string_view rString, 
sal_uInt32 nCLOffset,
+                                         LanguageType eLnge) const;
+
+    // Return CLOffset or (MaxCLOffset + SV_COUNTRY_LANGUAGE_OFFSET) if new 
language/country
+    SVL_DLLPRIVATE sal_uInt32 ImpGetCLOffset(LanguageType eLnge) const;
+
+    // Generate builtin formats provided by i18n behind CLOffset,
+    // if bNoAdditionalFormats==false also generate additional i18n formats.
+    SVL_DLLPRIVATE void ImpGenerateFormats(SvNFLanguageData& rCurrentLanguage,
+                                           const NativeNumberWrapper* pNatNum, 
sal_uInt32 CLOffset,
+                                           bool bNoAdditionalFormats);
+
+    // Create builtin formats for language/country if necessary, return 
CLOffset
+    SVL_DLLPRIVATE sal_uInt32 ImpGenerateCL(SvNFLanguageData& rCurrentLanguage,
+                                            const NativeNumberWrapper* 
pNatNum, LanguageType eLnge);
+
+    // Generate additional formats provided by i18n
+    SVL_DLLPRIVATE void ImpGenerateAdditionalFormats(
+        SvNFLanguageData& rCurrentLanguage, const NativeNumberWrapper* 
pNatNum, sal_uInt32 CLOffset,
+        css::uno::Reference<css::i18n::XNumberFormatCode> const& 
rNumberFormatCode,
+        bool bAfterChangingSystemCL);
+
+    // called by SvNumberFormatterRegistry_Impl::Notify if the default system 
currency changes
+    SVL_DLLPRIVATE void ResetDefaultSystemCurrency();
+
+    SVL_DLLPRIVATE bool PutEntry(SvNFLanguageData& rCurrentLanguage,
+                                 const NativeNumberWrapper* pNatNum, OUString& 
rString,
+                                 sal_Int32& nCheckPos, SvNumFormatType& nType, 
sal_uInt32& nKey,
+                                 LanguageType eLnge = LANGUAGE_DONTKNOW,
+                                 bool bReplaceBooleanEquivalent = true);
+
+    SVL_DLLPRIVATE SvNumberformat*
+    ImpInsertFormat(SvNFLanguageData& rCurrentLanguage, const 
NativeNumberWrapper* pNatNum,
+                    const css::i18n::NumberFormatCode& rCode, sal_uInt32 nPos,
+                    bool bAfterChangingSystemCL = false, sal_Int16 nOrgIndex = 
0);
+
+    SVL_DLLPRIVATE sal_uInt32 ImpGetStandardFormat(SvNFLanguageData& 
rCurrentLanguage,
+                                                   const NativeNumberWrapper* 
pNatNum,
+                                                   SvNumFormatType eType, 
sal_uInt32 CLOffset,
+                                                   LanguageType eLnge);
+
+    // Return the format index of the currency format of the current locale.
+    // Format is created if not already present.
+    SVL_DLLPRIVATE sal_uInt32 ImpGetDefaultCurrencyFormat(SvNFLanguageData& 
rCurrentLanguage,
+                                                          const 
NativeNumberWrapper* pNatNum,
+                                                          sal_uInt32 CLOffset, 
LanguageType eLnge);
+
+    // Return the format index of the currency format of the system locale.
+    // Format is created if not already present.
+    SVL_DLLPRIVATE sal_uInt32 
ImpGetDefaultSystemCurrencyFormat(SvNFLanguageData& rCurrentLanguage,
+                                                                const 
NativeNumberWrapper* pNatNum);
+
+    SVL_DLLPRIVATE std::pair<sal_uInt32, bool>
+    ImpGetDefaultFormat(SvNumFormatType nType, sal_uInt32 nSearch, sal_uInt32 
CLOffset) const;
+
+    SVL_DLLPRIVATE static sal_Int32
+    ImpGetFormatCodeIndex(const SvNFLanguageData& rCurrentLanguage,
+                          css::uno::Sequence<css::i18n::NumberFormatCode>& 
rSeq,
+                          const NfIndexTableOffset nTabOff);
+
+    SVL_DLLPRIVATE static void ImpAdjustFormatCodeDefault(const 
SvNFLanguageData& rCurrentLanguage,
+                                                          
css::i18n::NumberFormatCode* pFormatArr,
+                                                          sal_Int32 nCnt);
+};
+
+class SVL_DLLPUBLIC SvNFEngine
+{
+public:
+    typedef std::function<sal_uInt32(SvNFLanguageData& rCurrentLanguage,
+                                     const NativeNumberWrapper* pNatNum, 
LanguageType eLnge)>
+        GetCLOffset;
+    typedef std::function<void(sal_uInt32 nSearch, sal_uInt32 nFormat)> 
CacheFormat;
+
+    typedef std::function<sal_uInt32(SvNFLanguageData& rCurrentLanguage,
+                                     const NativeNumberWrapper* pNatNum, 
sal_uInt32 CLOffset,
+                                     LanguageType eLnge)>
+        GetDefaultCurrency;
+
+    struct Accessor
+    {
+        GetCLOffset mGetCLOffset;
+        CacheFormat mCacheFormat;
+        GetDefaultCurrency mGetDefaultCurrency;
+    };
+
+    static Accessor GetRWPolicy(SvNFFormatData& rFormatData);
+    static Accessor GetROPolicy(const SvNFFormatData& rFormatData);
+
+    static void ChangeIntl(SvNFLanguageData& rCurrentLanguage, LanguageType 
eLnge);
+    static void ChangeNullDate(SvNFLanguageData& rCurrentLanguage, sal_uInt16 
nDay,
+                               sal_uInt16 nMonth, sal_Int16 nYear);
+
+    static sal_uInt32 GetFormatIndex(SvNFLanguageData& rCurrentLanguage, const 
Accessor& rFuncs,
+                                     const NativeNumberWrapper* pNatNum, 
NfIndexTableOffset nTabOff,
+                                     LanguageType eLnge);
+
+    static sal_uInt32 GetFormatForLanguageIfBuiltIn(SvNFLanguageData& 
rCurrentLanguage,
+                                                    const NativeNumberWrapper* 
pNatNum,
+                                                    const Accessor& rFunc, 
sal_uInt32 nFormat,
+                                                    LanguageType eLnge);
+
+    static bool IsNumberFormat(SvNFLanguageData& rCurrentLanguage,
+                               const SvNFFormatData& rFormatData,
+                               const NativeNumberWrapper* pNatNum, const 
Accessor& rFunc,
+                               const OUString& sString, sal_uInt32& F_Index, 
double& fOutNumber,
+                               SvNumInputOptions eInputOptions = 
SvNumInputOptions::NONE);
+
+    static sal_uInt32 GetStandardFormat(SvNFLanguageData& rCurrentLanguage,
+                                        const SvNFFormatData& rFormatData,
+                                        const NativeNumberWrapper* pNatNum, 
const Accessor& rFunc,
+                                        SvNumFormatType eType, LanguageType 
eLnge);
+
+    static sal_uInt32 GetStandardFormat(SvNFLanguageData& rCurrentLanguage,
+                                        const SvNFFormatData& rFormatData,
+                                        const NativeNumberWrapper* pNatNum, 
const Accessor& rFuncs,
+                                        sal_uInt32 nFIndex, SvNumFormatType 
eType,
+                                        LanguageType eLnge);
+
+    static sal_uInt32 GetStandardFormat(SvNFLanguageData& rCurrentLanguage,
+                                        const SvNFFormatData& rFormatData,
+                                        const NativeNumberWrapper* pNatNum, 
const Accessor& rFuncs,
+                                        double fNumber, sal_uInt32 nFIndex, 
SvNumFormatType eType,
+                                        LanguageType eLnge);
+
+    static sal_uInt32 GetStandardIndex(SvNFLanguageData& rCurrentLanguage,
+                                       const SvNFFormatData& rFormatData,
+                                       const NativeNumberWrapper* pNatNum, 
const Accessor& rFuncs,
+                                       LanguageType eLnge = LANGUAGE_DONTKNOW);
+
+    static sal_uInt32 GetTimeFormat(SvNFLanguageData& rCurrentLanguage,
+                                    const SvNFFormatData& rFormatData,
+                                    const NativeNumberWrapper* pNatNum, const 
Accessor& rFuncs,
+                                    double fNumber, LanguageType eLnge, bool 
bForceDuration);
+
+    /// Return the decimal separator matching the locale of the given format
+    static OUString GetFormatDecimalSep(SvNFLanguageData& rCurrentLanguage,
+                                        const SvNFFormatData& rFormatData, 
sal_uInt32 nFormat);
+
+    /// Count of decimals
+    static sal_uInt16 GetFormatPrecision(SvNFLanguageData& rCurrentLanguage,
+                                         const SvNFFormatData& rFormatData, 
sal_uInt32 nFormat);
+
+    static void GetInputLineString(SvNFLanguageData& rCurrentLanguage,
+                                   const SvNFFormatData& rFormatData,
+                                   const NativeNumberWrapper* pNatNum, const 
Accessor& rFuncs,
+                                   const double& fOutNumber, sal_uInt32 
nFIndex,
+                                   OUString& sOutString, bool bFiltering, bool 
bForceSystemLocale);
+
+    static sal_uInt32 GetEditFormat(SvNFLanguageData& rCurrentLanguage,
+                                    const SvNFFormatData& rFormatData,
+                                    const NativeNumberWrapper* pNatNum, const 
Accessor& rFuncs,
+                                    double fNumber, sal_uInt32 nFIndex, 
SvNumFormatType eType,
+                                    const SvNumberformat* pFormat, 
LanguageType eForLocale);
+
+    static void GetOutputString(SvNFLanguageData& rCurrentLanguage,
+                                const SvNFFormatData& rFormatData,
+                                const NativeNumberWrapper* pNatNum, const 
Accessor& rFuncs,
+                                const double& fOutNumber, sal_uInt32 nFIndex, 
OUString& sOutString,
+                                const Color** ppColor, bool bUseStarFormat);
+
+    static void GetOutputString(SvNFLanguageData& rCurrentLanguage,
+                                const SvNFFormatData& rFormatData, const 
OUString& sString,
+                                sal_uInt32 nFIndex, OUString& sOutString, 
const Color** ppColor,
+                                bool bUseStarFormat);
+
+    static bool GetPreviewString(SvNFLanguageData& rCurrentLanguage,
+                                 const SvNFFormatData& rFormatData,
+                                 const NativeNumberWrapper* pNatNum, const 
Accessor& rFuncs,
+                                 const OUString& sFormatString, double 
fPreviewNumber,
+                                 OUString& sOutString, const Color** ppColor, 
LanguageType eLnge,
+                                 bool bUseStarFormat);
+
+    static bool GetPreviewString(SvNFLanguageData& rCurrentLanguage,
+                                 const SvNFFormatData& rFormatData,
+                                 const NativeNumberWrapper* pNatNum, const 
Accessor& rFuncs,
+                                 const OUString& sFormatString, const 
OUString& sPreviewString,
+                                 OUString& sOutString, const Color** ppColor,
+                                 LanguageType eLnge = LANGUAGE_DONTKNOW);
+
+    static bool GetPreviewStringGuess(SvNFLanguageData& rCurrentLanguage,
+                                      const SvNFFormatData& rFormatData,
+                                      const NativeNumberWrapper* pNatNum, 
const Accessor& rFuncs,
+                                      const OUString& sFormatString, double 
fPreviewNumber,
+                                      OUString& sOutString, const Color** 
ppColor,
+                                      LanguageType eLnge);
+
+    static OUString GenerateFormat(SvNFLanguageData& rCurrentLanguage,
+                                   const SvNFFormatData& rFormatData,
+                                   const NativeNumberWrapper* pNatNum, const 
Accessor& rFuncs,
+                                   sal_uInt32 nIndex, LanguageType eLnge, bool 
bThousand,
+                                   bool IsRed, sal_uInt16 nPrecision, 
sal_uInt16 nLeadingZeros);
+
+private:
+    static sal_uInt32 ImpGetDefaultFormat(const SvNFFormatData& rFormatData,
+                                          const SvNFEngine::CacheFormat& rFunc,
+                                          SvNumFormatType nType, sal_uInt32 
CLOffset);
+    static sal_uInt32
+    ImpGetStandardFormat(SvNFLanguageData& rCurrentLanguage, const 
SvNFFormatData& rFormatData,
+                         const NativeNumberWrapper* pNatNum, const 
SvNFEngine::Accessor& rFuncs,
+                         SvNumFormatType eType, sal_uInt32 CLOffset, 
LanguageType eLnge);
+
+    static sal_uInt32 DefaultCurrencyRW(SvNFFormatData& rFormatData,
+                                        SvNFLanguageData& rCurrentLanguage,
+                                        const NativeNumberWrapper* pNatNum, 
sal_uInt32 CLOffset,
+                                        LanguageType eLnge);
+    static sal_uInt32 DefaultCurrencyRO(const SvNFFormatData& rFormatData, 
SvNFLanguageData&,
+                                        const NativeNumberWrapper*, sal_uInt32 
CLOffset,
+                                        LanguageType eLnge);
+
+    static sal_uInt32 GetCLOffsetRW(SvNFFormatData& rFormatData, 
SvNFLanguageData& rCurrentLanguage,
+                                    const NativeNumberWrapper* pNatNum, 
LanguageType eLnge);
+    static sal_uInt32 GetCLOffsetRO(const SvNFFormatData& rFormatData, 
SvNFLanguageData&,
+                                    const NativeNumberWrapper*, LanguageType 
eLnge);
+
+    static void CacheFormatRW(SvNFFormatData& rFormatData, sal_uInt32 nSearch, 
sal_uInt32 nFormat);
+    static void CacheFormatRO(const SvNFFormatData& rFormatData, sal_uInt32 
nSearch,
+                              sal_uInt32 nFormat);
+};
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/svl/numformat.hxx b/include/svl/numformat.hxx
index 47e85cd0fa5a..7acecbcbc2b4 100644
--- a/include/svl/numformat.hxx
+++ b/include/svl/numformat.hxx
@@ -19,22 +19,8 @@
 #pragma once
 
 #include <svl/svldllapi.h>
-#include <com/sun/star/i18n/XNumberFormatCode.hpp>
-#include <com/sun/star/uno/XComponentContext.hpp>
-#include <i18nlangtag/lang.h>
-#include <tools/link.hxx>
-#include <svl/nfkeytab.hxx>
-#include <svl/ondemand.hxx>
-#include <svl/zforlist.hxx>
-#include <unotools/charclass.hxx>
-
-#include <map>
-
-class Color;
-class ImpSvNumberformatScan;
-class ImpSvNumberInputScan;
-class SvNumberFormatterRegistry_Impl;
-class NfCurrencyTable;
+
+#include <svl/nfengine.hxx>
 
 class SVL_DLLPUBLIC SvNumberFormatter
 {
@@ -246,7 +232,7 @@ public:
                               sal_uInt16& nPrecision, sal_uInt16& nLeadingCnt);
 
     /// Count of decimals
-    sal_uInt16 GetFormatPrecision(sal_uInt32 nFormat) const;
+    sal_uInt16 GetFormatPrecision(sal_uInt32 nFormat);
 
     /// Count of integer digits
     sal_uInt16 GetFormatIntegerDigits(sal_uInt32 nFormat) const;
@@ -381,10 +367,7 @@ public:
     static sal_uInt16 ExpandTwoDigitYear(sal_uInt16 nYear, sal_uInt16 
nTwoDigitYearStart);
 
     /// Return the decimal separator matching the locale of the given format
-    OUString GetFormatDecimalSep(sal_uInt32 nFormat) const;
-
-    /// Return the decimal separator matching the given locale / LanguageType.
-    OUString GetLangDecimalSep(LanguageType nLang) const;
+    OUString GetFormatDecimalSep(sal_uInt32 nFormat);
 
     static void resetTheCurrencyTable();
 
@@ -554,50 +537,18 @@ public:
     /** Access for unit tests. */
     static size_t GetMaxDefaultColors();
 
-    struct InputScannerPrivateAccess
-    {
-        friend class ImpSvNumberInputScan;
-
-    private:
-        InputScannerPrivateAccess() {}
-    };
-    /** Access for input scanner to temporarily (!) switch locales. */
-    OnDemandLocaleDataWrapper& GetOnDemandLocaleDataWrapper(const 
InputScannerPrivateAccess&)
-    {
-        return xLocaleData;
-    }
-
 private:
     mutable ::osl::Mutex m_aMutex;
     css::uno::Reference<css::uno::XComponentContext> m_xContext;
     const LanguageType IniLnge; // Initialized setting language/country
-    LanguageType ActLnge; // Current setting language/country
-    LanguageTag maLanguageTag;
-    std::map<sal_uInt32, std::unique_ptr<SvNumberformat>>
-        aFTable; // Table of format keys to format entries
-    typedef std::map<sal_uInt32, sal_uInt32> DefaultFormatKeysMap;
-    DefaultFormatKeysMap aDefaultFormatKeys; // Table of default standard to 
format keys
+    SvNFFormatData m_aFormatData;
+    SvNFEngine::Accessor m_aRWPolicy;
     std::unique_ptr<SvNumberFormatTable> pFormatTable; // For the UI dialog
     std::unique_ptr<SvNumberFormatterIndexTable>
         pMergeTable; // List of indices for merging two formatters
-    OnDemandCharClass xCharClass; // CharacterClassification
-    OnDemandLocaleDataWrapper xLocaleData; // LocaleData switched between 
SYSTEM, ENGLISH and other
-    OnDemandTransliterationWrapper xTransliteration; // Transliteration loaded 
on demand
-    OnDemandCalendarWrapper xCalendar; // Calendar loaded on demand
+    SvNFLanguageData m_aCurrentLanguage;
     OnDemandNativeNumberWrapper xNatNum; // Native number service loaded on 
demand
-    std::unique_ptr<ImpSvNumberInputScan> pStringScanner; // Input string 
scanner
-    std::unique_ptr<ImpSvNumberformatScan> pFormatScanner; // Format code 
string scanner
     Link<sal_uInt16, Color*> aColorLink; // User defined color table CallBack
-    sal_uInt32 MaxCLOffset; // Max language/country offset used
-    sal_uInt32 nDefaultSystemCurrencyFormat; // NewCurrency matching SYSTEM 
locale
-    NfEvalDateFormat eEvalDateFormat; // DateFormat evaluation
-    bool bNoZero; // Zero value suppression
-
-    // cached locale data items needed almost any time
-    OUString aDecimalSep;
-    OUString aDecimalSepAlt;
-    OUString aThousandSep;
-    OUString aDateSep;
 
     SVL_DLLPRIVATE static volatile bool bCurrencyTableInitialized;
     SVL_DLLPRIVATE static sal_uInt16 nSystemCurrencyPosition;
@@ -606,82 +557,42 @@ private:
     // get the registry, create one if none exists
     SVL_DLLPRIVATE static SvNumberFormatterRegistry_Impl& 
GetFormatterRegistry();
 
-    // Generate builtin formats provided by i18n behind CLOffset,
-    // if bNoAdditionalFormats==false also generate additional i18n formats.
-    SVL_DLLPRIVATE void ImpGenerateFormats(sal_uInt32 CLOffset, bool 
bNoAdditionalFormats);
-
     // Generate additional formats provided by i18n
     SVL_DLLPRIVATE void ImpGenerateAdditionalFormats(
         sal_uInt32 CLOffset,
         css::uno::Reference<css::i18n::XNumberFormatCode> const& 
rNumberFormatCode,
         bool bAfterChangingSystemCL);
 
-    SVL_DLLPRIVATE SvNumberformat* ImpInsertFormat(const 
css::i18n::NumberFormatCode& rCode,
-                                                   sal_uInt32 nPos,
-                                                   bool bAfterChangingSystemCL 
= false,
-                                                   sal_Int16 nOrgIndex = 0);
-
-    // Return CLOffset or (MaxCLOffset + SV_COUNTRY_LANGUAGE_OFFSET) if new 
language/country
-    SVL_DLLPRIVATE sal_uInt32 ImpGetCLOffset(LanguageType eLnge) const;
-
     // Test whether format code already exists, then return index key,
     // otherwise NUMBERFORMAT_ENTRY_NOT_FOUND
     SVL_DLLPRIVATE sal_uInt32 ImpIsEntry(std::u16string_view rString, 
sal_uInt32 CLOffset,
                                          LanguageType eLnge) const;
 
-    // Create builtin formats for language/country if necessary, return 
CLOffset
-    SVL_DLLPRIVATE sal_uInt32 ImpGenerateCL(LanguageType eLnge);
-
     // Create theCurrencyTable with all <type>NfCurrencyEntry</type>
     SVL_DLLPRIVATE static void ImpInitCurrencyTable();
 
-    // Return the format index of the currency format of the system locale.
-    // Format is created if not already present.
-    SVL_DLLPRIVATE sal_uInt32 ImpGetDefaultSystemCurrencyFormat();
-
-    // Return the format index of the currency format of the current locale.
-    // Format is created if not already present.
-    SVL_DLLPRIVATE sal_uInt32 ImpGetDefaultCurrencyFormat();
-
-    // Return the default format for a given type and current locale.
-    // May ONLY be called from within GetStandardFormat().
-    SVL_DLLPRIVATE sal_uInt32 ImpGetDefaultFormat(SvNumFormatType nType);
-
-    // Return the index in a sequence of format codes matching an enum of
-    // NfIndexTableOffset. If not found 0 is returned. If the sequence doesn't
-    // contain any format code elements a default element is created and 
inserted.
-    SVL_DLLPRIVATE sal_Int32 ImpGetFormatCodeIndex(
-        css::uno::Sequence<css::i18n::NumberFormatCode>& rSeq, const 
NfIndexTableOffset nTabOff);
-
-    // Adjust a sequence of format codes to contain only one (THE) default
-    // instead of multiple defaults for short/medium/long types.
-    // If there is no medium but a short and a long default the long is taken.
-    // Non-PRODUCT version may check locale data for matching defaults in one
-    // FormatElement group.
-    SVL_DLLPRIVATE void 
ImpAdjustFormatCodeDefault(css::i18n::NumberFormatCode* pFormatArr,
-                                                   sal_Int32 nCount);
-
-    // Obtain the format entry for a given key index.
-    SVL_DLLPRIVATE SvNumberformat* GetFormatEntry(sal_uInt32 nKey);
-    SVL_DLLPRIVATE const SvNumberformat* GetFormatEntry(sal_uInt32 nKey) const;
-
     // used as a loop body inside of GetNewCurrencySymbolString() and 
GetCurrencyEntry()
     static bool ImpLookupCurrencyEntryLoopBody(const NfCurrencyEntry*& 
pFoundEntry,
                                                bool& bFoundBank, const 
NfCurrencyEntry* pData,
                                                sal_uInt16 nPos, 
std::u16string_view rSymbol);
 
+    // called by SvNumberFormatterRegistry_Impl::Notify if the default system 
currency changes
+    SVL_DLLPRIVATE void ResetDefaultSystemCurrency();
+
     // link to be set at 
<method>SvtSysLocaleOptions::SetCurrencyChangeLink()</method>
     DECL_DLLPRIVATE_STATIC_LINK(SvNumberFormatter, CurrencyChangeLink, 
LinkParamNone*, void);
 
     // Substitute a format during GetFormatEntry(), i.e. system formats.
-    SVL_DLLPRIVATE SvNumberformat* ImpSubstituteEntry(SvNumberformat* pFormat,
-                                                      sal_uInt32* o_pRealKey = 
nullptr);
+    SVL_DLLPRIVATE const SvNumberformat* ImpSubstituteEntry(const 
SvNumberformat* pFormat,
+                                                            sal_uInt32* 
o_pRealKey = nullptr);
 
     // Whether nFIndex is a special builtin format
     SVL_DLLPRIVATE bool ImpIsSpecialStandardFormat(sal_uInt32 nFIndex, 
LanguageType eLnge);
+    SVL_DLLPRIVATE static bool ImpIsSpecialStandardFormat(sal_uInt32 nFIndex, 
sal_uInt32 nCLOffset);
 
-    // called by SvNumberFormatterRegistry_Impl::Notify if the default system 
currency changes
-    SVL_DLLPRIVATE void ResetDefaultSystemCurrency();
+    SVL_DLLPRIVATE sal_uInt32 ImpGetOrGenerateCLOffset(LanguageType eLnge);
+
+    SVL_DLLPRIVATE LanguageType ImpResolveLanguage(LanguageType eLnge) const;
 
     // Replace the SYSTEM language/country format codes. Called upon change of
     // the user configurable locale.
@@ -700,28 +611,26 @@ public:
 
     const css::uno::Reference<css::uno::XComponentContext>& 
GetComponentContext() const;
 
-    //! The following method is not to be used from outside but must be
-    //! public for the InputScanner.
-    // return the current FormatScanner
-    const ImpSvNumberformatScan* GetFormatScanner() const;
-
     //! The following methods are not to be used from outside but must be
     //! public for the InputScanner and FormatScanner.
 
     // return current (!) Locale
-    const LanguageTag& GetLanguageTag() const;
+    const LanguageTag& GetLanguageTag() const { return 
m_aCurrentLanguage.GetLanguageTag(); }
 
     // return corresponding Transliteration wrapper
-    const ::utl::TransliterationWrapper* GetTransliteration() const;
+    const ::utl::TransliterationWrapper* GetTransliteration() const
+    {
+        return m_aCurrentLanguage.GetTransliteration();
+    }
 
     // return the corresponding CharacterClassification wrapper
-    const CharClass* GetCharClass() const;
+    const CharClass* GetCharClass() const { return 
m_aCurrentLanguage.GetCharClass(); }
 
     // return the corresponding LocaleData wrapper
-    const LocaleDataWrapper* GetLocaleData() const;
+    const LocaleDataWrapper* GetLocaleData() const { return 
m_aCurrentLanguage.GetLocaleData(); }
 
     // return the corresponding Calendar wrapper
-    CalendarWrapper* GetCalendar() const;
+    CalendarWrapper* GetCalendar() const { return 
m_aCurrentLanguage.GetCalendar(); }
 
     // return the corresponding NativeNumberSupplier wrapper
     const NativeNumberWrapper* GetNatNum() const;
@@ -729,19 +638,19 @@ public:
     // cached locale data items
 
     // return the corresponding decimal separator
-    const OUString& GetNumDecimalSep() const;
+    const OUString& GetNumDecimalSep() const { return 
m_aCurrentLanguage.GetNumDecimalSep(); }
 
     // return the corresponding decimal separator alternative
-    const OUString& GetNumDecimalSepAlt() const;
+    const OUString& GetNumDecimalSepAlt() const { return 
m_aCurrentLanguage.GetNumDecimalSepAlt(); }
 
     // return the corresponding group (AKA thousand) separator
-    const OUString& GetNumThousandSep() const;
+    const OUString& GetNumThousandSep() const { return 
m_aCurrentLanguage.GetNumThousandSep(); }
 
     // return the corresponding date separator
-    const OUString& GetDateSep() const;
+    const OUString& GetDateSep() const { return 
m_aCurrentLanguage.GetDateSep(); }
 
-    // checks for decimal separator and optional alternative
-    bool IsDecimalSep(std::u16string_view rStr) const;
+    const SvNFFormatData& GetROFormatData() const { return m_aFormatData; }
+    const SvNFLanguageData& GetROLanguageData() const { return 
m_aCurrentLanguage; }
 };
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/svl/zformat.hxx b/include/svl/zformat.hxx
index f60e74783d5c..ed13abfcb63c 100644
--- a/include/svl/zformat.hxx
+++ b/include/svl/zformat.hxx
@@ -32,8 +32,12 @@ namespace com::sun::star::i18n { struct 
NativeNumberXmlAttributes2; }
 
 class Color;
 
+class SvNFLanguageData;
+
 class ImpSvNumberformatScan;            // format code string scanner
 class ImpSvNumberInputScan;             // input string scanner
+class NativeNumberWrapper;
+class SvNFFormatData;
 class SvNumberFormatter;
 
 enum SvNumberformatLimitOps
@@ -171,6 +175,7 @@ public:
     SvNumberformat( OUString& rString,
                    ImpSvNumberformatScan* pSc,
                    ImpSvNumberInputScan* pISc,
+                   const NativeNumberWrapper* pNatNum,
                    sal_Int32& nCheckPos,
                    LanguageType& eLan,
                    bool bReplaceBooleanEquivalent = true );
@@ -239,11 +244,11 @@ public:
      * Get output string from a numeric value that fits the number of
      * characters specified.
      */
-    bool GetOutputString( double fNumber, sal_uInt16 nCharCount, OUString& 
rOutString ) const;
+    bool GetOutputString( double fNumber, sal_uInt16 nCharCount, OUString& 
rOutString, const NativeNumberWrapper* pNatNum ) const;
 
     // bStarFlag: Take *n format as ESC n
-    bool GetOutputString( double fNumber, OUString& OutString, const Color** 
ppColor, bool bStarFlag = false ) const;
-    void GetOutputString( std::u16string_view sString, OUString& OutString, 
const Color** ppColor, bool bStarFlag = false ) const;
+    bool GetOutputString( double fNumber, OUString& OutString, const Color** 
ppColor, const NativeNumberWrapper* pNatNum, bool bStarFlag = false) const;
+    void GetOutputString( std::u16string_view sString, OUString& OutString, 
const Color** ppColor, bool bStarFlag = false) const;
 
     // True if type text
     bool IsTextFormat() const { return bool(eType & SvNumFormatType::TEXT); }
@@ -283,7 +288,7 @@ public:
 
     //! Read/write access on a special sal_uInt16 component, may only be used 
on the
     //! standard format 0, 10000, ... and only by the number formatter!
-    struct FormatterPrivateAccess { friend SvNumberFormatter; private: 
FormatterPrivateAccess() {} };
+    struct FormatterPrivateAccess { friend SvNumberFormatter; friend 
SvNFFormatData; private: FormatterPrivateAccess() {} };
     sal_uInt16 GetLastInsertKey( const FormatterPrivateAccess& ) const
         { return NumFor[0].Info().nThousand; }
     void SetLastInsertKey( sal_uInt16 nKey, const FormatterPrivateAccess& )
@@ -457,7 +462,8 @@ public:
     // rAttr.Number not empty if NatNum attributes are to be stored
     void GetNatNumXml(
             css::i18n::NativeNumberXmlAttributes2& rAttr,
-            sal_uInt16 nNumFor ) const;
+            sal_uInt16 nNumFor,
+            const NativeNumberWrapper* pNatNum ) const;
     /** Return empty string if no NatNum modifier or invalid nNumFor
         otherwise return "[NatNum1]" or "[NatNum12 ...]" */
     OUString GetNatNumModifierString( sal_uInt16 nNumFor = 0 ) const;
@@ -551,7 +557,7 @@ private:
     const CharClass& rChrCls() const;
     const LocaleDataWrapper& rLoc() const;
     CalendarWrapper& GetCal() const;
-    const SvNumberFormatter& GetFormatter() const;
+    const SvNFLanguageData& GetCurrentLanguageData() const;
 
     // divide in substrings and color conditions
     SVL_DLLPRIVATE short ImpNextSymbol( OUStringBuffer& rString,
@@ -606,9 +612,12 @@ private:
                                                           const LocaleType & 
aTmpLocale );
 
     // standard number output
-    SVL_DLLPRIVATE void ImpGetOutputStandard( double& fNumber, OUString& 
OutString ) const;
-    SVL_DLLPRIVATE void ImpGetOutputStandard( double& fNumber, OUStringBuffer& 
OutString ) const;
-    SVL_DLLPRIVATE void ImpGetOutputStdToPrecision( double& rNumber, OUString& 
rOutString, sal_uInt16 nPrecision ) const;
+    SVL_DLLPRIVATE void ImpGetOutputStandard(double& fNumber, OUString& 
OutString,
+                                             const NativeNumberWrapper* 
pNatNum) const;
+    SVL_DLLPRIVATE void ImpGetOutputStandard(double& fNumber, OUStringBuffer& 
OutString,
+                                             const NativeNumberWrapper* 
pNatNum) const;
+    SVL_DLLPRIVATE void ImpGetOutputStdToPrecision(double& rNumber, OUString& 
rOutString, sal_uInt16 nPrecision,
+                                                   const NativeNumberWrapper* 
pNatNum) const;
     // numbers in input line
     SVL_DLLPRIVATE void ImpGetOutputInputLine( double fNumber, OUString& 
OutString ) const;
 
@@ -621,7 +630,9 @@ private:
 
     // Helper function for number strings
     // append string symbols, insert leading 0 or ' ', or ...
-    SVL_DLLPRIVATE bool ImpNumberFill(OUStringBuffer& sStr,
+    SVL_DLLPRIVATE bool ImpNumberFill(
+                    const NativeNumberWrapper* pNatNum,
+                    OUStringBuffer& sStr,
                     double& rNumber,
                     sal_Int32& k,
                     sal_uInt16& j,
@@ -631,7 +642,9 @@ private:
                     bool bInsertRightBlank = false ) const;
 
     // Helper function to fill in the integer part and the group (AKA 
thousand) separators
-    SVL_DLLPRIVATE bool ImpNumberFillWithThousands(OUStringBuffer& sStr,
+    SVL_DLLPRIVATE bool ImpNumberFillWithThousands(
+                                 const NativeNumberWrapper* pNatNum,
+                                 OUStringBuffer& sStr,
                                  double& rNumber,
                                  sal_Int32 k,
                                  sal_uInt16 j,
@@ -649,7 +662,8 @@ private:
                                       sal_Int32 & nDigitCount,
                                       utl::DigitGroupingIterator & ) const;
 
-    SVL_DLLPRIVATE bool ImpDecimalFill( OUStringBuffer& sStr,
+    SVL_DLLPRIVATE bool ImpDecimalFill(const NativeNumberWrapper* pNatNum,
+                                 OUStringBuffer& sStr,
                                  double& rNumber,
                                  sal_Int32 nDecPos,
                                  sal_uInt16 j,
@@ -673,23 +687,28 @@ private:
     SVL_DLLPRIVATE bool ImpGetFractionOutput(double fNumber,
                                              sal_uInt16 nIx,
                                              bool bStarFlag,
+                                             const NativeNumberWrapper* 
pNatNum,
                                              OUStringBuffer& OutString) const;
     SVL_DLLPRIVATE bool ImpGetScientificOutput(double fNumber,
                                                sal_uInt16 nIx,
                                                bool bStarFlag,
+                                               const NativeNumberWrapper* 
pNatNum,
                                                OUStringBuffer& OutString) 
const;
 
     SVL_DLLPRIVATE bool ImpGetDateOutput( double fNumber,
                                           sal_uInt16 nIx,
                                           bool bStarFlag,
+                                          const NativeNumberWrapper* pNatNum,
                                           OUStringBuffer& OutString ) const;
     SVL_DLLPRIVATE bool ImpGetTimeOutput( double fNumber,
                                           sal_uInt16 nIx,
                                           bool bStarFlag,
+                                          const NativeNumberWrapper* pNatNum,
                                           OUStringBuffer& OutString ) const;
     SVL_DLLPRIVATE bool ImpGetDateTimeOutput( double fNumber,
                                               sal_uInt16 nIx,
                                               bool bStarFlag,
+                                              const NativeNumberWrapper* 
pNatNum,
                                               OUStringBuffer& OutString ) 
const;
 
     // Switches to the "gregorian" calendar if the current calendar is
@@ -707,26 +726,28 @@ private:
 
     SVL_DLLPRIVATE bool ImpGetLogicalOutput( double fNumber,
                                              sal_uInt16 nIx,
-                                             OUStringBuffer& OutString ) const;
+                                             const NativeNumberWrapper* 
pNatNum,
+                                             OUStringBuffer& OutString) const;
 
     SVL_DLLPRIVATE bool ImpGetNumberOutput( double fNumber,
                                             sal_uInt16 nIx,
                                             bool bStarFlag,
-                                            OUStringBuffer& OutString ) const;
+                                            const NativeNumberWrapper* pNatNum,
+                                            OUStringBuffer& OutString) const;
 
     SVL_DLLPRIVATE void ImpCopyNumberformat( const SvNumberformat& rFormat );
 
     // normal digits or other digits, depending on ImpSvNumFor.aNatNum,
     // [NatNum1], [NatNum2], ...
-    SVL_DLLPRIVATE OUString ImpGetNatNumString( const SvNumberNatNum& rNum, 
sal_Int64 nVal,
-                                              sal_uInt16 nMinDigits  ) const;
+    SVL_DLLPRIVATE static OUString ImpGetNatNumString(const SvNumberNatNum& 
rNum, sal_Int64 nVal,
+                                                      sal_uInt16 nMinDigits, 
const NativeNumberWrapper* pNatNum);
 
-    OUString ImpIntToString( sal_uInt16 nIx, sal_Int64 nVal, sal_uInt16 
nMinDigits = 0 ) const
+    OUString ImpIntToString(const NativeNumberWrapper* pNatNum, sal_uInt16 
nIx, sal_Int64 nVal, sal_uInt16 nMinDigits = 0 ) const
     {
         const SvNumberNatNum& rNum = NumFor[nIx].GetNatNum();
         if ( nMinDigits || rNum.IsComplete() )
         {
-            return ImpGetNatNumString( rNum, nVal, nMinDigits );
+            return ImpGetNatNumString( rNum, nVal, nMinDigits, pNatNum );
         }
         return OUString::number(nVal);
     }
@@ -738,29 +759,15 @@ private:
     // nFractionDecimals, unless nMinimumInputLineDecimals>0 is given for input
     // line string where extra trailing "0" are discarded.
     SVL_DLLPRIVATE sal_uInt16 ImpGetFractionOfSecondString( OUStringBuffer& 
rBuf, double fFractionOfSecond,
-            int nFractionDecimals, bool bAddOneRoundingDecimal, sal_uInt16 
nIx, sal_uInt16 nMinimumInputLineDecimals ) const;
+            int nFractionDecimals, bool bAddOneRoundingDecimal, sal_uInt16 
nIx, sal_uInt16 nMinimumInputLineDecimals,
+            const NativeNumberWrapper* pNatNum) const;
 
     // transliterate according to NativeNumber
-    SVL_DLLPRIVATE OUString impTransliterateImpl(const OUString& rStr, const 
SvNumberNatNum& rNum) const;
-    SVL_DLLPRIVATE void impTransliterateImpl(OUStringBuffer& rStr, const 
SvNumberNatNum& rNum) const;
-    SVL_DLLPRIVATE OUString impTransliterateImpl(const OUString& rStr, const 
SvNumberNatNum& rNum, sal_uInt16 nDateKey) const;
-
-    OUString impTransliterate(const OUString& rStr, const SvNumberNatNum& 
rNum) const
-    {
-        return rNum.IsComplete() ? impTransliterateImpl(rStr, rNum) : rStr;
-    }
-
-    SVL_DLLPRIVATE void impTransliterate(OUStringBuffer& rStr, const 
SvNumberNatNum& rNum) const
-    {
-        if(rNum.IsComplete())
-        {
-            impTransliterateImpl(rStr, rNum);
-        }
-    }
+    SVL_DLLPRIVATE OUString impTransliterateImpl(const OUString& rStr, const 
SvNumberNatNum& rNum, sal_uInt16 nDateKey, const NativeNumberWrapper* pNatNum) 
const;
 
-    OUString impTransliterate(const OUString& rStr, const SvNumberNatNum& 
rNum, sal_uInt16 nDateKey) const
+    OUString impTransliterate(const OUString& rStr, const SvNumberNatNum& 
rNum, sal_uInt16 nDateKey, const NativeNumberWrapper* pNatNum) const
     {
-        return rNum.IsComplete() ? impTransliterateImpl(rStr, rNum, nDateKey) 
: rStr;
+        return rNum.IsComplete() ? impTransliterateImpl(rStr, rNum, nDateKey, 
pNatNum) : rStr;
     }
 
 };
diff --git a/sc/source/ui/view/output2.cxx b/sc/source/ui/view/output2.cxx
index dd9a7ba0e1a5..8a18ea06a084 100644
--- a/sc/source/ui/view/output2.cxx
+++ b/sc/source/ui/view/output2.cxx
@@ -646,7 +646,7 @@ bool ScDrawStringsVars::SetTextToWidthOrHash( 
ScRefCellValue& rCell, tools::Long
     sal_uInt16 nNumDigits = static_cast<sal_uInt16>(nWidth / nMaxDigit);
     {
         OUString sTempOut(aString);
-        if (!pNumFormat->GetOutputString(fVal, nNumDigits, sTempOut))
+        if (!pNumFormat->GetOutputString(fVal, nNumDigits, sTempOut, 
pOutput->mpDoc->GetFormatTable()->GetNatNum()))
         {
             aString = sTempOut;
             // Failed to get output string.  Bail out.
@@ -685,7 +685,7 @@ bool ScDrawStringsVars::SetTextToWidthOrHash( 
ScRefCellValue& rCell, tools::Long
         // Re-calculate.
         nNumDigits = static_cast<sal_uInt16>(nWidth / nMaxDigit);
         OUString sTempOut(aString);
-        if (!pNumFormat->GetOutputString(fVal, nNumDigits, sTempOut))
+        if (!pNumFormat->GetOutputString(fVal, nNumDigits, sTempOut, 
pOutput->mpDoc->GetFormatTable()->GetNatNum()))
         {
             aString = sTempOut;
             // Failed to get output string.  Bail out.
diff --git a/sc/source/ui/view/viewfunc.cxx b/sc/source/ui/view/viewfunc.cxx
index 370097507f06..76e575886ced 100644
--- a/sc/source/ui/view/viewfunc.cxx
+++ b/sc/source/ui/view/viewfunc.cxx
@@ -2991,7 +2991,7 @@ void ScViewFunc::ChangeNumFmtDecimals( bool bIncrement )
         //  the ways of the Numberformatters are unfathomable, so try:
         OUString aOut;
         const Color* pCol;
-        pOldEntry->GetOutputString( nVal, aOut, &pCol );
+        pOldEntry->GetOutputString( nVal, aOut, &pCol, pFormatter->GetNatNum() 
);
 
         nPrecision = 0;
         // 'E' for exponential is fixed in Numberformatter
diff --git a/svl/source/numbers/zforfind.cxx b/svl/source/numbers/zforfind.cxx
index c1898104a905..350129da68d7 100644
--- a/svl/source/numbers/zforfind.cxx
+++ b/svl/source/numbers/zforfind.cxx
@@ -72,22 +72,21 @@ const sal_Unicode cNoBreakSpace = 0xA0;
 const sal_Unicode cNarrowNoBreakSpace = 0x202F;
 const bool kDefaultEra = true;     // Gregorian CE, positive year
 
-ImpSvNumberInputScan::ImpSvNumberInputScan( SvNumberFormatter* pFormatterP )
+ImpSvNumberInputScan::ImpSvNumberInputScan(SvNFLanguageData& rCurrentLanguage)
         :
+        mrCurrentLanguageData(rCurrentLanguage),
         bTextInitialized( false ),
         bScanGenitiveMonths( false ),
         bScanPartitiveMonths( false ),
         eScannedType( SvNumFormatType::UNDEFINED ),
         eSetType( SvNumFormatType::UNDEFINED )
 {
-    pFormatter = pFormatterP;
     moNullDate.emplace( 30,12,1899 );
     nYear2000 = SvNumberFormatter::GetYear2000Default();
     Reset();
     ChangeIntl();
 }
 
-
 ImpSvNumberInputScan::~ImpSvNumberInputScan()
 {
 }
@@ -130,21 +129,20 @@ void ImpSvNumberInputScan::Reset()
 }
 
 // native number transliteration if necessary
-static void TransformInput( SvNumberFormatter const * pFormatter, OUString& 
rStr )
+static void TransformInput(const NativeNumberWrapper* pNatNum, const 
SvNFLanguageData& rCurrentLanguage, OUString& rStr)
 {
     sal_Int32 nPos, nLen;
     for ( nPos = 0, nLen = rStr.getLength(); nPos < nLen; ++nPos )
     {
         if ( 256 <= rStr[ nPos ] &&
-             pFormatter->GetCharClass()->isDigit( rStr, nPos ) )
+             rCurrentLanguage.GetCharClass()->isDigit( rStr, nPos ) )
         {
             break;
         }
     }
     if ( nPos < nLen )
     {
-        rStr = pFormatter->GetNatNum()->getNativeNumberString( rStr,
-                                                               
pFormatter->GetLanguageTag().getLocale(), 0 );
+        rStr = pNatNum->getNativeNumberString(rStr, 
rCurrentLanguage.GetLanguageTag().getLocale(), 0);
     }
 }
 
@@ -291,7 +289,7 @@ bool ImpSvNumberInputScan::SkipThousands( const 
sal_Unicode*& pStr,
     bool res = false;
     OUStringBuffer sBuff(rSymbol);
     sal_Unicode cToken;
-    const OUString& rThSep = pFormatter->GetNumThousandSep();
+    const OUString& rThSep = mrCurrentLanguageData.GetNumThousandSep();
     const sal_Unicode* pHere = pStr;
     ScanState eState = SsStart;
     sal_Int32 nCounter = 0; // counts 3 digits
@@ -466,7 +464,7 @@ bool ImpSvNumberInputScan::StringContainsWord( const 
OUString& rWhat,
         if (nPos+1 < nIndex)
             return true;    // Surrogate, assume these to be new words.
 
-        const sal_Int32 nType = pFormatter->GetCharClass()->getCharacterType( 
rString, nPos);
+        const sal_Int32 nType = 
mrCurrentLanguageData.GetCharClass()->getCharacterType( rString, nPos);
         using namespace ::com::sun::star::i18n;
 
         if ((nType & (KCharacterType::UPPER | KCharacterType::LOWER | 
KCharacterType::DIGIT)) != 0)
@@ -539,7 +537,7 @@ inline bool ImpSvNumberInputScan::GetThousandSep( 
std::u16string_view rString,
                                                   sal_Int32& nPos,
                                                   sal_uInt16 nStringPos ) const
 {
-    const OUString& rSep = pFormatter->GetNumThousandSep();
+    const OUString& rSep = mrCurrentLanguageData.GetNumThousandSep();
     // Is it an ordinary space instead of a no-break space?
     bool bSpaceBreak = (rSep[0] == cNoBreakSpace || rSep[0] == 
cNarrowNoBreakSpace) &&
         rString[0] == u' ' &&
@@ -551,7 +549,7 @@ inline bool ImpSvNumberInputScan::GetThousandSep( 
std::u16string_view rString,
         return false; // no? => out
     }
 
-    utl::DigitGroupingIterator aGrouping( 
pFormatter->GetLocaleData()->getDigitGrouping());
+    utl::DigitGroupingIterator aGrouping( 
mrCurrentLanguageData.GetLocaleData()->getDigitGrouping());
     // Match ,### in {3} or ,## in {3,2}
     /* FIXME: this could be refined to match ,## in {3,2} only if ,##,## or
      * ,##,### and to match ,### in {3,2} only if it's the last. However,
@@ -580,7 +578,7 @@ short ImpSvNumberInputScan::GetLogical( std::u16string_view 
rString ) const
 {
     short res;
 
-    const ImpSvNumberformatScan* pFS = pFormatter->GetFormatScanner();
+    const ImpSvNumberformatScan* pFS = 
mrCurrentLanguageData.GetFormatScanner();
     if ( rString == pFS->GetTrueString() )
     {
         res = 1;
@@ -611,7 +609,7 @@ short ImpSvNumberInputScan::GetMonth( const OUString& 
rString, sal_Int32& nPos )
         {
             InitText();
         }
-        sal_Int16 nMonths = 
pFormatter->GetCalendar()->getNumberOfMonthsInYear();
+        sal_Int16 nMonths = 
mrCurrentLanguageData.GetCalendar()->getNumberOfMonthsInYear();
         for ( sal_Int16 i = 0; i < nMonths; i++ )
         {
             if ( bScanGenitiveMonths && StringContainsWord( 
pUpperGenitiveMonthText[i], rString, nPos ) )
@@ -650,7 +648,7 @@ short ImpSvNumberInputScan::GetMonth( const OUString& 
rString, sal_Int32& nPos )
                 res = sal::static_int_cast< short >(-(i+1)); // negative
                 break;  // for
             }
-            else if (i == 2 && pFormatter->GetLanguageTag().getLanguage() == 
"de")
+            else if (i == 2 && 
mrCurrentLanguageData.GetLanguageTag().getLanguage() == "de")
             {
                 if (pUpperAbbrevMonthText[i] == u"M\u00C4R" && 
StringContainsWord( "MRZ", rString, nPos))
                 {   // Accept MRZ for MÄR
@@ -689,7 +687,7 @@ short ImpSvNumberInputScan::GetMonth( const OUString& 
rString, sal_Int32& nPos )
             // Brutal hack for German locales that know "Januar" or "Jänner".
             /* TODO: add alternative month names to locale data? if there are
              * more languages... */
-            const LanguageTag& rLanguageTag = pFormatter->GetLanguageTag();
+            const LanguageTag& rLanguageTag = 
mrCurrentLanguageData.GetLanguageTag();
             if (rLanguageTag.getLanguage() == "de")
             {
                 if (rLanguageTag.getCountry() == "AT")
@@ -744,7 +742,7 @@ int ImpSvNumberInputScan::GetDayOfWeek( const OUString& 
rString, sal_Int32& nPos
         {
             InitText();
         }
-        sal_Int16 nDays = pFormatter->GetCalendar()->getNumberOfDaysInWeek();
+        sal_Int16 nDays = 
mrCurrentLanguageData.GetCalendar()->getNumberOfDaysInWeek();
         for ( sal_Int16 i = 0; i < nDays; i++ )
         {
             if ( StringContainsWord( pUpperDayText[i], rString, nPos ) )
@@ -778,8 +776,8 @@ bool ImpSvNumberInputScan::GetCurrency( const OUString& 
rString, sal_Int32& nPos
         if ( !aUpperCurrSymbol.getLength() )
         {   // If no format specified the currency of the currently active 
locale.
             LanguageType eLang = (mpFormat ? mpFormat->GetLanguage() :
-                    
pFormatter->GetLocaleData()->getLanguageTag().getLanguageType());
-            aUpperCurrSymbol = pFormatter->GetCharClass()->uppercase(
+                    
mrCurrentLanguageData.GetLocaleData()->getLanguageTag().getLanguageType());
+            aUpperCurrSymbol = mrCurrentLanguageData.GetCharClass()->uppercase(
                 SvNumberFormatter::GetCurrencyEntry( eLang ).GetSymbol() );
         }
         if ( StringContains( aUpperCurrSymbol, rString, nPos ) )
@@ -794,7 +792,7 @@ bool ImpSvNumberInputScan::GetCurrency( const OUString& 
rString, sal_Int32& nPos
             {
                 if ( aSymbol.getLength() <= rString.getLength() - nPos )
                 {
-                    aSymbol = pFormatter->GetCharClass()->uppercase(aSymbol);
+                    aSymbol = 
mrCurrentLanguageData.GetCharClass()->uppercase(aSymbol);
                     if ( StringContains( aSymbol, rString, nPos ) )
                     {
                         nPos = nPos + aSymbol.getLength();
@@ -826,8 +824,8 @@ bool ImpSvNumberInputScan::GetTimeAmPm( const OUString& 
rString, sal_Int32& nPos
 
     if ( rString.getLength() > nPos )
     {
-        const CharClass* pChr = pFormatter->GetCharClass();
-        const LocaleDataWrapper* pLoc = pFormatter->GetLocaleData();
+        const CharClass* pChr = mrCurrentLanguageData.GetCharClass();
+        const LocaleDataWrapper* pLoc = mrCurrentLanguageData.GetLocaleData();
         if ( StringContains( pChr->uppercase( pLoc->getTimeAM() ), rString, 
nPos ) )
         {
             nAmPm = 1;
@@ -855,13 +853,13 @@ inline bool ImpSvNumberInputScan::GetDecSep( 
std::u16string_view rString, sal_In
 {
     if ( static_cast<sal_Int32>(rString.size()) > nPos )
     {
-        const OUString& rSep = pFormatter->GetNumDecimalSep();
+        const OUString& rSep = mrCurrentLanguageData.GetNumDecimalSep();
         if ( o3tl::starts_with(rString.substr(nPos), rSep) )
         {
             nPos = nPos + rSep.getLength();
             return true;
         }
-        const OUString& rSepAlt = pFormatter->GetNumDecimalSepAlt();
+        const OUString& rSepAlt = mrCurrentLanguageData.GetNumDecimalSepAlt();
         if ( !rSepAlt.isEmpty() && o3tl::starts_with(rString.substr(nPos), 
rSepAlt) )
         {
             nPos = nPos + rSepAlt.getLength();
@@ -891,7 +889,7 @@ inline bool ImpSvNumberInputScan::GetTime100SecSep( 
std::u16string_view rString,
         }
         // Even in an otherwise ISO 8601 string be lenient and accept the
         // locale defined separator.
-        const OUString& rSep = pFormatter->GetLocaleData()->getTime100SecSep();
+        const OUString& rSep = 
mrCurrentLanguageData.GetLocaleData()->getTime100SecSep();
         if ( o3tl::starts_with(rString.substr(nPos), rSep))
         {
             nPos = nPos + rSep.getLength();
@@ -1086,7 +1084,7 @@ sal_uInt16 ImpSvNumberInputScan::ImplGetDay( sal_uInt16 
nIndex ) const
 sal_uInt16 ImpSvNumberInputScan::ImplGetMonth( sal_uInt16 nIndex ) const
 {
     // Preset invalid month number
-    sal_uInt16 nRes = pFormatter->GetCalendar()->getNumberOfMonthsInYear();
+    sal_uInt16 nRes = 
mrCurrentLanguageData.GetCalendar()->getNumberOfMonthsInYear();
 
     if (sStrArray[nNums[nIndex]].getLength() <= 2)
     {
@@ -1207,7 +1205,7 @@ bool ImpSvNumberInputScan::IsAcceptableIso8601()
 {
     if (mpFormat && (mpFormat->GetType() & SvNumFormatType::DATE))
     {
-        switch (pFormatter->GetEvalDateFormat())
+        switch (mrCurrentLanguageData.GetEvalDateFormat())
         {
             case NF_EVALDATEFORMAT_INTL:
                 return CanForceToIso8601( GetDateOrder());
@@ -1316,19 +1314,19 @@ bool ImpSvNumberInputScan::IsAcceptedDatePattern( 
sal_uInt16 nStartPatternAt )
     else if (!sDateAcceptancePatterns.hasElements())
     {
         // The current locale is the format's locale, if a format is present.
-        const NfEvalDateFormat eEDF = pFormatter->GetEvalDateFormat();
-        if (!mpFormat || eEDF == NF_EVALDATEFORMAT_FORMAT || 
mpFormat->GetLanguage() == pFormatter->GetLanguage())
+        const NfEvalDateFormat eEDF = 
mrCurrentLanguageData.GetEvalDateFormat();
+        if (!mpFormat || eEDF == NF_EVALDATEFORMAT_FORMAT || 
mpFormat->GetLanguage() == mrCurrentLanguageData.GetIniLanguage())
         {
-            sDateAcceptancePatterns = 
pFormatter->GetLocaleData()->getDateAcceptancePatterns();
+            sDateAcceptancePatterns = 
mrCurrentLanguageData.GetLocaleData()->getDateAcceptancePatterns();
         }
         else
         {
-            OnDemandLocaleDataWrapper& xLocaleData = 
pFormatter->GetOnDemandLocaleDataWrapper(
-                    SvNumberFormatter::InputScannerPrivateAccess());
+            OnDemandLocaleDataWrapper& xLocaleData = 
mrCurrentLanguageData.GetOnDemandLocaleDataWrapper(
+                    SvNFLanguageData::InputScannerPrivateAccess());
             const LanguageTag aSaveLocale( xLocaleData->getLanguageTag() );
             assert(mpFormat->GetLanguage() == aSaveLocale.getLanguageType());  
 // prerequisite
             // Obtain formatter's locale's (e.g. system) patterns.
-            xLocaleData.changeLocale( LanguageTag( pFormatter->GetLanguage()));
+            xLocaleData.changeLocale( LanguageTag( 
mrCurrentLanguageData.GetIniLanguage()));
             const css::uno::Sequence<OUString> aLocalePatterns( 
xLocaleData->getDateAcceptancePatterns());
             // Reset to format's locale.
             xLocaleData.changeLocale( aSaveLocale);
@@ -1365,7 +1363,7 @@ bool ImpSvNumberInputScan::IsAcceptedDatePattern( 
sal_uInt16 nStartPatternAt )
     }
     nDatePatternStart = nStartPatternAt; // remember start particle
 
-    const sal_Int32 nMonthsInYear = 
pFormatter->GetCalendar()->getNumberOfMonthsInYear();
+    const sal_Int32 nMonthsInYear = 
mrCurrentLanguageData.GetCalendar()->getNumberOfMonthsInYear();
 
     for (sal_Int32 nPattern=0; nPattern < sDateAcceptancePatterns.getLength(); 
++nPattern)
     {
@@ -1375,8 +1373,8 @@ bool ImpSvNumberInputScan::IsAcceptedDatePattern( 
sal_uInt16 nStartPatternAt )
             // Ignore a pattern that would match numeric input with decimal
             // separator. It may had been read from configuration or resulted
             // from the locales' patterns concatenation above.
-            if (    rPat[1] == 
pFormatter->GetLocaleData()->getNumDecimalSep().toChar()
-                 || rPat[1] == 
pFormatter->GetLocaleData()->getNumDecimalSepAlt().toChar())
+            if (    rPat[1] == 
mrCurrentLanguageData.GetLocaleData()->getNumDecimalSep().toChar()
+                 || rPat[1] == 
mrCurrentLanguageData.GetLocaleData()->getNumDecimalSepAlt().toChar())
             {
                 SAL_WARN("svl.numbers", "ignoring date acceptance pattern with 
decimal separator ambiguity: " << rPat);
                 continue;   // for, next pattern
@@ -1660,7 +1658,7 @@ DateOrder ImpSvNumberInputScan::GetDateOrder( bool 
bFromFormatIfNoPattern )
         if (bFromFormatIfNoPattern && mpFormat)
             return mpFormat->GetDateOrder();
         else
-            return pFormatter->GetLocaleData()->getDateOrder();
+            return mrCurrentLanguageData.GetLocaleData()->getDateOrder();
     }
     switch ((nOrder & 0xff0000) >> 16)
     {
@@ -1726,7 +1724,7 @@ DateOrder ImpSvNumberInputScan::GetDateOrder( bool 
bFromFormatIfNoPattern )
         }
     }
     SAL_WARN( "svl.numbers", "ImpSvNumberInputScan::GetDateOrder: undefined, 
falling back to locale's default");
-    return pFormatter->GetLocaleData()->getDateOrder();
+    return mrCurrentLanguageData.GetLocaleData()->getDateOrder();
 }
 
 LongDateOrder ImpSvNumberInputScan::GetMiddleMonthLongDateOrder( bool 
bFormatTurn,
@@ -1782,7 +1780,7 @@ bool ImpSvNumberInputScan::GetDateRef( double& fDays, 
sal_uInt16& nCounter )
     int nFormatOrder;
     if ( mpFormat && (mpFormat->GetType() & SvNumFormatType::DATE) )
     {
-        eEDF = pFormatter->GetEvalDateFormat();
+        eEDF = mrCurrentLanguageData.GetEvalDateFormat();
         switch ( eEDF )
         {
         case NF_EVALDATEFORMAT_INTL :
@@ -1805,8 +1803,8 @@ bool ImpSvNumberInputScan::GetDateRef( double& fDays, 
sal_uInt16& nCounter )
     }
     bool res = true;
 
-    const LocaleDataWrapper* pLoc = pFormatter->GetLocaleData();
-    CalendarWrapper* pCal = pFormatter->GetCalendar();
+    const LocaleDataWrapper* pLoc = mrCurrentLanguageData.GetLocaleData();
+    CalendarWrapper* pCal = mrCurrentLanguageData.GetCalendar();
     for ( int nTryOrder = 1; nTryOrder <= nFormatOrder; nTryOrder++ )
     {
         pCal->setGregorianDateTime( Date( Date::SYSTEM ) ); // today
@@ -2459,7 +2457,7 @@ bool ImpSvNumberInputScan::ScanStartString( const 
OUString& rString )
             if (nDayOfWeek < 0)
             {
                 SkipChar( '.', rString, nTempPos ); // abbreviated
-                SkipString( 
pFormatter->GetLocaleData()->getLongDateDayOfWeekSep(), rString, nTempPos );
+                SkipString( 
mrCurrentLanguageData.GetLocaleData()->getLongDateDayOfWeekSep(), rString, 
nTempPos );
                 SkipBlanks( rString, nTempPos);
                 short nTempTempMonth = GetMonth( rString, nTempPos);
                 if (nTempTempMonth)
@@ -2513,7 +2511,7 @@ bool ImpSvNumberInputScan::ScanStartString( const 
OUString& rString )
                     {
                         // full long name
                         SkipBlanks(rString, nPos);
-                        SkipString( 
pFormatter->GetLocaleData()->getLongDateDayOfWeekSep(), rString, nPos );
+                        SkipString( 
mrCurrentLanguageData.GetLocaleData()->getLongDateDayOfWeekSep(), rString, nPos 
);
                     }
                     SkipBlanks(rString, nPos);
                     nTempMonth = GetMonth(rString, nPos);
@@ -2698,12 +2696,12 @@ bool ImpSvNumberInputScan::ScanMidString( const 
OUString& rString, sal_uInt16 nS
         nThousand++;
     }
 
-    const LocaleDataWrapper* pLoc = pFormatter->GetLocaleData();
+    const LocaleDataWrapper* pLoc = mrCurrentLanguageData.GetLocaleData();
     bool bSignedYear = false;
     bool bDate = SkipDatePatternSeparator( nStringPos, nPos, bSignedYear);   
// 12/31  31.12.  12/31/1999  31.12.1999
     if (!bDate)
     {
-        const OUString& rDate = pFormatter->GetDateSep();
+        const OUString& rDate = mrCurrentLanguageData.GetDateSep();
         SkipBlanks(rString, nPos);
         bDate = SkipString( rDate, rString, nPos);      // 10.  10-  10/
     }
@@ -3087,7 +3085,7 @@ bool ImpSvNumberInputScan::ScanEndString( const OUString& 
rString )
         eScannedType = SvNumFormatType::PERCENT;
     }
 
-    const LocaleDataWrapper* pLoc = pFormatter->GetLocaleData();
+    const LocaleDataWrapper* pLoc = mrCurrentLanguageData.GetLocaleData();
     const OUString& rTime = pLoc->getTimeSep();
     if ( SkipString(rTime, rString, nPos) )         // 10:
     {
@@ -3120,7 +3118,7 @@ bool ImpSvNumberInputScan::ScanEndString( const OUString& 
rString )
     bool bDate = SkipDatePatternSeparator( nStringsCnt-1, nPos, bSignedYear);  
 // 12/31  31.12.  12/31/1999  31.12.1999
     if (!bDate)
     {
-        const OUString& rDate = pFormatter->GetDateSep();
+        const OUString& rDate = mrCurrentLanguageData.GetDateSep();
         bDate = SkipString( rDate, rString, nPos);      // 10.  10-  10/
     }
     if (bDate && bSignDetectedHere)
@@ -3234,7 +3232,7 @@ bool ImpSvNumberInputScan::ScanEndString( const OUString& 
rString )
     {
         // day of week is just parsed away
         sal_Int32 nOldPos = nPos;
-        const OUString& rSep = 
pFormatter->GetLocaleData()->getLongDateDayOfWeekSep();
+        const OUString& rSep = 
mrCurrentLanguageData.GetLocaleData()->getLongDateDayOfWeekSep();
         if ( StringContains( rSep, rString, nPos ) )
         {
             nPos = nPos + rSep.getLength();
@@ -3292,7 +3290,7 @@ bool ImpSvNumberInputScan::ScanStringNumFor( const 
OUString& rString,       // S
     {
         return false;
     }
-    const ::utl::TransliterationWrapper* pTransliteration = 
pFormatter->GetTransliteration();
+    const ::utl::TransliterationWrapper* pTransliteration = 
mrCurrentLanguageData.GetTransliteration();
     const OUString* pStr;
     OUString aString( rString );
     bool bFound = false;
@@ -3445,7 +3443,7 @@ bool ImpSvNumberInputScan::IsNumberFormatMain( const 
OUString& rString,        /
             if (eSetType == SvNumFormatType::FRACTION)  // Fraction 1 = 1/1
             {
                 if (i >= nStringsCnt || // no end string nor decimal separator
-                    pFormatter->IsDecimalSep( sStrArray[i]))
+                    mrCurrentLanguageData.IsDecimalSep( sStrArray[i]))
                 {
                     eScannedType = SvNumFormatType::FRACTION;
                     nMatchedAllStrings &= ~nMatchedVirgin;
@@ -3468,7 +3466,7 @@ bool ImpSvNumberInputScan::IsNumberFormatMain( const 
OUString& rString,        /
                 eScannedType == SvNumFormatType::UNDEFINED &&   // not date or 
currency
                 nDecPos == 0 &&             // no previous decimal separator
                 (i >= nStringsCnt ||        // no end string nor decimal 
separator
-                 pFormatter->IsDecimalSep( sStrArray[i]))
+                 mrCurrentLanguageData.IsDecimalSep( sStrArray[i]))
                 )
             {
                 eScannedType = SvNumFormatType::FRACTION;
@@ -3742,8 +3740,8 @@ bool ImpSvNumberInputScan::MatchedReturn()
 void ImpSvNumberInputScan::InitText()
 {
     sal_Int32 j, nElems;
-    const CharClass* pChrCls = pFormatter->GetCharClass();
-    const CalendarWrapper* pCal = pFormatter->GetCalendar();
+    const CharClass* pChrCls = mrCurrentLanguageData.GetCharClass();
+    const CalendarWrapper* pCal = mrCurrentLanguageData.GetCalendar();
 
     pUpperMonthText.reset();
     pUpperAbbrevMonthText.reset();
@@ -3816,13 +3814,13 @@ void ImpSvNumberInputScan::InitText()
  */
 void ImpSvNumberInputScan::ChangeIntl()
 {
-    sal_Unicode cDecSep = pFormatter->GetNumDecimalSep()[0];
+    sal_Unicode cDecSep = mrCurrentLanguageData.GetNumDecimalSep()[0];
     bDecSepInDateSeps = ( cDecSep == '-' ||
-                          cDecSep == pFormatter->GetDateSep()[0] );
+                          cDecSep == mrCurrentLanguageData.GetDateSep()[0] );
     if (!bDecSepInDateSeps)
     {
-        sal_Unicode cDecSepAlt = pFormatter->GetNumDecimalSepAlt().toChar();
-        bDecSepInDateSeps = cDecSepAlt && (cDecSepAlt == '-' || cDecSepAlt == 
pFormatter->GetDateSep()[0]);
+        sal_Unicode cDecSepAlt = 
mrCurrentLanguageData.GetNumDecimalSepAlt().toChar();
+        bDecSepInDateSeps = cDecSepAlt && (cDecSepAlt == '-' || cDecSepAlt == 
mrCurrentLanguageData.GetDateSep()[0]);
     }
     bTextInitialized = false;
     aUpperCurrSymbol.clear();
@@ -3854,6 +3852,7 @@ bool ImpSvNumberInputScan::IsNumberFormat( const 
OUString& rString,         // s
                                            SvNumFormatType& F_Type,         // 
IN: old type, OUT: new type
                                            double& fOutNumber,              // 
OUT: number if convertible
                                            const SvNumberformat* pFormat,   // 
maybe a number format to match against
+                                           const NativeNumberWrapper* pNatNum,
                                            SvNumInputOptions eInputOptions )
 {
     bool res; // return value
@@ -3871,9 +3870,9 @@ bool ImpSvNumberInputScan::IsNumberFormat( const 
OUString& rString,         // s
     else
     {
         // NoMoreUpperNeeded, all comparisons on UpperCase
-        OUString aString = pFormatter->GetCharClass()->uppercase( rString );
+        OUString aString = mrCurrentLanguageData.GetCharClass()->uppercase( 
rString );
         // convert native number to ASCII if necessary
-        TransformInput(pFormatter, aString);
+        TransformInput(pNatNum, mrCurrentLanguageData, aString);
         res = IsNumberFormatMain( aString, pFormat );
     }
 
diff --git a/svl/source/numbers/zforfind.hxx b/svl/source/numbers/zforfind.hxx
index dea732b93297..fbcb615926bd 100644
--- a/svl/source/numbers/zforfind.hxx
+++ b/svl/source/numbers/zforfind.hxx
@@ -28,7 +28,7 @@
 #include <optional>
 
 class SvNumberformat;
-class SvNumberFormatter;
+class SvNFLanguageData;
 enum class SvNumFormatType : sal_Int16;
 
 #define SV_MAX_COUNT_INPUT_STRINGS  20    // max count of substrings in input 
scanner
@@ -36,7 +36,7 @@ enum class SvNumFormatType : sal_Int16;
 class ImpSvNumberInputScan
 {
 public:
-    explicit ImpSvNumberInputScan( SvNumberFormatter* pFormatter );
+    explicit ImpSvNumberInputScan(SvNFLanguageData& rCurrentLanguage);
     ~ImpSvNumberInputScan();
 
 /*!*/   void ChangeIntl();                      // MUST be called if language 
changes
@@ -51,6 +51,7 @@ public:
                          SvNumFormatType& F_Type,            /// format type 
(in + out)
                          double& fOutNumber,                 /// value 
determined (out)
                          const SvNumberformat* pFormat,      /// number format 
to which compare against
+                         const NativeNumberWrapper* pNatNum,
                          SvNumInputOptions eInputOptions);
 
     /// after IsNumberFormat: get decimal position
@@ -76,7 +77,7 @@ public:
     bool HasIso8601Tsep() const { return bIso8601Tsep; }
 
 private:
-    SvNumberFormatter*  pFormatter;
+    SvNFLanguageData& mrCurrentLanguageData;
     const SvNumberformat* mpFormat;                            //* The format 
to compare against, if any
     std::unique_ptr<OUString[]> pUpperMonthText;               //* Array of 
month names, uppercase
     std::unique_ptr<OUString[]> pUpperAbbrevMonthText;         //* Array of 
month names, abbreviated, uppercase
diff --git a/svl/source/numbers/zforlist.cxx b/svl/source/numbers/zforlist.cxx
index ace560bad560..c98f94a11353 100644
--- a/svl/source/numbers/zforlist.cxx
+++ b/svl/source/numbers/zforlist.cxx
@@ -271,22 +271,29 @@ sal_uInt16 SvNumberFormatter::nSystemCurrencyPosition = 0;
 const sal_uInt16 SvNumberFormatter::UNLIMITED_PRECISION   = 
::std::numeric_limits<sal_uInt16>::max();
 const sal_uInt16 SvNumberFormatter::INPUTSTRING_PRECISION = 
::std::numeric_limits<sal_uInt16>::max()-1;
 
-SvNumberFormatter::SvNumberFormatter( const Reference< XComponentContext >& 
rxContext,
-                                      LanguageType eLang )
-    : m_xContext( rxContext )
-    , IniLnge(eLang != LANGUAGE_DONTKNOW ? eLang : UNKNOWN_SUBSTITUTE)
-    , ActLnge(IniLnge)
-    , maLanguageTag(IniLnge)
-    , MaxCLOffset(0)
-    , nDefaultSystemCurrencyFormat(NUMBERFORMAT_ENTRY_NOT_FOUND)
+void SvNFEngine::ChangeIntl(SvNFLanguageData& rCurrentLanguage, LanguageType 
eLnge)
+{
+    rCurrentLanguage.ChangeIntl(eLnge);
+}
+
+void SvNFEngine::ChangeNullDate(SvNFLanguageData& rCurrentLanguage, sal_uInt16 
nDay, sal_uInt16 nMonth, sal_Int16 nYear)
+{
+    rCurrentLanguage.pFormatScanner->ChangeNullDate(nDay, nMonth, nYear);
+    rCurrentLanguage.pStringScanner->ChangeNullDate(nDay, nMonth, nYear);
+}
+
+SvNFLanguageData::SvNFLanguageData(const Reference<XComponentContext>& 
rxContext, LanguageType eLang,
+                                   const SvNumberFormatter& rColorCallback)
+    : xContext(rxContext)
+    , IniLnge(eLang)
+    , ActLnge(eLang)
+    , aLanguageTag(eLang)
     , eEvalDateFormat(NF_EVALDATEFORMAT_INTL)
-    , bNoZero(false)
 {
-    xCharClass.changeLocale( m_xContext, maLanguageTag );
-    xLocaleData.init( m_xContext, maLanguageTag );
-    xCalendar.init( m_xContext, maLanguageTag.getLocale() );
-    xTransliteration.init( m_xContext, IniLnge );
-    xNatNum.init( m_xContext );
+    xCharClass.changeLocale(xContext, aLanguageTag);
+    xLocaleData.init(xContext, aLanguageTag);
+    xCalendar.init(xContext, aLanguageTag.getLocale());
+    xTransliteration.init(xContext, ActLnge);
 
     // cached locale data items
     const LocaleDataWrapper* pLoc = GetLocaleData();
@@ -295,43 +302,99 @@ SvNumberFormatter::SvNumberFormatter( const Reference< 
XComponentContext >& rxCo
     aThousandSep = pLoc->getNumThousandSep();
     aDateSep = pLoc->getDateSep();
 
-    pStringScanner.reset( new ImpSvNumberInputScan( this ) );
-    pFormatScanner.reset( new ImpSvNumberformatScan( this ) );
-    ImpGenerateFormats( 0, false );     // 0 .. 999 for initialized language 
formats
+    pStringScanner.reset(new ImpSvNumberInputScan(*this));
+    pFormatScanner.reset(new ImpSvNumberformatScan(*this, rColorCallback));
+}
 
-    ::osl::MutexGuard aGuard( GetGlobalMutex() );
-    GetFormatterRegistry().Insert( this );
+SvNFLanguageData::SvNFLanguageData(const SvNFLanguageData& rOther)
+    : xContext(rOther.xContext)
+    , IniLnge(rOther.IniLnge)
+    , ActLnge(rOther.ActLnge)
+    , aLanguageTag(rOther.aLanguageTag)
+    , aDecimalSep(rOther.aDecimalSep)
+    , aDecimalSepAlt(rOther.aDecimalSepAlt)
+    , aThousandSep(rOther.aThousandSep)
+    , aDateSep(rOther.aDateSep)
+    , eEvalDateFormat(rOther.eEvalDateFormat)
+{
+    xCharClass.changeLocale(xContext, aLanguageTag);
+    xLocaleData.init(xContext, aLanguageTag);
+    xCalendar.init(xContext, aLanguageTag.getLocale());
+    xTransliteration.init(xContext, ActLnge);
+
+    pStringScanner.reset(new ImpSvNumberInputScan(*this));
+    pFormatScanner.reset(new ImpSvNumberformatScan(*this, 
rOther.pFormatScanner->getColorCallback()));
 }
 
-SvNumberFormatter::~SvNumberFormatter()
+SvNFLanguageData::~SvNFLanguageData()
 {
-    {
-        ::osl::MutexGuard aGuard( GetGlobalMutex() );
-        pFormatterRegistry->Remove( this );
-        if ( !pFormatterRegistry->Count() )
-        {
-            delete pFormatterRegistry;
-            pFormatterRegistry = nullptr;
-        }
-    }
+}
 
-    aFTable.clear();
-    ClearMergeTable();
+const LocaleDataWrapper* SvNFLanguageData::GetLocaleData() const { return 
xLocaleData.get(); }
+
+const CharClass* SvNFLanguageData::GetCharClass() const { return 
xCharClass.get(); }
+
+CalendarWrapper* SvNFLanguageData::GetCalendar() const { return 
xCalendar.get(); }
+
+const ::utl::TransliterationWrapper* SvNFLanguageData::GetTransliteration() 
const
+{
+    return xTransliteration.get();
 }
 
+const LanguageTag& SvNFLanguageData::GetLanguageTag() const { return 
aLanguageTag; }
 
-void SvNumberFormatter::ChangeIntl(LanguageType eLnge)
+const ImpSvNumberformatScan* SvNFLanguageData::GetFormatScanner() const { 
return pFormatScanner.get(); }
+
+const OUString& SvNFLanguageData::GetNumDecimalSep() const { return 
aDecimalSep; }
+
+const OUString& SvNFLanguageData::GetNumDecimalSepAlt() const { return 
aDecimalSepAlt; }
+
+const OUString& SvNFLanguageData::GetNumThousandSep() const { return 
aThousandSep; }
+
+const OUString& SvNFLanguageData::GetDateSep() const { return aDateSep; }
+
+bool SvNFLanguageData::IsDecimalSep( std::u16string_view rStr ) const
+{
+    if (rStr == GetNumDecimalSep())
+        return true;
+    if (GetNumDecimalSepAlt().isEmpty())
+        return false;
+    return rStr == GetNumDecimalSepAlt();
+}
+
+OUString SvNFLanguageData::GetLangDecimalSep( LanguageType nLang ) const
+{
+    if (nLang == ActLnge)
+    {
+        return GetNumDecimalSep();
+    }
+    OUString aRet;
+    LanguageType eSaveLang = xLocaleData.getCurrentLanguage();
+    if (nLang == eSaveLang)
+    {
+        aRet = xLocaleData->getNumDecimalSep();
+    }
+    else
+    {
+        LanguageTag aSaveLocale( xLocaleData->getLanguageTag() );
+        const_cast<SvNFLanguageData*>(this)->xLocaleData.changeLocale( 
LanguageTag( nLang));
+        aRet = xLocaleData->getNumDecimalSep();
+        const_cast<SvNFLanguageData*>(this)->xLocaleData.changeLocale( 
aSaveLocale );
+    }
+    return aRet;
+}
+
+void SvNFLanguageData::ChangeIntl(LanguageType eLnge)
 {
-    ::osl::MutexGuard aGuard( GetInstanceMutex() );
     if (ActLnge == eLnge)
         return;
 
     ActLnge = eLnge;
 
-    maLanguageTag.reset( eLnge );
-    xCharClass.changeLocale( m_xContext, maLanguageTag );
-    xLocaleData.changeLocale( maLanguageTag );
-    xCalendar.changeLocale( maLanguageTag.getLocale() );
+    aLanguageTag.reset( eLnge );
+    xCharClass.changeLocale( xContext, aLanguageTag );
+    xLocaleData.changeLocale( aLanguageTag );
+    xCalendar.changeLocale( aLanguageTag.getLocale() );
     xTransliteration.changeLocale( eLnge );
 
     // cached locale data items, initialize BEFORE calling ChangeIntl below
@@ -345,6 +408,43 @@ void SvNumberFormatter::ChangeIntl(LanguageType eLnge)
     pStringScanner->ChangeIntl();
 }
 
+SvNumberFormatter::SvNumberFormatter( const Reference< XComponentContext >& 
rxContext,
+                                      LanguageType eLang )
+    : m_xContext( rxContext )
+    , IniLnge(eLang != LANGUAGE_DONTKNOW ? eLang : UNKNOWN_SUBSTITUTE)
+    , m_aRWPolicy(SvNFEngine::GetRWPolicy(m_aFormatData))
+    , m_aCurrentLanguage(rxContext, IniLnge, *this)
+{
+    xNatNum.init( m_xContext );
+
+    // 0 .. 999 for initialized language formats
+    m_aFormatData.ImpGenerateFormats(m_aCurrentLanguage, GetNatNum(), 0, 
false);
+
+    ::osl::MutexGuard aGuard( GetGlobalMutex() );
+    GetFormatterRegistry().Insert( this );
+}
+
+SvNumberFormatter::~SvNumberFormatter()
+{
+    {
+        ::osl::MutexGuard aGuard( GetGlobalMutex() );
+        pFormatterRegistry->Remove( this );
+        if ( !pFormatterRegistry->Count() )
+        {
+            delete pFormatterRegistry;
+            pFormatterRegistry = nullptr;
+        }
+    }
+
+    m_aFormatData.aFTable.clear();
+    ClearMergeTable();
+}
+
+void SvNumberFormatter::ChangeIntl(LanguageType eLnge)
+{
+    ::osl::MutexGuard aGuard( GetInstanceMutex() );
+    SvNFEngine::ChangeIntl(m_aCurrentLanguage, eLnge);
+}
 
 // static
 ::osl::Mutex& SvNumberFormatter::GetGlobalMutex()
@@ -393,44 +493,53 @@ void SvNumberFormatter::ChangeNullDate(sal_uInt16 nDay,
                                        sal_Int16 nYear)
 {
     ::osl::MutexGuard aGuard( GetInstanceMutex() );
-    pFormatScanner->ChangeNullDate(nDay, nMonth, nYear);
-    pStringScanner->ChangeNullDate(nDay, nMonth, nYear);
+    SvNFEngine::ChangeNullDate(m_aCurrentLanguage, nDay, nMonth, nYear);
+}
+
+const Date& SvNFLanguageData::GetNullDate() const
+{
+    return pFormatScanner->GetNullDate();
+}
+
+void SvNFLanguageData::ChangeStandardPrec(short nPrec)
+{
+    pFormatScanner->ChangeStandardPrec(nPrec);
 }
 
 const Date& SvNumberFormatter::GetNullDate() const
 {
     ::osl::MutexGuard aGuard( GetInstanceMutex() );
-    return pFormatScanner->GetNullDate();
+    return m_aCurrentLanguage.GetNullDate();
 }
 
 void SvNumberFormatter::ChangeStandardPrec(short nPrec)
 {
     ::osl::MutexGuard aGuard( GetInstanceMutex() );
-    pFormatScanner->ChangeStandardPrec(nPrec);
+    m_aCurrentLanguage.ChangeStandardPrec(nPrec);
 }
 
 void SvNumberFormatter::SetNoZero(bool bNZ)
 {
     ::osl::MutexGuard aGuard( GetInstanceMutex() );
-    bNoZero = bNZ;
+    m_aFormatData.SetNoZero(bNZ);
 }
 
 sal_uInt16 SvNumberFormatter::GetStandardPrec() const
 {
     ::osl::MutexGuard aGuard( GetInstanceMutex() );
-    return pFormatScanner->GetStandardPrec();
+    return m_aCurrentLanguage.pFormatScanner->GetStandardPrec();
 }
 
 bool SvNumberFormatter::GetNoZero() const
 {
     ::osl::MutexGuard aGuard( GetInstanceMutex() );
-    return bNoZero;
+    return m_aFormatData.GetNoZero();
 }
 
 void SvNumberFormatter::ReplaceSystemCL( LanguageType eOldLanguage )
 {
-    sal_uInt32 nCLOffset = ImpGetCLOffset( LANGUAGE_SYSTEM );
-    if ( nCLOffset > MaxCLOffset )
+    sal_uInt32 nCLOffset = m_aFormatData.ImpGetCLOffset( LANGUAGE_SYSTEM );
+    if ( nCLOffset > m_aFormatData.MaxCLOffset )
     {
         return ;    // no SYSTEM entries to replace
     }
@@ -439,30 +548,30 @@ void SvNumberFormatter::ReplaceSystemCL( LanguageType 
eOldLanguage )
     sal_uInt32 nKey;
 
     // remove old builtin formats
-    auto it = aFTable.find( nCLOffset );
-    while ( it != aFTable.end() && (nKey = it->first) >= nCLOffset && nKey <= 
nMaxBuiltin )
+    auto it = m_aFormatData.aFTable.find( nCLOffset );
+    while ( it != m_aFormatData.aFTable.end() && (nKey = it->first) >= 
nCLOffset && nKey <= nMaxBuiltin )
     {
-        it = aFTable.erase(it);
+        it = m_aFormatData.aFTable.erase(it);
     }
 
     // move additional and user defined to temporary table
     SvNumberFormatTable aOldTable;
-    while ( it != aFTable.end() && (nKey = it->first) >= nCLOffset && nKey < 
nNextCL )
+    while ( it != m_aFormatData.aFTable.end() && (nKey = it->first) >= 
nCLOffset && nKey < nNextCL )
     {
         aOldTable[ nKey ] = it->second.release();
-        it = aFTable.erase(it);
+        it = m_aFormatData.aFTable.erase(it);
     }
 
     // generate new old builtin formats
-    // reset ActLnge otherwise ChangeIntl() wouldn't switch if already 
LANGUAGE_SYSTEM
-    ActLnge = LANGUAGE_DONTKNOW;
+    // reset m_aCurrentLanguage.ActLnge otherwise ChangeIntl() wouldn't switch 
if already LANGUAGE_SYSTEM
+    m_aCurrentLanguage.ActLnge = LANGUAGE_DONTKNOW;
     ChangeIntl( LANGUAGE_SYSTEM );
-    ImpGenerateFormats( nCLOffset, true );
+    m_aFormatData.ImpGenerateFormats(m_aCurrentLanguage, GetNatNum(), 
nCLOffset, true);
 
     // convert additional and user defined from old system to new system
-    SvNumberformat* pStdFormat = GetFormatEntry( nCLOffset + ZF_STANDARD );
+    SvNumberformat* pStdFormat = m_aFormatData.GetFormatEntry( nCLOffset + 
ZF_STANDARD );
     sal_uInt32 nLastKey = nMaxBuiltin;
-    pFormatScanner->SetConvertMode( eOldLanguage, LANGUAGE_SYSTEM, true , 
true);
+    m_aCurrentLanguage.pFormatScanner->SetConvertMode( eOldLanguage, 
LANGUAGE_SYSTEM, true , true);
     while ( !aOldTable.empty() )
     {
         nKey = aOldTable.begin()->first;
@@ -480,8 +589,8 @@ void SvNumberFormatter::ReplaceSystemCL( LanguageType 
eOldLanguage )
         LanguageType eLge = eOldLanguage;   // ConvertMode changes this
         bool bCheck = false;
         sal_Int32 nCheckPos = -1;
-        std::unique_ptr<SvNumberformat> pNewEntry(new SvNumberformat( aString, 
pFormatScanner.get(),
-                                                                      
pStringScanner.get(), nCheckPos, eLge ));
+        std::unique_ptr<SvNumberformat> pNewEntry(new SvNumberformat( aString, 
m_aCurrentLanguage.pFormatScanner.get(),
+                                                                      
m_aCurrentLanguage.pStringScanner.get(), GetNatNum(), nCheckPos, eLge ));
         if ( nCheckPos == 0 )
         {
             SvNumFormatType eCheckType = pNewEntry->GetType();
@@ -494,14 +603,14 @@ void SvNumberFormatter::ReplaceSystemCL( LanguageType 
eOldLanguage )
                 pNewEntry->SetType( SvNumFormatType::DEFINED );
             }
 
-            if ( aFTable.emplace( nKey, std::move(pNewEntry) ).second )
+            if ( m_aFormatData.aFTable.emplace( nKey, std::move(pNewEntry) 
).second )
             {
                 bCheck = true;
             }
         }
         DBG_ASSERT( bCheck, "SvNumberFormatter::ReplaceSystemCL: couldn't 
convert" );
     }
-    pFormatScanner->SetConvertMode(false);
+    m_aCurrentLanguage.pFormatScanner->SetConvertMode(false);
     pStdFormat->SetLastInsertKey( sal_uInt16(nLastKey - nCLOffset), 
SvNumberformat::FormatterPrivateAccess() );
 
     // append new system additional formats
@@ -514,72 +623,43 @@ const css::uno::Reference<css::uno::XComponentContext>& 
SvNumberFormatter::GetCo
     return m_xContext;
 }
 
-const ImpSvNumberformatScan* SvNumberFormatter::GetFormatScanner() const { 
return pFormatScanner.get(); }
-
-const LanguageTag& SvNumberFormatter::GetLanguageTag() const { return 
maLanguageTag; }
-
-const ::utl::TransliterationWrapper* SvNumberFormatter::GetTransliteration() 
const
-{
-    return xTransliteration.get();
-}
-
-const CharClass* SvNumberFormatter::GetCharClass() const { return 
xCharClass.get(); }
-
-const LocaleDataWrapper* SvNumberFormatter::GetLocaleData() const { return 
xLocaleData.get(); }
-
-CalendarWrapper* SvNumberFormatter::GetCalendar() const { return 
xCalendar.get(); }
-
 const NativeNumberWrapper* SvNumberFormatter::GetNatNum() const { return 
xNatNum.get(); }
 
-const OUString& SvNumberFormatter::GetNumDecimalSep() const { return 
aDecimalSep; }
-
-const OUString& SvNumberFormatter::GetNumDecimalSepAlt() const { return 
aDecimalSepAlt; }
-
-const OUString& SvNumberFormatter::GetNumThousandSep() const { return 
aThousandSep; }
-
-const OUString& SvNumberFormatter::GetDateSep() const { return aDateSep; }
-
-bool SvNumberFormatter::IsDecimalSep( std::u16string_view rStr ) const
+bool SvNFFormatData::IsTextFormat(sal_uInt32 F_Index) const
 {
-    if (rStr == GetNumDecimalSep())
-        return true;
-    if (GetNumDecimalSepAlt().isEmpty())
-        return false;
-    return rStr == GetNumDecimalSepAlt();
+    const SvNumberformat* pFormat = GetFormatEntry(F_Index);
+    return pFormat && pFormat->IsTextFormat();
 }
 
 bool SvNumberFormatter::IsTextFormat(sal_uInt32 F_Index) const
 {
     ::osl::MutexGuard aGuard( GetInstanceMutex() );
-    const SvNumberformat* pFormat = GetFormatEntry(F_Index);
-
-    return pFormat && pFormat->IsTextFormat();
+    return m_aFormatData.IsTextFormat(F_Index);
 }
 
-bool SvNumberFormatter::PutEntry(OUString& rString,
+bool SvNFFormatData::PutEntry(SvNFLanguageData& rCurrentLanguage,
+                                 const NativeNumberWrapper* pNatNum,
+                                 OUString& rString,
                                  sal_Int32& nCheckPos,
                                  SvNumFormatType& nType,
                                  sal_uInt32& nKey,      // format key
                                  LanguageType eLnge,
                                  bool bReplaceBooleanEquivalent)
 {
-    ::osl::MutexGuard aGuard( GetInstanceMutex() );
     nKey = 0;
     if (rString.isEmpty())                             // empty string
     {
         nCheckPos = 1;                                  // -> Error
         return false;
     }
-    if (eLnge == LANGUAGE_DONTKNOW)
-    {
-        eLnge = IniLnge;
-    }
-    ChangeIntl(eLnge);                                  // change locale if 
necessary
+    eLnge = rCurrentLanguage.ImpResolveLanguage(eLnge);
+    rCurrentLanguage.ChangeIntl(eLnge);                 // change locale if 
necessary
     LanguageType eLge = eLnge;                          // non-const for 
ConvertMode
     bool bCheck = false;
     std::unique_ptr<SvNumberformat> p_Entry(new SvNumberformat(rString,
-                                                               
pFormatScanner.get(),
-                                                               
pStringScanner.get(),
+                                                               
rCurrentLanguage.pFormatScanner.get(),
+                                                               
rCurrentLanguage.pStringScanner.get(),
+                                                               pNatNum,
                                                                nCheckPos,
                                                                eLge,
                                                                
bReplaceBooleanEquivalent));
@@ -598,7 +678,7 @@ bool SvNumberFormatter::PutEntry(OUString& rString,
             nType = SvNumFormatType::DEFINED;
         }
 
-        sal_uInt32 CLOffset = ImpGenerateCL(eLge);  // create new standard 
formats if necessary
+        sal_uInt32 CLOffset = ImpGenerateCL(rCurrentLanguage, pNatNum, eLge);  
// create new standard formats if necessary
 
         nKey = ImpIsEntry(p_Entry->GetFormatstring(),CLOffset, eLge);
         if (nKey == NUMBERFORMAT_ENTRY_NOT_FOUND) // only in not yet present
@@ -624,6 +704,17 @@ bool SvNumberFormatter::PutEntry(OUString& rString,
     return bCheck;
 }
 
+bool SvNumberFormatter::PutEntry(OUString& rString,
+                                 sal_Int32& nCheckPos,
+                                 SvNumFormatType& nType,
+                                 sal_uInt32& nKey,      // format key
+                                 LanguageType eLnge,
+                                 bool bReplaceBooleanEquivalent)
+{
+    ::osl::MutexGuard aGuard( GetInstanceMutex() );
+    return m_aFormatData.PutEntry(m_aCurrentLanguage, GetNatNum(), rString, 
nCheckPos, nType, nKey, eLnge, bReplaceBooleanEquivalent);
+}
+
 bool SvNumberFormatter::PutandConvertEntry(OUString& rString,
                                            sal_Int32& nCheckPos,
                                            SvNumFormatType& nType,
@@ -639,23 +730,23 @@ bool SvNumberFormatter::PutandConvertEntry(OUString& 
rString,
     {
         eNewLnge = IniLnge;
     }
-    pFormatScanner->SetConvertMode(eLnge, eNewLnge, false, bConvertDateOrder);
+    m_aCurrentLanguage.pFormatScanner->SetConvertMode(eLnge, eNewLnge, false, 
bConvertDateOrder);
     bRes = PutEntry(rString, nCheckPos, nType, nKey, eLnge, 
bReplaceBooleanEquivalent);
-    pFormatScanner->SetConvertMode(false);
+    m_aCurrentLanguage.pFormatScanner->SetConvertMode(false);
 
     if (bReplaceBooleanEquivalent && nCheckPos == 0 && nType == 
SvNumFormatType::DEFINED
             && nKey != NUMBERFORMAT_ENTRY_NOT_FOUND)
     {
         // The boolean string formats are always "user defined" without any
         // other type.
-        const SvNumberformat* pEntry = GetFormatEntry(nKey);
+        const SvNumberformat* pEntry = m_aFormatData.GetFormatEntry(nKey);
         if (pEntry && pEntry->GetType() == SvNumFormatType::DEFINED)
         {
             // Replace boolean string format with Boolean in target locale, in
             // case the source strings are the target locale's.
             const OUString aSaveString = rString;
             ChangeIntl(eNewLnge);
-            if (pFormatScanner->ReplaceBooleanEquivalent( rString))
+            if (m_aCurrentLanguage.pFormatScanner->ReplaceBooleanEquivalent( 
rString))
             {
                 const sal_Int32 nSaveCheckPos = nCheckPos;
                 const SvNumFormatType nSaveType = nType;
@@ -693,9 +784,9 @@ bool SvNumberFormatter::PutandConvertEntrySystem(OUString& 
rString,
     {
         eNewLnge = IniLnge;
     }
-    pFormatScanner->SetConvertMode(eLnge, eNewLnge, true, true);
+    m_aCurrentLanguage.pFormatScanner->SetConvertMode(eLnge, eNewLnge, true, 
true);
     bRes = PutEntry(rString, nCheckPos, nType, nKey, eLnge);
-    pFormatScanner->SetConvertMode(false);
+    m_aCurrentLanguage.pFormatScanner->SetConvertMode(false);
     return bRes;
 }
 
@@ -778,7 +869,7 @@ sal_uInt32 SvNumberFormatter::GetIndexPuttingAndConverting( 
OUString & rString,
 void SvNumberFormatter::DeleteEntry(sal_uInt32 nKey)
 {
     ::osl::MutexGuard aGuard( GetInstanceMutex() );
-    aFTable.erase(nKey);
+    m_aFormatData.aFTable.erase(nKey);
 }
 
 void SvNumberFormatter::GetUsedLanguages( std::vector<LanguageType>& rList )
@@ -787,9 +878,9 @@ void SvNumberFormatter::GetUsedLanguages( 
std::vector<LanguageType>& rList )
     rList.clear();
 
     sal_uInt32 nOffset = 0;
-    while (nOffset <= MaxCLOffset)
+    while (nOffset <= m_aFormatData.MaxCLOffset)
     {
-        SvNumberformat* pFormat = GetFormatEntry(nOffset);
+        SvNumberformat* pFormat = m_aFormatData.GetFormatEntry(nOffset);
         if (pFormat)
         {
             rList.push_back( pFormat->GetLanguage() );
@@ -804,7 +895,7 @@ void SvNumberFormatter::FillKeywordTable( NfKeywordTable& 
rKeywords,
 {
     ::osl::MutexGuard aGuard( GetInstanceMutex() );
     ChangeIntl( eLang );
-    const NfKeywordTable & rTable = pFormatScanner->GetKeywords();
+    const NfKeywordTable & rTable = 
m_aCurrentLanguage.pFormatScanner->GetKeywords();
     for ( sal_uInt16 i = 0; i < NF_KEYWORD_ENTRIES_COUNT; ++i )
     {
         rKeywords[i] = rTable[i];
@@ -867,15 +958,15 @@ void SvNumberFormatter::FillKeywordTableForExcel( 
NfKeywordTable& rKeywords )
 }
 
 
-static OUString lcl_buildBooleanStringFormat( SvNumberformat* pEntry )
+static OUString lcl_buildBooleanStringFormat( SvNumberformat* pEntry, const 
NativeNumberWrapper* pNatNum )
 {
     // Build Boolean number format, which needs non-zero and zero subformat
     // codes with TRUE and FALSE strings.
     const Color* pColor = nullptr;
     OUString aFormatStr, aTemp;
-    pEntry->GetOutputString( 1.0, aTemp, &pColor );
+    pEntry->GetOutputString( 1.0, aTemp, &pColor, pNatNum );
     aFormatStr += "\"" + aTemp + "\";\"" + aTemp + "\";\"";
-    pEntry->GetOutputString( 0.0, aTemp, &pColor );
+    pEntry->GetOutputString( 0.0, aTemp, &pColor, pNatNum );
     aFormatStr += aTemp + "\"";
     return aFormatStr;
 }
@@ -896,7 +987,7 @@ OUString SvNumberFormatter::GetFormatStringForExcel( 
sal_uInt32 nKey, const NfKe
             // locales. You can't have both. We could force to English for all
             // locales like below, but Excel would display English strings then
             // even for the system locale matching this locale. YMMV.
-            aFormatStr = lcl_buildBooleanStringFormat( const_cast< 
SvNumberformat* >(pEntry));
+            aFormatStr = lcl_buildBooleanStringFormat( const_cast< 
SvNumberformat* >(pEntry), GetNatNum() );
         }
         else
         {
@@ -932,15 +1023,15 @@ OUString SvNumberFormatter::GetFormatStringForExcel( 
sal_uInt32 nKey, const NfKe
                     // >"VRAI";"VRAI";"FAUX"< recognized as real boolean and
                     // properly converted. Then written as
                     // >"TRUE";"TRUE";"FALSE"<
-                    aFormatStr = lcl_buildBooleanStringFormat( const_cast< 
SvNumberformat* >(pEntry));
+                    aFormatStr = lcl_buildBooleanStringFormat( const_cast< 
SvNumberformat* >(pEntry), GetNatNum() );
                 }
                 else
                 {
-                    // GetLocaleData() returns the current locale's data, so 
switch
+                    // m_aCurrentLanguage.GetLocaleData() returns the current 
locale's data, so switch
                     // before (which doesn't do anything if it was the same 
locale
                     // already).
                     rTempFormatter.ChangeIntl( LANGUAGE_ENGLISH_US);
-                    aFormatStr = pEntry->GetMappedFormatstring( rKeywords, 
*rTempFormatter.GetLocaleData(), nLang,
+                    aFormatStr = pEntry->GetMappedFormatstring( rKeywords, 
*rTempFormatter.m_aCurrentLanguage.GetLocaleData(), nLang,
                             bSystemLanguage);
                 }
             }
@@ -961,7 +1052,7 @@ OUString SvNumberFormatter::GetKeyword( LanguageType 
eLnge, sal_uInt16 nIndex )
 {
     ::osl::MutexGuard aGuard( GetInstanceMutex() );
     ChangeIntl(eLnge);
-    const NfKeywordTable & rTable = pFormatScanner->GetKeywords();
+    const NfKeywordTable & rTable = 
m_aCurrentLanguage.pFormatScanner->GetKeywords();
     if ( nIndex < NF_KEYWORD_ENTRIES_COUNT )
     {
         return rTable[nIndex];
@@ -975,11 +1066,19 @@ OUString SvNumberFormatter::GetStandardName( 
LanguageType eLnge )
 {
     ::osl::MutexGuard aGuard( GetInstanceMutex() );
     ChangeIntl( eLnge );
-    return pFormatScanner->GetStandardName();
+    return m_aCurrentLanguage.pFormatScanner->GetStandardName();
 }
 
+SvNFFormatData::SvNFFormatData()
+    : MaxCLOffset(0)
+    , nDefaultSystemCurrencyFormat(NUMBERFORMAT_ENTRY_NOT_FOUND)
+    , bNoZero(false)
+{
+}
+
+SvNFFormatData::~SvNFFormatData() = default;
 
-sal_uInt32 SvNumberFormatter::ImpGetCLOffset(LanguageType eLnge) const
+sal_uInt32 SvNFFormatData::ImpGetCLOffset(LanguageType eLnge) const
 {
     sal_uInt32 nOffset = 0;
     while (nOffset <= MaxCLOffset)
@@ -994,9 +1093,9 @@ sal_uInt32 SvNumberFormatter::ImpGetCLOffset(LanguageType 
eLnge) const
     return nOffset;
 }
 
-sal_uInt32 SvNumberFormatter::ImpIsEntry(std::u16string_view rString,
-                                         sal_uInt32 nCLOffset,
-                                         LanguageType eLnge) const
+sal_uInt32 SvNFFormatData::ImpIsEntry(std::u16string_view rString,
+                                      sal_uInt32 nCLOffset,
+                                      LanguageType eLnge) const
 {
     sal_uInt32 res = NUMBERFORMAT_ENTRY_NOT_FOUND;
     auto it = aFTable.find( nCLOffset);
-e 
... etc. - the rest is truncated

Reply via email to