1*f8e2c85aSAndrew Rist /**************************************************************
2cdf0e10cSrcweir *
3*f8e2c85aSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
4*f8e2c85aSAndrew Rist * or more contributor license agreements. See the NOTICE file
5*f8e2c85aSAndrew Rist * distributed with this work for additional information
6*f8e2c85aSAndrew Rist * regarding copyright ownership. The ASF licenses this file
7*f8e2c85aSAndrew Rist * to you under the Apache License, Version 2.0 (the
8*f8e2c85aSAndrew Rist * "License"); you may not use this file except in compliance
9*f8e2c85aSAndrew Rist * with the License. You may obtain a copy of the License at
10*f8e2c85aSAndrew Rist *
11*f8e2c85aSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
12*f8e2c85aSAndrew Rist *
13*f8e2c85aSAndrew Rist * Unless required by applicable law or agreed to in writing,
14*f8e2c85aSAndrew Rist * software distributed under the License is distributed on an
15*f8e2c85aSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*f8e2c85aSAndrew Rist * KIND, either express or implied. See the License for the
17*f8e2c85aSAndrew Rist * specific language governing permissions and limitations
18*f8e2c85aSAndrew Rist * under the License.
19*f8e2c85aSAndrew Rist *
20*f8e2c85aSAndrew Rist *************************************************************/
21*f8e2c85aSAndrew Rist
22*f8e2c85aSAndrew Rist
23cdf0e10cSrcweir
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_shell.hxx"
26cdf0e10cSrcweir
27cdf0e10cSrcweir //------------------------------------------------------------------------
28cdf0e10cSrcweir // includes
29cdf0e10cSrcweir //------------------------------------------------------------------------
30cdf0e10cSrcweir #include <osl/diagnose.h>
31cdf0e10cSrcweir #include "SysShExec.hxx"
32cdf0e10cSrcweir #include <osl/file.hxx>
33cdf0e10cSrcweir
34cdf0e10cSrcweir #ifndef _COM_SUN_STAR_SYS_SHELL_SYSTEMSHELLEXECUTEFLAGS_HPP_
35cdf0e10cSrcweir #include <com/sun/star/system/SystemShellExecuteFlags.hpp>
36cdf0e10cSrcweir #endif
37cdf0e10cSrcweir
38cdf0e10cSrcweir #define WIN32_LEAN_AND_MEAN
39cdf0e10cSrcweir #if defined _MSC_VER
40cdf0e10cSrcweir #pragma warning(push, 1)
41cdf0e10cSrcweir #endif
42cdf0e10cSrcweir #include <windows.h>
43cdf0e10cSrcweir #include <shellapi.h>
44cdf0e10cSrcweir #include <objbase.h>
45cdf0e10cSrcweir #if defined _MSC_VER
46cdf0e10cSrcweir #pragma warning(pop)
47cdf0e10cSrcweir #endif
48cdf0e10cSrcweir
49cdf0e10cSrcweir //------------------------------------------------------------------------
50cdf0e10cSrcweir // namespace directives
51cdf0e10cSrcweir //------------------------------------------------------------------------
52cdf0e10cSrcweir
53cdf0e10cSrcweir using com::sun::star::uno::Reference;
54cdf0e10cSrcweir using com::sun::star::uno::RuntimeException;
55cdf0e10cSrcweir using com::sun::star::uno::Sequence;
56cdf0e10cSrcweir using com::sun::star::uno::XInterface;
57cdf0e10cSrcweir using com::sun::star::lang::EventObject;
58cdf0e10cSrcweir using com::sun::star::lang::XServiceInfo;
59cdf0e10cSrcweir using com::sun::star::lang::IllegalArgumentException;
60cdf0e10cSrcweir using rtl::OUString;
61cdf0e10cSrcweir using osl::Mutex;
62cdf0e10cSrcweir using com::sun::star::system::XSystemShellExecute;
63cdf0e10cSrcweir using com::sun::star::system::SystemShellExecuteException;
64cdf0e10cSrcweir
65cdf0e10cSrcweir using namespace ::com::sun::star::system::SystemShellExecuteFlags;
66cdf0e10cSrcweir using namespace cppu;
67cdf0e10cSrcweir
68cdf0e10cSrcweir //------------------------------------------------------------------------
69cdf0e10cSrcweir // defines
70cdf0e10cSrcweir //------------------------------------------------------------------------
71cdf0e10cSrcweir
72cdf0e10cSrcweir #define SYSSHEXEC_IMPL_NAME "com.sun.star.sys.shell.SystemShellExecute"
73cdf0e10cSrcweir
74cdf0e10cSrcweir //------------------------------------------------------------------------
75cdf0e10cSrcweir // helper functions
76cdf0e10cSrcweir //------------------------------------------------------------------------
77cdf0e10cSrcweir
78cdf0e10cSrcweir namespace // private
79cdf0e10cSrcweir {
SysShExec_getSupportedServiceNames()80cdf0e10cSrcweir Sequence< OUString > SAL_CALL SysShExec_getSupportedServiceNames()
81cdf0e10cSrcweir {
82cdf0e10cSrcweir Sequence< OUString > aRet(1);
83cdf0e10cSrcweir aRet[0] = OUString::createFromAscii("com.sun.star.sys.shell.SystemShellExecute");
84cdf0e10cSrcweir return aRet;
85cdf0e10cSrcweir }
86cdf0e10cSrcweir
87cdf0e10cSrcweir /* This is the error table that defines the mapping between OS error
88cdf0e10cSrcweir codes and errno values */
89cdf0e10cSrcweir
90cdf0e10cSrcweir struct errentry {
91cdf0e10cSrcweir unsigned long oscode; /* OS return value */
92cdf0e10cSrcweir int errnocode; /* System V error code */
93cdf0e10cSrcweir };
94cdf0e10cSrcweir
95cdf0e10cSrcweir struct errentry errtable[] = {
96cdf0e10cSrcweir { ERROR_SUCCESS, osl_File_E_None }, /* 0 */
97cdf0e10cSrcweir { ERROR_INVALID_FUNCTION, osl_File_E_INVAL }, /* 1 */
98cdf0e10cSrcweir { ERROR_FILE_NOT_FOUND, osl_File_E_NOENT }, /* 2 */
99cdf0e10cSrcweir { ERROR_PATH_NOT_FOUND, osl_File_E_NOENT }, /* 3 */
100cdf0e10cSrcweir { ERROR_TOO_MANY_OPEN_FILES, osl_File_E_MFILE }, /* 4 */
101cdf0e10cSrcweir { ERROR_ACCESS_DENIED, osl_File_E_ACCES }, /* 5 */
102cdf0e10cSrcweir { ERROR_INVALID_HANDLE, osl_File_E_BADF }, /* 6 */
103cdf0e10cSrcweir { ERROR_ARENA_TRASHED, osl_File_E_NOMEM }, /* 7 */
104cdf0e10cSrcweir { ERROR_NOT_ENOUGH_MEMORY, osl_File_E_NOMEM }, /* 8 */
105cdf0e10cSrcweir { ERROR_INVALID_BLOCK, osl_File_E_NOMEM }, /* 9 */
106cdf0e10cSrcweir { ERROR_BAD_ENVIRONMENT, osl_File_E_2BIG }, /* 10 */
107cdf0e10cSrcweir { ERROR_BAD_FORMAT, osl_File_E_NOEXEC }, /* 11 */
108cdf0e10cSrcweir { ERROR_INVALID_ACCESS, osl_File_E_INVAL }, /* 12 */
109cdf0e10cSrcweir { ERROR_INVALID_DATA, osl_File_E_INVAL }, /* 13 */
110cdf0e10cSrcweir { ERROR_INVALID_DRIVE, osl_File_E_NOENT }, /* 15 */
111cdf0e10cSrcweir { ERROR_CURRENT_DIRECTORY, osl_File_E_ACCES }, /* 16 */
112cdf0e10cSrcweir { ERROR_NOT_SAME_DEVICE, osl_File_E_XDEV }, /* 17 */
113cdf0e10cSrcweir { ERROR_NO_MORE_FILES, osl_File_E_NOENT }, /* 18 */
114cdf0e10cSrcweir { ERROR_LOCK_VIOLATION, osl_File_E_ACCES }, /* 33 */
115cdf0e10cSrcweir { ERROR_BAD_NETPATH, osl_File_E_NOENT }, /* 53 */
116cdf0e10cSrcweir { ERROR_NETWORK_ACCESS_DENIED, osl_File_E_ACCES }, /* 65 */
117cdf0e10cSrcweir { ERROR_BAD_NET_NAME, osl_File_E_NOENT }, /* 67 */
118cdf0e10cSrcweir { ERROR_FILE_EXISTS, osl_File_E_EXIST }, /* 80 */
119cdf0e10cSrcweir { ERROR_CANNOT_MAKE, osl_File_E_ACCES }, /* 82 */
120cdf0e10cSrcweir { ERROR_FAIL_I24, osl_File_E_ACCES }, /* 83 */
121cdf0e10cSrcweir { ERROR_INVALID_PARAMETER, osl_File_E_INVAL }, /* 87 */
122cdf0e10cSrcweir { ERROR_NO_PROC_SLOTS, osl_File_E_AGAIN }, /* 89 */
123cdf0e10cSrcweir { ERROR_DRIVE_LOCKED, osl_File_E_ACCES }, /* 108 */
124cdf0e10cSrcweir { ERROR_BROKEN_PIPE, osl_File_E_PIPE }, /* 109 */
125cdf0e10cSrcweir { ERROR_DISK_FULL, osl_File_E_NOSPC }, /* 112 */
126cdf0e10cSrcweir { ERROR_INVALID_TARGET_HANDLE, osl_File_E_BADF }, /* 114 */
127cdf0e10cSrcweir { ERROR_INVALID_HANDLE, osl_File_E_INVAL }, /* 124 */
128cdf0e10cSrcweir { ERROR_WAIT_NO_CHILDREN, osl_File_E_CHILD }, /* 128 */
129cdf0e10cSrcweir { ERROR_CHILD_NOT_COMPLETE, osl_File_E_CHILD }, /* 129 */
130cdf0e10cSrcweir { ERROR_DIRECT_ACCESS_HANDLE, osl_File_E_BADF }, /* 130 */
131cdf0e10cSrcweir { ERROR_NEGATIVE_SEEK, osl_File_E_INVAL }, /* 131 */
132cdf0e10cSrcweir { ERROR_SEEK_ON_DEVICE, osl_File_E_ACCES }, /* 132 */
133cdf0e10cSrcweir { ERROR_DIR_NOT_EMPTY, osl_File_E_NOTEMPTY }, /* 145 */
134cdf0e10cSrcweir { ERROR_NOT_LOCKED, osl_File_E_ACCES }, /* 158 */
135cdf0e10cSrcweir { ERROR_BAD_PATHNAME, osl_File_E_NOENT }, /* 161 */
136cdf0e10cSrcweir { ERROR_MAX_THRDS_REACHED, osl_File_E_AGAIN }, /* 164 */
137cdf0e10cSrcweir { ERROR_LOCK_FAILED, osl_File_E_ACCES }, /* 167 */
138cdf0e10cSrcweir { ERROR_ALREADY_EXISTS, osl_File_E_EXIST }, /* 183 */
139cdf0e10cSrcweir { ERROR_FILENAME_EXCED_RANGE, osl_File_E_NOENT }, /* 206 */
140cdf0e10cSrcweir { ERROR_NESTING_NOT_ALLOWED, osl_File_E_AGAIN }, /* 215 */
141cdf0e10cSrcweir { ERROR_NOT_ENOUGH_QUOTA, osl_File_E_NOMEM } /* 1816 */
142cdf0e10cSrcweir };
143cdf0e10cSrcweir
144cdf0e10cSrcweir /* size of the table */
145cdf0e10cSrcweir #define ERRTABLESIZE (sizeof(errtable)/sizeof(errtable[0]))
146cdf0e10cSrcweir
147cdf0e10cSrcweir /* The following two constants must be the minimum and maximum
148cdf0e10cSrcweir values in the (contiguous) range of osl_File_E_xec Failure errors. */
149cdf0e10cSrcweir #define MIN_EXEC_ERROR ERROR_INVALID_STARTING_CODESEG
150cdf0e10cSrcweir #define MAX_EXEC_ERROR ERROR_INFLOOP_IN_RELOC_CHAIN
151cdf0e10cSrcweir
152cdf0e10cSrcweir /* These are the low and high value in the range of errors that are
153cdf0e10cSrcweir access violations */
154cdf0e10cSrcweir #define MIN_EACCES_RANGE ERROR_WRITE_PROTECT
155cdf0e10cSrcweir #define MAX_EACCES_RANGE ERROR_SHARING_BUFFER_EXCEEDED
156cdf0e10cSrcweir
157cdf0e10cSrcweir
158cdf0e10cSrcweir /*******************************************************************************/
159cdf0e10cSrcweir
_mapError(DWORD dwError)160cdf0e10cSrcweir oslFileError _mapError( DWORD dwError )
161cdf0e10cSrcweir {
162cdf0e10cSrcweir int i;
163cdf0e10cSrcweir
164cdf0e10cSrcweir /* check the table for the OS error code */
165cdf0e10cSrcweir for ( i = 0; i < ERRTABLESIZE; ++i )
166cdf0e10cSrcweir {
167cdf0e10cSrcweir if ( dwError == errtable[i].oscode )
168cdf0e10cSrcweir return (oslFileError)errtable[i].errnocode;
169cdf0e10cSrcweir }
170cdf0e10cSrcweir
171cdf0e10cSrcweir /* The error code wasn't in the table. We check for a range of */
172cdf0e10cSrcweir /* osl_File_E_ACCES errors or exec failure errors (ENOEXEC). Otherwise */
173cdf0e10cSrcweir /* osl_File_E_INVAL is returned. */
174cdf0e10cSrcweir
175cdf0e10cSrcweir if ( dwError >= MIN_EACCES_RANGE && dwError <= MAX_EACCES_RANGE)
176cdf0e10cSrcweir return osl_File_E_ACCES;
177cdf0e10cSrcweir else if ( dwError >= MIN_EXEC_ERROR && dwError <= MAX_EXEC_ERROR)
178cdf0e10cSrcweir return osl_File_E_NOEXEC;
179cdf0e10cSrcweir else
180cdf0e10cSrcweir return osl_File_E_INVAL;
181cdf0e10cSrcweir }
182cdf0e10cSrcweir
183cdf0e10cSrcweir #define MapError( oserror ) _mapError( oserror )
184cdf0e10cSrcweir
185cdf0e10cSrcweir #define E_UNKNOWN_EXEC_ERROR -1
186cdf0e10cSrcweir
187cdf0e10cSrcweir //-----------------------------------------
188cdf0e10cSrcweir //-----------------------------------------
189cdf0e10cSrcweir
is_system_path(const OUString & path_or_uri)190cdf0e10cSrcweir bool is_system_path(const OUString& path_or_uri)
191cdf0e10cSrcweir {
192cdf0e10cSrcweir OUString url;
193cdf0e10cSrcweir osl::FileBase::RC rc = osl::FileBase::getFileURLFromSystemPath(path_or_uri, url);
194cdf0e10cSrcweir return (rc == osl::FileBase::E_None);
195cdf0e10cSrcweir }
196cdf0e10cSrcweir
197cdf0e10cSrcweir //-----------------------------------------
198cdf0e10cSrcweir // trying to identify a jump mark
199cdf0e10cSrcweir //-----------------------------------------
200cdf0e10cSrcweir
201cdf0e10cSrcweir const OUString JUMP_MARK_HTM = OUString::createFromAscii(".htm#");
202cdf0e10cSrcweir const OUString JUMP_MARK_HTML = OUString::createFromAscii(".html#");
203cdf0e10cSrcweir const sal_Unicode HASH_MARK = (sal_Unicode)'#';
204cdf0e10cSrcweir
has_jump_mark(const OUString & system_path,sal_Int32 * jmp_mark_start=NULL)205cdf0e10cSrcweir bool has_jump_mark(const OUString& system_path, sal_Int32* jmp_mark_start = NULL)
206cdf0e10cSrcweir {
207cdf0e10cSrcweir sal_Int32 jmp_mark = std::max<int>(
208cdf0e10cSrcweir system_path.lastIndexOf(JUMP_MARK_HTM),
209cdf0e10cSrcweir system_path.lastIndexOf(JUMP_MARK_HTML));
210cdf0e10cSrcweir
211cdf0e10cSrcweir if (jmp_mark_start)
212cdf0e10cSrcweir *jmp_mark_start = jmp_mark;
213cdf0e10cSrcweir
214cdf0e10cSrcweir return (jmp_mark > -1);
215cdf0e10cSrcweir }
216cdf0e10cSrcweir
217cdf0e10cSrcweir //-----------------------------------------
218cdf0e10cSrcweir //-----------------------------------------
219cdf0e10cSrcweir
is_existing_file(const OUString & file_name)220cdf0e10cSrcweir bool is_existing_file(const OUString& file_name)
221cdf0e10cSrcweir {
222cdf0e10cSrcweir OSL_ASSERT(is_system_path(file_name));
223cdf0e10cSrcweir
224cdf0e10cSrcweir bool exist = false;
225cdf0e10cSrcweir
226cdf0e10cSrcweir OUString file_url;
227cdf0e10cSrcweir osl::FileBase::RC rc = osl::FileBase::getFileURLFromSystemPath(file_name, file_url);
228cdf0e10cSrcweir
229cdf0e10cSrcweir if (osl::FileBase::E_None == rc)
230cdf0e10cSrcweir {
231cdf0e10cSrcweir osl::DirectoryItem dir_item;
232cdf0e10cSrcweir rc = osl::DirectoryItem::get(file_url, dir_item);
233cdf0e10cSrcweir exist = (osl::FileBase::E_None == rc);
234cdf0e10cSrcweir }
235cdf0e10cSrcweir return exist;
236cdf0e10cSrcweir }
237cdf0e10cSrcweir
238cdf0e10cSrcweir //-------------------------------------------------
239cdf0e10cSrcweir // Jump marks in file urls are illegal.
240cdf0e10cSrcweir //-------------------------------------------------
241cdf0e10cSrcweir
remove_jump_mark(OUString * p_command)242cdf0e10cSrcweir void remove_jump_mark(OUString* p_command)
243cdf0e10cSrcweir {
244cdf0e10cSrcweir OSL_PRECOND(p_command, "invalid parameter");
245cdf0e10cSrcweir
246cdf0e10cSrcweir sal_Int32 pos;
247cdf0e10cSrcweir if (has_jump_mark(*p_command, &pos))
248cdf0e10cSrcweir {
249cdf0e10cSrcweir const sal_Unicode* p_jmp_mark = p_command->getStr() + pos;
250cdf0e10cSrcweir while (*p_jmp_mark && (*p_jmp_mark != HASH_MARK))
251cdf0e10cSrcweir p_jmp_mark++;
252cdf0e10cSrcweir
253cdf0e10cSrcweir *p_command = OUString(p_command->getStr(), p_jmp_mark - p_command->getStr());
254cdf0e10cSrcweir }
255cdf0e10cSrcweir }
256cdf0e10cSrcweir
257cdf0e10cSrcweir } // end namespace
258cdf0e10cSrcweir
259cdf0e10cSrcweir //-----------------------------------------------------------------------------------------
260cdf0e10cSrcweir //
261cdf0e10cSrcweir //-----------------------------------------------------------------------------------------
262cdf0e10cSrcweir
CSysShExec()263cdf0e10cSrcweir CSysShExec::CSysShExec( ) :
264cdf0e10cSrcweir WeakComponentImplHelper2< XSystemShellExecute, XServiceInfo >( m_aMutex )
265cdf0e10cSrcweir {
266cdf0e10cSrcweir /*
267cdf0e10cSrcweir * As this service is declared thread-affine, it is ensured to be called from a
268cdf0e10cSrcweir * dedicated thread, so initialize COM here.
269cdf0e10cSrcweir *
270cdf0e10cSrcweir * We need COM to be initialized for STA, but osl thread get initialized for MTA.
271cdf0e10cSrcweir * Once this changed, we can remove the uninitialize call.
272cdf0e10cSrcweir */
273cdf0e10cSrcweir CoUninitialize();
274cdf0e10cSrcweir CoInitialize( NULL );
275cdf0e10cSrcweir }
276cdf0e10cSrcweir
277cdf0e10cSrcweir //-------------------------------------------------
278cdf0e10cSrcweir //
279cdf0e10cSrcweir //-------------------------------------------------
280cdf0e10cSrcweir
execute(const OUString & aCommand,const OUString & aParameter,sal_Int32 nFlags)281cdf0e10cSrcweir void SAL_CALL CSysShExec::execute( const OUString& aCommand, const OUString& aParameter, sal_Int32 nFlags )
282cdf0e10cSrcweir throw (IllegalArgumentException, SystemShellExecuteException, RuntimeException)
283cdf0e10cSrcweir {
284cdf0e10cSrcweir // parameter checking
285cdf0e10cSrcweir if (0 == aCommand.getLength())
286cdf0e10cSrcweir throw IllegalArgumentException(
287cdf0e10cSrcweir OUString::createFromAscii( "Empty command" ),
288cdf0e10cSrcweir static_cast< XSystemShellExecute* >( this ),
289cdf0e10cSrcweir 1 );
290cdf0e10cSrcweir
291cdf0e10cSrcweir if (!(nFlags >= DEFAULTS && nFlags <= NO_SYSTEM_ERROR_MESSAGE))
292cdf0e10cSrcweir throw IllegalArgumentException(
293cdf0e10cSrcweir OUString::createFromAscii( "Invalid Flags specified" ),
294cdf0e10cSrcweir static_cast< XSystemShellExecute* >( this ),
295cdf0e10cSrcweir 3 );
296cdf0e10cSrcweir
297cdf0e10cSrcweir /* #i4789#; jump mark detection on system paths
298cdf0e10cSrcweir if the given command is a system path (not http or
299cdf0e10cSrcweir other uri schemes) and seems to have a jump mark
300cdf0e10cSrcweir and names no existing file (remeber the jump mark
301cdf0e10cSrcweir sign '#' is a valid file name character we remove
302cdf0e10cSrcweir the jump mark, else ShellExecuteEx fails */
303cdf0e10cSrcweir OUString preprocessed_command(aCommand);
304cdf0e10cSrcweir if (is_system_path(preprocessed_command))
305cdf0e10cSrcweir {
306cdf0e10cSrcweir if (has_jump_mark(preprocessed_command) && !is_existing_file(preprocessed_command))
307cdf0e10cSrcweir remove_jump_mark(&preprocessed_command);
308cdf0e10cSrcweir }
309cdf0e10cSrcweir /* Convert file uris to system paths */
310cdf0e10cSrcweir else
311cdf0e10cSrcweir {
312cdf0e10cSrcweir OUString aSystemPath;
313cdf0e10cSrcweir if (::osl::FileBase::E_None == ::osl::FileBase::getSystemPathFromFileURL(preprocessed_command, aSystemPath))
314cdf0e10cSrcweir preprocessed_command = aSystemPath;
315cdf0e10cSrcweir }
316cdf0e10cSrcweir
317cdf0e10cSrcweir SHELLEXECUTEINFOW sei;
318cdf0e10cSrcweir ZeroMemory(&sei, sizeof( sei));
319cdf0e10cSrcweir
320cdf0e10cSrcweir sei.cbSize = sizeof(sei);
321cdf0e10cSrcweir sei.lpFile = reinterpret_cast<LPCWSTR>(preprocessed_command.getStr());
322cdf0e10cSrcweir sei.lpParameters = reinterpret_cast<LPCWSTR>(aParameter.getStr());
323cdf0e10cSrcweir sei.nShow = SW_SHOWNORMAL;
324cdf0e10cSrcweir
325cdf0e10cSrcweir if (NO_SYSTEM_ERROR_MESSAGE & nFlags)
326cdf0e10cSrcweir sei.fMask = SEE_MASK_FLAG_NO_UI;
327cdf0e10cSrcweir
328cdf0e10cSrcweir SetLastError( 0 );
329cdf0e10cSrcweir
330cdf0e10cSrcweir sal_Bool bRet = ShellExecuteExW(&sei) ? sal_True : sal_False;
331cdf0e10cSrcweir
332cdf0e10cSrcweir if (!bRet && (nFlags & NO_SYSTEM_ERROR_MESSAGE))
333cdf0e10cSrcweir {
334cdf0e10cSrcweir // ShellExecuteEx fails to set an error code
335cdf0e10cSrcweir // we return osl_File_E_INVAL
336cdf0e10cSrcweir sal_Int32 psxErr = GetLastError();
337cdf0e10cSrcweir if (ERROR_SUCCESS == psxErr)
338cdf0e10cSrcweir psxErr = E_UNKNOWN_EXEC_ERROR;
339cdf0e10cSrcweir else
340cdf0e10cSrcweir psxErr = MapError(psxErr);
341cdf0e10cSrcweir
342cdf0e10cSrcweir throw SystemShellExecuteException(
343cdf0e10cSrcweir OUString::createFromAscii("Error executing command"),
344cdf0e10cSrcweir static_cast< XSystemShellExecute* >(this),
345cdf0e10cSrcweir psxErr);
346cdf0e10cSrcweir }
347cdf0e10cSrcweir }
348cdf0e10cSrcweir
349cdf0e10cSrcweir // -------------------------------------------------
350cdf0e10cSrcweir // XServiceInfo
351cdf0e10cSrcweir // -------------------------------------------------
352cdf0e10cSrcweir
getImplementationName()353cdf0e10cSrcweir OUString SAL_CALL CSysShExec::getImplementationName( )
354cdf0e10cSrcweir throw( RuntimeException )
355cdf0e10cSrcweir {
356cdf0e10cSrcweir return OUString::createFromAscii( SYSSHEXEC_IMPL_NAME );
357cdf0e10cSrcweir }
358cdf0e10cSrcweir
359cdf0e10cSrcweir // -------------------------------------------------
360cdf0e10cSrcweir // XServiceInfo
361cdf0e10cSrcweir // -------------------------------------------------
362cdf0e10cSrcweir
supportsService(const OUString & ServiceName)363cdf0e10cSrcweir sal_Bool SAL_CALL CSysShExec::supportsService( const OUString& ServiceName )
364cdf0e10cSrcweir throw( RuntimeException )
365cdf0e10cSrcweir {
366cdf0e10cSrcweir Sequence < OUString > SupportedServicesNames = SysShExec_getSupportedServiceNames();
367cdf0e10cSrcweir
368cdf0e10cSrcweir for ( sal_Int32 n = SupportedServicesNames.getLength(); n--; )
369cdf0e10cSrcweir if (SupportedServicesNames[n].compareTo(ServiceName) == 0)
370cdf0e10cSrcweir return sal_True;
371cdf0e10cSrcweir
372cdf0e10cSrcweir return sal_False;
373cdf0e10cSrcweir }
374cdf0e10cSrcweir
375cdf0e10cSrcweir // -------------------------------------------------
376cdf0e10cSrcweir // XServiceInfo
377cdf0e10cSrcweir // -------------------------------------------------
378cdf0e10cSrcweir
getSupportedServiceNames()379cdf0e10cSrcweir Sequence< OUString > SAL_CALL CSysShExec::getSupportedServiceNames( )
380cdf0e10cSrcweir throw( RuntimeException )
381cdf0e10cSrcweir {
382cdf0e10cSrcweir return SysShExec_getSupportedServiceNames();
383cdf0e10cSrcweir }
384cdf0e10cSrcweir
385