Version 4.2.0.1, tag libreoffice-4.2.0.1
[LibreOffice.git] / embeddedobj / test / mtexecutor / mteregister.cxx
blobd3fffbb0369965329649371b71a8cfd9b639ffe6
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <com/sun/star/registry/XRegistryKey.hpp>
21 #include <com/sun/star/registry/InvalidRegistryException.hpp>
22 #include <cppuhelper/factory.hxx>
24 #include "mainthreadexecutor.hxx"
25 #include "bitmapcreator.hxx"
27 using namespace ::com::sun::star;
30 extern "C" {
32 SAL_DLLPUBLIC_EXPORT void * SAL_CALL component_getFactory( const sal_Char * pImplName, void * pServiceManager, void * pRegistryKey )
34 void * pRet = 0;
36 OUString aImplName( OUString::createFromAscii( pImplName ) );
37 uno::Reference< lang::XSingleServiceFactory > xFactory;
39 if ( pServiceManager )
41 if ( aImplName.equals( MainThreadExecutor::impl_staticGetImplementationName() ) )
43 xFactory= ::cppu::createOneInstanceFactory( reinterpret_cast< lang::XMultiServiceFactory*>( pServiceManager ),
44 MainThreadExecutor::impl_staticGetImplementationName(),
45 MainThreadExecutor::impl_staticCreateSelfInstance,
46 MainThreadExecutor::impl_staticGetSupportedServiceNames() );
48 else if ( aImplName.equals( VCLBitmapCreator::impl_staticGetImplementationName() ) )
50 xFactory= ::cppu::createOneInstanceFactory( reinterpret_cast< lang::XMultiServiceFactory*>( pServiceManager ),
51 VCLBitmapCreator::impl_staticGetImplementationName(),
52 VCLBitmapCreator::impl_staticCreateSelfInstance,
53 VCLBitmapCreator::impl_staticGetSupportedServiceNames() );
57 if ( xFactory.is() )
59 xFactory->acquire();
60 pRet = xFactory.get();
64 return pRet;
67 sal_Bool SAL_CALL component_writeInfo( void * pServiceManager, void * pRegistryKey )
69 if (pRegistryKey)
71 try
73 uno::Reference< registry::XRegistryKey > xKey( reinterpret_cast< registry::XRegistryKey* >( pRegistryKey ) );
75 uno::Reference< registry::XRegistryKey > xNewKey;
76 uno::Sequence< OUString > rServices;
77 sal_Int32 ind = 0;
79 xNewKey = xKey->createKey( OUString("/") +
80 MainThreadExecutor::impl_staticGetImplementationName() +
81 OUString( "/UNO/SERVICES") );
83 rServices = MainThreadExecutor::impl_staticGetSupportedServiceNames();
84 for( ind = 0; ind < rServices.getLength(); ind++ )
85 xNewKey->createKey( rServices.getConstArray()[ind] );
87 xNewKey = xKey->createKey( OUString("/") +
88 VCLBitmapCreator::impl_staticGetImplementationName() +
89 OUString( "/UNO/SERVICES") );
91 rServices = VCLBitmapCreator::impl_staticGetSupportedServiceNames();
92 for( ind = 0; ind < rServices.getLength(); ind++ )
93 xNewKey->createKey( rServices.getConstArray()[ind] );
95 return sal_True;
97 catch (registry::InvalidRegistryException &)
99 OSL_FAIL( "### InvalidRegistryException!" );
102 return sal_False;
105 } // extern "C"
107 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */