accessibility/Library_acc.mk                                              |    
3 
 accessibility/source/helper/acc_factory.cxx                               |   
39 ++++++++--
 accessibility/util/acc.component                                          |   
26 ++++++
 offapi/UnoApi_offapi.mk                                                   |    
1 
 offapi/com/sun/star/accessibility/GetStandardAccessibleFactoryService.idl |   
38 +++++++++
 toolkit/source/helper/accessibilityclient.cxx                             |   
37 +--------
 6 files changed, 108 insertions(+), 36 deletions(-)

New commits:
commit 1af510e95147374e5289ae1c12f1f280931919f4
Author:     Noel Grandin <noel.gran...@collabora.co.uk>
AuthorDate: Wed Feb 21 11:30:47 2024 +0200
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Thu Feb 29 14:41:48 2024 +0100

    Create an UNO service to do the symbol lookup in 
toolkit::AccessibilityClient
    
    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: I8664ae1d2da4526cc7eab79b36e1589eb391d7c4
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/163680
    Tested-by: Noel Grandin <noel.gran...@collabora.co.uk>
    Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk>

diff --git a/accessibility/Library_acc.mk b/accessibility/Library_acc.mk
index 34c4dc7eb0c5..1382e00019fa 100644
--- a/accessibility/Library_acc.mk
+++ b/accessibility/Library_acc.mk
@@ -9,7 +9,7 @@
 
 $(eval $(call gb_Library_Library,acc))
 
