diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2021-05-27 20:47:06 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2021-05-28 12:18:03 +0200 |
commit | 83fb7db6911aa77d713f3da0391b680e55563181 (patch) | |
tree | e54ce90695acf14f3a77ea4b2680997c22e55ae8 /reportdesign | |
parent | fbfb57635b602b50cb22465047ae5bcdbef3dd0a (diff) |
no need to allocate these SfxItemSet on the heap
use std::optional where the code needs to control the lifetime of the
object explicitly
Change-Id: Ia550ce051360f68911abc68c945a97d62a637b06
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/116291
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'reportdesign')
-rw-r--r-- | reportdesign/source/ui/misc/UITools.cxx | 12 | ||||
-rw-r--r-- | reportdesign/source/ui/report/ReportController.cxx | 24 |
2 files changed, 18 insertions, 18 deletions
diff --git a/reportdesign/source/ui/misc/UITools.cxx b/reportdesign/source/ui/misc/UITools.cxx index 2b806af28aeb..2cf762e48f8c 100644 --- a/reportdesign/source/ui/misc/UITools.cxx +++ b/reportdesign/source/ui/misc/UITools.cxx @@ -733,11 +733,11 @@ bool openCharDialog( const uno::Reference<report::XReportControlFormat >& _rxRep bool bSuccess = false; try { - ::std::unique_ptr<SfxItemSet> pDescriptor( new SfxItemSet( *pPool, pRanges ) ); - lcl_CharPropertiesToItems( _rxReportControlFormat, *pDescriptor ); + SfxItemSet aDescriptor( *pPool, pRanges ); + lcl_CharPropertiesToItems( _rxReportControlFormat, aDescriptor ); { // want the dialog to be destroyed before our set - ORptPageDialog aDlg(Application::GetFrameWeld(_rxParentWindow), pDescriptor.get(), "CharDialog"); + ORptPageDialog aDlg(Application::GetFrameWeld(_rxParentWindow), &aDescriptor, "CharDialog"); uno::Reference< report::XShape > xShape( _rxReportControlFormat, uno::UNO_QUERY ); if ( xShape.is() ) aDlg.RemoveTabPage("background"); @@ -776,12 +776,12 @@ bool openAreaDialog( const uno::Reference<report::XShape >& _xShape,const uno::R try { SfxItemPool& rItemPool = pModel->GetItemPool(); - ::std::unique_ptr<SfxItemSet> pDescriptor( new SfxItemSet( rItemPool, {{rItemPool.GetFirstWhich(),rItemPool.GetLastWhich()}} ) ); - lcl_fillShapeToItems(_xShape,*pDescriptor); + SfxItemSet aDescriptor( rItemPool, {{rItemPool.GetFirstWhich(),rItemPool.GetLastWhich()}} ); + lcl_fillShapeToItems(_xShape, aDescriptor); { // want the dialog to be destroyed before our set SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create(); - ScopedVclPtr<AbstractSvxAreaTabDialog> pDialog(pFact->CreateSvxAreaTabDialog(pParent, pDescriptor.get(), pModel.get(), true)); + ScopedVclPtr<AbstractSvxAreaTabDialog> pDialog(pFact->CreateSvxAreaTabDialog(pParent, &aDescriptor, pModel.get(), true)); if ( RET_OK == pDialog->Execute() ) { bSuccess = true; diff --git a/reportdesign/source/ui/report/ReportController.cxx b/reportdesign/source/ui/report/ReportController.cxx index 03bfb73160a1..e08bc607b6ca 100644 --- a/reportdesign/source/ui/report/ReportController.cxx +++ b/reportdesign/source/ui/report/ReportController.cxx @@ -2418,18 +2418,18 @@ void OReportController::openPageDialog(const uno::Reference<report::XSection>& _ try { - ::std::unique_ptr<SfxItemSet> pDescriptor(new SfxItemSet(*pPool, pRanges)); + SfxItemSet aDescriptor(*pPool, pRanges); // fill it if ( _xSection.is() ) - pDescriptor->Put(SvxBrushItem(::Color(ColorTransparency, _xSection->getBackColor()),RPTUI_ID_BRUSH)); + aDescriptor.Put(SvxBrushItem(::Color(ColorTransparency, _xSection->getBackColor()),RPTUI_ID_BRUSH)); else { - pDescriptor->Put(SvxSizeItem(RPTUI_ID_SIZE,VCLSize(getStyleProperty<awt::Size>(m_xReportDefinition,PROPERTY_PAPERSIZE)))); - pDescriptor->Put(SvxLRSpaceItem(getStyleProperty<sal_Int32>(m_xReportDefinition,PROPERTY_LEFTMARGIN) + aDescriptor.Put(SvxSizeItem(RPTUI_ID_SIZE,VCLSize(getStyleProperty<awt::Size>(m_xReportDefinition,PROPERTY_PAPERSIZE)))); + aDescriptor.Put(SvxLRSpaceItem(getStyleProperty<sal_Int32>(m_xReportDefinition,PROPERTY_LEFTMARGIN) ,getStyleProperty<sal_Int32>(m_xReportDefinition,PROPERTY_RIGHTMARGIN),0,0,RPTUI_ID_LRSPACE)); - pDescriptor->Put(SvxULSpaceItem(static_cast<sal_uInt16>(getStyleProperty<sal_Int32>(m_xReportDefinition,PROPERTY_TOPMARGIN)) + aDescriptor.Put(SvxULSpaceItem(static_cast<sal_uInt16>(getStyleProperty<sal_Int32>(m_xReportDefinition,PROPERTY_TOPMARGIN)) ,static_cast<sal_uInt16>(getStyleProperty<sal_Int32>(m_xReportDefinition,PROPERTY_BOTTOMMARGIN)),RPTUI_ID_ULSPACE)); - pDescriptor->Put(SfxUInt16Item(SID_ATTR_METRIC,static_cast<sal_uInt16>(eUserMetric))); + aDescriptor.Put(SfxUInt16Item(SID_ATTR_METRIC,static_cast<sal_uInt16>(eUserMetric))); uno::Reference< style::XStyle> xPageStyle(getUsedStyle(m_xReportDefinition)); if ( xPageStyle.is() ) @@ -2440,14 +2440,14 @@ void OReportController::openPageDialog(const uno::Reference<report::XSection>& _ aPageItem.PutValue(xProp->getPropertyValue(PROPERTY_PAGESTYLELAYOUT),MID_PAGE_LAYOUT); aPageItem.SetLandscape(getStyleProperty<bool>(m_xReportDefinition,PROPERTY_ISLANDSCAPE)); aPageItem.SetNumType(static_cast<SvxNumType>(getStyleProperty<sal_Int16>(m_xReportDefinition,PROPERTY_NUMBERINGTYPE))); - pDescriptor->Put(aPageItem); - pDescriptor->Put(SvxBrushItem(::Color(ColorTransparency, getStyleProperty<sal_Int32>(m_xReportDefinition,PROPERTY_BACKCOLOR)),RPTUI_ID_BRUSH)); + aDescriptor.Put(aPageItem); + aDescriptor.Put(SvxBrushItem(::Color(ColorTransparency, getStyleProperty<sal_Int32>(m_xReportDefinition,PROPERTY_BACKCOLOR)),RPTUI_ID_BRUSH)); } } { // want the dialog to be destroyed before our set ORptPageDialog aDlg( - getFrameWeld(), pDescriptor.get(),_xSection.is() + getFrameWeld(), &aDescriptor,_xSection.is() ? OUString("BackgroundDialog") : OUString("PageDialog")); if (aDlg.run() == RET_OK) @@ -4223,13 +4223,13 @@ void OReportController::openZoomDialog() pPool->FreezeIdRanges(); // the same try { - ::std::unique_ptr<SfxItemSet> pDescriptor(new SfxItemSet(*pPool, pRanges)); + SfxItemSet aDescriptor(*pPool, pRanges); // fill it SvxZoomItem aZoomItem( m_eZoomType, m_nZoomValue, SID_ATTR_ZOOM ); aZoomItem.SetValueSet(SvxZoomEnableFlags::N100|SvxZoomEnableFlags::WHOLEPAGE|SvxZoomEnableFlags::PAGEWIDTH); - pDescriptor->Put(aZoomItem); + aDescriptor.Put(aZoomItem); - ScopedVclPtr<AbstractSvxZoomDialog> pDlg(pFact->CreateSvxZoomDialog(nullptr, *pDescriptor)); + ScopedVclPtr<AbstractSvxZoomDialog> pDlg(pFact->CreateSvxZoomDialog(nullptr, aDescriptor)); pDlg->SetLimits( 20, 400 ); bool bCancel = ( RET_CANCEL == pDlg->Execute() ); |