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: t_accels.inc,v $
13 '* last change: $Author: jsk $ $Date: 2008-06-20 07:57:02 $
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 : handle accelerators
38 '*******************************************************************************
40 ' #1 hGetAccel ' function to retrieve a language specific accelerator
42 '\******************************************************************************
44 function hGetAccel( cCommand as string ) as string
46 '///<h3>Retrieve a keyboard accelerator for a specific function</h3>
47 '///<i>Uses: global/input/accelerators.txt</i><br>
48 '///<i>NOTE: Accelerator is language dependent</i><br>
51 '///+<li>Name of the action to be executed (string). Valid options are:</li>
53 '///+<li>"FileOpen"</li>
54 '///+<li>"FileSave"</li>
55 '///+<li>"Print"</li>
56 '///+<li>"SelectAll"</li>
57 '///+<li>"Copy"</li>
58 '///+<li>"DocumentConverter_ShowLog"</li>
59 '///+<li>"IDE_SWITCH_TAB+"</li>
60 '///+<li>"IDE_SWITCH_TAB-"</li>
65 '///+<li>Accelerator (string)</li>
67 '///+<li>A string ready to use by .typeKeys(...) method</li>
68 '///+<li>"Error" if the requested Accelerator is unknown</li>
71 '///<u>Description</u>:
73 const CFN = "hGetAccel::"
74 const DEFAULT_LANGUAGE = "en-us"
77 dim lsAccelerators( 1000 ) as string
79 cFile = gTesttoolpath & "global/input/accelerators.txt"
80 cFile = convertpath( cFile )
82 dim cProximityLocale as string
86 printlog( CFN & "Enter with option: " & cCommand )
87 'printlog( CFN & "Current Language.: <" & gISOLang & ">" )
89 '///+<li>Get the section from the accelerators file</li>
90 hGetDatafileSection( cFile , lsAccelerators() , cCommand , "" , "" )
92 '///+<li>Find the matching string for the current language</li>
93 cAccel = hGetValueForKeyAsString( lsAccelerators() , gISOLang )
95 '///+<li>In case of a miss we retry with a modified string</li>
97 if ( instr( cAccel , "Error" ) <> 0 ) then
99 iLang = len( gISOLang )
103 '///+<li>Try xx-XX</li>
104 cProximityLocale = gISOLang & "-" & ucase( gISOLang )
105 printlog( CFN & "Trying alternative locale: " & cProximityLocale )
106 cAccel = hGetValueForKeyAsString( lsAccelerators() , cProximityLocale )
109 cProximityLocale = mid( cUpperCaseLocale , 1, 2 )
110 printlog( CFN & "Trying alternative locale: " & cProximityLocale )
111 cAccel = hGetValueForKeyAsString( lsAccelerators() , cProximityLocale )
113 '///+<li>Try en-US</li>
114 cProximityLocale = "en-US"
115 printlog( CFN & "Trying default locale: " & cProximityLocale )
116 cAccel = hGetValueForKeyAsString( lsAccelerators() , DEFAULT_LANGUAGE )
122 '///+<li>Build the complete accelerator-string so it can be used by "TypeKeys"</li>
123 '///+<li>Print it to the log and return the string to the calling function</li>
125 cAccel = "<" & cAccel & ">"
126 printlog( CFN & "Requested accelerator: " & cAccel & " for language: " & gISOLang )