LCOV - code coverage report
Current view: top level - stoc/source/loader - dllcomponentloader.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 12 21 57.1 %
Date: 2015-06-13 12:38:46 Functions: 6 10 60.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : 
      21             : #include <stdlib.h>
      22             : #include <osl/file.h>
      23             : #include <vector>
      24             : #include <osl/mutex.hxx>
      25             : #include <osl/diagnose.h>
      26             : #include <osl/module.h>
      27             : #include <rtl/ref.hxx>
      28             : #include <rtl/ustring.hxx>
      29             : #include <uno/environment.h>
      30             : #include <uno/mapping.hxx>
      31             : #include <cppuhelper/queryinterface.hxx>
      32             : #include <cppuhelper/weak.hxx>
      33             : #include <cppuhelper/shlib.hxx>
      34             : #include <cppuhelper/implbase3.hxx>
      35             : #include <cppuhelper/implementationentry.hxx>
      36             : #include <cppuhelper/supportsservice.hxx>
      37             : #include <cppuhelper/bootstrap.hxx>
      38             : 
      39             : #include <com/sun/star/loader/XImplementationLoader.hpp>
      40             : #include <com/sun/star/lang/XMultiServiceFactory.hpp>
      41             : #include <com/sun/star/lang/XServiceInfo.hpp>
      42             : #include <com/sun/star/lang/XInitialization.hpp>
      43             : #include <com/sun/star/registry/XRegistryKey.hpp>
      44             : 
      45             : using namespace com::sun::star;
      46             : using namespace css::uno;
      47             : using namespace css::loader;
      48             : using namespace css::lang;
      49             : using namespace css::registry;
      50             : using namespace cppu;
      51             : using namespace osl;
      52             : 
      53             : namespace {
      54             : 
      55             : class DllComponentLoader
      56             :     : public WeakImplHelper3< XImplementationLoader,
      57             :                               XInitialization,
      58             :                               XServiceInfo >
      59             : {
      60             : public:
      61             :     DllComponentLoader( const Reference<XComponentContext> & xCtx );
      62             :     virtual ~DllComponentLoader();
      63             : 
      64             :     // XServiceInfo
      65             :     virtual OUString SAL_CALL getImplementationName(  ) throw(css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
      66             :     virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) throw(css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
      67             :     virtual Sequence< OUString > SAL_CALL getSupportedServiceNames(  ) throw(css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
      68             : 
      69             :     // XInitialization
      70             :     virtual void SAL_CALL initialize( const css::uno::Sequence< css::uno::Any >& aArguments ) throw(css::uno::Exception, css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
      71             : 
      72             :     // XImplementationLoader
      73             :     virtual Reference<XInterface> SAL_CALL activate( const OUString& implementationName, const OUString& implementationLoaderUrl, const OUString& locationUrl, const Reference<XRegistryKey>& xKey ) throw(CannotActivateFactoryException, RuntimeException, std::exception) SAL_OVERRIDE;
      74             :     virtual sal_Bool SAL_CALL writeRegistryInfo( const Reference<XRegistryKey>& xKey, const OUString& implementationLoaderUrl, const OUString& locationUrl ) throw(CannotRegisterImplementationException, RuntimeException, std::exception) SAL_OVERRIDE;
      75             : 
      76             : private:
      77             :     Reference<XMultiServiceFactory> m_xSMgr;
      78             : };
      79             : 
      80             : 
      81           1 : DllComponentLoader::DllComponentLoader( const Reference<XComponentContext> & xCtx )
      82             : {
      83           1 :     m_xSMgr.set( xCtx->getServiceManager(), UNO_QUERY );
      84           1 : }
      85             : 
      86             : 
      87           2 : DllComponentLoader::~DllComponentLoader() {}
      88             : 
      89             : 
      90           1 : OUString SAL_CALL DllComponentLoader::getImplementationName(  )
      91             :     throw(css::uno::RuntimeException, std::exception)
      92             : {
      93           1 :     return OUString("com.sun.star.comp.stoc.DLLComponentLoader");
      94             : }
      95             : 
      96           0 : sal_Bool SAL_CALL DllComponentLoader::supportsService( const OUString& ServiceName )
      97             :     throw(css::uno::RuntimeException, std::exception)
      98             : {
      99           0 :     return cppu::supportsService(this, ServiceName);
     100             : }
     101             : 
     102           1 : Sequence<OUString> SAL_CALL DllComponentLoader::getSupportedServiceNames(  )
     103             :     throw(css::uno::RuntimeException, std::exception)
     104             : {
     105           1 :     Sequence< OUString > seqNames(1);
     106           1 :     seqNames[0] = "com.sun.star.loader.SharedLibrary";
     107           1 :     return seqNames;
     108             : }
     109             : 
     110             : 
     111           0 : void DllComponentLoader::initialize( const css::uno::Sequence< css::uno::Any >& )
     112             :     throw(css::uno::Exception, css::uno::RuntimeException, std::exception)
     113             : {
     114             :     OSL_FAIL( "dllcomponentloader::initialize should not be called !" );
     115             : //      if( aArgs.getLength() != 1 )
     116             : //      {
     117             : //          throw IllegalArgumentException();
     118             : //      }
     119             : 
     120             : //      Reference< XMultiServiceFactory > rServiceManager;
     121             : 
     122             : //      if( aArgs.getConstArray()[0].getValueType().getTypeClass() == TypeClass_INTERFACE )
     123             : //      {
     124             : //          aArgs.getConstArray()[0] >>= rServiceManager;
     125             : //      }
     126             : 
     127             : //      if( !rServiceManager.is() )
     128             : //      {
     129             : //          throw IllegalArgumentException();
     130             : //      }
     131             : 
     132             : //      m_xSMgr = rServiceManager;
     133           0 : }
     134             : 
     135             : 
     136           0 : Reference<XInterface> SAL_CALL DllComponentLoader::activate(
     137             :     const OUString & rImplName, const OUString &, const OUString & rLibName,
     138             :     const Reference< XRegistryKey > & )
     139             : 
     140             :     throw(CannotActivateFactoryException, RuntimeException, std::exception)
     141             : {
     142             :     return loadSharedLibComponentFactory(
     143             :         cppu::bootstrap_expandUri(rLibName), OUString(), rImplName, m_xSMgr,
     144           0 :         css::uno::Reference<css::registry::XRegistryKey>());
     145             : }
     146             : 
     147             : 
     148             : 
     149           0 : sal_Bool SAL_CALL DllComponentLoader::writeRegistryInfo(
     150             :     const Reference< XRegistryKey > & xKey, const OUString &, const OUString & rLibName )
     151             : 
     152             :     throw(CannotRegisterImplementationException, RuntimeException, std::exception)
     153             : {
     154             : #ifdef DISABLE_DYNLOADING
     155             :     (void) xKey;
     156             :     (void) rLibName;
     157             :     OSL_FAIL( "DllComponentLoader::writeRegistryInfo() should not be called I think?" );
     158             :     return sal_False;
     159             : #else
     160             :     writeSharedLibComponentInfo(
     161           0 :         cppu::bootstrap_expandUri(rLibName), OUString(), m_xSMgr, xKey );
     162           0 :     return sal_True;
     163             : #endif
     164             : }
     165             : 
     166             : }
     167             : 
     168             : extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface * SAL_CALL
     169           1 : com_sun_star_comp_stoc_DLLComponentLoader_get_implementation(
     170             :     css::uno::XComponentContext *context,
     171             :     css::uno::Sequence<css::uno::Any> const &)
     172             : {
     173           1 :     return cppu::acquire(new DllComponentLoader(context));
     174             : }
     175             : 
     176             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11