bin/find-can-be-private-symbols.py | 1 cui/Library_cui.mk | 3 cui/source/factory/cuiexp.cxx | 46 +++++++++++--- cui/util/cui.component | 4 + offapi/UnoApi_offapi.mk | 1 offapi/com/sun/star/cui/GetCreateDialogFactoryService.idl | 38 +++++++++++ solenv/bin/native-code.py | 1 sw/CppunitTest_sw_a11y.mk | 1 vcl/source/window/abstdlg.cxx | 33 +--------- vcl/workben/commonfuzzer.hxx | 2 10 files changed, 90 insertions(+), 40 deletions(-)
New commits: commit 47bfbbdb73380335196887b36c4d14530c0461ec Author: Noel Grandin <noel.gran...@collabora.co.uk> AuthorDate: Fri Feb 23 13:05:55 2024 +0200 Commit: Noel Grandin <noel.gran...@collabora.co.uk> CommitDate: Sun Feb 25 14:45:55 2024 +0100 Create an UNO service to do the cui symbol lookup in vcl which means I can remove one usage of gb_Library_set_plugin_for, which is blocking linking the cui module into --enable-mergelibs=more Change-Id: Ic6cd48377627f94747037c7247a1cd398738b390 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/163820 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> diff --git a/bin/find-can-be-private-symbols.py b/bin/find-can-be-private-symbols.py index d2835b0af1d7..65fda7320c23 100755 --- a/bin/find-can-be-private-symbols.py +++ b/bin/find-can-be-private-symbols.py @@ -179,7 +179,6 @@ with open("bin/find-can-be-private-symbols.functions.results", "wt") as f: # dynamically loaded elif sym.endswith("get_implementation"): continue elif sym.endswith("component_getFactory"): continue - elif sym == "CreateDialogFactory": continue elif sym == "CreateUnoWrapper": continue elif sym == "ExportDOC": continue elif sym == "ExportRTF": continue diff --git a/cui/Library_cui.mk b/cui/Library_cui.mk index 105defe54e80..e01e33ecb4ec 100644 --- a/cui/Library_cui.mk +++ b/cui/Library_cui.mk @@ -9,8 +9,6 @@ $(eval $(call gb_Library_Library,cui)) -$(eval $(call gb_Library_set_plugin_for,cui,vcl)) - $(eval $(call gb_Library_set_componentfile,cui,cui/util/cui,services)) $(eval $(call gb_Library_set_include,cui,\ @@ -62,6 +60,7 @@ $(eval $(call gb_Library_use_libraries,cui,\ tl \ ucbhelper \ utl \ + vcl \ $(if $(ENABLE_BREAKPAD), \ crashreport \ ) \ diff --git a/cui/source/factory/cuiexp.cxx b/cui/source/factory/cuiexp.cxx index 06557be56779..28b83f6a8780 100644 --- a/cui/source/factory/cuiexp.cxx +++ b/cui/source/factory/cuiexp.cxx @@ -19,18 +19,50 @@ #include "dlgfact.hxx" #include <sal/types.h> +#include <cppuhelper/supportsservice.hxx> +#include <com/sun/star/lang/XUnoTunnel.hpp> -namespace cui +/// anonymous implementation namespace +namespace { -static AbstractDialogFactory_Impl* GetFactory() +class GetCreateDialogFactoryService + : public ::cppu::WeakImplHelper<css::lang::XServiceInfo, css::lang::XUnoTunnel> { - static AbstractDialogFactory_Impl* pFactory = new AbstractDialogFactory_Impl; - return pFactory; -} -} +public: + // css::lang::XServiceInfo: + virtual OUString SAL_CALL getImplementationName() override + { + return "com.sun.star.cui.GetCreateDialogFactoryService"; + } + 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.cui.GetCreateDialogFactoryService" }; + } + + // XUnoTunnel + virtual sal_Int64 SAL_CALL + getSomething(const ::css::uno::Sequence<::sal_Int8>& /*aIdentifier*/) override + { + // Noting that we have to return a pointer to **VclAbstractDialogFactory** otherwise + // the dynamic_casting on the other end will fail on Windows (possibly because of the virtual base involved). + static VclAbstractDialogFactory* pFactory = new AbstractDialogFactory_Impl; + return reinterpret_cast<sal_Int64>(pFactory); + } +}; + +} // closing anonymous implementation namespace extern "C" { -SAL_DLLPUBLIC_EXPORT VclAbstractDialogFactory* CreateDialogFactory() { return ::cui::GetFactory(); } +SAL_DLLPUBLIC_EXPORT css::uno::XInterface* +com_sun_star_cui_GetCreateDialogFactoryService(css::uno::XComponentContext*, + css::uno::Sequence<css::uno::Any> const&) +{ + return cppu::acquire(new GetCreateDialogFactoryService); +} } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/cui/util/cui.component b/cui/util/cui.component index 3ff2cd15c33b..6c72ec90c872 100644 --- a/cui/util/cui.component +++ b/cui/util/cui.component @@ -25,4 +25,8 @@ <service name="com.sun.star.ui.dialogs.ColorPicker"/> <service name="com.sun.star.ui.dialogs.AsynchronousColorPicker"/> </implementation> + <implementation name="com.sun.star.cui.GetCreateDialogFactoryService" + constructor="com_sun_star_cui_GetCreateDialogFactoryService"> + <service name="com.sun.star.cui.GetCreateDialogFactoryService"/> + </implementation> </component> diff --git a/offapi/UnoApi_offapi.mk b/offapi/UnoApi_offapi.mk index ce31dcb1a844..204ef1feb1b5 100644 --- a/offapi/UnoApi_offapi.mk +++ b/offapi/UnoApi_offapi.mk @@ -101,6 +101,7 @@ $(eval $(call gb_UnoApi_add_idlfiles_nohdl,offapi,com/sun/star/configuration,\ $(eval $(call gb_UnoApi_add_idlfiles_nohdl,offapi,com/sun/star/cui,\ AsynchronousColorPicker \ ColorPicker \ + GetCreateDialogFactoryService \ )) $(eval $(call gb_UnoApi_add_idlfiles_nohdl,offapi,com/sun/star/datatransfer,\ DataFormatTranslator \ diff --git a/offapi/com/sun/star/cui/GetCreateDialogFactoryService.idl b/offapi/com/sun/star/cui/GetCreateDialogFactoryService.idl new file mode 100644 index 000000000000..c0fc03c52131 --- /dev/null +++ b/offapi/com/sun/star/cui/GetCreateDialogFactoryService.idl @@ -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 cui { + +/** + The vcl module uses this to call ::cui::GetFactory() in the cui 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 GetCreateDialogFactoryService : com::sun::star::lang::XUnoTunnel; + +}; }; }; }; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/solenv/bin/native-code.py b/solenv/bin/native-code.py index 4358188d1219..915218b865da 100755 --- a/solenv/bin/native-code.py +++ b/solenv/bin/native-code.py @@ -118,6 +118,7 @@ core_constructor_list = [ "com_sun_star_comp_rendering_MtfRenderer_get_implementation", # cui/util/cui.component ("com_sun_star_cui_ColorPicker_get_implementation", "#if !ENABLE_FUZZERS"), + "com_sun_star_cui_GetCreateDialogFactoryService", # dbaccess/util/dba.component "com_sun_star_comp_dba_DataAccessDescriptorFactory", "com_sun_star_comp_dba_OCommandDefinition", diff --git a/sw/CppunitTest_sw_a11y.mk b/sw/CppunitTest_sw_a11y.mk index 0c9a193a6135..a5f611b86208 100644 --- a/sw/CppunitTest_sw_a11y.mk +++ b/sw/CppunitTest_sw_a11y.mk @@ -20,6 +20,7 @@ $(eval $(call gb_CppunitTest_use_libraries,sw_a11y, \ acc \ sal \ cppu \ + cui \ subsequenttest \ test \ unotest \ diff --git a/vcl/source/window/abstdlg.cxx b/vcl/source/window/abstdlg.cxx index 5bacc91b3751..1cc5325c7200 100644 --- a/vcl/source/window/abstdlg.cxx +++ b/vcl/source/window/abstdlg.cxx @@ -17,41 +17,18 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ -#include <osl/module.hxx> #include <vcl/abstdlg.hxx> #include <vcl/bitmapex.hxx> +#include <com/sun/star/cui/GetCreateDialogFactoryService.hpp> +#include <comphelper/processfactory.hxx> typedef VclAbstractDialogFactory*(SAL_CALL* FuncPtrCreateDialogFactory)(); -#ifndef DISABLE_DYNLOADING -extern "C" { -static void thisModule() {} -} -#else -extern "C" VclAbstractDialogFactory* CreateDialogFactory(); -#endif - VclAbstractDialogFactory* VclAbstractDialogFactory::Create() { - static auto fp = []() -> FuncPtrCreateDialogFactory { -#ifndef DISABLE_DYNLOADING - ::osl::Module aDialogLibrary; - if (aDialogLibrary.loadRelative(&thisModule, CUI_DLL_NAME, - SAL_LOADMODULE_GLOBAL | SAL_LOADMODULE_LAZY)) - { - auto const p = reinterpret_cast<FuncPtrCreateDialogFactory>( - aDialogLibrary.getFunctionSymbol("CreateDialogFactory")); - aDialogLibrary.release(); - return p; - } - return nullptr; -#else - return CreateDialogFactory; -#endif - }(); - if (fp) - return fp(); - return nullptr; + auto xService + = css::cui::GetCreateDialogFactoryService::create(comphelper::getProcessComponentContext()); + return reinterpret_cast<VclAbstractDialogFactory*>(xService->getSomething({})); } VclAbstractDialog::~VclAbstractDialog() {} diff --git a/vcl/workben/commonfuzzer.hxx b/vcl/workben/commonfuzzer.hxx index 2ac18fd51a49..72939cb6656d 100644 --- a/vcl/workben/commonfuzzer.hxx +++ b/vcl/workben/commonfuzzer.hxx @@ -79,8 +79,6 @@ namespace } } -extern "C" void* CreateDialogFactory() { return nullptr; } - extern "C" bool GetSpecialCharsForEdit() { return false; } extern "C"