1 /*************************************************************************
3 * $RCSfile: component.cxx,v $
7 * last change: $Author: rt $ $Date: 2008-04-10 16:28:46 $
9 * The Contents of this file are made available subject to the terms of
12 * Copyright (c) 2003 by Sun Microsystems, Inc.
13 * All rights reserved.
15 * Redistribution and use in source and binary forms, with or without
16 * modification, are permitted provided that the following conditions
18 * 1. Redistributions of source code must retain the above copyright
19 * notice, this list of conditions and the following disclaimer.
20 * 2. Redistributions in binary form must reproduce the above copyright
21 * notice, this list of conditions and the following disclaimer in the
22 * documentation and/or other materials provided with the distribution.
23 * 3. Neither the name of Sun Microsystems, Inc. nor the names of its
24 * contributors may be used to endorse or promote products derived
25 * from this software without specific prior written permission.
27 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
28 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
29 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
30 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
31 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
32 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
33 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
34 * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
35 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
36 * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
37 * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
39 *************************************************************************/
42 #include <rtl/ustring.hxx>
43 #include <cppuhelper/queryinterface.hxx> // helper for queryInterface() impl
44 #include <cppuhelper/factory.hxx> // helper for component factory
45 // generated c++ interfaces
46 #include <com/sun/star/lang/XSingleServiceFactory.hpp>
47 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
48 #include <com/sun/star/lang/XServiceInfo.hpp>
49 #include <com/sun/star/registry/XRegistryKey.hpp>
51 // include our specific addon header to get access to functions and definitions
54 using namespace ::rtl
;
55 using namespace ::osl
;
56 using namespace ::cppu
;
57 using namespace ::com::sun::star::uno
;
58 using namespace ::com::sun::star::lang
;
59 using namespace ::com::sun::star::registry
;
61 //##################################################################################################
62 //#### EXPORTED ####################################################################################
63 //##################################################################################################
67 * Gives the environment this component belongs to.
69 extern "C" void SAL_CALL
component_getImplementationEnvironment(const sal_Char
** ppEnvTypeName
, uno_Environment
** ppEnv
)
71 *ppEnvTypeName
= CPPU_CURRENT_LANGUAGE_BINDING_NAME
;
75 * This function creates an implementation section in the registry and another subkey
77 * for each supported service.
78 * @param pServiceManager the service manager
79 * @param pRegistryKey the registry key
81 extern "C" sal_Bool SAL_CALL
component_writeInfo(void * pServiceManager
, void * pRegistryKey
)
83 sal_Bool result
= sal_False
;
89 Reference
< XRegistryKey
> xNewKey(
90 reinterpret_cast< XRegistryKey
* >( pRegistryKey
)->createKey(
91 OUString( RTL_CONSTASCII_USTRINGPARAM("/" IMPLEMENTATION_NAME
"/UNO/SERVICES") ) ) );
93 const Sequence
< OUString
> & rSNL
=
94 Addon_getSupportedServiceNames();
95 const OUString
* pArray
= rSNL
.getConstArray();
96 for ( sal_Int32 nPos
= rSNL
.getLength(); nPos
--; )
97 xNewKey
->createKey( pArray
[nPos
] );
101 catch (InvalidRegistryException
&)
103 // we should not ignore exceptions
110 * This function is called to get service factories for an implementation.
112 * @param pImplName name of implementation
113 * @param pServiceManager a service manager, need for component creation
114 * @param pRegistryKey the registry key for this component, need for persistent data
115 * @return a component factory
117 extern "C" void * SAL_CALL
component_getFactory(const sal_Char
* pImplName
, void * pServiceManager
, void * pRegistryKey
)
121 if (rtl_str_compare( pImplName
, IMPLEMENTATION_NAME
) == 0)
123 Reference
< XSingleServiceFactory
> xFactory( createSingleFactory(
124 reinterpret_cast< XMultiServiceFactory
* >( pServiceManager
),
125 OUString( RTL_CONSTASCII_USTRINGPARAM( IMPLEMENTATION_NAME
) ),
126 Addon_createInstance
,
127 Addon_getSupportedServiceNames() ) );
132 pRet
= xFactory
.get();