include/svl/nfengine.hxx        |    2 +-
 include/svl/numformat.hxx       |    2 +-
 svl/source/numbers/zforlist.cxx |   19 ++++++++-----------
 svl/source/numbers/zformat.cxx  |    2 +-
 4 files changed, 11 insertions(+), 14 deletions(-)

New commits:
commit 6ddc398095bcbb288b1ef1ec3f01a52a615672f8
Author:     Caolán McNamara <[email protected]>
AuthorDate: Wed Mar 27 11:11:11 2024 +0000
Commit:     Caolán McNamara <[email protected]>
CommitDate: Wed Mar 27 17:23:45 2024 +0100

    drop const_cast and be more honest that internal state changes
    
    Change-Id: I20dd009b2bd14cdf958572dabc7a7e565a2f98ba
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/165393
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <[email protected]>

diff --git a/include/svl/nfengine.hxx b/include/svl/nfengine.hxx
index aa57d731fbac..a4890e074d1a 100644
--- a/include/svl/nfengine.hxx
+++ b/include/svl/nfengine.hxx
@@ -92,7 +92,7 @@ public:
     bool IsDecimalSep(std::u16string_view rStr) const;
 
     /// Return the decimal separator matching the given locale / LanguageType.
-    OUString GetLangDecimalSep(LanguageType nLang) const;
+    OUString GetLangDecimalSep(LanguageType nLang);
 
     /// Change language/country, also input and format scanner
     void ChangeIntl(LanguageType eLnge);
diff --git a/include/svl/numformat.hxx b/include/svl/numformat.hxx
index 7acecbcbc2b4..b26e245ca8d5 100644
--- a/include/svl/numformat.hxx
+++ b/include/svl/numformat.hxx
@@ -264,7 +264,7 @@ public:
     const SvNumberformat* GetEntry(sal_uInt32 nKey) const;
 
     /// Obtain substituted GetFormatEntry(), i.e. system formats.
-    const SvNumberformat* GetSubstitutedEntry(sal_uInt32 nKey, sal_uInt32& 
o_rNewKey) const;
+    const SvNumberformat* GetSubstitutedEntry(sal_uInt32 nKey, sal_uInt32& 
o_rNewKey);
 
     /// Return the format index of the standard default number format for 
language/country
     sal_uInt32 GetStandardIndex(LanguageType eLnge = LANGUAGE_DONTKNOW);
diff --git a/svl/source/numbers/zforlist.cxx b/svl/source/numbers/zforlist.cxx
index 05f3dd9f2daa..9a4490849d11 100644
--- a/svl/source/numbers/zforlist.cxx
+++ b/svl/source/numbers/zforlist.cxx
@@ -362,7 +362,7 @@ bool SvNFLanguageData::IsDecimalSep( std::u16string_view 
rStr ) const
     return rStr == GetNumDecimalSepAlt();
 }
 
-OUString SvNFLanguageData::GetLangDecimalSep( LanguageType nLang ) const
+OUString SvNFLanguageData::GetLangDecimalSep( LanguageType nLang )
 {
     if (nLang == ActLnge)
     {
@@ -377,9 +377,9 @@ OUString SvNFLanguageData::GetLangDecimalSep( LanguageType 
nLang ) const
     else
     {
         LanguageTag aSaveLocale( xLocaleData->getLanguageTag() );
-        const_cast<SvNFLanguageData*>(this)->xLocaleData.changeLocale( 
LanguageTag( nLang));
+        xLocaleData.changeLocale( LanguageTag( nLang));
         aRet = xLocaleData->getNumDecimalSep();
-        const_cast<SvNFLanguageData*>(this)->xLocaleData.changeLocale( 
aSaveLocale );
+        xLocaleData.changeLocale( aSaveLocale );
     }
     return aRet;
 }
@@ -2886,14 +2886,13 @@ const SvNumberformat* SvNumberFormatter::GetEntry( 
sal_uInt32 nKey ) const
     return m_aFormatData.GetFormatEntry(nKey);
 }
 
