diff options
author | Caolán McNamara <caolan.mcnamara@collabora.com> | 2024-06-05 16:33:45 +0100 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2024-06-06 08:26:42 +0200 |
commit | 9fa0b6977ba8292bfcc313caf080733090974c3f (patch) | |
tree | 165265e089952d77c2445ed9d113985bfd0a709f /svl | |
parent | 039a18ff147be304966caf529e6f14ad4996a3e0 (diff) |
Resolves: tdf#161430 reindex the correct style if there are duplicate names
Change-Id: I6d4e96faef3ec6caa038edf7595f91f20d964807
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/168479
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'svl')
-rw-r--r-- | svl/source/items/IndexedStyleSheets.cxx | 16 | ||||
-rw-r--r-- | svl/source/items/style.cxx | 6 |
2 files changed, 13 insertions, 9 deletions
diff --git a/svl/source/items/IndexedStyleSheets.cxx b/svl/source/items/IndexedStyleSheets.cxx index adce9bf1dca2..0db2f201f35f 100644 --- a/svl/source/items/IndexedStyleSheets.cxx +++ b/svl/source/items/IndexedStyleSheets.cxx @@ -69,14 +69,18 @@ IndexedStyleSheets::Reindex() } void -IndexedStyleSheets::ReindexOnNameChange(const OUString& rOldName, const OUString& rNewName) +IndexedStyleSheets::ReindexOnNameChange(const SfxStyleSheetBase& style, const OUString& rOldName, const OUString& rNewName) { - auto it = mPositionsByName.find(rOldName); - if (it != mPositionsByName.end()) + std::pair<MapType::const_iterator, MapType::const_iterator> range = mPositionsByName.equal_range(rOldName); + for (MapType::const_iterator it = range.first; it != range.second; ++it) { - unsigned nPos = it->second; - mPositionsByName.erase(it); - mPositionsByName.insert(std::make_pair(rNewName, nPos)); + if (mStyleSheets[it->second].get() == &style) + { + unsigned nPos = it->second; + mPositionsByName.erase(it); + mPositionsByName.insert(std::make_pair(rNewName, nPos)); + break; + } } } diff --git a/svl/source/items/style.cxx b/svl/source/items/style.cxx index a43e326ad877..3827b7cb0e7d 100644 --- a/svl/source/items/style.cxx +++ b/svl/source/items/style.cxx @@ -178,7 +178,7 @@ bool SfxStyleSheetBase::SetName(const OUString& rName, bool bReIndexNow) aFollow = rName; aName = rName; if (bReIndexNow) - m_pPool->ReindexOnNameChange(aOldName, rName); + m_pPool->ReindexOnNameChange(*this, aOldName, rName); m_pPool->Broadcast( SfxStyleSheetModifiedHint( aOldName, *this ) ); return true; @@ -890,9 +890,9 @@ SfxStyleSheetBasePool::Reindex() } void -SfxStyleSheetBasePool::ReindexOnNameChange(const OUString& rOldName, const OUString& rNewName) +SfxStyleSheetBasePool::ReindexOnNameChange(const SfxStyleSheetBase& style, const OUString& rOldName, const OUString& rNewName) { - pImpl->mxIndexedStyleSheets->ReindexOnNameChange(rOldName, rNewName); + pImpl->mxIndexedStyleSheets->ReindexOnNameChange(style, rOldName, rNewName); } const svl::IndexedStyleSheets& |