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