LCOV - code coverage report
Current view: top level - starmath/source - register.cxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 40 42 95.2 %
Date: 2014-04-11 Functions: 3 3 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 <com/sun/star/lang/XServiceInfo.hpp>
      21             : #include <com/sun/star/registry/XRegistryKey.hpp>
      22             : #include <com/sun/star/uno/Sequence.h>
      23             : #include <rtl/ustring.hxx>
      24             : 
      25             : #include <sfx2/sfxmodelfactory.hxx>
      26             : 
      27             : #include "smdll.hxx"
      28             : #include "document.hxx"
      29             : #include "unomodel.hxx"
      30             : 
      31             : using namespace ::com::sun::star;
      32             : using namespace ::com::sun::star::uno;
      33             : using namespace ::com::sun::star::lang;
      34             : 
      35             : //Math document
      36             : extern Sequence< OUString > SAL_CALL
      37             :         SmDocument_getSupportedServiceNames() throw();
      38             : extern OUString SAL_CALL
      39             :         SmDocument_getImplementationName() throw();
      40             : extern Reference< XInterface >SAL_CALL
      41             :         SmDocument_createInstance(const Reference< XMultiServiceFactory > & rSMgr, const sal_uInt64 _nCreationFlags) throw( Exception );
      42             : 
      43             : //MathML import
      44             : extern Sequence< OUString > SAL_CALL
      45             :         SmXMLImport_getSupportedServiceNames() throw();
      46             : extern OUString SAL_CALL
      47             :         SmXMLImport_getImplementationName() throw();
      48             : extern Reference< XInterface > SAL_CALL
      49             :         SmXMLImport_createInstance(const Reference< XMultiServiceFactory > & rSMgr) throw( Exception );
      50             : extern Sequence< OUString > SAL_CALL
      51             :         SmXMLImportMeta_getSupportedServiceNames() throw();
      52             : extern OUString SAL_CALL
      53             :         SmXMLImportMeta_getImplementationName() throw();
      54             : extern Reference< XInterface > SAL_CALL
      55             :         SmXMLImportMeta_createInstance(const Reference< XMultiServiceFactory > & rSMgr) throw( Exception );
      56             : extern Sequence< OUString > SAL_CALL
      57             :         SmXMLImportSettings_getSupportedServiceNames() throw();
      58             : extern OUString SAL_CALL SmXMLImportSettings_getImplementationName() throw();
      59             : extern Reference< XInterface > SAL_CALL
      60             :         SmXMLImportSettings_createInstance(const Reference< XMultiServiceFactory > & rSMgr) throw( Exception );
      61             : 
      62             : //MathML export
      63             : extern Sequence< OUString > SAL_CALL
      64             :         SmXMLExport_getSupportedServiceNames() throw();
      65             : extern OUString SAL_CALL
      66             :         SmXMLExport_getImplementationName() throw();
      67             : extern Reference< XInterface > SAL_CALL
      68             :         SmXMLExport_createInstance(const Reference< XMultiServiceFactory > & rSMgr) throw( Exception );
      69             : extern Sequence< OUString > SAL_CALL
      70             :         SmXMLExportMetaOOO_getSupportedServiceNames() throw();
      71             : extern OUString SAL_CALL
      72             :         SmXMLExportMetaOOO_getImplementationName() throw();
      73             : extern Reference< XInterface > SAL_CALL
      74             :         SmXMLExportMetaOOO_createInstance(const Reference< XMultiServiceFactory > & rSMgr) throw( Exception );
      75             : extern Sequence< OUString > SAL_CALL
      76             :         SmXMLExportMeta_getSupportedServiceNames() throw();
      77             : extern OUString SAL_CALL
      78             :         SmXMLExportMeta_getImplementationName() throw();
      79             : extern Reference< XInterface > SAL_CALL
      80             :         SmXMLExportMeta_createInstance(const Reference< XMultiServiceFactory > & rSMgr) throw( Exception );
      81             : extern Sequence< OUString > SAL_CALL
      82             :         SmXMLExportSettingsOOO_getSupportedServiceNames() throw();
      83             : extern OUString SAL_CALL
      84             :         SmXMLExportSettingsOOO_getImplementationName() throw();
      85             : extern Reference< XInterface > SAL_CALL
      86             :         SmXMLExportSettingsOOO_createInstance(const Reference< XMultiServiceFactory > & rSMgr) throw( Exception );
      87             : extern Sequence< OUString > SAL_CALL
      88             :         SmXMLExportSettings_getSupportedServiceNames() throw();
      89             : extern OUString SAL_CALL
      90             :         SmXMLExportSettings_getImplementationName() throw();
      91             : extern Reference< XInterface > SAL_CALL
      92             :         SmXMLExportSettings_createInstance(const Reference< XMultiServiceFactory > & rSMgr) throw( Exception );
      93             : extern Sequence< OUString > SAL_CALL
      94             :         SmXMLExportContent_getSupportedServiceNames() throw();
      95             : extern OUString SAL_CALL
      96             :         SmXMLExportContent_getImplementationName() throw();
      97             : extern Reference< XInterface > SAL_CALL
      98             :         SmXMLExportContent_createInstance(const Reference< XMultiServiceFactory > & rSMgr) throw( Exception );
      99             : 
     100             : 
     101             : extern "C" {
     102             : 
     103          28 : SAL_DLLPUBLIC_EXPORT void* SAL_CALL sm_component_getFactory( const sal_Char* pImplementationName,
     104             :                                      void* pServiceManager,
     105             :                                      void* /*pRegistryKey*/ )
     106             : {
     107             :     // Set default return value for this operation - if it failed.
     108          28 :     void* pReturn = NULL ;
     109             : 
     110          28 :     if  (
     111          28 :             ( pImplementationName   !=  NULL ) &&
     112             :             ( pServiceManager       !=  NULL )
     113             :         )
     114             :     {
     115             :         // Define variables which are used in following macros.
     116          28 :         Reference< XSingleServiceFactory >   xFactory                                                                                                ;
     117          56 :         Reference< XMultiServiceFactory >    xServiceManager( reinterpret_cast< XMultiServiceFactory* >( pServiceManager ) ) ;
     118             : 
     119          28 :         if( SmXMLImport_getImplementationName().equalsAscii( pImplementationName ))
     120             :         {
     121           4 :             xFactory = ::cppu::createSingleFactory( xServiceManager,
     122             :             SmXMLImport_getImplementationName(),
     123             :             SmXMLImport_createInstance,
     124           2 :             SmXMLImport_getSupportedServiceNames() );
     125             :         }
     126          26 :         else if( SmXMLExport_getImplementationName().equalsAscii( pImplementationName ))
     127             :         {
     128           2 :             xFactory = ::cppu::createSingleFactory( xServiceManager,
     129             :             SmXMLExport_getImplementationName(),
     130             :             SmXMLExport_createInstance,
     131           1 :             SmXMLExport_getSupportedServiceNames() );
     132             :         }
     133          25 :         else if( SmXMLImportMeta_getImplementationName().equalsAscii( pImplementationName ))
     134             :         {
     135           2 :             xFactory = ::cppu::createSingleFactory( xServiceManager,
     136             :             SmXMLImportMeta_getImplementationName(),
     137             :             SmXMLImportMeta_createInstance,
     138           1 :             SmXMLImportMeta_getSupportedServiceNames() );
     139             :         }
     140          24 :         else if( SmXMLExportMetaOOO_getImplementationName().equalsAscii( pImplementationName ))
     141             :         {
     142           2 :             xFactory = ::cppu::createSingleFactory( xServiceManager,
     143             :             SmXMLExportMetaOOO_getImplementationName(),
     144             :             SmXMLExportMetaOOO_createInstance,
     145           1 :             SmXMLExportMetaOOO_getSupportedServiceNames() );
     146             :         }
     147          23 :         else if( SmXMLExportMeta_getImplementationName().equalsAscii( pImplementationName ))
     148             :         {
     149           0 :             xFactory = ::cppu::createSingleFactory( xServiceManager,
     150             :             SmXMLExportMeta_getImplementationName(),
     151             :             SmXMLExportMeta_createInstance,
     152           0 :             SmXMLExportMeta_getSupportedServiceNames() );
     153             :         }
     154          23 :         else if( SmXMLImportSettings_getImplementationName().equalsAscii( pImplementationName ))
     155             :         {
     156           4 :             xFactory = ::cppu::createSingleFactory( xServiceManager,
     157             :             SmXMLImportSettings_getImplementationName(),
     158             :             SmXMLImportSettings_createInstance,
     159           2 :             SmXMLImportSettings_getSupportedServiceNames() );
     160             :         }
     161          21 :         else if( SmXMLExportSettingsOOO_getImplementationName().equalsAscii( pImplementationName ))
     162             :         {
     163           2 :             xFactory = ::cppu::createSingleFactory( xServiceManager,
     164             :             SmXMLExportSettingsOOO_getImplementationName(),
     165             :             SmXMLExportSettingsOOO_createInstance,
     166           1 :             SmXMLExportSettingsOOO_getSupportedServiceNames() );
     167             :         }
     168          20 :         else if( SmXMLExportSettings_getImplementationName().equalsAscii( pImplementationName ))
     169             :         {
     170          12 :             xFactory = ::cppu::createSingleFactory( xServiceManager,
     171             :             SmXMLExportSettings_getImplementationName(),
     172             :             SmXMLExportSettings_createInstance,
     173           6 :             SmXMLExportSettings_getSupportedServiceNames() );
     174             :         }
     175          14 :         else if( SmXMLExportContent_getImplementationName().equalsAscii( pImplementationName ))
     176             :         {
     177          12 :             xFactory = ::cppu::createSingleFactory( xServiceManager,
     178             :             SmXMLExportContent_getImplementationName(),
     179             :             SmXMLExportContent_createInstance,
     180           6 :             SmXMLExportContent_getSupportedServiceNames() );
     181             :         }
     182           8 :         else if( SmDocument_getImplementationName().equalsAscii( pImplementationName ))
     183             :         {
     184          16 :             xFactory = ::sfx2::createSfxModelFactory( xServiceManager,
     185             :             SmDocument_getImplementationName(),
     186             :             SmDocument_createInstance,
     187           8 :             SmDocument_getSupportedServiceNames() );
     188             :         }
     189             : 
     190             : 
     191             :         // Factory is valid - service was found.
     192          28 :         if ( xFactory.is() )
     193             :         {
     194          28 :             xFactory->acquire();
     195          28 :             pReturn = xFactory.get();
     196          28 :         }
     197             :     }
     198             : 
     199             :     // Return with result of this operation.
     200          28 :     return pReturn ;
     201             : }
     202          27 : } // extern "C"
     203             : 
     204             : 
     205             : 
     206             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10