From 94d6fa11d086187b82adf9aa596e0f334827e095 Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Tue, 17 Sep 2019 12:50:05 +0100 Subject: weld OfaTreeOptionsDialog MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit including ability to host a vcl::Window based XWindow hierarchy inside a native widget, e.g. the dictionary extensions have option pages Change-Id: I17d933bac12679e10164214a9045b677291a6557 Reviewed-on: https://gerrit.libreoffice.org/79070 Tested-by: Jenkins Reviewed-by: Caolán McNamara Tested-by: Caolán McNamara --- cui/source/factory/dlgfact.cxx | 42 ++++++++++++++++++------------------------ cui/source/factory/dlgfact.hxx | 9 ++------- 2 files changed, 20 insertions(+), 31 deletions(-) (limited to 'cui/source/factory') diff --git a/cui/source/factory/dlgfact.cxx b/cui/source/factory/dlgfact.cxx index 289c79ccf8be..7608d9f8cd3e 100644 --- a/cui/source/factory/dlgfact.cxx +++ b/cui/source/factory/dlgfact.cxx @@ -108,8 +108,6 @@ short CuiAbstractSingleTabController_Impl::Execute() return m_xDlg->run(); } -IMPL_ABSTDLG_BASE(CuiVclAbstractDialog_Impl) - short AbstractSvxDistributeDialog_Impl::Execute() { return m_xDlg->run(); @@ -948,9 +946,9 @@ bool AbstractPasswordToOpenModifyDialog_Impl::IsRecommendToOpenReadonly() const } // Create dialogs with simplest interface -VclPtr AbstractDialogFactory_Impl::CreateVclDialog( vcl::Window* pParent, sal_uInt32 nResId ) +VclPtr AbstractDialogFactory_Impl::CreateVclDialog(weld::Window* pParent, sal_uInt32 nResId) { - VclPtr pDlg; + std::unique_ptr xDlg; switch ( nResId ) { case SID_OPTIONS_TREEDIALOG : @@ -961,25 +959,24 @@ VclPtr AbstractDialogFactory_Impl::CreateVclDialog( vcl::Wind if (nResId == SID_OPTIONS_TREEDIALOG) bActivateLastSelection = true; Reference< frame::XFrame > xFrame; - VclPtrInstance pOptDlg( pParent, xFrame, bActivateLastSelection ); + xDlg = std::make_unique(pParent, xFrame, bActivateLastSelection); if (nResId == SID_OPTIONS_DATABASES) { - pOptDlg->ActivatePage(SID_SB_DBREGISTEROPTIONS); + xDlg->ActivatePage(SID_SB_DBREGISTEROPTIONS); } else if (nResId == SID_LANGUAGE_OPTIONS) { //open the tab page "tools/options/languages" - pOptDlg->ActivatePage(OFA_TP_LANGUAGES_FOR_SET_DOCUMENT_LANGUAGE); + xDlg->ActivatePage(OFA_TP_LANGUAGES_FOR_SET_DOCUMENT_LANGUAGE); } - pDlg.reset(pOptDlg); } break; default: break; } - if ( pDlg ) - return VclPtr::Create( pDlg ); + if (xDlg) + return VclPtr::Create(std::move(xDlg)); return nullptr; } @@ -988,26 +985,24 @@ VclPtr AbstractDialogFactory_Impl::CreateAboutDialog(weld::Wi return VclPtr::Create(std::make_unique(pParent)); } -VclPtr AbstractDialogFactory_Impl::CreateFrameDialog(vcl::Window* pParent, const Reference< frame::XFrame >& rxFrame, +VclPtr AbstractDialogFactory_Impl::CreateFrameDialog(weld::Window* pParent, const Reference< frame::XFrame >& rxFrame, sal_uInt32 nResId, const OUString& rParameter ) { - VclPtr pDlg; - if ( SID_OPTIONS_TREEDIALOG == nResId || SID_OPTIONS_DATABASES == nResId ) + std::unique_ptr xDlg; + if (SID_OPTIONS_TREEDIALOG == nResId || SID_OPTIONS_DATABASES == nResId) { // only activate last page if we don't want to activate a special page bool bActivateLastSelection = ( nResId != SID_OPTIONS_DATABASES && rParameter.isEmpty() ); - VclPtrInstance pOptDlg(pParent, rxFrame, bActivateLastSelection); + xDlg = std::make_unique(pParent, rxFrame, bActivateLastSelection); if ( nResId == SID_OPTIONS_DATABASES ) - pOptDlg->ActivatePage(SID_SB_DBREGISTEROPTIONS); + xDlg->ActivatePage(SID_SB_DBREGISTEROPTIONS); else if ( !rParameter.isEmpty() ) - pOptDlg->ActivatePage( rParameter ); - pDlg.reset(pOptDlg); + xDlg->ActivatePage( rParameter ); } - if ( pDlg ) - return VclPtr::Create( pDlg ); - else - return nullptr; + if (xDlg) + return VclPtr::Create(std::move(xDlg)); + return nullptr; } // TabDialog outside the drawing layer @@ -1594,10 +1589,9 @@ VclPtr AbstractDialogFactory_Impl::CreateSvxNewTableD return VclPtr::Create(pParent); } -VclPtr AbstractDialogFactory_Impl::CreateOptionsDialog( - weld::Window* /*pParent*/, const OUString& rExtensionId ) +VclPtr AbstractDialogFactory_Impl::CreateOptionsDialog(weld::Window* pParent, const OUString& rExtensionId) { - return VclPtr::Create( VclPtr::Create(nullptr /* TODO: pParent*/, rExtensionId ) ); + return VclPtr::Create(std::make_unique(pParent, rExtensionId)); } VclPtr AbstractDialogFactory_Impl::CreateSvxInsRowColDlg(weld::Window* pParent, bool bCol, const OString& rHelpId) diff --git a/cui/source/factory/dlgfact.hxx b/cui/source/factory/dlgfact.hxx index 7d579b22ae20..dab0e9ae43d0 100644 --- a/cui/source/factory/dlgfact.hxx +++ b/cui/source/factory/dlgfact.hxx @@ -112,11 +112,6 @@ bool Class::StartExecuteAsync(VclAbstractDialog::AsyncContext &rCtx) \ return pDlg->StartExecuteAsync(rCtx); \ } -class CuiVclAbstractDialog_Impl : public VclAbstractDialog -{ - DECL_ABSTDLG_BASE(CuiVclAbstractDialog_Impl,Dialog) -}; - class CuiAbstractController_Impl : public VclAbstractDialog { std::unique_ptr m_xDlg; @@ -761,7 +756,7 @@ public: class AbstractDialogFactory_Impl : public SvxAbstractDialogFactory { public: - virtual VclPtr CreateVclDialog( vcl::Window* pParent, sal_uInt32 nResId ) override; + virtual VclPtr CreateVclDialog(weld::Window* pParent, sal_uInt32 nResId) override; virtual VclPtr CreateAboutDialog(weld::Window* pParent) override; @@ -775,7 +770,7 @@ public: virtual VclPtr CreateEventConfigDialog(weld::Widget* pParent, const SfxItemSet& rAttr, const css::uno::Reference< css::frame::XFrame >& rFrame) override; - virtual VclPtr CreateFrameDialog(vcl::Window* pParent, const css::uno::Reference< css::frame::XFrame >& rxFrame, + virtual VclPtr CreateFrameDialog(weld::Window* pParent, const css::uno::Reference< css::frame::XFrame >& rxFrame, sal_uInt32 nResId, const OUString& rParameter ) override; virtual VclPtr CreateAutoCorrTabDialog(weld::Window* pParent, const SfxItemSet* pAttrSet) override; -- cgit