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