[Libreoffice-commits] core.git: 7 commits - cppuhelper/source cpputools/source include/cppuhelper jurt/com stoc/source

Stephan Bergmann sbergman at redhat.com
Mon Sep 30 16:18:31 PDT 2013


 cppuhelper/source/compat.cxx                               |   27 -
 cppuhelper/source/shlib.cxx                                |  314 +------------
 cpputools/source/unoexe/unoexe.cxx                         |   43 -
 include/cppuhelper/shlib.hxx                               |   70 --
 jurt/com/sun/star/comp/loader/RegistrationClassFinder.java |   58 --
 stoc/source/loader/dllcomponentloader.cxx                  |   23 
 6 files changed, 69 insertions(+), 466 deletions(-)

New commits:
commit d2e1dd559f4009a83f3ce6cb6617dfced010be74
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Tue Oct 1 01:15:30 2013 +0200

    [API CHANGE] Stricter requirements for shlib.hxx function arguments
    
    rLibName -> uri must be an (absolute file) URI, rPath must be empty, and xKey
    must be null in loadSharedLibComponentFactory.  While incompatible in theory,
    these functions should only be called internally, anyway.
    
    Change-Id: Iab144b199e4e7db62358283efec6877a5da19bab

diff --git a/cppuhelper/source/shlib.cxx b/cppuhelper/source/shlib.cxx
index 00c21d2..09b7004 100644
--- a/cppuhelper/source/shlib.cxx
+++ b/cppuhelper/source/shlib.cxx
@@ -19,11 +19,7 @@
 
 #include "sal/config.h"
 
-#include "osl/diagnose.h"
-#include "osl/file.hxx"
-#include "osl/mutex.hxx"
 #include "osl/module.hxx"
-#include "rtl/ustrbuf.hxx"
 #include "uno/environment.h"
 #include "uno/mapping.hxx"
 #include "cppuhelper/factory.hxx"
@@ -47,67 +43,12 @@ using namespace ::com::sun::star::uno;
 
 using rtl::OString;
 using rtl::OUString;
