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: tools2.inc,v $
13 '* last change: $Author: vg $ $Date: 2008-08-18 12:38:33 $
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 : helge.delfs@sun.com
36 '* short description : Tools for writer/Optional - 2
38 '************************************************************************
40 ' #1 fStartupNavigator
43 ' #1 fCalculateTolerance
47 '\***********************************************************************
49 function fStartupNavigator(navigatorItem as String , subItemNum as Integer)
50 '/// Start up Navigator , and set focus to the correct position
54 if NOT Navigator.Exists then
58 Kontext "NavigatorWriter"
59 if Auswahlliste.GetItemCount < 11 then
63 Auswahlliste.TypeKeys "<Home>" '<- Set focus to first entry
64 if Auswahlliste.GetItemCount > 11 then '<- If nodes are open
65 For j= 1 to 12 '<- close all nodes
68 Auswahlliste.TypeKeys "-"
72 Auswahlliste.TypeKeys "<Home>" ' point focus to first entry
75 Select case navigatorItem
76 case "Headings" : goto GoON
77 case "Tables" : Auswahlliste.TypeKeys "<down>"
78 case "TextFrame" : Auswahlliste.TypeKeys "<down>" , 2
79 case "Graphics" : Auswahlliste.TypeKeys "<down>" , 3
80 case "OLEObject" : Auswahlliste.TypeKeys "<down>" , 4
81 case "Bookmarks" : Auswahlliste.TypeKeys "<down>" , 5
82 case "Section" : Auswahlliste.TypeKeys "<down>" , 6
83 case "Hyperlinks" : Auswahlliste.TypeKeys "<down>" , 7
84 case "References" : Auswahlliste.TypeKeys "<down>" , 8
85 case "Indexes" : Auswahlliste.TypeKeys "<down>" , 9
86 case "Notes" : Auswahlliste.TypeKeys "<down>" , 10
87 case "DrawObjects" : Auswahlliste.TypeKeys "<down>" , 11
91 Auswahlliste.TypeKeys "<return>"
95 Auswahlliste.TypeKeys "<Up>",subItemNum
99 '-------------------------------------------------------------------------
101 function fCloseNavigator
105 if Navigator.Exists(2) then
111 '-------------------------------------------------------------------------
113 function StrToDouble ( sWert$ ) as Double
114 '/// Transfer String to Double , including
120 dim i, i1, i2 as integer
126 '/// Input : {'a[. ,]b[mm cm " pi pt]' with a, b as integer} as String
127 '///+ Output: a[. , ]b as double
129 ' get rid of measure unit, the only single character is '"' all others are two chars
131 if (isNumeric (sWert$) = FALSE) then
132 if ( (StrComp (right (sWert$, 1), chr$(34) ) = 0) OR (StrComp (right (sWert$, 1), "%") = 0 )) then
133 sDummy$ = Left ( sWert$, Len(sWert$)-1 )
135 sDummy$ = Left ( sWert$, Len(sWert$)-Len(gMeasurementUnit) )
140 ' get position of fraction mark
141 i1 = instr (sDummy$, ",") ' wrong output
142 i2 = instr (sDummy$, ".")
143 if i1 > i2 then i = i1 else i = i2
146 a = val (left (sDummy$,i-1))
153 n = (len (sDummy$)-i)
154 b = val (right (sDummy$, n) )
160 '-------------------------------------------------------------------------
162 function fCalculateTolerance (sNumber1 , sNumber2) as Single
163 '/// Change 2 parameters to number , then Compare them and return the result.
165 Dim dNumber1 , dNumber2 as Single
166 Dim iCommaLocation1 , iCommaLocation2 as Integer
168 'the code below 4 lines is set "2,00cm" to "2.00"cm if needed
169 iCommaLocation1 = InStr(sNumber1 , ",")
170 if iCommaLocation1 > 0 then
171 sNumber1 = Left(sNumber1 , iCommaLocation1-1) + "." + Right(sNumber1,Len(sNumber1) - iCommaLocation1)
174 iCommaLocation2 = InStr(sNumber2 , ",")
175 if iCommaLocation2 > 0 then
176 sNumber2 = Left(sNumber2 , iCommaLocation2-1) + "." + Right(sNumber2,Len(sNumber2) - iCommaLocation2)
179 dNumber1 = Val( Left(sNumber1, Len(sNumber1)-Len(gMeasurementUnit) ))
180 dNumber2 = Val( Left(sNumber2, Len(sNumber2)-Len(gMeasurementUnit) ))
182 fCalculateTolerance = Abs( dNumber1 - dNumber2 )
185 '-------------------------------------------------------------------------
187 function fFindWord (sTest) as String
188 '/// Set the focus to the word which you want
191 Kontext "FindAndReplace"
192 SearchFor.SetText sTest
199 '-------------------------------------------------------------------------
201 function fGetLanguageName( CountryID as Integer ) as String
202 '/// This routine will return the Language name based on CountryID
204 case 01 : ' English (USA)
205 select case CountryID
206 case 1: fGetLanguageName = "English (USA)"
207 case 31: fGetLanguageName = "Dutch (Netherlands)"
208 case 33: fGetLanguageName = "French (France)"
209 case 34: fGetLanguageName = "Spanish (Spain)"
210 case 39: fGetLanguageName = "Italian (Italy)"
211 case 46: fGetLanguageName = "Swedish (Sweden)"
212 case 49: fGetLanguageName = "German (Germany)"
213 case 55: fGetLanguageName = "Portuguese (Brazil)"
214 case 81: fGetLanguageName = "Japanese"
215 case 82: fGetLanguageName = "Korean (RoK)"
216 case 86: fGetLanguageName = "Chinese (simplified)"
217 case 88: fGetLanguageName = "Chinese (traditional)"
219 QAErrorLog "Now, the test does not support for the language " +iSprache
220 fGetLanguageName = ""
224 select case CountryID
225 case 1: fGetLanguageName = "Engels (VS)"
226 case 31: fGetLanguageName = "Netherlands (NL)"
227 case 33: fGetLanguageName = "Frans (Frankrijk)"
228 case 34: fGetLanguageName = "Spaans (Spanje)"
229 case 39: fGetLanguageName = "Italiaans (Itali�)"
230 case 46: fGetLanguageName = "Zweeds (Zweden)"
231 case 49: fGetLanguageName = "Duits (Duitsland)"
232 case 55: fGetLanguageName = "Portugees (Brazili�)"
233 case 81: fGetLanguageName = "Japans"
234 case 82: fGetLanguageName = "Korean (RoK)"
235 case 86: fGetLanguageName = "Chinese (vereenvoudigd)"
236 case 88: fGetLanguageName = "Chinese (traditioneel)"
238 QAErrorLog "Now, the test does not support for the language " +iSprache
239 fGetLanguageName = ""
243 select case CountryID
244 case 1: fGetLanguageName = "Anglais (U.S.A.)"
245 case 31: fGetLanguageName = "N�erlandais (Pays-Bas)"
246 case 33: fGetLanguageName = "Français (France)"
247 case 34: fGetLanguageName = "Espagnol (Espagne)"
248 case 39: fGetLanguageName = "Italien (Italie)"
249 case 46: fGetLanguageName = "Suédois (Suède)"
250 case 49: fGetLanguageName = "Allemand (Allemagne)"
251 case 55: fGetLanguageName = "Portugais (Brésil)"
252 case 81: fGetLanguageName = "Japonais"
253 case 82: fGetLanguageName = "Coréen"
254 case 86: fGetLanguageName = "Chinois (simple)"
255 case 88: fGetLanguageName = "Chinois (traditionnel)"
257 QAErrorLog "Now, the test does not support for the language " +iSprache
258 fGetLanguageName = ""
262 select case CountryID
263 case 1: fGetLanguageName = "Inglés (EE.UU.)"
264 case 31: fGetLanguageName = "Holand�s (Pa�ses Bajos)"
265 case 33: fGetLanguageName = "Francés (Francia)"
266 case 34: fGetLanguageName = "Español (España)"
267 case 39: fGetLanguageName = "Italiano (Italia)"
268 case 46: fGetLanguageName = "Sueco (Suecia)"
269 case 49: fGetLanguageName = "Alemán (Alemania)"
270 case 55: fGetLanguageName = "Portugués (Brasil)"
271 case 81: fGetLanguageName = "Japonés"
272 case 82: fGetLanguageName = "Coreano"
273 case 86: fGetLanguageName = "Chino (simple)"
274 case 88: fGetLanguageName = "Chino (tradicional)"
276 QAErrorLog "Now, the test does not support for the language " +iSprache
277 fGetLanguageName = ""
281 select case CountryID
282 case 1: fGetLanguageName = "Inglese (US)"
283 case 31: fGetLanguageName = "Olandese (Paesi Bassi)"
284 case 33: fGetLanguageName = "Francese (Francia)"
285 case 34: fGetLanguageName = "Spagnolo (Spagna)"
286 case 39: fGetLanguageName = "Italiano (Italia)"
287 case 46: fGetLanguageName = "Svedese (Svezia)"
288 case 49: fGetLanguageName = "Tedesco (Germania)"
289 case 55: fGetLanguageName = "Portoghese (Brasile)"
290 case 81: fGetLanguageName = "Giapponese"
291 case 82: fGetLanguageName = "Coreano"
292 case 86: fGetLanguageName = "Cinese (semplificato)"
293 case 88: fGetLanguageName = "Cinese (tradizionale)"
295 QAErrorLog "Now, the test does not support for the language " +iSprache
296 fGetLanguageName = ""
300 select case CountryID
301 case 1: fGetLanguageName = "engelska"
302 case 31: fGetLanguageName = "Holl�ndska (Nederl�nderna)"
303 case 33: fGetLanguageName = "franska (Frankrike)"
304 case 34: fGetLanguageName = "spanska (Spanien)"
305 case 39: fGetLanguageName = "italienska (Italien)"
306 case 46: fGetLanguageName = "svenska (Sverige)"
307 case 49: fGetLanguageName = "tyska (Tyskland)"
308 case 55: fGetLanguageName = "portugisiska (Brasilien)"
309 case 81: fGetLanguageName = "japanska"
310 case 82: fGetLanguageName = "koreanska"
311 case 86: fGetLanguageName = "kinesiska (enkel)"
312 case 88: fGetLanguageName = "kinesiska (trad.)"
314 QAErrorLog "Now, the test does not support for the language " +iSprache
315 fGetLanguageName = ""
319 select case CountryID
320 case 1: fGetLanguageName = "Englisch (USA)"
321 case 31: fGetLanguageName = "Niederl�ndisch (Niederlande)"
322 case 33: fGetLanguageName = "Französisch (Frankreich)"
323 case 34: fGetLanguageName = "Spanisch (Spanien)"
324 case 39: fGetLanguageName = "Italienisch (Italien)"
325 case 46: fGetLanguageName = "Schwedisch (Schweden)"
326 case 49: fGetLanguageName = "Deutsch (Deutschland)"
327 case 55: fGetLanguageName = "Portugiesisch (Brasilien)"
328 case 81: fGetLanguageName = "Japanisch"
329 case 82: fGetLanguageName = "Koreanisch"
330 case 86: fGetLanguageName = "Chinesisch (einfach)"
331 case 88: fGetLanguageName = "Chinesisch (Trad.)"
333 QAErrorLog "Now, the test does not support for the language " +iSprache
334 fGetLanguageName = ""
337 case 55 : ' Portuguese
338 select case CountryID
339 case 1: fGetLanguageName = "Inglês (EUA)"
340 case 31: fGetLanguageName = "Holand�s (Holanda)"
341 case 33: fGetLanguageName = "Francês (França)"
342 case 34: fGetLanguageName = "Espanhol (Espanha)"
343 case 39: fGetLanguageName = "Italiano (Itália)"
344 case 46: fGetLanguageName = "Sueco (Suécia)"
345 case 49: fGetLanguageName = "Alemão (Alemanha)"
346 case 55: fGetLanguageName = "Português (Brasil)"
347 case 81: fGetLanguageName = "Japonês"
348 case 82: fGetLanguageName = "Coreano"
349 case 86: fGetLanguageName = "Chinês (simplificado)"
350 case 88: fGetLanguageName = "Chinês (Tradicional)"
352 QAErrorLog "Now, the test does not support for the language " +iSprache
353 fGetLanguageName = ""
357 select case CountryID
358 case 1: fGetLanguageName = "英語(米国)"
359 case 33: fGetLanguageName = "フランス語(フランス)"
360 case 34: fGetLanguageName = "スペイン語(スペイン)"
361 case 39: fGetLanguageName = "イタリア語(イタリア)"
362 case 46: fGetLanguageName = "スウェーデン語(スウェーデン)"
363 case 49: fGetLanguageName = "ドイツ語(ドイツ)"
364 case 55: fGetLanguageName = "�?ルトガル語(ブラジル)"
365 case 81: fGetLanguageName = "日本語"
366 case 82: fGetLanguageName = "韓国語"
367 case 86: fGetLanguageName = "中国語(簡体字)"
368 case 88: fGetLanguageName = "中国語(�?体字)"
370 QAErrorLog "Now, the test does not support for the language " +iSprache
371 fGetLanguageName = ""
375 select case CountryID
376 case 1: fGetLanguageName = "�?어(미국)"
377 case 33: fGetLanguageName = "스페�?�어(스페�?�)"
378 case 34: fGetLanguageName = "프랑스어(프랑스)"
379 case 39: fGetLanguageName = "�?�탈리아어 (�?�태리)"
380 case 46: fGetLanguageName = "스웨�?�어(스웨�?�)"
381 case 49: fGetLanguageName = "�?��?�어(�?��?�)"
382 case 55: fGetLanguageName = "�?�르투갈어(브�?�질)"
383 case 81: fGetLanguageName = "�?�본어"
384 case 82: fGetLanguageName = "한국어"
385 case 86: fGetLanguageName = "중국어(간체)"
386 case 88: fGetLanguageName = "중국어(번체)"
388 QAErrorLog "Now, the test does not support for the language " +iSprache
389 fGetLanguageName = ""
392 case 86 : ' Chinese (simplified)
393 select case CountryID
394 case 1: fGetLanguageName = "英语(美国)"
395 case 33: fGetLanguageName = "法语(法国)"
396 case 34: fGetLanguageName = "西�?�牙语(西�?�牙)"
397 case 39: fGetLanguageName = "�?大利语(�?大利)"
398 case 46: fGetLanguageName = "瑞典语(瑞典)"
399 case 49: fGetLanguageName = "德语(德国)"
400 case 55: fGetLanguageName = "葡�?�牙语(巴西)"
401 case 81: fGetLanguageName = "日语"
402 case 82: fGetLanguageName = "�?鲜语"
403 case 86: fGetLanguageName = "中文(简体字)"
404 case 88: fGetLanguageName = "中文(�?体字)"
406 QAErrorLog "Now, the test does not support for the language " +iSprache
407 fGetLanguageName = ""
410 case 88 : ' Chinese (traditional)
411 select case CountryID
412 case 1: fGetLanguageName = "英語(美國)"
413 case 33: fGetLanguageName = "法語(法國)"
414 case 34: fGetLanguageName = "西�?�牙語(西�?�牙)"
415 case 39: fGetLanguageName = "�?大利語(�?大利)"
416 case 46: fGetLanguageName = "瑞典語(瑞典)"
417 case 49: fGetLanguageName = "德語(德國)"
418 case 55: fGetLanguageName = "葡�?�牙語(巴西)"
419 case 81: fGetLanguageName = "日語"
420 case 82: fGetLanguageName = "韓語"
421 case 86: fGetLanguageName = "中文(簡體字)"
422 case 88: fGetLanguageName = "中文(�?體)"
424 QAErrorLog "Now, the test does not support for the language " +iSprache
425 fGetLanguageName = ""
428 case else : ' Fallback
429 QAErrorLog "Now, the test does not support for the language " +iSprache
430 fGetLanguageName = ""