LCOV - code coverage report
Current view: top level - scripting/source/provider - MasterScriptProviderFactory.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 21 32 65.6 %
Date: 2012-08-25 Functions: 8 11 72.7 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 12 30 40.0 %

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

Generated by: LCOV version 1.10