Update ooo320-m1
[ooovba.git] / extensions / source / plugin / base / service.cxx
blobfda11f0785b1acc4ee140aec0daf86b78d2cb037
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: service.cxx,v $
10 * $Revision: 1.6 $
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_extensions.hxx"
34 #if STLPORT_VERSION>=321
35 #include <cstdarg>
36 #endif
38 #include <plugin/impl.hxx>
39 #include <tools/debug.hxx>
40 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
41 #include <com/sun/star/lang/XSingleServiceFactory.hpp>
42 #include <com/sun/star/container/XSet.hpp>
43 #include <com/sun/star/registry/XRegistryKey.hpp>
45 #include <uno/dispatcher.h> // declaration of generic uno interface
46 #include <uno/mapping.hxx> // mapping stuff
48 #include <cppuhelper/factory.hxx>
50 using namespace cppu;
52 extern "C" {
53 void SAL_CALL component_getImplementationEnvironment(
54 const sal_Char** ppEnvTypeName,
55 uno_Environment** /*ppEnv*/ )
57 *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME;
60 sal_Bool SAL_CALL component_writeInfo( void* /*pServiceManager*/, void* pXUnoKey )
62 if( pXUnoKey )
64 try
66 Reference< ::com::sun::star::registry::XRegistryKey > xKey( reinterpret_cast< ::com::sun::star::registry::XRegistryKey* >( pXUnoKey ) );
68 ::rtl::OUString aImplName = ::rtl::OUString::createFromAscii( "/" );
69 aImplName += XPluginManager_Impl::getImplementationName_Static();
70 aImplName += ::rtl::OUString::createFromAscii( "/UNO/SERVICES/com.sun.star.plugin.PluginManager" );
71 xKey->createKey( aImplName );
73 aImplName = ::rtl::OUString::createFromAscii( "/" );
74 aImplName += PluginModel::getImplementationName_Static();
75 aImplName += ::rtl::OUString::createFromAscii( "/UNO/SERVICES/com.sun.star.plugin.PluginModel" );
76 xKey->createKey( aImplName );
78 return sal_True;
80 catch( ::com::sun::star::registry::InvalidRegistryException& )
84 return sal_False;
87 void* SAL_CALL component_getFactory(
88 const sal_Char* pImplementationName,
89 void* pXUnoSMgr,
90 void* /*pXUnoKey*/
93 void* pRet = 0;
95 ::rtl::OUString aImplName( ::rtl::OUString::createFromAscii( pImplementationName ) );
97 if( pXUnoSMgr )
99 Reference< ::com::sun::star::lang::XMultiServiceFactory > xMgr(
100 reinterpret_cast< ::com::sun::star::lang::XMultiServiceFactory* >( pXUnoSMgr )
102 Reference< ::com::sun::star::lang::XSingleServiceFactory > xFactory;
103 if( aImplName.equals( XPluginManager_Impl::getImplementationName_Static() ) )
105 xFactory = ::cppu::createSingleFactory(
106 xMgr, aImplName, PluginManager_CreateInstance,
107 XPluginManager_Impl::getSupportedServiceNames_Static() );
109 else if( aImplName.equals( PluginModel::getImplementationName_Static() ) )
111 xFactory = ::cppu::createSingleFactory(
112 xMgr, aImplName, PluginModel_CreateInstance,
113 PluginModel::getSupportedServiceNames_Static() );
115 if( xFactory.is() )
117 xFactory->acquire();
118 pRet = xFactory.get();
121 return pRet;
123 } /* extern "C" */