summaryrefslogtreecommitdiffstats
path: root/svl/source
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-07 11:48:25 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-07 11:48:25 +0000
commit9c0049cfae49c8e4ddef9125a69db2ad134c10c6 (patch)
tree812a86c0eee63dfc5ace12f2622ed3ce9cd3d680 /svl/source
parentReleasing progress-linux version 4:24.2.3-2~progress7.99u1. (diff)
downloadlibreoffice-9c0049cfae49c8e4ddef9125a69db2ad134c10c6.tar.xz
libreoffice-9c0049cfae49c8e4ddef9125a69db2ad134c10c6.zip
Merging upstream version 4:24.2.4.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'svl/source')
-rw-r--r--svl/source/items/IndexedStyleSheets.cxx12
-rw-r--r--svl/source/items/itemset.cxx18
-rw-r--r--svl/source/items/style.cxx36
-rw-r--r--svl/source/numbers/zforlist.cxx90
-rw-r--r--svl/source/numbers/zformat.cxx12
5 files changed, 85 insertions, 83 deletions
diff --git a/svl/source/items/IndexedStyleSheets.cxx b/svl/source/items/IndexedStyleSheets.cxx
index 57e2dddbf1..3761f0e427 100644
--- a/svl/source/items/IndexedStyleSheets.cxx
+++ b/svl/source/items/IndexedStyleSheets.cxx
@@ -83,6 +83,18 @@ sal_Int32 IndexedStyleSheets::GetNumberOfStyleSheets() const
}
void
+IndexedStyleSheets::ReindexOnNameChange(const OUString& rOldName, const OUString& rNewName)
+{
+ auto it = mPositionsByName.find(rOldName);
+ if (it != mPositionsByName.end())
+ {
+ unsigned nPos = it->second;
+ mPositionsByName.erase(it);
+ mPositionsByName.insert(std::make_pair(rNewName, nPos));
+ }
+}
+
+void
IndexedStyleSheets::AddStyleSheet(const rtl::Reference< SfxStyleSheetBase >& style)
{
if (!HasStyleSheet(style)) {
diff --git a/svl/source/items/itemset.cxx b/svl/source/items/itemset.cxx
index 66780cb581..fd9cbb1ddd 100644
--- a/svl/source/items/itemset.cxx
+++ b/svl/source/items/itemset.cxx
@@ -1891,11 +1891,8 @@ static void isMiss()
sal_uInt16 WhichRangesContainer::getOffsetFromWhich(sal_uInt16 nWhich) const
{
- if (empty())
- return INVALID_WHICHPAIR_OFFSET;
-
// special case for single entry - happens often e.g. UI stuff
- if (1 == m_size)
+ if (m_size == 1)
{
if( m_pairs->first <= nWhich && nWhich <= m_pairs->second )
return nWhich - m_pairs->first;
@@ -1904,6 +1901,9 @@ sal_uInt16 WhichRangesContainer::getOffsetFromWhich(sal_uInt16 nWhich) const
return INVALID_WHICHPAIR_OFFSET;
}
+ if (m_size == 0)
+ return INVALID_WHICHPAIR_OFFSET;
+
// check if nWhich is inside last successfully used WhichPair
if (INVALID_WHICHPAIR_OFFSET != m_aLastWhichPairOffset
&& m_aLastWhichPairFirst <= nWhich
@@ -1949,12 +1949,8 @@ sal_uInt16 WhichRangesContainer::getOffsetFromWhich(sal_uInt16 nWhich) const
sal_uInt16 WhichRangesContainer::getWhichFromOffset(sal_uInt16 nOffset) const
{
- // check for empty, if yes, return null which is an invalid WhichID
- if (empty())
- return 0;
-
// special case for single entry - happens often e.g. UI stuff
- if (1 == m_size)
+ if (m_size == 1)
{
if (nOffset <= m_pairs->second - m_pairs->first)
return m_pairs->first + nOffset;
@@ -1963,6 +1959,10 @@ sal_uInt16 WhichRangesContainer::getWhichFromOffset(sal_uInt16 nOffset) const
return 0;
}
+ // check for empty, if yes, return null which is an invalid WhichID
+ if (m_size == 0)
+ return 0;
+
// check if nWhich is inside last successfully used WhichPair
if (INVALID_WHICHPAIR_OFFSET != m_aLastWhichPairOffset)
{
diff --git a/svl/source/items/style.cxx b/svl/source/items/style.cxx
index 41551e5064..bfdbac6f3f 100644
--- a/svl/source/items/style.cxx
+++ b/svl/source/items/style.cxx
@@ -163,24 +163,24 @@ bool SfxStyleSheetBase::SetName(const OUString& rName, bool bReIndexNow)
if(rName.isEmpty())
return false;
- if( aName != rName )
- {
- OUString aOldName = aName;
- SfxStyleSheetBase *pOther = m_pPool->Find( rName, nFamily ) ;
- if ( pOther && pOther != this )
- return false;
+ if( aName == rName )
+ return true;
- if ( !aName.isEmpty() )
- m_pPool->ChangeParent(aName, rName, nFamily, false);
+ OUString aOldName = aName;
+ SfxStyleSheetBase *pOther = m_pPool->Find( rName, nFamily ) ;
+ if ( pOther && pOther != this )
+ return false;
- if ( aFollow == aName )
- aFollow = rName;
- aName = rName;
- if (bReIndexNow)
- m_pPool->Reindex();
+ if ( !aName.isEmpty() )
+ m_pPool->ChangeParent(aName, rName, nFamily, false);
- m_pPool->Broadcast( SfxStyleSheetModifiedHint( aOldName, *this ) );
- }
+ if ( aFollow == aName )
+ aFollow = rName;
+ aName = rName;
+ if (bReIndexNow)
+ m_pPool->ReindexOnNameChange(aOldName, rName);
+
+ m_pPool->Broadcast( SfxStyleSheetModifiedHint( aOldName, *this ) );
return true;
}
@@ -890,6 +890,12 @@ SfxStyleSheetBasePool::Reindex()
pImpl->mxIndexedStyleSheets->Reindex();
}
+void
+SfxStyleSheetBasePool::ReindexOnNameChange(const OUString& rOldName, const OUString& rNewName)
+{
+ pImpl->mxIndexedStyleSheets->ReindexOnNameChange(rOldName, rNewName);
+}
+
const svl::IndexedStyleSheets&
SfxStyleSheetBasePool::GetIndexedStyleSheets() const
{
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
{