merge the formfield patch from ooo-build
[ooovba.git] / comphelper / source / processfactory / componentfactory.cxx
blobefa05000c7158a1735a61a98982f064d2184d457
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: componentfactory.cxx,v $
10 * $Revision: 1.7 $
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_comphelper.hxx"
33 #include <comphelper/componentfactory.hxx>
34 #include <comphelper/processfactory.hxx>
35 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
37 #ifndef _COM_SUN_STAR_REGISTRY_XREGISTRYKEY_HDL_
38 #include <com/sun/star/registry/XRegistryKey.hpp>
39 #endif
40 #include <cppuhelper/shlib.hxx>
43 #ifndef GCC
44 #endif
47 using namespace ::com::sun::star;
48 using namespace ::com::sun::star::uno;
49 using namespace ::com::sun::star::lang;
50 using namespace ::com::sun::star::registry;
51 using namespace ::rtl;
54 namespace comphelper
57 Reference< XInterface > getComponentInstance(
58 const OUString & rLibraryName,
59 const OUString & rImplementationName
62 Reference< XInterface > xI;
63 Reference< XMultiServiceFactory > xMSF = ::comphelper::getProcessServiceFactory();
64 if ( xMSF.is() )
65 xI = xMSF->createInstance( rImplementationName );
66 if( !xI.is() )
68 Reference< XSingleServiceFactory > xSSF =
69 loadLibComponentFactory( rLibraryName, rImplementationName,
70 Reference< XMultiServiceFactory >(), Reference< XRegistryKey >() );
71 if (xSSF.is())
72 xI = xSSF->createInstance();
74 return xI;
78 Reference< XSingleServiceFactory > loadLibComponentFactory(
79 const OUString & rLibName,
80 const OUString & rImplName,
81 const Reference< XMultiServiceFactory > & xSF,
82 const Reference< XRegistryKey > & xKey
85 return Reference< XSingleServiceFactory >( ::cppu::loadSharedLibComponentFactory(
86 rLibName, OUString(), rImplName, xSF, xKey ), UNO_QUERY );
89 } // namespace comphelper