1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: componentfactory.cxx,v $
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>
40 #include <cppuhelper/shlib.hxx>
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
;
57 Reference
< XInterface
> getComponentInstance(
58 const OUString
& rLibraryName
,
59 const OUString
& rImplementationName
62 Reference
< XInterface
> xI
;
63 Reference
< XMultiServiceFactory
> xMSF
= ::comphelper::getProcessServiceFactory();
65 xI
= xMSF
->createInstance( rImplementationName
);
68 Reference
< XSingleServiceFactory
> xSSF
=
69 loadLibComponentFactory( rLibraryName
, rImplementationName
,
70 Reference
< XMultiServiceFactory
>(), Reference
< XRegistryKey
>() );
72 xI
= xSSF
->createInstance();
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