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: wiz_CopyTableWizard.inc,v $
13 '* last change: $Author: jsi $ $Date: 2008-06-16 07:43:42 $
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 : marc.neumann@sun.com
36 '* short description : Copy Table Autopilot
38 '\**************************************************************************************
40 Dim sTabName as string
43 sub wiz_CopyTableWizard
45 printlog "------------------- wiz_CopyTableWizard.inc ------------------------"
47 call tCopy_Table_Dialog_Definition_and_data
48 call tCopy_Table_Dialog_Definition
49 call tCopy_Table_Dialog_Attach_data
50 call tCopy_Table_from_Text_Document
51 call tCopy_Table_from_Calc_Document
52 ' because of issue 68334 I need to restart the office
53 call ExitRestartTheOffice
54 call tCopy_Table_from_hsql_to_dBase
56 call tCopy_Table_Paste_Special
59 '--------------------------------------------------------------------
60 testcase tCopy_Table_Dialog_Definition_and_data
62 Dim sTableDimension as string
63 Dim iRowCount as integer
64 Dim iColumnCount as integer
66 '/// open the bibliography database
67 printlog "open the bibliography database"
68 call fOpenDatabase(gOfficePath + ConvertPath("user/database/biblio.odb"))
70 '///Make sure that there isn't a biblio2 table
71 printlog "Make sure that there isn't a biblio2 table"
72 If fFindtable("biblio2") = true then
73 call fDeleteTable("biblio2")
76 '/// select the biblio table
77 printlog "select the biblio table"
78 call fFindtable("biblio")
80 '/// press CTRL + C to copy the table and CTRL + V to paste the table again
81 printlog "press CTRL + C to copy the table and CTRL + V to paste the table again"
83 Database.typeKeys("<MOD1 C>",true)
85 Database.typeKeys("<MOD1 V>",true)
88 '/// the copy table dialog appear
89 printlog "the copy table dialog appear"
90 Kontext "CopyDatabaseTable"
91 if not CopyDatabaseTable.Exists(3) then
92 warnlog "the Copy Table Autopilot doesn't appear"
96 '/// select the Definition and Data option
97 printlog "select the Definition and Data option"
98 Kontext "TabCopyDatabaseTable"
99 DefinitionAndData.Check
101 '/// change the table name to biblio
102 printlog "change the table name to biblio"
103 Kontext "TabCopyDatabaseTable"
104 TableName.setText "biblio"
107 printlog "click next"
108 Kontext "CopyDatabaseTable"
110 '/// there should be a message that the table name already exists.
111 printlog "there should be a message that the table name already exists."
113 If not MessageBox.Exists(1) then
114 warnlog "There have to be an error messages that the table name already exists"
119 '/// change the table name to biblio2
120 printlog "change the table name to biblio2"
121 Kontext "TabCopyDatabaseTable"
122 TableName.setText "biblio2"
123 DefinitionAndData.Check
126 printlog "click next"
127 Kontext "CopyDatabaseTable"
133 printlog "add all columns"
134 Kontext "TabColumnSelect"
139 printlog "click next"
140 Kontext "CopyDatabaseTable"
146 Kontext "CopyDatabaseTable"
150 qaerrorlog "because of issue 76051 this copied table is not checked"
151 '///Check if the table is copied correct
152 'printlog "Check, if the table is copied correct"
153 'sTableDimension = fCreateRefFile("Bibliography", "t" , "biblio2" , "#")
154 'if (sTableDimension = "") then
155 ' printlog "Problem while creating Reference File"
157 ' 'printlog sTableDimension 'Debugcode
158 ' iColumnCount = CInt(Left(sTableDimension, instr(sTableDimension,",")))+1
159 ' 'printlog "Number of Columns: " & iColumnCount 'Debugcode
160 ' iRowCount = CInt(Right(sTableDimension, (Len(sTableDimension) - instr(sTableDimension,","))))+1
161 ' 'printlog "Number of Rows: " & iRowCount 'Debugcode
162 ' call tCompareMatrixValues("Bibliography", "user/work/biblio2.ttr", "t", "biblio", iRowCount, iColumnCount, "#")
166 '/// delete the copy table
167 printlog "delete the copy table"
168 call fDeleteTable("biblio2")
170 '/// close the database
171 printlog "close the database"
172 call fCloseDatabase()
175 '--------------------------------------------------------------------
176 testcase tCopy_Table_Dialog_Definition
178 '/// open the bibliography database
179 printlog "open the bibliography database"
180 call fOpenDatabase(gOfficePath + ConvertPath("user/database/biblio.odb"))
182 '/// select the biblio table
183 printlog "select the biblio table"
184 call fFindtable("biblio")
186 '/// press CTRL + C to copy the table and CTRL + V to paste the table again
187 printlog "press CTRL + C to copy the table and CTRL + V to paste the table again"
189 Database.typeKeys("<MOD1 C>",true)
191 Database.typeKeys("<MOD1 V>",true)
195 '/// the copy table dialog appear
196 printlog "the copy table dialog appear"
197 Kontext "CopyDatabaseTable"
198 if not CopyDatabaseTable.Exists(3) then
199 warnlog "the Copy Table Autopilot doesn't appear"
202 '/// check definition
203 printlog "check definition"
204 Kontext "TabCopyDatabaseTable"
207 '/// change the table name to biblio2
208 printlog "change the table name to biblio2"
209 Kontext "TabCopyDatabaseTable"
210 TableName.setText "biblio2"
211 DefinitionAndData.Check
213 printlog "click next"
214 Kontext "CopyDatabaseTable"
219 printlog "add all columns"
220 Kontext "TabColumnSelect"
225 printlog "click next"
226 Kontext "CopyDatabaseTable"
232 Kontext "CopyDatabaseTable"
236 'TODO: check if the table is copied correct
238 '/// delete the copy table
239 printlog "delete the copy table"
240 call fDeleteTable("biblio2")
242 '/// close the database
243 printlog "close the database"
244 call fCloseDatabase()
247 '--------------------------------------------------------------------
248 testcase tCopy_Table_Dialog_Attach_data
250 '/// open the bibliography database
251 printlog "open the bibliography database"
252 call fOpenDatabase(gOfficePath + ConvertPath("user/database/biblio.odb"))
254 '/// select the biblio table
255 printlog "select the biblio table"
256 call fFindtable("biblio")
258 '/// press CTRL + C to copy the table and CTRL + V to paste the table again
259 printlog "press CTRL + C to copy the table and CTRL + V to paste the table again"
261 Database.typeKeys("<MOD1 C>",true)
263 Database.typeKeys("<MOD1 V>",true)
266 '/// the copy table dialog appear
267 printlog "the copy table dialog appear"
268 Kontext "CopyDatabaseTable"
269 if not CopyDatabaseTable.Exists(3) then
270 warnlog "the Copy Table Autopilot doesn't appear"
274 '/// check definition
275 Kontext "TabCopyDatabaseTable"
278 '/// change the table name to biblio3
279 printlog "change the table name to biblio3"
280 Kontext "TabCopyDatabaseTable"
281 TableName.setText "biblio3"
282 DefinitionAndData.Check
285 printlog "click next"
286 Kontext "CopyDatabaseTable"
291 printlog "add all columns"
292 Kontext "TabColumnSelect"
297 printlog "click next"
298 Kontext "CopyDatabaseTable"
304 Kontext "CopyDatabaseTable"
308 '/// select the biblio table
309 printlog "select the biblio table"
310 call fFindtable("biblio")
312 '/// press CTRL + C to copy the table and CTRL + V to paste the table again
313 printlog "press CTRL + C to copy the table and CTRL + V to paste the table again"
315 Database.typeKeys("<MOD1 C>",true)
317 Database.typeKeys("<MOD1 V>",true)
320 '/// the copy table dialog appear
321 printlog "the copy table dialog appear"
322 Kontext "CopyDatabaseTable"
323 if not CopyDatabaseTable.Exists(3) then
324 warnlog "the Copy Table Autopilot doesn't appear"
327 '/// change the table name to biblio3 and choose attach data
328 printlog "change the table name to biblio3"
329 Kontext "TabCopyDatabaseTable"
330 TableName.setText "biblio3"
334 printlog "click next"
335 Kontext "CopyDatabaseTable"
341 Kontext "CopyDatabaseTable"
345 'TODO: check if the table is copied correct
347 '/// delete the copy table
348 call fDeleteTable("biblio3")
350 '/// close the database
351 call fCloseDatabase()
354 '--------------------------------------------------------------------
355 testcase tCopy_Table_from_Text_Document
357 '/// open a new document
358 printlog "open a new document"
361 '/// insert a table and insert some data
362 printlog "insert a table and insert some data"
365 Kontext "TabelleEinfuegenWriter"
367 TabelleEinfuegenWriter.OK
369 Kontext "DocumentWriter"
370 DocumentWriter.TypeKeys "field1" , true
371 DocumentWriter.TypeKeys "<TAB>" , true
372 DocumentWriter.TypeKeys "field2" , true
373 DocumentWriter.TypeKeys "<TAB>" , true
374 DocumentWriter.TypeKeys "field3" , true
375 DocumentWriter.TypeKeys "<TAB>" , true
376 DocumentWriter.TypeKeys "field4" , true
377 DocumentWriter.TypeKeys "<TAB>" , true
378 DocumentWriter.TypeKeys "field5" , true
379 DocumentWriter.TypeKeys "<TAB>" , true
380 DocumentWriter.TypeKeys "1" , true
381 DocumentWriter.TypeKeys "<TAB>" , true
382 DocumentWriter.TypeKeys "value1" , true
383 DocumentWriter.TypeKeys "<TAB>" , true
384 DocumentWriter.TypeKeys "value2" , true
385 DocumentWriter.TypeKeys "<TAB>" , true
386 DocumentWriter.TypeKeys "31.7.2003" , true
387 DocumentWriter.TypeKeys "<TAB>" , true
390 DocumentWriter.TypeKeys "<MOD1 C>" , true
393 '/// open database for past to
394 call fOpenDatabase(gOfficePath + ConvertPath("user/database/biblio.odb"))
396 '/// select the biblio table
397 call fFindtable("biblio")
399 '/// press CTRL + V to paste the table
401 Database.typeKeys("<MOD1 V>",true)
404 '/// the copy table dialog appear
405 printlog "the copy table dialog appear"
406 Kontext "CopyDatabaseTable"
407 if not CopyDatabaseTable.Exists(3) then
408 warnlog "the Copy Table Autopilot doesn't appear"
411 '/// change the table name to biblio2
412 printlog "change the table name to biblio2"
413 Kontext "TabCopyDatabaseTable"
414 TableName.setText "biblio2"
416 '/// select Definition and Data
417 printlog "select Definition and Data"
418 DefinitionAndData.Check
421 printlog "click next"
422 Kontext "CopyDatabaseTable"
427 printlog "add all columns"
428 Kontext "TabColumnSelect"
433 printlog "click next"
434 Kontext "CopyDatabaseTable"
443 'TODO: check if the table is copied correct
445 '/// delete the copy table
446 printlog "delete the copy table"
447 call fDeleteTable("biblio2")
449 '/// close the database
450 printlog "close the database"
453 '/// close the document
454 printlog "close the document"
458 '--------------------------------------------------------------------
459 testcase tCopy_Table_from_Calc_Document
461 '/// open a new calc document
462 printlog "open a calc new document"
463 gApplication = "CALC"
466 '/// insert some data
467 printlog "insert some data"
468 Kontext "DocumentCalc"
469 DocumentCalc.TypeKeys "Field1" , true
470 DocumentCalc.TypeKeys "<TAB>" , true
471 DocumentCalc.TypeKeys "Field2" , true
472 DocumentCalc.TypeKeys "<TAB>" , true
473 DocumentCalc.TypeKeys "Field3" , true
474 DocumentCalc.TypeKeys "<TAB>" , true
475 DocumentCalc.TypeKeys "Field4" , true
476 DocumentCalc.TypeKeys "<TAB>" , true
477 DocumentCalc.TypeKeys "Field5" , true
478 DocumentCalc.TypeKeys "<TAB>" , true
479 DocumentCalc.TypeKeys "<RETURN>" , true
480 DocumentCalc.TypeKeys "<HOME>" , true
481 DocumentCalc.TypeKeys "1" , true
482 DocumentCalc.TypeKeys "<TAB>" , true
483 DocumentCalc.TypeKeys "value1" , true
484 DocumentCalc.TypeKeys "<TAB>" , true
485 DocumentCalc.TypeKeys "value2" , true
486 DocumentCalc.TypeKeys "<TAB>" , true
487 DocumentCalc.TypeKeys "31.7.2003" , true
488 DocumentCalc.TypeKeys "<TAB>" , true
489 '/// select all and press CTRL + C to copy the data to the clipboard
490 printlog "select all and press CTRL + C to copy the data to the clipboard"
493 DocumentCalc.TypeKeys "<MOD1 C>" , true
496 '/// open database for paste to
497 printlog "open database for paste to"
498 app.FileCopy gTesttoolPath + ConvertPath("dbaccess/optional/input/hsql_datasource/TT_hsqldb.odb"),gOfficePath + ConvertPath("user/work/TT_hsqldb.odb")
499 call fOpendatabase(ConvertPath(gOfficePath + "user/work/TT_hsqldb.odb"))
501 '/// open the tables container
502 printlog "open the tables container"
503 call fFindtable("biblio2")
505 '/// press CTRL + V to paste the table again
507 Database.typeKeys("<MOD1 V>",true)
510 '/// the copy table dialog appear
511 printlog "the copy table dialog appear"
512 Kontext "CopyDatabaseTable"
513 if not CopyDatabaseTable.Exists(3) then
514 warnlog "the Copy Table Autopilot doesn't appear"
517 '/// change the table name to biblio2
518 printlog "change the table name to biblio2"
519 Kontext "TabCopyDatabaseTable"
520 TableName.setText "biblio2"
522 '/// select Definition and Data
523 printlog "select Definition and Data"
524 DefinitionAndData.Check
526 '/// let the wizard create a primary key
527 printlog "let the wizard create a primary key"
528 CreatePrimaryKey.Check
529 '/// check if the default text for the primary key is available
530 printlog "check if the default text for the primary key is available"
531 if ( PrimaryKeyName.getText = "" ) then
532 warnlog "the automatic default text for the primary key doesn't work"
535 '/// change the default text to ID111
536 printlog "change the default text to ID111"
537 PrimaryKeyName.setText("ID1111")
540 printlog "click next"
541 Kontext "CopyDatabaseTable"
546 printlog "add all columns"
547 Kontext "TabColumnSelect"
552 printlog "click next"
553 Kontext "CopyDatabaseTable"
562 '/// ceck if the table is copied correct
563 printlog "ceck if the table is copied correct"
564 call fOpenTableInDesign("biblio2")
566 Kontext "TableDesignTable"
568 s = Fieldname.getText()
570 if s <> "ID1111" then
571 warnlog "the first field is wrong. It should ID1111 but it is " + s
573 TableDesignTable.TypeKeys("<DOWN>")
574 s = Fieldname.getText()
576 if s <> "Field1" then
577 warnlog "the second field is wrong. It should Field1 but it is " + s
579 TableDesignTable.TypeKeys("<DOWN>")
580 s = Fieldname.getText()
582 if s <> "Field2" then
583 warnlog "the third field is wrong. It should Field2 but it is " + s
585 TableDesignTable.TypeKeys("<DOWN>")
586 s = Fieldname.getText()
588 if s <> "Field3" then
589 warnlog "the 4. field is wrong. It should Field3 but it is " + s
591 TableDesignTable.TypeKeys("<DOWN>")
592 s = Fieldname.getText()
594 if s <> "Field4" then
595 warnlog "the 5. field is wrong. It should Field4 but it is " + s
597 TableDesignTable.TypeKeys("<DOWN>")
598 s = Fieldname.getText()
600 if s <> "Field5" then
601 warnlog "the 6. field is wrong. It should Field5 but it is " + s
603 TableDesignTable.TypeKeys("<DOWN>")
605 '/// close the table design
606 printlog "close the table design"
607 call fCloseTableDesign
609 '/// delete the copy table
610 printlog "delete the copy table"
611 call fDeleteTable("biblio2")
613 '/// close the database
614 printlog "close the database"
617 '/// close the spreadsheet document
618 printlog "close the spreadsheet document"
621 gApplication = "WRITER"
624 '--------------------------------------------------------------------
625 testcase tCopy_Table_from_hsql_to_dBase
627 '/// copy the database file to a local path
628 printlog "copy the database file to a local path"
629 app.FileCopy gTesttoolPath + ConvertPath("dbaccess/optional/input/hsql_datasource/TT_hsqldb.odb"),gOfficePath + ConvertPath("user/work/TT_hsqldb.odb")
631 '/// open a hsql database
632 printlog "open a hsql database"
633 call fOpendatabase(ConvertPath(gOfficePath + "user/work/TT_hsqldb.odb"))
636 '/// select the tabel TT_CopyTest
637 printlog "select the tabel TT_CopyTest"
638 call fFindTable("TT_1")
640 '/// press CTRL + C to copy the table
641 printlog "press CTRL + C to copy the table"
643 Database.typeKeys("<MOD1 C>",true)
645 '/// open the bibliography database
646 printlog "open the bibliography database"
647 call fOpenDatabase(gOfficePath + "user/database/biblio.odb")
649 call fDeleteTable("TT_1") ' delete the table TT_1 if the table exists.
651 '/// select the biblio table
652 printlog "select the biblio table"
653 call fFindTable("biblio")
655 '/// press CTRL + V to paste the table
657 Database.typeKeys("<MOD1 V>",true)
659 '/// the copy table dialog appear
660 printlog "the copy table dialog appear"
661 Kontext "CopyDatabaseTable"
662 if not CopyDatabaseTable.Exists(3) then
663 warnlog "the Copy Table Autopilot doesn't appear"
667 '/// select Definition and Data
668 printlog "select Definition and Data"
669 Kontext "TabCopyDatabaseTable"
670 TableName.setText("TT_1")
671 DefinitionAndData.Check
674 printlog "click next"
675 Kontext "CopyDatabaseTable"
679 printlog "add all columns"
680 Kontext "TabColumnSelect"
683 ' there is a messages box about missing compatible field type.
685 if MessageBox.exists(3) then
686 printlog "There is a messageBox. " + MessageBox.getText
691 printlog "click next"
692 Kontext "CopyDatabaseTable"
701 if MessageBox.exists(3) then
702 printlog "There is a messageBox. " + MessageBox.getText
706 if MessageBox.exists(3) then
707 printlog "There is a messageBox. " + MessageBox.getText
711 '/// delete the copied table
712 printlog "delete the copied table"
713 call fDeleteTable("TT_1")
715 '/// close the database
716 printlog "close the database"
717 call fCloseDatabase()
719 '/// close the other database
720 printlog "close the other database"
721 call fCloseDatabase()
724 '--------------------------------------------------------------------
725 testcase tCopy_Table_Paste_Special
727 Dim sTableDimension as string
728 Dim iRowCount as integer
729 Dim iColumnCount as integer
731 '/// open the bibliography database
732 printlog "open the bibliography database"
733 call fOpenDatabase(gOfficePath + ConvertPath("user/database/biblio.odb"))
735 '///Make sure that there isn't a biblio2 table
736 printlog "Make sure that there isn't a biblio2 table"
737 If fFindtable("biblio2") = true then
738 call fDeleteTable("biblio2")
741 '/// select the biblio table
742 printlog "select the biblio table"
743 call fFindtable("biblio")
745 '/// press CTRL + C to copy the table and CTRL + V to paste the table again
746 printlog "press CTRL + C to copy the table and CTRL + V to paste the table again"
748 Database.typeKeys("<MOD1 C>",true)
754 Kontext "InhaltEinfuegen"
757 '/// the copy table dialog appear
758 printlog "the copy table dialog appear"
759 Kontext "CopyDatabaseTable"
760 if not CopyDatabaseTable.Exists(3) then
761 warnlog "the Copy Table Autopilot doesn't appear"
765 '/// change the table name to biblio
766 printlog "change the table name to biblio"
767 Kontext "TabCopyDatabaseTable"
768 TableName.setText "biblio"
771 printlog "click next"
772 Kontext "CopyDatabaseTable"
774 '/// there should be a message that the table name already exists.
775 printlog "there should be a message that the table name already exists."
777 If not MessageBox.Exists(1) then
778 warnlog "There have to be an error messages that the table name already exists"
783 '/// change the table name to biblio2
784 printlog "change the table name to biblio2"
785 Kontext "TabCopyDatabaseTable"
786 TableName.setText "biblio2"
787 DefinitionAndData.Check
790 printlog "click next"
791 Kontext "CopyDatabaseTable"
797 printlog "add all columns"
798 Kontext "TabColumnSelect"
803 printlog "click next"
804 Kontext "CopyDatabaseTable"
810 Kontext "CopyDatabaseTable"
814 qaerrorlog "because of issue 76051 this copied table is not checked"
815 '///Check if the table is copied correct
816 'printlog "Check, if the table is copied correct"
817 'sTableDimension = fCreateRefFile("Bibliography", "t" , "biblio2" , "#")
818 'if (sTableDimension = "") then
819 ' printlog "Problem while creating Reference File"
821 ' 'printlog sTableDimension 'Debugcode
822 ' iColumnCount = CInt(Left(sTableDimension, instr(sTableDimension,",")))+1
823 ' 'printlog "Number of Columns: " & iColumnCount 'Debugcode
824 ' iRowCount = CInt(Right(sTableDimension, (Len(sTableDimension) - instr(sTableDimension,","))))+1
825 ' 'printlog "Number of Rows: " & iRowCount 'Debugcode
826 ' call tCompareMatrixValues("Bibliography", "user/work/biblio2.ttr", "t", "biblio", iRowCount, iColumnCount, "#")
830 '/// delete the copy table
831 printlog "delete the copy table"
832 call fDeleteTable("biblio2")
834 '/// close the database
835 printlog "close the database"
836 call fCloseDatabase()