diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2021-07-20 16:08:56 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2021-07-21 08:40:33 +0200 |
commit | 70b7bbc41299b65560f3339adc6a15fa9152f635 (patch) | |
tree | 054d20d5e902f78c7f936e2f52544ea4aeb0c6c3 /cui | |
parent | 8286014d9d3b96cd69e462a19d666488f66a89c9 (diff) |
can pass SfxItemSet around by value in SfxShell
Change-Id: I80ee25c56da437d778e11f2dab3d07845ebd9597
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/119274
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'cui')
-rw-r--r-- | cui/source/inc/treeopt.hxx | 2 | ||||
-rw-r--r-- | cui/source/options/treeopt.cxx | 30 |
2 files changed, 16 insertions, 16 deletions
diff --git a/cui/source/inc/treeopt.hxx b/cui/source/inc/treeopt.hxx index 59f7ef2d3e03..541726b27a90 100644 --- a/cui/source/inc/treeopt.hxx +++ b/cui/source/inc/treeopt.hxx @@ -144,7 +144,7 @@ private: static LastPageSaver* pLastPageSaver; - std::unique_ptr<SfxItemSet> CreateItemSet( sal_uInt16 nId ); + std::optional<SfxItemSet> CreateItemSet( sal_uInt16 nId ); static void ApplyItemSet( sal_uInt16 nId, const SfxItemSet& rSet ); void InitTreeAndHandler(); void Initialize( const css::uno::Reference< css::frame::XFrame >& _xFrame ); diff --git a/cui/source/options/treeopt.cxx b/cui/source/options/treeopt.cxx index 4f8d97b01595..698196afe099 100644 --- a/cui/source/options/treeopt.cxx +++ b/cui/source/options/treeopt.cxx @@ -451,7 +451,7 @@ struct OptionsPageInfo struct OptionsGroupInfo { - std::unique_ptr<SfxItemSet> m_pInItemSet; + std::optional<SfxItemSet> m_pInItemSet; std::unique_ptr<SfxItemSet> m_pOutItemSet; SfxShell* m_pShell; // used to create the page SfxModule* m_pModule; // used to create the ItemSet @@ -626,7 +626,7 @@ void OfaTreeOptionsDialog::ResetCurrentPageFromConfig() xTreeLB->iter_parent(*xParent); OptionsGroupInfo* pGroupInfo = reinterpret_cast<OptionsGroupInfo*>(xTreeLB->get_id(*xParent).toInt64()); - pPageInfo->m_xPage->Reset( pGroupInfo->m_pInItemSet.get() ); + pPageInfo->m_xPage->Reset( &*pGroupInfo->m_pInItemSet ); } else if ( pPageInfo->m_xExtPage ) pPageInfo->m_xExtPage->ResetPage(); @@ -892,9 +892,9 @@ void OfaTreeOptionsDialog::ActivateLastSelection() void OfaTreeOptionsDialog::InitItemSets(OptionsGroupInfo& rGroupInfo) { if (!rGroupInfo.m_pInItemSet) - rGroupInfo.m_pInItemSet = rGroupInfo.m_pShell - ? rGroupInfo.m_pShell->CreateItemSet( rGroupInfo.m_nDialogId ) - : CreateItemSet( rGroupInfo.m_nDialogId ); + rGroupInfo.m_pInItemSet.emplace( rGroupInfo.m_pShell + ? *rGroupInfo.m_pShell->CreateItemSet( rGroupInfo.m_nDialogId ) + : *CreateItemSet( rGroupInfo.m_nDialogId ) ); if (!rGroupInfo.m_pOutItemSet) rGroupInfo.m_pOutItemSet = std::make_unique<SfxItemSet>( *rGroupInfo.m_pInItemSet->GetPool(), @@ -965,7 +965,7 @@ void OfaTreeOptionsDialog::SelectHdl_Impl() { SvtViewOptions aTabPageOpt( EViewType::TabPage, OUString::number( pPageInfo->m_nPageId) ); pPageInfo->m_xPage->SetUserData( GetViewOptUserItem( aTabPageOpt ) ); - pPageInfo->m_xPage->Reset( pGroupInfo->m_pInItemSet.get() ); + pPageInfo->m_xPage->Reset( &*pGroupInfo->m_pInItemSet ); } } else if ( 0 == pPageInfo->m_nPageId && !pPageInfo->m_xExtPage ) @@ -1026,15 +1026,15 @@ void OfaTreeOptionsDialog::SelectHdl_Impl() xTreeLB->set_help_id(sHelpId); } -std::unique_ptr<SfxItemSet> OfaTreeOptionsDialog::CreateItemSet( sal_uInt16 nId ) +std::optional<SfxItemSet> OfaTreeOptionsDialog::CreateItemSet( sal_uInt16 nId ) { Reference< XLinguProperties > xProp( LinguMgr::GetLinguPropertySet() ); - std::unique_ptr<SfxItemSet> pRet; + std::optional<SfxItemSet> pRet; switch(nId) { case SID_GENERAL_OPTIONS: { - pRet = std::make_unique<SfxItemSet>( + pRet.emplace( SfxGetpApp()->GetPool(), svl::Items< SID_HTML_MODE, SID_HTML_MODE, @@ -1074,7 +1074,7 @@ std::unique_ptr<SfxItemSet> OfaTreeOptionsDialog::CreateItemSet( sal_uInt16 nId break; case SID_LANGUAGE_OPTIONS : { - pRet = std::make_unique<SfxItemSet>( + pRet.emplace( SfxGetpApp()->GetPool(), svl::Items< SID_ATTR_CHAR_CJK_LANGUAGE, SID_ATTR_CHAR_CJK_LANGUAGE, @@ -1141,7 +1141,7 @@ std::unique_ptr<SfxItemSet> OfaTreeOptionsDialog::CreateItemSet( sal_uInt16 nId } break; case SID_INET_DLG : - pRet = std::make_unique<SfxItemSet>( SfxGetpApp()->GetPool(), + pRet.emplace( SfxGetpApp()->GetPool(), svl::Items< //SID_OPTIONS_START - ..END SID_SAVEREL_INET, SID_SAVEREL_FSYS, @@ -1150,7 +1150,7 @@ std::unique_ptr<SfxItemSet> OfaTreeOptionsDialog::CreateItemSet( sal_uInt16 nId SfxGetpApp()->GetOptions(*pRet); break; case SID_FILTER_DLG: - pRet = std::make_unique<SfxItemSet>( + pRet.emplace( SfxGetpApp()->GetPool(), svl::Items< SID_ATTR_WARNALIENFORMAT, SID_ATTR_WARNALIENFORMAT, @@ -1161,8 +1161,8 @@ std::unique_ptr<SfxItemSet> OfaTreeOptionsDialog::CreateItemSet( sal_uInt16 nId break; case SID_SB_STARBASEOPTIONS: - pRet = std::make_unique<SfxItemSet>( SfxGetpApp()->GetPool(), - svl::Items<SID_SB_POOLING_ENABLED, SID_SB_DB_REGISTER> ); + pRet.emplace( SfxGetpApp()->GetPool(), + svl::Items<SID_SB_POOLING_ENABLED, SID_SB_DB_REGISTER> ); ::offapp::ConnectionPoolConfig::GetOptions(*pRet); svx::DbRegisteredNamesConfig::GetOptions(*pRet); break; @@ -1170,7 +1170,7 @@ std::unique_ptr<SfxItemSet> OfaTreeOptionsDialog::CreateItemSet( sal_uInt16 nId case SID_SCH_EDITOPTIONS: { SvxChartOptions aChartOpt; - pRet = std::make_unique<SfxItemSet>( SfxGetpApp()->GetPool(), svl::Items<SID_SCH_EDITOPTIONS, SID_SCH_EDITOPTIONS> ); + pRet.emplace( SfxGetpApp()->GetPool(), svl::Items<SID_SCH_EDITOPTIONS, SID_SCH_EDITOPTIONS> ); pRet->Put( SvxChartColorTableItem( SID_SCH_EDITOPTIONS, aChartOpt.GetDefaultColors() ) ); break; } |