update dev300-m58
[ooovba.git] / extensions / source / scanner / scnserv.cxx
blob6632a19c63c09e7e61bf582110ecc662085c7d5e
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: scnserv.cxx,v $
10 * $Revision: 1.6 $
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 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_extensions.hxx"
33 #include <osl/diagnose.h>
34 #include <cppuhelper/factory.hxx>
35 #include <uno/mapping.hxx>
36 #include "scanner.hxx"
38 #include <com/sun/star/registry/XRegistryKey.hpp>
40 using namespace com::sun::star::registry;
42 // ------------------------------------------
43 // - component_getImplementationEnvironment -
44 // ------------------------------------------
46 extern "C" void SAL_CALL component_getImplementationEnvironment( const sal_Char** ppEnvTypeName, uno_Environment** /*ppEnv*/ )
48 *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME;
51 // -----------------------
52 // - component_writeInfo -
53 // -----------------------
55 extern "C" sal_Bool SAL_CALL component_writeInfo( void* /*pServiceManager*/, void* pRegistryKey )
57 sal_Bool bRet = sal_False;
59 if( pRegistryKey )
61 try
63 ::rtl::OUString aImplName( '/' );
65 aImplName += ScannerManager::getImplementationName_Static();
66 aImplName += ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "/UNO/SERVICES/" ) );
67 aImplName += ScannerManager::getImplementationName_Static();
69 REF( XRegistryKey ) xNewKey1( static_cast< XRegistryKey* >( pRegistryKey )->createKey( aImplName ) );
71 bRet = sal_True;
73 catch( InvalidRegistryException& )
75 OSL_ENSURE( sal_False, "### InvalidRegistryException!" );
79 return bRet;
82 // ------------------------
83 // - component_getFactory -
84 // ------------------------
86 extern "C" void* SAL_CALL component_getFactory( const sal_Char* pImplName, void* pServiceManager, void* /*pRegistryKey*/ )
88 REF( ::com::sun::star::lang::XSingleServiceFactory ) xFactory;
89 void* pRet = 0;
91 if( ::rtl::OUString::createFromAscii( pImplName ) == ScannerManager::getImplementationName_Static() )
93 xFactory = REF( ::com::sun::star::lang::XSingleServiceFactory )( ::cppu::createSingleFactory(
94 static_cast< ::com::sun::star::lang::XMultiServiceFactory* >( pServiceManager ),
95 ScannerManager::getImplementationName_Static(),
96 ScannerManager_CreateInstance,
97 ScannerManager::getSupportedServiceNames_Static() ) );
100 if( xFactory.is() )
102 xFactory->acquire();
103 pRet = xFactory.get();
106 return pRet;