1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: detreg.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sc.hxx"
34 #include "scdetect.hxx"
35 #include <com/sun/star/lang/XServiceInfo.hpp>
36 #include <com/sun/star/registry/XRegistryKey.hpp>
37 #include <com/sun/star/uno/Sequence.h>
38 #include <sal/types.h>
39 #include <rtl/ustring.hxx>
41 using ::rtl::OUString
;
42 using namespace ::com::sun::star
;
43 using namespace ::com::sun::star::uno
;
44 using namespace ::com::sun::star::lang
;
48 SAL_DLLPUBLIC_EXPORT
void SAL_CALL
component_getImplementationEnvironment(
49 const sal_Char
** ppEnvironmentTypeName
,
50 uno_Environment
** /* ppEnvironment */ )
52 *ppEnvironmentTypeName
= CPPU_CURRENT_LANGUAGE_BINDING_NAME
;
55 SAL_DLLPUBLIC_EXPORT sal_Bool SAL_CALL
component_writeInfo( void* /* pServiceManager */ ,
58 Reference
< ::registry::XRegistryKey
>
59 xKey( reinterpret_cast< ::registry::XRegistryKey
* >( pRegistryKey
) ) ;
61 OUString
aDelimiter( RTL_CONSTASCII_USTRINGPARAM("/") );
62 OUString
aUnoServices( RTL_CONSTASCII_USTRINGPARAM( "/UNO/SERVICES") );
64 // Eigentliche Implementierung und ihre Services registrieren
66 Reference
< ::registry::XRegistryKey
> xNewKey(xKey
->createKey( aDelimiter
+ ScFilterDetect::impl_getStaticImplementationName() +
69 Sequence
< OUString
> aServices(ScFilterDetect::impl_getStaticSupportedServiceNames());
70 for(i
= 0; i
< aServices
.getLength(); i
++ )
71 xNewKey
->createKey( aServices
.getConstArray()[i
] );
76 SAL_DLLPUBLIC_EXPORT
void* SAL_CALL
component_getFactory( const sal_Char
* pImplementationName
,
77 void* pServiceManager
,
78 void* /* pRegistryKey */ )
80 // Set default return value for this operation - if it failed.
81 void* pReturn
= NULL
;
84 ( pImplementationName
!= NULL
) &&
85 ( pServiceManager
!= NULL
)
88 // Define variables which are used in following macros.
89 Reference
< XSingleServiceFactory
> xFactory
;
90 Reference
< XMultiServiceFactory
> xServiceManager( reinterpret_cast< XMultiServiceFactory
* >( pServiceManager
) ) ;
92 if( ScFilterDetect::impl_getStaticImplementationName().equalsAscii( pImplementationName
) )
94 xFactory
.set(::cppu::createSingleFactory( xServiceManager
,
95 ScFilterDetect::impl_getStaticImplementationName(),
96 ScFilterDetect::impl_createInstance
,
97 ScFilterDetect::impl_getStaticSupportedServiceNames() ));
100 // Factory is valid - service was found.
104 pReturn
= xFactory
.get();
108 // Return with result of this operation.