LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/vcl/source/components - factory.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 20 24 83.3 %
Date: 2013-07-09 Functions: 1 1 100.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             : #include <osl/mutex.hxx>
      21             : #include <rtl/ustrbuf.hxx>
      22             : #include <uno/dispatcher.h> // declaration of generic uno interface
      23             : #include <uno/mapping.hxx> // mapping stuff
      24             : #include <cppuhelper/factory.hxx>
      25             : #include <com/sun/star/lang/XMultiServiceFactory.hpp>
      26             : #include <vcl/dllapi.h>
      27             : 
      28             : using namespace com::sun::star::uno;
      29             : using namespace com::sun::star::lang;
      30             : 
      31             : // service implementation
      32             : extern Sequence< OUString > SAL_CALL vcl_session_getSupportedServiceNames();
      33             : extern OUString SAL_CALL vcl_session_getImplementationName();
      34             : extern Reference< XInterface > SAL_CALL vcl_session_createInstance( const Reference< XMultiServiceFactory > & );
      35             : 
      36             : namespace vcl
      37             : {
      38             : extern Sequence< OUString > SAL_CALL FontIdentificator_getSupportedServiceNames();
      39             : extern OUString SAL_CALL FontIdentificator_getImplementationName();
      40             : extern Reference< XInterface > SAL_CALL FontIdentificator_createInstance( const Reference< XMultiServiceFactory > & );
      41             : 
      42             : extern OUString SAL_CALL Clipboard_getImplementationName();
      43             : extern Reference< XSingleServiceFactory > SAL_CALL Clipboard_createFactory( const Reference< XMultiServiceFactory > & );
      44             : 
      45             : extern Sequence< OUString > SAL_CALL DragSource_getSupportedServiceNames();
      46             : extern OUString SAL_CALL DragSource_getImplementationName();
      47             : extern Reference< XInterface > SAL_CALL DragSource_createInstance( const Reference< XMultiServiceFactory > & );
      48             : 
      49             : extern Sequence< OUString > SAL_CALL DropTarget_getSupportedServiceNames();
      50             : extern OUString SAL_CALL DropTarget_getImplementationName();
      51             : extern Reference< XInterface > SAL_CALL DropTarget_createInstance( const Reference< XMultiServiceFactory > & );
      52             : 
      53             : }
      54             : 
      55             : extern "C" {
      56             : 
      57          98 :     VCL_DLLPUBLIC void* SAL_CALL vcl_component_getFactory(
      58             :         const sal_Char* pImplementationName,
      59             :         void* pXUnoSMgr,
      60             :         void* /*pXUnoKey*/
      61             :         )
      62             :     {
      63          98 :         void* pRet = 0;
      64             : 
      65          98 :         if( pXUnoSMgr )
      66             :         {
      67             :             Reference< ::com::sun::star::lang::XMultiServiceFactory > xMgr(
      68             :                 reinterpret_cast< ::com::sun::star::lang::XMultiServiceFactory* >( pXUnoSMgr )
      69          98 :                 );
      70         196 :             Reference< ::com::sun::star::lang::XSingleServiceFactory > xFactory;
      71          98 :             if( vcl_session_getImplementationName().equalsAscii( pImplementationName ) )
      72             :             {
      73           0 :                 xFactory = ::cppu::createOneInstanceFactory(
      74             :                     xMgr, vcl_session_getImplementationName(), vcl_session_createInstance,
      75           0 :                     vcl_session_getSupportedServiceNames() );
      76             :             }
      77          98 :             else if( vcl::FontIdentificator_getImplementationName().equalsAscii( pImplementationName ) )
      78             :             {
      79           0 :                 xFactory = ::cppu::createSingleFactory(
      80             :                     xMgr, vcl::FontIdentificator_getImplementationName(), vcl::FontIdentificator_createInstance,
      81           0 :                     vcl::FontIdentificator_getSupportedServiceNames() );
      82             :             }
      83          98 :             else if( vcl::Clipboard_getImplementationName().equalsAscii( pImplementationName ) )
      84             :             {
      85          32 :                 xFactory = vcl::Clipboard_createFactory( xMgr );
      86             :             }
      87          66 :             else if( vcl::DragSource_getImplementationName().equalsAscii( pImplementationName ) )
      88             :             {
      89          66 :                 xFactory = ::cppu::createSingleFactory(
      90             :                     xMgr, vcl::DragSource_getImplementationName(), vcl::DragSource_createInstance,
      91          33 :                     vcl::DragSource_getSupportedServiceNames() );
      92             :             }
      93          33 :             else if( vcl::DropTarget_getImplementationName().equalsAscii( pImplementationName ) )
      94             :             {
      95          66 :                 xFactory = ::cppu::createSingleFactory(
      96             :                     xMgr, vcl::DropTarget_getImplementationName(), vcl::DropTarget_createInstance,
      97          33 :                     vcl::DropTarget_getSupportedServiceNames() );
      98             :             }
      99          98 :             if( xFactory.is() )
     100             :             {
     101          98 :                 xFactory->acquire();
     102          98 :                 pRet = xFactory.get();
     103          98 :             }
     104             :         }
     105          98 :         return pRet;
     106             :     }
     107             : 
     108             : } /* extern "C" */
     109             : 
     110             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10