[Libreoffice-commits] core.git: editeng/source filter/source sc/source sd/source
Noel Grandin (via logerrit)
logerrit at kemper.freedesktop.org
Fri Jul 2 13:35:19 UTC 2021
editeng/source/uno/unotext.cxx | 29 ++++++++++++++---------------
filter/source/msfilter/svdfppt.cxx | 6 +++---
sc/source/core/tool/editutil.cxx | 4 ++--
sc/source/ui/app/inputhdl.cxx | 6 +++---
sc/source/ui/view/cellsh3.cxx | 21 ++++++++-------------
sc/source/ui/view/viewfun4.cxx | 7 +++----
sd/source/ui/func/fupage.cxx | 12 ++++++------
sd/source/ui/view/drviews2.cxx | 6 +++---
sd/source/ui/view/drviewsf.cxx | 4 ++--
9 files changed, 44 insertions(+), 51 deletions(-)
New commits:
commit 2024780f9e169a6c1d167e494d37f46f7640dc97
Author: Noel Grandin <noel.grandin at collabora.co.uk>
AuthorDate: Thu Jul 1 11:01:40 2021 +0200
Commit: Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Fri Jul 2 15:34:38 2021 +0200
can allocate these SfxItemSet on the stack
Change-Id: I85a749429a3a14aca5c6eaeaa5da37b25eb9f730
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/118283
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>
diff --git a/editeng/source/uno/unotext.cxx b/editeng/source/uno/unotext.cxx
index cae30b9eaa99..cf9ea10a601e 100644
--- a/editeng/source/uno/unotext.cxx
+++ b/editeng/source/uno/unotext.cxx
@@ -770,11 +770,11 @@ void SvxUnoTextRangeBase::_setPropertyValues( const uno::Sequence< OUString >& a
nEndPara = aSel.nEndPara;
}
- std::unique_ptr<SfxItemSet> pOldAttrSet;
- std::unique_ptr<SfxItemSet> pNewAttrSet;
+ std::optional<SfxItemSet> pOldAttrSet;
+ std::optional<SfxItemSet> pNewAttrSet;
- std::unique_ptr<SfxItemSet> pOldParaSet;
- std::unique_ptr<SfxItemSet> pNewParaSet;
+ std::optional<SfxItemSet> pOldParaSet;
+ std::optional<SfxItemSet> pNewParaSet;
for( ; nCount; nCount--, pPropertyNames++, pValues++ )
{
@@ -786,11 +786,10 @@ void SvxUnoTextRangeBase::_setPropertyValues( const uno::Sequence< OUString >& a
if( (nPara == -1) && !bParaAttrib )
{
- if( nullptr == pNewAttrSet )
+ if( !pNewAttrSet )
{
- const SfxItemSet aSet( pForwarder->GetAttribs( aSel ) );
- pOldAttrSet.reset(new SfxItemSet( aSet ));
- pNewAttrSet.reset(new SfxItemSet( *pOldAttrSet->GetPool(), pOldAttrSet->GetRanges() ));
+ pOldAttrSet.emplace( pForwarder->GetAttribs( aSel ) );
+ pNewAttrSet.emplace( *pOldAttrSet->GetPool(), pOldAttrSet->GetRanges() );
}
setPropertyValue( pMap, *pValues, GetSelection(), *pOldAttrSet, *pNewAttrSet );
@@ -806,11 +805,11 @@ void SvxUnoTextRangeBase::_setPropertyValues( const uno::Sequence< OUString >& a
}
else
{
- if( nullptr == pNewParaSet )
+ if( !pNewParaSet )
{
const SfxItemSet & rSet = pForwarder->GetParaAttribs( nTempPara );
- pOldParaSet.reset(new SfxItemSet( rSet ));
- pNewParaSet.reset(new SfxItemSet( *pOldParaSet->GetPool(), pOldParaSet->GetRanges() ));
+ pOldParaSet.emplace( rSet );
+ pNewParaSet.emplace( *pOldParaSet->GetPool(), pOldParaSet->GetRanges() );
}
setPropertyValue( pMap, *pValues, GetSelection(), *pOldParaSet, *pNewParaSet );
@@ -1037,23 +1036,23 @@ uno::Sequence< beans::PropertyState > SvxUnoTextRangeBase::_getPropertyStates(co
SvxTextForwarder* pForwarder = mpEditSource ? mpEditSource->GetTextForwarder() : nullptr;
if( pForwarder )
{
- std::unique_ptr<SfxItemSet> pSet;
+ std::optional<SfxItemSet> pSet;
if( nPara != -1 )
{
- pSet.reset(new SfxItemSet( pForwarder->GetParaAttribs( nPara ) ));
+ pSet.emplace( pForwarder->GetParaAttribs( nPara ) );
}
else
{
ESelection aSel( GetSelection() );
CheckSelection( aSel, pForwarder );
- pSet.reset(new SfxItemSet( pForwarder->GetAttribs( aSel, EditEngineAttribs::OnlyHard ) ));
+ pSet.emplace( pForwarder->GetAttribs( aSel, EditEngineAttribs::OnlyHard ) );
}
beans::PropertyState* pState = aRet.getArray();
for( const OUString& rName : PropertyName )
{
const SfxItemPropertyMapEntry* pMap = mpPropSet->getPropertyMapEntry( rName );
- if( !_getOnePropertyStates(pSet.get(), pMap, *pState++) )
+ if( !_getOnePropertyStates(&*pSet, pMap, *pState++) )
{
throw beans::UnknownPropertyException(rName);
}
diff --git a/filter/source/msfilter/svdfppt.cxx b/filter/source/msfilter/svdfppt.cxx
index f7ef3675a03d..0de16f0a6689 100644
--- a/filter/source/msfilter/svdfppt.cxx
+++ b/filter/source/msfilter/svdfppt.cxx
@@ -3049,7 +3049,7 @@ sal_uInt16 SdrPowerPointImport::GetMasterPageIndex( sal_uInt16 nPageNum, PptPage
SdrObject* SdrPowerPointImport::ImportPageBackgroundObject( const SdrPage& rPage, sal_uInt32& nBgFileOffset )
{
SdrObject* pRet = nullptr;
- std::unique_ptr<SfxItemSet> pSet;
+ std::optional<SfxItemSet> pSet;
sal_uLong nOldFPos = rStCtrl.Tell(); // remember FilePos for restoring it later
DffRecordHeader aPageHd;
if ( SeekToCurrentPage( &aPageHd ) )
@@ -3074,7 +3074,7 @@ SdrObject* SdrPowerPointImport::ImportPageBackgroundObject( const SdrPage& rPage
ReadDffPropSet( rStCtrl, static_cast<DffPropertyReader&>(*this) );
mnFix16Angle = Fix16ToAngle( GetPropertyValue( DFF_Prop_Rotation, 0 ) );
sal_uInt32 nColor = GetPropertyValue( DFF_Prop_fillColor, 0xffffff );
- pSet.reset(new SfxItemSet( pSdrModel->GetItemPool() ));
+ pSet.emplace( pSdrModel->GetItemPool() );
DffObjData aObjData( aEscherObjectHd, tools::Rectangle( 0, 0, 28000, 21000 ), 0 );
ApplyAttributes( rStCtrl, *pSet, aObjData );
Color aColor( MSO_CLR_ToColor( nColor ) );
@@ -3087,7 +3087,7 @@ SdrObject* SdrPowerPointImport::ImportPageBackgroundObject( const SdrPage& rPage
rStCtrl.Seek( nOldFPos ); // restore FilePos
if ( !pSet )
{
- pSet.reset(new SfxItemSet( pSdrModel->GetItemPool() ));
+ pSet.emplace( pSdrModel->GetItemPool() );
pSet->Put( XFillStyleItem( drawing::FillStyle_NONE ) );
}
pSet->Put( XLineStyleItem( drawing::LineStyle_NONE ) );
diff --git a/sc/source/core/tool/editutil.cxx b/sc/source/core/tool/editutil.cxx
index b47c2bd7ee39..de1205af7d23 100644
--- a/sc/source/core/tool/editutil.cxx
+++ b/sc/source/core/tool/editutil.cxx
@@ -677,7 +677,7 @@ void ScEditEngineDefaulter::RepeatDefaults()
void ScEditEngineDefaulter::RemoveParaAttribs()
{
- std::unique_ptr<SfxItemSet> pCharItems;
+ std::optional<SfxItemSet> pCharItems;
bool bUpdateMode = GetUpdateMode();
if ( bUpdateMode )
SetUpdateMode( false );
@@ -695,7 +695,7 @@ void ScEditEngineDefaulter::RemoveParaAttribs()
if ( !pDefaults || *pParaItem != pDefaults->Get(nWhich) )
{
if (!pCharItems)
- pCharItems.reset(new SfxItemSet( GetEmptyItemSet() ));
+ pCharItems.emplace( GetEmptyItemSet() );
pCharItems->Put( *pParaItem );
}
}
diff --git a/sc/source/ui/app/inputhdl.cxx b/sc/source/ui/app/inputhdl.cxx
index a8bf4a39e8f9..f01f93d46d70 100644
--- a/sc/source/ui/app/inputhdl.cxx
+++ b/sc/source/ui/app/inputhdl.cxx
@@ -3088,7 +3088,7 @@ void ScInputHandler::EnterHandler( ScEnterMode nBlockMode )
// Find common (cell) attributes before RemoveAdjust
if ( pActiveViewSh && bUniformAttribs )
{
- std::unique_ptr<SfxItemSet> pCommonAttrs;
+ std::optional<SfxItemSet> pCommonAttrs;
for (sal_uInt16 nId = EE_CHAR_START; nId <= EE_CHAR_END; nId++)
{
SfxItemState eState = aOldAttribs.GetItemState( nId, false, &pItem );
@@ -3098,7 +3098,7 @@ void ScInputHandler::EnterHandler( ScEnterMode nBlockMode )
*pItem != pEditDefaults->Get(nId) )
{
if ( !pCommonAttrs )
- pCommonAttrs.reset(new SfxItemSet( mpEditEngine->GetEmptyItemSet() ));
+ pCommonAttrs.emplace( mpEditEngine->GetEmptyItemSet() );
pCommonAttrs->Put( *pItem );
}
}
@@ -3107,7 +3107,7 @@ void ScInputHandler::EnterHandler( ScEnterMode nBlockMode )
{
ScDocument& rDoc = pActiveViewSh->GetViewData().GetDocument();
pCellAttrs = std::make_unique<ScPatternAttr>(rDoc.GetPool());
- pCellAttrs->GetFromEditItemSet( pCommonAttrs.get() );
+ pCellAttrs->GetFromEditItemSet( &*pCommonAttrs );
}
}
diff --git a/sc/source/ui/view/cellsh3.cxx b/sc/source/ui/view/cellsh3.cxx
index b98440d9e552..25c808886443 100644
--- a/sc/source/ui/view/cellsh3.cxx
+++ b/sc/source/ui/view/cellsh3.cxx
@@ -454,27 +454,22 @@ void ScCellShell::Execute( SfxRequest& rReq )
// set cell attribute without dialog:
- std::unique_ptr<SfxItemSet> pEmptySet(
- new SfxItemSet( *pReqArgs->GetPool(),
- svl::Items<ATTR_PATTERN_START,
- ATTR_PATTERN_END>{} ));
+ SfxItemSet aEmptySet( *pReqArgs->GetPool(),
+ svl::Items<ATTR_PATTERN_START,
+ ATTR_PATTERN_END>{} );
- std::unique_ptr<SfxItemSet> pNewSet(
- new SfxItemSet( *pReqArgs->GetPool(),
- svl::Items<ATTR_PATTERN_START,
- ATTR_PATTERN_END>{} ));
+ SfxItemSet aNewSet( *pReqArgs->GetPool(),
+ svl::Items<ATTR_PATTERN_START,
+ ATTR_PATTERN_END>{} );
const SfxPoolItem* pAttr = nullptr;
sal_uInt16 nWhich = 0;
for ( nWhich=ATTR_PATTERN_START; nWhich<=ATTR_PATTERN_END; nWhich++ )
if ( pReqArgs->GetItemState( nWhich, true, &pAttr ) == SfxItemState::SET )
- pNewSet->Put( *pAttr );
+ aNewSet.Put( *pAttr );
- pTabViewShell->ApplyAttributes( pNewSet.get(), pEmptySet.get() );
-
- pNewSet.reset();
- pEmptySet.reset();
+ pTabViewShell->ApplyAttributes( &aNewSet, &aEmptySet );
rReq.Done();
}
diff --git a/sc/source/ui/view/viewfun4.cxx b/sc/source/ui/view/viewfun4.cxx
index c19240f6cba5..0fa16227d574 100644
--- a/sc/source/ui/view/viewfun4.cxx
+++ b/sc/source/ui/view/viewfun4.cxx
@@ -362,13 +362,12 @@ void ScViewFunc::DoThesaurus()
pThesaurusEngine->SetRefDevice(GetViewData().GetActiveWin()->GetOutDev());
pThesaurusEngine->SetSpeller(xSpeller);
MakeEditView(pThesaurusEngine.get(), nCol, nRow );
- std::unique_ptr<SfxItemSet> pEditDefaults(
- new SfxItemSet(pThesaurusEngine->GetEmptyItemSet()));
+ SfxItemSet aEditDefaults(pThesaurusEngine->GetEmptyItemSet());
const ScPatternAttr* pPattern = rDoc.GetPattern(nCol, nRow, nTab);
if (pPattern)
{
- pPattern->FillEditItemSet( pEditDefaults.get() );
- pThesaurusEngine->SetDefaults( *pEditDefaults );
+ pPattern->FillEditItemSet( &aEditDefaults );
+ pThesaurusEngine->SetDefaults( aEditDefaults );
}
if (aOldText.meType == CELLTYPE_EDIT)
diff --git a/sd/source/ui/func/fupage.cxx b/sd/source/ui/func/fupage.cxx
index 6d5fdbc896ec..32b98a08bf58 100644
--- a/sd/source/ui/func/fupage.cxx
+++ b/sd/source/ui/func/fupage.cxx
@@ -285,7 +285,7 @@ const SfxItemSet* FuPage::ExecuteDialog(weld::Window* pParent, const SfxRequest&
MergePageBackgroundFilling(mpPage, pStyleSheet, mbMasterPage, aMergedAttr);
}
- std::unique_ptr< SfxItemSet > pTempSet;
+ std::optional< SfxItemSet > pTempSet;
const sal_uInt16 nId = GetSlotID();
if (nId == SID_SAVE_BACKGROUND)
@@ -330,14 +330,14 @@ const SfxItemSet* FuPage::ExecuteDialog(weld::Window* pParent, const SfxRequest&
if (nError == ERRCODE_NONE)
{
- pTempSet.reset( new SfxItemSet( mpDoc->GetPool(), svl::Items<XATTR_FILL_FIRST, XATTR_FILL_LAST>{}) );
+ pTempSet.emplace( mpDoc->GetPool(), svl::Items<XATTR_FILL_FIRST, XATTR_FILL_LAST>{} );
pTempSet->Put( XFillStyleItem( drawing::FillStyle_BITMAP ) );
// MigrateItemSet makes sure the XFillBitmapItem will have a unique name
SfxItemSet aMigrateSet( mpDoc->GetPool(), svl::Items<XATTR_FILLBITMAP, XATTR_FILLBITMAP>{} );
aMigrateSet.Put(XFillBitmapItem("background", aGraphic));
- SdrModel::MigrateItemSet( &aMigrateSet, pTempSet.get(), mpDoc );
+ SdrModel::MigrateItemSet( &aMigrateSet, &*pTempSet, mpDoc );
pTempSet->Put( XFillBmpStretchItem( true ));
pTempSet->Put( XFillBmpTileItem( false ));
@@ -352,7 +352,7 @@ const SfxItemSet* FuPage::ExecuteDialog(weld::Window* pParent, const SfxRequest&
SdAbstractDialogFactory* pFact = SdAbstractDialogFactory::Create();
ScopedVclPtr<SfxAbstractTabDialog> pDlg( pFact->CreateSdTabPageDialog(mpViewShell->GetFrameWeld(), &aMergedAttr, mpDocSh, mbDisplayBackgroundTabPage, bIsImpressDoc) );
if( pDlg->Execute() == RET_OK )
- pTempSet.reset( new SfxItemSet(*pDlg->GetOutputItemSet()) );
+ pTempSet.emplace( *pDlg->GetOutputItemSet() );
}
if (pTempSet && pStyleSheet)
@@ -398,7 +398,7 @@ const SfxItemSet* FuPage::ExecuteDialog(weld::Window* pParent, const SfxRequest&
// MigrateItemSet guarantees unique gradient names
SfxItemSet aMigrateSet( mpDoc->GetPool(), svl::Items<XATTR_FILLGRADIENT, XATTR_FILLGRADIENT>{} );
aMigrateSet.Put( XFillGradientItem("gradient", pTempGradItem->GetGradientValue()) );
- SdrModel::MigrateItemSet( &aMigrateSet, pTempSet.get(), mpDoc);
+ SdrModel::MigrateItemSet( &aMigrateSet, &*pTempSet, mpDoc);
}
const XFillHatchItem* pTempHatchItem = pTempSet->GetItem<XFillHatchItem>(XATTR_FILLHATCH);
@@ -407,7 +407,7 @@ const SfxItemSet* FuPage::ExecuteDialog(weld::Window* pParent, const SfxRequest&
// MigrateItemSet guarantees unique hatch names
SfxItemSet aMigrateSet( mpDoc->GetPool(), svl::Items<XATTR_FILLHATCH, XATTR_FILLHATCH>{} );
aMigrateSet.Put( XFillHatchItem("hatch", pTempHatchItem->GetHatchValue()) );
- SdrModel::MigrateItemSet( &aMigrateSet, pTempSet.get(), mpDoc);
+ SdrModel::MigrateItemSet( &aMigrateSet, &*pTempSet, mpDoc);
}
if( !mbMasterPage && bChanges && mbPageBckgrdDeleted )
diff --git a/sd/source/ui/view/drviews2.cxx b/sd/source/ui/view/drviews2.cxx
index dae22d8dfde8..36ff551eb7c3 100644
--- a/sd/source/ui/view/drviews2.cxx
+++ b/sd/source/ui/view/drviews2.cxx
@@ -1238,11 +1238,11 @@ void DrawViewShell::FuTemporary(SfxRequest& rReq)
case SID_SET_DEFAULT:
{
- std::unique_ptr<SfxItemSet> pSet;
+ std::optional<SfxItemSet> pSet;
if (mpDrawView->IsTextEdit())
{
- pSet.reset(new SfxItemSet( GetPool(), svl::Items<EE_ITEMS_START, EE_ITEMS_END>{} ));
+ pSet.emplace( GetPool(), svl::Items<EE_ITEMS_START, EE_ITEMS_END>{} );
mpDrawView->SetAttributes( *pSet, true );
}
else
@@ -1269,7 +1269,7 @@ void DrawViewShell::FuTemporary(SfxRequest& rReq)
}
}
- pSet.reset(new SfxItemSet( GetPool() ));
+ pSet.emplace( GetPool() );
mpDrawView->SetAttributes( *pSet, true );
sal_uLong j = 0;
diff --git a/sd/source/ui/view/drviewsf.cxx b/sd/source/ui/view/drviewsf.cxx
index 3afa8848ef2b..6a9ebdc94f1c 100644
--- a/sd/source/ui/view/drviewsf.cxx
+++ b/sd/source/ui/view/drviewsf.cxx
@@ -714,11 +714,11 @@ void DrawViewShell::GetAttrState( SfxItemSet& rSet )
nWhich = aIter.NextWhich();
}
- std::unique_ptr<SfxItemSet> pSet;
+ std::optional<SfxItemSet> pSet;
if( bAttr )
{
- pSet.reset(new SfxItemSet( GetDoc()->GetPool() ));
+ pSet.emplace( GetDoc()->GetPool() );
mpDrawView->GetAttributes( *pSet );
rSet.Put( *pSet, false );
}
More information about the Libreoffice-commits
mailing list