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 <noel.grandin@collabora.co.uk>
This commit is contained in:
Noel Grandin 2024-03-05 12:02:05 +02:00
parent 66fefd9a7d
commit e311a4b87b
6 changed files with 112 additions and 31 deletions

View file

@ -3398,6 +3398,7 @@ $(eval $(call gb_UnoApi_add_idlfiles,offapi,com/sun/star/sheet,\
ConditionFormatOperator \ ConditionFormatOperator \
ConditionOperator \ ConditionOperator \
ConditionOperator2 \ ConditionOperator2 \
CreateDialogFactoryService \
DataBarAxis \ DataBarAxis \
DataBarEntryType \ DataBarEntryType \
DateType \ DateType \

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 sheet {
/**
The sc module uses this to get a pointer to the ScAbstractDialogFactory from the scui 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,7 +9,7 @@
$(eval $(call gb_Library_Library,scui)) $(eval $(call gb_Library_Library,scui))
$(eval $(call gb_Library_set_plugin_for,scui,sc)) $(eval $(call gb_Library_set_componentfile,scui,sc/util/scui,services))
$(eval $(call gb_Library_set_include,scui,\ $(eval $(call gb_Library_set_include,scui,\
-I$(SRCDIR)/sc/source/core/inc \ -I$(SRCDIR)/sc/source/core/inc \
@ -58,6 +58,7 @@ $(eval $(call gb_Library_use_libraries,scui,\
$(call gb_Helper_optional,OPENCL, \ $(call gb_Helper_optional,OPENCL, \
opencl) \ opencl) \
sal \ sal \
sc \
sfx \ sfx \
sot \ sot \
svl \ svl \

View file

@ -21,35 +21,17 @@
#include <osl/module.hxx> #include <osl/module.hxx>
#include <tools/svlibrary.h> #include <tools/svlibrary.h>
#include <comphelper/processfactory.hxx>
typedef ScAbstractDialogFactory* (*ScFuncPtrCreateDialogFactory)(); #include <com/sun/star/sheet/CreateDialogFactoryService.hpp>
#ifndef DISABLE_DYNLOADING
extern "C" { static void thisModule() {} }
#else
extern "C" ScAbstractDialogFactory* ScCreateDialogFactory();
#endif
ScAbstractDialogFactory* ScAbstractDialogFactory::Create() ScAbstractDialogFactory* ScAbstractDialogFactory::Create()
{ {
ScFuncPtrCreateDialogFactory fp = nullptr; auto xService = css::sheet::CreateDialogFactoryService::create(comphelper::getProcessComponentContext());
#ifndef DISABLE_DYNLOADING assert(xService);
static ::osl::Module aDialogLibrary; // get a factory instance
ScAbstractDialogFactory* pFactory = reinterpret_cast<ScAbstractDialogFactory*>(xService->getSomething({}));
if ( aDialogLibrary.is() || aDialogLibrary.loadRelative( &thisModule, SVLIBRARY("scui"), assert(pFactory);
SAL_LOADMODULE_GLOBAL | SAL_LOADMODULE_LAZY ) ) return pFactory;
fp = reinterpret_cast<ScAbstractDialogFactory* (SAL_CALL*)()>(
aDialogLibrary.getFunctionSymbol( "ScCreateDialogFactory" ));
#else
fp = ScCreateDialogFactory;
#endif
if ( fp )
return fp();
return nullptr;
} }
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

View file

@ -21,13 +21,46 @@
#include "scdlgfact.hxx" #include "scdlgfact.hxx"
#include <sal/types.h> #include <sal/types.h>
#include <cppuhelper/supportsservice.hxx>
/// anonymous implementation namespace
namespace
{
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.sheet.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.sheet.CreateDialogFactoryService" };
}
// XUnoTunnel
virtual sal_Int64 SAL_CALL
getSomething(const ::css::uno::Sequence<::sal_Int8>& /*aIdentifier*/) override
{
static ScAbstractDialogFactory_Impl aFactory;
return reinterpret_cast<sal_Int64>(static_cast<ScAbstractDialogFactory*>(&aFactory));
}
};
} // closing anonymous implementation namespace
extern "C" { 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<css::uno::Any> const&)
{ {
static ScAbstractDialogFactory_Impl aFactory; return cppu::acquire(new CreateDialogFactoryService);
return &aFactory;
} }
} }
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

26
sc/util/scui.component Normal file
View file

@ -0,0 +1,26 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
* 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 .
-->
<component loader="com.sun.star.loader.SharedLibrary" environment="@CPPU_ENV@"
xmlns="http://openoffice.org/2010/uno-components">
<implementation name="com.sun.star.sheet.comp.CreateDialogFactoryService"
constructor="com_sun_star_sheet_CreateDialogFactoryService_get_implementation">
<service name="com.sun.star.sheet.CreateDialogFactoryService"/>
</implementation>
</component>