1cdf0e10cSrcweir<?xml version="1.0" encoding="UTF-8"?>
2cdf0e10cSrcweir<helpdocument version="1.0">
3cdf0e10cSrcweir
4226a8927SAndrew Rist<!--***********************************************************
5cdf0e10cSrcweir *
6226a8927SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
7226a8927SAndrew Rist * or more contributor license agreements.  See the NOTICE file
8226a8927SAndrew Rist * distributed with this work for additional information
9226a8927SAndrew Rist * regarding copyright ownership.  The ASF licenses this file
10226a8927SAndrew Rist * to you under the Apache License, Version 2.0 (the
11226a8927SAndrew Rist * "License"); you may not use this file except in compliance
12226a8927SAndrew Rist * with the License.  You may obtain a copy of the License at
13226a8927SAndrew Rist *
14226a8927SAndrew Rist *   http://www.apache.org/licenses/LICENSE-2.0
15226a8927SAndrew Rist *
16226a8927SAndrew Rist * Unless required by applicable law or agreed to in writing,
17226a8927SAndrew Rist * software distributed under the License is distributed on an
18226a8927SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
19226a8927SAndrew Rist * KIND, either express or implied.  See the License for the
20226a8927SAndrew Rist * specific language governing permissions and limitations
21226a8927SAndrew Rist * under the License.
22226a8927SAndrew Rist *
23226a8927SAndrew Rist ***********************************************************-->
24226a8927SAndrew Rist
25226a8927SAndrew Rist
26cdf0e10cSrcweir
27cdf0e10cSrcweir
28cdf0e10cSrcweir<meta>
29cdf0e10cSrcweir      <topic id="textsharedguidescriptingxml" indexer="include">
30cdf0e10cSrcweir         <title xml-lang="en-US" id="tit">Scripting %PRODUCTNAME</title>
31cdf0e10cSrcweir         <filename>/text/shared/guide/scripting.xhp</filename>
32cdf0e10cSrcweir      </topic>
33cdf0e10cSrcweir   </meta>
34cdf0e10cSrcweir   <body>
35cdf0e10cSrcweir<bookmark xml-lang="en-US" branch="index" id="bm_id5277565"><bookmark_value>assigning scripts</bookmark_value>
36cdf0e10cSrcweir      <bookmark_value>programming;scripting</bookmark_value>
37cdf0e10cSrcweir      <bookmark_value>form controls;assigning macros</bookmark_value>
38cdf0e10cSrcweir      <bookmark_value>pictures;assigning macros</bookmark_value>
39cdf0e10cSrcweir      <bookmark_value>hyperlinks;assigning macros</bookmark_value>
40cdf0e10cSrcweir      <bookmark_value>shortcut keys;assigning macros</bookmark_value>
41cdf0e10cSrcweir      <bookmark_value>controls;assigning macros (Basic)</bookmark_value>
42cdf0e10cSrcweir      <bookmark_value>menus;assigning macros</bookmark_value>
43cdf0e10cSrcweir      <bookmark_value>events;assigning scripts</bookmark_value>
44cdf0e10cSrcweir</bookmark><comment>MW deleted "programming;...",  "scripting in programming", "BeanShell scripting", "Basic;..."  and "java;..."</comment><comment>MW added "controls;..",  "menus;..." and "events;..."</comment>
45cdf0e10cSrcweir<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>
46cdf0e10cSrcweir</variable></paragraph>
47cdf0e10cSrcweir      <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>
48cdf0e10cSrcweir      <paragraph xml-lang="en-US" id="par_idN1072B" role="paragraph" l10n="NEW">%PRODUCTNAME internally supports the following scripting languages:</paragraph>
49cdf0e10cSrcweir      <list type="ordered">
50cdf0e10cSrcweir         <listitem>
51cdf0e10cSrcweir            <paragraph xml-lang="en-US" id="par_idN10731" role="paragraph" l10n="NEW">%PRODUCTNAME Basic</paragraph>
52cdf0e10cSrcweir         </listitem>
53cdf0e10cSrcweir         <listitem>
54cdf0e10cSrcweir            <paragraph xml-lang="en-US" id="par_idN10739" role="paragraph" l10n="NEW">JavaScript</paragraph>
55cdf0e10cSrcweir         </listitem>
56cdf0e10cSrcweir         <listitem>
57cdf0e10cSrcweir            <paragraph xml-lang="en-US" id="par_idN1073D" role="paragraph" l10n="CHG">BeanShell</paragraph>
58cdf0e10cSrcweir         </listitem>
59cdf0e10cSrcweir         <listitem>
60cdf0e10cSrcweir            <paragraph xml-lang="en-US" id="par_id6797082" role="paragraph" l10n="CHG">Python</paragraph>
61cdf0e10cSrcweir         </listitem>
62cdf0e10cSrcweir      </list>
63*ff3f4ebcSOliver-Rainer Wittmann      <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>
64cdf0e10cSrcweir      <paragraph xml-lang="en-US" id="par_idN10751" role="heading" level="2" l10n="NEW">To assign a script to a new menu entry</paragraph>
65cdf0e10cSrcweir      <list type="ordered">
66cdf0e10cSrcweir         <listitem>
67cdf0e10cSrcweir            <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>
68cdf0e10cSrcweir         </listitem>
69cdf0e10cSrcweir         <listitem>
70cdf0e10cSrcweir            <paragraph xml-lang="en-US" id="par_idN1093D" role="paragraph" l10n="NEW">Click <emph>Add</emph>.</paragraph>
71cdf0e10cSrcweir         </listitem>
72cdf0e10cSrcweir         <listitem>
73cdf0e10cSrcweir            <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>
74cdf0e10cSrcweir         </listitem>
75cdf0e10cSrcweir         <listitem>
76cdf0e10cSrcweir            <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>
77cdf0e10cSrcweir         </listitem>
78cdf0e10cSrcweir         <listitem>
79cdf0e10cSrcweir            <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>
80cdf0e10cSrcweir         </listitem>
81cdf0e10cSrcweir         <listitem>
82cdf0e10cSrcweir            <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>
83cdf0e10cSrcweir         </listitem>
84cdf0e10cSrcweir         <listitem>
85cdf0e10cSrcweir            <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>
86cdf0e10cSrcweir         </listitem>
87cdf0e10cSrcweir      </list>
88cdf0e10cSrcweir      <paragraph xml-lang="en-US" id="par_idN10783" role="heading" level="2" l10n="NEW">To assign a script to a key combination</paragraph>
89cdf0e10cSrcweir      <list type="ordered">
90cdf0e10cSrcweir         <listitem>
91cdf0e10cSrcweir            <paragraph xml-lang="en-US" id="par_idN10787" role="paragraph" l10n="NEW">Choose <emph>Tools - Customize - Keyboard</emph>.</paragraph>
92cdf0e10cSrcweir         </listitem>
93cdf0e10cSrcweir         <listitem>
94cdf0e10cSrcweir            <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>
95cdf0e10cSrcweir         </listitem>
96cdf0e10cSrcweir         <listitem>
97cdf0e10cSrcweir            <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>
98cdf0e10cSrcweir         </listitem>
99cdf0e10cSrcweir         <listitem>
100cdf0e10cSrcweir            <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>
101cdf0e10cSrcweir         </listitem>
102cdf0e10cSrcweir         <listitem>
103cdf0e10cSrcweir            <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>
104cdf0e10cSrcweir         </listitem>
105cdf0e10cSrcweir         <listitem>
106cdf0e10cSrcweir            <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>
107cdf0e10cSrcweir            <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>
108cdf0e10cSrcweir         </listitem>
109cdf0e10cSrcweir         <listitem>
110cdf0e10cSrcweir            <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>
111cdf0e10cSrcweir         </listitem>
112cdf0e10cSrcweir      </list>
113cdf0e10cSrcweir      <paragraph xml-lang="en-US" id="par_idN1078A" role="heading" level="2" l10n="NEW">To assign a script to an event</paragraph>
114cdf0e10cSrcweir      <list type="ordered">
115cdf0e10cSrcweir         <listitem>
116cdf0e10cSrcweir            <paragraph xml-lang="en-US" id="par_idN1078E" role="paragraph" l10n="NEW">Choose <emph>Tools - Customize - Events</emph>.</paragraph>
117cdf0e10cSrcweir         </listitem>
118cdf0e10cSrcweir         <listitem>
119cdf0e10cSrcweir            <paragraph xml-lang="en-US" id="par_idN10A16" role="paragraph" l10n="NEW">Click <emph>Macro</emph> button.</paragraph>
120cdf0e10cSrcweir         </listitem>
121cdf0e10cSrcweir         <listitem>
122cdf0e10cSrcweir            <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>
123cdf0e10cSrcweir         </listitem>
124cdf0e10cSrcweir         <listitem>
125cdf0e10cSrcweir            <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>
126cdf0e10cSrcweir         </listitem>
127cdf0e10cSrcweir         <listitem>
128cdf0e10cSrcweir            <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>
129cdf0e10cSrcweir         </listitem>
130cdf0e10cSrcweir         <listitem>
131cdf0e10cSrcweir            <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>
132cdf0e10cSrcweir         </listitem>
133cdf0e10cSrcweir         <listitem>
134cdf0e10cSrcweir            <paragraph xml-lang="en-US" id="par_idN10AB6" role="paragraph" l10n="NEW">Select to save in %PRODUCTNAME or current document.</paragraph>
135cdf0e10cSrcweir            <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>
136cdf0e10cSrcweir         </listitem>
137cdf0e10cSrcweir         <listitem>
138cdf0e10cSrcweir            <paragraph xml-lang="en-US" id="par_idN10ABD" role="paragraph" l10n="NEW">Select an event from the list and click <emph>OK</emph>.</paragraph>
139cdf0e10cSrcweir         </listitem>
140cdf0e10cSrcweir      </list>
141cdf0e10cSrcweir      <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>
142cdf0e10cSrcweir      <list type="ordered">
143cdf0e10cSrcweir         <listitem>
144cdf0e10cSrcweir            <paragraph xml-lang="en-US" id="par_idN10795" role="paragraph" l10n="NEW">Select the embedded object, for example a chart, in your document.</paragraph>
145cdf0e10cSrcweir         </listitem>
146cdf0e10cSrcweir         <listitem>
147cdf0e10cSrcweir            <paragraph xml-lang="en-US" id="par_idN10ADB" role="paragraph" l10n="NEW">Choose <emph>Format - Frame/Object - Macro</emph>.</paragraph>
148cdf0e10cSrcweir         </listitem>
149cdf0e10cSrcweir         <listitem>
150cdf0e10cSrcweir            <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>
151cdf0e10cSrcweir         </listitem>
152cdf0e10cSrcweir         <listitem>
153cdf0e10cSrcweir            <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>
154cdf0e10cSrcweir         </listitem>
155cdf0e10cSrcweir         <listitem>
156cdf0e10cSrcweir            <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>
157cdf0e10cSrcweir         </listitem>
158cdf0e10cSrcweir         <listitem>
159cdf0e10cSrcweir            <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>
160cdf0e10cSrcweir         </listitem>
161cdf0e10cSrcweir         <listitem>
162cdf0e10cSrcweir            <paragraph xml-lang="en-US" id="par_idN10AF7" role="paragraph" l10n="NEW">Select an event from the list and click <emph>OK</emph>.</paragraph>
163cdf0e10cSrcweir         </listitem>
164cdf0e10cSrcweir      </list>
165cdf0e10cSrcweir      <paragraph xml-lang="en-US" id="par_idN10798" role="heading" level="2" l10n="NEW">To assign a script to a hyperlink</paragraph>
166cdf0e10cSrcweir      <list type="ordered">
167cdf0e10cSrcweir         <listitem>
168cdf0e10cSrcweir            <paragraph xml-lang="en-US" id="par_idN1079C" role="paragraph" l10n="NEW">Position the cursor inside the hyperlink. </paragraph>
169cdf0e10cSrcweir         </listitem>
170cdf0e10cSrcweir         <listitem>
171cdf0e10cSrcweir            <paragraph xml-lang="en-US" id="par_idN10B15" role="paragraph" l10n="NEW">Choose <emph>Insert - Hyperlink</emph>.</paragraph>
172cdf0e10cSrcweir         </listitem>
173cdf0e10cSrcweir         <listitem>
174cdf0e10cSrcweir            <paragraph xml-lang="en-US" id="par_idN10B19" role="paragraph" l10n="NEW">Click the <emph>Events</emph> button.</paragraph>
175cdf0e10cSrcweir         </listitem>
176cdf0e10cSrcweir         <listitem>
177cdf0e10cSrcweir            <paragraph xml-lang="en-US" id="par_idN10B21" role="paragraph" l10n="NEW">Select and assign as stated above.</paragraph>
178cdf0e10cSrcweir         </listitem>
179cdf0e10cSrcweir      </list>
180cdf0e10cSrcweir      <paragraph xml-lang="en-US" id="par_idN1079F" role="heading" level="2" l10n="NEW">To assign a script to a graphic</paragraph>
181cdf0e10cSrcweir      <list type="ordered">
182cdf0e10cSrcweir         <listitem>
183cdf0e10cSrcweir            <paragraph xml-lang="en-US" id="par_idN107A3" role="paragraph" l10n="NEW">Select the graphic in your document. </paragraph>
184cdf0e10cSrcweir         </listitem>
185cdf0e10cSrcweir         <listitem>
186cdf0e10cSrcweir            <paragraph xml-lang="en-US" id="par_idN10B3B" role="paragraph" l10n="CHG">Choose <emph>Format - Picture - Macro</emph>.</paragraph>
187cdf0e10cSrcweir         </listitem>
188cdf0e10cSrcweir         <listitem>
189cdf0e10cSrcweir            <paragraph xml-lang="en-US" id="par_idN10B3F" role="paragraph" l10n="NEW">Select and assign as stated above.</paragraph>
190cdf0e10cSrcweir         </listitem>
191cdf0e10cSrcweir      </list>
192cdf0e10cSrcweir      <paragraph xml-lang="en-US" id="par_idN107A6" role="heading" level="2" l10n="NEW">To assign a script to a form control</paragraph>
193cdf0e10cSrcweir      <list type="ordered">
194cdf0e10cSrcweir         <listitem>
195cdf0e10cSrcweir            <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>
196cdf0e10cSrcweir         </listitem>
197cdf0e10cSrcweir         <listitem>
198cdf0e10cSrcweir            <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>
199cdf0e10cSrcweir         </listitem>
200cdf0e10cSrcweir         <listitem>
201cdf0e10cSrcweir            <paragraph xml-lang="en-US" id="par_idN10B5D" role="paragraph" l10n="NEW">Click the <emph>Events</emph> tab of the Properties dialog.</paragraph>
202cdf0e10cSrcweir         </listitem>
203cdf0e10cSrcweir         <listitem>
204cdf0e10cSrcweir            <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>
205cdf0e10cSrcweir         </listitem>
206cdf0e10cSrcweir      </list>
207cdf0e10cSrcweir      <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>
208cdf0e10cSrcweir      <list type="ordered">
209cdf0e10cSrcweir         <listitem>
210cdf0e10cSrcweir            <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>
211cdf0e10cSrcweir         </listitem>
212cdf0e10cSrcweir         <listitem>
213cdf0e10cSrcweir            <paragraph xml-lang="en-US" id="par_idN10B7F" role="paragraph" l10n="NEW">Right-click the control, then choose <emph>Properties</emph>.</paragraph>
214cdf0e10cSrcweir         </listitem>
215cdf0e10cSrcweir         <listitem>
216cdf0e10cSrcweir            <paragraph xml-lang="en-US" id="par_idN10B87" role="paragraph" l10n="NEW">Click the <emph>Events</emph> tab of the Properties dialog.</paragraph>
217cdf0e10cSrcweir         </listitem>
218cdf0e10cSrcweir         <listitem>
219cdf0e10cSrcweir            <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>
220cdf0e10cSrcweir         </listitem>
221cdf0e10cSrcweir      </list>
222cdf0e10cSrcweir   </body>
223cdf0e10cSrcweir</helpdocument>