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: c_l10n_tools.inc,v $
13 '* last change: $Author: jsi $ $Date: 2008-06-16 08:06:09 $
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 : oliver.craemer@sun.com
36 '* short description : tools for localisation in calc
38 '**************************************************************************************************
40 ' #1 fFunctionname 'Returns the localized name of a given function in the current UI language
41 ' #1 fError_l10n 'Returns the localized name of a given errorcode in the current UI language
43 '\************************************************************************************************
45 function fFunctionname ( sFunctionname_en as string ) as string
47 '///<b>The function returns the localized name of a given function in the current UI language</b>
48 '///+ -Input is the english name of the function as string
49 '///+ -Output is the localized name of the function as string
50 '///+ -If there is no translation available the fallback is the english name
52 dim sloaddocument as string
53 dim sfunctionstring as string
54 dim scelladress as string
56 use "global/tools/includes/required/t_doc2.inc"
57 const CFN = "qa:qatesttool:spreadsheet:tools:includes:c_l10n_tools.in:fFunctionname "
59 sloaddocument = Convertpath (gTesttoolPath + "spreadsheet\tools\input\Functionnames.ods" )
61 '///Load document with all functions <i>gTestToolPath</i>/spreadsheet/tools/input/Functionnames.ods
62 call hFileOpen ( sloaddocument )
64 '///Make sure that the file is editable
65 call sMakeReadOnlyDocumentEditable()
67 '///Setting selection to A1 to avoid messagebox in Search and Replace dialog.
68 call fCalcSelectRange ("A1")
69 '///Search for function by Search and Replace dialog
70 kontext "DocumentCalc"
73 kontext "FindAndReplace"
74 '///Setting dialog to defaults
76 SimilaritySearch.UnCheck
77 CurrentSelectionOnly.UnCheck
79 SearchForStyles.UnCheck
81 '///Setting search parameter
83 SearchFor.SetText sFunctionname_en
86 '///If a MsgBox appears the search must have failed => Fallback to english name
88 if active.getRT = 304 then
89 warnlog CFN & "Function not found, falling back to english name"
90 fFunctionname = sFunctionname_en
93 '///Throw a warning if a dialog of unexpected resource type appears
94 warnlog CFN & "Unknown message box! " & active.GetText
96 fFunctionname = sFunctionname_en
98 kontext "FindAndReplace"
100 '///Reset dialog to defaultsetting
101 WholeWordsOnly.UnCheck
106 kontext "FindAndReplace"
108 '///Reset dialog to defaultsettings
109 WholeWordsOnly.UnCheck
111 Kontext "RechenleisteCalc"
112 scelladress = Bereich.GetSelText
113 if fCalcGetCellValue (scelladress) = sFunctionname_en then
114 '///Get localised string for function by extracting functionname out of next cell
115 call fCalcSelectRange ( "B" & mid(scelladress,2) )
116 kontext ( "RechenleisteCalc" )
117 EingabeZeileCalc.TypeKeys ("<f2><mod1 a>")
119 sfunctionstring = GetClipboardText ()
120 kontext "DocumentCalc"
121 DocumentCalc.TypeKeys ("<ESCAPE>",2)
122 ' DEBUG: printlog sfunctionstring
123 ' DEBUG: printlog len(sfunctionstring)
124 ' DEBUG: printlog instr(sfunctionstring,"(")
125 fFunctionname = mid(sfunctionstring,2,(instr(sfunctionstring,"(")-2)
126 printlog " The name of the function in this locale (" & iSprache & ") is " & fFunctionname
128 warnlog CFN & "Function not found, falling back to english version"
129 fFunctionname = sFunctionname_en
137 '----------------------------------------------------------------------------
140 function fError_l10n ( sError_en as string ) as string
142 '///<b>The function returns the localized name of a given error in the current UI language</b>
143 '///+ -Input is the english name of the error as string
144 '///+ -Output is the localized name of the error as string
145 '///+ -If there is no translation available the fallback is the english name
147 dim sloaddocument as string
148 dim sfunctionstring as string
149 dim scelladress as string
151 use "global/tools/includes/required/t_doc2.inc"
152 const CFN = "qa:qatesttool:spreadsheet:tools:includes:c_l10n_tools.in:fError_l10n "
154 sloaddocument = Convertpath (gTesttoolPath + "spreadsheet\tools\input\Errorcodes.ods" )
156 '///Load document with all errorcodes <i>gTestToolPath</i>/spreadsheet/tools/input/Errorcodes.ods
157 call hFileOpen ( sloaddocument )
159 '///Make sure that the file is editable
160 call sMakeReadOnlyDocumentEditable()
162 '///Setting selection to A1 to avoid messagebox in Search and Replace dialog.
163 call fCalcSelectRange ("A1")
164 '///Search for function by Search and Replace dialog
165 kontext "DocumentCalc"
168 kontext "FindAndReplace"
169 '///Setting dialog to defaults
171 SimilaritySearch.UnCheck
172 CurrentSelectionOnly.UnCheck
174 SearchForStyles.UnCheck
176 '///Setting search parameter
178 SearchFor.SetText sError_en
181 '///If a MsgBox appears the search must have failed => Fallback to english name
182 if active.exists then
183 if active.getRT = 304 then
184 warnlog CFN & "Function not found, falling back to english name"
185 fError_l10n = sError_en
188 '///Throw a warning if a dialog of unexpected resource type appears
189 warnlog CFN & "Unknown message box! " & active.GetText
191 fError_l10n = sError_en
193 kontext "FindAndReplace"
195 '///Reset dialog to defaultsetting
196 WholeWordsOnly.UnCheck
201 kontext "FindAndReplace"
203 '///Reset dialog to defaultsetting
204 WholeWordsOnly.UnCheck
206 Kontext "RechenleisteCalc"
207 scelladress = Bereich.GetSelText
208 if fCalcGetCellValue (scelladress) = sError_en then
209 '///Get localised string for ERR by extracting errorcode out of next cell
210 call fCalcSelectRange ( "B" & mid(scelladress,2) )
211 kontext "DocumentCalc"
213 fError_l10n = GetClipboardText ()
214 kontext "DocumentCalc"
215 printlog " The name for ERR in this locale (" & iSprache & ") is " & fError_l10n
217 warnlog CFN & "Errorcode not found, falling back to english version"
218 fError_l10n = sError_en