diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-06-07 11:47:06 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-06-07 11:47:06 +0000 |
commit | 8ceff95c69cf9bd9ff5ab3a4b5689925b8bd6a59 (patch) | |
tree | ca2b0cc4fba88107f5f6e740285184a061011866 /svl/source/numbers | |
parent | Adding debian version 4:24.2.3-2. (diff) | |
download | libreoffice-8ceff95c69cf9bd9ff5ab3a4b5689925b8bd6a59.tar.xz libreoffice-8ceff95c69cf9bd9ff5ab3a4b5689925b8bd6a59.zip |
Merging upstream version 4:24.2.4.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'svl/source/numbers')
-rw-r--r-- | svl/source/numbers/zforlist.cxx | 90 | ||||
-rw-r--r-- | svl/source/numbers/zformat.cxx | 12 |
2 files changed, 43 insertions, 59 deletions
diff --git a/svl/source/numbers/zforlist.cxx b/svl/source/numbers/zforlist.cxx index 3b6c2bd7f1..e7b45a8209 100644 --- a/svl/source/numbers/zforlist.cxx +++ b/svl/source/numbers/zforlist.cxx @@ -242,7 +242,6 @@ void SvNumberFormatterRegistry_Impl::ConfigurationChanged( utl::ConfigurationBro } } - SvNumberFormatterRegistry_Impl* SvNumberFormatter::pFormatterRegistry = nullptr; volatile bool SvNumberFormatter::bCurrencyTableInitialized = false; namespace @@ -275,44 +274,18 @@ 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) + , MaxCLOffset(0) + , nDefaultSystemCurrencyFormat(NUMBERFORMAT_ENTRY_NOT_FOUND) + , eEvalDateFormat(NF_EVALDATEFORMAT_INTL) + , bNoZero(false) { - 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 @@ -324,16 +297,28 @@ void SvNumberFormatter::ImpConstruct( LanguageType eLang ) pStringScanner.reset( new ImpSvNumberInputScan( this ) ); pFormatScanner.reset( new ImpSvNumberformatScan( this ) ); - pFormatTable = nullptr; - MaxCLOffset = 0; ImpGenerateFormats( 0, false ); // 0 .. 999 for initialized language formats - pMergeTable = nullptr; - bNoZero = false; ::osl::MutexGuard aGuard( GetGlobalMutex() ); 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) { @@ -390,7 +375,7 @@ void SvNumberFormatter::SetColorLink( const Link<sal_uInt16,Color*>& rColorTable aColorLink = rColorTableCallBack; } -Color* SvNumberFormatter::GetUserDefColor(sal_uInt16 nIndex) +Color* SvNumberFormatter::GetUserDefColor(sal_uInt16 nIndex) const { ::osl::MutexGuard aGuard( GetInstanceMutex() ); if( aColorLink.IsSet() ) @@ -1011,7 +996,7 @@ sal_uInt32 SvNumberFormatter::ImpGetCLOffset(LanguageType eLnge) const sal_uInt32 SvNumberFormatter::ImpIsEntry(std::u16string_view rString, sal_uInt32 nCLOffset, - LanguageType eLnge) + LanguageType eLnge) const { sal_uInt32 res = NUMBERFORMAT_ENTRY_NOT_FOUND; auto it = aFTable.find( nCLOffset); @@ -1030,7 +1015,6 @@ sal_uInt32 SvNumberFormatter::ImpIsEntry(std::u16string_view rString, return res; } - SvNumberFormatTable& SvNumberFormatter::GetFirstEntryTable( SvNumFormatType& eType, sal_uInt32& FIndex, @@ -1302,8 +1286,7 @@ bool SvNumberFormatter::IsNumberFormat(const OUString& sString, LanguageType SvNumberFormatter::GetLanguage() const { - ::osl::MutexGuard aGuard( GetInstanceMutex() ); - return IniLnge; + return IniLnge; // immutable } // static @@ -1487,7 +1470,7 @@ sal_uInt32 SvNumberFormatter::GetStandardFormat( SvNumFormatType eType, Language } } -bool SvNumberFormatter::IsSpecialStandardFormat( sal_uInt32 nFIndex, +bool SvNumberFormatter::ImpIsSpecialStandardFormat( sal_uInt32 nFIndex, LanguageType eLnge ) { ::osl::MutexGuard aGuard( GetInstanceMutex() ); @@ -1502,7 +1485,7 @@ sal_uInt32 SvNumberFormatter::GetStandardFormat( sal_uInt32 nFIndex, SvNumFormat LanguageType eLnge ) { ::osl::MutexGuard aGuard( GetInstanceMutex() ); - if ( IsSpecialStandardFormat( nFIndex, eLnge ) ) + if ( ImpIsSpecialStandardFormat( nFIndex, eLnge ) ) return nFIndex; else return GetStandardFormat( eType, eLnge ); @@ -1540,7 +1523,7 @@ sal_uInt32 SvNumberFormatter::GetStandardFormat( double fNumber, sal_uInt32 nFIn SvNumFormatType eType, LanguageType eLnge ) { ::osl::MutexGuard aGuard( GetInstanceMutex() ); - if ( IsSpecialStandardFormat( nFIndex, eLnge ) ) + if ( ImpIsSpecialStandardFormat( nFIndex, eLnge ) ) return nFIndex; switch( eType ) @@ -3121,8 +3104,10 @@ void SvNumberFormatter::ImpGenerateAdditionalFormats( sal_uInt32 CLOffset, pStdFormat->SetLastInsertKey( static_cast<sal_uInt16>(nPos - CLOffset), SvNumberformat::FormatterPrivateAccess() ); } +namespace { -sal_Int32 SvNumberFormatter::ImpPosToken ( const OUStringBuffer & sFormat, sal_Unicode token, sal_Int32 nStartPos /* = 0*/ ) const +// return position of a special character +sal_Int32 ImpPosToken(const OUStringBuffer & sFormat, sal_Unicode token, sal_Int32 nStartPos = 0) { sal_Int32 nLength = sFormat.getLength(); for ( sal_Int32 i=nStartPos; i<nLength && i>=0 ; i++ ) @@ -3155,6 +3140,8 @@ sal_Int32 SvNumberFormatter::ImpPosToken ( const OUStringBuffer & sFormat, sal_U return -2; } +} + OUString SvNumberFormatter::GenerateFormat(sal_uInt32 nIndex, LanguageType eLnge, bool bThousand, @@ -3585,8 +3572,8 @@ sal_uInt32 SvNumberFormatter::GetFormatIndex( NfIndexTableOffset nTabOff, return nCLOffset + indexTable[nTabOff]; } - -NfIndexTableOffset SvNumberFormatter::GetIndexTableOffset( sal_uInt32 nFormat ) const +//static +NfIndexTableOffset SvNumberFormatter::GetIndexTableOffset(sal_uInt32 nFormat) { sal_uInt32 nOffset = nFormat % SV_COUNTRY_LANGUAGE_OFFSET; // relative index if ( nOffset > SV_MAX_COUNT_STANDARD_FORMATS ) @@ -3779,19 +3766,16 @@ void SvNumberFormatter::SetDefaultSystemCurrency( std::u16string_view rAbbrev, L nSystemCurrencyPosition = 0; // not found => simple SYSTEM } - void SvNumberFormatter::ResetDefaultSystemCurrency() { nDefaultSystemCurrencyFormat = NUMBERFORMAT_ENTRY_NOT_FOUND; } - void SvNumberFormatter::InvalidateDateAcceptancePatterns() { pStringScanner->InvalidateDateAcceptancePatterns(); } - sal_uInt32 SvNumberFormatter::ImpGetDefaultSystemCurrencyFormat() { if ( nDefaultSystemCurrencyFormat == NUMBERFORMAT_ENTRY_NOT_FOUND ) diff --git a/svl/source/numbers/zformat.cxx b/svl/source/numbers/zformat.cxx index 313a598279..b2d38f29cd 100644 --- a/svl/source/numbers/zformat.cxx +++ b/svl/source/numbers/zformat.cxx @@ -3052,7 +3052,7 @@ bool SvNumberformat::ImpGetFractionOutput(double fNumber, } sal_uInt16 SvNumberformat::ImpGetFractionOfSecondString( OUStringBuffer& rBuf, double fFractionOfSecond, - int nFractionDecimals, bool bAddOneRoundingDecimal, sal_uInt16 nIx, sal_uInt16 nMinimumInputLineDecimals ) + int nFractionDecimals, bool bAddOneRoundingDecimal, sal_uInt16 nIx, sal_uInt16 nMinimumInputLineDecimals ) const { if (!nFractionDecimals) return 0; @@ -4327,7 +4327,7 @@ bool SvNumberformat::ImpGetDateTimeOutput(double fNumber, bool SvNumberformat::ImpGetLogicalOutput(double fNumber, sal_uInt16 nIx, - OUStringBuffer& sStr) + OUStringBuffer& sStr) const { bool bRes = false; const ImpSvNumberformatInfo& rInfo = NumFor[nIx].Info(); @@ -4350,7 +4350,7 @@ bool SvNumberformat::ImpGetLogicalOutput(double fNumber, bool SvNumberformat::ImpGetNumberOutput(double fNumber, sal_uInt16 nIx, - OUStringBuffer& sStr) + OUStringBuffer& sStr) const { bool bRes = false; bool bSign; @@ -4470,7 +4470,7 @@ bool SvNumberformat::ImpDecimalFill( OUStringBuffer& sStr, // number string sal_Int32 nDecPos, // decimals start sal_uInt16 j, // symbol index within format code sal_uInt16 nIx, // subformat index - bool bInteger) // is integer + bool bInteger) const // is integer { bool bRes = false; bool bFilled = false; // Was filled? @@ -4592,7 +4592,7 @@ bool SvNumberformat::ImpNumberFillWithThousands( OUStringBuffer& sBuff, // numb sal_uInt16 j, // symbol index within format code sal_uInt16 nIx, // subformat index sal_Int32 nDigCnt, // count of integer digits in format - bool bAddDecSep) // add decimal separator if necessary + bool bAddDecSep) const // add decimal separator if necessary { bool bRes = false; sal_Int32 nLeadingStringChars = 0; // inserted StringChars before number @@ -4752,7 +4752,7 @@ void SvNumberformat::ImpDigitFill(OUStringBuffer& sStr, // number string sal_Int32 & k, // position within string sal_uInt16 nIx, // subformat index sal_Int32 & nDigitCount, // count of integer digits from the right so far - utl::DigitGroupingIterator & rGrouping ) // current grouping + utl::DigitGroupingIterator & rGrouping ) const // current grouping { if (NumFor[nIx].Info().bThousand) // Only if grouping fill in separators { |