-using rtl::OUStringBuffer;
 
 namespace cppu
 {
 
 #ifndef DISABLE_DYNLOADING
 
-static OUString makeComponentPath(
-    const OUString & rLibName, const OUString & rPath )
-{
-#if OSL_DEBUG_LEVEL > 0
-    // No system path allowed here !
-    {
-        OUString aComp;
-        OSL_ASSERT( FileBase::E_None ==
-                    FileBase::getSystemPathFromFileURL( rLibName, aComp ) );
-        OSL_ASSERT(
-            rPath.isEmpty() ||
-            FileBase::E_None ==
-              FileBase::getSystemPathFromFileURL( rPath, aComp ) );
-    }
-#endif
-
-    OUStringBuffer buf( rPath.getLength() + rLibName.getLength() + 12 );
-
-    if (!rPath.isEmpty())
-    {
-        buf.append( rPath );
-        if (rPath[ rPath.getLength() -1 ] != '/')
-            buf.append( (sal_Unicode) '/' );
-    }
-    if (!rLibName.endsWithIgnoreAsciiCase( SAL_DLLEXTENSION )
-#if defined MACOSX
-        && !rLibName.endsWithIgnoreAsciiCase(".jnilib")
-#endif
-        )
-    {
-#if defined SAL_DLLPREFIX
-        if (! rLibName.endsWithIgnoreAsciiCase( ".uno" ))
-        {
-            buf.appendAscii( RTL_CONSTASCII_STRINGPARAM(SAL_DLLPREFIX) );
-        }
-#endif
-        buf.append( rLibName );
-        buf.appendAscii( RTL_CONSTASCII_STRINGPARAM(SAL_DLLEXTENSION) );
-    }
-    else // name is completely pre/postfixed
-    {
-        buf.append( rLibName );
-    }
-
-    OUString out( buf.makeStringAndClear() );
-#if OSL_DEBUG_LEVEL > 1
-    OString str( OUStringToOString( out, RTL_TEXTENCODING_ASCII_US ) );
-    OSL_TRACE(OSL_LOG_PREFIX "component path=%s", str.getStr());
-#endif
-
-    return out;
-}
-
-//==============================================================================
 static void getLibEnv(oslModule                lib,
                       uno::Environment       * pEnv,
                       OUString               * pSourceEnv_name,
@@ -176,13 +117,12 @@ extern "C" {static void s_getFactory(va_list * pParam)
 
 /* For backwards compatibility */
 Reference< XInterface > SAL_CALL loadSharedLibComponentFactory(
-    OUString const & rLibName, OUString const & rPath,
-    OUString const & rImplName,
+    OUString const & uri, OUString const & rPath, OUString const & rImplName,
     Reference< lang::XMultiServiceFactory > const & xMgr,
     Reference< registry::XRegistryKey > const & xKey )
     SAL_THROW( (loader::CannotActivateFactoryException) )
 {
-    return loadSharedLibComponentFactory( rLibName, rPath, rImplName, xMgr, xKey, rtl::OUString() );
+    return loadSharedLibComponentFactory( uri, rPath, rImplName, xMgr, xKey, rtl::OUString() );
 }
 
 namespace
@@ -194,7 +134,6 @@ Reference< XInterface > invokeComponentFactory(
     OUString const & rModulePath,
     OUString const & rImplName,
     Reference< ::com::sun::star::lang::XMultiServiceFactory > const & xMgr,
-    Reference< ::com::sun::star::registry::XRegistryKey > const & xKey,
     OUString const & rPrefix,
     OUString &rExcMsg )
 {
@@ -244,18 +183,11 @@ Reference< XInterface > invokeComponentFactory(
         {
             void * pSMgr = aCurrent2Env.mapInterface(
                 xMgr.get(), ::getCppuType( &xMgr ) );
-            void * pKey = aCurrent2Env.mapInterface(
-                xKey.get(), ::getCppuType( &xKey ) );
 
             void * pSSF = NULL;
 
-            env.invoke(s_getFactory, pGetter, &aImplName, pSMgr, pKey, &pSSF);
+            env.invoke(s_getFactory, pGetter, &aImplName, pSMgr, 0, &pSSF);
 
-            if (pKey)
-            {
-                (env.get()->pExtEnv->releaseInterface)(
-                    env.get()->pExtEnv, pKey );
-            }
             if (pSMgr)
             {
                 (*env.get()->pExtEnv->releaseInterface)(
@@ -325,35 +257,34 @@ extern "C"
 #endif
 
 Reference< XInterface > SAL_CALL loadSharedLibComponentFactory(
-    OUString const & rLibName, OUString const & rPath,
-    OUString const & rImplName,
+    OUString const & uri, OUString const & rPath, OUString const & rImplName,
     Reference< lang::XMultiServiceFactory > const & xMgr,
     Reference< registry::XRegistryKey > const & xKey,
     OUString const & rPrefix )
     SAL_THROW( (loader::CannotActivateFactoryException) )
 {
+    assert(rPath.isEmpty());
+    assert(!xKey.is());
 #ifndef DISABLE_DYNLOADING
-    OUString sLibName(rLibName);
+    OUString moduleUri(uri);
 
 #ifdef ANDROID
-    if ( rLibName.equals( "bootstrap.uno" SAL_DLLEXTENSION ) )
-        sLibName = "libbootstrap.uno" SAL_DLLEXTENSION;
+    if ( uri == "bootstrap.uno" SAL_DLLEXTENSION )
+        moduleUri = "libbootstrap.uno" SAL_DLLEXTENSION;
 #endif
 
-    OUString aModulePath( makeComponentPath( sLibName, rPath ) );
     oslModule lib = osl_loadModule(
-        aModulePath.pData, SAL_LOADMODULE_LAZY | SAL_LOADMODULE_GLOBAL );
+        moduleUri.pData, SAL_LOADMODULE_LAZY | SAL_LOADMODULE_GLOBAL );
     if (! lib)
     {
-        OUString const msg("loading component library failed: " + aModulePath);
+        OUString const msg("loading component library failed: " + moduleUri);
         SAL_WARN("cppuhelper", msg);
         throw loader::CannotActivateFactoryException(msg,
             Reference< XInterface >() );
     }
 #else
-    (void) rPath;
     oslModule lib;
-    OUString aModulePath("MAIN");
+    OUString moduleUri("MAIN");
     if (! osl_getModuleHandle( NULL, &lib))
     {
         throw loader::CannotActivateFactoryException(
@@ -407,7 +338,7 @@ Reference< XInterface > SAL_CALL loadSharedLibComponentFactory(
     };
     for (int i = 0; pSym == NULL && non_app_specific_map[i].lib != NULL; ++i)
     {
-        if ( rLibName.equalsAscii( non_app_specific_map[i].lib ) )
+        if ( uri.equalsAscii( non_app_specific_map[i].lib ) )
             pSym = (oslGenericFunction) non_app_specific_map[i].component_getFactory_function;
     }
 
@@ -417,12 +348,12 @@ Reference< XInterface > SAL_CALL loadSharedLibComponentFactory(
         const lib_to_component_mapping *map = lo_get_libmap();
         for (int i = 0; pSym == NULL && map[i].lib != NULL; ++i)
         {
-            if ( rLibName.equalsAscii( map[i].lib ) )
+            if ( uri.equalsAscii( map[i].lib ) )
                 pSym = (oslGenericFunction) map[i].component_getFactory_function;
         }
         if ( pSym == NULL )
         {
-            fprintf( stderr, "attempting to load unknown library %s\n", OUStringToOString( rLibName, RTL_TEXTENCODING_ASCII_US ).getStr() );
+            fprintf( stderr, "attempting to load unknown library %s\n", OUStringToOString( uri, RTL_TEXTENCODING_ASCII_US ).getStr() );
             assert( !"Attempt to load unknown library" );
         }
     }
@@ -434,11 +365,11 @@ Reference< XInterface > SAL_CALL loadSharedLibComponentFactory(
 
     if (pSym != 0)
     {
-        xRet = invokeComponentFactory( pSym, lib, aModulePath, rImplName, xMgr, xKey, rPrefix, aExcMsg );
+        xRet = invokeComponentFactory( pSym, lib, moduleUri, rImplName, xMgr, rPrefix, aExcMsg );
     }
     else
     {
-        aExcMsg = aModulePath;
+        aExcMsg = moduleUri;
         aExcMsg += ": cannot get symbol: ";
         aExcMsg += aGetFactoryName;
     }
@@ -471,17 +402,17 @@ extern "C" { static void s_writeInfo(va_list * pParam)
 }}
 
 void SAL_CALL writeSharedLibComponentInfo(
-    OUString const & rLibName, OUString const & rPath,
+    OUString const & uri, OUString const & rPath,
     Reference< lang::XMultiServiceFactory > const & xMgr,
     Reference< registry::XRegistryKey > const & xKey )
     SAL_THROW( (registry::CannotRegisterImplementationException) )
 {
-    OUString aModulePath( makeComponentPath( rLibName, rPath ) );
+    assert(rPath.isEmpty());
     oslModule lib = osl_loadModule(
-        aModulePath.pData, SAL_LOADMODULE_LAZY | SAL_LOADMODULE_GLOBAL );
+        uri.pData, SAL_LOADMODULE_LAZY | SAL_LOADMODULE_GLOBAL );
     if (! lib)
     {
-        OUString const msg("loading component library failed: " + aModulePath);
+        OUString const msg("loading component library failed: " + uri);
         SAL_WARN("cppuhelper", msg);
         throw registry::CannotRegisterImplementationException(msg,
             Reference< XInterface >() );
@@ -522,7 +453,7 @@ void SAL_CALL writeSharedLibComponentInfo(
                         env.get()->pExtEnv, pKey );
                     if (! bRet)
                     {
-                        aExcMsg = aModulePath;
+                        aExcMsg = uri;
                         aExcMsg += ": component_writeInfo() "
                                    "returned false!";
                     }
@@ -530,7 +461,7 @@ void SAL_CALL writeSharedLibComponentInfo(
                 else
                 {
                     // key is mandatory
-                    aExcMsg = aModulePath;
+                    aExcMsg = uri;
                     aExcMsg += ": registry is mandatory to invoke"
                                " component_writeInfo()!";
                 }
@@ -553,7 +484,7 @@ void SAL_CALL writeSharedLibComponentInfo(
     }
     else
     {
-        aExcMsg = aModulePath;
+        aExcMsg = uri;
         aExcMsg += ": cannot get symbol: ";
         aExcMsg += aWriteInfoName;
     }
diff --git a/include/cppuhelper/shlib.hxx b/include/cppuhelper/shlib.hxx
index baf3a8d..bb6d4ed 100644
--- a/include/cppuhelper/shlib.hxx
+++ b/include/cppuhelper/shlib.hxx
@@ -31,21 +31,20 @@ namespace cppu
 
 /** Loads a shared library component and gets the factory out of it.  You can give either a
     fully qualified libname or single lib name.  The libname need not be pre/postfixed
-    (e.g. xxx.dll).  You can give parameter rPath to force lookup of the library in a specific
-    directory.
+    (e.g. xxx.dll).
 
-    @param rLibName name of the library
-    @param rPath optional path
+    @param uri URI of the library
+    @param rPath deprecated, must be empty
     @param rImplName implementation to be retrieved from the library
     @param xMgr service manager to be provided to the component
-    @param xKey registry key to be provided to the component
+    @param xKey deprecated, must be null
     @return
     factory instance (com::sun::star::lang::XSingleComponentFactory or legacy
     com::sun::star::lang::XSingleServiceFactory)
 */
 CPPUHELPER_DLLPUBLIC ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >
 SAL_CALL loadSharedLibComponentFactory(
-    ::rtl::OUString const & rLibName, ::rtl::OUString const & rPath,
+    ::rtl::OUString const & uri, ::rtl::OUString const & rPath,
     ::rtl::OUString const & rImplName,
     ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > const & xMgr,
     ::com::sun::star::uno::Reference< ::com::sun::star::registry::XRegistryKey > const & xKey )
@@ -53,15 +52,14 @@ SAL_CALL loadSharedLibComponentFactory(
 
 /** Loads a shared library component and gets the factory out of it.  You can give either a
     fully qualified libname or single lib name.  The libname need not be pre/postfixed
-    (e.g. xxx.dll).  You can give parameter rPath to force lookup of the library in a specific
-    directory.  An optional 'prefix' parameter is used to determine the symbol
+    (e.g. xxx.dll).  An optional 'prefix' parameter is used to determine the symbol
     name of the entry point in the library.
 
-    @param rLibName name of the library
-    @param rPath optional path
+    @param uri URI of the library
+    @param rPath deprecated, must be empty
     @param rImplName implementation to be retrieved from the library
     @param xMgr service manager to be provided to the component
-    @param xKey registry key to be provided to the component
+    @param xKey deprecated, must be null
     @param rPrefix optional component prefix
     @return
     factory instance (com::sun::star::lang::XSingleComponentFactory or legacy
@@ -69,7 +67,7 @@ SAL_CALL loadSharedLibComponentFactory(
 */
 CPPUHELPER_DLLPUBLIC ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >
 SAL_CALL loadSharedLibComponentFactory(
-    ::rtl::OUString const & rLibName, ::rtl::OUString const & rPath,
+    ::rtl::OUString const & uri, ::rtl::OUString const & rPath,
     ::rtl::OUString const & rImplName,
     ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > const & xMgr,
     ::com::sun::star::uno::Reference< ::com::sun::star::registry::XRegistryKey > const & xKey,
@@ -78,19 +76,18 @@ SAL_CALL loadSharedLibComponentFactory(
 
 /** Invokes component_writeInfo() function of specified component library.  You can give either
     a fully qualified libname or single lib name. The libname need not be pre/postfixed
-    (e.g. xxx.dll).  You can give parameter rPath to force lookup of the library in a specific
-    directory.
+    (e.g. xxx.dll).
 
     @deprecated component_writeInfo should no longer be used in new components
 
-    @param rLibName name of the library
-    @param rPath optional path
+    @param uri URI of the library
+    @param rPath deprecated, must be empty
     @param xMgr service manager to be provided to the component
     @param xKey registry key to be provided to the component
 */
 CPPUHELPER_DLLPUBLIC void
 SAL_CALL writeSharedLibComponentInfo(
-    ::rtl::OUString const & rLibName, ::rtl::OUString const & rPath,
+    ::rtl::OUString const & uri, ::rtl::OUString const & rPath,
     ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > const & xMgr,
     ::com::sun::star::uno::Reference< ::com::sun::star::registry::XRegistryKey > const & xKey )
     SAL_THROW( (::com::sun::star::registry::CannotRegisterImplementationException) );
diff --git a/stoc/source/loader/dllcomponentloader.cxx b/stoc/source/loader/dllcomponentloader.cxx
index 0b22987..854487d 100644
--- a/stoc/source/loader/dllcomponentloader.cxx
+++ b/stoc/source/loader/dllcomponentloader.cxx
@@ -185,7 +185,7 @@ Reference<XInterface> SAL_CALL DllComponentLoader::activate(
 
     return loadSharedLibComponentFactory(
         cppu::bootstrap_expandUri(rLibName), OUString(), rImplName, m_xSMgr,
-        xKey, aPrefix );
+        css::uno::Reference<css::registry::XRegistryKey>(), aPrefix );
 }
 
 
commit 02a872cb2cb68338a9459dd7d922001ee6c9a343
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Tue Oct 1 01:09:41 2013 +0200

    Remove odd "bootstrapping" of acceptor/connector/binaryurp components
    
    ...that had effectively been in uno.exe since
    c460c0ccb6f389339b2ff9e57a101557c30df676 "initial import," for whatever reason
    it was supposed to be good for, but would no longer work anyway at least since
    644c33a857c46d540202189228f519946dc33833 "fdo#67313: Use "lo" suffix for private
    URE libs."
    
    Change-Id: I98c038a4d9d963eefc542c91247cf263d7d988bb

diff --git a/cpputools/source/unoexe/unoexe.cxx b/cpputools/source/unoexe/unoexe.cxx
index cb345ca..1a7ace1 100644
--- a/cpputools/source/unoexe/unoexe.cxx
+++ b/cpputools/source/unoexe/unoexe.cxx
@@ -30,7 +30,6 @@
 #include <rtl/ustrbuf.hxx>
 
 #include <cppuhelper/bootstrap.hxx>
-#include <cppuhelper/shlib.hxx>
 #include <cppuhelper/implbase1.hxx>
 
 #include <com/sun/star/lang/XMain.hpp>
@@ -38,9 +37,7 @@
 #include <com/sun/star/lang/XComponent.hpp>
 #include <com/sun/star/lang/XSingleComponentFactory.hpp>
 #include <com/sun/star/lang/XSingleServiceFactory.hpp>
-#include <com/sun/star/lang/XMultiServiceFactory.hpp>
 #include <com/sun/star/lang/XEventListener.hpp>
-#include <com/sun/star/container/XSet.hpp>
 #include <com/sun/star/loader/XImplementationLoader.hpp>
 #include <com/sun/star/registry/XRegistryKey.hpp>
 #include <com/sun/star/connection/Acceptor.hpp>
@@ -175,46 +172,6 @@ void createInstance(
 
     if (! x.is())
     {
-        static sal_Bool s_bSet = sal_False;
-        if (! s_bSet)
-        {
-            MutexGuard aGuard( Mutex::getGlobalMutex() );
-            if (! s_bSet)
-            {
-                Reference< XSet > xSet( xMgr, UNO_QUERY );
-                if (xSet.is())
-                {
-                    Reference< XMultiServiceFactory > xSF( xMgr, UNO_QUERY );
-                    // acceptor
-                    xSet->insert( makeAny( loadSharedLibComponentFactory(
-                        OUString( "acceptor.uno" SAL_DLLEXTENSION ),
-                        OUString(),
-                        OUString( "com.sun.star.comp.io.Acceptor" ),
-                        xSF, Reference< XRegistryKey >(),
-                        "acceptor_" ) ) );
-                    // connector
-                    xSet->insert( makeAny( loadSharedLibComponentFactory(
-                        OUString( "connector.uno" SAL_DLLEXTENSION ),
-                        OUString(),
-                        OUString( "com.sun.star.comp.io.Connector" ),
-                        xSF, Reference< XRegistryKey >(),
-                        "connector_" ) ) );
-                    // bridge factory
-                    xSet->insert( makeAny( loadSharedLibComponentFactory(
-                        OUString( "binaryurp.uno" SAL_DLLEXTENSION ),
-                        OUString(),
-                        OUString( "com.sun.star.comp.bridge.BridgeFactory" ),
-                        xSF, Reference< XRegistryKey >(),
-                        "binaryurp_" ) ) );
-                }
-                s_bSet = sal_True;
-            }
-        }
-        x = xMgr->createInstanceWithContext( rServiceName, xContext );
-    }
-
-    if (! x.is())
-    {
         OUStringBuffer buf( 64 );
         buf.appendAscii( RTL_CONSTASCII_STRINGPARAM("cannot get service instance \"") );
         buf.append( rServiceName );
commit f3010323077228e282509924d8bab29b35fd21f0
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Tue Oct 1 00:39:34 2013 +0200

    IllegalArgumentException is a RuntimeException now
    
    Change-Id: I929da9300cc02da114907841ad8805d1227f3f79

diff --git a/stoc/source/loader/dllcomponentloader.cxx b/stoc/source/loader/dllcomponentloader.cxx
index 5e65c20..0b22987 100644
--- a/stoc/source/loader/dllcomponentloader.cxx
+++ b/stoc/source/loader/dllcomponentloader.cxx
@@ -36,7 +36,6 @@
 #include <cppuhelper/bootstrap.hxx>
 
 #include <com/sun/star/loader/XImplementationLoader.hpp>
-#include <com/sun/star/lang/IllegalArgumentException.hpp>
 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
 #include <com/sun/star/lang/XServiceInfo.hpp>
 #include <com/sun/star/lang/XInitialization.hpp>
@@ -96,9 +95,6 @@ public:
     virtual sal_Bool SAL_CALL writeRegistryInfo( const Reference<XRegistryKey>& xKey, const OUString& implementationLoaderUrl, const OUString& locationUrl ) throw(CannotRegisterImplementationException, RuntimeException);
 
 private:
-    OUString expand_url( OUString const & url )
-        SAL_THROW( (RuntimeException) );
-
     Reference<XMultiServiceFactory> m_xSMgr;
 };
 
@@ -162,20 +158,6 @@ void DllComponentLoader::initialize( const ::com::sun::star::uno::Sequence< ::co
 //      m_xSMgr = rServiceManager;
 }
 
-//==================================================================================================
-OUString DllComponentLoader::expand_url( OUString const & url )
-    SAL_THROW( (RuntimeException) )
-{
-    try
-    {
-        return cppu::bootstrap_expandUri( url );
-    }
-    catch ( const IllegalArgumentException & e )
-    {
-        throw RuntimeException( e.Message, e.Context );
-    }
-}
-
 //*************************************************************************
 Reference<XInterface> SAL_CALL DllComponentLoader::activate(
     const OUString & rImplName, const OUString &, const OUString & rLibName,
@@ -202,7 +184,8 @@ Reference<XInterface> SAL_CALL DllComponentLoader::activate(
     }
 
     return loadSharedLibComponentFactory(
-        expand_url( rLibName ), OUString(), rImplName, m_xSMgr, xKey, aPrefix );
+        cppu::bootstrap_expandUri(rLibName), OUString(), rImplName, m_xSMgr,
+        xKey, aPrefix );
 }
 
 
@@ -219,7 +202,7 @@ sal_Bool SAL_CALL DllComponentLoader::writeRegistryInfo(
     return sal_False;
 #else
     writeSharedLibComponentInfo(
-        expand_url( rLibName ), OUString(), m_xSMgr, xKey );
+        cppu::bootstrap_expandUri(rLibName), OUString(), m_xSMgr, xKey );
     return sal_True;
 #endif
 }
commit c91f5851d0412cbf8fbe1b3d8da0048241aaba09
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Tue Oct 1 00:08:26 2013 +0200

    [API CHANGE] Remove unused cppu::invokeStaticComponentFactory again
    
    ...that has neither been intended for external use anyway, nor has it ever been
    used internally since its dead-on-arrival inception in
    b16ab7a751c04049b4171df412f1ef0f4f9b02f2 "Add invokeStaticComponentFactory() for
    statically linked components: Will be used for iOS at least."  Sigh.
    
    Change-Id: I17795b2a1945809688deba0a5492415fbe877400

diff --git a/cppuhelper/source/compat.cxx b/cppuhelper/source/compat.cxx
index 3047c11..c507540 100644
--- a/cppuhelper/source/compat.cxx
+++ b/cppuhelper/source/compat.cxx
@@ -21,9 +21,11 @@
 
 #include <cstdlib>
 
+#include "com/sun/star/loader/CannotActivateFactoryException.hpp"
 #include "com/sun/star/uno/Exception.hpp"
 #include "com/sun/star/uno/Reference.hxx"
 #include "com/sun/star/uno/Sequence.hxx"
+#include "osl/module.h"
 #include "sal/types.h"
 
 namespace com { namespace sun { namespace star {
@@ -32,8 +34,14 @@ namespace com { namespace sun { namespace star {
         class XMultiServiceFactory;
     }
     namespace reflection { class XIdlClass; }
-    namespace registry { class XSimpleRegistry; }
-    namespace uno { class XComponentContext; }
+    namespace registry {
+        class XRegistryKey;
+        class XSimpleRegistry;
+    }
+    namespace uno {
+        class XComponentContext;
+        class XInterface;
+    }
 } } }
 namespace rtl { class OUString; }
 
@@ -84,6 +92,17 @@ createStandardClassWithSequence(
     for (;;) { std::abort(); } // avoid "must return a value" warnings
 }
 
+SAL_DLLPUBLIC_EXPORT css::uno::Reference<css::uno::XInterface> SAL_CALL
+invokeStaticComponentFactory(
+    oslGenericFunction, rtl::OUString const &,
+    css::uno::Reference<css::lang::XMultiServiceFactory> const &,
+    css::uno::Reference<css::registry::XRegistryKey> const &,
+    rtl::OUString const &)
+    SAL_THROW((css::loader::CannotActivateFactoryException))
+{
+    for (;;) { std::abort(); } // avoid "must return a value" warnings
+}
+
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/cppuhelper/source/shlib.cxx b/cppuhelper/source/shlib.cxx
index 2887e6f..00c21d2 100644
--- a/cppuhelper/source/shlib.cxx
+++ b/cppuhelper/source/shlib.cxx
@@ -456,33 +456,6 @@ Reference< XInterface > SAL_CALL loadSharedLibComponentFactory(
     return xRet;
 }
 
-Reference< XInterface > SAL_CALL invokeStaticComponentFactory(
-    oslGenericFunction pGetter,
-    OUString const & rImplName,
-    Reference< ::com::sun::star::lang::XMultiServiceFactory > const & xMgr,
-    Reference< ::com::sun::star::registry::XRegistryKey > const & xKey,
-    OUString const & rPrefix )
-    SAL_THROW( (::com::sun::star::loader::CannotActivateFactoryException) )
-{
-    Reference< XInterface > xRet;
-    oslModule pExe;
-    OUString aExePath("MAIN");
-    osl_getModuleHandle( NULL, &pExe );
-    OUString aExcMsg;
-
-    xRet = invokeComponentFactory( pGetter, pExe, aExePath, rImplName, xMgr, xKey, rPrefix, aExcMsg );
-
-    if (! xRet.is())
-    {
-        SAL_WARN("cppuhelper", "### cannot activate factory: " << aExcMsg);
-        throw loader::CannotActivateFactoryException(
-            aExcMsg,
-            Reference< XInterface >() );
-    }
-
-    return xRet;
-}
-
 #ifndef DISABLE_DYNLOADING
 
 //==============================================================================
diff --git a/include/cppuhelper/shlib.hxx b/include/cppuhelper/shlib.hxx
index 9e78c41..baf3a8d 100644
--- a/include/cppuhelper/shlib.hxx
+++ b/include/cppuhelper/shlib.hxx
@@ -19,7 +19,6 @@
 #ifndef _CPPUHELPER_SHLIB_HXX_
 #define _CPPUHELPER_SHLIB_HXX_
 
-#include <osl/module.hxx>
 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
 #include <com/sun/star/registry/XRegistryKey.hpp>
 #include <com/sun/star/loader/CannotActivateFactoryException.hpp>
@@ -77,26 +76,6 @@ SAL_CALL loadSharedLibComponentFactory(
     ::rtl::OUString const & rPrefix )
     SAL_THROW( (::com::sun::star::loader::CannotActivateFactoryException) );
 
-/** Gets the factory out of an already loaded (for instance statically linked) component.
-
-    @param pGetter the component's component_getFactory function
-    @param rImplName implementation to be retrieved from the library
-    @param xMgr service manager to be provided to the component
-    @param xKey registry key to be provided to the component
-    @param rPrefix optional component prefix
-    @return
-    factory instance (com::sun::star::lang::XSingleComponentFactory or legacy
-    com::sun::star::lang::XSingleServiceFactory)
-*/
-CPPUHELPER_DLLPUBLIC ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >
-SAL_CALL invokeStaticComponentFactory(
-    oslGenericFunction pGetter,
-    ::rtl::OUString const & rImplName,
-    ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > const & xMgr,
-    ::com::sun::star::uno::Reference< ::com::sun::star::registry::XRegistryKey > const & xKey,
-    ::rtl::OUString const & rPrefix )
-    SAL_THROW( (::com::sun::star::loader::CannotActivateFactoryException) );
-
 /** Invokes component_writeInfo() function of specified component library.  You can give either
     a fully qualified libname or single lib name. The libname need not be pre/postfixed
     (e.g. xxx.dll).  You can give parameter rPath to force lookup of the library in a specific
commit 69f1846f4095a9dc607a0e568980d8625d657c94
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Tue Oct 1 00:07:23 2013 +0200

    All the content of cppuhelper/source/compat.cxx must be in namespace cppu
    
    Change-Id: I30dde10d1c299dbd9c0b2cb2fa025ce432df6cce

diff --git a/cppuhelper/source/compat.cxx b/cppuhelper/source/compat.cxx
index ab57a2a..3047c11 100644
--- a/cppuhelper/source/compat.cxx
+++ b/cppuhelper/source/compat.cxx
@@ -48,8 +48,6 @@ css::uno::Reference< css::lang::XMultiComponentFactory > bootstrapInitialSF(
     for (;;) { std::abort(); } // avoid "must return a value" warnings
 }
 
-}
-
 SAL_DLLPUBLIC_EXPORT css::uno::Reference< css::uno::XComponentContext > SAL_CALL
 bootstrap_InitialComponentContext(
     css::uno::Reference< css::registry::XSimpleRegistry > const &,
@@ -86,4 +84,6 @@ createStandardClassWithSequence(
     for (;;) { std::abort(); } // avoid "must return a value" warnings
 }
 
+}
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
commit fc71ed951f646d5c686cfc3615b5b967cbe12612
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Mon Sep 30 23:31:15 2013 +0200

    Fix comments
    
    Change-Id: Ia5bc8b0dec8cecdec06a71377ac5cd3a52109955

diff --git a/include/cppuhelper/shlib.hxx b/include/cppuhelper/shlib.hxx
index dcdf148..9e78c41 100644
--- a/include/cppuhelper/shlib.hxx
+++ b/include/cppuhelper/shlib.hxx
@@ -30,13 +30,6 @@
 namespace cppu
 {
 
-// Note the pointless redundancy
-// "::com::sun::star::lang::XSingleComponentFactory or
-// ::com::sun::star::lang::XSingleComponentFactory" in the doc
-// comments below. Whether the documentation is supposed to mean only
-// XSingleComponentFactory, or whether the other one should be
-// something else, I don't know.
-
 /** Loads a shared library component and gets the factory out of it.  You can give either a
     fully qualified libname or single lib name.  The libname need not be pre/postfixed
     (e.g. xxx.dll).  You can give parameter rPath to force lookup of the library in a specific
@@ -48,8 +41,8 @@ namespace cppu
     @param xMgr service manager to be provided to the component
     @param xKey registry key to be provided to the component
     @return
-    factory instance (com::sun::star::lang::XSingleComponentFactory or
-    com::sun::star::lang::XSingleComponentFactory)
+    factory instance (com::sun::star::lang::XSingleComponentFactory or legacy
+    com::sun::star::lang::XSingleServiceFactory)
 */
 CPPUHELPER_DLLPUBLIC ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >
 SAL_CALL loadSharedLibComponentFactory(
@@ -72,8 +65,8 @@ SAL_CALL loadSharedLibComponentFactory(
     @param xKey registry key to be provided to the component
     @param rPrefix optional component prefix
     @return
-    factory instance (com::sun::star::lang::XSingleComponentFactory or
-    com::sun::star::lang::XSingleComponentFactory)
+    factory instance (com::sun::star::lang::XSingleComponentFactory or legacy
+    com::sun::star::lang::XSingleServiceFactory)
 */
 CPPUHELPER_DLLPUBLIC ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >
 SAL_CALL loadSharedLibComponentFactory(
@@ -92,8 +85,8 @@ SAL_CALL loadSharedLibComponentFactory(
     @param xKey registry key to be provided to the component
     @param rPrefix optional component prefix
     @return
-    factory instance (com::sun::star::lang::XSingleComponentFactory or
-    com::sun::star::lang::XSingleComponentFactory)
+    factory instance (com::sun::star::lang::XSingleComponentFactory or legacy
+    com::sun::star::lang::XSingleServiceFactory)
 */
 CPPUHELPER_DLLPUBLIC ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >
 SAL_CALL invokeStaticComponentFactory(
commit 3fb51feb1c0a5b62dc55c76d0037564f42366226
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Mon Sep 30 23:15:18 2013 +0200

    [API CHANGE] Remove unused CPLD_ACCESS feature from C++/Java component loaders
    
    ...introduced in 2000 with 38974aeef6dfaa1c625cf5498ec553489dd08c87 "added
    library loading limitation by using env variable CPLD_ACCESSPATH=path1;path2;
    etc." and 9be3c618e0b1d2b2635bd7b134693ed5ff3021bc "#80090# restrict jar file
    access to java system property com.sun.star.comp.loader.CPLD_ACCESSPATH" but
    already in 2004 considered "a hack [that] seems to be unused nowadays" in
    1d3164df959b31ba9f50ddc108569f3adec32ff7 "CWS sb20: #i29119# Replaced
    sandbox.jar-based class loader with an own one."
    
    Change-Id: I637afd5daeb4ca097edd17f834c81af892dcfc6a

diff --git a/cppuhelper/source/shlib.cxx b/cppuhelper/source/shlib.cxx
index 0933ddb..2887e6f 100644
--- a/cppuhelper/source/shlib.cxx
+++ b/cppuhelper/source/shlib.cxx
@@ -17,14 +17,13 @@
  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
  */
 
-#include <config_features.h>
+#include "sal/config.h"
 
 #include "osl/diagnose.h"
 #include "osl/file.hxx"
 #include "osl/mutex.hxx"
 #include "osl/module.hxx"
 #include "rtl/ustrbuf.hxx"
-#include "rtl/instance.hxx"
 #include "uno/environment.h"
 #include "uno/mapping.hxx"
 #include "cppuhelper/factory.hxx"
@@ -33,7 +32,6 @@
 #include "com/sun/star/beans/XPropertySet.hpp"
 
 #include <stdio.h>
-#include <vector>
 
 #ifdef ANDROID
 #include <osl/detail/android-bootstrap.h>
@@ -54,155 +52,8 @@ using rtl::OUStringBuffer;
 namespace cppu
 {
 
-#if OSL_DEBUG_LEVEL > 1
-//------------------------------------------------------------------------------
-static inline void out( const char * p ) SAL_THROW(())
-{
-    printf( "%s\n", p );
-}
-static inline void out( const OUString & r ) throw ()
-{
-    OString s( OUStringToOString( r, RTL_TEXTENCODING_ASCII_US ) );
-    out( s.getStr() );
-}
-#endif
-
-namespace
-{
-    class buildAccessDPath
-    {
-    private:
-        ::std::vector< OUString > m_aAccessDPath;
-        bool m_bCPLD_ACCESSPATHSet;
-    public:
-        buildAccessDPath() : m_bCPLD_ACCESSPATHSet(false)
-        {
-            const char * pEnv = ::getenv( "CPLD_ACCESSPATH" );
-            if (pEnv)
-            {
-                m_bCPLD_ACCESSPATHSet = true;
-
-                OString aEnv( pEnv );
-                sal_Int32 nIndex = 0;
-                do
-                {
-                    OUString aStr( OStringToOUString(
-                        aEnv.getToken( 0, ';', nIndex ),
-                        RTL_TEXTENCODING_ASCII_US ) );
-                    OUString aFileUrl;
-                    if (FileBase::getFileURLFromSystemPath(aStr, aFileUrl)
-                        != FileBase::E_None)
-                    {
-                        OSL_ASSERT(false);
-                    }
-                    m_aAccessDPath.push_back( aFileUrl );
-                } while( nIndex != -1 );
-    #if OSL_DEBUG_LEVEL > 1
-                out( "> cpld: acknowledged following access path(s): \"" );
-                ::std::vector< OUString >::const_iterator iPos( m_aAccessDPath.begin() );
-                while (iPos != m_aAccessDPath.end())
-                {
-                    out( *iPos );
-                    ++iPos;
-                    if (iPos != m_aAccessDPath.end())
-                        out( ";" );
-                }
-                out( "\"\n" );
-    #endif
-            }
-            else
-            {
-                // no access path env set
-    #if OSL_DEBUG_LEVEL > 1
-                out( "=> no CPLD_ACCESSPATH set.\n" );
-    #endif
-            }
-        }
-        ::std::vector< OUString >* getAccessDPath() { return m_bCPLD_ACCESSPATHSet ? &m_aAccessDPath : NULL; }
-    };
-
-    class theAccessDPath : public rtl::Static<buildAccessDPath, theAccessDPath> {};
-}
-
 #ifndef DISABLE_DYNLOADING
 
-static const ::std::vector< OUString > * getAccessDPath() SAL_THROW(())
-{
-    return theAccessDPath::get().getAccessDPath();
-}
-
-//------------------------------------------------------------------------------
-static bool checkAccessPath( OUString * pComp ) throw ()
-{
-    const ::std::vector< OUString > * pPath = getAccessDPath();
-
-    if (pPath)
-    {
-        sal_Bool bAbsolute = pComp->startsWith( "file://" );
-        for ( ::std::vector< OUString >::const_iterator iPos( pPath->begin() );
-              iPos != pPath->end(); ++iPos )
-        {
-            OUString aBaseDir( *iPos );
-            OUString aAbs;
-
-            if ( bAbsolute )
-            {
-                aAbs = *pComp;
-#if OSL_DEBUG_LEVEL > 1
-                out( "> taking path: \"" );
-                out( aAbs );
-#endif
-            }
-            else
-            {
-                if (osl_File_E_None !=
-                    ::osl_getAbsoluteFileURL(
-                        aBaseDir.pData, pComp->pData, &aAbs.pData ))
-                {
-                    continue;
-                }
-#if OSL_DEBUG_LEVEL > 1
-                out( "> found path: \"" );
-                out( aBaseDir );
-                out( "\" + \"" );
-                out( *pComp );
-                out( "\" => \"" );
-                out( aAbs );
-#endif
-            }
-
-            if (0 == aAbs.indexOf( aBaseDir ) && // still part of it?
-                aBaseDir.getLength() < aAbs.getLength() &&
-                (aBaseDir[ aBaseDir.getLength() -1 ] == (sal_Unicode)'/' ||
-                 // dir boundary
-                 aAbs[ aBaseDir.getLength() ] == (sal_Unicode)'/'))
-            {
-#if OSL_DEBUG_LEVEL > 1
-                out( ": ok.\n" );
-#endif
-                // load from absolute path
-                *pComp = aAbs;
-                return true;
-            }
-#if OSL_DEBUG_LEVEL > 1
-            else
-            {
-                out( "\" ...does not match given path \"" );
-                out( aBaseDir );
-                out( "\".\n" );
-            }
-#endif
-        }
-        return false;
-    }
-    else
-    {
-        // no access path env set
-        return true;
-    }
-}
-
-//------------------------------------------------------------------------------
 static OUString makeComponentPath(
     const OUString & rLibName, const OUString & rPath )
 {
@@ -490,15 +341,6 @@ Reference< XInterface > SAL_CALL loadSharedLibComponentFactory(
 #endif
 
     OUString aModulePath( makeComponentPath( sLibName, rPath ) );
-    if (! checkAccessPath( &aModulePath ))
-    {
-        OUString const msg(
-                "permission denied to load component library: " + aModulePath);
-        SAL_WARN("cppuhelper", msg);
-        throw loader::CannotActivateFactoryException(msg,
-            Reference< XInterface >() );
-    }
-
     oslModule lib = osl_loadModule(
         aModulePath.pData, SAL_LOADMODULE_LAZY | SAL_LOADMODULE_GLOBAL );
     if (! lib)
@@ -662,16 +504,6 @@ void SAL_CALL writeSharedLibComponentInfo(
     SAL_THROW( (registry::CannotRegisterImplementationException) )
 {
     OUString aModulePath( makeComponentPath( rLibName, rPath ) );
-
-    if (! checkAccessPath( &aModulePath ))
-    {
-        OUString const msg(
-                "permission denied to load component library: " + aModulePath);
-        SAL_WARN("cppuhelper", msg);
-        throw registry::CannotRegisterImplementationException(msg,
-            Reference< XInterface >() );
-    }
-
     oslModule lib = osl_loadModule(
         aModulePath.pData, SAL_LOADMODULE_LAZY | SAL_LOADMODULE_GLOBAL );
     if (! lib)
diff --git a/include/cppuhelper/shlib.hxx b/include/cppuhelper/shlib.hxx
index 666359f..dcdf148 100644
--- a/include/cppuhelper/shlib.hxx
+++ b/include/cppuhelper/shlib.hxx
@@ -40,8 +40,7 @@ namespace cppu
 /** Loads a shared library component and gets the factory out of it.  You can give either a
     fully qualified libname or single lib name.  The libname need not be pre/postfixed
     (e.g. xxx.dll).  You can give parameter rPath to force lookup of the library in a specific
-    directory.  The resulting path of the library will be checked against environment variable
-    CPLD_ACCESSPATH if set.
+    directory.
 
     @param rLibName name of the library
     @param rPath optional path
@@ -63,8 +62,7 @@ SAL_CALL loadSharedLibComponentFactory(
 /** Loads a shared library component and gets the factory out of it.  You can give either a
     fully qualified libname or single lib name.  The libname need not be pre/postfixed
     (e.g. xxx.dll).  You can give parameter rPath to force lookup of the library in a specific
-    directory.  The resulting path of the library will be checked against environment variable
-    CPLD_ACCESSPATH if set. An optional 'prefix' parameter is used to determine the symbol
+    directory.  An optional 'prefix' parameter is used to determine the symbol
     name of the entry point in the library.
 
     @param rLibName name of the library
@@ -109,8 +107,7 @@ SAL_CALL invokeStaticComponentFactory(
 /** Invokes component_writeInfo() function of specified component library.  You can give either
     a fully qualified libname or single lib name. The libname need not be pre/postfixed
     (e.g. xxx.dll).  You can give parameter rPath to force lookup of the library in a specific
-    directory.  The resulting path of the library will be checked against environment variable
-    CPLD_ACCESSPATH if set.
+    directory.
 
     @deprecated component_writeInfo should no longer be used in new components
 
diff --git a/jurt/com/sun/star/comp/loader/RegistrationClassFinder.java b/jurt/com/sun/star/comp/loader/RegistrationClassFinder.java
index aef6724..8351316 100644
--- a/jurt/com/sun/star/comp/loader/RegistrationClassFinder.java
+++ b/jurt/com/sun/star/comp/loader/RegistrationClassFinder.java
@@ -20,11 +20,9 @@ package com.sun.star.comp.loader;
 
 import com.sun.star.lib.unoloader.UnoClassLoader;
 import com.sun.star.lib.util.WeakMap;
-import java.io.File;
 import java.io.IOException;
 import java.net.URL;
 import java.net.URLClassLoader;
-import java.util.StringTokenizer;
 import java.util.jar.Attributes;
 
 final class RegistrationClassFinder {
@@ -38,7 +36,6 @@ final class RegistrationClassFinder {
             }
         }
         URL url = new URL(locationUrl);
-        checkAccess(url);
         Attributes attr = UnoClassLoader.getJarMainAttributes(url);
         String name = attr == null
             ? null : attr.getValue("RegistrationClassName");
@@ -65,60 +62,5 @@ final class RegistrationClassFinder {
 
     private RegistrationClassFinder() {} // do not instantiate
 
-    private static void checkAccess(URL url) throws ClassNotFoundException {
-        // The system property com.sun.star.comp.loader.CPLD_ACCESSPATH was
-        // introduced as a hack to restrict which UNO components can be
-        // instantiated.  It seems to be unused nowadays, and should probably be
-        // replaced by the native Java security features, anyway.
-        if (accessPath != null) {
-            if (!url.getProtocol().equals("file")) {
-                throw new ClassNotFoundException(
-                    "Access restriction: <" + url + "> is not a file URL");
-            }
-            String p;
-            try {
-                p = new File(url.getFile()).getCanonicalPath();
-            } catch (IOException e) {
-                throw new ClassNotFoundException(
-                    "Access restriction: <" + url + "> is bad: " + e);
-            }
-            for (int i = 0; i < accessPath.length; ++i) {
-                String p2 = accessPath[i];
-                if (p.startsWith(p2) && p.length() > p2.length()
-                    && (p2.charAt(p2.length() - 1) == File.separatorChar
-                        || p.charAt(p2.length()) == File.separatorChar))
-                {
-                    return;
-                }
-            }
-            throw new ClassNotFoundException(
-                "Access restriction: <" + url + "> is restricted");
-        }
-    }
-
     private static final WeakMap map = new WeakMap();
-
-    private static final String[] accessPath;
-    static {
-        String[] ap = null;
-        String p = System.getProperty(
-            "com.sun.star.comp.loader.CPLD_ACCESSPATH");
-        if (p != null) {
-            StringTokenizer t = new StringTokenizer(p, ";");
-            ap = new String[t.countTokens()];
-            int i = 0;
-            while (t.hasMoreTokens()) {
-                try {
-                    ap[i] = new File(t.nextToken()).getCanonicalPath();
-                    ++i;
-                } catch (IOException e) {}
-            }
-            if (i != ap.length) {
-                String[] ap2 = new String[i];
-                System.arraycopy(ap, 0, ap2, 0, i);
-                ap = ap2;
-            }
-        }
-        accessPath = ap;
-    }
 }


More information about the Libreoffice-commits mailing list