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: dbtools.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 '***************************************************************************************
40 ' #1 fSelectDatasourceInBeamer
41 ' #1 fConnectToDatasourceInBeamer
42 ' #1 fSelectSchemaInTableFilter
46 ' #1 tools_dbtools_fgetMySQLDatabaseProperties
48 '\***********************************************************************************
49 '--------------------------------------------------------------------
50 function fSelectDatasourceInBeamer(sDSName1)
51 '/// select a datasource in the beamer with the given name
52 '/// <u>parameter:</u>
53 '/// <b>sDSName1:</b> the name of the datasource which shall be seleced
56 dim bfindDS as boolean
60 Kontext "DatabaseBeamer"
61 Kontext "DatabaseSelection"
63 iNoDS = DatabaseSelection.getItemCount
65 DatabaseSelection.Select i
66 if DatabaseSelection.getText = sDSName1 then
72 fSelectDatasourceInBeamer = bfindDS
77 '--------------------------------------------------------------------
78 function fConnectToDatasourceInBeamer(sDSName , sPWD, optional bNewDoc)
80 if ( isMissing (bNewDoc) )then
90 dim bConnect as boolean
92 if fFindDatasource(sDSName) = true then
93 DatabaseSelection.TypeKeys "<ADD>"
94 DatabaseSelection.TypeKeys "<DOWN>"
95 DatabaseSelection.TypeKeys "<DOWN>"
96 DatabaseSelection.TypeKeys "<DOWN>"
97 DatabaseSelection.TypeKeys "<ADD>"
99 if LoginDialog.Exists(3) then
100 Password.SetText sPWD
105 warnlog "Could not found the datasource " + sDSName
112 fConnectToDatasource = bConnect
115 '--------------------------------------------------------------------
116 function fSelectSchemaInTableFilter(sSchema as String)
117 '/// select the given schema in the table filter dialog in an open database
118 '/// <u>parameter:</u>
119 '/// <b>sSchema:</b> the name of the schema
131 Kontext "TablesFilter"
132 printlog Tables.getItemCount
135 fSelectSchemaInTableFilter = true
138 '-------------------------------------------------------------------------
139 function fOpenNewDataBase ( sSaveFileName )
140 '/// open a database window and sabe it to the given name
141 '/// <u>parameter:</u>
142 '/// <b>sSaveFileName:</b> the file name for the database file
143 FileOpen "FileName", "private:factory/sdatabase" , "FrameName", "_blank" , "SynchronMode" ,True
147 Kontext "SpeichernDlg"
148 Dateiname.setText Convertpath(gOfficePath + "/user/work/" + sSaveFileName)
153 if MessageBox.exists then
160 '-------------------------------------------------------------------------
161 function fOpenDataBase ( sFileName , optional sPassword)
162 '/// open a database file with the given name and try to connect
163 '/// <u>parameter:</u>
164 '/// <b>sFileName:</b> the file name which shall be open
165 '/// <b><i>optional</i>sFileName:</b> the password for connecting
170 Dim DieDatei as String
171 DieDatei = ConvertPath ( sFileName )
172 '/// open the File Open dialog
173 printlog "open the File Open dialog"
177 '/// open the given file
178 printlog "open the given file: " + sFileName
179 Dateiname.SetText DieDatei
184 'click on the main window to get the focus
186 Database.MouseDown(50,50)
187 Database.MouseUp(50,50)
193 '/// if the password is given add the password
194 if ( Not IsMissing(sPassword) ) then
195 printlog "set password : " + sPassword
196 Kontext "LoginDialog"
197 if LoginDialog.Exists then
198 Password.setText sPassword
204 if (MessageBox.exists(2)) then
207 dim iNrTexts as integer
209 iNrtexts = MessageBox.getFixedtextCount
210 for i = 1 to iNrtexts
211 qaerrorlog MessageBox.getFixedtext(i)
214 ' try again to close the dialog if exists
215 if (MessageBox.exists(2)) then
224 '-------------------------------------------------------------------------
225 function fCloseDatabase(optional bSave)
226 '/// close the database
227 '/// <u>parameter:</u>
228 '/// <b><i>optional</i>bSave:</b> if true the the database is saved if false then the changes are lost
231 Database.MouseDown(50,50)
232 Database.MouseUp(50,50)
238 if Messagebox.Exists(3) then
239 if ( IsMissing( bSave ) ) then
253 '-------------------------------------------------------------------------
254 sub sCloseAllToolbars
256 Kontext "FormControls"
257 if FormControls.exists(1) then
261 Kontext "MoreControls"
262 if MoreControls.exists(1) then
266 Kontext "FormDesignTools"
267 if FormDesignTools.exists(1) then
268 FormDesignTools.close()
272 '-------------------------------------------------------------------------
273 function tools_dbtools_fgetMySQLJDBCDatabaseProperties()
274 '/// return the databaseserver properties from the environment directory
275 '/// <u>parameter:</u>
278 '/// the properties as an array
279 '/// entry 1 defined (yes or no)
280 '/// entry 2 server name
281 '/// entry 3 database name
282 '/// entry 4 database port
283 '/// entry 5 database user name
284 '/// entry 6 database user password
287 dim b(10000) as String
289 c = hGetDataFileSection( gTesttoolPath + gPrivateEnvironmentLocation + "input/base.txt", b(), "mysql_jdbc" , "" , "" )
291 ' split the string at = and return the right part
294 b(i) = Right(b(i),len(b(i))-Instr(b(i),"="))
298 tools_dbtools_fgetMySQLJDBCDatabaseProperties = b()
301 '-------------------------------------------------------------------------
302 function tools_dbtools_fgetMySQLODBCDatabaseProperties()
303 '/// return the databaseserver properties from the environment directory
304 '/// <u>parameter:</u>
307 '/// the properties as an array
308 '/// entry 1 defined (yes or no)
309 '/// entry 2 odbc dsn name
310 '/// entry 3 database user name
311 '/// entry 4 database user password
314 dim b(10000) as String
316 c = hGetDataFileSection( gTesttoolPath + gPrivateEnvironmentLocation + "input/base.txt", b(), "mysql_odbc" , "" , "" )
318 ' split the string at = and return the right part
321 b(i) = Right(b(i),len(b(i))-Instr(b(i),"="))
325 tools_dbtools_fgetMySQLODBCDatabaseProperties = b()
328 '-------------------------------------------------------------------------
329 function tools_dbtools_fgetAdabasDatabaseProperties()
330 '/// return the databaseserver properties from the environment directory
331 '/// <u>parameter:</u>
334 '/// the properties as an array
335 '/// entry 1 defined (yes or no)
336 '/// entry 2 server name
337 '/// entry 3 database name
338 '/// entry 4 database user name
339 '/// entry 5 database user password
342 dim b(10000) as String
344 c = hGetDataFileSection( gTesttoolPath + gPrivateEnvironmentLocation + "input/base.txt", b(), "adabas" , "" , "" )
346 ' split the string at = and return the right part
349 b(i) = Right(b(i),len(b(i))-Instr(b(i),"="))
353 tools_dbtools_fgetAdabasDatabaseProperties = b()