[Libreoffice-commits] core.git: extensions/Library_dbp.mk extensions/source

Noel Grandin (via logerrit) logerrit at kemper.freedesktop.org
Mon Jul 27 13:34:29 UTC 2020


 extensions/Library_dbp.mk                     |    1 
 extensions/source/dbpilots/dbp.component      |   11 ++-
 extensions/source/dbpilots/dbpservices.cxx    |   65 ------------------
 extensions/source/dbpilots/dbpservices.hxx    |   34 ---------
 extensions/source/dbpilots/unoautopilot.hxx   |   44 ++++--------
 extensions/source/dbpilots/wizardservices.cxx |   89 ++++++++------------------
 extensions/source/dbpilots/wizardservices.hxx |   63 ------------------
 7 files changed, 51 insertions(+), 256 deletions(-)

New commits:
commit 843eb355cb960413fef3817b9cbff75ac1f72c7d
Author:     Noel Grandin <noel.grandin at collabora.co.uk>
AuthorDate: Thu Jul 23 09:39:25 2020 +0200
Commit:     Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Mon Jul 27 15:33:51 2020 +0200

    extensions/dbp: create instances with uno constructors
    
    See tdf#74608 for motivation.
    
    Change-Id: Ifc0cd058dd1ad0f2b66657a6a4287049ebcbebe5
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/99270
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/extensions/Library_dbp.mk b/extensions/Library_dbp.mk
index ccf7151eb2bb..38c58e4f1f0d 100644
--- a/extensions/Library_dbp.mk
+++ b/extensions/Library_dbp.mk
@@ -26,7 +26,6 @@ $(eval $(call gb_Library_use_sdk_api,dbp))
 $(eval $(call gb_Library_add_exception_objects,dbp,\
 	extensions/source/dbpilots/commonpagesdbp \
 	extensions/source/dbpilots/controlwizard \
-	extensions/source/dbpilots/dbpservices \
 	extensions/source/dbpilots/dbptools \
 	extensions/source/dbpilots/gridwizard \
 	extensions/source/dbpilots/groupboxwiz \
diff --git a/extensions/source/dbpilots/dbp.component b/extensions/source/dbpilots/dbp.component
index 5fb9353093db..5cff1fb3c3fe 100644
--- a/extensions/source/dbpilots/dbp.component
+++ b/extensions/source/dbpilots/dbp.component
@@ -18,14 +18,17 @@
  -->
 
 <component loader="com.sun.star.loader.SharedLibrary" environment="@CPPU_ENV@"
-    prefix="dbp" xmlns="http://openoffice.org/2010/uno-components">
-  <implementation name="org.openoffice.comp.dbp.OGridWizard">
+    xmlns="http://openoffice.org/2010/uno-components">
+  <implementation name="org.openoffice.comp.dbp.OGridWizard"
+    constructor="extensions_dbp_OGridWizard_get_implementation">
     <service name="com.sun.star.sdb.GridControlAutoPilot"/>
   </implementation>
-  <implementation name="org.openoffice.comp.dbp.OGroupBoxWizard">
+  <implementation name="org.openoffice.comp.dbp.OGroupBoxWizard"
+    constructor="extensions_dbp_OGroupBoxWizard_get_implementation">
     <service name="com.sun.star.sdb.GroupBoxAutoPilot"/>
   </implementation>
-  <implementation name="org.openoffice.comp.dbp.OListComboWizard">
+  <implementation name="org.openoffice.comp.dbp.OListComboWizard"
+    constructor="extensions_dbp_OListComboWizard_get_implementation">
     <service name="com.sun.star.sdb.ListComboBoxAutoPilot"/>
   </implementation>
 </component>
diff --git a/extensions/source/dbpilots/dbpservices.cxx b/extensions/source/dbpilots/dbpservices.cxx
deleted file mode 100644
index fd2f472ae769..000000000000
--- a/extensions/source/dbpilots/dbpservices.cxx
+++ /dev/null
@@ -1,65 +0,0 @@
-/* -*- 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 .
- */
-
-#include <componentmodule.hxx>
-#include "dbpservices.hxx"
-#include <mutex>
-
-using namespace ::com::sun::star::uno;
-using namespace ::com::sun::star::lang;
-using namespace ::com::sun::star::registry;
-
-extern "C" {
-
-static void dbp_initializeModule()
-{
-    std::once_flag aInit;
-    std::call_once(aInit, [&]()
-    {
-        createRegistryInfo_OGroupBoxWizard();
-        createRegistryInfo_OListComboWizard();
-        createRegistryInfo_OGridWizard();
-        return true;
-    });
-}
-
-}
-
-extern "C" SAL_DLLPUBLIC_EXPORT void* dbp_component_getFactory(
-                    const char* pImplementationName,
-                    void* pServiceManager,
-                    void* /*pRegistryKey*/)
-{
-    dbp_initializeModule();
-
-    Reference< XInterface > xRet;
-    if (pServiceManager && pImplementationName)
-    {
-        xRet = compmodule::OModule::getComponentFactory(
-            OUString::createFromAscii(pImplementationName),
-            static_cast< XMultiServiceFactory* >(pServiceManager));
-    }
-
-    if (xRet.is())
-        xRet->acquire();
-    return xRet.get();
-};
-
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/dbpilots/dbpservices.hxx b/extensions/source/dbpilots/dbpservices.hxx
deleted file mode 100644
index 2feea60c17b3..000000000000
--- a/extensions/source/dbpilots/dbpservices.hxx
+++ /dev/null
@@ -1,34 +0,0 @@
-/* -*- 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 .
- */
-
-#ifndef INCLUDED_EXTENSIONS_SOURCE_DBPILOTS_DBPSERVICES_HXX
-#define INCLUDED_EXTENSIONS_SOURCE_DBPILOTS_DBPSERVICES_HXX
-
-#include <sal/config.h>
-
-extern "C" {
-
-void createRegistryInfo_OGridWizard();
-void createRegistryInfo_OGroupBoxWizard();
-void createRegistryInfo_OListComboWizard();
-}
-
-#endif
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/dbpilots/unoautopilot.hxx b/extensions/source/dbpilots/unoautopilot.hxx
index 4b69cd615ad9..9d201522c24b 100644
--- a/extensions/source/dbpilots/unoautopilot.hxx
+++ b/extensions/source/dbpilots/unoautopilot.hxx
@@ -32,20 +32,22 @@
 namespace dbp
 {
     typedef ::svt::OGenericUnoDialog    OUnoAutoPilot_Base;
-    template <class TYPE, class SERVICEINFO>
+    template <class TYPE>
     class OUnoAutoPilot final
             :public OUnoAutoPilot_Base
-            ,public ::comphelper::OPropertyArrayUsageHelper< OUnoAutoPilot< TYPE, SERVICEINFO > >
+            ,public ::comphelper::OPropertyArrayUsageHelper< OUnoAutoPilot< TYPE > >
     {
-        explicit OUnoAutoPilot(const css::uno::Reference< css::uno::XComponentContext >& _rxORB)
-            : OUnoAutoPilot_Base(_rxORB)
+    public:
+        explicit OUnoAutoPilot(const css::uno::Reference< css::uno::XComponentContext >& _rxORB,
+                OUString aImplementationName,
+                const css::uno::Sequence<OUString>& aSupportedServices)
+            : OUnoAutoPilot_Base(_rxORB),
+              m_ImplementationName(aImplementationName),
+              m_SupportedServices(aSupportedServices)
         {
         }
 
 
-        css::uno::Reference< css::beans::XPropertySet >   m_xObjectModel;
-
-    public:
         // XTypeProvider
         virtual css::uno::Sequence<sal_Int8> SAL_CALL getImplementationId(  ) override
         {
@@ -55,31 +57,12 @@ namespace dbp
         // XServiceInfo
         virtual OUString SAL_CALL getImplementationName() override
         {
-            return getImplementationName_Static();
+            return m_ImplementationName;
         }
 
         virtual css::uno::Sequence<OUString> SAL_CALL getSupportedServiceNames() override
         {
-            return getSupportedServiceNames_Static();
-        }
-
-        // XServiceInfo - static methods
-        /// @throws css::uno::RuntimeException
-        static css::uno::Sequence< OUString > getSupportedServiceNames_Static()
-        {
-            return SERVICEINFO::getServiceNames();
-        }
-
-        /// @throws css::uno::RuntimeException
-        static OUString getImplementationName_Static()
-        {
-            return SERVICEINFO::getImplementationName();
-        }
-
-        static css::uno::Reference< css::uno::XInterface >
-                SAL_CALL Create(const css::uno::Reference< css::lang::XMultiServiceFactory >& _rxFactory)
-        {
-            return *(new OUnoAutoPilot<TYPE, SERVICEINFO>( comphelper::getComponentContext(_rxFactory) ));
+            return m_SupportedServices;
         }
 
         // XPropertySet
@@ -121,6 +104,11 @@ namespace dbp
 
             OUnoAutoPilot_Base::implInitialize(_rValue);
         }
+
+        css::uno::Reference< css::beans::XPropertySet >   m_xObjectModel;
+        OUString m_ImplementationName;
+        css::uno::Sequence<OUString> m_SupportedServices;
+
     };
 
 }   // namespace dbp
diff --git a/extensions/source/dbpilots/wizardservices.cxx b/extensions/source/dbpilots/wizardservices.cxx
index 2f7b91b45a36..25bcf79427b2 100644
--- a/extensions/source/dbpilots/wizardservices.cxx
+++ b/extensions/source/dbpilots/wizardservices.cxx
@@ -19,80 +19,47 @@
 
 #include <sal/config.h>
 
-#include "dbpservices.hxx"
-#include "wizardservices.hxx"
 #include "unoautopilot.hxx"
 #include "groupboxwiz.hxx"
 #include "listcombowizard.hxx"
 #include "gridwizard.hxx"
 
 // the registration methods
-extern "C" void createRegistryInfo_OGroupBoxWizard()
-{
-    static compmodule::OMultiInstanceAutoRegistration<
-        ::dbp::OUnoAutoPilot< ::dbp::OGroupBoxWizard, ::dbp::OGroupBoxSI >
-    > aAutoRegistration;
-}
 
-extern "C" void createRegistryInfo_OListComboWizard()
+extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
+extensions_dbp_OGroupBoxWizard_get_implementation(
+    css::uno::XComponentContext* context , css::uno::Sequence<css::uno::Any> const&)
 {
-    static compmodule::OMultiInstanceAutoRegistration<
-        ::dbp::OUnoAutoPilot< ::dbp::OListComboWizard, ::dbp::OListComboSI >
-    > aAutoRegistration;
+    return cppu::acquire(
+        new ::dbp::OUnoAutoPilot< ::dbp::OGroupBoxWizard>(
+            context,
+            "org.openoffice.comp.dbp.OGroupBoxWizard",
+            { "com.sun.star.sdb.GroupBoxAutoPilot" }
+            ));
 }
 
-extern "C" void createRegistryInfo_OGridWizard()
+extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
+extensions_dbp_OListComboWizard_get_implementation(
+    css::uno::XComponentContext* context , css::uno::Sequence<css::uno::Any> const&)
 {
-    static compmodule::OMultiInstanceAutoRegistration<
-        ::dbp::OUnoAutoPilot< ::dbp::OGridWizard, ::dbp::OGridSI >
-    > aAutoRegistration;
+    return cppu::acquire(
+        new ::dbp::OUnoAutoPilot< ::dbp::OListComboWizard>(
+            context,
+            "org.openoffice.comp.dbp.OListComboWizard",
+            { "com.sun.star.sdb.ListComboBoxAutoPilot" }
+            ));
 }
 
-
-namespace dbp
+extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
+extensions_dbp_OGridWizard_get_implementation(
+    css::uno::XComponentContext* context , css::uno::Sequence<css::uno::Any> const&)
 {
-
-
-    using namespace ::com::sun::star::uno;
-
-    OUString OGroupBoxSI::getImplementationName()
-    {
-        return "org.openoffice.comp.dbp.OGroupBoxWizard";
-    }
-
-
-    Sequence< OUString > OGroupBoxSI::getServiceNames()
-    {
-        Sequence< OUString > aReturn { "com.sun.star.sdb.GroupBoxAutoPilot" };
-        return aReturn;
-    }
-
-    OUString OListComboSI::getImplementationName()
-    {
-        return "org.openoffice.comp.dbp.OListComboWizard";
-    }
-
-
-    Sequence< OUString > OListComboSI::getServiceNames()
-    {
-        Sequence< OUString > aReturn { "com.sun.star.sdb.ListComboBoxAutoPilot" };
-        return aReturn;
-    }
-
-    OUString OGridSI::getImplementationName()
-    {
-        return "org.openoffice.comp.dbp.OGridWizard";
-    }
-
-
-    Sequence< OUString > OGridSI::getServiceNames()
-    {
-        Sequence< OUString > aReturn { "com.sun.star.sdb.GridControlAutoPilot" };
-        return aReturn;
-    }
-
-
-}   // namespace dbp
-
+    return cppu::acquire(
+        new ::dbp::OUnoAutoPilot< ::dbp::OGridWizard>(
+            context,
+            "org.openoffice.comp.dbp.OGridWizard",
+            { "com.sun.star.sdb.GridControlAutoPilot" }
+            ));
+}
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/dbpilots/wizardservices.hxx b/extensions/source/dbpilots/wizardservices.hxx
deleted file mode 100644
index 9ed99154e0b4..000000000000
--- a/extensions/source/dbpilots/wizardservices.hxx
+++ /dev/null
@@ -1,63 +0,0 @@
-/* -*- 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 .
- */
-
-#ifndef INCLUDED_EXTENSIONS_SOURCE_DBPILOTS_WIZARDSERVICES_HXX
-#define INCLUDED_EXTENSIONS_SOURCE_DBPILOTS_WIZARDSERVICES_HXX
-
-#include <com/sun/star/uno/Sequence.hxx>
-#include <rtl/ustring.hxx>
-
-
-namespace dbp
-{
-    // service info for the group box wizard
-    struct OGroupBoxSI
-    {
-    public:
-        static OUString         getImplementationName();
-        static css::uno::Sequence< OUString >
-                                getServiceNames();
-    };
-
-    // service info for the list/combo box wizard
-    struct OListComboSI
-    {
-    public:
-        static OUString         getImplementationName();
-        static css::uno::Sequence< OUString >
-                                getServiceNames();
-    };
-
-
-    // service info for the grid wizard
-    struct OGridSI
-    {
-    public:
-        static OUString         getImplementationName();
-        static css::uno::Sequence< OUString >
-                                getServiceNames();
-    };
-
-
-}   // namespace dbp
-
-
-#endif // INCLUDED_EXTENSIONS_SOURCE_DBPILOTS_WIZARDSERVICES_HXX
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */


More information about the Libreoffice-commits mailing list