[Libreoffice-commits] core.git: solenv/bin ucb/Library_ucphier1.mk ucb/source

Noel Grandin (via logerrit) logerrit at kemper.freedesktop.org
Thu Jul 16 11:16:02 UTC 2020


 solenv/bin/native-code.py                        |    4 +
 ucb/Library_ucphier1.mk                          |    1 
 ucb/source/ucp/hierarchy/hierarchydatasource.cxx |   33 ++++-------
 ucb/source/ucp/hierarchy/hierarchydatasource.hxx |    6 --
 ucb/source/ucp/hierarchy/hierarchyprovider.cxx   |   36 ++++--------
 ucb/source/ucp/hierarchy/hierarchyprovider.hxx   |    7 --
 ucb/source/ucp/hierarchy/hierarchyservices.cxx   |   69 -----------------------
 ucb/source/ucp/hierarchy/ucphier1.component      |    8 +-
 8 files changed, 36 insertions(+), 128 deletions(-)

New commits:
commit a48ab89fe259d385f20a14f62c9cd9bc7b5b36e9
Author:     Noel Grandin <noel.grandin at collabora.co.uk>
AuthorDate: Thu Jul 16 10:10:03 2020 +0200
Commit:     Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Thu Jul 16 13:15:25 2020 +0200

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

