sw/inc/swmodule.hxx               |    5 +++++
 sw/source/core/inc/txtfrm.hxx     |    3 ++-
 sw/source/core/text/inftxt.cxx    |    5 ++---
 sw/source/core/text/txtfrm.cxx    |   11 +++++------
 sw/source/core/txtnode/swfont.cxx |   13 +++++++++----
 sw/source/uibase/app/apphdl.cxx   |    2 +-
 sw/source/uibase/app/swmodule.cxx |    1 +
 7 files changed, 25 insertions(+), 15 deletions(-)

New commits:
commit 259624bc6883f9505a28355f046724ddcefdb951
Author:     Caolán McNamara <caolan.mcnam...@collabora.com>
AuthorDate: Thu Oct 3 12:55:50 2024 +0100
Commit:     Caolán McNamara <caolan.mcnam...@collabora.com>
CommitDate: Thu Oct 3 16:59:50 2024 +0200

    We don't need to constantly fetch SvtCTLOptions::GetCTLTextNumerals
    
    we are already listening to SvtCTLOptions and triggering
    SwViewShell::ChgNumberDigits if it changes, so can just keep
    the initial value and update it at that point.
    
    Change-Id: I669aeb755506b9d703a7c638a82c03935779ce8d
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/174421
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <caolan.mcnam...@collabora.com>

diff --git a/sw/inc/swmodule.hxx b/sw/inc/swmodule.hxx
index 9c3a7efa35db..334faf772738 100644
--- a/sw/inc/swmodule.hxx
+++ b/sw/inc/swmodule.hxx
@@ -25,6 +25,7 @@
 
 #include <o3tl/deleter.hxx>
 #include <tools/fldunit.hxx>
+#include <svl/ctloptions.hxx>
 #include <svl/lstner.hxx>
 #include <unotools/options.hxx>
 #include <sfx2/module.hxx>
@@ -108,6 +109,8 @@ class SAL_DLLPUBLIC_RTTI SwModule final : public SfxModule, 
public SfxListener,
     css::uno::Reference< css::scanner::XScannerManager2 >    m_xScannerManager;
     css::uno::Reference< css::linguistic2::XLanguageGuessing >  
m_xLanguageGuesser;
 
+    SvtCTLOptions::TextNumerals m_eCTLTextNumerals;
+
     bool                m_bAuthorInitialised : 1;
     bool                m_bEmbeddedLoadSave : 1;
 
@@ -183,6 +186,8 @@ public:
     bool IsEmbeddedLoadSave() const         { return m_bEmbeddedLoadSave; }
     void SetEmbeddedLoadSave( bool bFlag )  { m_bEmbeddedLoadSave = bFlag; }
 
+    SvtCTLOptions::TextNumerals GetCTLTextNumerals() const { return 
m_eCTLTextNumerals; }
+
     static void ShowDBObj( SwView const & rView, const SwDBData& rData);
 
     // Table modi.
diff --git a/sw/source/core/inc/txtfrm.hxx b/sw/source/core/inc/txtfrm.hxx
index 182809007213..eb0458a9022d 100644
--- a/sw/source/core/inc/txtfrm.hxx
+++ b/sw/source/core/inc/txtfrm.hxx
@@ -20,6 +20,7 @@
 #define INCLUDED_SW_SOURCE_CORE_INC_TXTFRM_HXX
 
 #include <com/sun/star/uno/Sequence.hxx>
+#include <svl/ctloptions.hxx>
 #include "cntfrm.hxx"
 #include "TextFrameIndex.hxx"
 #include <nodeoffset.hxx>
@@ -981,7 +982,7 @@ class SwDigitModeModifier
     const OutputDevice& rOut;
     LanguageType nOldLanguageType;
 public:
-    SwDigitModeModifier( const OutputDevice& rOutp, LanguageType eCurLang );
+    SwDigitModeModifier( const OutputDevice& rOutp, LanguageType eCurLang, 
SvtCTLOptions::TextNumerals eCTlTextNumerals );
     ~SwDigitModeModifier();
 };
 
