1<?xml version="1.0" encoding="UTF-8"?>
2<!DOCTYPE script:module PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "module.dtd">
3<script:module xmlns:script="http://openoffice.org/2000/script" script:name="system_XSystemShellExecute" script:language="StarBasic">
4
5
6'*************************************************************************
7'
8' DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
9'
10' Copyright 2000, 2010 Oracle and/or its affiliates.
11'
12' OpenOffice.org - a multi-platform office productivity suite
13'
14' This file is part of OpenOffice.org.
15'
16' OpenOffice.org is free software: you can redistribute it and/or modify
17' it under the terms of the GNU Lesser General Public License version 3
18' only, as published by the Free Software Foundation.
19'
20' OpenOffice.org is distributed in the hope that it will be useful,
21' but WITHOUT ANY WARRANTY; without even the implied warranty of
22' MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
23' GNU Lesser General Public License version 3 for more details
24' (a copy is included in the LICENSE file that accompanied this code).
25'
26' You should have received a copy of the GNU Lesser General Public License
27' version 3 along with OpenOffice.org.  If not, see
28' <http://www.openoffice.org/license.html>
29' for a copy of the LGPLv3 License.
30'
31'*************************************************************************
32*****
33'*************************************************************************
34
35
36
37' Be sure that all variables are dimensioned:
38option explicit
39
40'*************************************************************************
41' This Interface/Service test depends on the following GLOBAL variables,
42' which must be specified in the object creation:
43
44'     - java existing in PATH system var and
45'       SystemShellExecute.class file in docs dir
46
47'*************************************************************************
48
49
50
51
52
53
54Sub RunTest()
55
56'*************************************************************************
57' INTERFACE:
58' com.sun.star.system.XSystemShellExecute
59'*************************************************************************
60On Error Goto ErrHndl
61    Dim bOK As Boolean
62    Dim cResFile As String, cResURL As String, cClassPath As String
63    Dim oFacc As Object
64    Dim bExist As Boolean, i As Integer
65    Dim cArgs As String
66
67    Test.StartMethod("execute()")
68    cClassPath = utils.URL2Path(utils.Path2URL(cTestDocsDir))
69    cResURL = utils.getTempFileURL("SystemShellExecute.txt", true)
70    cResFile = utils.URL2Path(cResURL)
71    bOK = true
72
73    cArgs = "-classpath " + cClassPath + " SystemShellExecute " + cResFile
74    Out.Log("Executing : 'java " + cArgs + "'")
75    oObj.execute("java", cArgs, 1)
76
77    oFacc = createUnoService("com.sun.star.ucb.SimpleFileAccess")
78
79    if bOK then
80        Out.Log("Waiting while the file will be created or timeout reached ...")
81        bExist = false
82        i = 0
83        while i &lt; 20 AND NOT bExist
84            bExist = oFacc.exists(cResURL)
85            wait(1000)
86            i = i + 1
87        wend
88
89        if bExist then
90            Out.Log("The command was executed and file created in " + i + " sec.")
91        else
92            Out.Log("File was not created.")
93        endif
94
95        bOK = bOK AND bExist
96    endif
97
98    Test.MethodTested("execute()", bOK)
99
100Exit Sub
101ErrHndl:
102    Test.Exception()
103    bOK = false
104    resume next
105End Sub
106</script:module>
107