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 <com/sun/star/container/XSet.hpp>
32 #include <osl/diagnose.h>
33 #include "SysShExec.hxx"
34
35 //-----------------------------------------------------------------------
36 // namespace directives
37 //-----------------------------------------------------------------------
38
39 using namespace ::rtl ;
40 using namespace ::com::sun::star::uno ;
41 using namespace ::com::sun::star::container ;
42 using namespace ::com::sun::star::lang ;
43 using namespace ::com::sun::star::registry ;
44 using namespace ::cppu ;
45 using com::sun::star::system::XSystemShellExecute;
46
47 //-----------------------------------------------------------------------
48 // defines
49 //-----------------------------------------------------------------------
50
51 #define SYSSHEXEC_SERVICE_NAME "com.sun.star.system.SystemShellExecute"
52 #define SYSSHEXEC_IMPL_NAME "com.sun.star.system.SystemShellExecute"
53 #define SYSSHEXEC_REGKEY_NAME "/com.sun.star.system.SystemShellExecute/UNO/SERVICES/com.sun.star.system.SystemShellExecute"
54
55 //-----------------------------------------------------------------------
56 //
57 //-----------------------------------------------------------------------
58
59 namespace
60 {
createInstance(const Reference<XMultiServiceFactory> &)61 Reference< XInterface > SAL_CALL createInstance( const Reference< XMultiServiceFactory >& )
62 {
63 return Reference< XInterface >( static_cast< XSystemShellExecute* >( new CSysShExec( ) ) );
64 }
65 }
66
67 //-----------------------------------------------------------------------
68 // the 3 important functions which will be exported
69 //-----------------------------------------------------------------------
70
71 extern "C"
72 {
73
74 //----------------------------------------------------------------------
75 // component_getImplementationEnvironment
76 //----------------------------------------------------------------------
77
component_getImplementationEnvironment(const sal_Char ** ppEnvTypeName,uno_Environment **)78 void SAL_CALL component_getImplementationEnvironment(
79 const sal_Char ** ppEnvTypeName, uno_Environment ** /*ppEnv*/ )
80 {
81 *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME ":affine";
82 }
83
84 //----------------------------------------------------------------------
85 // component_getFactory
86 // returns a factory to create XFilePicker-Services
87 //----------------------------------------------------------------------
88
component_getFactory(const sal_Char * pImplName,uno_Interface * pSrvManager,uno_Interface *)89 void* SAL_CALL component_getFactory( const sal_Char* pImplName, uno_Interface* pSrvManager, uno_Interface* /*pRegistryKey*/ )
90 {
91 void* pRet = 0;
92
93 if ( pSrvManager && ( 0 == rtl_str_compare( pImplName, SYSSHEXEC_IMPL_NAME ) ) )
94 {
95 Sequence< OUString > aSNS( 1 );
96 aSNS.getArray( )[0] = OUString::createFromAscii( SYSSHEXEC_SERVICE_NAME );
97
98 Reference< XSingleServiceFactory > xFactory ( createOneInstanceFactory(
99 reinterpret_cast< XMultiServiceFactory* > ( pSrvManager ),
100 OUString::createFromAscii( pImplName ),
101 createInstance,
102 aSNS ) );
103 if ( xFactory.is() )
104 {
105 xFactory->acquire();
106 pRet = xFactory.get();
107 }
108 }
109
110 return pRet;
111 }
112
113 } // extern "C"
114