include/svl/numformat.hxx       |    2 +-
 include/svl/ondemand.hxx        |   11 ++---------
 svl/source/numbers/zforlist.cxx |    4 ++--
 3 files changed, 5 insertions(+), 12 deletions(-)

New commits:
commit ec91e33eaa21d3771406a55a159a2963bcb994b3
Author:     Caolán McNamara <caolan.mcnam...@collabora.com>
AuthorDate: Thu Apr 11 22:40:18 2024 +0100
Commit:     Caolán McNamara <caolan.mcnam...@collabora.com>
CommitDate: Fri Apr 12 15:14:21 2024 +0200

    fold OnDemandNativeNumberWrapper ctor and init together
    
    Change-Id: I79e2cb4c81a2bbac4da16ece778e4ad3acc59eb7
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/166025
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <caolan.mcnam...@collabora.com>

diff --git a/include/svl/numformat.hxx b/include/svl/numformat.hxx
index f77b5336520c..f1dcd68b479b 100644
--- a/include/svl/numformat.hxx
+++ b/include/svl/numformat.hxx
@@ -549,7 +549,7 @@ private:
     std::unique_ptr<SvNumberFormatterIndexTable>
         pMergeTable; // List of indices for merging two formatters
     SvNFLanguageData m_aCurrentLanguage;
-    OnDemandNativeNumberWrapper xNatNum; // Native number service loaded on 
demand
+    OnDemandNativeNumberWrapper m_xNatNum; // Native number service loaded on 
demand
     Link<sal_uInt16, Color*> aColorLink; // User defined color table CallBack
 
     SVL_DLLPRIVATE static sal_uInt16 nSystemCurrencyPosition;
diff --git a/include/svl/ondemand.hxx b/include/svl/ondemand.hxx
index f412f146d686..691fd6fc8099 100644
--- a/include/svl/ondemand.hxx
+++ b/include/svl/ondemand.hxx
@@ -252,10 +252,6 @@ public:
 
 /** Load a native number service wrapper only if it's needed.
     SvNumberformatter uses it.
-
-    @ATTENTION
-    If the default ctor is used the init() method MUST be called
-    before accessing the native number supplier.
  */
 class OnDemandNativeNumberWrapper
 {
@@ -263,12 +259,9 @@ class OnDemandNativeNumberWrapper
     mutable std::optional<NativeNumberWrapper> moNativeNumber;
 
 public:
-    OnDemandNativeNumberWrapper() {}
-
-    void init(const css::uno::Reference<css::uno::XComponentContext>& 
rxContext)
+    OnDemandNativeNumberWrapper(const 
css::uno::Reference<css::uno::XComponentContext>& rContext)
+        : m_xContext(rContext)
     {
-        m_xContext = rxContext;
-        moNativeNumber.reset();
     }
 
     NativeNumberWrapper& get() const
diff --git a/svl/source/numbers/zforlist.cxx b/svl/source/numbers/zforlist.cxx
index e8f3331916d7..be23893d2571 100644
--- a/svl/source/numbers/zforlist.cxx
+++ b/svl/source/numbers/zforlist.cxx
@@ -415,8 +415,8 @@ SvNumberFormatter::SvNumberFormatter( const Reference< 
XComponentContext >& rxCo
     , IniLnge(eLang != LANGUAGE_DONTKNOW ? eLang : UNKNOWN_SUBSTITUTE)
     , m_aRWPolicy(SvNFEngine::GetRWPolicy(m_aFormatData))
     , m_aCurrentLanguage(rxContext, IniLnge, *this)
+    , m_xNatNum(m_xContext)
 {
-    xNatNum.init( m_xContext );
 
     // 0 .. 999 for initialized language formats
     m_aFormatData.ImpGenerateFormats(m_aCurrentLanguage, GetNatNum(), 0, 
false);
@@ -624,7 +624,7 @@ const css::uno::Reference<css::uno::XComponentContext>& 
SvNumberFormatter::GetCo
     return m_xContext;
 }
 
-const NativeNumberWrapper& SvNumberFormatter::GetNatNum() const { return 
xNatNum.get(); }
+const NativeNumberWrapper& SvNumberFormatter::GetNatNum() const { return 
m_xNatNum.get(); }
 
 bool SvNFFormatData::IsTextFormat(sal_uInt32 F_Index) const
 {

Reply via email to