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_grids.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 Grids dialog
38 '**************************************************************************************************
40 ' #1 fInvokeGridsDialog
41 ' #1 fCloseGridsDialogOK
44 '\************************************************************************************************
46 ' ch_tools_grids.inc - Library for automation of the 'Insert::Grids...' dialog
47 ' This Include contains a set of functions to modify the controls of the Grids 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 fInvokeGridsDialog() as INTEGER
66 fInvokeGridsDialog = 99
67 ' Function to invoke the 'Insert / Grids...' dialog
68 ' Returns (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::Grids...' in menu"
74 '/// Execute menu item 'Insert::Grids...'
78 QAErrorLog "Error 1: Invoking menu item 'Insert::Grids...' failed"
79 fInvokeGridsDialog = 1
83 '/// Lookup if call was successful
84 Kontext "InsertGridsDialog"
85 if InsertGridsDialog.exists(2) then
86 printlog ">> Grids dialog is visible now."
87 fInvokeGridsDialog = 0
89 qaErrorLog "Error 2: The slot 'InsertGrids' has been executed but the dialog is not visible"
90 fInvokeGridsDialog = 2
93 if fInvokeGridsDialog = 99 then
94 warnlog "Error 99: Something unexpected happened!!"
98 '--------------------------------------------------------------------
100 function fCloseGridsDialogOK() as INTEGER
101 fCloseGridsDialogOK = 99
102 ' Function to close the Grids dialog using OK button
104 ' Returns error-codes:
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
110 printlog "** Closing Grids dialog"
111 Kontext "InsertGridsDialog"
112 '/// Check existence of Grids dialog
113 if InsertGridsDialog.exists(2) then
114 printlog ">> Grids dialog is visible as expected."
116 'Return Error 15 and quit if dialog not found
117 qaErrorLog "Error 15: OOPS, Grids dialog should be visible ..."
118 qaErrorLog "... this is a BUG or a scripting error -> Check this out!"
119 fCloseGridsDialogOK = 15
122 '/// Click OK button in Grids dialog
126 qaErrorLog "Error 1: Closing the Grids dialog seems to have a serious problem -> Check this out!"
127 fCloseGridsDialogOK = 1
130 '/// Check that Grids dialog is not available anymore
131 Kontext "InsertGridsDialog"
132 if InsertGridsDialog.exists(2) then
133 'Return Error 2 if still present
134 qaErrorLog "Error 2: Grids dialog should be invisible now ..."
135 qaErrorLog "... closing the dialog doesn't seem to work -> Check this out!"
136 fCloseGridsDialogOK = 2
138 printlog ">> Closing the Grids dialog seems to work as expected"
139 fCloseGridsDialogOK = 0
142 if fCloseGridsDialogOK = 99 then
143 warnlog "Error 99: Something unexpected happened!!"
147 '--------------------------------------------------------------------
149 function fSetGrid ( oGrid as OBJECT , bGridCheck as BOOLEAN ) as INTEGER
151 ' Function to check-boxes in Grids dialog
154 ' Grid Indicator (Name of declaration): MainGrid[XYZ]Axis, MinorGrid[XYZ]Axis< are valid name
157 ' FALSE := Uncheck Grid
158 ' Returns error-code:
160 ' 1 := Serious problem trying to check grid
161 ' 2 := Grid was not set
162 '11 := Check-box for desired grid is not visible
163 '12 := Check-box for desired grid is not enabled
164 '99 := Unexpected error
165 printlog "** Setting Grid"
166 Kontext "InsertGridsDialog"
167 '/// Check if desired grid check-box is visible
168 if NOT oGrid.IsVisible then
169 qaErrorLog "Error 11: Check-box for desired grid is not visible"
170 qaErrorLog "... BUG or Script problem -> Check this out!"
174 '/// Check if desired grid check-box is enabled
175 if NOT oGrid.IsEnabled then
176 qaErrorLog "Error 12: Check-box for desired grid is not enabled"
177 qaErrorLog "... BUG or Script problem -> Check this out!"
181 '/// Try to (Un)Check desired Grid
182 Kontext "InsertGridsDialog"
190 ' Throw error 1 and quit on serious problem
191 qaErrorLog "Error 1: Check grid seems to cause a serious problem -> Check this out!"
195 '/// Verify (against input) if grid was checked
196 if oGrid.IsChecked = bGridCheck then
198 printlog ">> Setting grid seems to work"
200 qaErrorLog "Error 2: Grid was not checked -> Check this out!"
204 if fSetGrid = 99 then
205 warnlog "Error 99: Something unexpected happened!!"