-$(eval $(call gb_Library_set_plugin_for,acc,tk))
+$(eval $(call 
gb_Library_set_componentfile,acc,accessibility/util/acc,services))
 
 $(eval $(call gb_Library_set_include,acc,\
     $$(INCLUDE) \
@@ -33,6 +33,7 @@ $(eval $(call gb_Library_use_libraries,acc,\
     sot \
     svl \
     svt \
+    tk \
     tl \
     utl \
     vcl \
diff --git a/accessibility/source/helper/acc_factory.cxx 
b/accessibility/source/helper/acc_factory.cxx
index 4dcc63e4ab12..25622d1c7c22 100644
--- a/accessibility/source/helper/acc_factory.cxx
+++ b/accessibility/source/helper/acc_factory.cxx
@@ -20,6 +20,7 @@
 #include <config_features.h>
 #include <config_feature_desktop.h>
 
+#include <cppuhelper/supportsservice.hxx>
 #include <toolkit/awt/vclxwindows.hxx>
 #include <toolkit/helper/accessiblefactory.hxx>
 #include <vcl/accessiblefactory.hxx>
@@ -471,6 +472,35 @@ Reference< XAccessible > 
AccessibleFactory::createEditBrowseBoxTableCellAccess(
 } // anonymous namespace
 
 #if HAVE_FEATURE_DESKTOP
+
+/// anonymous implementation namespace
+namespace {
+
+class GetStandardAccessibleFactoryService:
+    public ::cppu::WeakImplHelper<
+        css::lang::XServiceInfo,
+        css::lang::XUnoTunnel>
+{
+public:
+    // css::lang::XServiceInfo:
+    virtual OUString SAL_CALL getImplementationName() override
+        { return 
"com.sun.star.accessibility.comp.GetStandardAccessibleFactoryService"; }
+    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.accessibility.GetStandardAccessibleFactoryService" }; }
+
+    // XUnoTunnel
+    virtual sal_Int64 SAL_CALL getSomething( const ::css::uno::Sequence< 
::sal_Int8 >& /*aIdentifier*/ ) override
+    {
+        ::toolkit::IAccessibleFactory* pFactory = new AccessibleFactory;
+        pFactory->acquire();
+        return reinterpret_cast<sal_Int64>(pFactory);
+    }
+};
+
+} // closing anonymous implementation namespace
+
 /* this is the entry point to retrieve a factory for the toolkit-level 
Accessible/Contexts supplied
     by this library
 
@@ -479,11 +509,12 @@ Reference< XAccessible > 
AccessibleFactory::createEditBrowseBoxTableCellAccess(
 */
 extern "C"
 {
-    SAL_DLLPUBLIC_EXPORT void* getStandardAccessibleFactory()
+    SAL_DLLPUBLIC_EXPORT css::uno::XInterface *
+    
com_sun_star_accessibility_GetStandardAccessibleFactoryService_get_implementation(
+        css::uno::XComponentContext *,
+        css::uno::Sequence<css::uno::Any> const &)
     {
-        ::toolkit::IAccessibleFactory* pFactory = new AccessibleFactory;
-        pFactory->acquire();
-        return pFactory;
+        return cppu::acquire(new GetStandardAccessibleFactoryService);
     }
 }
 
diff --git a/accessibility/util/acc.component b/accessibility/util/acc.component
new file mode 100644
index 000000000000..713a1bb118c1
--- /dev/null
+++ b/accessibility/util/acc.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.accessibility.comp.GetStandardAccessibleFactoryService"
+      
constructor="com_sun_star_accessibility_GetStandardAccessibleFactoryService_get_implementation">
+    <service 
name="com.sun.star.accessibility.GetStandardAccessibleFactoryService"/>
+  </implementation>
+</component>
diff --git a/offapi/UnoApi_offapi.mk b/offapi/UnoApi_offapi.mk
index 204ef1feb1b5..8d2509769466 100644
--- a/offapi/UnoApi_offapi.mk
+++ b/offapi/UnoApi_offapi.mk
@@ -1630,6 +1630,7 @@ $(eval $(call 
gb_UnoApi_add_idlfiles,offapi,com/sun/star/accessibility,\
        AccessibleTableModelChange \
        AccessibleTableModelChangeType \
        AccessibleTextType \
+       GetStandardAccessibleFactoryService \
        IllegalAccessibleComponentStateException \
        TextSegment \
     MSAAService \
diff --git 
a/offapi/com/sun/star/accessibility/GetStandardAccessibleFactoryService.idl 
b/offapi/com/sun/star/accessibility/GetStandardAccessibleFactoryService.idl
new file mode 100644
index 000000000000..15015b8a6f3e
--- /dev/null
+++ b/offapi/com/sun/star/accessibility/GetStandardAccessibleFactoryService.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 accessibility {
+
+/**
+  The toolkit module uses this to get a pointer to the AccessibleFactory from 
the acc 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 GetStandardAccessibleFactoryService : com::sun::star::lang::XUnoTunnel;
+
+}; }; }; };
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/toolkit/source/helper/accessibilityclient.cxx 
b/toolkit/source/helper/accessibilityclient.cxx
index c8bbf2cfb523..01c0cd6b920f 100644
--- a/toolkit/source/helper/accessibilityclient.cxx
+++ b/toolkit/source/helper/accessibilityclient.cxx
@@ -23,13 +23,14 @@
 #include <sal/config.h>
 
 #include <toolkit/helper/accessiblefactory.hxx>
-#include <osl/module.h>
+#include <comphelper/processfactory.hxx>
 #include <osl/diagnose.h>
 #include <osl/mutex.hxx>
 #include <rtl/ref.hxx>
 #include <tools/svlibrary.h>
 
 #include <helper/accessibilityclient.hxx>
+#include <com/sun/star/accessibility/GetStandardAccessibleFactoryService.hpp>
 
 namespace toolkit
 {
@@ -38,14 +39,6 @@ namespace toolkit
 
     namespace
     {
-#ifndef DISABLE_DYNLOADING
-        oslModule                                
s_hAccessibleImplementationModule = nullptr;
-#endif
-#if HAVE_FEATURE_DESKTOP
-#if !ENABLE_WASM_STRIP_ACCESSIBILITY
-        GetStandardAccComponentFactory           s_pAccessibleFactoryFunc = 
nullptr;
-#endif
-#endif
         ::rtl::Reference< IAccessibleFactory >   s_pFactory;
     }
 
@@ -58,16 +51,6 @@ namespace toolkit
     {
     }
 
-#if !ENABLE_WASM_STRIP_ACCESSIBILITY
-#if HAVE_FEATURE_DESKTOP
-#ifndef DISABLE_DYNLOADING
-    extern "C" { static void thisModule() {} }
-#else
-    extern "C" void *getStandardAccessibleFactory();
-#endif
-#endif // HAVE_FEATURE_DESKTOP
-#endif // ENABLE_WASM_STRIP_ACCESSIBILITY
-
     void AccessibilityClient::ensureInitialized()
     {
         if ( m_bInitialized )
@@ -77,20 +60,12 @@ namespace toolkit
 
 #if !ENABLE_WASM_STRIP_ACCESSIBILITY
 #if HAVE_FEATURE_DESKTOP
-        // load the library implementing the factory
         if (!s_pFactory)
         {
-#ifndef DISABLE_DYNLOADING
-            s_hAccessibleImplementationModule = osl_loadModuleRelative( 
&thisModule, u"" SVLIBRARY( "acc" ) ""_ustr.pData, 0 );
-            assert(s_hAccessibleImplementationModule);
-            s_pAccessibleFactoryFunc = 
reinterpret_cast<GetStandardAccComponentFactory>(
-                osl_getFunctionSymbol( s_hAccessibleImplementationModule, 
u"getStandardAccessibleFactory"_ustr.pData ));
-#else
-            s_pAccessibleFactoryFunc = getStandardAccessibleFactory;
-#endif // DISABLE_DYNLOADING
-
-            assert(s_pAccessibleFactoryFunc);
-            IAccessibleFactory* pFactory = static_cast< IAccessibleFactory* >( 
(*s_pAccessibleFactoryFunc)() );
+            auto xService = 
css::accessibility::GetStandardAccessibleFactoryService::create(comphelper::getProcessComponentContext());
+            assert(xService);
+            // get a factory instance
+            IAccessibleFactory* pFactory = 
reinterpret_cast<IAccessibleFactory*>(xService->getSomething({}));
             assert(pFactory);
             s_pFactory = pFactory;
             pFactory->release();

Reply via email to