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 2000, 2010 Oracle and/or its affiliates.
7 ' OpenOffice.org - a multi-platform office productivity suite
9 ' This file is part of OpenOffice.org.
11 ' OpenOffice.org is free software: you can redistribute it and/or modify
12 ' it under the terms of the GNU Lesser General Public License version 3
13 ' only, as published by the Free Software Foundation.
15 ' OpenOffice.org is distributed in the hope that it will be useful,
16 ' but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ' MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ' GNU Lesser General Public License version 3 for more details
19 ' (a copy is included in the LICENSE file that accompanied this code).
21 ' You should have received a copy of the GNU Lesser General Public License
22 ' version 3 along with OpenOffice.org. If not, see
23 ' <http://www.openoffice.org/license.html>
24 ' for a copy of the LGPLv3 License.
26 '/************************************************************************
28 '* owner : marc.neumann@oracle.com
30 '* short description : Helper Routines for Base tests.
32 '***************************************************************************************
34 ' #1 fSelectDatasourceInBeamer
35 ' #1 fConnectToDatasourceInBeamer
36 ' #1 fSelectSchemaInTableFilter
40 ' #1 tools_dbtools_fgetMySQLDatabaseProperties
42 '\***********************************************************************************
44 private const VERBOSE = true
46 '--------------------------------------------------------------------
47 function fSelectDatasourceInBeamer(sDSName1)
48 '/// select a datasource in the beamer with the given name
49 '/// <u>parameter:</u>
50 '/// <b>sDSName1:</b> the name of the datasource which shall be seleced
53 dim bfindDS as boolean
57 Kontext "DatabaseBeamer"
58 Kontext "DatabaseSelection"
60 iNoDS = DatabaseSelection.getItemCount
62 DatabaseSelection.Select i
63 if DatabaseSelection.getText = sDSName1 then
69 fSelectDatasourceInBeamer = bfindDS
74 '--------------------------------------------------------------------
75 function fConnectToDatasourceInBeamer(sDSName , sPWD, optional bNewDoc)
77 if ( isMissing (bNewDoc) )then
87 dim bConnect as boolean
89 if fFindDatasource(sDSName) = true then
90 DatabaseSelection.TypeKeys "<ADD>"
91 DatabaseSelection.TypeKeys "<DOWN>"
92 DatabaseSelection.TypeKeys "<DOWN>"
93 DatabaseSelection.TypeKeys "<DOWN>"
94 DatabaseSelection.TypeKeys "<ADD>"
96 if LoginDialog.Exists(3) then
97 LoginPassword.SetText sPWD
102 warnlog "Could not found the datasource " + sDSName
109 fConnectToDatasource = bConnect
112 '--------------------------------------------------------------------
113 function fSelectSchemaInTableFilter(sSchema as String)
114 '/// select the given schema in the table filter dialog in an open database
115 '/// <u>parameter:</u>
116 '/// <b>sSchema:</b> the name of the schema
128 Kontext "TablesFilter"
129 printlog Tables.getItemCount
132 fSelectSchemaInTableFilter = true
135 '-------------------------------------------------------------------------
136 function fOpenNewDataBase ( sSaveFileName )
137 '/// open a database window and sabe it to the given name
138 '/// <u>parameter:</u>
139 '/// <b>sSaveFileName:</b> the file name for the database file
140 FileOpen "FileName", "private:factory/sdatabase" , "FrameName", "_blank" , "SynchronMode" ,True
144 Kontext "SpeichernDlg"
145 Dateiname.setText Convertpath(gOfficePath + "/user/work/" + sSaveFileName)
150 if MessageBox.exists then
157 '-------------------------------------------------------------------------
158 function fOpenDataBase ( sFileName , optional sPassword)
159 '/// open a database file with the given name and try to connect
160 '/// <u>parameter:</u>
161 '/// <b>sFileName:</b> the file name which shall be open
162 '/// <b><i>optional</i>sFileName:</b> the password for connecting
167 Dim DieDatei as String
168 DieDatei = ConvertPath ( sFileName )
171 printlog "Filename : " + sFileName
172 if(NOT isMissing(sPassword)) then
173 printlog "Password : " + sPassword
177 '/// open the File Open dialog
178 printlog "open the File Open dialog"
182 '/// open the given file
183 Dateiname.SetText DieDatei
188 'click on the main window to get the focus
190 Database.MouseDown(50,50)
191 Database.MouseUp(50,50)
197 '/// if the password is given add the password
198 if ( Not IsMissing(sPassword) ) then
199 printlog "set password : " + sPassword
200 Kontext "LoginDialog"
201 if LoginDialog.Exists then
202 LoginPassword.setText sPassword
208 if (MessageBox.exists(2)) then
211 dim iNrTexts as integer
213 iNrtexts = MessageBox.getFixedtextCount
214 for i = 1 to iNrtexts
215 qaerrorlog MessageBox.getFixedtext(i)
218 ' try again to close the dialog if exists
219 if (MessageBox.exists(2)) then
228 '-------------------------------------------------------------------------
229 function fCloseDatabase(optional bSave)
230 '/// close the database
231 '/// <u>parameter:</u>
232 '/// <b><i>optional</i>bSave:</b> if true the the database is saved if false then the changes are lost
235 Database.MouseDown(50,50)
236 Database.MouseUp(50,50)
242 if Messagebox.Exists(3) then
243 if ( IsMissing( bSave ) ) then
257 '-------------------------------------------------------------------------
258 sub sCloseAllToolbars
260 Kontext "FormControls"
261 if FormControls.exists(1) then
265 Kontext "MoreControls"
266 if MoreControls.exists(1) then
270 Kontext "FormDesignTools"
271 if FormDesignTools.exists(1) then
272 FormDesignTools.close()
276 '-------------------------------------------------------------------------
277 function tools_dbtools_fgetMySQLJDBCDatabaseProperties(sDBConfigFileName as string)
278 '/// return the databaseserver properties from the environment directory
279 '/// <u>parameter:</u>
282 '/// the properties as an array
283 '/// entry 1 defined (yes or no)
284 '/// entry 2 server name
285 '/// entry 3 database name
286 '/// entry 4 database port
287 '/// entry 5 database user name
288 '/// entry 6 database user password
289 '/// entry 7 jdbc driver file path
291 tools_dbtools_fgetMySQLJDBCDatabaseProperties = fgetGenericDatabaseProperties( sDBConfigFileName, "mysql_jdbc" )
294 '-------------------------------------------------------------------------
295 function tools_dbtools_fgetMySQLODBCDatabaseProperties()
296 '/// return the databaseserver properties from the environment directory
297 '/// <u>parameter:</u>
300 '/// the properties as an array
301 '/// entry 1 defined (yes or no)
302 '/// entry 2 odbc dsn name
303 '/// entry 3 database user name
304 '/// entry 4 database user password
307 dim b(10000) as String
309 c = hGetDataFileSection( gTesttoolPath + gPrivateEnvironmentLocation + "input/base.txt", b(), "mysql_odbc" , "" , "" )
311 ' split the string at = and return the right part
314 b(i) = Right(b(i),len(b(i))-Instr(b(i),"="))
318 tools_dbtools_fgetMySQLODBCDatabaseProperties = b()
321 '-------------------------------------------------------------------------
322 function tools_dbtools_fgetAdabasDatabaseProperties()
323 '/// return the databaseserver properties from the environment directory
324 '/// <u>parameter:</u>
327 '/// the properties as an array
328 '/// entry 1 defined (yes or no)
329 '/// entry 2 server name
330 '/// entry 3 database name
331 '/// entry 4 database user name
332 '/// entry 5 database user password
335 dim b(10000) as String
337 c = hGetDataFileSection( gTesttoolPath + gPrivateEnvironmentLocation + "input/base.txt", b(), "adabas" , "" , "" )
339 ' split the string at = and return the right part
342 b(i) = Right(b(i),len(b(i))-Instr(b(i),"="))
346 tools_dbtools_fgetAdabasDatabaseProperties = b()
349 '-------------------------------------------------------------------------------
350 function fgetGenericDatabaseProperties(sDBConfigFileName as string, sType as String)
353 dim b(10000) as String
355 c = hGetDataFileSection( sDBConfigFileName, b(), sType , "" , "" )
357 ' split the string at = and return the right part
360 printlog "orig. string : " + b(i)
362 b(i) = Right(b(i),len(b(i))-Instr(b(i),"="))
364 printlog "string after the '=' : " + b(i)
371 fgetGenericDatabaseProperties = b()