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: help_tools.inc,v $
13 '* last change: $Author: jsi $ $Date: 2008-06-16 12:19:06 $
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 : Replacements for routines in t_lists.inc adds some
38 '\******************************************************************************
40 function hOpenHelp() as boolean
42 '///<h3>Function to open the Help Browser</h3>
50 '///+<li>Errorcondition (boolean)</li>
52 '///+<li>TRUE if the help is open</li>
53 '///+<li>FALSE if the help did not open</li>
57 '///<u>Description</u>:
59 const CFN = "hOpenHelp::"
65 printlog( CFN & "Enter" )
67 '///+<li>Open the help Browser using the slot</li>
71 printlog( CFN & "Failed to open help, slot failed" )
76 '///+<li>Verify that the help is indeed open (max 10 sec.)</li>
77 Kontext "StarOfficeHelp"
80 if ( StarOfficeHelp.exists() ) then
89 '///+<li>Print a status to the log, return TRUE or FALSE</li>
91 printlog( CFN & "Exit: Help is open" )
93 printlog( CFN & "Exit: Help is not open" )
95 if ( Active.exists( 2 ) ) then
96 printlog( "Msgbox: " & Active.getText()
106 '*******************************************************************************
108 function hCloseHelp() as boolean
110 '///<h3>Function to close the Help Browser</h3>
113 '///+<li>Nothing</li>
118 '///+<li>Errorcondition (boolean)</li>
120 '///+<li>TRUE if the help is closed</li>
121 '///+<li>FALSE if the help did not close</li>
125 '///<u>Description</u>:
127 const CFN = "hCloseHelp::"
130 printlog( CFN & "Enter" )
132 '///+<li>Verify that the Help Browser is Open</li>
133 kontext "StarOfficeHelp"
134 if ( not StarOfficeHelp.exists() ) then
135 printlog( CFN & "Help is not open" )
140 '///+<li>Close the Help Browser by typing CTRL+F4</li>
141 StarOfficeHelp.typeKeys( "<MOD1 F4>" )
143 '///+<li>Verify that the Help Browser is not open (anymore)</li>
144 kontext "StarOfficeHelp"
145 if ( StarOfficeHelp.exists() ) then
146 printlog( CFN & "Exit: Help is still open" )
149 printlog( CFN & "Exit: Help has been closed" )
153 '///+<li>Return TRUE or FALSE</li>
159 '******************************************************************************
161 function hSelectHelpTab( cTab as string ) as boolean
163 '///<h3>Select a tab on the help dialog by name</h3>
166 '///+<li>The tab to open (string)</li>
168 '///+<li>"content" for the contents tab</li>
169 '///+<li>"index" for the index tab</li>
170 '///+<li>"find" for the find tab</li>
171 '///+<li>"bookmarks" for the bookmarks tab</li>
177 '///+<li>Errorcondition (boolean)</li>
179 '///+<li>TRUE if the requested tabpage is open</li>
180 '///+<li>FALSE if the requested tabpage did not open</li>
184 '///<u>Description</u>:
186 const CFN = "hSelectHelpTab::"
191 dim cTabName as string
192 cTabName = lcase( cTab )
194 kontext "StarOfficeHelp"
196 printlog( CFN & "Enter" )
198 '///+<li>Select the requested Tabpage, verify that it is open</li>
200 case "content" : TabControl.setPage( ContentPage )
201 if ( SearchContent.isVisible() ) then
204 case "index" : TabControl.setPage( IndexPage )
205 if ( SearchIndex.isVisible() ) then
208 case "find" : TabControl.setPage( FindPage )
209 if ( SearchFind.isVisible() ) then
212 case "bookmarks" : TabControl.setPage( BookmarksPage )
213 if ( Bookmarks.isVisible() ) then
217 printlog( CFN & "Invalid parameter passed to function: " & cTab )
218 printlog( CFN & "Valid are: content, index, find, bookmarks" )
222 '///+<li>Print a comment to the log</li>
224 printlog( CFN & "Exit: Selected Tabpage: " & cTab )
227 '///+<li>Return TRUE or FALSE</li>
228 hSelectHelpTab() = brc
233 '*******************************************************************************
235 function hUseBookmarksContextMenu( cAction as string ) as boolean
237 '///<h3>handle the bookmarks context menu in Help Browser</h3>
240 '///+<li>The context item to execute (string)</li>
242 '///+<li>"show"</li>
243 '///+<li>"rename"</li>
244 '///+<li>"delete"</li>
250 '///+<li>Errorcondition (boolean)</li>
252 '///+<li>TRUE on success</li>
253 '///+<li>FALSE on any other error</li>
257 '///<u>Description</u>:
259 const CFN = "hUseBookmarksContextMenu::"
260 dim cSelection as string
261 dim iActionPos as integer
263 printlog( CFN & "Enter" )
265 '///+<li>Verify that we are on the Bookmarks Page</li>
266 Kontext "BookmarksPage"
267 if ( not BookmarksPage.exists() ) then
268 printlog( CFN & "BookmarksPage is not open" )
269 hUseBookmarksContextMenu() = false
273 '///+<li>Find the index of the requested entry</li>
274 cSelection = lcase( cAction )
275 select case cSelection
276 case "show" : iActionPos = 1
277 case "rename" : iActionPos = 2
278 case "delete" : iActionPos = 3
279 case else : iActionPos = 0
282 '///+<li>If action is unsuported, return false and exit the function</li>
283 if ( iActionPos = 0 ) then
284 printlog( CFN & "Invalid action passed to function" )
285 hUseBookmarksContextMenu() = false
289 '///+<li>Open the context menu and select the requested index</li>
291 Bookmarks.openContextMenu()
292 printlog( CFN & "Exit: Opening item: " & MenuGetItemText( iActionPos ) )
293 MenuSelect( iActionPos )
295 '///+<li>Return TRUE if all went well so far</li>
296 hUseBookmarksContextMenu() = true
302 '*******************************************************************************
304 function hHelpGetAboutItemCount() as integer
306 '///<h3>Get the number of applications listed in the Help ListBox</h3>
310 '///+<li>Nothing</li>
315 '///+<li>Number of applications listed (integer)</li>
317 '///+<li>The default is 7</li>
321 '///<u>Description</u>:
324 const I_ABOUT_ITEMS = 8
325 const CFN = "hHelpGetAboutItemCount::"
328 dim cItemName as string
329 dim iAboutItems as integer
332 printlog( CFN & "Enter" )
334 '///+<li>Open Help</li>
337 qaerrorlog( CFN & "Help not open, aborting" )
338 hHelpGetAboutItemCount() = 0
342 hSelectHelpTab( "index" )
345 '///+<li>get the number of applications from the drop down box</li>
346 iAboutItems = HelpAbout.getItemCount()
347 if ( iAboutItems <> I_ABOUT_ITEMS ) then
348 warnlog( "The list of topics is incomplete:" )
351 '///+<li>Print the list of items to the log</li>
352 printlog( CFN & "Items listed in Application Listbox (HelpAbout)" )
353 for iItem = 1 to iAboutItems
354 cItemName = HelpAbout.getItemText( iItem )
355 printlog( " " & cItemName )
358 '///+<li>close help</li>
362 printlog( CFN & "Exit with item count = " & iAboutItems )
363 hHelpGetAboutItemCount() = iAboutItems
367 '*******************************************************************************
369 function hHelpGetSearchIndexItemCount() as integer
371 '///<h3>Get the number of items in the Help Search Index</h3>
372 '///<i>Starting point: Help / Index page</i><br>
373 '///<i>Note: Workaround for incorrect value returned by .getItemCount()</i><br>
377 '///+<li>Nothing</li>
382 '///+<li>Number of items in the list (integer)</li>
385 '///<u>Description</u>:
388 const CFN = "hHelpGetSearchIndexItemCount:"
391 printlog( CFN & "Enter" )
393 '///+<li>Run through the list and count the items, break on error</li>
394 for iItem = 1 to 10000
397 SearchIndex.select( iItem )
405 printlog( CFN & "Exit with item count = " & iItem )
406 hHelpGetSearchIndexItemCount() = iItem
411 '*******************************************************************************
413 function hGetHelpContentHeader( iLength as integer ) as string
416 '///<h3>Get the header of the content in the help browser</h3>
417 '///<i>This is the first line of the content page, truncated (if desired)</i><br><br>
419 '///<u>Parameter(s):</u><br>
421 '///+<li>Length of the requested string (Integer)</li>
423 '///+<li>The max length of the string to be returned</li>
424 '///+<li>≤ 0 = do not truncate</li>
429 '///<u>Returns:</u><br>
431 '///+<li>Header (String)</li>
433 '///+<li>A string containing the content header</li>
434 '///+<li>The header is the first line of the content page</li>
438 const CFN = "hGetHelpContentHeader::"
439 printlog( CFN & "Enter with option (iLength): " & iLength )
440 dim cHeaderString as string
442 '///<u>Description:</u>
444 '///+<li>Maximize the help viewer (required to avoid cut off strings)</li>
445 kontext "HelpContent"
446 'StarOfficeHelp.maximize()
448 '///+<li>Go to the top left position in the help browser</li>
449 HelpContent.typeKeys( "<MOD1 HOME>" )
451 '///+<li>Mark the entire line - note that this ends at the linebreak</li>
452 HelpContent.typeKeys( "<SHIFT END>" )
454 '///+<li>Copy the string to the clipboard</li>
457 '///+<li>Assign the string to a variable</li>
458 cHeaderString = getClipboardText
460 '///+<li>Truncate string</li>
461 if ( iLength > 0 ) then
462 if ( len( cHeaderString ) > iLength ) then
463 cHeaderString = left( cHeaderString, iLength )
468 printlog( CFN & "Exit: " & cHeaderString )
469 hGetHelpContentHeader() = cHeaderString