1 '**************************************************************************
2 '* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 '* Copyright 2008 by Sun Microsystems, Inc.
6 '* OpenOffice.org - a multi-platform office productivity suite
8 '* $RCSfile: w_sorting1.inc,v $
12 '* last change: $Author: vg $ $Date: 2008-08-18 12:35:51 $
14 '* This file is part of OpenOffice.org.
16 '* OpenOffice.org is free software: you can redistribute it and/or modify
17 '* it under the terms of the GNU Lesser General Public License version 3
18 '* only, as published by the Free Software Foundation.
20 '* OpenOffice.org is distributed in the hope that it will be useful,
21 '* but WITHOUT ANY WARRANTY; without even the implied warranty of
22 '* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 '* GNU Lesser General Public License version 3 for more details
24 '* (a copy is included in the LICENSE file that accompanied this code).
26 '* You should have received a copy of the GNU Lesser General Public License
27 '* version 3 along with OpenOffice.org. If not, see
28 '* <http://www.openoffice.org/license.html>
29 '* for a copy of the LGPLv3 License.
31 '/************************************************************************
33 '* owner : helge.delfs@sun.com
35 '* short description : Sorting functions in Writer
37 '************************************************************************
39 ' #1 tToolsSort1 ' Text in one Column and 1 Key
40 ' #1 tToolsSort2 ' Numbers in 1 Column and 1 Key
41 ' #1 tToolsSort3 ' Text in several Columns and 3 Keys
42 ' #1 tToolsSort4 ' Table with Header ( Text and Numbers mixed )
43 ' #1 tToolsSort5 ' Table without Header ( Text and Numbers mixed )
44 ' #1 tToolsSort6 ' Copy sorted table in another table
46 '\***********************************************************************
50 Call tToolsSort1 ' Text in one Column and 1 Key
51 Call tToolsSort2 ' Numbers in 1 Column and 1 Key
52 Call tToolsSort3 ' Text in several Columns and 3 Keys
53 Call tToolsSort4 ' Table with Header ( Text and Numbers mixed )
54 Call tToolsSort5 ' Table without Header ( Text and Numbers mixed )
55 Call tToolsSort6 ' Copy sorted table in another table
61 PrintLog "- Tools / Sort normal Text ( 1. Column )"
62 Printlog " - alphanumeric ascending ( Key 1 )"
64 Call wTypeKeys "Ohallo<Return>Ahallo<Return>Ghallo<Return>Zhallo<Return>Shallo"
65 Call wTypeKeys ( "<Mod1 a>" )
72 Schluesseltyp1.Select 1
75 Call AufsteigendKontrollieren ( FALSE )
77 Printlog " - alphanumeric descending ( Key 1 )"
78 Call wTypeKeys ( "<Mod1 a>" )
83 Schluesseltyp1.Select 1
86 AbsteigendKontrollieren ( FALSE )
88 Printlog " - alphanumeric ascending ( Key 2 )"
89 Call wTypeKeys "<Mod1 a>"
90 Call wTypeKeys "<Delete>"
92 Call wTypeKeys "Ohallo<Return>Ahallo<Return>Ghallo<Return>Zhallo<Return>Shallo"
93 Call wTypeKeys ( "<Mod1 a>" )
100 Schluesseltyp2.Select 1
103 Call AufsteigendKontrollieren ( FALSE )
105 Printlog " - alphanumeric descending ( Key 2 )"
106 Call wTypeKeys "<Mod1 a>"
110 Schluesseltyp2.Select 1
113 AbsteigendKontrollieren ( FALSE )
115 Printlog " - alphanumeric ascending ( Key 3 )"
116 Call wTypeKeys "<Mod1 a>"
117 Call wTypeKeys "<Delete>"
119 Call wTypeKeys "Ohallo<Return>Ahallo<Return>Ghallo<Return>Zhallo<Return>Shallo"
120 Call wTypeKeys ( "<Mod1 a>" )
127 Schluesseltyp3.Select 1
130 Call AufsteigendKontrollieren ( FALSE )
132 Printlog " - alphanumeric descending ( Key 3 )"
133 Call wTypeKeys "<Mod1 a>"
140 Schluesseltyp3.Select 1
143 Call AbsteigendKontrollieren ( FALSE )
148 ' *******************************************************************
151 PrintLog "- Tools / Sorting numbers ( 1. Column )"
153 Printlog " - numeric ascending ( Key 1 )"
155 Call wTypeKeys "43<Return>54<Return>23<Return>65<Return>56"
156 Call wTypeKeys ( "<Mod1 a>" )
161 Schluesseltyp1.Select 2
164 Call AufsteigendKontrollieren ( TRUE )
166 Printlog " - numeric descending ( Key 1 )"
167 Call wTypeKeys ( "<Mod1 a>" )
172 Schluesseltyp1.Select 2
175 Call AbsteigendKontrollieren ( TRUE )
177 Printlog " - numeric ascending ( Key 2 )"
178 Call wTypeKeys "<Mod1 a>"
179 Call wTypeKeys "<Delete>"
181 Call wTypeKeys "43<Return>54<Return>23<Return>65<Return>56"
182 Call wTypeKeys ( "<Mod1 a>" )
188 Schluesseltyp2.Select 2
191 Call AufsteigendKontrollieren ( TRUE )
193 Printlog " - numeric descending ( Key 2 )"
194 Call wTypeKeys ( "<Mod1 a>" )
200 Schluesseltyp2.Select 2
203 Call AbsteigendKontrollieren ( TRUE )
205 Printlog " - numeric ascending ( Key 3 )"
206 Call wTypeKeys ( "<Mod1 a>" )
207 Call wTypeKeys ( "<Delete>" )
209 Call wTypeKeys "43<Return>54<Return>23<Return>65<Return>56"
210 Call wTypeKeys ( "<Mod1 a>" )
217 Schluesseltyp3.Select 2
220 Call AufsteigendKontrollieren ( TRUE )
222 Printlog " - numeric descending ( Key 3 )"
223 Call wTypeKeys ( "<Mod1 a>" )
230 Schluesseltyp3.Select 2
233 Call AbsteigendKontrollieren ( TRUE )
238 ' *******************************************************************
242 PrintLog "- Tools / Sorting text in several lines"
245 case 1: Printlog " - Seperator is a tabulator"
246 case 2: Printlog " - Seperator is a semicolon"
248 case 3: Printlog " - Seperator is a '|'"
251 if gApplication = "WRITER" then
252 Call hFileOpen ( gTesttoolPath + "writer\optional\input\sorting\sort2.odt" )
253 Call sMakeReadOnlyDocumentEditable
255 Call hFileOpen ( gTesttoolPath + "writer\optional\input\sorting\sort2.odm" )
256 Call sMakeReadOnlyDocumentEditable
259 if i <> 1 then TrennzeichenSetzen ( Trennzeichen )
261 Printlog " - alphanumeric ascending after 1.Column, followed by 4.Column and 3. Column"
262 Call wTypeKeys ( "<Mod1 a>" )
267 Schluesseltyp1.Select 1
272 Schluesseltyp2.Select 1
277 Schluesseltyp3.Select 1
284 ZeichenText.SetText Trennzeichen
287 Call AufSortierungPruefen(i)
288 Call UndoRichtigBeiSortierung
290 Printlog " - alphanumeric descending 1.Column, followed by 4. column and 3. column"
295 Schluesseltyp1.Select 1
299 Schluesseltyp2.Select 1
303 Schluesseltyp3.Select 1
312 ZeichenText.SetText Trennzeichen
315 Call AbSortierungPruefen(i)
316 Call UndoRichtigBeiSortierung
323 ' *******************************************************************
326 PrintLog "- Tools / Sorting in table with header"
327 if gApplication = "WRITER" then
328 Call hFileOpen ( gTesttoolPath + "writer\optional\input\sorting\sort1.odt" )
329 Call sMakeReadOnlyDocumentEditable
331 Call hFileOpen ( gTesttoolPath + "writer\optional\input\sorting\sort1.odm" )
332 Call sMakeReadOnlyDocumentEditable
334 Call wTypeKeys "<Mod1 a>", 2
336 Printlog " - 3. column alphanum., 1. column num., 3. column alphanum. ascending"
341 Schluesseltyp1.Select 1
345 Schluesseltyp2.Select 2
349 Schluesseltyp3.Select 1
353 if Tabulator.IsEnabled then Warnlog "Tabs is active"
354 if Zeichen.IsEnabled then Warnlog "Char is active"
358 Call wTypeKeys "<Mod1 a>", 3 ' Umstellung zur 5.0 Cursor steht nach Sortierung in der letzten Zelle, mit 3*Ctrl_A kommt man in die 1.
361 if GetClipboardText <> "1" then Warnlog "Header of the first column has been sorted"
362 if ZelleRuntertesten("2") = FALSE then Warnlog "1/2 is wrong"
363 if ZelleRuntertesten("4") = FALSE then Warnlog "1/3 is wrong"
364 if ZelleRuntertesten("5") = FALSE then Warnlog "1/4 is wrong"
365 if ZelleRuntertesten("3") = FALSE then Warnlog "1/5 is wrong"
366 if ZelleRuntertesten("6") = FALSE then Warnlog "1/6 is wrong"
367 Call wTypeKeys "<Right>"
368 Call wTypeKeys "<up>", 5
369 Call wTypeKeys "<Mod1 a>"
372 if GetClipboardText <> "a" then Warnlog "Header of the 2. column has not been sorted"
373 if ZelleRuntertesten("a") = FALSE then Warnlog "2/2 is wrong"
374 if ZelleRuntertesten("b") = FALSE then Warnlog "2/3 is wrong"
375 if ZelleRuntertesten("c") = FALSE then Warnlog "2/4 is wrong"
376 if ZelleRuntertesten("b") = FALSE then Warnlog "2/5 is wrong"
377 if ZelleRuntertesten("c") = FALSE then Warnlog "2/6 is wrong"
378 Call wTypeKeys "<Right>"
379 Call wTypeKeys "<up>", 5
380 Call wTypeKeys "<Mod1 a>"
383 if GetClipboardText <> "zz" then Warnlog "Header der 3. column has not been sorted"
384 if ZelleRuntertesten("xx") = FALSE then Warnlog "3/2 is wrong"
385 if ZelleRuntertesten("xx") = FALSE then Warnlog "3/3 is wrong"
386 if ZelleRuntertesten("xx") = FALSE then Warnlog "3/4 is wrong"
387 if ZelleRuntertesten("zz") = FALSE then Warnlog "3/5 is wrong"
388 if ZelleRuntertesten("zz") = FALSE then Warnlog "3/6 is wrong"
390 Printlog " - 3. column alphanum., 1. column num., 3. column alphanum. descending"
391 Call wTypeKeys "<Left Right>"
392 Call wTypeKeys "<Mod1 a>", 2
398 Schluesseltyp1.Select 1
402 Schluesseltyp2.Select 2
406 Schluesseltyp3.Select 1
413 Call wTypeKeys "<up><Left>", 6
414 Call wTypeKeys "<Mod1 a>"
417 if GetClipboardText <> "1" then Warnlog "Header of the 1. column has been sorted"
418 if ZelleRuntertesten("6") = FALSE then Warnlog "1/2 is wrong"
419 if ZelleRuntertesten("3") = FALSE then Warnlog "1/3 is wrong"
420 if ZelleRuntertesten("5") = FALSE then Warnlog "1/4 is wrong"
421 if ZelleRuntertesten("4") = FALSE then Warnlog "1/5 is wrong"
422 if ZelleRuntertesten("2") = FALSE then Warnlog "1/6 is wrong"
423 Call wTypeKeys "<Right>"
424 Call wTypeKeys "<up>", 5
425 Call wTypeKeys "<Mod1 a>"
428 if GetClipboardText <> "a" then Warnlog "Header of the 2. column has not been sorted"
429 if ZelleRuntertesten("c") = FALSE then Warnlog "2/2 is wrong"
430 if ZelleRuntertesten("b") = FALSE then Warnlog "2/3 is wrong"
431 if ZelleRuntertesten("c") = FALSE then Warnlog "2/4 is wrong"
432 if ZelleRuntertesten("b") = FALSE then Warnlog "2/5 is wrong"
433 if ZelleRuntertesten("a") = FALSE then Warnlog "2/6 is wrong"
434 Call wTypeKeys "<Right>"
435 Call wTypeKeys "<up>", 5
436 Call wTypeKeys "<Mod1 a>"
439 if GetClipboardText <> "zz" then Warnlog "Header of the 3. column has not been sorted"
440 if ZelleRuntertesten("zz") = FALSE then Warnlog "3/2 is wrong"
441 if ZelleRuntertesten("zz") = FALSE then Warnlog "3/3 is wrong"
442 if ZelleRuntertesten("xx") = FALSE then Warnlog "3/4 is wrong"
443 if ZelleRuntertesten("xx") = FALSE then Warnlog "3/5 is wrong"
444 if ZelleRuntertesten("xx") = FALSE then Warnlog "3/6 is wrong"
448 ' *******************************************************************
451 PrintLog "- Tools / Sorting in table without header"
452 if gApplication = "WRITER" then
453 Call hFileOpen ( gTesttoolPath + "writer\optional\input\sorting\sort1.odt" )
454 Call sMakeReadOnlyDocumentEditable
456 Call hFileOpen ( gTesttoolPath + "writer\optional\input\sorting\sort1.odm" )
457 Call sMakeReadOnlyDocumentEditable
460 Call wNavigatorAuswahl (2, 2)
461 Call wTypeKeys "<Mod1 a>", 2
462 Printlog " - 3. column alphanum., 1. column num., 2. column alphanum. ascending"
467 Schluesseltyp1.Select 1
471 Schluesseltyp2.Select 2
475 Schluesseltyp3.Select 1
479 if Tabulator.IsEnabled then Warnlog "'Tabs' is active when table is selected"
480 if Zeichen.IsEnabled then Warnlog "'Character' is active when table is selected"
484 Call wNavigatorAuswahl (2, 2)
485 Call wTypeKeys "<Mod1 a>"
489 if GetClipboardText <> "2" then Warnlog "1/1 is wrong!"
490 if ZelleRuntertesten("4") = FALSE then Warnlog "1/2 is wrong"
491 if ZelleRuntertesten("5") = FALSE then Warnlog "1/3 is wrong"
492 if ZelleRuntertesten("1") = FALSE then Warnlog "1/4 is wrong"
493 if ZelleRuntertesten("3") = FALSE then Warnlog "1/5 is wrong"
494 if ZelleRuntertesten("6") = FALSE then Warnlog "1/6 is wrong"
495 Call wTypeKeys "<Right>"
496 Call wTypeKeys "<up>", 5
497 Call wTypeKeys "<Mod1 a>"
500 if GetClipboardText <> "a" then Warnlog "2/1 is wrong!"
501 if ZelleRuntertesten("b") = FALSE then Warnlog "2/2 is wrong"
502 if ZelleRuntertesten("c") = FALSE then Warnlog "2/3 is wrong"
503 if ZelleRuntertesten("a") = FALSE then Warnlog "2/4 is wrong"
504 if ZelleRuntertesten("b") = FALSE then Warnlog "2/5 is wrong"
505 if ZelleRuntertesten("c") = FALSE then Warnlog "2/6 is wrong"
506 Call wTypeKeys "<Right>"
507 Call wTypeKeys "<up>", 5
508 Call wTypeKeys "<Mod1 a>"
511 if GetClipboardText <> "xx" then Warnlog "3/1 is wrong!"
512 if ZelleRuntertesten("xx") = FALSE then Warnlog "3/2 is wrong"
513 if ZelleRuntertesten("xx") = FALSE then Warnlog "3/3 is wrong"
514 if ZelleRuntertesten("zz") = FALSE then Warnlog "3/4 is wrong"
515 if ZelleRuntertesten("zz") = FALSE then Warnlog "3/5 is wrong"
516 if ZelleRuntertesten("zz") = FALSE then Warnlog "3/6 is wrong"
519 Printlog " - 3. column alphanum., 1. column num., 2. column alphanum. descending"
520 Call wNavigatorAuswahl (2, 2)
521 Call wTypeKeys "<Mod1 a>", 2
527 Schluesseltyp1.Select 1
531 Schluesseltyp2.Select 2
535 Schluesseltyp3.Select 1
542 Call wNavigatorAuswahl (2, 2)
543 Call wTypeKeys "<Mod1 a>"
546 if GetClipboardText <> "6" then Warnlog "1/1 is wrong!"
547 if ZelleRuntertesten("3") = FALSE then Warnlog "1/2 is wrong"
548 if ZelleRuntertesten("1") = FALSE then Warnlog "1/3 is wrong"
549 if ZelleRuntertesten("5") = FALSE then Warnlog "1/4 is wrong"
550 if ZelleRuntertesten("4") = FALSE then Warnlog "1/5 is wrong"
551 if ZelleRuntertesten("2") = FALSE then Warnlog "1/6 is wrong"
552 Call wTypeKeys "<Right>"
553 Call wTypeKeys "<up>", 5
554 Call wTypeKeys "<Mod1 a>"
557 if GetClipboardText <> "c" then Warnlog "2/1 is wrong!"
558 if ZelleRuntertesten("b") = FALSE then Warnlog "2/2 is wrong"
559 if ZelleRuntertesten("a") = FALSE then Warnlog "2/3 is wrong"
560 if ZelleRuntertesten("c") = FALSE then Warnlog "2/4 is wrong"
561 if ZelleRuntertesten("b") = FALSE then Warnlog "2/5 is wrong"
562 if ZelleRuntertesten("a") = FALSE then Warnlog "2/6 is wrong"
563 Call wTypeKeys "<Right>"
564 Call wTypeKeys "<up>", 5
565 Call wTypeKeys "<Mod1 a>"
568 if GetClipboardText <> "zz" then Warnlog "3/1 is wrong!"
569 if ZelleRuntertesten("zz") = FALSE then Warnlog "3/2 is wrong"
570 if ZelleRuntertesten("zz") = FALSE then Warnlog "3/3 is wrong"
571 if ZelleRuntertesten("xx") = FALSE then Warnlog "3/4 is wrong"
572 if ZelleRuntertesten("xx") = FALSE then Warnlog "3/5 is wrong"
573 if ZelleRuntertesten("xx") = FALSE then Warnlog "3/6 is wrong"
577 ' *******************************************************************
580 PrintLog "- Tools / Sort a sorted table and copy in another one"
582 if gApplication = "WRITER" then
583 Call hFileOpen ( gTesttoolPath + "writer\optional\input\sorting\sort3.odt" )
584 Call sMakeReadOnlyDocumentEditable
586 Call hFileOpen ( gTesttoolPath + "writer\optional\input\sorting\sort3.odm" )
587 Call sMakeReadOnlyDocumentEditable
589 Call wTypeKeys "<Mod1 a>", 2
591 Printlog " - Sort 1. column numeric descending"
596 Schluesseltyp1.Select 2
603 Call wTypeKeys "<Mod1 a>", 3
606 if GetClipboardText <> "4" then Warnlog "Header of the 1. column has not been sorted"
607 if ZelleRuntertesten("3") = FALSE then Warnlog "1/2 is wrong"
608 if ZelleRuntertesten("2") = FALSE then Warnlog "1/3 is wrong"
609 if ZelleRuntertesten("1") = FALSE then Warnlog "1/4 is wrong"
610 Call wTypeKeys "<Tab>"
611 Call wTypeKeys "<up>", 3
612 Call wTypeKeys "<Mod1 a>"
615 if GetClipboardText <> "dd" then Warnlog "Header of the 2. column has not been sorted"
616 if ZelleRuntertesten("cc") = FALSE then Warnlog "2/2 is wrong"
617 if ZelleRuntertesten("bb") = FALSE then Warnlog "2/3 is wrong"
618 if ZelleRuntertesten("aa") = FALSE then Warnlog "2/4 is wrong"
619 Call wTypeKeys "<Tab>"
620 Call wTypeKeys "<up>", 3
621 Call wTypeKeys "<Mod1 a>"
624 if GetClipboardText <> "ww" then Warnlog "Header of the 3 column has not been sorted"
625 if ZelleRuntertesten("xx") = FALSE then Warnlog "3/2 is wrong"
626 if ZelleRuntertesten("yy") = FALSE then Warnlog "3/3 is wrong"
627 if ZelleRuntertesten("zz") = FALSE then Warnlog "3/4 is wrong"
629 Printlog " - copy table"
630 Call wTypeKeys "<Left Right>"
631 Call wTypeKeys "<Mod1 a>", 2
635 Printlog " - insert table"
636 Call wTypeKeys "<Down>", 10
637 Call wTypeKeys "<Up>", 4
642 Call wTypeKeys "<Mod1 a>"
645 if GetClipboardText <> "4" then Warnlog "Header of the 1. column has not been sorted"
646 if ZelleRuntertesten("3") = FALSE then Warnlog "1/2 is wrong"
647 if ZelleRuntertesten("2") = FALSE then Warnlog "1/3 is wrong"
648 if ZelleRuntertesten("1") = FALSE then Warnlog "1/4 is wrong"
649 Call wTypeKeys "<Tab>"
650 Call wTypeKeys "<up>", 3
651 Call wTypeKeys "<Mod1 a>"
654 if GetClipboardText <> "dd" then Warnlog "Header of the 2. column has not been sorted"
655 if ZelleRuntertesten("cc") = FALSE then Warnlog "2/2 is wrong"
656 if ZelleRuntertesten("bb") = FALSE then Warnlog "2/3 is wrong"
657 if ZelleRuntertesten("aa") = FALSE then Warnlog "2/4 is wrong"
658 Call wTypeKeys "<Tab>"
659 Call wTypeKeys "<up>", 3
660 Call wTypeKeys "<Mod1 a>"
663 if GetClipboardText <> "ww" then Warnlog "Header of the 3 column has not been sorted"
664 if ZelleRuntertesten("xx") = FALSE then Warnlog "3/2 is wrong"
665 if ZelleRuntertesten("yy") = FALSE then Warnlog "3/3 is wrong"
666 if ZelleRuntertesten("zz") = FALSE then Warnlog "3/4 is wrong"