[Libreoffice-commits] core.git: include/svl svl/source

Noel Grandin (via logerrit) logerrit at kemper.freedesktop.org
Fri Sep 17 19:26:11 UTC 2021


 include/svl/numformat.hxx       |    4 +++-
 svl/source/numbers/zforlist.cxx |    8 ++++----
 2 files changed, 7 insertions(+), 5 deletions(-)

New commits:
commit 661f8785e6727dca1ef23c51ae9ecf4d3da299d3
Author:     Noel Grandin <noel.grandin at collabora.co.uk>
AuthorDate: Fri Sep 17 15:15:54 2021 +0200
Commit:     Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Fri Sep 17 21:25:38 2021 +0200

    no need to allocate CharClass separately in SvNumberFormatter
    
    Change-Id: I79b815567c59702c2d3fe7944bb2f16bacf0e472
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/122252
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/include/svl/numformat.hxx b/include/svl/numformat.hxx
index 3256adf881b5..a851032ef47c 100644
--- a/include/svl/numformat.hxx
+++ b/include/svl/numformat.hxx
@@ -24,6 +24,8 @@
 #include <i18nlangtag/lang.h>
 #include <tools/link.hxx>
 #include <svl/zforlist.hxx>
+#include <unotools/charclass.hxx>
+#include <optional>
 
 class SvNumberFormatterRegistry_Impl;
 class NfCurrencyTable;
@@ -561,7 +563,7 @@ private:
     std::unique_ptr<SvNumberFormatTable> pFormatTable; // For the UI dialog
     std::unique_ptr<SvNumberFormatterIndexTable>
         pMergeTable; // List of indices for merging two formatters
-    std::unique_ptr<CharClass> pCharClass; // CharacterClassification
+    std::optional<CharClass> oCharClass; // CharacterClassification
     OnDemandLocaleDataWrapper xLocaleData; // LocaleData switched between SYSTEM, ENGLISH and other
     OnDemandTransliterationWrapper xTransliteration; // Transliteration loaded on demand
     OnDemandCalendarWrapper xCalendar; // Calendar loaded on demand
diff --git a/svl/source/numbers/zforlist.cxx b/svl/source/numbers/zforlist.cxx
index 077d04867e0f..9c35f99547fc 100644
--- a/svl/source/numbers/zforlist.cxx
+++ b/svl/source/numbers/zforlist.cxx
@@ -303,7 +303,7 @@ void SvNumberFormatter::ImpConstruct( LanguageType eLang )
     nDefaultSystemCurrencyFormat = NUMBERFORMAT_ENTRY_NOT_FOUND;
 
     maLanguageTag.reset( eLang );
-    pCharClass.reset( new CharClass( m_xContext, maLanguageTag ) );
+    oCharClass.emplace( m_xContext, maLanguageTag );
     xLocaleData.init( m_xContext, maLanguageTag );
     xCalendar.init( m_xContext, maLanguageTag.getLocale() );
     xTransliteration.init( m_xContext, eLang );
@@ -338,7 +338,7 @@ void SvNumberFormatter::ChangeIntl(LanguageType eLnge)
     ActLnge = eLnge;
 
     maLanguageTag.reset( eLnge );
-    pCharClass.reset( new CharClass( m_xContext, maLanguageTag ) );
+    oCharClass.emplace( m_xContext, maLanguageTag );
     xLocaleData.changeLocale( maLanguageTag );
     xCalendar.changeLocale( maLanguageTag.getLocale() );
     xTransliteration.changeLocale( eLnge );
@@ -532,7 +532,7 @@ const ::utl::TransliterationWrapper* SvNumberFormatter::GetTransliteration() con
     return xTransliteration.get();
 }
 
-const CharClass* SvNumberFormatter::GetCharClass() const { return pCharClass.get(); }
+const CharClass* SvNumberFormatter::GetCharClass() const { return oCharClass ? &*oCharClass : nullptr; }
 
 const LocaleDataWrapper* SvNumberFormatter::GetLocaleData() const { return xLocaleData.get(); }
 
@@ -1846,7 +1846,7 @@ bool SvNumberFormatter::GetPreviewStringGuess( const OUString& sFormatString,
     eLnge = ActLnge;
     bool bEnglish = (eLnge == LANGUAGE_ENGLISH_US);
 
-    OUString aFormatStringUpper( pCharClass->uppercase( sFormatString ) );
+    OUString aFormatStringUpper( oCharClass->uppercase( sFormatString ) );
     sal_uInt32 nCLOffset = ImpGenerateCL( eLnge );
     sal_uInt32 nKey = ImpIsEntry( aFormatStringUpper, nCLOffset, eLnge );
     if ( nKey != NUMBERFORMAT_ENTRY_NOT_FOUND )


More information about the Libreoffice-commits mailing list