-const SvNumberformat* SvNumberFormatter::GetSubstitutedEntry( sal_uInt32 nKey, 
sal_uInt32 & o_rNewKey ) const
+const SvNumberformat* SvNumberFormatter::GetSubstitutedEntry( sal_uInt32 nKey, 
sal_uInt32 & o_rNewKey )
 {
     ::osl::MutexGuard aGuard( GetInstanceMutex() );
     // A tad ugly, but GetStandardFormat() and GetFormatIndex() in
     // ImpSubstituteEntry() may have to add the LANGUAGE_SYSTEM formats if not
     // already present (which in practice most times they are).
-    SvNumberFormatter* pThis = const_cast<SvNumberFormatter*>(this);
-    return pThis->ImpSubstituteEntry( pThis->m_aFormatData.GetFormatEntry( 
nKey), &o_rNewKey);
+    return ImpSubstituteEntry(m_aFormatData.GetFormatEntry(nKey), &o_rNewKey);
 }
 
 const SvNumberformat* SvNumberFormatter::ImpSubstituteEntry( const 
SvNumberformat* pFormat, sal_uInt32 * o_pRealKey )
diff --git a/svl/source/numbers/zformat.cxx b/svl/source/numbers/zformat.cxx
index ca34bd235aad..951c61ec04e1 100644
--- a/svl/source/numbers/zformat.cxx
+++ b/svl/source/numbers/zformat.cxx
@@ -858,7 +858,7 @@ SvNumberformat::SvNumberformat(OUString& rString,
                         else if (rScan.GetConvertMode() && ((nDecPos = 
sStr.indexOf( aConvertFromDecSep)) >= 0))
                         {
                             if (aConvertToDecSep.isEmpty())
-                                aConvertToDecSep = 
GetCurrentLanguageData().GetLangDecimalSep( rScan.GetNewLnge());
+                                aConvertToDecSep = 
rScan.GetCurrentLanguageData().GetLangDecimalSep( rScan.GetNewLnge());
                             if (aConvertToDecSep != aConvertFromDecSep)
                             {
                                 const OUString aStr( sStr.replaceAt( nDecPos,
commit 381e257a814036df6baab4ddbb96371fba856acf
Author:     Caolán McNamara <[email protected]>
AuthorDate: Wed Mar 27 11:13:34 2024 +0000
Commit:     Caolán McNamara <[email protected]>
CommitDate: Wed Mar 27 17:23:37 2024 +0100

    don't need to const cast here anymore
    
    Change-Id: I9d3502e9e16625135d2f065e39aec7ac6c6232ce
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/165392
    Tested-by: Caolán McNamara <[email protected]>
    Reviewed-by: Caolán McNamara <[email protected]>

diff --git a/svl/source/numbers/zforlist.cxx b/svl/source/numbers/zforlist.cxx
index 826d3b725616..05f3dd9f2daa 100644
--- a/svl/source/numbers/zforlist.cxx
+++ b/svl/source/numbers/zforlist.cxx
@@ -957,8 +957,7 @@ void SvNumberFormatter::FillKeywordTableForExcel( 
NfKeywordTable& rKeywords )
     rKeywords[ NF_KEY_THAI_T ] = "T";
 }
 
-
-static OUString lcl_buildBooleanStringFormat( SvNumberformat* pEntry, const 
NativeNumberWrapper* pNatNum, const SvNFLanguageData& rCurrentLang )
+static OUString lcl_buildBooleanStringFormat(const SvNumberformat* pEntry, 
const NativeNumberWrapper* pNatNum, const SvNFLanguageData& rCurrentLang)
 {
     // Build Boolean number format, which needs non-zero and zero subformat
     // codes with TRUE and FALSE strings.
@@ -971,7 +970,6 @@ static OUString lcl_buildBooleanStringFormat( 
SvNumberformat* pEntry, const Nati
     return aFormatStr;
 }
 
-
 OUString SvNumberFormatter::GetFormatStringForExcel( sal_uInt32 nKey, const 
NfKeywordTable& rKeywords,
         SvNumberFormatter& rTempFormatter ) const
 {
@@ -987,7 +985,7 @@ OUString SvNumberFormatter::GetFormatStringForExcel( 
sal_uInt32 nKey, const NfKe
             // locales. You can't have both. We could force to English for all
             // locales like below, but Excel would display English strings then
             // even for the system locale matching this locale. YMMV.
-            aFormatStr = lcl_buildBooleanStringFormat( const_cast< 
SvNumberformat* >(pEntry), GetNatNum(), m_aCurrentLanguage );
+            aFormatStr = lcl_buildBooleanStringFormat(pEntry, GetNatNum(), 
m_aCurrentLanguage);
         }
         else
         {
@@ -1023,7 +1021,7 @@ OUString SvNumberFormatter::GetFormatStringForExcel( 
sal_uInt32 nKey, const NfKe
                     // >"VRAI";"VRAI";"FAUX"< recognized as real boolean and
                     // properly converted. Then written as
                     // >"TRUE";"TRUE";"FALSE"<
-                    aFormatStr = lcl_buildBooleanStringFormat( const_cast< 
SvNumberformat* >(pEntry), GetNatNum(), m_aCurrentLanguage );
+                    aFormatStr = lcl_buildBooleanStringFormat(pEntry, 
GetNatNum(), m_aCurrentLanguage);
                 }
                 else
                 {

Reply via email to