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: g_autocorrection.inc,v $
13 '* last change: $Author: jsi $ $Date: 2008-06-16 10:42:39 $
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 : wolfram.garten@sun.com
36 '* short description :
38 '*******************************************************************
40 ' #1 tToolsAutocorrectReplace
41 ' #1 tToolsAutocorrectExceptions
42 ' #1 tToolsAutocorrectCustomQuotes
43 ' #1 tToolsAutocorrectOption
45 '\*******************************************************************
47 ' Tools->Autocorrect...
48 ' Replace; Exceptions; Options; Custom Quotes
52 ' box only enabled, if the both tabpages are selected ...
54 testcase tToolsAutocorrectReplace
64 active.SetPage TabErsetzung
65 Kontext "TabErsetzung"
66 iTemp = WelcheSprache.GetItemCount
68 WelcheSprache.select i
70 x = Liste.getItemCount
71 ' results from an english version:
72 ' - 28: English (UK): 807
73 ' - 29: English (USA): 807
74 ' - 38: French (France): 304
75 ' - 43: German (Germany): 100
76 ' - 102: Spanish (Spain): 353
78 printlog " - " + i + ": " + WelcheSprache.getSelText + ": " + x
79 ' printlog " " + Liste.getItemText (5,1) + " - " + Liste.getItemText (5,2)
87 testcase tToolsAutocorrectExceptions
97 active.SetPage TabAusnahmen
98 Kontext "TabAusnahmen"
99 iTemp = WelcheSprache.GetItemCount
101 WelcheSprache.select i
103 x = AbkuerzungenListe.getItemCount
104 ' results from an english version:
105 ' - 28: English (UK): 120
106 ' - 28: English (UK): 7
107 ' - 29: English (USA): 120
108 ' - 29: English (USA): 7
109 ' - 38: French (France): 50
110 ' - 38: French (France): 1
111 ' - 43: German (Germany): 123
112 ' - 43: German (Germany): 20
113 ' - 102: Spanish (Spain): 115
114 ' - 102: Spanish (Spain): 1
116 printlog " - " + i + ": " + WelcheSprache.getSelText + ": " + x
117 ' printlog " " + AbkuerzungenListe.getItemText (5)
119 y = WoerterListe.getItemCount
121 printlog " - " + i + ": " + WelcheSprache.getSelText + ": " + y
122 ' printlog " " + WoerterListe.getItemText (5)
130 '-------------------------------------------------------------------------------
131 testcase tToolsAutocorrectCustomQuotes(bSimple as boolean)
133 ' bSinple = true: use simple quotes ;; else Double Quotes
138 dim sFileName as string
140 if (gApplication = "IMPRESS") then
141 ExtensionString = "odp"
143 ExtensionString = "odg"
146 if iSprache = "1" OR iSprache = "33" OR iSprache = "34" OR iSprache = "36" OR iSprache = "39" OR iSprache = "46" OR iSprache = "48" OR iSprache = "49" OR iSprache = "55" then
147 sFileName = (ConvertPath ( gTesttoolPath + "graphics\required\input\rightfont" & iSprache & "." + ExtensionString ))
148 elseif bAsianLan = true then
149 Printlog "Language-file for Asian language " & iSprache & " is missing. Using standard instead."
150 sFileName = (ConvertPath ( gTesttoolPath + "graphics\required\input\rightfont." + ExtensionString))
152 warnlog "Language-file for language " & iSprache & " is missing. Using standard instead."
153 sFileName = (ConvertPath ( gTesttoolPath + "graphics\required\input\rightfont." + ExtensionString))
156 if hFileExists ( sFileName ) = FALSE then
157 warnlog "The language-file was not found or accessible! The test ends."
161 'HDE has same problems in w_106a.inc ;-) !!! migrate ?!?! ///'
165 printlog "File opened: " + sFileName
168 Call sMakeReadOnlyDocumentEditable
171 Printlog "- Tools/Autocorrect -single quotes"
174 case 01 : Vorn$ = Chr(8216) : Hinten$ = Chr(8217)
175 case 03 : Vorn$ = Chr(8216) : Hinten$ = Chr(8217)
176 case 07 : qaerrorlog "Test impossible. No quotes in russian!"
179 case 31 : Vorn$ = Chr(8218) : Hinten$ = Chr(8216)
180 case 33 : Vorn$ = Chr(8216) : Hinten$ = Chr(8217)
181 case 34 : Vorn$ = Chr(8216) : Hinten$ = Chr(8217)
182 case 36 : Vorn$ = Chr(187) : Hinten$ = Chr(171)
183 case 39 : Vorn$ = Chr(8216) : Hinten$ = Chr(8217)
184 case 45 : Vorn$ = Chr(8217) : Hinten$ = Chr(8217)
185 case 46 : Vorn$ = Chr(8217) : Hinten$ = Chr(8217)
186 case 48 : Vorn$ = Chr(8216) : Hinten$ = Chr(8217)
187 case 49 : Vorn$ = Chr(8218) : Hinten$ = Chr(8216)
188 case 55 : Vorn$ = Chr(8216) : Hinten$ = Chr(8217)
189 case 81, 82, 86, 88 : Vorn$ = Chr(8216) : Hinten$ = Chr(8217) ' Asian
190 case else : Warnlog "- Nothing prepared for this language, but I run: take the warnlogs an insert the numbers here.: "+iSprache
191 Vorn$ = Chr(8216) : Hinten$ = Chr(8217)
194 Printlog "- Tools/Autocorrect -double quotes"
197 case 01 : Vorn$ = Chr(8220) : Hinten$ = Chr(8221)
198 case 03 : Vorn$ = Chr(8220) : Hinten$ = Chr(8221)
199 case 07 : qaerrorlog "Test not possible. No quotes in russian !"
202 case 31 : Vorn$ = Chr(8222) : Hinten$ = Chr(8220)
203 case 33 : Vorn$ = Chr(171) : Hinten$ = Chr(187)
204 case 34 : Vorn$ = Chr(8220) : Hinten$ = Chr(8221)
205 case 36 : Vorn$ = Chr(8222) : Hinten$ = Chr(8221)
206 case 39 : Vorn$ = Chr(8220) : Hinten$ = Chr(8221)
207 case 45 : Vorn$ = Chr(8221) : Hinten$ = Chr(8221)
208 case 46 : Vorn$ = Chr(8221) : Hinten$ = Chr(8221)
209 case 48 : Vorn$ = Chr(8222) : Hinten$ = Chr(8221)
210 case 49 : Vorn$ = Chr(8222) : Hinten$ = Chr(8220)
211 case 55 : Vorn$ = Chr(8220) : Hinten$ = Chr(8221)
212 case 81, 82, 86, 88 : Vorn$ = Chr(8220) : Hinten$ = Chr(8221) ' Asian
213 case else : Warnlog "- Nothing prepared for this language: "+iSprache
217 Printlog " - replace quotes" '------------------------------------------------------------------------------------------
220 active.SetPage TabTypografisch
221 Kontext "TabTypografisch"
223 EinfacheErsetzen.Check
225 DoppelteErsetzen.Check
226 DoppeltStandard.Click
232 hTextrahmenErstellen ( Normal$ + "Hallo" + Normal$ + " ",20,20,60,30)
234 hTypeKeys ("<Home><Shift Right>")
237 sTemp = GetClipboardText
238 if (sTemp <> Vorn$) then
239 Warnlog "The beginning quote seems wrong. Should be :'" + Vorn$ +"':"+ASC(vorn$)+ ": but it is = :'" + sTemp +"':"+ASC(sTemp)+":"
242 hTypeKeys "<End><Left><Shift Left>"
245 sTemp = GetClipboardText
246 if (sTemp <> Hinten$) then
247 Warnlog "The end quote seems wrong. Should be :" + Hinten$ +":"+ASC(Hinten$) +": but it is :" + sTemp + ":"+ASC(sTemp)+":"
250 hTypeKeys "<Home><Shift End><Delete>"
252 Printlog " - dont replace quotes" '------------------------------------------------------------------------------------------
255 Active.SetPage TabTypografisch
256 Kontext "TabTypografisch"
258 EinfacheErsetzen.Uncheck
260 DoppelteErsetzen.Uncheck
266 hTextrahmenErstellen ( Normal$ + "Hello" + Normal$ + " ",20,20,60,30)
268 hTypeKeys "<Home><Shift Right>"
271 sTemp = GetClipboardText
272 if (sTemp <> Normal$) then
273 Warnlog "The beginning quote seems wrong. Should be :'" + Vorn$ +"':"+ASC(vorn$)+ ": but it is = :'" + sTemp +"':"+ASC(sTemp)+":"
276 hTypeKeys "<End><Left><Shift Left>"
279 sTemp = GetClipboardText
280 if (sTemp <> Normal$) then
281 Warnlog "The end quote seems wrong. Should be :" + Hinten$ +":"+ASC(Hinten$) +": but it is :" + sTemp + ":"+ASC(sTemp)+":"
283 hTypeKeys "<Home><Shift End><Delete>"
285 Printlog " - replace quotes" '------------------------------------------------------------------------------------------
288 active.SetPage TabTypografisch
289 Kontext "TabTypografisch"
291 EinfacheErsetzen.Check
292 EinfachWortAnfang.Click
294 DoppelteErsetzen.Check
295 DoppeltWortAnfang.Click
297 Kontext "Sonderzeichen"
299 Schriftliste.TypeKeys "<Home>"
300 Schriftliste.TypeKeys "<Right>", 91 '123
304 Kontext "TabTypografisch"
306 EinfachWortEnde.Click
308 DoppeltWortEnde.Click
310 Kontext "Sonderzeichen"
312 Schriftliste.TypeKeys "<Home>"
313 Schriftliste.TypeKeys "<Right>", 93 '125
317 Kontext "TabTypografisch"
322 hTextrahmenErstellen ( Normal$ + "Hello" + Normal$ + " ",20,20,60,30)
324 hTypeKeys "<Home><Shift Right>"
327 sTemp = GetClipboardText
328 if (sTemp <> Chr(123)) then
329 Warnlog "Beginning quote is wrong. It should be :" + Chr (123) + ":123: but it is = " + sTemp +":"+ASC(sTemp)+":"
332 hTypeKeys "<End><Left><Shift Left>"
335 sTemp = GetClipboardText
336 if (sTemp <> Chr(125)) then
337 Warnlog "The end quote is wrong, it should be :" + Chr (125) + ":125: but it is = " + sTemp +":"+ASC(sTemp)+":"
339 hTypeKeys "<Home><Shift End><Delete>"
341 Printlog " - back to standard" '------------------------------------------------------------------------------------------
344 active.SetPage TabTypografisch
345 Kontext "TabTypografisch"
347 EinfacheErsetzen.Check
348 EinfachStandard.Click
350 DoppelteErsetzen.Check
351 DoppeltStandard.Click
356 hTextrahmenErstellen ( Normal$ + "Hello" + Normal$ + " ",20,20,60,30)
358 hTypeKeys "<Home><Shift Right>"
361 sTemp = GetClipboardText
362 if (sTemp <> Vorn$) then
363 Warnlog "The beginning quote seems wrong. Should be :" + Vorn$ +":"+ASC(vorn$)+ ": but it is = :" + sTemp +":"+ASC(sTemp)+":"
366 hTypeKeys "<End><Left><Shift Left>"
369 sTemp = GetClipboardText
370 if (sTemp <> Hinten$) then
371 Warnlog "The end quote seems wrong. Should be :" + Hinten$ +":"+ASC(Hinten$) +": but it is :" + sTemp + ":"+ASC(sTemp)+":"
373 hTypeKeys "<Home><Shift End><Delete>"
377 active.SetPage TabTypografisch
378 Kontext "TabTypografisch"
380 EinfacheErsetzen.UnCheck
382 DoppelteErsetzen.UnCheck
390 '-------------------------------------------------------------------------------
391 testcase tToolsAutocorrectOption
393 const cEntryCount = 9
395 dim iEntryCount as integer
396 dim sEntries (20, 2) as string
397 dim bState as boolean
399 ' this test relies on the following order of entries!!:
400 sEntries (1,1) = "Use replacement table"
401 sEntries (1,2) = "(C) "
402 sEntries (2,1) = "Correct TWo INitial CApitals"
403 sEntries (2,2) = "ABer "
404 sEntries (3,1) = "Capitalize first letter of every sentence"
405 sEntries (3,2) = "Hello. this is a sentence. "
406 sEntries (4,1) = "Automatic *bold* and _underline_"
407 sEntries (4,2) = "*Hello* " '"_Hello_ "
408 sEntries (5,1) = "URL Recognition"
409 sEntries (5,2) = "It is www.ksta.de "
410 sEntries (6,1) = "Replace 1st... with 1^st..."
411 sEntries (6,2) = "1st "
412 sEntries (7,1) = "Replace 1/2 ... with û ..."
413 sEntries (7,2) = "1/2 "
414 sEntries (8,1) = "Replace dashes"
415 sEntries (8,2) = "Hello - Hrbert "
416 sEntries (9,1) = "Ignore double spaces"
417 sEntries (9,2) = "Hello this is 2 blanks "
419 Printlog "- Tools / Autocorrect -options"
421 callAutocorrectOptions
423 iEntryCount = Einstellungen.getItemCount
424 if (iEntryCount <> cEntryCount) then
425 warnLog "Unexpected count of entries in Listbox: expected: '" + cEntryCount + "' actual: '" + iEntryCount + "'"
426 for i = 1 to iEntryCount
427 Printlog " " + i + " - '" + sEntries (i,1) + "' ?= '" + Einstellungen.getItemText(1) + "'"
432 for i = 1 to cEntryCount
433 callAutocorrectOptions
434 Printlog " " + i + " - '" + sEntries (i,1) + "' ?= '" + Einstellungen.getItemText(i) + "'"
435 bState = (i <> cEntryCount)
436 Einstellungen.select(i)
437 if (bState <> Einstellungen.isChecked) then
438 Warnlog " Entry is '" + bState + "' per default - will be '" + bState + "' now!"
440 ' first test the opposite default value
442 Einstellungen.UnCheck
447 sCheckCheck (i, sEntries(i,2), not bState)
448 ' now test and set the default value
449 callAutocorrectOptions
450 Einstellungen.select(i)
454 Einstellungen.UnCheck
457 sCheckCheck (i, sEntries(i,2), bState)
464 '-------------------------------------------------------------------------------