merge the formfield patch from ooo-build
[ooovba.git] / shell / source / win32 / SysShentry.cxx
blob0e2549615d61b025945c82c9860cb1472aa3cee3
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: SysShentry.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 <com/sun/star/container/XSet.hpp>
39 #include <osl/diagnose.h>
40 #include "SysShExec.hxx"
42 //-----------------------------------------------------------------------
43 // namespace directives
44 //-----------------------------------------------------------------------
46 using namespace ::rtl ;
47 using namespace ::com::sun::star::uno ;
48 using namespace ::com::sun::star::container ;
49 using namespace ::com::sun::star::lang ;
50 using namespace ::com::sun::star::registry ;
51 using namespace ::cppu ;
52 using com::sun::star::system::XSystemShellExecute;
54 //-----------------------------------------------------------------------
55 // defines
56 //-----------------------------------------------------------------------
58 #define SYSSHEXEC_SERVICE_NAME "com.sun.star.system.SystemShellExecute"
59 #define SYSSHEXEC_IMPL_NAME "com.sun.star.system.SystemShellExecute"
60 #define SYSSHEXEC_REGKEY_NAME "/com.sun.star.system.SystemShellExecute/UNO/SERVICES/com.sun.star.system.SystemShellExecute"
62 //-----------------------------------------------------------------------
63 //
64 //-----------------------------------------------------------------------
66 namespace
68 Reference< XInterface > SAL_CALL createInstance( const Reference< XMultiServiceFactory >& )
70 return Reference< XInterface >( static_cast< XSystemShellExecute* >( new CSysShExec( ) ) );
74 //-----------------------------------------------------------------------
75 // the 3 important functions which will be exported
76 //-----------------------------------------------------------------------
78 extern "C"
81 //----------------------------------------------------------------------
82 // component_getImplementationEnvironment
83 //----------------------------------------------------------------------
85 void SAL_CALL component_getImplementationEnvironment(
86 const sal_Char ** ppEnvTypeName, uno_Environment ** /*ppEnv*/ )
88 *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME ":affine";
91 //-----------------------------------------------------------------------
93 //-----------------------------------------------------------------------
95 sal_Bool SAL_CALL component_writeInfo( void* /*pServiceManager*/, void* pRegistryKey )
97 sal_Bool bRetVal = sal_True;
99 if ( pRegistryKey )
103 Reference< XRegistryKey > pXNewKey( static_cast< XRegistryKey* >( pRegistryKey ) );
104 pXNewKey->createKey(
105 OUString::createFromAscii( SYSSHEXEC_REGKEY_NAME ) );
107 catch( InvalidRegistryException& )
109 OSL_ENSURE(sal_False, "InvalidRegistryException caught");
110 bRetVal = sal_False;
114 return bRetVal;
117 //----------------------------------------------------------------------
118 // component_getFactory
119 // returns a factory to create XFilePicker-Services
120 //----------------------------------------------------------------------
122 void* SAL_CALL component_getFactory( const sal_Char* pImplName, uno_Interface* pSrvManager, uno_Interface* /*pRegistryKey*/ )
124 void* pRet = 0;
126 if ( pSrvManager && ( 0 == rtl_str_compare( pImplName, SYSSHEXEC_IMPL_NAME ) ) )
128 Sequence< OUString > aSNS( 1 );
129 aSNS.getArray( )[0] = OUString::createFromAscii( SYSSHEXEC_SERVICE_NAME );
131 Reference< XSingleServiceFactory > xFactory ( createOneInstanceFactory(
132 reinterpret_cast< XMultiServiceFactory* > ( pSrvManager ),
133 OUString::createFromAscii( pImplName ),
134 createInstance,
135 aSNS ) );
136 if ( xFactory.is() )
138 xFactory->acquire();
139 pRet = xFactory.get();
143 return pRet;
146 } // extern "C"