summaryrefslogtreecommitdiffstats
path: root/svl/source/items
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/items
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/items')
-rw-r--r--svl/source/items/IndexedStyleSheets.cxx12
-rw-r--r--svl/source/items/itemset.cxx18
-rw-r--r--svl/source/items/style.cxx36
3 files changed, 42 insertions, 24 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
{