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: querytools.inc,v $
13 '* last change: $Author: jsi $ $Date: 2008-06-16 07:43:46 $
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 : Helper Routines for Base tests.
38 '***************************************************************************************
41 ' #1 fOpenNewQueryDesign
42 ' #1 fStartQueryWizard
43 ' #1 fCloseQueryDesign
45 '\***********************************************************************************
46 '-------------------------------------------------------------------------
47 function fFindQueryInBeamer(sDSName1,sQueryName1)
48 '/// select a query with the given name in the beamer
49 '/// <u>parameter:</u>
50 '/// <b>sDSName1:</b> the name of the datasource
51 '/// <b>sQueryName1:</b> the name of the query
54 dim bfindQuery as boolean
56 dim iNoQuery as integer
59 Kontext "DatabaseBeamer"
60 Kontext "DatabaseSelection"
62 iNoDS = DatabaseSelection.getItemCount
64 DatabaseSelection.Select i
65 if DatabaseSelection.getText = sDSName1 then
71 DatabaseSelection.TypeKeys "<ADD>" , true
73 DatabaseSelection.TypeKeys "<DOWN>" , true
75 DatabaseSelection.TypeKeys "<DOWN>" , true
77 DatabaseSelection.TypeKeys "<ADD>" , true
79 DatabaseSelection.TypeKeys "<DOWN>" , true
83 iNoQuery = DatabaseSelection.getItemCount
85 ii = DatabaseSelection.GetSelIndex
86 for i = ii to iNoQuery
87 DatabaseSelection.Select i
88 if DatabaseSelection.getText = sQueryName1 then
95 fFindQuery = bfindQuery
98 '--------------------------------------------------------------------
99 function fOpenNewQueryDesign() as boolean
100 '/// open a new query design
101 '/// <u>parameter:</u>
104 Database.MouseDown(50,50)
105 Database.MouseUp(50,50)
107 if ( Database.NotExists(3) ) then
108 fOpenNewQueryDesign = false
109 warnlog "The database windows doesn't exists"
115 printlog "open new query design"
119 fOpenNewQueryDesign = true
122 '--------------------------------------------------------------------
123 function fOpenNewSQLQueryDesign() as boolean
124 '/// open a new query design in SQL mode
125 '/// <u>parameter:</u>
128 Database.MouseDown(50,50)
129 Database.MouseUp(50,50)
131 if ( Database.NotExists(3) ) then
132 fOpenNewSQLQueryDesign = false
133 warnlog "The database windows doesn't exists"
139 printlog "open new sql query design"
143 fOpenNewSQLQueryDesign = true
146 '-------------------------------------------------------------------------
147 function fStartQueryWizard()
148 '/// start the query wizard
149 '/// <u>parameter:</u>
152 if ( Database.NotExists(3) ) then
153 fStartQueryWizard = false
157 Database.MouseDown(50,50)
158 Database.MouseUp(50,50)
167 fStartQueryWizard = true
170 '-------------------------------------------------------------------------
171 function fCloseQueryDesign(optional bSave)
172 '/// close the query design
173 '/// <u>parameter:</u>
174 '/// <b><i>optional</i>bSave:</b> if true the query is saved if false then the changes are lost
178 Kontext "QueryDesignTable"
179 QueryDesignTable.UseMenu
180 ' bug file / close close the whole database
181 'hMenuSelectNr(1) ' the file menu
182 'hMenuSelectNr(4) ' the Close Window
184 hMenuSelectNr(6) ' the window menu
185 hMenuSelectNr(1) ' the Close Window
188 if Messagebox.Exists(3) then
189 if ( IsMissing( bSave ) ) then
203 '-------------------------------------------------------------------------
204 function fOpenQueryInSQLDesign(sQueryName as String)
205 '/// open a query in sql design
206 '/// <u>parameter:</u>
207 '/// <b>bQueryName:</b> the name of the query which should be open
209 if ( fFindQuery(sQueryName) = true ) then
210 printlog "Query " + sQueryName + " found -> open in sql design"
219 fOpenQueryInSQLDesign= true
221 fOpenQueryInSQLDesign = false
227 '-------------------------------------------------------------------------
228 function fCloseSQLQueryDesign(optional bSave)
229 '/// close the query design
230 '/// <u>parameter:</u>
231 '/// <b><i>optional</i>bSave:</b> if true the query is saved if false then the changes are lost
235 Kontext "QueryEditWindow"
236 QueryEditWindow.UseMenu
237 ' bug file / close close the whole database
238 'hMenuSelectNr(1) ' the file menu
239 'hMenuSelectNr(4) ' the Close Window
241 hMenuSelectNr(6) ' the window menu
242 hMenuSelectNr(1) ' the Close Window
245 if Messagebox.Exists(3) then
246 if ( IsMissing( bSave ) ) then
260 '-------------------------------------------------------------------------
261 function fSaveQueryDesign(sName as String)
262 '/// save an open Query Design
263 '/// <u>parameter:</u> the name of query
266 Kontext "QueryDesignTable"
267 QueryDesignTable.UseMenu
269 hMenuSelectNr(1) ' the file menu
270 hMenuSelectNr(6) ' the save
272 Kontext "DatabaseTableSaveAs"
273 TableName.setText(sName)
274 DatabaseTableSaveAs.OK
278 fSaveQueryDesign = true
281 '-------------------------------------------------------------------------
282 function fSaveSQLQueryDesign(sName as String)
283 '/// save an open SQL Query Design
284 '/// <u>parameter:</u> the name of query
287 Kontext "QueryEditWindow"
288 QueryEditWindow.UseMenu
290 hMenuSelectNr(1) ' the file menu
291 hMenuSelectNr(6) ' the save
293 Kontext "DatabaseTableSaveAs"
294 TableName.setText(sName)
295 DatabaseTableSaveAs.OK
299 fSaveSQLQueryDesign = true
303 '-------------------------------------------------------------------------
304 function fChooseTableInAddTableDialog(sTableName as string) as boolean
306 if ( not AddTables.exists(1) ) then
307 fChooseTableInQueryAddTableDialog = false
311 'TODO: add a test to click on the execute button, before the add table dialog is closed.
314 ix = TableName.getItemCount
317 TableName.TypeKeys "<ADD>"
318 'printlog "ix = " + ix
319 'printlog "TableName.getItemCount = " + TableName.getItemCount
320 if TableName.getItemCount > ix then
321 ix = TableName.getItemCount
322 'printlog "TableName.getItemCount > ix"
324 'printlog "TableName.getSeltext = " + TableName.getSeltext
325 if TableName.getSeltext = sTableName then
329 if TableName.getSeltext <> sTableName then
330 warnlog "Can find the table " + sTableName + "." + _
331 "Make sure that the table exists when starting this test."
335 if Messagebox.Exists(3) then
336 if Messagebox.getRT = 304 then
343 printlog "- Add " + sTableName +" table to query design"
344 '/// Add database table to Query.
347 if AddTables.exists(2) then
348 CloseDlg.Click ' When the AddTables dialog still exists then close him
351 fChooseTableInAddTableDialog = true
354 '--------------------------------------------------------------------
355 function fOpenQuery(sQueryName as string)
356 '/// open the query with the given name
357 '/// <u>parameter:</u>
358 '/// <b>squeryName:</b> the query which shall be opened
359 if ( fFindQuery(sQueryName) = true ) then
360 printlog "Query " + sQueryName + " found -> open"
361 Kontext "ContainerView"
362 OpenTable ' uno-Slot .uno:DB/Open
370 '--------------------------------------------------------------------
371 function fFindQuery(sQueryName as string)
372 '/// select the Query with the given name in the Query container
373 '/// <u>parameter:</u>
374 '/// <b>sQueryName:</b> the Query which shall be selected
376 Dim iNumbersOfQuerys as integer
379 Kontext "ContainerView"
385 if ( Not QueriesTree.exists(1) ) then
386 qaerrorlog "The Query tree doesn't exists"
387 ' May be a messagebox appear click OK to close it
389 if MessageBox.exists(1) then
390 qaerrorlog MessageBox.getText()
391 while MessageBox.exists() ' sometimes there are more then 1 message boxe
398 iNumbersOfQuerys = QueriesTree.getItemCount()
400 ' this select the first entry
401 QueriesTree.TypeKeys "<HOME>"
402 QueriesTree.TypeKeys "<UP>"
405 for i = 1 to iNumbersOfQuerys
407 QueriesTree.TypeKeys "<ADD>"
409 'printlog "QueryName.getItemCount = " + QueriesTree.getItemCount
410 if QueriesTree.getItemCount > iNumbersOfQuerys then
411 iNumbersOfQuerys = QueriesTree.getItemCount()
413 'printlog "QueryName.getSeltext = " + QueriesTree.getSeltext
414 if QueriesTree.getSeltext = sQueryName then
418 QueriesTree.TypeKeys "<DOWN>"
423 '-------------------------------------------------------------------------
424 function fCloseQueryView()
425 '/// close an open Query view
426 '/// <u>parameter:</u>
432 ' bug file / close close the whole database
433 'hMenuSelectNr(1) ' the file menu
434 'hMenuSelectNr(4) ' the Close Window
436 hMenuSelectNr(5) ' the window menu
437 hMenuSelectNr(1) ' the Close Window
438 ' if messages box appear because of unsaved record click no in the dialog
440 if Messagebox.Exists(3) then
444 fCloseQueryView = true