1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_shell.hxx"
30 
31 //-----------------------------------------------------------------------
32 //	includes of other projects
33 //-----------------------------------------------------------------------
34 #include <cppuhelper/factory.hxx>
35 #include <osl/diagnose.h>
36 #include "shellexec.hxx"
37 
38 //-----------------------------------------------------------------------
39 // namespace directives
40 //-----------------------------------------------------------------------
41 
42 using namespace ::rtl;
43 using namespace ::com::sun::star::uno;
44 using namespace ::com::sun::star::lang;
45 using namespace ::com::sun::star::registry;
46 using namespace ::cppu;
47 using com::sun::star::system::XSystemShellExecute;
48 
49 //-----------------------------------------------------------------------
50 // defines
51 //-----------------------------------------------------------------------
52 
53 #define SHELLEXEC_SERVICE_NAME  "com.sun.star.system.SystemShellExecute"
54 #define SHELLEXEC_IMPL_NAME     "com.sun.star.comp.system.SystemShellExecute"
55 #define SHELLEXEC_REGKEY_NAME   "/com.sun.star.comp.system.SystemShellExecute/UNO/SERVICES/com.sun.star.system.SystemShellExecute"
56 
57 //-----------------------------------------------------------------------
58 //
59 //-----------------------------------------------------------------------
60 
61 namespace
62 {
63     Reference< XInterface > SAL_CALL createInstance(const Reference< XComponentContext >& xContext)
64     {
65         return Reference< XInterface >( static_cast< XSystemShellExecute* >( new ShellExec(xContext) ) );
66     }
67 }
68 
69 //-----------------------------------------------------------------------
70 // the 3 important functions which will be exported
71 //-----------------------------------------------------------------------
72 
73 extern "C"
74 {
75 
76 //----------------------------------------------------------------------
77 // component_getImplementationEnvironment
78 //----------------------------------------------------------------------
79 
80 void SAL_CALL component_getImplementationEnvironment(
81 	const sal_Char ** ppEnvTypeName, uno_Environment ** /*ppEnv*/ )
82 {
83 	*ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME;
84 }
85 
86 //----------------------------------------------------------------------
87 // component_getFactory
88 //----------------------------------------------------------------------
89 
90 void* SAL_CALL component_getFactory( const sal_Char* pImplName, uno_Interface* /*pSrvManager*/, uno_Interface* /*pRegistryKey*/ )
91 {
92     Reference< XSingleComponentFactory > xFactory;
93 
94     if (0 == ::rtl_str_compare( pImplName, SHELLEXEC_IMPL_NAME ))
95     {
96         OUString serviceName( RTL_CONSTASCII_USTRINGPARAM(SHELLEXEC_SERVICE_NAME) );
97 
98         xFactory = ::cppu::createSingleComponentFactory(
99             createInstance,
100             OUString( RTL_CONSTASCII_USTRINGPARAM(SHELLEXEC_IMPL_NAME) ),
101             Sequence< OUString >( &serviceName, 1 ) );
102 
103     }
104 
105     if (xFactory.is())
106 	xFactory->acquire();
107 
108     return xFactory.get();
109 }
110 
111 } // extern "C"
112