summaryrefslogtreecommitdiff
path: root/svl
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2024-04-17 14:41:48 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2024-04-18 08:14:06 +0200
commit5060893f0b69c094beae73ab1a0926e3feb249b2 (patch)
treed2037c633e68054c1e74aed9d63c71a64e610c53 /svl
parenteeeff49f40c08cb3b53dba837590de3065990917 (diff)
tdf#160706 speed up loading conditional formatting rule in XLS (II)
Reduce the work we do in IndexedStyleSheets::Reindex takes my test document from 117s to 48s Change-Id: I2e23b05684d0f2e3a9dc05c0a0fc4e9bbea7008d Reviewed-on: https://gerrit.libreoffice.org/c/core/+/166180 Tested-by: Noel Grandin <noel.grandin@collabora.co.uk> Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'svl')
-rw-r--r--svl/source/items/IndexedStyleSheets.cxx12
-rw-r--r--svl/source/items/style.cxx36
2 files changed, 33 insertions, 15 deletions
diff --git a/svl/source/items/IndexedStyleSheets.cxx b/svl/source/items/IndexedStyleSheets.cxx
index 351e56425036..adce9bf1dca2 100644
--- a/svl/source/items/IndexedStyleSheets.cxx
+++ b/svl/source/items/IndexedStyleSheets.cxx
@@ -69,6 +69,18 @@ IndexedStyleSheets::Reindex()
}
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/style.cxx b/svl/source/items/style.cxx
index bcd90faeaef4..8a2da70793e6 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;
}
@@ -889,6 +889,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
{