[Libreoffice-commits] core.git: connectivity/source

Noel Grandin (via logerrit) logerrit at kemper.freedesktop.org
Mon Jul 13 17:50:52 UTC 2020


 connectivity/source/drivers/mozab/bootstrap/MMozillaBootstrap.cxx  |   63 +---------
 connectivity/source/drivers/mozab/bootstrap/MMozillaBootstrap.hxx  |    3 
 connectivity/source/drivers/mozab/bootstrap/mozbootstrap.component |    5 
 3 files changed, 13 insertions(+), 58 deletions(-)

New commits:
commit 9ad54d31c80a6ba826f3c121efbf6b9376140c86
Author:     Noel Grandin <noel.grandin at collabora.co.uk>
AuthorDate: Mon Jul 13 16:02:05 2020 +0200
Commit:     Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Mon Jul 13 19:50:00 2020 +0200

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

diff --git a/connectivity/source/drivers/mozab/bootstrap/MMozillaBootstrap.cxx b/connectivity/source/drivers/mozab/bootstrap/MMozillaBootstrap.cxx
index 8dc7768778af..62bea4e8f253 100644
--- a/connectivity/source/drivers/mozab/bootstrap/MMozillaBootstrap.cxx
+++ b/connectivity/source/drivers/mozab/bootstrap/MMozillaBootstrap.cxx
@@ -21,6 +21,7 @@
 #include <cppuhelper/factory.hxx>
 #include <com/sun/star/lang/XSingleServiceFactory.hpp>
 #include <cppuhelper/supportsservice.hxx>
+#include <rtl/ref.hxx>
 #include "MMozillaBootstrap.hxx"
 #include "MNSProfileDiscover.hxx"
 
@@ -34,34 +35,17 @@ using ::com::sun::star::uno::Sequence;
 using ::com::sun::star::lang::XSingleServiceFactory;
 using ::com::sun::star::lang::XMultiServiceFactory;
 
-static MozillaBootstrap *pMozillaBootstrap=nullptr;
-static Reference<XMozillaBootstrap> xMozillaBootstrap;
-extern "C" SAL_DLLPUBLIC_EXPORT void* OMozillaBootstrap_CreateInstance(const css::uno::Reference< css::lang::XMultiServiceFactory >& )
-{
-    if (!pMozillaBootstrap)
-    {
-        pMozillaBootstrap=new connectivity::mozab::MozillaBootstrap;
-        pMozillaBootstrap->Init();
-        xMozillaBootstrap = pMozillaBootstrap;
-    }
-    return  pMozillaBootstrap;
-}
-
 MozillaBootstrap::MozillaBootstrap()
     : OMozillaBootstrap_BASE(m_aMutex)
 {
+    m_ProfileAccess.reset(new ProfileAccess);
+    bootupProfile(css::mozilla::MozillaProductType_Mozilla,OUString());
 }
 
 MozillaBootstrap::~MozillaBootstrap()
 {
 }
 
