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: register.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 ************************************************************************/
30 #if defined(_MSC_VER) && (_MSC_VER > 1310)
31 #pragma warning(disable : 4917 4555)
37 #include "servprov.hxx"
38 #include <com/sun/star/lang/XSingleServiceFactory.hpp>
39 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
40 #include <com/sun/star/registry/XRegistryKey.hpp>
41 #include <com/sun/star/registry/InvalidRegistryException.hpp>
42 #include <rtl/ustring.h>
43 #include <cppuhelper/factory.hxx>
46 using namespace ::com::sun::star
;
49 uno::Reference
<uno::XInterface
> SAL_CALL
EmbedServer_createInstance(
50 const uno::Reference
<lang::XMultiServiceFactory
> & xSMgr
)
51 throw (uno::Exception
)
53 uno::Reference
<uno::XInterface
> xService
= *new EmbedServer_Impl( xSMgr
);
57 ::rtl::OUString SAL_CALL
EmbedServer_getImplementationName() throw()
59 return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.comp.ole.EmbedServer") );
63 uno::Sequence
< ::rtl::OUString
> SAL_CALL
EmbedServer_getSupportedServiceNames() throw()
65 uno::Sequence
< ::rtl::OUString
> aServiceNames( 1 );
66 aServiceNames
[0] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.document.OleEmbeddedServerRegistration" ) );
72 void SAL_CALL
component_getImplementationEnvironment( const sal_Char
** ppEnvTypeName
, uno_Environment
** /*ppEnv*/ )
74 *ppEnvTypeName
= CPPU_CURRENT_LANGUAGE_BINDING_NAME
;
77 void * SAL_CALL
component_getFactory( const sal_Char
* pImplName
, void * pServiceManager
, void * /*pRegistryKey*/ )
81 ::rtl::OUString
aImplName( ::rtl::OUString::createFromAscii( pImplName
) );
82 uno::Reference
< lang::XSingleServiceFactory
> xFactory
;
84 if(pServiceManager
&& aImplName
.equals( EmbedServer_getImplementationName() ) )
86 xFactory
= ::cppu::createOneInstanceFactory( reinterpret_cast< lang::XMultiServiceFactory
*>(pServiceManager
),
87 EmbedServer_getImplementationName(),
88 EmbedServer_createInstance
,
89 EmbedServer_getSupportedServiceNames() );
95 pRet
= xFactory
.get();
101 sal_Bool SAL_CALL
component_writeInfo( void * /*pServiceManager*/, void * pRegistryKey
)
107 uno::Reference
< registry::XRegistryKey
> xKey( reinterpret_cast< registry::XRegistryKey
* >( pRegistryKey
) );
109 uno::Reference
< registry::XRegistryKey
> xNewKey
;
111 xNewKey
= xKey
->createKey( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("/") ) +
112 EmbedServer_getImplementationName() +
113 ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "/UNO/SERVICES") ) );
115 uno::Sequence
< ::rtl::OUString
> rServices
= EmbedServer_getSupportedServiceNames();
116 for( sal_Int32 ind
= 0; ind
< rServices
.getLength(); ind
++ )
117 xNewKey
->createKey( rServices
.getConstArray()[ind
] );
121 catch (registry::InvalidRegistryException
&)
123 OSL_ENSURE( sal_False
, "### InvalidRegistryException!" );
131 // Fix strange warnings about some
132 // ATL::CAxHostWindow::QueryInterface|AddRef|Releae functions.
133 // warning C4505: 'xxx' : unreferenced local function has been removed
134 #if defined(_MSC_VER)
135 #pragma warning(disable: 4505)