merge the formfield patch from ooo-build
[ooovba.git] / shell / source / unix / exec / shellexecentry.cxx
blob5ef8c34651131bc07b8e68765131ec4b3cbc4e11
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: shellexecentry.cxx,v $
10 * $Revision: 1.6 $
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_shell.hxx"
34 //-----------------------------------------------------------------------
35 // includes of other projects
36 //-----------------------------------------------------------------------
37 #include <cppuhelper/factory.hxx>
38 #include <osl/diagnose.h>
39 #include "shellexec.hxx"
41 //-----------------------------------------------------------------------
42 // namespace directives
43 //-----------------------------------------------------------------------
45 using namespace ::rtl;
46 using namespace ::com::sun::star::uno;
47 using namespace ::com::sun::star::lang;
48 using namespace ::com::sun::star::registry;
49 using namespace ::cppu;
50 using com::sun::star::system::XSystemShellExecute;
52 //-----------------------------------------------------------------------
53 // defines
54 //-----------------------------------------------------------------------
56 #define SHELLEXEC_SERVICE_NAME "com.sun.star.system.SystemShellExecute"
57 #define SHELLEXEC_IMPL_NAME "com.sun.star.comp.system.SystemShellExecute"
58 #define SHELLEXEC_REGKEY_NAME "/com.sun.star.comp.system.SystemShellExecute/UNO/SERVICES/com.sun.star.system.SystemShellExecute"
60 //-----------------------------------------------------------------------
61 //
62 //-----------------------------------------------------------------------
64 namespace
66 Reference< XInterface > SAL_CALL createInstance(const Reference< XComponentContext >& xContext)
68 return Reference< XInterface >( static_cast< XSystemShellExecute* >( new ShellExec(xContext) ) );
72 //-----------------------------------------------------------------------
73 // the 3 important functions which will be exported
74 //-----------------------------------------------------------------------
76 extern "C"
79 //----------------------------------------------------------------------
80 // component_getImplementationEnvironment
81 //----------------------------------------------------------------------
83 void SAL_CALL component_getImplementationEnvironment(
84 const sal_Char ** ppEnvTypeName, uno_Environment ** /*ppEnv*/ )
86 *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME;
89 //-----------------------------------------------------------------------
90 // component_writeInfo
91 //-----------------------------------------------------------------------
93 sal_Bool SAL_CALL component_writeInfo( void* /*pServiceManager*/, void* pRegistryKey )
95 if (pRegistryKey)
97 try
99 Reference< XRegistryKey > pXNewKey( static_cast< XRegistryKey* >( pRegistryKey ) );
100 pXNewKey->createKey( OUString( RTL_CONSTASCII_USTRINGPARAM( SHELLEXEC_REGKEY_NAME ) ) );
101 return sal_True;
103 catch( InvalidRegistryException& )
105 OSL_ENSURE(sal_False, "InvalidRegistryException caught");
109 return sal_False;
112 //----------------------------------------------------------------------
113 // component_getFactory
114 //----------------------------------------------------------------------
116 void* SAL_CALL component_getFactory( const sal_Char* pImplName, uno_Interface* /*pSrvManager*/, uno_Interface* /*pRegistryKey*/ )
118 Reference< XSingleComponentFactory > xFactory;
120 if (0 == ::rtl_str_compare( pImplName, SHELLEXEC_IMPL_NAME ))
122 OUString serviceName( RTL_CONSTASCII_USTRINGPARAM(SHELLEXEC_SERVICE_NAME) );
124 xFactory = ::cppu::createSingleComponentFactory(
125 createInstance,
126 OUString( RTL_CONSTASCII_USTRINGPARAM(SHELLEXEC_IMPL_NAME) ),
127 Sequence< OUString >( &serviceName, 1 ) );
131 if (xFactory.is())
132 xFactory->acquire();
134 return xFactory.get();
137 } // extern "C"