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_legend.inc,v $
13 '* last change: $Author: jsi $ $Date: 2008-06-13 14:27:02 $
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 Legend dialog
38 '**************************************************************************************************
40 ' #1 fInvokeLegendDialog
41 ' #1 fCloseLegendDialogOK
42 ' #1 fSetDisplayLegend
43 ' #1 fSetLegendPosition
45 '\************************************************************************************************
47 ' ch_tools_legend.inc - A library for automation of the 'Insert/Legend...' dialog
48 ' This Include contains a set of functions to modify the controls of the Legend dialog.
49 ' All functions are designed to return error-codes depending on the behaviour of the action applied.
52 ' Error 1: The basic action beeing applied caused a serious problem, e.g. a crash.
53 ' Error 2 TO 9: A functional problem occured.
54 ' Error 11 TO 19: Wrong marginal conditions end up in failture, e.g. control not visible.
55 ' NOTE: This errors can also be used for 'negative' testing.
56 ' Error 42: Wrong input. Probably only of interest during test development .
57 ' Error 99: Unexpected behaviour - Shouldn't normally occur.
59 ' Only Errors 42 and 99 throw 'warnlogs'.
60 ' All other errors are silent.
61 ' They only throw QAErrorlogs the give a hint what probably went wrong.
62 ' Expected Errors MUST exclusivly be handled by the calling routine.
64 '--------------------------------------------------------------------
66 function fInvokeLegendDialog() as INTEGER
67 fInvokeLegendDialog = 99
68 ' Function to invoke the 'Insert/Legend...' dialog
69 ' Return (Error codes):
71 ' 1 = Serious problem trying to invoke the dialog
72 ' 2 = Failure (Dialog not present after invocation)
73 ' 99 = Unexpected error
74 printlog "Invoking 'Insert/Legend...' in menu"
75 '/// Execute menu item 'Insert/Legend...'
79 qaErrorLog "Error 1: Invoking menu item 'Insert/Legend...' failed"
80 fInvokeLegendDialog = 1
84 '/// Lookup if call was successful
85 Kontext "InsertLegendDialog"
86 if InsertLegendDialog.exists(2) then
87 printlog ">> Legend dialog is visible now."
88 fInvokeLegendDialog = 0
90 QAErrorLog "Error 2: The slot 'InsertLegend' has been executed but the dialog is not visible"
91 fInvokeLegendDialog = 2
94 if fInvokeLegendDialog = 99 then
95 warnlog "Error 99: Something unexpected happened!!"
99 '--------------------------------------------------------------------
101 function fCloseLegendDialogOK() as INTEGER
102 fCloseLegendDialogOK = 99
103 ' Function to close the Legend dialog using OK button
105 ' Returns error-code:
107 ' 1 := Serious problem trying to Close the dialog
108 ' 2 := Failure (Dialog present after applying OK button)
109 '15 := Dialog not present before closing
110 '99 := Unexpected error
111 printlog "** Closing Legend dialog"
112 Kontext "InsertLegendDialog"
113 '/// Check existence of Legend dialog
114 if InsertLegendDialog.exists(2) then
115 printlog ">> Legend dialog is visible as expected."
117 ' Return Error 15 and quit if dialog not found
118 qaErrorLog "Error 15: OOPS, Legend dialog should be visible ..."
119 qaErrorLog "... this is a BUG or a scripting error -> Check this out!"
120 fCloseLegendDialogOK = 15
123 '/// Click OK button in Legend dialog
125 InsertLegendDialog.OK
127 qaErrorLog "Error 1: Closing the Legend dialog seems to have a serious problem -> Check this out!"
128 fCloseLegendDialogOK = 1
131 '///+ Check that the Legend dialog is not available any longer
132 Kontext "InsertLegendDialog"
133 if InsertLegendDialog.exists(2) then
134 ' Return Error 2 if still present
135 qaErrorLog "Error 2: Legend dialog should be invisible now ..."
136 qaErrorLog "... closing the dialog doesn't seem to work -> Check this out!"
137 fCloseLegendDialogOK = 2
139 printlog ">> Closing the Legend dialog seems to work as expected"
140 fCloseLegendDialogOK = 0
143 if fCloseLegendDialogOK = 99 then
144 warnlog "Error 99: Something unexpected happened!!"
148 '--------------------------------------------------------------------
150 function fSetDisplayLegend ( bDisplayLegend as BOOLEAN ) as INTEGER
151 fSetDisplayLegend = 99
152 ' Function to [en|dis]able visibility of chart legend
154 ' BOOLEAN bDisplayLegend
155 ' TRUE := Check 'Dislay (legend)'
156 ' FALSE := Uncheck 'Dislay (legend)'
157 ' Returns error-code:
159 ' 1 := Serious problem trying to check grid
160 ' 2 := 'Dislay (legend)' was not set
161 '11 := 'Dislay (legend)' Check-box is not visible
162 '99 := Unexpected error
163 printlog "** Setting Display Legend"
164 '/// Check if 'Dislay (legend)' check-box is visible
165 Kontext "InsertLegendDialog"
166 if NOT Display.IsVisible then
167 qaErrorLog "Error 11: Check-box for 'Dislay (legend)' is not visible"
168 qaErrorLog "... BUG or Script problem -> Check this out!"
169 fSetDisplayLegend = 11
172 '/// Try to (Un)Check 'Dislay (legend)'
173 Kontext "InsertLegendDialog"
175 if bDisplayLegend then
181 ' Throw error 1 and quit on serious problem
182 qaErrorLog "Error 1: Check 'Dislay (legend)' seems to cause a serious problem -> Check this out!"
183 fSetDisplayLegend = 1
186 '/// Verify (against input) if check-box was checked
187 if Display.IsChecked = bDisplayLegend then
188 fSetDisplayLegend = 0
189 printlog ">> Setting 'Dislay (legend)' seems to work"
191 qaErrorLog "Error 2: 'Dislay (legend)' was not checked -> Check this out!"
192 fSetDisplayLegend = 2
195 if fSetDisplayLegend = 99 then
196 warnlog "Error 99: Something unexpected happened!!"
200 '--------------------------------------------------------------------
202 function fSetLegendPosition ( oPosition as OBJECT ) as INTEGER
203 fSetLegendPosition = 99
204 ' Function to select Legend position
207 ' Declaration name of Radio-Button: Position[Left|Right|Top|Bottom] are valid values
208 ' Returns error-code:
210 ' 1 := Serious problem trying to check Legend position radio-button
211 ' 2 := Legend position radio-button was not set
212 '12 := Radio-Button for desired position is not enabled
213 '42 := User error, input doesn't match.
214 '99 := Unexpected error
215 printlog "** Setting Legend position"
216 '/// Check if Legend position radio-button is enabled
217 Kontext "InsertLegendDialog"
218 if NOT oPosition.IsEnabled then
219 qaErrorLog "Error 12: Radio-Button for desired position is not enabled"
220 qaErrorLog "... BUG or Script problem -> Check this out!"
221 fSetLegendPosition = 12
224 '/// Try to (Un)Check desired radio-button
225 Kontext "InsertLegendDialog"
229 ' Throw error 1 and quit on serious problem
230 qaErrorLog "Error 1: Check Legend position radio-button seems to cause a serious problem -> Check this out!"
231 fSetLegendPosition = 1
234 '/// Verify (against input) if Legend position radio-button was checked
235 if oPosition.IsChecked then
236 fSetLegendPosition = 0
237 printlog ">> Setting Legend position radio-button seems to work"
239 qaErrorLog "Error 2: Desires Legend position radio-button was not checked -> Check this out!"
240 fSetLegendPosition = 2
243 if fSetLegendPosition = 99 then
244 warnlog "Error 99: Something unexpected happened!!"