1*f78e906fSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*f78e906fSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*f78e906fSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*f78e906fSAndrew Rist  * distributed with this work for additional information
6*f78e906fSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*f78e906fSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*f78e906fSAndrew Rist  * "License"); you may not use this file except in compliance
9*f78e906fSAndrew Rist  * with the License.  You may obtain a copy of the License at
10*f78e906fSAndrew Rist  *
11*f78e906fSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*f78e906fSAndrew Rist  *
13*f78e906fSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*f78e906fSAndrew Rist  * software distributed under the License is distributed on an
15*f78e906fSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*f78e906fSAndrew Rist  * KIND, either express or implied.  See the License for the
17*f78e906fSAndrew Rist  * specific language governing permissions and limitations
18*f78e906fSAndrew Rist  * under the License.
19*f78e906fSAndrew Rist  *
20*f78e906fSAndrew Rist  *************************************************************/
21*f78e906fSAndrew Rist 
22*f78e906fSAndrew Rist 
23cdf0e10cSrcweir #if defined(_MSC_VER) && (_MSC_VER > 1310)
24cdf0e10cSrcweir #pragma warning(disable : 4917 4555)
25cdf0e10cSrcweir #endif
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #ifdef __MINGW32__
28cdf0e10cSrcweir #define INITGUID
29cdf0e10cSrcweir #endif
30cdf0e10cSrcweir #include "servprov.hxx"
31cdf0e10cSrcweir #include <com/sun/star/lang/XSingleServiceFactory.hpp>
32cdf0e10cSrcweir #include <com/sun/star/lang/XMultiServiceFactory.hpp>
33cdf0e10cSrcweir #include <com/sun/star/registry/XRegistryKey.hpp>
34cdf0e10cSrcweir #include <com/sun/star/registry/InvalidRegistryException.hpp>
35cdf0e10cSrcweir #include <rtl/ustring.h>
36cdf0e10cSrcweir #include <cppuhelper/factory.hxx>
37cdf0e10cSrcweir 
38cdf0e10cSrcweir 
39cdf0e10cSrcweir using namespace ::com::sun::star;
40cdf0e10cSrcweir 
41cdf0e10cSrcweir 
EmbedServer_createInstance(const uno::Reference<lang::XMultiServiceFactory> & xSMgr)42cdf0e10cSrcweir uno::Reference<uno::XInterface> SAL_CALL EmbedServer_createInstance(
43cdf0e10cSrcweir     const uno::Reference<lang::XMultiServiceFactory> & xSMgr)
44cdf0e10cSrcweir throw (uno::Exception)
45cdf0e10cSrcweir {
46cdf0e10cSrcweir 	uno::Reference<uno::XInterface > xService = *new EmbedServer_Impl( xSMgr );
47cdf0e10cSrcweir 	return xService;
48cdf0e10cSrcweir }
49cdf0e10cSrcweir 
EmbedServer_getImplementationName()50cdf0e10cSrcweir ::rtl::OUString SAL_CALL EmbedServer_getImplementationName() throw()
51cdf0e10cSrcweir {
52cdf0e10cSrcweir 	return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.comp.ole.EmbedServer") );
53cdf0e10cSrcweir 
54cdf0e10cSrcweir }
55cdf0e10cSrcweir 
EmbedServer_getSupportedServiceNames()56cdf0e10cSrcweir uno::Sequence< ::rtl::OUString > SAL_CALL EmbedServer_getSupportedServiceNames() throw()
57cdf0e10cSrcweir {
58cdf0e10cSrcweir 	uno::Sequence< ::rtl::OUString > aServiceNames( 1 );
59cdf0e10cSrcweir 	aServiceNames[0] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.document.OleEmbeddedServerRegistration" ) );
60cdf0e10cSrcweir 	return aServiceNames;
61cdf0e10cSrcweir }
62cdf0e10cSrcweir 
63cdf0e10cSrcweir extern "C" {
64cdf0e10cSrcweir 
component_getImplementationEnvironment(const sal_Char ** ppEnvTypeName,uno_Environment **)65cdf0e10cSrcweir void SAL_CALL component_getImplementationEnvironment( const sal_Char ** ppEnvTypeName, uno_Environment ** /*ppEnv*/ )
66cdf0e10cSrcweir {
67cdf0e10cSrcweir 	*ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME;
68cdf0e10cSrcweir }
69cdf0e10cSrcweir 
component_getFactory(const sal_Char * pImplName,void * pServiceManager,void *)70cdf0e10cSrcweir void * SAL_CALL component_getFactory( const sal_Char * pImplName, void * pServiceManager, void * /*pRegistryKey*/ )
71cdf0e10cSrcweir {
72cdf0e10cSrcweir 	void * pRet = 0;
73cdf0e10cSrcweir 
74cdf0e10cSrcweir 	::rtl::OUString aImplName( ::rtl::OUString::createFromAscii( pImplName ) );
75cdf0e10cSrcweir 	uno::Reference< lang::XSingleServiceFactory > xFactory;
76cdf0e10cSrcweir 
77cdf0e10cSrcweir 	if(pServiceManager && aImplName.equals( EmbedServer_getImplementationName() ) )
78cdf0e10cSrcweir 	{
79cdf0e10cSrcweir 		xFactory= ::cppu::createOneInstanceFactory( reinterpret_cast< lang::XMultiServiceFactory*>(pServiceManager),
80cdf0e10cSrcweir 											EmbedServer_getImplementationName(),
81cdf0e10cSrcweir 											EmbedServer_createInstance,
82cdf0e10cSrcweir 											EmbedServer_getSupportedServiceNames() );
83cdf0e10cSrcweir 	}
84cdf0e10cSrcweir 
85cdf0e10cSrcweir 	if (xFactory.is())
86cdf0e10cSrcweir 	{
87cdf0e10cSrcweir 		xFactory->acquire();
88cdf0e10cSrcweir 		pRet = xFactory.get();
89cdf0e10cSrcweir 	}
90cdf0e10cSrcweir 
91cdf0e10cSrcweir 	return pRet;
92cdf0e10cSrcweir }
93cdf0e10cSrcweir 
94cdf0e10cSrcweir } // extern "C"
95cdf0e10cSrcweir 
96cdf0e10cSrcweir // Fix strange warnings about some
97cdf0e10cSrcweir // ATL::CAxHostWindow::QueryInterface|AddRef|Releae functions.
98cdf0e10cSrcweir // warning C4505: 'xxx' : unreferenced local function has been removed
99cdf0e10cSrcweir #if defined(_MSC_VER)
100cdf0e10cSrcweir #pragma warning(disable: 4505)
101cdf0e10cSrcweir #endif
102