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: ch_tools_titles.inc,v $
13 '* last change: $Author: jsi $ $Date: 2008-06-13 14:27:03 $
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 : oliver.craemer@sun.com
36 '* short description : Tool library for Titles dialog
38 '**************************************************************************************************
40 ' #1 fInvokeTitlesDialog
41 ' #1 fCloseTitlesDialogOK
44 '\************************************************************************************************
46 ' ch_tools_titles.inc - A library for automation of the 'Insert::Titles...' dialog
47 ' This Include contains a set of functions to modify the controls of the Titles dialog.
48 ' All functions are designed to return error-codes depending on the behaviour of the action applied.
51 ' Error 1: The basic action beeing applied caused a serious problem, e.g. a crash.
52 ' Error 2 TO 9: A functional problem occured.
53 ' Error 11 TO 19: Wrong marginal conditions end up in Failure, e.g. control not visible.
54 ' NOTE: This errors can also be used for 'negative' testing.
55 ' Error 42: Wrong input. Probably only of interest during test development .
56 ' Error 99: Unexpected behaviour - Shouldn't normally occur.
58 ' Only Errors 42 and 99 throw 'Warnlogs'.
59 ' All other errors are silent!
60 ' They only throw QAErrorlogs the give a hint what probably went wrong.
61 ' Expected Errors MUST exclusivly be handled by the calling routine!
63 '--------------------------------------------------------------------
65 function fInvokeTitlesDialog() as INTEGER
66 fInvokeTitlesDialog = 99
67 ' Function to invoke the 'Insert::Titles...' dialog
68 ' Return (Error codes):
70 ' 1 = Serious problem trying to invoke the dialog
71 ' 2 = Failure (Dialog not present after invocation)
72 '99 = Unexpected error
73 printlog "Invoking 'Insert::Titles...' in menu"
74 '/// Execute menu item 'Insert::Titles...'
78 qaErrorLog "Error 1: Invoking menu item 'Insert::Titles...' failed"
79 fInvokeTitlesDialog = 1
83 '/// Lookup if call was successfull
84 Kontext "InsertTitleDialog"
85 if InsertTitleDialog.exists(2) then
86 printlog "Titles dialog is visible now."
87 fInvokeTitlesDialog = 0
89 qaErrorLog "Error 2: 'InsertTitles' has been executed but the dialog is not visible"
90 fInvokeTitlesDialog = 2
93 if fInvokeTitlesDialog = 99 then
94 warnlog "Error 99: Something unexpected happened!!"
98 '--------------------------------------------------------------------
100 function fCloseTitlesDialogOK() as INTEGER
101 fCloseTitlesDialogOK = 99
102 ' Function to close the Titles dialog using OK button
104 ' Returns error-code:
106 ' 1 := Serious problem trying to Close the dialog
107 ' 2 := Failure (Dialog present after applying OK button)
108 '15 := Dialog not present before closing
109 '99 := Unexpected error
111 printlog "** Closing Titles dialog"
112 Kontext "InsertTitleDialog"
113 '/// Check existence of Titles dialog
114 if InsertTitleDialog.exists(2) then
115 printlog ">> Titles dialog is visible as expected."
117 ' Return Error 15 and quit if dialog not found
118 qaErrorLog "Error 15: OOPS, Titles dialog should be visible ..."
119 qaErrorLog "... this is a BUG or a scripting error -> Check this out!"
120 fCloseTitlesDialogOK = 15
123 '/// Click OK button in Titles dialog
127 qaErrorLog "Error 1: Closing the Titles dialog seems to have a serious problem -> Check this out!"
128 fCloseTitlesDialogOK = 1
131 '/// Check that Titles dialog not existing anymore
132 Kontext "InsertTitleDialog"
133 if InsertTitleDialog.exists(2) then
134 ' Return Error 2 if still present
135 qaErrorLog "Error 2: Titles dialog should be invisible now ..."
136 qaErrorLog "... closing the dialog doesn't seem to work -> Check this out!"
137 fCloseTitlesDialogOK = 2
139 printlog ">> Closing the Titles dialog seems to work as expected"
140 fCloseTitlesDialogOK = 0
143 if fCloseTitlesDialogOK = 99 then
144 warnlog "Error 99: Something unexpected happened!!"
148 '--------------------------------------------------------------------
150 function fSetTitle ( oTitle as OBJECT , sTitleString as STRING ) as INTEGER
152 ' Function to set strings in Titles dialog
153 ' Input: OBJECT oTitle
154 ' Title Indicator (Name of declaration):
155 ' MainTitle, SubTitle, TitleXaxis, TitleYaxis, TitleZaxis are valid names
156 ' STRING sTitleString
157 ' Text to set on 'oTitle'
158 ' Returns error-code:
160 ' 1 := Serious problem trying to set title
161 ' 2 := Title was not set
162 '12 := Text-box for desired title is not enabled
163 '99 := Unexpected error
164 printlog "** Setting title"
165 '/// Check if desired title text-box is enabled
166 if NOT oTitle.IsEnabled then
167 qaErrorLog "Error 12: Text-box for desired title is not enabled"
168 qaErrorLog "... BUG or Script problem -> Check this out!"
172 '/// Put the text in desired title field
173 Kontext "InsertTitleDialog"
175 oTitle.setText ( sTitleString )
177 ' Throw error 1 and quit on serious problem
178 qaErrorLog "Error 1: Set text on title seems to cause a serious problem -> Check this out!"
182 '/// Verify (against input) if title was set correctly
183 if oTitle.getText = sTitleString then
185 printlog ">> Setting title seems to work"
187 qaErrorLog "Error 2: Title was not set -> Check this out!"
191 if fSetTitle = 99 then
192 warnlog "Error 99: Something unexpected happened!!"