From e311a4b87bad35a50812574dd9a96d6f4cd8dfd8 Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Tue, 5 Mar 2024 12:02:05 +0200 Subject: Create an UNO service to do the symbol lookup in sc which means I can remove one usage of gb_Library_set_plugin_for, which is blocking linking the accessibility module into --enable-mergelibs=more Change-Id: I389fcafd80f1a450befbffdc252be497ba20f6d5 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/164415 Tested-by: Jenkins Reviewed-by: Noel Grandin --- sc/source/ui/attrdlg/scabstdlg.cxx | 34 ++++++++----------------------- sc/source/ui/attrdlg/scuiexp.cxx | 41 ++++++++++++++++++++++++++++++++++---- 2 files changed, 45 insertions(+), 30 deletions(-) (limited to 'sc/source') diff --git a/sc/source/ui/attrdlg/scabstdlg.cxx b/sc/source/ui/attrdlg/scabstdlg.cxx index a8a457c5c985..9696147639fe 100644 --- a/sc/source/ui/attrdlg/scabstdlg.cxx +++ b/sc/source/ui/attrdlg/scabstdlg.cxx @@ -21,35 +21,17 @@ #include #include - -typedef ScAbstractDialogFactory* (*ScFuncPtrCreateDialogFactory)(); - -#ifndef DISABLE_DYNLOADING - -extern "C" { static void thisModule() {} } - -#else - -extern "C" ScAbstractDialogFactory* ScCreateDialogFactory(); - -#endif +#include +#include ScAbstractDialogFactory* ScAbstractDialogFactory::Create() { - ScFuncPtrCreateDialogFactory fp = nullptr; -#ifndef DISABLE_DYNLOADING - static ::osl::Module aDialogLibrary; - - if ( aDialogLibrary.is() || aDialogLibrary.loadRelative( &thisModule, SVLIBRARY("scui"), - SAL_LOADMODULE_GLOBAL | SAL_LOADMODULE_LAZY ) ) - fp = reinterpret_cast( - aDialogLibrary.getFunctionSymbol( "ScCreateDialogFactory" )); -#else - fp = ScCreateDialogFactory; -#endif - if ( fp ) - return fp(); - return nullptr; + auto xService = css::sheet::CreateDialogFactoryService::create(comphelper::getProcessComponentContext()); + assert(xService); + // get a factory instance + ScAbstractDialogFactory* pFactory = reinterpret_cast(xService->getSomething({})); + assert(pFactory); + return pFactory; } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/attrdlg/scuiexp.cxx b/sc/source/ui/attrdlg/scuiexp.cxx index 4351539a9055..1179050037b2 100644 --- a/sc/source/ui/attrdlg/scuiexp.cxx +++ b/sc/source/ui/attrdlg/scuiexp.cxx @@ -21,13 +21,46 @@ #include "scdlgfact.hxx" #include +#include + +/// anonymous implementation namespace +namespace +{ +class CreateDialogFactoryService + : public ::cppu::WeakImplHelper +{ +public: + // css::lang::XServiceInfo: + virtual OUString SAL_CALL getImplementationName() override + { + return "com.sun.star.sheet.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.sheet.CreateDialogFactoryService" }; + } + + // XUnoTunnel + virtual sal_Int64 SAL_CALL + getSomething(const ::css::uno::Sequence<::sal_Int8>& /*aIdentifier*/) override + { + static ScAbstractDialogFactory_Impl aFactory; + return reinterpret_cast(static_cast(&aFactory)); + } +}; + +} // closing anonymous implementation namespace extern "C" { -SAL_DLLPUBLIC_EXPORT ScAbstractDialogFactory* ScCreateDialogFactory() +SAL_DLLPUBLIC_EXPORT css::uno::XInterface* +com_sun_star_sheet_CreateDialogFactoryService_get_implementation( + css::uno::XComponentContext*, css::uno::Sequence const&) { - static ScAbstractDialogFactory_Impl aFactory; - return &aFactory; + return cppu::acquire(new CreateDialogFactoryService); } } - /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ -- cgit