From 4c12a78b003bf0587be9edd96d538b7f5ee2a3f5 Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Thu, 9 Jul 2020 18:45:54 +0200 Subject: desktop/deployment: create instances with uno constructors See tdf#74608 for motivation Change-Id: I11fe446e07e9a807c1267c4037922877d987003c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/98472 Tested-by: Jenkins Reviewed-by: Noel Grandin --- .../source/deployment/gui/deploymentgui.component | 11 ++-- desktop/source/deployment/gui/dp_gui_dialog2.cxx | 17 ++++++ desktop/source/deployment/gui/dp_gui_dialog2.hxx | 8 ++- desktop/source/deployment/gui/dp_gui_service.cxx | 67 +++++++++++++--------- desktop/source/deployment/gui/license_dialog.cxx | 18 ++++++ desktop/source/deployment/gui/license_dialog.hxx | 8 ++- 6 files changed, 95 insertions(+), 34 deletions(-) (limited to 'desktop/source/deployment') diff --git a/desktop/source/deployment/gui/deploymentgui.component b/desktop/source/deployment/gui/deploymentgui.component index abe2c77f5d55..3b56863c13c2 100644 --- a/desktop/source/deployment/gui/deploymentgui.component +++ b/desktop/source/deployment/gui/deploymentgui.component @@ -18,14 +18,17 @@ --> - + xmlns="http://openoffice.org/2010/uno-components"> + - + - + diff --git a/desktop/source/deployment/gui/dp_gui_dialog2.cxx b/desktop/source/deployment/gui/dp_gui_dialog2.cxx index d018edad0109..b6b698d236e9 100644 --- a/desktop/source/deployment/gui/dp_gui_dialog2.cxx +++ b/desktop/source/deployment/gui/dp_gui_dialog2.cxx @@ -48,6 +48,7 @@ #include #include +#include #include #include @@ -1347,6 +1348,22 @@ UpdateRequiredDialogService::UpdateRequiredDialogService( SAL_UNUSED_PARAMETER u { } +// XServiceInfo +OUString UpdateRequiredDialogService::getImplementationName() +{ + return "com.sun.star.comp.deployment.ui.UpdateRequiredDialog"; +} + +sal_Bool UpdateRequiredDialogService::supportsService( const OUString& ServiceName ) +{ + return cppu::supportsService(this, ServiceName); +} + +css::uno::Sequence< OUString > UpdateRequiredDialogService::getSupportedServiceNames() +{ + return { "com.sun.star.deployment.ui.UpdateRequiredDialog" }; +} + // XExecutableDialog diff --git a/desktop/source/deployment/gui/dp_gui_dialog2.hxx b/desktop/source/deployment/gui/dp_gui_dialog2.hxx index b3d348c840f3..9777742e1b4b 100644 --- a/desktop/source/deployment/gui/dp_gui_dialog2.hxx +++ b/desktop/source/deployment/gui/dp_gui_dialog2.hxx @@ -35,6 +35,7 @@ #include #include #include +#include namespace dp_gui { @@ -242,13 +243,18 @@ public: virtual ~ShowLicenseDialog() override; }; -class UpdateRequiredDialogService : public ::cppu::WeakImplHelper< css::ui::dialogs::XExecutableDialog > +class UpdateRequiredDialogService : public ::cppu::WeakImplHelper< css::ui::dialogs::XExecutableDialog, css::lang::XServiceInfo > { css::uno::Reference< css::uno::XComponentContext > const m_xComponentContext; public: UpdateRequiredDialogService( css::uno::Sequence< css::uno::Any > const & args, css::uno::Reference< css::uno::XComponentContext> const & xComponentContext ); + // XServiceInfo + virtual OUString SAL_CALL getImplementationName() override; + virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override; + virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override; + // XExecutableDialog virtual void SAL_CALL setTitle( OUString const & title ) override; virtual sal_Int16 SAL_CALL execute() override; diff --git a/desktop/source/deployment/gui/dp_gui_service.cxx b/desktop/source/deployment/gui/dp_gui_service.cxx index 8acfdc5a32f1..0d0315f0daaa 100644 --- a/desktop/source/deployment/gui/dp_gui_service.cxx +++ b/desktop/source/deployment/gui/dp_gui_service.cxx @@ -22,9 +22,9 @@ #include "dp_gui_theextmgr.hxx" #include #include +#include #include #include -#include #include #include #include @@ -42,8 +42,6 @@ using namespace ::dp_misc; using namespace ::com::sun::star; using namespace ::com::sun::star::uno; -namespace sdecl = comphelper::service_decl; - namespace dp_gui { namespace { @@ -108,7 +106,7 @@ namespace { class ServiceImpl : public ::cppu::WeakImplHelper + task::XJobExecutor, css::lang::XServiceInfo> { Reference const m_xComponentContext; std::optional< Reference > /* const */ m_parent; @@ -120,6 +118,11 @@ public: ServiceImpl( Sequence const & args, Reference const & xComponentContext ); + // XServiceInfo + virtual OUString SAL_CALL getImplementationName() override; + virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override; + virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override; + // XAsynchronousExecutableDialog virtual void SAL_CALL setDialogTitle( OUString const & aTitle ) override; virtual void SAL_CALL startExecuteModal( @@ -154,6 +157,22 @@ ServiceImpl::ServiceImpl( Sequence const& args, Translate::SetReadStringHook(ReplaceProductNameHookProc); } +// XServiceInfo +OUString ServiceImpl::getImplementationName() +{ + return "com.sun.star.comp.deployment.ui.PackageManagerDialog"; +} + +sal_Bool ServiceImpl::supportsService( const OUString& ServiceName ) +{ + return cppu::supportsService(this, ServiceName); +} + +css::uno::Sequence< OUString > ServiceImpl::getSupportedServiceNames() +{ + return { "com.sun.star.deployment.ui.PackageManagerDialog" }; +} + // XAsynchronousExecutableDialog void ServiceImpl::setDialogTitle( OUString const & title ) @@ -270,35 +289,27 @@ void ServiceImpl::trigger( OUString const &rEvent ) startExecuteModal( Reference< ui::dialogs::XDialogClosedListener >() ); } -sdecl::class_ > const serviceSI; -sdecl::ServiceDecl const serviceDecl( - serviceSI, - "com.sun.star.comp.deployment.ui.PackageManagerDialog", - "com.sun.star.deployment.ui.PackageManagerDialog" ); - -sdecl::class_ > const licenseSI; -sdecl::ServiceDecl const licenseDecl( - licenseSI, - "com.sun.star.comp.deployment.ui.LicenseDialog", - "com.sun.star.deployment.ui.LicenseDialog" ); - -sdecl::class_ > const updateSI; -sdecl::ServiceDecl const updateDecl( - updateSI, - "com.sun.star.comp.deployment.ui.UpdateRequiredDialog", - "com.sun.star.deployment.ui.UpdateRequiredDialog" ); } // namespace dp_gui -extern "C" { +extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface* +desktop_LicenseDialog_get_implementation( + css::uno::XComponentContext* context, css::uno::Sequence const& args) +{ + return cppu::acquire(new dp_gui::LicenseDialog(args, context)); +} -SAL_DLLPUBLIC_EXPORT void * deploymentgui_component_getFactory( - char const * pImplName, void *, void *) +extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface* +desktop_ServiceImpl_get_implementation( + css::uno::XComponentContext* context, css::uno::Sequence const& args) { - return sdecl::component_getFactoryHelper( - pImplName, - {&dp_gui::serviceDecl, &dp_gui::licenseDecl, &dp_gui::updateDecl}); + return cppu::acquire(new dp_gui::ServiceImpl(args, context)); } -} // extern "C" +extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface* +desktop_UpdateRequiredDialogService_get_implementation( + css::uno::XComponentContext* context, css::uno::Sequence const& args) +{ + return cppu::acquire(new dp_gui::UpdateRequiredDialogService(args, context)); +} /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/desktop/source/deployment/gui/license_dialog.cxx b/desktop/source/deployment/gui/license_dialog.cxx index 3e92f8cf626f..ef2b64b91101 100644 --- a/desktop/source/deployment/gui/license_dialog.cxx +++ b/desktop/source/deployment/gui/license_dialog.cxx @@ -24,6 +24,7 @@ #include #include #include +#include #include "license_dialog.hxx" @@ -200,6 +201,23 @@ LicenseDialog::LicenseDialog( Sequence const& args, comphelper::unwrapArgs( args, m_parent, m_sExtensionName, m_sLicenseText ); } +// XServiceInfo +OUString LicenseDialog::getImplementationName() +{ + return "com.sun.star.comp.deployment.ui.LicenseDialog"; +} + +sal_Bool LicenseDialog::supportsService( const OUString& ServiceName ) +{ + return cppu::supportsService(this, ServiceName); +} + +css::uno::Sequence< OUString > LicenseDialog::getSupportedServiceNames() +{ + return { "com.sun.star.deployment.ui.LicenseDialog" }; +} + + // XExecutableDialog void LicenseDialog::setTitle( OUString const & ) diff --git a/desktop/source/deployment/gui/license_dialog.hxx b/desktop/source/deployment/gui/license_dialog.hxx index 4cb615ef8278..cc9886f24978 100644 --- a/desktop/source/deployment/gui/license_dialog.hxx +++ b/desktop/source/deployment/gui/license_dialog.hxx @@ -23,12 +23,13 @@ #include #include #include +#include namespace dp_gui { class LicenseDialog - : public ::cppu::WeakImplHelper + : public ::cppu::WeakImplHelper { css::uno::Reference /* const */ m_parent; OUString m_sExtensionName; @@ -40,6 +41,11 @@ public: LicenseDialog( css::uno::Sequence const & args, css::uno::Reference const & xComponentContext ); + // XServiceInfo + virtual OUString SAL_CALL getImplementationName() override; + virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override; + virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override; + // XExecutableDialog virtual void SAL_CALL setTitle( OUString const & title ) override; virtual sal_Int16 SAL_CALL execute() override; -- cgit