diff --git a/sw/source/core/text/inftxt.cxx b/sw/source/core/text/inftxt.cxx
index 8471cf8282d5..1d7bbaf42e18 100644
--- a/sw/source/core/text/inftxt.cxx
+++ b/sw/source/core/text/inftxt.cxx
@@ -1637,14 +1637,13 @@ void SwTextFormatInfo::CtorInitTextFormatInfo( 
OutputDevice* pRenderContext, SwT
     m_nLineNetHeight = 0;
     SetLineStart(TextFrameIndex(0));
 
-    SvtCTLOptions::TextNumerals const nTextNumerals(
-            SvtCTLOptions::GetCTLTextNumerals());
+    SvtCTLOptions::TextNumerals const 
nTextNumerals(SW_MOD()->GetCTLTextNumerals());
     // cannot cache for NUMERALS_CONTEXT because we need to know the string
     // for the whole paragraph now
     if (nTextNumerals != SvtCTLOptions::NUMERALS_CONTEXT)
     {
         // set digit mode to what will be used later to get same results
-        SwDigitModeModifier const m(*m_pRef, LANGUAGE_NONE /*dummy*/);
+        SwDigitModeModifier const m(*m_pRef, LANGUAGE_NONE /*dummy*/, 
nTextNumerals);
         assert(m_pRef->GetDigitLanguage() != LANGUAGE_NONE);
         SetCachedVclData(OutputDevice::CreateTextLayoutCache(*m_pText));
     }
diff --git a/sw/source/core/text/txtfrm.cxx b/sw/source/core/text/txtfrm.cxx
index ad813eddfc57..6f44e9268075 100644
--- a/sw/source/core/text/txtfrm.cxx
+++ b/sw/source/core/text/txtfrm.cxx
@@ -722,7 +722,8 @@ void SwLayoutModeModifier::SetAuto()
     const_cast<OutputDevice&>(m_rOut).SetLayoutMode( nNewLayoutMode );
 }
 