diff --git a/solenv/bin/native-code.py b/solenv/bin/native-code.py
index 931435367b5d..8153cebb6596 100755
--- a/solenv/bin/native-code.py
+++ b/solenv/bin/native-code.py
@@ -29,7 +29,6 @@ core_factory_list = [
     ("libucb1.a", "ucb_component_getFactory"),
     ("libucpexpand1lo.a", "ucpexpand1_component_getFactory", "#ifdef ANDROID"),
     ("libucpfile1.a", "ucpfile_component_getFactory"),
-    ("libucphier1.a", "ucphier1_component_getFactory"),
     ("libxstor.a", "xstor_component_getFactory"),
     ("libodfflatxmllo.a", "odfflatxml_component_getFactory"),
     ("libvcllo.a", "vcl_component_getFactory"),
@@ -331,6 +330,9 @@ core_constructor_list = [
 # ucb/source/tdoc/ucptdoc1.component
     "ucb_tdoc_ContentProvider_get_implementation",
     "ucb_tdoc_DocumentContentFactory_get_implementation",
+# ucb/source/ucp/ucphier1.component
+    "ucb_HierarchyContentProvider_get_implementation",
+    "ucb_HierarchyDataSource_get_implementation",
 # unotools/util/utl.component
     "unotools_ServiceDocument_get_implementation",
     "unotools_OTempFileService_get_implementation",
diff --git a/ucb/Library_ucphier1.mk b/ucb/Library_ucphier1.mk
index 5e4c6d68c52b..27406f7a9b3c 100644
--- a/ucb/Library_ucphier1.mk
+++ b/ucb/Library_ucphier1.mk
@@ -33,7 +33,6 @@ $(eval $(call gb_Library_add_exception_objects,ucphier1,\
 	ucb/source/ucp/hierarchy/hierarchydatasource \
 	ucb/source/ucp/hierarchy/hierarchydatasupplier \
 	ucb/source/ucp/hierarchy/hierarchyprovider \
-	ucb/source/ucp/hierarchy/hierarchyservices \
 	ucb/source/ucp/hierarchy/hierarchyuri \
 ))
 
diff --git a/ucb/source/ucp/hierarchy/hierarchydatasource.cxx b/ucb/source/ucp/hierarchy/hierarchydatasource.cxx
index c3e9340b57ac..e082994b0105 100644
--- a/ucb/source/ucp/hierarchy/hierarchydatasource.cxx
+++ b/ucb/source/ucp/hierarchy/hierarchydatasource.cxx
@@ -40,6 +40,7 @@
 #include <com/sun/star/lang/XSingleServiceFactory.hpp>
 #include <ucbhelper/getcomponentcontext.hxx>
 #include <ucbhelper/macros.hxx>
+#include <rtl/ref.hxx>
 
 using namespace com::sun::star;
 using namespace hierarchy_ucp;
@@ -195,35 +196,29 @@ HierarchyDataSource::~HierarchyDataSource()
 }
 
 // XServiceInfo methods.
-
-XSERVICEINFO_COMMOM_IMPL( HierarchyDataSource,
-                          "com.sun.star.comp.ucb.HierarchyDataSource" )
-/// @throws css::uno::Exception
-static css::uno::Reference< css::uno::XInterface >
-HierarchyDataSource_CreateInstance( const css::uno::Reference< css::lang::XMultiServiceFactory> & rSMgr )
+OUString SAL_CALL HierarchyDataSource::getImplementationName()                       \
 {
-    css::lang::XServiceInfo* pX = new HierarchyDataSource( ucbhelper::getComponentContext(rSMgr) );
-    return css::uno::Reference< css::uno::XInterface >::query( pX );
+    return "com.sun.star.comp.ucb.HierarchyDataSource";
 }
-
-css::uno::Sequence< OUString >
-HierarchyDataSource::getSupportedServiceNames_Static()
+sal_Bool SAL_CALL HierarchyDataSource::supportsService( const OUString& ServiceName )
+{
+    return cppu::supportsService( this, ServiceName );
+}
+css::uno::Sequence< OUString > HierarchyDataSource::getSupportedServiceNames()
 {
     return { "com.sun.star.ucb.DefaultHierarchyDataSource", "com.sun.star.ucb.HierarchyDataSource" };
 }
 
-css::uno::Reference< css::lang::XSingleServiceFactory >
-HierarchyDataSource::createServiceFactory( const css::uno::Reference< css::lang::XMultiServiceFactory >& rxServiceMgr )
+extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
+ucb_HierarchyDataSource_get_implementation(
+    css::uno::XComponentContext* context , css::uno::Sequence<css::uno::Any> const&)
 {
-    return cppu::createOneInstanceFactory(
-                rxServiceMgr,
-                HierarchyDataSource::getImplementationName_Static(),
-                HierarchyDataSource_CreateInstance,
-                HierarchyDataSource::getSupportedServiceNames_Static() );
+    static rtl::Reference<HierarchyDataSource> g_Instance(new HierarchyDataSource(context));
+    g_Instance->acquire();
+    return static_cast<cppu::OWeakObject*>(g_Instance.get());
 }
 
 
-
 // XComponent methods.
 
 
diff --git a/ucb/source/ucp/hierarchy/hierarchydatasource.hxx b/ucb/source/ucp/hierarchy/hierarchydatasource.hxx
index 3c2eb82ba64d..e21d7acda551 100644
--- a/ucb/source/ucp/hierarchy/hierarchydatasource.hxx
+++ b/ucb/source/ucp/hierarchy/hierarchydatasource.hxx
@@ -53,12 +53,6 @@ public:
     virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override;
     virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override;
 
-    static OUString getImplementationName_Static();
-    static css::uno::Sequence< OUString > getSupportedServiceNames_Static();
-
-    static css::uno::Reference< css::lang::XSingleServiceFactory > createServiceFactory( const css::uno::Reference<
-                          css::lang::XMultiServiceFactory >& rxServiceMgr );
-
     // XComponent
     virtual void SAL_CALL dispose() override;
     virtual void SAL_CALL addEventListener( const css::uno::Reference< css::lang::XEventListener > & xListener ) override;
diff --git a/ucb/source/ucp/hierarchy/hierarchyprovider.cxx b/ucb/source/ucp/hierarchy/hierarchyprovider.cxx
index 605c0b9d9b32..342b686f2286 100644
--- a/ucb/source/ucp/hierarchy/hierarchyprovider.cxx
+++ b/ucb/source/ucp/hierarchy/hierarchyprovider.cxx
@@ -97,38 +97,30 @@ XTYPEPROVIDER_IMPL_4( HierarchyContentProvider,
 
 // XServiceInfo methods.
 
-XSERVICEINFO_COMMOM_IMPL( HierarchyContentProvider,
-                          "com.sun.star.comp.ucb.HierarchyContentProvider" )
-/// @throws css::uno::Exception
-static css::uno::Reference< css::uno::XInterface >
-HierarchyContentProvider_CreateInstance( const css::uno::Reference< css::lang::XMultiServiceFactory> & rSMgr )
+OUString SAL_CALL HierarchyContentProvider::getImplementationName()                       \
 {
-    css::lang::XServiceInfo* pX = new HierarchyContentProvider( ucbhelper::getComponentContext(rSMgr) );
-    return css::uno::Reference< css::uno::XInterface >::query( pX );
+    return "com.sun.star.comp.ucb.HierarchyContentProvider";
 }
-
-css::uno::Sequence< OUString >
-HierarchyContentProvider::getSupportedServiceNames_Static()
+sal_Bool SAL_CALL HierarchyContentProvider::supportsService( const OUString& ServiceName )
+{
+    return cppu::supportsService( this, ServiceName );
+}
+css::uno::Sequence< OUString > HierarchyContentProvider::getSupportedServiceNames()
 {
-    css::uno::Sequence< OUString > aSNS { "com.sun.star.ucb.HierarchyContentProvider" };
-    return aSNS;
+    return { "com.sun.star.ucb.HierarchyContentProvider" };
 }
 
 // Service factory implementation.
 
-
-css::uno::Reference< css::lang::XSingleServiceFactory >
-HierarchyContentProvider::createServiceFactory( const css::uno::Reference< css::lang::XMultiServiceFactory >& rxServiceMgr )
+extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
+ucb_HierarchyContentProvider_get_implementation(
+    css::uno::XComponentContext* context , css::uno::Sequence<css::uno::Any> const&)
 {
-    return cppu::createOneInstanceFactory(
-                rxServiceMgr,
-                HierarchyContentProvider::getImplementationName_Static(),
-                HierarchyContentProvider_CreateInstance,
-                HierarchyContentProvider::getSupportedServiceNames_Static() );
+    static rtl::Reference<HierarchyContentProvider> g_Instance(new HierarchyContentProvider(context));
+    g_Instance->acquire();
+    return static_cast<cppu::OWeakObject*>(g_Instance.get());
 }
 
-
-
 // XContentProvider methods.
 
 
diff --git a/ucb/source/ucp/hierarchy/hierarchyprovider.hxx b/ucb/source/ucp/hierarchy/hierarchyprovider.hxx
index 1bc72e034dc0..4c82a262dfe4 100644
--- a/ucb/source/ucp/hierarchy/hierarchyprovider.hxx
+++ b/ucb/source/ucp/hierarchy/hierarchyprovider.hxx
@@ -90,13 +90,6 @@ public:
     virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override;
     virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override;
 
-    static OUString getImplementationName_Static();
-    static css::uno::Sequence< OUString > getSupportedServiceNames_Static();
-
-    static css::uno::Reference< css::lang::XSingleServiceFactory >
-    createServiceFactory( const css::uno::Reference<
-                          css::lang::XMultiServiceFactory >& rxServiceMgr );
-
     // XContentProvider
     virtual css::uno::Reference< css::ucb::XContent > SAL_CALL
     queryContent( const css::uno::Reference< css::ucb::XContentIdentifier >& Identifier ) override;
diff --git a/ucb/source/ucp/hierarchy/hierarchyservices.cxx b/ucb/source/ucp/hierarchy/hierarchyservices.cxx
deleted file mode 100644
index a8161341da8c..000000000000
--- a/ucb/source/ucp/hierarchy/hierarchyservices.cxx
+++ /dev/null
@@ -1,69 +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 <com/sun/star/lang/XMultiServiceFactory.hpp>
-#include <com/sun/star/lang/XSingleServiceFactory.hpp>
-#include "hierarchyprovider.hxx"
-#include "hierarchydatasource.hxx"
-
-using namespace com::sun::star;
-using namespace hierarchy_ucp;
-
-
-extern "C" SAL_DLLPUBLIC_EXPORT void * ucphier1_component_getFactory(
-    const char * pImplName, void * pServiceManager, void * /*pRegistryKey*/ )
-{
-    void * pRet = nullptr;
-
-    uno::Reference< lang::XMultiServiceFactory > xSMgr(
-            static_cast< lang::XMultiServiceFactory * >(
-                pServiceManager ) );
-    uno::Reference< lang::XSingleServiceFactory > xFactory;
-
-
-    // Hierarchy Content Provider.
-
-
-    if ( HierarchyContentProvider::getImplementationName_Static().
-                equalsAscii( pImplName ) )
-    {
-        xFactory = HierarchyContentProvider::createServiceFactory( xSMgr );
-    }
-
-
-    // Hierarchy Data Source.
-
-
-    else if ( HierarchyDataSource::getImplementationName_Static().
-                equalsAscii( pImplName ) )
-    {
-        xFactory = HierarchyDataSource::createServiceFactory( xSMgr );
-    }
-
-
-    if ( xFactory.is() )
-    {
-        xFactory->acquire();
-        pRet = xFactory.get();
-    }
-
-    return pRet;
-}
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/ucb/source/ucp/hierarchy/ucphier1.component b/ucb/source/ucp/hierarchy/ucphier1.component
index 6d880b46cf7c..5122c5a63787 100644
--- a/ucb/source/ucp/hierarchy/ucphier1.component
+++ b/ucb/source/ucp/hierarchy/ucphier1.component
@@ -18,11 +18,13 @@
  -->
 
 <component loader="com.sun.star.loader.SharedLibrary" environment="@CPPU_ENV@"
-    prefix="ucphier1" xmlns="http://openoffice.org/2010/uno-components">
-  <implementation name="com.sun.star.comp.ucb.HierarchyContentProvider">
+    xmlns="http://openoffice.org/2010/uno-components">
+  <implementation name="com.sun.star.comp.ucb.HierarchyContentProvider"
+    constructor="ucb_HierarchyContentProvider_get_implementation">
     <service name="com.sun.star.ucb.HierarchyContentProvider"/>
   </implementation>
-  <implementation name="com.sun.star.comp.ucb.HierarchyDataSource">
+  <implementation name="com.sun.star.comp.ucb.HierarchyDataSource"
+    constructor="ucb_HierarchyDataSource_get_implementation">
     <service name="com.sun.star.ucb.DefaultHierarchyDataSource"/>
     <service name="com.sun.star.ucb.HierarchyDataSource"/>
   </implementation>


More information about the Libreoffice-commits mailing list