diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2024-08-15 18:51:28 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2024-08-15 22:04:36 +0200 |
commit | afe19beb79c3f88e42fd4b1d9b87cd324092197f (patch) | |
tree | 2e52d74e68e660583f992948eca12009005ce50f /sw | |
parent | bd0c2772f843dd9ae6c82d00665e303c20a48a73 (diff) |
tdf#158556 cache SwDocStyleSheet
so we dont keep creating it again. Shaves 3% off the load time.
Change-Id: Id67927f854d55769f76e56c6bc9a9e9bb05eea6c
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/171919
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sw')
-rw-r--r-- | sw/inc/unoxstyle.hxx | 3 | ||||
-rw-r--r-- | sw/source/core/unocore/unostyle.cxx | 10 |
2 files changed, 12 insertions, 1 deletions
diff --git a/sw/inc/unoxstyle.hxx b/sw/inc/unoxstyle.hxx index 6ccade4592ad..b33a8e4130b7 100644 --- a/sw/inc/unoxstyle.hxx +++ b/sw/inc/unoxstyle.hxx @@ -43,6 +43,7 @@ class SwDoc; class SfxItemPropertySet; class SwDocShell; class SwXNumberingRules; +class SwDocStyleSheet; class SAL_DLLPUBLIC_RTTI SwXStyle : public cppu::ImplInheritanceHelper< @@ -57,6 +58,8 @@ class SAL_DLLPUBLIC_RTTI SwXStyle bool m_bIsDescriptor; bool m_bIsConditional; OUString m_sParentStyleName; + // cache UNO stylesheets + std::unordered_map<SfxStyleSheetBase*, rtl::Reference<SwDocStyleSheet>> maUnoStyleSheets; protected: SfxStyleSheetBasePool* m_pBasePool; diff --git a/sw/source/core/unocore/unostyle.cxx b/sw/source/core/unocore/unostyle.cxx index fb41a7d9364f..5c69f446d6ef 100644 --- a/sw/source/core/unocore/unostyle.cxx +++ b/sw/source/core/unocore/unostyle.cxx @@ -2433,7 +2433,15 @@ void SwXStyle::getToggleAttributes( assert(m_pBasePool); SfxStyleSheetBase* pStyleSheetBase = m_pBasePool->Find(m_sStyleName, m_rEntry.family()); assert(pStyleSheetBase); - rtl::Reference<SwDocStyleSheet> xDocStyleSheet = new SwDocStyleSheet(*static_cast<SwDocStyleSheet*>(pStyleSheetBase)); + rtl::Reference<SwDocStyleSheet> xDocStyleSheet; + auto it = maUnoStyleSheets.find(pStyleSheetBase); + if (it != maUnoStyleSheets.end()) + xDocStyleSheet = it->second; + else + { + xDocStyleSheet = new SwDocStyleSheet(*static_cast<SwDocStyleSheet*>(pStyleSheetBase)); + maUnoStyleSheets.insert({pStyleSheetBase, xDocStyleSheet}); + } const SfxItemSet& rItemSet(xDocStyleSheet->GetItemSet()); assert(rItemSet.GetParent()); |