1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_shell.hxx"
26 
27 //-----------------------------------------------------------------------
28 //	includes of other projects
29 //-----------------------------------------------------------------------
30 #include <cppuhelper/factory.hxx>
31 #include <osl/diagnose.h>
32 #include "shellexec.hxx"
33 
34 //-----------------------------------------------------------------------
35 // namespace directives
36 //-----------------------------------------------------------------------
37 
38 using namespace ::rtl;
39 using namespace ::com::sun::star::uno;
40 using namespace ::com::sun::star::lang;
41 using namespace ::com::sun::star::registry;
42 using namespace ::cppu;
43 using com::sun::star::system::XSystemShellExecute;
44 
45 //-----------------------------------------------------------------------
46 // defines
47 //-----------------------------------------------------------------------
48 
49 #define SHELLEXEC_SERVICE_NAME  "com.sun.star.system.SystemShellExecute"
50 #define SHELLEXEC_IMPL_NAME     "com.sun.star.comp.system.SystemShellExecute"
51 #define SHELLEXEC_REGKEY_NAME   "/com.sun.star.comp.system.SystemShellExecute/UNO/SERVICES/com.sun.star.system.SystemShellExecute"
52 
53 //-----------------------------------------------------------------------
54 //
55 //-----------------------------------------------------------------------
56 
57 namespace
58 {
createInstance(const Reference<XComponentContext> & xContext)59     Reference< XInterface > SAL_CALL createInstance(const Reference< XComponentContext >& xContext)
60     {
61         return Reference< XInterface >( static_cast< XSystemShellExecute* >( new ShellExec(xContext) ) );
62     }
63 }
64 
65 //-----------------------------------------------------------------------
66 // the 3 important functions which will be exported
67 //-----------------------------------------------------------------------
68 
69 extern "C"
70 {
71 
72 //----------------------------------------------------------------------
73 // component_getImplementationEnvironment
74 //----------------------------------------------------------------------
75 
component_getImplementationEnvironment(const sal_Char ** ppEnvTypeName,uno_Environment **)76 void SAL_CALL component_getImplementationEnvironment(
77 	const sal_Char ** ppEnvTypeName, uno_Environment ** /*ppEnv*/ )
78 {
79 	*ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME;
80 }
81 
82 //----------------------------------------------------------------------
83 // component_getFactory
84 //----------------------------------------------------------------------
85 
component_getFactory(const sal_Char * pImplName,uno_Interface *,uno_Interface *)86 void* SAL_CALL component_getFactory( const sal_Char* pImplName, uno_Interface* /*pSrvManager*/, uno_Interface* /*pRegistryKey*/ )
87 {
88     Reference< XSingleComponentFactory > xFactory;
89 
90     if (0 == ::rtl_str_compare( pImplName, SHELLEXEC_IMPL_NAME ))
91     {
92         OUString serviceName( RTL_CONSTASCII_USTRINGPARAM(SHELLEXEC_SERVICE_NAME) );
93 
94         xFactory = ::cppu::createSingleComponentFactory(
95             createInstance,
96             OUString( RTL_CONSTASCII_USTRINGPARAM(SHELLEXEC_IMPL_NAME) ),
97             Sequence< OUString >( &serviceName, 1 ) );
98 
99     }
100 
101     if (xFactory.is())
102 	xFactory->acquire();
103 
104     return xFactory.get();
105 }
106 
107 } // extern "C"
108