offapi/UnoApi_offapi.mk                                  |    1 
 offapi/com/sun/star/sheet/CreateDialogFactoryService.idl |   38 +++++++++++++
 sc/Library_scui.mk                                       |    3 -
 sc/source/ui/attrdlg/scabstdlg.cxx                       |   34 ++----------
 sc/source/ui/attrdlg/scuiexp.cxx                         |   41 +++++++++++++--
 sc/util/scui.component                                   |   26 +++++++++
 6 files changed, 112 insertions(+), 31 deletions(-)

New commits:
commit e311a4b87bad35a50812574dd9a96d6f4cd8dfd8
Author:     Noel Grandin <noel.gran...@collabora.co.uk>
AuthorDate: Tue Mar 5 12:02:05 2024 +0200
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Tue Mar 5 13:07:36 2024 +0100

    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.gran...@collabora.co.uk>

diff --git a/offapi/UnoApi_offapi.mk b/offapi/UnoApi_offapi.mk
index 8a9cb2f58757..5cfc725c5e29 100644
--- a/offapi/UnoApi_offapi.mk
+++ b/offapi/UnoApi_offapi.mk
@@ -3398,6 +3398,7 @@ $(eval $(call 
gb_UnoApi_add_idlfiles,offapi,com/sun/star/sheet,\
        ConditionFormatOperator \
        ConditionOperator \
        ConditionOperator2 \
+       CreateDialogFactoryService \
        DataBarAxis \
        DataBarEntryType \
        DateType \
diff --git a/offapi/com/sun/star/sheet/CreateDialogFactoryService.idl 
b/offapi/com/sun/star/sheet/CreateDialogFactoryService.idl
new file mode 100644
index 000000000000..9fdf5176ec20
--- /dev/null
+++ b/offapi/com/sun/star/sheet/CreateDialogFactoryService.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 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: */
diff --git a/sc/Library_scui.mk b/sc/Library_scui.mk
index a4c7572734ae..a71140b9803b 100644
--- a/sc/Library_scui.mk
+++ b/sc/Library_scui.mk
@@ -9,7 +9,7 @@
 
 $(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,\
        -I$(SRCDIR)/sc/source/core/inc \
@@ -58,6 +58,7 @@ $(eval $(call gb_Library_use_libraries,scui,\
        $(call gb_Helper_optional,OPENCL, \
                opencl) \
        sal \
+       sc \
        sfx \
        sot \
        svl \
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 <osl/module.hxx>
 #include <tools/svlibrary.h>
-
-typedef ScAbstractDialogFactory* (*ScFuncPtrCreateDialogFactory)();
-
-#ifndef DISABLE_DYNLOADING
-
-extern "C" { static void thisModule() {} }
-
-#else
-
-extern "C" ScAbstractDialogFactory* ScCreateDialogFactory();
-
-#endif
+#include <comphelper/processfactory.hxx>
+#include <com/sun/star/sheet/CreateDialogFactoryService.hpp>
 
 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<ScAbstractDialogFactory* (SAL_CALL*)()>(
-            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<ScAbstractDialogFactory*>(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 <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" {
-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 &aFactory;
+    return cppu::acquire(new CreateDialogFactoryService);
 }
 }
-
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/util/scui.component b/sc/util/scui.component
new file mode 100644
index 000000000000..3a36222b93bc
--- /dev/null
+++ b/sc/util/scui.component
@@ -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>

Reply via email to