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: services.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 #include <com/sun/star/registry/XRegistryKey.hpp>
32 #include <cppu/macros.hxx>
33 #include <cppuhelper/factory.hxx>
34 #include <rtl/ustring.hxx>
35 #include <sal/types.h>
36 #include <uno/environment.h>
38 #include "interactionhandler.hxx"
39 #include "requeststringresolver.hxx"
42 using namespace com::sun::star::uno
;
43 using namespace com::sun::star::lang
;
44 using namespace com::sun::star::registry
;
48 sal_Bool
writeInfo( void * pRegistryKey
,
49 const char * pImplementationName
,
50 Sequence
< OUString
> const & rServiceNames
)
52 OUString
aKeyName( OUString::createFromAscii( "/" ) );
53 aKeyName
+= OUString::createFromAscii( pImplementationName
);
54 aKeyName
+= OUString::createFromAscii( "/UNO/SERVICES" );
56 Reference
< XRegistryKey
> xKey
;
59 xKey
= static_cast< XRegistryKey
* >(
60 pRegistryKey
)->createKey( aKeyName
);
62 catch ( InvalidRegistryException
const & )
70 sal_Bool bSuccess
= sal_True
;
72 for ( sal_Int32 n
= 0; n
< rServiceNames
.getLength(); ++n
)
76 xKey
->createKey( rServiceNames
[ n
] );
78 catch ( InvalidRegistryException
const & )
89 //============================================================================
91 // component_getImplementationEnvironment
93 //============================================================================
95 extern "C" void SAL_CALL
96 component_getImplementationEnvironment(sal_Char
const ** pEnvTypeName
,
99 *pEnvTypeName
= CPPU_CURRENT_LANGUAGE_BINDING_NAME
;
102 //============================================================================
104 // component_writeInfo
106 //============================================================================
108 extern "C" sal_Bool SAL_CALL
component_writeInfo(void *, void * pRegistryKey
)
110 return pRegistryKey
&&
112 //////////////////////////////////////////////////////////////////////
113 // UUI Interaction Handler.
114 //////////////////////////////////////////////////////////////////////
116 writeInfo( pRegistryKey
,
117 UUIInteractionHandler::m_aImplementationName
,
118 UUIInteractionHandler::getSupportedServiceNames_static() ) &&
120 //////////////////////////////////////////////////////////////////////
121 // UUI Interaction Request String Resolver.
122 //////////////////////////////////////////////////////////////////////
124 writeInfo( pRegistryKey
,
125 UUIInteractionRequestStringResolver::m_aImplementationName
,
126 UUIInteractionRequestStringResolver::getSupportedServiceNames_static() );
129 //============================================================================
131 // component_getFactory
133 //============================================================================
135 extern "C" void * SAL_CALL
component_getFactory(sal_Char
const * pImplName
,
136 void * pServiceManager
,
144 Reference
< XMultiServiceFactory
> xSMgr(
145 reinterpret_cast< XMultiServiceFactory
* >( pServiceManager
) );
146 Reference
< XSingleServiceFactory
> xFactory
;
148 //////////////////////////////////////////////////////////////////////
149 // UUI Interaction Handler.
150 //////////////////////////////////////////////////////////////////////
152 if ( rtl_str_compare(pImplName
,
153 UUIInteractionHandler::m_aImplementationName
)
157 cppu::createSingleFactory(
158 static_cast< XMultiServiceFactory
* >(
160 OUString::createFromAscii(
161 UUIInteractionHandler::m_aImplementationName
),
162 &UUIInteractionHandler::createInstance
,
163 UUIInteractionHandler::getSupportedServiceNames_static());
166 //////////////////////////////////////////////////////////////////////
167 // UUI Interaction Request String Resolver.
168 //////////////////////////////////////////////////////////////////////
170 else if ( rtl_str_compare(pImplName
,
171 UUIInteractionRequestStringResolver::m_aImplementationName
)
175 cppu::createSingleFactory(
176 static_cast< XMultiServiceFactory
* >(
178 OUString::createFromAscii(
179 UUIInteractionRequestStringResolver::m_aImplementationName
),
180 &UUIInteractionRequestStringResolver::createInstance
,
181 UUIInteractionRequestStringResolver::getSupportedServiceNames_static());
184 //////////////////////////////////////////////////////////////////////
189 pRet
= xFactory
.get();