xref: /trunk/main/extensions/source/ole/servreg.cxx (revision 1ecadb572e7010ff3b3382ad9bf179dbc6efadbb)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
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.
14  *
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).
20  *
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.
25  *
26  ************************************************************************/
27 
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_extensions.hxx"
30 #include <rtl/unload.h>
31 #include <osl/time.h>
32 #include "ole2uno.hxx"
33 #include "servprov.hxx"
34 #include <rtl/ustring.hxx>
35 #include <cppuhelper/factory.hxx>
36 using namespace rtl;
37 using namespace ole_adapter;
38 using namespace cppu;
39 
40 namespace ole_adapter
41 {
42 rtl_StandardModuleCount globalModuleCount= MODULE_COUNT_INIT;
43 
44 
45 
46 Reference<XInterface> SAL_CALL ConverterProvider_CreateInstance2(   const Reference<XMultiServiceFactory> & xSMgr)
47                             throw(Exception)
48 {
49     Reference<XInterface> xService = *new OleConverter_Impl2( xSMgr);
50     return xService;
51 }
52 
53 Reference<XInterface> SAL_CALL ConverterProvider_CreateInstanceVar1(    const Reference<XMultiServiceFactory> & xSMgr)
54                             throw(Exception)
55 {
56     Reference<XInterface> xService = *new OleConverter_Impl2( xSMgr, UNO_OBJECT_WRAPPER_REMOTE_OPT, IUNKNOWN_WRAPPER_IMPL);
57     return xService;
58 }
59 
60 Reference<XInterface> SAL_CALL OleClient_CreateInstance( const Reference<XMultiServiceFactory> & xSMgr)
61                             throw(Exception)
62 {
63     Reference<XInterface> xService = *new OleClient_Impl( xSMgr);
64     return xService;
65 }
66 
67 Reference<XInterface> SAL_CALL OleServer_CreateInstance( const Reference<XMultiServiceFactory> & xSMgr)
68                             throw (Exception)
69 {
70     Reference<XInterface > xService = *new OleServer_Impl(xSMgr);
71     return xService;
72 }
73 } // end namespace
74 
75 extern "C" void * SAL_CALL component_getFactory(
76     const sal_Char * pImplName, void * pServiceManager, void * /*pRegistryKey*/ )
77 {
78     void * pRet = 0;
79 
80     OUString aImplName( OUString::createFromAscii( pImplName ) );
81     Reference< XSingleServiceFactory > xFactory;
82     Sequence<OUString> seqServiceNames;
83     if (pServiceManager && aImplName.equals(  reinterpret_cast<const sal_Unicode*>(L"com.sun.star.comp.ole.OleConverter2")  ))
84     {
85         xFactory=  createSingleFactory( reinterpret_cast< XMultiServiceFactory*>(pServiceManager),
86                                          OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.comp.ole.OleConverter2")),
87                                          ConverterProvider_CreateInstance2, seqServiceNames,
88                                          &globalModuleCount.modCnt );
89     }
90     else if (pServiceManager && aImplName.equals(  reinterpret_cast<const sal_Unicode*>(L"com.sun.star.comp.ole.OleConverterVar1")  ))
91     {
92         xFactory= createSingleFactory( reinterpret_cast<XMultiServiceFactory*>(pServiceManager),
93                                        OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.comp.ole.OleConverterVar1")),
94                                        ConverterProvider_CreateInstanceVar1, seqServiceNames,
95                                        &globalModuleCount.modCnt );
96     }
97     else if(pServiceManager && aImplName.equals(reinterpret_cast<const sal_Unicode*>(L"com.sun.star.comp.ole.OleClient")))
98     {
99         xFactory= createSingleFactory( reinterpret_cast< XMultiServiceFactory*>(pServiceManager),
100                                        OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.comp.ole.OleClient")),
101                                        OleClient_CreateInstance, seqServiceNames,
102                                        &globalModuleCount.modCnt);
103     }
104     else if(pServiceManager && aImplName.equals(reinterpret_cast<const sal_Unicode*>(L"com.sun.star.comp.ole.OleServer")))
105     {
106         xFactory= createOneInstanceFactory( reinterpret_cast< XMultiServiceFactory*>(pServiceManager),
107                                             OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.comp.ole.OleServer")),
108                                             OleServer_CreateInstance, seqServiceNames,
109                                             &globalModuleCount.modCnt);
110     }
111 
112     if (xFactory.is())
113     {
114         xFactory->acquire();
115         pRet = xFactory.get();
116     }
117 
118     return pRet;
119 }
120 
121 
122 extern "C" void SAL_CALL component_getImplementationEnvironment(
123     const sal_Char ** ppEnvTypeName, uno_Environment ** /*ppEnv*/ )
124 {
125     *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME;
126 }
127 
128 
129 extern "C"  sal_Bool component_canUnload( TimeValue* libUnused)
130 {
131     return globalModuleCount.canUnload( &globalModuleCount, libUnused);
132 }
133