include/svl/numformat.hxx       |    9 +----
 svl/source/numbers/zforlist.cxx |   62 +++++++++++++++-------------------------
 2 files changed, 27 insertions(+), 44 deletions(-)

New commits:
commit 72caa6437556d349051b4cf100dda5d2befc4095
Author:     Caolán McNamara <[email protected]>
AuthorDate: Thu Feb 29 12:33:23 2024 +0000
Commit:     Miklos Vajna <[email protected]>
CommitDate: Fri Mar 1 11:59:28 2024 +0100

    SvNumberFormatter::ImpConstruct is only used once by the single ctor
    
    so fold it into the ctor
    
    Change-Id: If063143ef47a8ab293edf3896fb51079d0e0284f
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/164144
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <[email protected]>
    (cherry picked from commit 657631791421eae2c88a89da27bd2c0dc1822175)
    
    there is only the one ctor, so drop misleading "preferred" comment
    
    that suggests there are alternatives to choose from
    
    Change-Id: Ica3367fae93f57f339bdc39b1cd91d47a2c9618e
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/164146
    Tested-by: Caolán McNamara <[email protected]>
    Reviewed-by: Caolán McNamara <[email protected]>
    (cherry picked from commit 023e59d0283614a568362b794bb94a9254401d7e)
    
    if we rearrange, we don't need to create maLanguageTag twice
    
    Change-Id: I2c8ad9999adc406dc850c59b48e49681099dc054
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/164147
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <[email protected]>
    (cherry picked from commit 9fcee419dd368823d842b9c9a032b2213ee24d34)
    
    use member init list
    
    Change-Id: I09dea90e3e3f3fd0a4047b989329a027f788f695
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/164148
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <[email protected]>
    (cherry picked from commit 8f7cb2b7474d877af61ab00f6635aec5cefa3d78)
    
    IniLnge is set during ctor and never changes subsequently
    
    Change-Id: Ie052e32976d9810555c8f1892dab47a7472cdc71
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/164149
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <[email protected]>
    (cherry picked from commit 1245614991654b9d3ddb15f644a689585fd4c9de)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/164185
    Tested-by: Jenkins CollaboraOffice <[email protected]>
    Reviewed-by: Miklos Vajna <[email protected]>

diff --git a/include/svl/numformat.hxx b/include/svl/numformat.hxx
index 0a374f3c3301..6a007d1bd057 100644
--- a/include/svl/numformat.hxx
+++ b/include/svl/numformat.hxx
@@ -53,7 +53,7 @@ public:
      */
     static const sal_uInt16 INPUTSTRING_PRECISION;
 
-    /// Preferred ctor with service manager and language/country enum
+    /// ctor with service manager and language/country enum
     SvNumberFormatter(const css::uno::Reference<css::uno::XComponentContext>& 
rxContext,
                       LanguageType eLang);
 
@@ -573,6 +573,8 @@ public:
 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
@@ -591,8 +593,6 @@ private:
     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
-    LanguageType IniLnge; // Initialized setting language/country
-    LanguageType ActLnge; // Current setting language/country
     NfEvalDateFormat eEvalDateFormat; // DateFormat evaluation
     bool bNoZero; // Zero value suppression
 
@@ -609,9 +609,6 @@ private:
     // get the registry, create one if none exists
     SVL_DLLPRIVATE static SvNumberFormatterRegistry_Impl& 
GetFormatterRegistry();
 
-    // called by ctors
-    SVL_DLLPRIVATE void ImpConstruct(LanguageType eLang);
-
     // 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);
diff --git a/svl/source/numbers/zforlist.cxx b/svl/source/numbers/zforlist.cxx
index 3b6c2bd7f1b5..fa9c83757eff 100644
--- a/svl/source/numbers/zforlist.cxx
+++ b/svl/source/numbers/zforlist.cxx
@@ -275,44 +275,18 @@ const sal_uInt16 SvNumberFormatter::INPUTSTRING_PRECISION 
= ::std::numeric_limit
 SvNumberFormatter::SvNumberFormatter( const Reference< XComponentContext >& 
rxContext,
                                       LanguageType eLang )
     : m_xContext( rxContext )
-    , maLanguageTag( eLang)
+    , IniLnge(eLang != LANGUAGE_DONTKNOW ? eLang : UNKNOWN_SUBSTITUTE)
+    , ActLnge(IniLnge)
+    , maLanguageTag(IniLnge)
+    , MaxCLOffset(0)
+    , nDefaultSystemCurrencyFormat(NUMBERFORMAT_ENTRY_NOT_FOUND)
+    , eEvalDateFormat(NF_EVALDATEFORMAT_INTL)
+    , bNoZero(false)
 {
-    ImpConstruct( eLang );
-}
-
-SvNumberFormatter::~SvNumberFormatter()
-{
-    {
-        ::osl::MutexGuard aGuard( GetGlobalMutex() );
-        pFormatterRegistry->Remove( this );
-        if ( !pFormatterRegistry->Count() )
-        {
-            delete pFormatterRegistry;
-            pFormatterRegistry = nullptr;
-        }
-    }
-
-    aFTable.clear();
-    ClearMergeTable();
-}
-
-
-void SvNumberFormatter::ImpConstruct( LanguageType eLang )
-{
-    if ( eLang == LANGUAGE_DONTKNOW )
-    {
-        eLang = UNKNOWN_SUBSTITUTE;
-    }
-    IniLnge = eLang;
-    ActLnge = eLang;
-    eEvalDateFormat = NF_EVALDATEFORMAT_INTL;
-    nDefaultSystemCurrencyFormat = NUMBERFORMAT_ENTRY_NOT_FOUND;
-
-    maLanguageTag.reset( eLang );
     xCharClass.changeLocale( m_xContext, maLanguageTag );
     xLocaleData.init( m_xContext, maLanguageTag );
     xCalendar.init( m_xContext, maLanguageTag.getLocale() );
-    xTransliteration.init( m_xContext, eLang );
+    xTransliteration.init( m_xContext, IniLnge );
     xNatNum.init( m_xContext );
 
     // cached locale data items
@@ -324,16 +298,28 @@ void SvNumberFormatter::ImpConstruct( LanguageType eLang )
 
     pStringScanner.reset( new ImpSvNumberInputScan( this ) );
     pFormatScanner.reset( new ImpSvNumberformatScan( this ) );
-    pFormatTable = nullptr;
-    MaxCLOffset = 0;
     ImpGenerateFormats( 0, false );     // 0 .. 999 for initialized language 
formats
-    pMergeTable = nullptr;
-    bNoZero = false;
 
     ::osl::MutexGuard aGuard( GetGlobalMutex() );
     GetFormatterRegistry().Insert( this );
 }
 
+SvNumberFormatter::~SvNumberFormatter()
+{
+    {
+        ::osl::MutexGuard aGuard( GetGlobalMutex() );
+        pFormatterRegistry->Remove( this );
+        if ( !pFormatterRegistry->Count() )
+        {
+            delete pFormatterRegistry;
+            pFormatterRegistry = nullptr;
+        }
+    }
+
+    aFTable.clear();
+    ClearMergeTable();
+}
+
 
 void SvNumberFormatter::ChangeIntl(LanguageType eLnge)
 {

Reply via email to