LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/scripting/source/provider - MasterScriptProviderFactory.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 21 32 65.6 %
Date: 2013-07-09 Functions: 8 11 72.7 %
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             : #include <cppuhelper/weakref.hxx>
      21             : #include <cppuhelper/implementationentry.hxx>
      22             : #include <cppuhelper/factory.hxx>
      23             : #include <cppuhelper/exc_hlp.hxx>
      24             : #include <cppuhelper/implbase1.hxx>
      25             : 
      26             : #include "MasterScriptProviderFactory.hxx"
      27             : 
      28             : using namespace ::com::sun::star;
      29             : using namespace ::com::sun::star::uno;
      30             : using namespace ::com::sun::star::script;
      31             : 
      32             : namespace func_provider
      33             : {
      34             : 
      35           4 : MasterScriptProviderFactory::MasterScriptProviderFactory(
      36             :     Reference< XComponentContext > const & xComponentContext )
      37           4 :     : m_xComponentContext( xComponentContext )
      38             : {
      39           4 : }
      40             : 
      41           8 : MasterScriptProviderFactory::~MasterScriptProviderFactory()
      42             : {
      43           8 : }
      44             : 
      45             : 
      46             : //############################################################################
      47             : // Implementation of XScriptProviderFactory
      48             : //############################################################################
      49             : 
      50             : 
      51             : Reference< provider::XScriptProvider > SAL_CALL
      52         104 : MasterScriptProviderFactory::createScriptProvider( const Any& context ) throw ( lang::IllegalArgumentException, RuntimeException)
      53             : {
      54         104 :     Reference< provider::XScriptProvider > xMsp( getActiveMSPList() ->getMSPFromAnyContext( context ), UNO_QUERY_THROW );
      55         104 :     return xMsp;
      56             : }
      57             : 
      58             : //############################################################################
      59             : // Helper methods
      60             : //############################################################################
      61             : 
      62             : const rtl::Reference< ActiveMSPList > &
      63         104 : MasterScriptProviderFactory::getActiveMSPList() const
      64             : {
      65         104 :     if ( !m_MSPList.is() )
      66             :     {
      67           4 :         ::osl::MutexGuard guard( ::osl::Mutex::getGlobalMutex() );
      68           4 :         if ( !m_MSPList.is() )
      69           4 :            m_MSPList = new ActiveMSPList( m_xComponentContext );
      70             :     }
      71         104 :     return m_MSPList;
      72             : }
      73             : 
      74             : //############################################################################
      75             : // Namespace global methods for setting up MasterScriptProviderFactory service
      76             : //############################################################################
      77             : 
      78             : Sequence< OUString > SAL_CALL
      79           4 : mspf_getSupportedServiceNames( )
      80             :     SAL_THROW(())
      81             : {
      82             :     OUString str_name(
      83           4 :         "com.sun.star.script.provider.MasterScriptProviderFactory");
      84             : 
      85           4 :     return Sequence< OUString >( &str_name, 1 );
      86             : }
      87             : 
      88             : OUString SAL_CALL
      89           8 : mspf_getImplementationName( )
      90             :     SAL_THROW(())
      91             : {
      92             :     return OUString(
      93           8 :         "com.sun.star.script.provider.MasterScriptProviderFactory");
      94             : }
      95             : 
      96             : Reference< XInterface > SAL_CALL
      97           4 : mspf_create( Reference< XComponentContext > const & xComponentContext )
      98             :     SAL_THROW( (Exception) )
      99             : {
     100             :     return static_cast< ::cppu::OWeakObject * >(
     101           4 :         new MasterScriptProviderFactory( xComponentContext ) );
     102             : }
     103             : 
     104             : //############################################################################
     105             : // Implementation of XServiceInfo
     106             : //############################################################################
     107             : 
     108             : OUString SAL_CALL
     109           0 : MasterScriptProviderFactory::getImplementationName()
     110             :     throw (RuntimeException)
     111             : {
     112           0 :     return mspf_getImplementationName();
     113             : }
     114             : 
     115             : Sequence< OUString > SAL_CALL
     116           0 : MasterScriptProviderFactory::getSupportedServiceNames()
     117             :     throw (RuntimeException)
     118             : {
     119           0 :     return mspf_getSupportedServiceNames();
     120             : }
     121             : 
     122           0 : sal_Bool MasterScriptProviderFactory::supportsService(
     123             :     OUString const & serviceName )
     124             :     throw (RuntimeException)
     125             : {
     126             : //     check();
     127             : 
     128             :     Sequence< OUString > supported_services(
     129           0 :         getSupportedServiceNames() );
     130             : 
     131           0 :     OUString const * ar = supported_services.getConstArray();
     132             : 
     133           0 :     for ( sal_Int32 pos = supported_services.getLength(); pos--; )
     134             :     {
     135           0 :         if (ar[ pos ].equals( serviceName ))
     136           0 :             return true;
     137             :     }
     138           0 :     return false;
     139             : }
     140             : 
     141             : } // namespace browsenodefactory
     142             : 
     143             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10