CWS-TOOLING: integrate CWS tl88
[LibreOffice.git] / starmath / source / detreg.cxx
blobc79813f994a77f1166aaf822ca1a522fb4c56d80
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
11 * OpenOffice.org is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU Lesser General Public License version 3
13 * only, as published by the Free Software Foundation.
15 * OpenOffice.org is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License version 3 for more details
19 * (a copy is included in the LICENSE file that accompanied this code).
21 * You should have received a copy of the GNU Lesser General Public License
22 * version 3 along with OpenOffice.org. If not, see
23 * <http://www.openoffice.org/license.html>
24 * for a copy of the LGPLv3 License.
26 ************************************************************************/
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_starmath.hxx"
30 #include <com/sun/star/lang/XServiceInfo.hpp>
31 #include <com/sun/star/registry/XRegistryKey.hpp>
32 #include <com/sun/star/uno/Sequence.h>
33 #include <rtl/ustring.hxx>
35 #include "smdetect.hxx"
37 using namespace ::rtl;
38 using namespace ::com::sun::star;
39 using namespace ::com::sun::star::uno;
40 using namespace ::com::sun::star::lang;
42 extern "C" {
44 void SAL_CALL component_getImplementationEnvironment(
45 const sal_Char** ppEnvironmentTypeName,
46 uno_Environment** /*ppEnvironment*/ )
48 *ppEnvironmentTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME ;
51 sal_Bool SAL_CALL component_writeInfo( void* /*pServiceManager*/,
52 void* pRegistryKey )
54 Reference< ::registry::XRegistryKey >
55 xKey( reinterpret_cast< ::registry::XRegistryKey* >( pRegistryKey ) ) ;
57 OUString aDelimiter( RTL_CONSTASCII_USTRINGPARAM("/") );
58 OUString aUnoServices( RTL_CONSTASCII_USTRINGPARAM( "/UNO/SERVICES") );
60 // Eigentliche Implementierung und ihre Services registrieren
61 sal_Int32 i;
62 Reference< ::registry::XRegistryKey > xNewKey;
64 xNewKey = xKey->createKey( aDelimiter + SmFilterDetect::impl_getStaticImplementationName() +
65 aUnoServices );
67 Sequence< OUString > aServices = SmFilterDetect::impl_getStaticSupportedServiceNames();
68 for(i = 0; i < aServices.getLength(); i++ )
69 xNewKey->createKey( aServices.getConstArray()[i] );
71 return sal_True;
74 void* SAL_CALL component_getFactory( const sal_Char* pImplementationName,
75 void* pServiceManager,
76 void* /*pRegistryKey*/ )
78 // Set default return value for this operation - if it failed.
79 void* pReturn = NULL ;
81 if (
82 ( pImplementationName != NULL ) &&
83 ( pServiceManager != NULL )
86 // Define variables which are used in following macros.
87 Reference< XSingleServiceFactory > xFactory ;
88 Reference< XMultiServiceFactory > xServiceManager( reinterpret_cast< XMultiServiceFactory* >( pServiceManager ) ) ;
90 if( SmFilterDetect::impl_getStaticImplementationName().equalsAscii( pImplementationName ) )
92 xFactory = ::cppu::createSingleFactory( xServiceManager,
93 SmFilterDetect::impl_getStaticImplementationName(),
94 SmFilterDetect::impl_createInstance,
95 SmFilterDetect::impl_getStaticSupportedServiceNames() );
98 // Factory is valid - service was found.
99 if ( xFactory.is() )
101 xFactory->acquire();
102 pReturn = xFactory.get();
106 // Return with result of this operation.
107 return pReturn ;
109 } // extern "C"