-SwDigitModeModifier::SwDigitModeModifier( const OutputDevice& rOutp, 
LanguageType eCurLang ) :
+SwDigitModeModifier::SwDigitModeModifier( const OutputDevice& rOutp, 
LanguageType eCurLang,
+                                          SvtCTLOptions::TextNumerals 
eCTLTextNumerals ) :
         rOut( rOutp ), nOldLanguageType( rOutp.GetDigitLanguage() )
 {
     LanguageType eLang = eCurLang;
@@ -730,13 +731,11 @@ SwDigitModeModifier::SwDigitModeModifier( const 
OutputDevice& rOutp, LanguageTyp
         eLang = LANGUAGE_ENGLISH_US;
     else
     {
-        const SvtCTLOptions::TextNumerals nTextNumerals = 
SvtCTLOptions::GetCTLTextNumerals();
-
-        if ( SvtCTLOptions::NUMERALS_HINDI == nTextNumerals )
+        if ( SvtCTLOptions::NUMERALS_HINDI == eCTLTextNumerals )
             eLang = LANGUAGE_ARABIC_SAUDI_ARABIA;
-        else if ( SvtCTLOptions::NUMERALS_ARABIC == nTextNumerals )
+        else if ( SvtCTLOptions::NUMERALS_ARABIC == eCTLTextNumerals )
             eLang = LANGUAGE_ENGLISH;
-        else if ( SvtCTLOptions::NUMERALS_SYSTEM == nTextNumerals )
+        else if ( SvtCTLOptions::NUMERALS_SYSTEM == eCTLTextNumerals )
             eLang = ::GetAppLanguage();
     }
 
diff --git a/sw/source/core/txtnode/swfont.cxx 
b/sw/source/core/txtnode/swfont.cxx
index 0b65fb0af231..5499c8b84421 100644
--- a/sw/source/core/txtnode/swfont.cxx
+++ b/sw/source/core/txtnode/swfont.cxx
@@ -52,6 +52,7 @@
 #include <fntcache.hxx>
 #include <txtfrm.hxx>
 #include <scriptinfo.hxx>
+#include <swmodule.hxx>
 
 #ifdef DBG_UTIL
 // global Variable
@@ -998,7 +999,8 @@ Size SwSubFont::GetTextSize_( SwDrawTextInfo& rInf )
          !IsSameInstance( rInf.GetpOut()->GetFont() ) )
         ChgFnt( rInf.GetShell(), rInf.GetOut() );
 
-    SwDigitModeModifier aDigitModeModifier( rInf.GetOut(), 
rInf.GetFont()->GetLanguage() );
+    SwDigitModeModifier aDigitModeModifier(rInf.GetOut(), 
rInf.GetFont()->GetLanguage(),
+                                           SW_MOD()->GetCTLTextNumerals());
 
     Size aTextSize;
     TextFrameIndex const nLn = rInf.GetLen() == TextFrameIndex(COMPLETE_STRING)
@@ -1127,7 +1129,8 @@ void SwSubFont::DrawText_( SwDrawTextInfo &rInf, const 
bool bGrey )
     if( !pLastFont || pLastFont->GetOwner() != m_nFontCacheId )
         ChgFnt( rInf.GetShell(), rInf.GetOut() );
 
-    SwDigitModeModifier aDigitModeModifier( rInf.GetOut(), 
rInf.GetFont()->GetLanguage() );
+    SwDigitModeModifier aDigitModeModifier(rInf.GetOut(), 
rInf.GetFont()->GetLanguage(),
+                                           SW_MOD()->GetCTLTextNumerals());
 
     const Point aOldPos(rInf.GetPos());
     Point aPos( rInf.GetPos() );
@@ -1252,7 +1255,8 @@ void SwSubFont::DrawStretchText_( SwDrawTextInfo &rInf )
     if ( !pLastFont || pLastFont->GetOwner() != m_nFontCacheId )
         ChgFnt( rInf.GetShell(), rInf.GetOut() );
 
-    SwDigitModeModifier aDigitModeModifier( rInf.GetOut(), 
rInf.GetFont()->GetLanguage() );
+    SwDigitModeModifier aDigitModeModifier(rInf.GetOut(), 
rInf.GetFont()->GetLanguage(),
+                                           SW_MOD()->GetCTLTextNumerals());
 
     rInf.ApplyAutoColor();
 
@@ -1317,7 +1321,8 @@ TextFrameIndex SwSubFont::GetModelPositionForViewPoint_( 
SwDrawTextInfo& rInf )
     if ( !pLastFont || pLastFont->GetOwner() != m_nFontCacheId )
         ChgFnt( rInf.GetShell(), rInf.GetOut() );
 
-    SwDigitModeModifier aDigitModeModifier( rInf.GetOut(), 
rInf.GetFont()->GetLanguage() );
+    SwDigitModeModifier aDigitModeModifier(rInf.GetOut(), 
rInf.GetFont()->GetLanguage(),
+                                           SW_MOD()->GetCTLTextNumerals());
 
     TextFrameIndex const nLn = rInf.GetLen() == TextFrameIndex(COMPLETE_STRING)
             ? TextFrameIndex(rInf.GetText().getLength())
diff --git a/sw/source/uibase/app/apphdl.cxx b/sw/source/uibase/app/apphdl.cxx
index fffe14724dfe..717d9bf6a9bf 100644
--- a/sw/source/uibase/app/apphdl.cxx
+++ b/sw/source/uibase/app/apphdl.cxx
@@ -1024,6 +1024,7 @@ void 
SwModule::ConfigurationChanged(utl::ConfigurationBroadcaster* pBrdCst, Conf
     }
     else if( pBrdCst == m_pCTLOptions.get() )
     {
+        m_eCTLTextNumerals = SvtCTLOptions::GetCTLTextNumerals();
         const SfxObjectShell* pObjSh = SfxObjectShell::GetFirst();
         while( pObjSh )
         {
@@ -1037,7 +1038,6 @@ void 
SwModule::ConfigurationChanged(utl::ConfigurationBroadcaster* pBrdCst, Conf
             pObjSh = SfxObjectShell::GetNext(*pObjSh);
         }
     }
-
 }
 
 SwDBConfig* SwModule::GetDBConfig()
diff --git a/sw/source/uibase/app/swmodule.cxx 
b/sw/source/uibase/app/swmodule.cxx
index 3d351cf492e1..001f9fe25fe8 100644
--- a/sw/source/uibase/app/swmodule.cxx
+++ b/sw/source/uibase/app/swmodule.cxx
@@ -130,6 +130,7 @@ SwModule::SwModule( SfxObjectFactory* pWebFact,
                     SfxObjectFactory* pGlobalFact )
     : SfxModule("sw"_ostr, {pWebFact, pFact, pGlobalFact}),
     m_pView(nullptr),
+    m_eCTLTextNumerals(SvtCTLOptions::GetCTLTextNumerals()),
     m_bAuthorInitialised(false),
     m_bEmbeddedLoadSave( false ),
     m_pDragDrop( nullptr ),

Reply via email to