1 'encoding UTF-8 Do not remove or change this line!
2 '**************************************************************************
3 '* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 '* Copyright 2008 by Sun Microsystems, Inc.
7 '* OpenOffice.org - a multi-platform office productivity suite
9 '* $RCSfile: customize_tools.inc,v $
13 '* last change: $Author: jsi $ $Date: 2008-06-16 12:19:05 $
15 '* This file is part of OpenOffice.org.
17 '* OpenOffice.org is free software: you can redistribute it and/or modify
18 '* it under the terms of the GNU Lesser General Public License version 3
19 '* only, as published by the Free Software Foundation.
21 '* OpenOffice.org is distributed in the hope that it will be useful,
22 '* but WITHOUT ANY WARRANTY; without even the implied warranty of
23 '* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 '* GNU Lesser General Public License version 3 for more details
25 '* (a copy is included in the LICENSE file that accompanied this code).
27 '* You should have received a copy of the GNU Lesser General Public License
28 '* version 3 along with OpenOffice.org. If not, see
29 '* <http://www.openoffice.org/license.html>
30 '* for a copy of the LGPLv3 License.
32 '/******************************************************************************
34 '* owner : joerg.skottke@sun.com
36 '* short description : Tools to ease the use of the ToolsCustomize-Dialog
38 '\******************************************************************************
40 function hToolsCustomizeOpen() as boolean
42 '///<h3>Open Tools/Customize</h3>
43 '///<i>Starting point: Any plain document</i><br>
50 '///+<li>Errorstatus (boolean)</li>
52 '///+<li>TRUE if the Keyboard-Tab is open</li>
53 '///+<li>FALSE on any other case</li>
56 '///<u>Description</u>:
59 const CFN = "hToolsCustomizeOpen::"
61 '///+<li>Open Tools/Customize using the ToolsCustomize slot</li>
64 '///+<li>Switch to the Events Tab</li>
65 hToolsCustomizeSelectTab( "Events" )
67 '///+<li>Verify that the requested tabpage is open</li>
68 Kontext TabCustomizeEvents
69 if ( TabCustomizeEvents.exists() ) then
70 hToolsCustomizeOpen() = true
71 printlog( CFN & "Successfully opened ToolsCustomize" )
73 hToolsCustomizeOpen() = false
74 printlog( CFN & "Failed to open ToolsCustomize" )
76 '///+<li>Return TRUE on success</li>
81 '*******************************************************************************
83 function hToolsCustomizeSelectTab( cTab as string ) as boolean
85 '///<h3>Switch Tabpages on ToolsCustomize Dialog</h3>
86 '///<i>Starting point: The Tools/Customize dialog</i><br>
89 '///+<li>Name of the Tab (string)</li>
91 '///+<li>"Keyboard"</li>
92 '///+<li>"Menu"</li>
93 '///+<li>"Toolbars"</li>
94 '///+<li>"Events"</li>
99 '///+<li>Errorstatus (boolean)</li>
101 '///+<li>TRUE if the requested tab is open</li>
102 '///+<li>FALSE on any other condition</li>
105 '///<u>Description</u>:
108 const CFN = "hToolsCustomizeSelectTab::"
114 '///+<li>Switch to one of the four available tabpages</li>
124 '///+<li>Keyboard</li>
125 case "keyboard" : active.setPage TabTastatur
126 kontext "TabTastatur"
127 if ( Aendern.isVisible() ) then
131 case "menu" : active.setPage TabCustomizeMenu
132 kontext "TabCustomizeMenu"
133 if ( Entries.isVisible() ) then
136 '///+<li>Toolbars</li>
137 case "toolbars" : active.setPage TabCustomizeToolbars
138 kontext "TabCustomizeToolbars"
139 if ( ToolbarContents.isVisible() ) then
143 case "events" : active.setPage TabCustomizeEvents
144 kontext "TabCustomizeEvents"
145 if ( AssignMacro.isVisible() ) then
153 printlog( CFN & "Could not access requested tabpage" )
159 printlog( CFN & "Opened Tab: " & cTab )
161 printlog( CFN & "Failed to open Tab: " & cTab )
164 '///+<li>Return TRUE on success</li>
166 hToolsCustomizeSelectTab() = brc
170 '*******************************************************************************
172 function hToolsCustomizeClose( iMode as integer ) as boolean
174 '///<h3>Close the ToolsCustomize-Dialog</h3>
175 '///<i>Starting point: Tools/Customize dialog</i><br>
178 '///+<li>Closing mode (integer)</li>
180 '///+<li>1: Use OK-button</li>
181 '///+<li>2: Use Cancel-button</li>
186 '///+<li>Errorstatus (boolean)</li>
188 '///+<li>TRUE if executing close action succeeded</li>
189 '///+<li>FALSE on any other condition</li>
192 '///<u>Description</u>:
195 const CFN = "hToolsCustomizeClose::"
201 '///+<li>Switch to the Events page by default</li>
202 active.setPage( TabCustomizeEvents )
204 '///+<li>Close dialog by OK or CANCEL</li>
208 case 1 : TabCustomizeEvents.OK()
210 case 2 : TabCustomizeEvents.Cancel()
216 '///+<li>Verify that the dialog has indeed been closed</li>
217 kontext "TabCustomizeEvents"
218 if ( TabCustomizeEvents.exists() ) then
223 printlog( CFN & "Closed Tools/Customize" )
225 printlog( CFN & "Failed to close Tools/Customize" )
229 hToolsCustomizeClose() = brc
232 '*******************************************************************************
234 function hToolsCustomizeAddNewMenu( cName as string, bMode as boolean ) as boolean
236 '///<h3>Add a new menu via Tools/Customize/Menu</h3>
237 '///<i>Starting point: Tools/Customize with Menu-Tab open</i><br>
240 '///+<li>Name of the new menu (string)</li>
241 '///+<li>Mode (boolean). Options:</li>
243 '///+<li>TRUE = The entry will be created (OK)</li>
244 '///+<li>FALSE = The entry will not be created (Cancel)</li>
249 '///+<li>Errorstatus (boolean)</li>
251 '///+<li>TRUE on success</li>
252 '///+<li>FALSE on failure</li>
255 '///<u>Description</u>:
258 const CFN = "hToolsCustomizeAddNewMenu::"
262 '///+<li>Click the "New..." button</li>
263 kontext "TabCustomizeMenu"
266 '///+<li>Verify that the menu organizer exists</li>
267 Kontext "MenuOrganiser"
268 if ( not MenuName.exists() ) then
269 printlog( CFN & "MenuOrganiser is not open" )
273 '///+<li>Name the new menu if we intend to create the new entry</li>
275 printlog( CFN & "Naming menu: " & cName )
276 MenuName.setText( cName )
280 call DialogTest( MenuOrganiser )
281 printlog( CFN & "Opened and closed MenuOrganiser" )
282 MenuOrganiser.cancel()
286 hToolsCustomizeAddNewMenu() = brc
291 '*******************************************************************************
293 function hDeselectSeparator() as integer
295 '///<h3>Make sure that we do not work on a separator item (Toolbars)</h3>
296 '///<i>Starting point: Tools/Customize: Toolbars must be open</i><br>
299 '///+<li>Nothing</li>
303 '///+<li>Position of the selected item (integer)</li>
305 '///+<li>Always > 1</li>
306 '///+<li>Always < Max number of items</li>
309 '///<u>Description</u>:
313 dim iCurrentItem as integer
314 dim cString as string
316 const CFN = "hDeselectSeparator::"
318 kontext "ToolsCustomizeToolbars"
319 if ( ToolbarContents.getItemCount > 0 ) then
321 iCurrentItem = ToolbarContents.getSelIndex()
322 cString = ToolbarContents.getSelText()
324 '///+<li>Check whether the selected item contains a number of minus-chars (---)</li>
325 if ( instr( cString , "----" ) ) then
327 '///+<li>If we are at the beginning of the list: Move up</li>
328 if ( iCurrentItem = 1 ) then
330 ToolbarContents.select( irc )
331 printlog( CFN & " Moved away from separator (up)" )
333 '///+<li>If we are somewhere else in the list, move down</li>
334 irc = iCurrentItem - 1
335 ToolbarContents.select( irc )
336 printlog( CFN & " Moved away from separator (down)" )
344 hDeselectSeparator() = irc
349 '*******************************************************************************