xref: /AOO42X/main/embeddedobj/test/mtexecutor/mteregister.cxx (revision b1c5455db1639c48e26c568e4fa7ee78ca5d60ee)
1*bfd08df8SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*bfd08df8SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*bfd08df8SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*bfd08df8SAndrew Rist  * distributed with this work for additional information
6*bfd08df8SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*bfd08df8SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*bfd08df8SAndrew Rist  * "License"); you may not use this file except in compliance
9*bfd08df8SAndrew Rist  * with the License.  You may obtain a copy of the License at
10cdf0e10cSrcweir  *
11*bfd08df8SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir  *
13*bfd08df8SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*bfd08df8SAndrew Rist  * software distributed under the License is distributed on an
15*bfd08df8SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*bfd08df8SAndrew Rist  * KIND, either express or implied.  See the License for the
17*bfd08df8SAndrew Rist  * specific language governing permissions and limitations
18*bfd08df8SAndrew Rist  * under the License.
19cdf0e10cSrcweir  *
20*bfd08df8SAndrew Rist  *************************************************************/
21*bfd08df8SAndrew Rist 
22*bfd08df8SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_embeddedobj.hxx"
26cdf0e10cSrcweir 
27cdf0e10cSrcweir 
28cdf0e10cSrcweir #include <com/sun/star/registry/XRegistryKey.hpp>
29cdf0e10cSrcweir #include <com/sun/star/registry/InvalidRegistryException.hpp>
30cdf0e10cSrcweir #include <cppuhelper/factory.hxx>
31cdf0e10cSrcweir 
32cdf0e10cSrcweir #include "mainthreadexecutor.hxx"
33cdf0e10cSrcweir #include "bitmapcreator.hxx"
34cdf0e10cSrcweir 
35cdf0e10cSrcweir using namespace ::com::sun::star;
36cdf0e10cSrcweir 
37cdf0e10cSrcweir 
38cdf0e10cSrcweir extern "C" {
39cdf0e10cSrcweir 
component_getImplementationEnvironment(const sal_Char ** ppEnvTypeName,uno_Environment ** ppEnv)40cdf0e10cSrcweir void SAL_CALL component_getImplementationEnvironment( const sal_Char ** ppEnvTypeName, uno_Environment ** ppEnv )
41cdf0e10cSrcweir {
42cdf0e10cSrcweir     *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME;
43cdf0e10cSrcweir }
44cdf0e10cSrcweir 
component_getFactory(const sal_Char * pImplName,void * pServiceManager,void * pRegistryKey)45cdf0e10cSrcweir void * SAL_CALL component_getFactory( const sal_Char * pImplName, void * pServiceManager, void * pRegistryKey )
46cdf0e10cSrcweir {
47cdf0e10cSrcweir     void * pRet = 0;
48cdf0e10cSrcweir 
49cdf0e10cSrcweir     ::rtl::OUString aImplName( ::rtl::OUString::createFromAscii( pImplName ) );
50cdf0e10cSrcweir     uno::Reference< lang::XSingleServiceFactory > xFactory;
51cdf0e10cSrcweir 
52cdf0e10cSrcweir     if ( pServiceManager )
53cdf0e10cSrcweir     {
54cdf0e10cSrcweir         if ( aImplName.equals( MainThreadExecutor::impl_staticGetImplementationName() ) )
55cdf0e10cSrcweir         {
56cdf0e10cSrcweir             xFactory= ::cppu::createOneInstanceFactory( reinterpret_cast< lang::XMultiServiceFactory*>( pServiceManager ),
57cdf0e10cSrcweir                                                 MainThreadExecutor::impl_staticGetImplementationName(),
58cdf0e10cSrcweir                                                 MainThreadExecutor::impl_staticCreateSelfInstance,
59cdf0e10cSrcweir                                                 MainThreadExecutor::impl_staticGetSupportedServiceNames() );
60cdf0e10cSrcweir         }
61cdf0e10cSrcweir         else if ( aImplName.equals( VCLBitmapCreator::impl_staticGetImplementationName() ) )
62cdf0e10cSrcweir         {
63cdf0e10cSrcweir             xFactory= ::cppu::createOneInstanceFactory( reinterpret_cast< lang::XMultiServiceFactory*>( pServiceManager ),
64cdf0e10cSrcweir                                                 VCLBitmapCreator::impl_staticGetImplementationName(),
65cdf0e10cSrcweir                                                 VCLBitmapCreator::impl_staticCreateSelfInstance,
66cdf0e10cSrcweir                                                 VCLBitmapCreator::impl_staticGetSupportedServiceNames() );
67cdf0e10cSrcweir 
68cdf0e10cSrcweir         }
69cdf0e10cSrcweir 
70cdf0e10cSrcweir         if ( xFactory.is() )
71cdf0e10cSrcweir         {
72cdf0e10cSrcweir             xFactory->acquire();
73cdf0e10cSrcweir             pRet = xFactory.get();
74cdf0e10cSrcweir         }
75cdf0e10cSrcweir     }
76cdf0e10cSrcweir 
77cdf0e10cSrcweir     return pRet;
78cdf0e10cSrcweir }
79cdf0e10cSrcweir 
component_writeInfo(void * pServiceManager,void * pRegistryKey)80cdf0e10cSrcweir sal_Bool SAL_CALL component_writeInfo( void * pServiceManager, void * pRegistryKey )
81cdf0e10cSrcweir {
82cdf0e10cSrcweir     if (pRegistryKey)
83cdf0e10cSrcweir     {
84cdf0e10cSrcweir         try
85cdf0e10cSrcweir         {
86cdf0e10cSrcweir             uno::Reference< registry::XRegistryKey > xKey( reinterpret_cast< registry::XRegistryKey* >( pRegistryKey ) );
87cdf0e10cSrcweir 
88cdf0e10cSrcweir             uno::Reference< registry::XRegistryKey >  xNewKey;
89cdf0e10cSrcweir             uno::Sequence< ::rtl::OUString > rServices;
90cdf0e10cSrcweir             sal_Int32 ind = 0;
91cdf0e10cSrcweir 
92cdf0e10cSrcweir             xNewKey = xKey->createKey( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("/") ) +
93cdf0e10cSrcweir                                         MainThreadExecutor::impl_staticGetImplementationName() +
94cdf0e10cSrcweir                                         ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "/UNO/SERVICES") )  );
95cdf0e10cSrcweir 
96cdf0e10cSrcweir             rServices = MainThreadExecutor::impl_staticGetSupportedServiceNames();
97cdf0e10cSrcweir             for( ind = 0; ind < rServices.getLength(); ind++ )
98cdf0e10cSrcweir                 xNewKey->createKey( rServices.getConstArray()[ind] );
99cdf0e10cSrcweir 
100cdf0e10cSrcweir             xNewKey = xKey->createKey( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("/") ) +
101cdf0e10cSrcweir                                         VCLBitmapCreator::impl_staticGetImplementationName() +
102cdf0e10cSrcweir                                         ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "/UNO/SERVICES") )  );
103cdf0e10cSrcweir 
104cdf0e10cSrcweir             rServices = VCLBitmapCreator::impl_staticGetSupportedServiceNames();
105cdf0e10cSrcweir             for( ind = 0; ind < rServices.getLength(); ind++ )
106cdf0e10cSrcweir                 xNewKey->createKey( rServices.getConstArray()[ind] );
107cdf0e10cSrcweir 
108cdf0e10cSrcweir             return sal_True;
109cdf0e10cSrcweir         }
110cdf0e10cSrcweir         catch (registry::InvalidRegistryException &)
111cdf0e10cSrcweir         {
112cdf0e10cSrcweir             OSL_ENSURE( sal_False, "### InvalidRegistryException!" );
113cdf0e10cSrcweir         }
114cdf0e10cSrcweir     }
115cdf0e10cSrcweir     return sal_False;
116cdf0e10cSrcweir }
117cdf0e10cSrcweir 
118cdf0e10cSrcweir } // extern "C"
119