LCOV - code coverage report
Current view: top level - xmloff/source/transform - XMLFilterRegistration.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 18 19 94.7 %
Date: 2012-08-25 Functions: 2 2 100.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 14 28 50.0 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*************************************************************************
       3                 :            :  *
       4                 :            :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5                 :            :  *
       6                 :            :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7                 :            :  *
       8                 :            :  * OpenOffice.org - a multi-platform office productivity suite
       9                 :            :  *
      10                 :            :  * This file is part of OpenOffice.org.
      11                 :            :  *
      12                 :            :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13                 :            :  * it under the terms of the GNU Lesser General Public License version 3
      14                 :            :  * only, as published by the Free Software Foundation.
      15                 :            :  *
      16                 :            :  * OpenOffice.org is distributed in the hope that it will be useful,
      17                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19                 :            :  * GNU Lesser General Public License version 3 for more details
      20                 :            :  * (a copy is included in the LICENSE file that accompanied this code).
      21                 :            :  *
      22                 :            :  * You should have received a copy of the GNU Lesser General Public License
      23                 :            :  * version 3 along with OpenOffice.org.  If not, see
      24                 :            :  * <http://www.openoffice.org/license.html>
      25                 :            :  * for a copy of the LGPLv3 License.
      26                 :            :  *
      27                 :            :  ************************************************************************/
      28                 :            : 
      29                 :            : 
      30                 :            : #include <string.h>
      31                 :            : #include <com/sun/star/registry/XRegistryKey.hpp>
      32                 :            : #include <cppuhelper/factory.hxx>
      33                 :            : 
      34                 :            : using namespace ::com::sun::star;
      35                 :            : 
      36                 :            : #define DECLARE_SERVICE( classname )    \
      37                 :            :     extern ::rtl::OUString SAL_CALL classname##_getImplementationName() throw();   \
      38                 :            :     extern uno::Sequence< ::rtl::OUString > SAL_CALL classname##_getSupportedServiceNames() throw();   \
      39                 :            :     extern uno::Reference< uno::XInterface > SAL_CALL classname##_createInstance(   \
      40                 :            :             const uno::Reference< lang::XMultiServiceFactory > & rSMgr ) throw( uno::Exception );
      41                 :            : 
      42                 :            : #define ENUMERATE_SERVICE( classname ) \
      43                 :            :     { classname##_getImplementationName, classname##_getSupportedServiceNames, classname##_createInstance }
      44                 :            : 
      45                 :            : // ============================================================================
      46                 :            : DECLARE_SERVICE( OOo2OasisTransformer )
      47                 :            : DECLARE_SERVICE( Oasis2OOoTransformer )
      48                 :            : 
      49                 :            : DECLARE_SERVICE( XMLAutoTextEventImportOOO )
      50                 :            : DECLARE_SERVICE( XMLMetaImportOOO )
      51                 :            : DECLARE_SERVICE( XMLMathSettingsImportOOO )
      52                 :            : DECLARE_SERVICE( XMLMathMetaImportOOO )
      53                 :            : DECLARE_SERVICE( XMLCalcSettingsImportOOO )
      54                 :            : DECLARE_SERVICE( XMLCalcMetaImportOOO )
      55                 :            : DECLARE_SERVICE( XMLCalcContentImportOOO )
      56                 :            : DECLARE_SERVICE( XMLCalcStylesImportOOO )
      57                 :            : DECLARE_SERVICE( XMLCalcImportOOO )
      58                 :            : DECLARE_SERVICE( XMLWriterSettingsImportOOO )
      59                 :            : DECLARE_SERVICE( XMLWriterMetaImportOOO )
      60                 :            : DECLARE_SERVICE( XMLWriterContentImportOOO )
      61                 :            : DECLARE_SERVICE( XMLWriterStylesImportOOO )
      62                 :            : DECLARE_SERVICE( XMLWriterImportOOO )
      63                 :            : DECLARE_SERVICE( XMLChartContentImportOOO )
      64                 :            : DECLARE_SERVICE( XMLChartStylesImportOOO )
      65                 :            : DECLARE_SERVICE( XMLChartImportOOO )
      66                 :            : DECLARE_SERVICE( XMLDrawSettingsImportOOO )
      67                 :            : DECLARE_SERVICE( XMLDrawMetaImportOOO )
      68                 :            : DECLARE_SERVICE( XMLDrawContentImportOOO )
      69                 :            : DECLARE_SERVICE( XMLDrawStylesImportOOO )
      70                 :            : DECLARE_SERVICE( XMLDrawImportOOO )
      71                 :            : DECLARE_SERVICE( XMLImpressSettingsImportOOO )
      72                 :            : DECLARE_SERVICE( XMLImpressMetaImportOOO )
      73                 :            : DECLARE_SERVICE( XMLImpressContentImportOOO )
      74                 :            : DECLARE_SERVICE( XMLImpressStylesImportOOO )
      75                 :            : DECLARE_SERVICE( XMLImpressImportOOO )
      76                 :            : 
      77                 :            : // ============================================================================
      78                 :            : 
      79                 :            : // ----------------------------------------------------------------------------
      80                 :            : namespace
      81                 :            : {
      82                 :            :     typedef ::rtl::OUString (SAL_CALL * GetImplementationName)();
      83                 :            :     typedef uno::Sequence< ::rtl::OUString > (SAL_CALL * GetSupportedServiceNames)();
      84                 :            :     typedef uno::Reference< ::uno::XInterface > (SAL_CALL * CreateInstance)(
      85                 :            :         const uno::Reference< lang::XMultiServiceFactory >& );
      86                 :            : 
      87                 :            :     struct ServiceDescriptor
      88                 :            :     {
      89                 :            :         GetImplementationName       getImplementationName;
      90                 :            :         GetSupportedServiceNames    getSupportedServiceNames;
      91                 :            :         CreateInstance              createInstance;
      92                 :            :     };
      93                 :            : 
      94                 :            :     // ------------------------------------------------------------------------
      95                 :         82 :     static const ServiceDescriptor* getServiceDescriptors()
      96                 :            :     {
      97                 :            :         static const ServiceDescriptor aDescriptors[] =
      98                 :            :         {
      99                 :            :             // ================================================================
     100                 :            :             ENUMERATE_SERVICE( OOo2OasisTransformer ),
     101                 :            :             ENUMERATE_SERVICE( Oasis2OOoTransformer ),
     102                 :            : 
     103                 :            :             ENUMERATE_SERVICE( XMLAutoTextEventImportOOO ),
     104                 :            :             ENUMERATE_SERVICE( XMLMetaImportOOO ),
     105                 :            :             ENUMERATE_SERVICE( XMLMathSettingsImportOOO ),
     106                 :            :             ENUMERATE_SERVICE( XMLMathMetaImportOOO ),
     107                 :            :             ENUMERATE_SERVICE( XMLCalcSettingsImportOOO ),
     108                 :            :             ENUMERATE_SERVICE( XMLCalcMetaImportOOO ),
     109                 :            :             ENUMERATE_SERVICE( XMLCalcContentImportOOO ),
     110                 :            :             ENUMERATE_SERVICE( XMLCalcStylesImportOOO ),
     111                 :            :             ENUMERATE_SERVICE( XMLCalcImportOOO ),
     112                 :            :             ENUMERATE_SERVICE( XMLWriterSettingsImportOOO ),
     113                 :            :             ENUMERATE_SERVICE( XMLWriterMetaImportOOO ),
     114                 :            :             ENUMERATE_SERVICE( XMLWriterContentImportOOO ),
     115                 :            :             ENUMERATE_SERVICE( XMLWriterStylesImportOOO ),
     116                 :            :             ENUMERATE_SERVICE( XMLWriterImportOOO ),
     117                 :            :             ENUMERATE_SERVICE( XMLChartContentImportOOO ),
     118                 :            :             ENUMERATE_SERVICE( XMLChartStylesImportOOO ),
     119                 :            :             ENUMERATE_SERVICE( XMLChartImportOOO ),
     120                 :            :             ENUMERATE_SERVICE( XMLDrawSettingsImportOOO ),
     121                 :            :             ENUMERATE_SERVICE( XMLDrawMetaImportOOO ),
     122                 :            :             ENUMERATE_SERVICE( XMLDrawContentImportOOO ),
     123                 :            :             ENUMERATE_SERVICE( XMLDrawStylesImportOOO ),
     124                 :            :             ENUMERATE_SERVICE( XMLDrawImportOOO ),
     125                 :            :             ENUMERATE_SERVICE( XMLImpressSettingsImportOOO ),
     126                 :            :             ENUMERATE_SERVICE( XMLImpressMetaImportOOO ),
     127                 :            :             ENUMERATE_SERVICE( XMLImpressContentImportOOO ),
     128                 :            :             ENUMERATE_SERVICE( XMLImpressStylesImportOOO ),
     129                 :            :             ENUMERATE_SERVICE( XMLImpressImportOOO ),
     130                 :            :             // ================================================================
     131                 :            :             { NULL, NULL, NULL }
     132                 :            :         };
     133                 :         82 :         return aDescriptors;
     134                 :            :     };
     135                 :            : }
     136                 :            : // ----------------------------------------------------------------------------
     137                 :            : 
     138                 :            : #ifdef __cplusplus
     139                 :            : extern "C"
     140                 :            : {
     141                 :            : #endif
     142                 :            : 
     143                 :         82 : SAL_DLLPUBLIC_EXPORT void* SAL_CALL xof_component_getFactory( const sal_Char * pImplName, void * pServiceManager, void * /*pRegistryKey*/ )
     144                 :            : {
     145                 :         82 :     void * pRet = NULL;
     146         [ +  - ]:         82 :     if( pServiceManager )
     147                 :            :     {
     148                 :            :         try
     149                 :            :         {
     150         [ +  - ]:         82 :             uno::Reference< lang::XMultiServiceFactory > xMSF( reinterpret_cast< lang::XMultiServiceFactory * >( pServiceManager ) );
     151                 :            : 
     152                 :         82 :             const sal_Int32 nImplNameLen = strlen( pImplName );
     153                 :            : 
     154                 :         82 :             const ServiceDescriptor* pDescriptor = getServiceDescriptors();
     155         [ +  - ]:       1284 :             while ( pDescriptor->getImplementationName )
     156                 :            :             {
     157 [ +  - ][ +  + ]:       1284 :                 if ( pDescriptor->getImplementationName().equalsAsciiL( pImplName, nImplNameLen ) )
     158                 :            :                 {
     159                 :            :                     uno::Reference< lang::XSingleServiceFactory > xFactory =
     160                 :            :                         ::cppu::createSingleFactory( xMSF,
     161                 :            :                             pDescriptor->getImplementationName(),
     162                 :            :                             pDescriptor->createInstance,
     163                 :            :                             pDescriptor->getSupportedServiceNames()
     164 [ +  - ][ +  - ]:         82 :                         );
         [ +  - ][ +  - ]
     165                 :            : 
     166         [ +  - ]:         82 :                     if ( xFactory.is() )
     167                 :            :                     {
     168         [ +  - ]:         82 :                         xFactory->acquire();
     169         [ +  - ]:         82 :                         pRet = xFactory.get();
     170                 :            :                         break;
     171         [ -  + ]:         82 :                     }
     172                 :            :                 }
     173                 :            : 
     174                 :       1202 :                 ++pDescriptor;
     175         [ #  # ]:         82 :             }
     176                 :            :         }
     177                 :          0 :         catch( uno::Exception& )
     178                 :            :         {
     179                 :            :             OSL_FAIL( "xof::xof_component_getFactory: Exception!" );
     180                 :            :         }
     181                 :            :     }
     182                 :            : 
     183                 :         82 :     return pRet;
     184                 :            : }
     185                 :            : 
     186                 :            : #ifdef __cplusplus
     187                 :            : }
     188                 :            : #endif
     189                 :            : 
     190                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10