Developing Scripts on the Command Line
For users who do not wish to develop their Office Scripts using an IDE there is a simple command line interface built into the Office Scripting module which can be used for the generation and deployment of Office Scripts.Contents
Prerequisites
- The Scripting module office.jar file should be included in the
classpath. You can unpack this file from the Scripting Framework installer
SFrameworkInstall.jar
by running the following command:
jar xf SFrameworkInstall.jar ide/office.jar
- The CommandLineTools class will only work if an XML parser (such as Apache Xerces) is available in the classpath.
The CommandLineTools class
The CommandLineTools class takes the following options (Note: Options in angle brackets "<>" are required, options in square brackets "[]" are optional):-g [Path to Parcel directory] [options]Generates a Script Parcel for the given the parcel directory. The parcel name will be the name of the parcel directory plus the .sxp extension.
- If a parcel directory is not specified the current directory is used. If the parcel directory does not contain a directory named Contents an error message is printed. Otherwise a Script Parcel (.sxp) file is generated in the parcel directory containing all of the files under the Contents directory. The options that may be used with the -g option allow the user to specify how the parcel-descriptor.xml file for the Script Parcel is generated (see the Scripting Framework developer guide for more information on the parcel-descriptor.xml file). The following options are available:
[-l language[=supported extension list]]
Specifies which language attribute to use for the parcel element in the parcel-descriptor.xml file. The supported extension list is ignored if the language is Java. Otherwise all files that have one of the supported extensions (the list should be separated by the platform specific path separator, ":" on Unix, ";" on Windows) will be added as script entries to the parcel-descriptor.xml file.
Alternatively the user can specify a list of names at the command line which will be added as scripts and no search for script names will be performed. The following table shows the behaviour of CommandLineTools when the -l flag is used:
-l flag used? parcel-descriptor.xml exists? result no no error message printed yes no parcel-descriptor.xml generated
parcel.sxp generatedno yes parcel-descriptor.xml not generated
parcel.sxp generatedyes yes if
language is different from parcel-descriptor.xml language, error
else
parcel-descriptor.xml regenerated
parcel.sxp generated[-p name=value]
Specifies a name value pair to be added as a language dependent property in the parcel-descriptor.xml file
[-v]
Specifies that verbose output should be displayed.
-d <Path to Script Parcel> <Target Directory|Document>
Deploys the given Script Parcel to a directory or an OpenOffice.org document. A directory will be created with the name of the Parcel and the contents of the Parcel will be put into that directory.
- If deploying to an OpenOffice.org installation the target directory should be the <Office Installation>/user/Scripts or <Office Installation>/share/Scripts directory. If the either the Script Parcel or the target do not exist an error message is printed. Otherwise the Script Parcel is deployed to the target.
Top
java CommandLineTools -g myparceldir -l Java
Generates a myparceldir.sxp file in myparceldir automatically exporting
all public Java methods which take XScriptContext as their first parameter as
Office scripts.
Generates a script parcel file in the current directory
automatically exporting all files that end with the .bsh extension as
BeanShell scripts
Generates a myparceldir.sxp file in myparceldir and exports MyScript.bsh
as an Office script.
Generates a myparceldir.sxp file in myparceldir, automatically
searching for valid Office scripts, and adding the classpath property to
each Office script.
Generates a myparceldir.sxp file in myparceldir, automatically
searching for valid Office scripts, and adding the classpath and the
secondprop properties to each Office script.
Deploys the myparceldir.sxp Script Parcel to the specified office directory.
Examples
Last Modified: Tue Mar 12 11:40:28 GMT 2003