include/svl/numformat.hxx | 9 ++---- svl/source/numbers/zforlist.cxx | 54 +++++++++++++++------------------------- 2 files changed, 24 insertions(+), 39 deletions(-)
New commits: commit aa225b41352f22c60f41fb9fa03c23b4e9359266 Author: Caolán McNamara <caolan.mcnam...@collabora.com> AuthorDate: Thu Feb 29 12:37:45 2024 +0000 Commit: Caolán McNamara <caolan.mcnam...@collabora.com> CommitDate: Fri Apr 12 15:33:14 2024 +0200 IniLnge is set during ctor and never changes subsequently so no lock is needed for it squashed commits of: 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 <caolan.mcnam...@collabora.com> Reviewed-by: Caolán McNamara <caolan.mcnam...@collabora.com> (cherry picked from commit 023e59d0283614a568362b794bb94a9254401d7e) 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 <caolan.mcnam...@collabora.com> (cherry picked from commit 657631791421eae2c88a89da27bd2c0dc1822175) 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 <caolan.mcnam...@collabora.com> (cherry picked from commit 9fcee419dd368823d842b9c9a032b2213ee24d34) 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 <caolan.mcnam...@collabora.com> (cherry picked from commit 1245614991654b9d3ddb15f644a689585fd4c9de) Related: tdf#160056 IniLnge is immutable no lock needed here Change-Id: I00461d44f78e9776568492fccb7dee0e9869944e Reviewed-on: https://gerrit.libreoffice.org/c/core/+/164848 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolan.mcnam...@collabora.com> (cherry picked from commit ee5b9597605176af0c80f9ea28caac9ba7980254) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/165749 Reviewed-by: Michael Stahl <michael.st...@allotropia.de> 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..665f70948a78 100644 --- a/svl/source/numbers/zforlist.cxx +++ b/svl/source/numbers/zforlist.cxx @@ -275,44 +275,17 @@ 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) { - 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 @@ -334,6 +307,22 @@ void SvNumberFormatter::ImpConstruct( LanguageType eLang ) 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) { @@ -1302,8 +1291,7 @@ bool SvNumberFormatter::IsNumberFormat(const OUString& sString, LanguageType SvNumberFormatter::GetLanguage() const { - ::osl::MutexGuard aGuard( GetInstanceMutex() ); - return IniLnge; + return IniLnge; // immutable } // static