diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2022-02-17 12:19:49 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2022-02-27 19:42:58 +0100 |
commit | 31e7845339b30a69f06a04619660398fe4267268 (patch) | |
tree | 049ffea6c16bfa05e798ca9dac81aa1a05a17aef /sd | |
parent | c97a3592c78ce276a353f95ce68c70a8a39174a0 (diff) |
use more SfxItemSet::CloneAsValue
to reduce heap allocations
Change-Id: Ia755c3e7f9610a5441a447cc74ea38ebcef068bc
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/130066
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sd')
-rw-r--r-- | sd/source/ui/view/drviews2.cxx | 22 | ||||
-rw-r--r-- | sd/source/ui/view/drviews7.cxx | 10 |
2 files changed, 16 insertions, 16 deletions
diff --git a/sd/source/ui/view/drviews2.cxx b/sd/source/ui/view/drviews2.cxx index bef73c1726d3..1cd427e8b6f8 100644 --- a/sd/source/ui/view/drviews2.cxx +++ b/sd/source/ui/view/drviews2.cxx @@ -543,12 +543,12 @@ public: } }; - void lcl_convertStringArguments(sal_uInt16 nSlot, const std::unique_ptr<SfxItemSet>& pArgs) + void lcl_convertStringArguments(sal_uInt16 nSlot, SfxItemSet& rArgs) { Color aColor; const SfxPoolItem* pItem = nullptr; - if (SfxItemState::SET == pArgs->GetItemState(SID_ATTR_LINE_WIDTH_ARG, false, &pItem)) + if (SfxItemState::SET == rArgs.GetItemState(SID_ATTR_LINE_WIDTH_ARG, false, &pItem)) { double fValue = static_cast<const SvxDoubleItem*>(pItem)->GetValue(); // FIXME: different units... @@ -556,9 +556,9 @@ public: int nValue = fValue * nPow; XLineWidthItem aItem(nValue); - pArgs->Put(aItem); + rArgs.Put(aItem); } - if (SfxItemState::SET == pArgs->GetItemState(SID_ATTR_COLOR_STR, false, &pItem)) + if (SfxItemState::SET == rArgs.GetItemState(SID_ATTR_COLOR_STR, false, &pItem)) { OUString sColor = static_cast<const SfxStringItem*>(pItem)->GetValue(); @@ -572,26 +572,26 @@ public: case SID_ATTR_LINE_COLOR: { XLineColorItem aLineColorItem(OUString(), aColor); - pArgs->Put(aLineColorItem); + rArgs.Put(aLineColorItem); break; } case SID_ATTR_FILL_COLOR: { XFillColorItem aFillColorItem(OUString(), aColor); - pArgs->Put(aFillColorItem); + rArgs.Put(aFillColorItem); break; } } } - if (SfxItemState::SET == pArgs->GetItemState(SID_FILL_GRADIENT_JSON, false, &pItem)) + if (SfxItemState::SET == rArgs.GetItemState(SID_FILL_GRADIENT_JSON, false, &pItem)) { const SfxStringItem* pJSON = static_cast<const SfxStringItem*>(pItem); if (pJSON) { XGradient aGradient = XGradient::fromJSON(pJSON->GetValue()); XFillGradientItem aItem(aGradient); - pArgs->Put(aItem); + rArgs.Put(aItem); } } } @@ -683,9 +683,9 @@ void DrawViewShell::FuTemporary(SfxRequest& rReq) { if( rReq.GetArgs() ) { - std::unique_ptr<SfxItemSet> pNewArgs = rReq.GetArgs()->Clone(); - lcl_convertStringArguments(rReq.GetSlot(), pNewArgs); - mpDrawView->SetAttributes(*pNewArgs); + SfxItemSet aNewArgs = rReq.GetArgs()->CloneAsValue(); + lcl_convertStringArguments(rReq.GetSlot(), aNewArgs); + mpDrawView->SetAttributes(aNewArgs); rReq.Done(); } else diff --git a/sd/source/ui/view/drviews7.cxx b/sd/source/ui/view/drviews7.cxx index 0f94af51feb8..cf0eb92c3828 100644 --- a/sd/source/ui/view/drviews7.cxx +++ b/sd/source/ui/view/drviews7.cxx @@ -1780,7 +1780,7 @@ void DrawViewShell::SetPageProperties (SfxRequest& rReq) { SdrPageProperties& rPageProperties = pPage->getSdrPageProperties(); const SfxItemSet &aPageItemSet = rPageProperties.GetItemSet(); - std::unique_ptr<SfxItemSet> pTempSet = aPageItemSet.Clone(false, &mpDrawView->GetModel()->GetItemPool()); + SfxItemSet aTempSet = aPageItemSet.CloneAsValue(false, &mpDrawView->GetModel()->GetItemPool()); const SfxPoolItem* pItem = nullptr; rPageProperties.ClearItem(XATTR_FILLSTYLE); @@ -1837,10 +1837,10 @@ void DrawViewShell::SetPageProperties (SfxRequest& rReq) // MigrateItemSet guarantees unique gradient names SfxItemSetFixed<XATTR_FILLGRADIENT, XATTR_FILLGRADIENT> aMigrateSet( mpDrawView->GetModel()->GetItemPool() ); aMigrateSet.Put( aGradientItem ); - SdrModel::MigrateItemSet( &aMigrateSet, pTempSet.get(), mpDrawView->GetModel() ); + SdrModel::MigrateItemSet( &aMigrateSet, &aTempSet, mpDrawView->GetModel() ); rPageProperties.PutItem( XFillStyleItem( drawing::FillStyle_GRADIENT ) ); - rPageProperties.PutItemSet( *pTempSet ); + rPageProperties.PutItemSet( aTempSet ); } else { @@ -1849,10 +1849,10 @@ void DrawViewShell::SetPageProperties (SfxRequest& rReq) // MigrateItemSet guarantees unique gradient names SfxItemSetFixed<XATTR_FILLGRADIENT, XATTR_FILLGRADIENT> aMigrateSet( mpDrawView->GetModel()->GetItemPool() ); aMigrateSet.Put( aGradientItem ); - SdrModel::MigrateItemSet( &aMigrateSet, pTempSet.get(), mpDrawView->GetModel() ); + SdrModel::MigrateItemSet( &aMigrateSet, &aTempSet, mpDrawView->GetModel() ); rPageProperties.PutItem( XFillStyleItem( drawing::FillStyle_GRADIENT ) ); - rPageProperties.PutItemSet( *pTempSet ); + rPageProperties.PutItemSet( aTempSet ); } } break; |