diff options
author | Noel Grandin <noelgrandin@gmail.com> | 2021-09-24 11:54:23 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2021-09-24 16:24:21 +0200 |
commit | e69ca434253d3278975078600f8a77291d97b9fc (patch) | |
tree | 37bb648f47d54f24a517d86c30f1e291dbc6de5d /sc | |
parent | 632e7b9d43f820250acb190835f50fb50f76b725 (diff) |
no need to allocate this SfxItemSet on the heap
Change-Id: I4982d075f21f74b3d0db1c61a499dceb92e50c87
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/122575
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sc')
-rw-r--r-- | sc/inc/cellsuno.hxx | 7 | ||||
-rw-r--r-- | sc/source/ui/unoobj/cellsuno.cxx | 26 |
2 files changed, 21 insertions, 12 deletions
diff --git a/sc/inc/cellsuno.hxx b/sc/inc/cellsuno.hxx index 7f1b1a0106ad..3d2080a29224 100644 --- a/sc/inc/cellsuno.hxx +++ b/sc/inc/cellsuno.hxx @@ -26,6 +26,7 @@ #include <rtl/ref.hxx> #include <sal/types.h> #include <tools/link.hxx> +#include <svl/itemset.hxx> #include <svl/lstner.hxx> #include <svl/listener.hxx> #include <com/sun/star/table/XTableChartsSupplier.hpp> @@ -89,6 +90,7 @@ #include <cppuhelper/weakref.hxx> #include <memory> +#include <optional> #include <vector> namespace com::sun::star::table { struct BorderLine2; } @@ -112,7 +114,6 @@ class SfxBroadcaster; class SfxHint; class SfxItemPropertyMap; class SfxItemPropertySet; -class SfxItemSet; struct SfxItemPropertyMapEntry; namespace editeng { class SvxBorderLine; } @@ -181,8 +182,8 @@ private: std::unique_ptr<ScLinkListener> pValueListener; std::unique_ptr<ScPatternAttr> pCurrentFlat; std::unique_ptr<ScPatternAttr> pCurrentDeep; - std::unique_ptr<SfxItemSet> pCurrentDataSet; - std::unique_ptr<SfxItemSet> pNoDfltCurrentDataSet; + std::optional<SfxItemSet> moCurrentDataSet; + std::optional<SfxItemSet> moNoDfltCurrentDataSet; std::unique_ptr<ScMarkData> pMarkData; ScRangeList aRanges; sal_Int64 nObjectId; diff --git a/sc/source/ui/unoobj/cellsuno.cxx b/sc/source/ui/unoobj/cellsuno.cxx index 0d9e076269bc..bab189c43d15 100644 --- a/sc/source/ui/unoobj/cellsuno.cxx +++ b/sc/source/ui/unoobj/cellsuno.cxx @@ -1432,10 +1432,8 @@ void ScCellRangesBase::ForgetCurrentAttrs() { pCurrentFlat.reset(); pCurrentDeep.reset(); - pCurrentDataSet.reset(); - pNoDfltCurrentDataSet.reset(); - pCurrentDataSet = nullptr; - pNoDfltCurrentDataSet = nullptr; + moCurrentDataSet.reset(); + moNoDfltCurrentDataSet.reset(); // #i62483# pMarkData can remain unchanged, is deleted only if the range changes (RefChanged) } @@ -1471,18 +1469,28 @@ const ScPatternAttr* ScCellRangesBase::GetCurrentAttrsDeep() SfxItemSet* ScCellRangesBase::GetCurrentDataSet(bool bNoDflt) { - if(!pCurrentDataSet) + if(!moCurrentDataSet) { const ScPatternAttr* pPattern = GetCurrentAttrsDeep(); if ( pPattern ) { // replace Dontcare with Default, so that we always have a reflection - pCurrentDataSet.reset( new SfxItemSet( pPattern->GetItemSet() ) ); - pNoDfltCurrentDataSet.reset( new SfxItemSet( pPattern->GetItemSet() ) ); - pCurrentDataSet->ClearInvalidItems(); + moCurrentDataSet.emplace( pPattern->GetItemSet() ); + moNoDfltCurrentDataSet.emplace( pPattern->GetItemSet() ); + moCurrentDataSet->ClearInvalidItems(); } } - return bNoDflt ? pNoDfltCurrentDataSet.get() : pCurrentDataSet.get(); + if (bNoDflt) + { + if (moNoDfltCurrentDataSet) + return &*moNoDfltCurrentDataSet; + } + else + { + if (moCurrentDataSet) + return &*moCurrentDataSet; + } + return nullptr; } const ScMarkData* ScCellRangesBase::GetMarkData() |