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 2000, 2010 Oracle and/or its affiliates.
7 ' OpenOffice.org - a multi-platform office productivity suite
9 ' This file is part of OpenOffice.org.
11 ' OpenOffice.org is free software: you can redistribute it and/or modify
12 ' it under the terms of the GNU Lesser General Public License version 3
13 ' only, as published by the Free Software Foundation.
15 ' OpenOffice.org is distributed in the hope that it will be useful,
16 ' but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ' MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ' GNU Lesser General Public License version 3 for more details
19 ' (a copy is included in the LICENSE file that accompanied this code).
21 ' You should have received a copy of the GNU Lesser General Public License
22 ' version 3 along with OpenOffice.org. If not, see
23 ' <http://www.openoffice.org/license.html>
24 ' for a copy of the LGPLv3 License.
26 '/************************************************************************
28 '* owner : oliver.craemer@oracle.com
30 '* short description : tools for localisation in calc
32 '\************************************************************************************************
34 function fFunctionname ( sFunctionname_en as string ) as string
36 '///<b>The function returns the localized name of a given function in the current UI language</b>
37 '///+ -Input is the english name of the function as string
38 '///+ -Output is the localized name of the function as string
39 '///+ -If there is no translation available the fallback is the english name
41 dim sloaddocument as string
42 dim sfunctionstring as string
43 dim scelladress as string
45 use "global/tools/includes/required/t_doc2.inc"
46 const CFN = "spreadsheet:tools:includes:c_l10n_tools.in:fFunctionname "
48 sloaddocument = gTesttoolPath & "spreadsheet\tools\input\Functionnames.ods"
50 '///Load document with all functions <i>gTestToolPath</i>/spreadsheet/tools/input/Functionnames.ods
51 hFileOpenLocally( sloaddocument )
54 '///Setting selection to A1 to avoid messagebox in Search and Replace dialog.
55 call fCalcSelectRange ("A1")
56 '///Search for function by Search and Replace dialog
57 kontext "DocumentCalc"
60 kontext "FindAndReplace"
61 printlog( "Reset <Find and Replace> dialog to default settings" )
62 if ( FindAndReplace.exists( 1 ) ) then
64 SimilaritySearch.UnCheck
65 CurrentSelectionOnly.UnCheck
67 SearchForStyles.UnCheck
69 '///Setting search parameter
71 SearchFor.SetText sFunctionname_en
74 '///If a MsgBox appears the search must have failed => Fallback to english name
76 if active.getRT = 304 then
77 warnlog CFN & "Function not found, falling back to english name"
78 fFunctionname = sFunctionname_en
81 '///Throw a warning if a dialog of unexpected resource type appears
82 warnlog CFN & "Unknown message box! " & active.GetText
84 fFunctionname = sFunctionname_en
87 kontext "FindAndReplace"
88 printlog( "Reset dialog to default settings" )
89 if ( FindAndReplace.exists( 1 ) ) then
90 WholeWordsOnly.UnCheck
91 hCloseDialog( FindAndReplace, "close" )
93 warnlog( CFN & "<FindAndReplace> not open" )
99 kontext "FindAndReplace"
100 printlog( "Reset <Find and Replace> dialog to default settings" )
101 if ( FindAndReplace.exists( 1 ) ) then
102 WholeWordsOnly.UnCheck
103 hCloseDialog( FindAndReplace, "close" )
105 warnlog( CFN & "<FindAndReplace> not open" )
108 Kontext "RechenleisteCalc"
109 scelladress = Bereich.GetSelText
110 if fCalcGetCellValue (scelladress) = sFunctionname_en then
111 '///Get localised string for function by extracting functionname out of next cell
112 call fCalcSelectRange ( "B" & mid(scelladress,2) )
113 kontext ( "RechenleisteCalc" )
114 EingabeZeileCalc.TypeKeys ("<f2><mod1 a>")
116 sfunctionstring = GetClipboardText ()
117 kontext "DocumentCalc"
118 DocumentCalc.TypeKeys ("<ESCAPE>",2)
119 ' DEBUG: printlog sfunctionstring
120 ' DEBUG: printlog len(sfunctionstring)
121 ' DEBUG: printlog instr(sfunctionstring,"(")
122 fFunctionname = mid(sfunctionstring,2,(instr(sfunctionstring,"(")-2)
123 printlog " The name of the function in this locale (" & iSprache & ") is " & fFunctionname
125 warnlog CFN & "Function not found, falling back to english version"
126 fFunctionname = sFunctionname_en
129 warnlog( CFN & "Unable to open <FindAndReplace> dialog" )
133 hFileDelete( gLastWorkFile )
138 '----------------------------------------------------------------------------
141 function fError_l10n ( sError_en as string ) as string
143 '///<b>The function returns the localized name of a given error in the current UI language</b>
144 '///+ -Input is the english name of the error as string
145 '///+ -Output is the localized name of the error as string
146 '///+ -If there is no translation available the fallback is the english name
148 dim sloaddocument as string
149 dim sfunctionstring as string
150 dim scelladress as string
152 use "global/tools/includes/required/t_doc2.inc"
153 const CFN = "qa:qatesttool:spreadsheet:tools:includes:c_l10n_tools.in:fError_l10n "
155 sloaddocument = gTesttoolPath & "spreadsheet\tools\input\Errorcodes.ods"
157 '///Load document with all errorcodes <i>gTestToolPath</i>/spreadsheet/tools/input/Errorcodes.ods
158 hFileOpenLocally( sloaddocument )
160 '///Setting selection to A1 to avoid messagebox in Search and Replace dialog.
161 call fCalcSelectRange ("A1")
162 '///Search for function by Search and Replace dialog
163 kontext "DocumentCalc"
166 kontext "FindAndReplace"
167 '///Setting dialog to defaults
169 SimilaritySearch.UnCheck
170 CurrentSelectionOnly.UnCheck
172 SearchForStyles.UnCheck
174 '///Setting search parameter
176 SearchFor.SetText sError_en
179 '///If a MsgBox appears the search must have failed => Fallback to english name
180 if active.exists then
181 if active.getRT = 304 then
182 warnlog CFN & "Function not found, falling back to english name"
183 fError_l10n = sError_en
186 '///Throw a warning if a dialog of unexpected resource type appears
187 warnlog CFN & "Unknown message box! " & active.GetText
189 fError_l10n = sError_en
192 kontext "FindAndReplace"
193 '///Reset dialog to defaultsetting
194 if ( FindAndReplace.exists( 1 ) ) then
195 WholeWordsOnly.UnCheck
196 hCloseDialog( FindAndReplace, "close" )
198 warnlog( CFN & "Failed to open <FindAndReplace>" )
205 kontext "FindAndReplace"
206 '///Reset dialog to defaultsetting
207 if ( FindAndReplace.exists( 1 ) ) then
208 WholeWordsOnly.UnCheck
209 hCloseDialog( FindAndReplace, "close" )
211 warnlog( CFN & "Failed to open <FindAndReplace>" )
214 Kontext "RechenleisteCalc"
215 scelladress = Bereich.GetSelText
216 if fCalcGetCellValue (scelladress) = sError_en then
217 '///Get localised string for ERR by extracting errorcode out of next cell
218 call fCalcSelectRange ( "B" & mid(scelladress,2) )
219 kontext "DocumentCalc"
221 fError_l10n = GetClipboardText ()
222 kontext "DocumentCalc"
223 printlog " The name for ERR in this locale (" & iSprache & ") is " & fError_l10n
225 warnlog CFN & "Errorcode not found, falling back to english version"
226 fError_l10n = sError_en
230 hFileDelete( gLastWorkFile )