-void MozillaBootstrap::Init()
-{
-    m_ProfileAccess.reset(new ProfileAccess);
-    bootupProfile(css::mozilla::MozillaProductType_Mozilla,OUString());
-}
-
 void MozillaBootstrap::disposing()
 {
     ::osl::MutexGuard aGuard(m_aMutex);
@@ -70,7 +54,7 @@ void MozillaBootstrap::disposing()
 
 OUString SAL_CALL MozillaBootstrap::getImplementationName(  )
 {
-    return MOZAB_MozillaBootstrap_IMPL_NAME;
+    return "com.sun.star.comp.mozilla.MozillaBootstrap";
 }
 
 sal_Bool SAL_CALL MozillaBootstrap::supportsService( const OUString& _rServiceName )
@@ -144,40 +128,13 @@ OUString SAL_CALL MozillaBootstrap::setCurrentProfile( css::mozilla::MozillaProd
     return -1;
 }
 
-static Reference< XInterface > createInstance( const Reference< XMultiServiceFactory >& rServiceManager )
+extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
+connectivity_moz_MozillaBootstrap_get_implementation(
+    css::uno::XComponentContext* , css::uno::Sequence<css::uno::Any> const&)
 {
-        MozillaBootstrap * pBootstrap = static_cast<MozillaBootstrap*>(OMozillaBootstrap_CreateInstance(rServiceManager));
-        return *pBootstrap;
+    static rtl::Reference<MozillaBootstrap> pMozillaBootstrap(new connectivity::mozab::MozillaBootstrap());
+    pMozillaBootstrap->acquire();
+    return static_cast<cppu::OWeakObject*>(pMozillaBootstrap.get());
 }
 
-extern "C" SAL_DLLPUBLIC_EXPORT void* mozbootstrap_component_getFactory(
-                                        const char* pImplementationName,
-                                        void* pServiceManager,
-                                        void* /*pRegistryKey*/)
-{
-        void* pRet = nullptr;
-
-        if (pServiceManager)
-        {
-                OUString aImplName( OUString::createFromAscii( pImplementationName ) );
-                Reference< XSingleServiceFactory > xFactory;
-                if ( aImplName == "com.sun.star.comp.mozilla.MozillaBootstrap" )
-                {
-                    Sequence<OUString> aSNS { "com.sun.star.mozilla.MozillaBootstrap" };
-
-                    xFactory = ::cppu::createSingleFactory(
-                        static_cast< XMultiServiceFactory* > ( pServiceManager),
-                        aImplName, createInstance, aSNS );
-                }
-                if ( xFactory.is() )
-                {
-                    xFactory->acquire();
-                    pRet = xFactory.get();
-                }
-        }
-
-        return pRet;
-};
-
-
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/connectivity/source/drivers/mozab/bootstrap/MMozillaBootstrap.hxx b/connectivity/source/drivers/mozab/bootstrap/MMozillaBootstrap.hxx
index a727e3579e0e..24407e038ccb 100644
--- a/connectivity/source/drivers/mozab/bootstrap/MMozillaBootstrap.hxx
+++ b/connectivity/source/drivers/mozab/bootstrap/MMozillaBootstrap.hxx
@@ -28,8 +28,6 @@
 #include <cppuhelper/compbase.hxx>
 
 
-#define MOZAB_MozillaBootstrap_IMPL_NAME "com.sun.star.comp.mozilla.MozillaBootstrap"
-
 namespace connectivity
 {
     namespace mozab
@@ -46,7 +44,6 @@ namespace connectivity
             std::unique_ptr<ProfileAccess> m_ProfileAccess;
         public:
 
-            void Init();
             MozillaBootstrap();
 
             // OComponentHelper
diff --git a/connectivity/source/drivers/mozab/bootstrap/mozbootstrap.component b/connectivity/source/drivers/mozab/bootstrap/mozbootstrap.component
index 848112c64e79..11b58c134ba8 100644
--- a/connectivity/source/drivers/mozab/bootstrap/mozbootstrap.component
+++ b/connectivity/source/drivers/mozab/bootstrap/mozbootstrap.component
@@ -18,8 +18,9 @@
  -->
 
 <component loader="com.sun.star.loader.SharedLibrary" environment="@CPPU_ENV@"
-    prefix="mozbootstrap" xmlns="http://openoffice.org/2010/uno-components">
-  <implementation name="com.sun.star.comp.mozilla.MozillaBootstrap">
+    xmlns="http://openoffice.org/2010/uno-components">
+  <implementation name="com.sun.star.comp.mozilla.MozillaBootstrap"
+    constructor="connectivity_moz_MozillaBootstrap_get_implementation">
     <service name="com.sun.star.mozilla.MozillaBootstrap"/>
   </implementation>
 </component>


More information about the Libreoffice-commits mailing list