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 <noel.grandin@collabora.co.uk>
This commit is contained in:
Noel Grandin 2024-03-05 14:40:44 +02:00
parent bacb92275c
commit 4ed1536c6e
6 changed files with 93 additions and 35 deletions

View file

@ -2971,6 +2971,7 @@ $(eval $(call gb_UnoApi_add_idlfiles,offapi,com/sun/star/presentation,\
AnimationEffect \
AnimationSpeed \
ClickAction \
CreateDialogFactoryService \
EffectCommands \
EffectNodeType \
EffectPresetClass \

View file

@ -0,0 +1,38 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
module com { module sun { module star { module presentation {
/**
The sd module uses this to get a pointer to the AccessibleFactory from the sdui module.
Because we have a dependency in our modules that goes the "wrong" way.
@since LibreOffice 24.8
@internal
ATTENTION: This is marked <em>internal</em> and does not
have the <em>published</em> flag, which means it is subject to
change without notice and should not be used outside the LibreOffice core.
*/
service CreateDialogFactoryService : com::sun::star::lang::XUnoTunnel;
}; }; }; };
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */

View file

@ -9,8 +9,6 @@
$(eval $(call gb_Library_Library,sdui))
$(eval $(call gb_Library_set_plugin_for,sdui,sd))
$(eval $(call gb_Library_set_componentfile,sdui,sd/source/console/presenter,services))
$(eval $(call gb_Library_set_include,sdui,\
@ -53,6 +51,7 @@ $(eval $(call gb_Library_use_libraries,sdui,\
fwk \
sal \
salhelper \
sd \
sfx \
sot \
svl \

View file

@ -15,4 +15,8 @@
constructor="sd_PresenterProtocolHandler_get_implementation">
<service name="com.sun.star.frame.ProtocolHandler"/>
</implementation>
<implementation name="com.sun.star.presentation.comp.CreateDialogFactoryService"
constructor="com_sun_star_presentation_CreateDialogFactoryService_get_implementation">
<service name="com.sun.star.presentation.CreateDialogFactoryService"/>
</implementation>
</component>

View file

@ -18,38 +18,19 @@
*/
#include <sdabstdlg.hxx>
#include <osl/module.hxx>
typedef SdAbstractDialogFactory* (*SdFuncPtrCreateDialogFactory)();
#ifndef DISABLE_DYNLOADING
extern "C" {
static void thisModule() {}
}
#else
extern "C" SdAbstractDialogFactory* SdCreateDialogFactory();
#endif
#include <comphelper/processfactory.hxx>
#include <com/sun/star/presentation/CreateDialogFactoryService.hpp>
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<SdAbstractDialogFactory*(SAL_CALL*)()>(
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<SdAbstractDialogFactory*>(xService->getSomething({}));
assert(pFactory);
return pFactory;
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */

View file

@ -19,14 +19,49 @@
#include "sddlgfact.hxx"
#include <sal/types.h>
#include <cppuhelper/supportsservice.hxx>
#include <com/sun/star/lang/XUnoTunnel.hpp>
class SdAbstractDialogFactory;
extern "C" {
SAL_DLLPUBLIC_EXPORT SdAbstractDialogFactory* SdCreateDialogFactory()
/// anonymous implementation namespace
namespace
{
static SdAbstractDialogFactory_Impl aFactory;
return &aFactory;
class CreateDialogFactoryService
: public ::cppu::WeakImplHelper<css::lang::XServiceInfo, css::lang::XUnoTunnel>
{
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<OUString> 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<sal_Int64>(static_cast<SdAbstractDialogFactory*>(&aFactory));
}
};
} // closing anonymous implementation namespace
extern "C" {
SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
com_sun_star_presentation_CreateDialogFactoryService_get_implementation(
css::uno::XComponentContext*, css::uno::Sequence<css::uno::Any> const&)
{
return cppu::acquire(new CreateDialogFactoryService);
}
}