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: wizards.inc,v $
13 '* last change: $Author: jsi $ $Date: 2008-06-16 12:19:06 $
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 : joerg.skottke@sun.com
36 '* short description : helper functions for the wizards
38 '\******************************************************************************
40 function hOpenWizardWithMenu( cType as string ) as integer
42 const CFN = "hOpenWizardWithMenu::"
44 '///<h3>Open a wizard via menu</h3>
45 '///<i>Starting point: Any plain document</i><br>
46 '///<i>Uses: framework/tools/input/menuentries.txt</i><br>
49 '///+<li>Name of Wizard (string). Known Wizards are:</li>
51 '///+<li>"LETTER"</li>
52 '///+<li>"FAX"</li>
53 '///+<li>"AGENDA"</li>
54 '///+<li>"PRESENTATION"</li>
55 '///+<li>"WEBPAGE"</li>
56 '///+<li>"DOCCONV"</li>
57 '///+<li>"EUROCONV"</li>
58 '///+<li>"ADDRESS"</li>
59 '///+<li>"MAILMERGE"</li>
64 '///+<li>Errorcode (integer)</li>
66 '///+<li>0: The expected wizard is open</li>
67 '///+<li>1: No wizard is open</li>
68 '///+<li>2: The incorrect wizard is open</li>
69 '///+<li>3: The requested wizard is unknown to this function</li>
72 '///<u>Description</u>:
75 dim iMainMenuPosition as integer ' position in the main menu
76 dim iMenuPosition as integer ' the position of the menuentry
77 dim iWizardMenuPosition as integer ' the position of the wizards menu
78 dim iWizardID as integer ' a unique number to identify the wizard
79 dim iWait as integer ' time of the wizard to open
80 dim iOpen as integer ' identifier for the open dialog
81 dim brc as boolean ' some multi purpose boolean returnvalue
83 hOpenWizardWithMenu() = 0
85 '///+<li>find out where in the menustructure the wizards are located</li>
86 printlog( "Requested Wizard: " & cType )
87 iWizardID = hGetWizardParams( cType , "ID" )
88 iMainMenuPosition = hGetWizardParams( cType , "MAIN" )
89 iMenuPosition = hGetWizardParams( cType , "SUB" )
90 iWizardMenuPosition = 4 ' This is the "Wizards" menuentry below "File"
93 kontext "DocumentWriter"
96 '///+<li>Open the 'File' menu</li>
97 printlog( CFN & "Open Menu at pos " & iMainMenuPosition )
98 hMenuSelectNr( iMainMenuPosition )
101 '///+<li>if we are in the filemenu the wizards are below a submenu</li>
102 if ( iMainMenuPosition = 1 ) then
103 printlog( CFN & "Select wizards-submenu at pos " & iWizardMenuPosition )
104 hMenuSelectNr( iWizardMenuPosition )
107 printlog( CFN & "Wizard is not in File-Menu" )
110 '///+<li>try to click the menuentry where we expect the wizard</li>
111 printlog( CFN & "Select " & cType & " wizard at pos " & iMenuPosition )
112 hMenuSelectNr( iMenuPosition )
116 ' we end up here, when the menuitems could not be accessed
117 printlog( CFN & "Error accessing menuentry for wizard" )
118 hOpenWizardwithMenu() = 1
123 printlog( CFN & "Trying to open wizard using the slot" )
124 select case iWizardId
125 case 1 : FileAutopilotLetter
126 case 2 : FileAutopilotFax
127 case 3 : FileAutopilotAgenda
128 case 4 : FileAutopilotPresentation
132 '///+<li>wait for a wizard to open, iOpen is the number of the menuitem</li>
133 iOpen = hWaitForWizard()
135 '///+<li>Verify that the correct wizard is open. iOpen should match iMenuPosition</li>
136 ' This works because the menu-positions are unique. BEWARE!
137 if ( iOpen <> iWizardID ) then
139 qaerrorlog( CFN & "Incorrect Wizard is open, did the menu-order change?" )
142 hOpenWizardWithMenu() = 2
146 hOpenWizardWithMenu() = 0
153 '*******************************************************************************
155 function hFinishWizard( iMode as integer ) as boolean
157 const CFN = "hFinishWizard::"
159 '///<h3>Finish or cancel a wizard</h3>
160 '///<i>Starting point: Any known wizard must be open</i><br>
161 '///<i>If several wizards are open at the same time the outcome is undefined</i><br>
164 '///+<li>Closing method (integer). Valid options are:</li>
166 '///+<li>1: Click Finish-Button</li>
167 '///+<li>2: Click Cancel-Button</li>
168 '///+<li>3: Use Accelerator for Finish-Button</li>
173 '///+<li>Errorcode (boolean)</li>
175 '///+<li>TRUE: If everything is ok</li>
176 '///+<li>FALSE: On any error (including incorrect function parameters)</li>
179 '///<u>Description</u>:
182 '///+<li>Handle possible errors when invoking this function</li>
183 if ( ( iMode < 1 ) or ( iMode > 3 ) ) then
184 printlog( CFN & "Invalid iMode = " & iMode )
185 hFinishWizard() = false
195 '///+<li>Try to close the wizard</li>
198 Kontext "AutopilotLetter"
199 if ( AutopilotLetter.exists() ) then
201 case 1 : hWaitForObject( FinishButton, 3000 ) : FinishButton.click()
202 case 2 : AutopilotLetter.cancel()
203 case 3 : cAccel = hGetAccel( "Finish_Wizard" )
204 AutopilotLetter.typeKeys( cAccel )
210 Kontext "AutopilotFax"
211 if ( AutopilotFax.exists() ) then
213 case 1 : hWaitForObject( FinishButton, 3000 ) : FinishButton.click()
214 case 2 : AutopilotFax.cancel()
215 case 3 : cAccel = hGetAccel( "Finish_Wizard" )
216 AutopilotFax.typeKeys( cAccel )
222 Kontext "AutopilotAgenda"
223 if ( AutopilotAgenda.exists() ) then
225 case 1 : hWaitForObject( createButton, 3000 ) : createButton.click()
226 case 2 : hWaitForObject( cancelButton, 3000 ) : cancelButton.click()
227 case 3 : cAccel = hGetAccel( "Finish_Wizard" )
228 AutopilotAgenda.typeKeys( cAccel )
234 Kontext "MailMergeWizard"
235 if ( MailMergeWizard.exists() ) then
237 case 1 : MailMergeWizard.OK()
238 case 2 : MailMergeWizard.Cancel()
239 case 3 : cAccel = hGetAccel( "Finish_Wizard" )
240 MailMergeWizard.typeKeys( cAccel )
246 Kontext "AutopilotPraesentation3"
247 if ( AutopilotPraesentation3.exists() ) then
249 case 1 : AutopilotPraesentation3.OK()
250 case 2 : AutopilotPraesentation3.Cancel()
251 case 3 : cAccel = hGetAccel( "Finish_Wizard" )
252 AutopilotPraesentation3.typeKeys( cAccel )
258 Kontext "AutoPilotEuroKonverter"
259 if ( AutoPilotEuroKonverter.exists() ) then
261 case 1 : hWaitForObject( Konvertieren, 3000 ) : Konvertieren.click()
262 case 2 : hWaitForObject( abbrechen , 3000 ) : abbrechen.click()
263 case 3 : cAccel = hGetAccel( "Finish_Wizard" )
264 AutoPilotEuroKonverter.typeKeys( cAccel )
272 '///+<li>Verify that no wizard is open anymore</li>
274 printlog( CFN & "Closed wizard" )
275 hFinishWizard() = true
277 qaerrorlog( CFN & "No (known) wizard is present to be closed" )
278 hFinishWizard() = false
284 '*******************************************************************************
286 function hGetWizardParams( cType as string, cParam as string ) as integer
288 const CFN = "hGetWizardParams::"
290 '///<h3>Retrieve the location of a wizard in the menu</h3>
291 '///<i>Uses: framework/tools/input/menuentries.txt</i><br>
292 '///<i>Refer to inline documentation for further information</i><br>
295 '///+<li>Name of Wizard (string). Valid options are:</li>
297 '///+<li>"LETTER"</li>
298 '///+<li>"FAX"</li>
299 '///+<li>"AGENDA"</li>
300 '///+<li>"PRESENTATION"</li>
301 '///+<li>"WEBPAGE"</li>
302 '///+<li>"DOCCONV"</li>
303 '///+<li>"EUROCONV"</li>
304 '///+<li>"ADDRESS"</li>
305 '///+<li>"MAILMERGE"</li>
307 '///+<li>Menu Position (string). Valid options are:</li>
309 '///+<li>"ID" - This is a unique id for the wizard</li>
310 '///+<li>"MAIN" - Main menu position (e.g. "File"</li>
311 '///+<li>"SUB" - Position below main menu</li>
316 '///+<li>Position of a menu entry (integer)</li>
318 '///+<li>0: Invalid function parameter</li>
319 '///+<li>1-n: Position of the item in the menu</li>
322 '///<u>Description</u>:
325 dim iParam as integer
327 dim cInputArray( 200 ) as string
328 dim iArraySize as integer
331 cFile = gTesttoolPath & "framework\tools\input\menuentries.txt"
332 cFile = convertpath( cFile )
334 '///+<li>Lowercase all function parameters</li>
335 cType = ucase( cType )
336 cParam = ucase( cParam )
338 '///+<li>Read in the section containing the waizard parameters</li>
339 '///+<li>Retrieve the requested value from the section</li>
340 iArraySize = hGetDataFileSection( cFile , cInputArray() , ctype , "" , "" )
341 if ( iArraySize = 3 ) then
345 iParam = hGetValueForKeyAsInt( cInputArray() , "iWizardId" )
347 iParam = hGetValueForKeyAsInt( cInputArray() , "iMainMenuPosition" )
349 iParam = hGetValueForKeyAsInt( cInputArray() , "iMenuPosition" )
352 hGetWizardParams() = iParam
354 qaerrorlog( CFN & "hGetDataFileSection returned invalid data" )
355 hGetWizardParams() = 0
361 '*******************************************************************************
363 function hWaitForWizard() as integer
365 const CFN = "hWaitForWizard::"
368 '///<h3>Wait for any wizard to open</h3>
369 '///<i>Uses: framework/tools/input/menuentries.txt</i><br>
370 '///<i>NOTE: Not all wizards are known to this function yet.</i><br>
373 '///+<li>Nothing</li>
377 '///+<li>Unique ID of the open wizard</li>
379 '///+<li>0: In case of any error</li>
380 '///+<li>1-n: The unique ID of the currently open wizard (integer)</li>
383 '///<u>Description</u>:
389 '///+<li>Determine the open wizard by trying wizard.exists()</li>
390 for iWait = 1 to MAXTRIES
394 kontext "AutopilotLetter"
395 if ( AutopilotLetter.exists() ) then
396 printlog( CFN & "Autopilot Letter is open" )
397 iOpen = hGetWizardParams( "LETTER" , "ID" )
401 kontext "AutopilotFax"
402 if ( AutopilotFax.exists() ) then
403 printlog( CFN & "Autopilot Fax is open" )
404 iOpen = hGetWizardParams( "FAX" , "ID" )
408 kontext "AutopilotAgenda"
409 if ( AutopilotAgenda.exists() ) then
410 printlog( CFN & "Autopilot Agenda is open" )
411 iOpen = hGetWizardParams( "AGENDA" , "ID" )
415 Kontext "MailMergeWizard"
416 if ( MailMergeWizard.exists() ) then
417 printlog( CFN & "Mailmerge Wizard is open" )
418 iOpen = hGetWizardParams( "MAILMERGE" , "ID" )
422 Kontext "AutopilotPraesentation1"
423 if ( AutopilotPraesentation1.exists() ) then
424 printlog( CFN & "Presentation Wizard is open" )
425 iOpen = hGetWizardParams( "IMPRESS" , "ID" )
429 Kontext "AutoPilotEuroKonverter"
430 if ( AutoPilotEuroKonverter.exists() ) then
431 printlog( CFN & "Euro Converter is open" )
432 iOpen = hGetWizardParams( "EUROCONV" , "ID" )
436 Kontext "DocumentConverter"
437 if ( DocumentConverter.exists( 1 ) ) then
438 printlog( CFN & "Document Converter is open" )
439 iOpen = hGetWizardParams( "DOCCONV" , "ID" )
445 hWaitForWizard() = iOpen
450 '*******************************************************************************
452 function hSetTemplateSavePath( cFile as string ) as integer
454 '///<h3>Set the template save-path</h3>
455 '///<i>Starting point: Last page on FAX-, AGENDA- or LETTERWIZARD</i><br>
458 '///+<li>Fully qualified path to target template name (string)</li>
462 '///+<li>Errorcode (integer)</li>
464 '///+<li>0: No errors, path has been set correctly</li>
465 '///+<li>1: The "SaveAs"-dialog did not open</li>
466 '///+<li>2: The "SaveAs"-button could not be clicked</li>
467 '///+<li>-1: Incorrect call to function</li>
470 '///<u>Description</u>:
473 const CFN = "hSetTemplateSavePath::"
477 '///+<li>Validate function parameter</li>
478 if ( cFile = "" ) then
479 printlog( CFN & "Invalid parameter passed to function: Empty Path" )
480 hSetTemplateSavePath() = -1
484 printlog( CFN & "Open the file-save-dialog" )
486 '///+<li>Click on the save-as button</li>
490 kontext "SpeichernDlg"
491 if ( SpeichernDlg.exists( 2 ) ) then
492 printlog( CFN & "File Save dialog shown. Good." )
495 qaerrorlog( "#i49515# FileSave dialog does not open" )
499 qaerrorlog( "#i58297# Cannot click SaveAs button" )
503 '///+<li>Enter a filename</li>
504 '///+<li>Save the file</li>
506 call dialogtest( SpeichernDlg )
508 printlog( CFN & "Name the file" )
509 DateiName.setText( cFile )
511 printlog( CFN & "Save the template" )
515 hSetTemplateSavePath() = iErr
520 '*******************************************************************************
522 function hHandleSaveError() as integer
524 const CFN = "hHandleSaveError::"
526 '///<h3>Handle errors while saving a template</h3>
527 '///<i>Starting point: Save-As dialog from last page on FAX-, AGENDA- or LETTERWIZARD</i><br>
530 '///+<li>Nothing</li>
534 '///+<li>Errorcode (integer)</li>
536 '///+<li>0: No unexpected dialogs were displayed</li>
537 '///+<li>1: Unexpected Active closed by clicking YES</li>
538 '///+<li>2: Unexpected Active closed by clicking OK</li>
541 '///<u>Description</u>:
543 '///<li>Check for unexpected messagebox: file could not be saved</li>
544 '///<li>Close the dialog either with YES or OK</li>
550 if ( active.exists( 2 ) ) then
551 printlog( CFN & "Unexpected MsgBox: " & active.getText() )
563 hHandleSaveError() = iErr
568 '*******************************************************************************
570 function hClickNextButton() as boolean
572 '///<h3>Click the Next-Button on some wizards</h3>
573 '///<i>Starting point: Last page on FAX-, AGENDA- or LETTERWIZARD</i><br>
574 '///<i>Refer to inline documentation for further information</i><br>
577 '///+<li>Nothing</li>
581 '///+<li>Status (boolean)</li>
583 '///+<li>TRUE: Everything is ok</li>
584 '///+<li>FALSE: Any error</li>
587 '///<u>Description</u>:
591 const CFN = "hClickNextButton::"
595 dim iBreak as integer
598 '///+<li>Click the "Next"-button</li>
599 irc = hWaitForObject( NextButton, 5000 )
601 printlog( CFN & "Next..." )
605 qaerrorlog( CFN & "Button not available within specified time -> bad" )
608 '///+<li>Handle the "Document Creation"-dialog (Mailmerge Wizard)</li>
610 do while ( active.exists( 1 ) )
612 printlog( CFN & "Waiting for document creation to complete..." )
613 if ( iBreak = 10 ) then
614 warnlog( "DocumentCreation (MailMergeWizard) not complete within 10 seconds" )
620 hClickNextButton() = brc