1<?xml version="1.0" encoding="UTF-8"?> 2 3<!--*********************************************************** 4 * 5 * Licensed to the Apache Software Foundation (ASF) under one 6 * or more contributor license agreements. See the NOTICE file 7 * distributed with this work for additional information 8 * regarding copyright ownership. The ASF licenses this file 9 * to you under the Apache License, Version 2.0 (the 10 * "License"); you may not use this file except in compliance 11 * with the License. You may obtain a copy of the License at 12 * 13 * http://www.apache.org/licenses/LICENSE-2.0 14 * 15 * Unless required by applicable law or agreed to in writing, 16 * software distributed under the License is distributed on an 17 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 18 * KIND, either express or implied. See the License for the 19 * specific language governing permissions and limitations 20 * under the License. 21 * 22 ***********************************************************--> 23 24<helpdocument version="1.0"> 25<meta> 26<topic id="textsharedguidescriptingxml" indexer="include"> 27<title xml-lang="en-US" id="tit">Scripting %PRODUCTNAME</title> 28<filename>/text/shared/guide/scripting.xhp</filename> 29</topic> 30</meta> 31<body> 32<bookmark xml-lang="en-US" branch="index" id="bm_id5277565"> 33<bookmark_value>assigning scripts</bookmark_value> 34<bookmark_value>programming;scripting</bookmark_value> 35<bookmark_value>form controls;assigning macros</bookmark_value> 36<bookmark_value>pictures;assigning macros</bookmark_value> 37<bookmark_value>hyperlinks;assigning macros</bookmark_value> 38<bookmark_value>shortcut keys;assigning macros</bookmark_value> 39<bookmark_value>controls;assigning macros (Basic)</bookmark_value> 40<bookmark_value>menus;assigning macros</bookmark_value> 41<bookmark_value>events;assigning scripts</bookmark_value> 42</bookmark><comment>MW deleted "programming;...", "scripting in programming", "BeanShell scripting", "Basic;..." and "java;..."</comment><comment>MW added "controls;..", "menus;..." and "events;..."</comment> 43<paragraph xml-lang="en-US" id="par_idN1070A" role="heading" level="1" l10n="NEW"><variable id="scripting"><link href="text/shared/guide/scripting.xhp">Assigning Scripts in %PRODUCTNAME</link> 44</variable></paragraph> 45<paragraph xml-lang="en-US" id="par_idN10728" role="paragraph" l10n="NEW">You can assign custom scripts (macros) to menu items, icons, dialog controls, and events in %PRODUCTNAME.</paragraph> 46<paragraph xml-lang="en-US" id="par_idN1072B" role="paragraph" l10n="NEW">%PRODUCTNAME internally supports the following scripting languages:</paragraph> 47<list type="ordered"> 48<listitem> 49<paragraph xml-lang="en-US" id="par_idN10731" role="paragraph" l10n="NEW">%PRODUCTNAME Basic</paragraph> 50</listitem> 51<listitem> 52<paragraph xml-lang="en-US" id="par_idN10739" role="paragraph" l10n="NEW">JavaScript</paragraph> 53</listitem> 54<listitem> 55<paragraph xml-lang="en-US" id="par_idN1073D" role="paragraph" l10n="CHG">BeanShell</paragraph> 56</listitem> 57<listitem> 58<paragraph xml-lang="en-US" id="par_id6797082" role="paragraph" l10n="CHG">Python</paragraph> 59</listitem> 60</list> 61<paragraph xml-lang="en-US" id="par_idN1091F" role="paragraph" l10n="NEW">In addition, developers can use high-level languages, for example Java programming language, to control %PRODUCTNAME externally. See the API project at Apache OpenOffice.</paragraph> 62<paragraph xml-lang="en-US" id="par_idN10751" role="heading" level="2" l10n="NEW">To assign a script to a new menu entry</paragraph> 63<list type="ordered"> 64<listitem> 65<paragraph xml-lang="en-US" id="par_idN10758" role="paragraph" l10n="NEW">Choose <emph>Tools - Customize</emph>, and click the <emph>Menus</emph> tab.</paragraph> 66</listitem> 67<listitem> 68<paragraph xml-lang="en-US" id="par_idN1093D" role="paragraph" l10n="NEW">Click <emph>Add</emph>.</paragraph> 69</listitem> 70<listitem> 71<paragraph xml-lang="en-US" id="par_idN10760" role="paragraph" l10n="NEW">In the <emph>Category</emph> list box, scroll down and open the "%PRODUCTNAME Macros" entry.</paragraph> 72</listitem> 73<listitem> 74<paragraph xml-lang="en-US" id="par_idN10768" role="paragraph" l10n="NEW">You see entries for "%PRODUCTNAME Macros" (scripts in the share directory of your %PRODUCTNAME installation), "My Macros" (scripts in the user directory), and the current document. Open any one of them to see the supported scripting languages.</paragraph> 75</listitem> 76<listitem> 77<paragraph xml-lang="en-US" id="par_idN1076C" role="paragraph" l10n="NEW">Open any scripting language entry to see the available scripts. Select a script.</paragraph> 78</listitem> 79<listitem> 80<paragraph xml-lang="en-US" id="par_idN10770" role="paragraph" l10n="NEW">A list of the script functions appears in the <emph>Commands</emph> list box. Select a function.</paragraph> 81</listitem> 82<listitem> 83<paragraph xml-lang="en-US" id="par_idN10778" role="paragraph" l10n="NEW">Click <emph>Add</emph> to create a new menu assignment. The new menu entry appears in the <emph>Entries</emph> list box.</paragraph> 84</listitem> 85</list> 86<paragraph xml-lang="en-US" id="par_idN10783" role="heading" level="2" l10n="NEW">To assign a script to a key combination</paragraph> 87<list type="ordered"> 88<listitem> 89<paragraph xml-lang="en-US" id="par_idN10787" role="paragraph" l10n="NEW">Choose <emph>Tools - Customize - Keyboard</emph>.</paragraph> 90</listitem> 91<listitem> 92<paragraph xml-lang="en-US" id="par_idN10A59" role="paragraph" l10n="NEW">In the <emph>Category</emph> list box, scroll down and open the "%PRODUCTNAME Macros" entry.</paragraph> 93</listitem> 94<listitem> 95<paragraph xml-lang="en-US" id="par_idN10A61" role="paragraph" l10n="NEW">You see entries for "%PRODUCTNAME Macros" (scripts in the share directory of your %PRODUCTNAME installation), "My Macros" (scripts in the user directory), and the current document. Open any one of them to see the supported scripting languages.</paragraph> 96</listitem> 97<listitem> 98<paragraph xml-lang="en-US" id="par_idN10A65" role="paragraph" l10n="NEW">Open any scripting language entry to see the available scripts. Select any script.</paragraph> 99</listitem> 100<listitem> 101<paragraph xml-lang="en-US" id="par_idN10A69" role="paragraph" l10n="NEW">A list of the script functions will appear in the <emph>Commands</emph> list box. Select any function.</paragraph> 102</listitem> 103<listitem> 104<paragraph xml-lang="en-US" id="par_idN10A71" role="paragraph" l10n="NEW">Click the option button for %PRODUCTNAME or Writer (or whichever application is currently open).</paragraph> 105<paragraph xml-lang="en-US" id="par_idN10A74" role="paragraph" l10n="NEW">Selecting the option button sets the scope of the new key combination to be applicable in all of %PRODUCTNAME or only in documents of the current module.</paragraph> 106</listitem> 107<listitem> 108<paragraph xml-lang="en-US" id="par_idN10A78" role="paragraph" l10n="NEW">Select a key combination from the <emph>Shortcut keys</emph> list box and click <emph>Modify</emph>.</paragraph> 109</listitem> 110</list> 111<paragraph xml-lang="en-US" id="par_idN1078A" role="heading" level="2" l10n="NEW">To assign a script to an event</paragraph> 112<list type="ordered"> 113<listitem> 114<paragraph xml-lang="en-US" id="par_idN1078E" role="paragraph" l10n="NEW">Choose <emph>Tools - Customize - Events</emph>.</paragraph> 115</listitem> 116<listitem> 117<paragraph xml-lang="en-US" id="par_idN10A16" role="paragraph" l10n="NEW">Click <emph>Macro</emph> button.</paragraph> 118</listitem> 119<listitem> 120<paragraph xml-lang="en-US" id="par_idN10A9E" role="paragraph" l10n="NEW">In the <emph>Library</emph> list box, scroll down and open the "%PRODUCTNAME Macros" entry.</paragraph> 121</listitem> 122<listitem> 123<paragraph xml-lang="en-US" id="par_idN10AA6" role="paragraph" l10n="NEW">You see entries for "%PRODUCTNAME Macros" (scripts in the share directory of your %PRODUCTNAME installation), "My Macros" (scripts in the user directory), and the current document. Open any one of them to see the supported scripting languages.</paragraph> 124</listitem> 125<listitem> 126<paragraph xml-lang="en-US" id="par_idN10AAA" role="paragraph" l10n="NEW">Open any scripting language entry to see the available scripts. Select any script.</paragraph> 127</listitem> 128<listitem> 129<paragraph xml-lang="en-US" id="par_idN10AAE" role="paragraph" l10n="NEW">A list of the script functions will appear in the <emph>Assigned Action</emph> list box. Select any function.</paragraph> 130</listitem> 131<listitem> 132<paragraph xml-lang="en-US" id="par_idN10AB6" role="paragraph" l10n="NEW">Select to save in %PRODUCTNAME or current document.</paragraph> 133<paragraph xml-lang="en-US" id="par_idN10AB9" role="paragraph" l10n="CHG">This sets the scope of the new event assignment to be applicable in all of %PRODUCTNAME or only in documents of the current module.</paragraph> 134</listitem> 135<listitem> 136<paragraph xml-lang="en-US" id="par_idN10ABD" role="paragraph" l10n="NEW">Select an event from the list and click <emph>OK</emph>.</paragraph> 137</listitem> 138</list> 139<paragraph xml-lang="en-US" id="par_idN10791" role="heading" level="2" l10n="NEW">To assign a script to an event for an embedded object</paragraph> 140<list type="ordered"> 141<listitem> 142<paragraph xml-lang="en-US" id="par_idN10795" role="paragraph" l10n="NEW">Select the embedded object, for example a chart, in your document.</paragraph> 143</listitem> 144<listitem> 145<paragraph xml-lang="en-US" id="par_idN10ADB" role="paragraph" l10n="NEW">Choose <emph>Format - Frame/Object - Macro</emph>.</paragraph> 146</listitem> 147<listitem> 148<paragraph xml-lang="en-US" id="par_idN10ADF" role="paragraph" l10n="NEW">In the <emph>Macros</emph> list box, open the %PRODUCTNAME Scripts entry.</paragraph> 149</listitem> 150<listitem> 151<paragraph xml-lang="en-US" id="par_idN10AE7" role="paragraph" l10n="NEW">You see entries for share (scripts in the share directory of your %PRODUCTNAME installation), user (scripts in the user directory), and the current document. Open any one of them to see the supported scripting languages.</paragraph> 152</listitem> 153<listitem> 154<paragraph xml-lang="en-US" id="par_idN10AEB" role="paragraph" l10n="NEW">Open any scripting language entry to see the available scripts. Select any script.</paragraph> 155</listitem> 156<listitem> 157<paragraph xml-lang="en-US" id="par_idN10AEF" role="paragraph" l10n="NEW">A list of the script functions will appear in the <emph>Existing macros in</emph> list box. Select any function.</paragraph> 158</listitem> 159<listitem> 160<paragraph xml-lang="en-US" id="par_idN10AF7" role="paragraph" l10n="NEW">Select an event from the list and click <emph>OK</emph>.</paragraph> 161</listitem> 162</list> 163<paragraph xml-lang="en-US" id="par_idN10798" role="heading" level="2" l10n="NEW">To assign a script to a hyperlink</paragraph> 164<list type="ordered"> 165<listitem> 166<paragraph xml-lang="en-US" id="par_idN1079C" role="paragraph" l10n="NEW">Position the cursor inside the hyperlink.</paragraph> 167</listitem> 168<listitem> 169<paragraph xml-lang="en-US" id="par_idN10B15" role="paragraph" l10n="NEW">Choose <emph>Insert - Hyperlink</emph>.</paragraph> 170</listitem> 171<listitem> 172<paragraph xml-lang="en-US" id="par_idN10B19" role="paragraph" l10n="NEW">Click the <emph>Events</emph> button.</paragraph> 173</listitem> 174<listitem> 175<paragraph xml-lang="en-US" id="par_idN10B21" role="paragraph" l10n="NEW">Select and assign as stated above.</paragraph> 176</listitem> 177</list> 178<paragraph xml-lang="en-US" id="par_idN1079F" role="heading" level="2" l10n="NEW">To assign a script to a graphic</paragraph> 179<list type="ordered"> 180<listitem> 181<paragraph xml-lang="en-US" id="par_idN107A3" role="paragraph" l10n="NEW">Select the graphic in your document.</paragraph> 182</listitem> 183<listitem> 184<paragraph xml-lang="en-US" id="par_idN10B3B" role="paragraph" l10n="CHG">Choose <emph>Format - Picture - Macro</emph>.</paragraph> 185</listitem> 186<listitem> 187<paragraph xml-lang="en-US" id="par_idN10B3F" role="paragraph" l10n="NEW">Select and assign as stated above.</paragraph> 188</listitem> 189</list> 190<paragraph xml-lang="en-US" id="par_idN107A6" role="heading" level="2" l10n="NEW">To assign a script to a form control</paragraph> 191<list type="ordered"> 192<listitem> 193<paragraph xml-lang="en-US" id="par_idN107AA" role="paragraph" l10n="CHG">Insert a form control, for example a button: Open the Form Controls toolbar, click the <emph>Push Button</emph> icon, drag open a button on your document.</paragraph> 194</listitem> 195<listitem> 196<paragraph xml-lang="en-US" id="par_idN10B59" role="paragraph" l10n="CHG">With the form control selected, click <emph>Control</emph> on the Form Controls toolbar.</paragraph> 197</listitem> 198<listitem> 199<paragraph xml-lang="en-US" id="par_idN10B5D" role="paragraph" l10n="NEW">Click the <emph>Events</emph> tab of the Properties dialog.</paragraph> 200</listitem> 201<listitem> 202<paragraph xml-lang="en-US" id="par_idN10B61" role="paragraph" l10n="NEW">Click one of the <emph>...</emph> buttons to open a dialog where you can assign a script to the selected event.</paragraph> 203</listitem> 204</list> 205<paragraph xml-lang="en-US" id="par_idN107AD" role="heading" level="2" l10n="NEW">To assign a script to a control in the %PRODUCTNAME Basic dialog</paragraph> 206<list type="ordered"> 207<listitem> 208<paragraph xml-lang="en-US" id="par_idN107B1" role="paragraph" l10n="NEW">Open the %PRODUCTNAME Basic dialog editor, then create a dialog with a control on it.</paragraph> 209</listitem> 210<listitem> 211<paragraph xml-lang="en-US" id="par_idN10B7F" role="paragraph" l10n="NEW">Right-click the control, then choose <emph>Properties</emph>.</paragraph> 212</listitem> 213<listitem> 214<paragraph xml-lang="en-US" id="par_idN10B87" role="paragraph" l10n="NEW">Click the <emph>Events</emph> tab of the Properties dialog.</paragraph> 215</listitem> 216<listitem> 217<paragraph xml-lang="en-US" id="par_idN10B8B" role="paragraph" l10n="NEW">Click one of the <emph>...</emph> buttons to open a dialog where you can assign a script to the selected event.</paragraph> 218</listitem> 219</list> 220</body> 221</helpdocument> 222