From 4ed1536c6eed2a7919a80c7f92617aa0a4058263 Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Tue, 5 Mar 2024 14:40:44 +0200 Subject: Create an UNO service to do the symbol lookup in sd which means I can remove one usage of gb_Library_set_plugin_for, which is blocking linking the sd module into --enable-mergelibs=more Change-Id: I90dae749f777446f67342d121e4dc29b974cb9b6 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/164423 Tested-by: Jenkins Reviewed-by: Noel Grandin --- sd/source/console/presenter.component | 4 ++++ sd/source/ui/dlg/sdabstdlg.cxx | 39 +++++++++------------------------ sd/source/ui/dlg/sduiexp.cxx | 41 ++++++++++++++++++++++++++++++++--- 3 files changed, 52 insertions(+), 32 deletions(-) (limited to 'sd/source') diff --git a/sd/source/console/presenter.component b/sd/source/console/presenter.component index 3e1bc8508d36..8a1d8b93a224 100644 --- a/sd/source/console/presenter.component +++ b/sd/source/console/presenter.component @@ -15,4 +15,8 @@ constructor="sd_PresenterProtocolHandler_get_implementation"> + + + diff --git a/sd/source/ui/dlg/sdabstdlg.cxx b/sd/source/ui/dlg/sdabstdlg.cxx index 2b686a3e8882..181a2ec42d62 100644 --- a/sd/source/ui/dlg/sdabstdlg.cxx +++ b/sd/source/ui/dlg/sdabstdlg.cxx @@ -18,38 +18,19 @@ */ #include - -#include - -typedef SdAbstractDialogFactory* (*SdFuncPtrCreateDialogFactory)(); - -#ifndef DISABLE_DYNLOADING - -extern "C" { -static void thisModule() {} -} - -#else - -extern "C" SdAbstractDialogFactory* SdCreateDialogFactory(); - -#endif +#include +#include SdAbstractDialogFactory* SdAbstractDialogFactory::Create() { - SdFuncPtrCreateDialogFactory fp = nullptr; -#ifndef DISABLE_DYNLOADING - static ::osl::Module aDialogLibrary; - static constexpr OUStringLiteral sLibName(u"" SDUI_DLL_NAME); - if (aDialogLibrary.is() || aDialogLibrary.loadRelative(&thisModule, sLibName)) - fp = reinterpret_cast( - aDialogLibrary.getFunctionSymbol("SdCreateDialogFactory")); -#else - fp = SdCreateDialogFactory; -#endif - if (fp) - return fp(); - return nullptr; + auto xService = css::presentation::CreateDialogFactoryService::create( + comphelper::getProcessComponentContext()); + assert(xService); + // get a factory instance + SdAbstractDialogFactory* pFactory + = reinterpret_cast(xService->getSomething({})); + assert(pFactory); + return pFactory; } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sd/source/ui/dlg/sduiexp.cxx b/sd/source/ui/dlg/sduiexp.cxx index 62901c70d0aa..63354ab7ed58 100644 --- a/sd/source/ui/dlg/sduiexp.cxx +++ b/sd/source/ui/dlg/sduiexp.cxx @@ -19,14 +19,49 @@ #include "sddlgfact.hxx" #include +#include +#include class SdAbstractDialogFactory; +/// anonymous implementation namespace +namespace +{ +class CreateDialogFactoryService + : public ::cppu::WeakImplHelper +{ +public: + // css::lang::XServiceInfo: + virtual OUString SAL_CALL getImplementationName() override + { + return "com.sun.star.presentation.comp.CreateDialogFactoryService"; + } + virtual sal_Bool SAL_CALL supportsService(const OUString& serviceName) override + { + return cppu::supportsService(this, serviceName); + } + virtual css::uno::Sequence SAL_CALL getSupportedServiceNames() override + { + return { "com.sun.star.presentation.CreateDialogFactoryService" }; + } + + // XUnoTunnel + virtual sal_Int64 SAL_CALL + getSomething(const ::css::uno::Sequence<::sal_Int8>& /*aIdentifier*/) override + { + static SdAbstractDialogFactory_Impl aFactory; + return reinterpret_cast(static_cast(&aFactory)); + } +}; + +} // closing anonymous implementation namespace + extern "C" { -SAL_DLLPUBLIC_EXPORT SdAbstractDialogFactory* SdCreateDialogFactory() +SAL_DLLPUBLIC_EXPORT css::uno::XInterface* +com_sun_star_presentation_CreateDialogFactoryService_get_implementation( + css::uno::XComponentContext*, css::uno::Sequence const&) { - static SdAbstractDialogFactory_Impl aFactory; - return &aFactory; + return cppu::acquire(new CreateDialogFactoryService); } } -- cgit