LCOV - code coverage report
Current view: top level - xmloff/source/transform - XMLFilterRegistration.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 18 20 90.0 %
Date: 2015-06-13 12:38:46 Functions: 2 2 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 <string.h>
      21             : #include <com/sun/star/registry/XRegistryKey.hpp>
      22             : #include <cppuhelper/factory.hxx>
      23             : #include <osl/diagnose.h>
      24             : 
      25             : #include <XMLFilterRegistration.hxx>
      26             : 
      27             : using namespace ::com::sun::star;
      28             : 
      29             : #define ENUMERATE_SERVICE( classname ) \
      30             :     { classname##_getImplementationName, classname##_getSupportedServiceNames, classname##_createInstance }
      31             : 
      32             : namespace
      33             : {
      34             :     typedef OUString (SAL_CALL * GetImplementationName)();
      35             :     typedef uno::Sequence< OUString > (SAL_CALL * GetSupportedServiceNames)();
      36             :     typedef uno::Reference< ::uno::XInterface > (SAL_CALL * CreateInstance)(
      37             :         const uno::Reference< lang::XMultiServiceFactory >& );
      38             : 
      39             :     struct ServiceDescriptor
      40             :     {
      41             :         GetImplementationName       getImplementationName;
      42             :         GetSupportedServiceNames    getSupportedServiceNames;
      43             :         CreateInstance              createInstance;
      44             :     };
      45             : 
      46          47 :     static const ServiceDescriptor* getServiceDescriptors()
      47             :     {
      48             :         static const ServiceDescriptor aDescriptors[] =
      49             :         {
      50             :             ENUMERATE_SERVICE( OOo2OasisTransformer ),
      51             :             ENUMERATE_SERVICE( Oasis2OOoTransformer ),
      52             : 
      53             :             ENUMERATE_SERVICE( XMLAutoTextEventImportOOO ),
      54             :             ENUMERATE_SERVICE( XMLMetaImportOOO ),
      55             :             ENUMERATE_SERVICE( XMLMathSettingsImportOOO ),
      56             :             ENUMERATE_SERVICE( XMLMathMetaImportOOO ),
      57             :             ENUMERATE_SERVICE( XMLCalcSettingsImportOOO ),
      58             :             ENUMERATE_SERVICE( XMLCalcMetaImportOOO ),
      59             :             ENUMERATE_SERVICE( XMLCalcContentImportOOO ),
      60             :             ENUMERATE_SERVICE( XMLCalcStylesImportOOO ),
      61             :             ENUMERATE_SERVICE( XMLCalcImportOOO ),
      62             :             ENUMERATE_SERVICE( XMLWriterSettingsImportOOO ),
      63             :             ENUMERATE_SERVICE( XMLWriterMetaImportOOO ),
      64             :             ENUMERATE_SERVICE( XMLWriterContentImportOOO ),
      65             :             ENUMERATE_SERVICE( XMLWriterStylesImportOOO ),
      66             :             ENUMERATE_SERVICE( XMLWriterImportOOO ),
      67             :             ENUMERATE_SERVICE( XMLChartContentImportOOO ),
      68             :             ENUMERATE_SERVICE( XMLChartStylesImportOOO ),
      69             :             ENUMERATE_SERVICE( XMLChartImportOOO ),
      70             :             ENUMERATE_SERVICE( XMLDrawSettingsImportOOO ),
      71             :             ENUMERATE_SERVICE( XMLDrawMetaImportOOO ),
      72             :             ENUMERATE_SERVICE( XMLDrawContentImportOOO ),
      73             :             ENUMERATE_SERVICE( XMLDrawStylesImportOOO ),
      74             :             ENUMERATE_SERVICE( XMLDrawImportOOO ),
      75             :             ENUMERATE_SERVICE( XMLImpressSettingsImportOOO ),
      76             :             ENUMERATE_SERVICE( XMLImpressMetaImportOOO ),
      77             :             ENUMERATE_SERVICE( XMLImpressContentImportOOO ),
      78             :             ENUMERATE_SERVICE( XMLImpressStylesImportOOO ),
      79             :             ENUMERATE_SERVICE( XMLImpressImportOOO ),
      80             :             { NULL, NULL, NULL }
      81             :         };
      82          47 :         return aDescriptors;
      83             :     };
      84             : }
      85             : 
      86             : #ifdef __cplusplus
      87             : extern "C"
      88             : {
      89             : #endif
      90             : 
      91          47 : SAL_DLLPUBLIC_EXPORT void* SAL_CALL xof_component_getFactory( const sal_Char * pImplName, void * pServiceManager, void * /*pRegistryKey*/ )
      92             : {
      93          47 :     void * pRet = NULL;
      94          47 :     if( pServiceManager )
      95             :     {
      96             :         try
      97             :         {
      98          47 :             uno::Reference< lang::XMultiServiceFactory > xMSF( static_cast< lang::XMultiServiceFactory * >( pServiceManager ) );
      99             : 
     100          47 :             const sal_Int32 nImplNameLen = strlen( pImplName );
     101             : 
     102          47 :             const ServiceDescriptor* pDescriptor = getServiceDescriptors();
     103         641 :             while ( pDescriptor->getImplementationName )
     104             :             {
     105         594 :                 if ( pDescriptor->getImplementationName().equalsAsciiL( pImplName, nImplNameLen ) )
     106             :                 {
     107             :                     uno::Reference< lang::XSingleServiceFactory > xFactory =
     108             :                         ::cppu::createSingleFactory( xMSF,
     109             :                             pDescriptor->getImplementationName(),
     110             :                             pDescriptor->createInstance,
     111             :                             pDescriptor->getSupportedServiceNames()
     112          47 :                         );
     113             : 
     114          47 :                     if ( xFactory.is() )
     115             :                     {
     116          47 :                         xFactory->acquire();
     117          47 :                         pRet = xFactory.get();
     118          47 :                         break;
     119           0 :                     }
     120             :                 }
     121             : 
     122         547 :                 ++pDescriptor;
     123          47 :             }
     124             :         }
     125           0 :         catch( uno::Exception& )
     126             :         {
     127             :             OSL_FAIL( "xof::xof_component_getFactory: Exception!" );
     128             :         }
     129             :     }
     130             : 
     131          47 :     return pRet;
     132             : }
     133             : 
     134             : #ifdef __cplusplus
     135             : }
     136             : #endif
     137             : 
     138             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11