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: dbcreatetools.inc,v $
13 '* last change: $Author: jsi $ $Date: 2008-06-16 07:43:45 $
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 : Library with function for creating all possible databases
38 '***************************************************************************************
40 ' #1 fCreateMySQL_ODBC_Datasource
41 ' #1 fCreateMySQL_JDBC_Datasource
42 ' #1 fCreateAdabasDatasource
43 ' #1 fCreateLocalAdabasDatasource
44 ' #1 fCreateJDBCDatasource
45 ' #1 fCreateODBCDatasource
46 ' #1 fCreateDbaseDatasource
47 ' #1 fCreateADODatasource
48 ' #1 fCreateTextDatasource
49 ' #1 fCreateSpreadsheetDatasource
50 ' #1 fCreateLDAPAddressbookDatasource
51 ' #1 fCreateEvolutionAddressbookDatasource
52 ' #1 fCreateWindowsAddressbookDatasource
53 ' #1 fCreateOutlookAddressbookDatasource
54 ' #1 fCreateMozillaAddressbookDatasource
55 ' #1 fRegisterDatabaseFile
56 ' #1 fDeRegisterDatabaseFile
57 ' #1 fSetJDBCDriverFiles
58 ' #1 getIdForDatabaseType
60 '\***********************************************************************************
61 function fCreateMySQL_ODBC_Datasource(sFileName, sOdbcDSN, sUser,optional sRegister) as boolean
62 '/// create a new MySQL database via ODBC file with the given filename
63 '///+ and the given URL
64 '/// <u>parameter:</u>
65 '/// <b>sFileName:</b> the file name for the database file
66 '/// <b>sOdbcDSN:</b> the name of the odbc datasource
67 '/// <b>sUser:</b> the user for the connection
68 '/// <b>sPassword:</b> the password for the connection
69 '/// <b><i>optional</i> sRegister:</b> the name under which the database is be registered
74 if ( app.Dir( ConvertPath(sFileName) ) ) <> "" then
75 app.kill(ConvertPath(sFileName))
78 Kontext "DocumentWriter"
79 if (DocumentWriter.exists(1)) then
80 DocumentWriter.UseMenu
82 Kontext "DocumentBackground"
83 DocumentBackground.UseMenu
91 Kontext "DatabaseWizard"
92 ConnectToDatabase.Check
94 DatabaseType.select( hGetDatabaseDisplayName( "sdbc:mysql:odbc:*" ) )
101 Kontext "DatabaseWizard"
104 printlog "add the URL"
105 MySQLODBCDSName.setText "sdbc:mysql:odbc:" + sOdbcDSN
107 Kontext "DatabaseWizard"
110 Kontext "DatabaseWizard"
111 '/// add the user name
112 printlog "add the user name"
113 UserName.setText sUser
115 '/// check the password required checkbox
116 printlog "check the password required checkbox"
117 PasswordRequired.Check
119 Kontext "DatabaseWizard"
122 Kontext "DatabaseWizard"
125 Kontext "SpeichernDlg"
126 Dateiname.setText ConvertPath(sFileName)
131 if ( IsMissing(sRegister) ) then
132 printlog "don't register datasource"
134 printlog "register datasource with name " + sRegister
135 call fRegisterDatabaseFile(ConvertPath(sFilename),sRegister)
140 printlog "--- End of function - *** Succeed ***"
142 warnlog "--- End of function - *** Failed *** Data source was not created"
145 call fCloseDatabase(true)
147 fCreateMySQL_ODBC_Datasource = bOK
150 '-------------------------------------------------------------------------
151 function fCreateMySQL_JDBC_Datasource(sFileName,sDatabaseName,sHost,sPort,sUser,optional sRegister) as boolean
152 '/// create a new MySQL database via JDBC file with the given filename
153 '///+ and the given URL
154 '/// <u>parameter:</u>
155 '/// <b>sFielName:</b> the file name for the database file
156 '/// <b>sDatabaseName:</b> the name of the mysql database
157 '/// <b>sHost:</b> the host where the mysql database is running
158 '/// <b>sPort:</b> the port where the mysql database is running
159 '/// <b>sUser:</b> the user for the connection
160 '/// <b><i>optional</i> sRegister:</b> the name under which the database is be registered
165 if ( app.Dir( ConvertPath(sFileName) ) ) <> "" then
166 app.kill(ConvertPath(sFileName))
169 Kontext "DocumentWriter"
170 if (DocumentWriter.exists(1)) then
171 DocumentWriter.UseMenu
173 Kontext "DocumentBackground"
174 DocumentBackground.UseMenu
182 Kontext "DatabaseWizard"
183 ConnectToDatabase.Check
185 DatabaseType.select( hGetDatabaseDisplayName( "sdbc:mysql:jdbc:*" ) )
192 MySQLDatabaseName.setText(sDatabaseName)
193 MySQLHostName.setText(sHost)
194 MySQLPort.setText(sPort)
199 '/// add the user name
200 printlog "add the user name"
201 UserName.setText sUser
203 '/// check the password required checkbox
204 printlog "check the password required checkbox"
205 PasswordRequired.Check
207 Kontext "DatabaseWizard"
210 Kontext "SpeichernDlg"
211 Dateiname.setText ConvertPath(sFileName)
216 if ( IsMissing(sRegister) ) then
217 printlog "don't register datasource"
219 printlog "register datasource with name " + sRegister
220 call fRegisterDatabaseFile(ConvertPath(sFilename),sRegister)
225 printlog "--- End of function - *** Succeed ***"
227 warnlog "--- End of function - *** Failed *** Data source was not created"
230 fCreateMySQL_JDBC_Datasource = bOK
234 call fCloseDatabase(true)
237 '-------------------------------------------------------------------------
238 function fCreateAdabasDatasource(sFileName,sURL,sUser, optional sRegister) as boolean
239 '/// create a new adabas database file with the given filename
240 '///+ and the given URL
241 '/// <u>parameter:</u>
242 '/// <b>sFielName:</b> the file name for the database file
243 '/// <b>sURL:</b> the URL for the adabas database
244 '/// <b>sUser:</b> the user for connect
245 '/// <b><i>optional</i> sRegister:</b> the name under which the database is registered
252 if ( app.Dir( ConvertPath(sFileName) ) ) <> "" then
253 app.kill(ConvertPath(sFileName))
258 Kontext "DocumentWriter"
259 if (DocumentWriter.exists(1)) then
260 DocumentWriter.UseMenu
262 Kontext "DocumentBackground"
263 DocumentBackground.UseMenu
271 Kontext "DatabaseWizard"
272 ConnectToDatabase.Check
274 DatabaseType.select ( hGetDatabaseDisplayName( "sdbc:adabas:*" ) )
278 '/// insert the adabas database name
279 printlog "insert the adabas database name"
280 AdabasDBName.setText("sdbc:adabas:" + sURL)
283 printlog "click Next"
287 printlog "insert the user"
288 UserName.setText sUser
289 PasswordRequired.Check
292 printlog "click Next"
296 printlog "click finish"
299 Kontext "SpeichernDlg"
300 Dateiname.setText ConvertPath(sFileName)
305 if MessageBox.exists then
311 ' register the database
312 if ( IsMissing(sRegister) ) then
313 printlog "don't register datasource"
315 printlog "register datasource with name " + sRegister
316 call fRegisterDatabaseFile(ConvertPath(sFilename),sRegister)
320 printlog "*** Succeed *** Data source was created"
322 fCreateAdabasDatasource = bOK
325 call fCloseDatabase(true)
329 warnlog "*** Failed *** Data source was not created"
334 '-------------------------------------------------------------------------
335 function fCreateLocalAdabasDatasource(sFileName,sDatabaseName,sSuperUser,sSuperPassword, optional sRegister) as boolean
336 '/// create a new adabas database file with the given filename
337 '///+ and the given URL
338 '/// <u>parameter:</u>
339 '/// <b>sFielName:</b> the file name for the database file
340 '/// <b>sURL:</b> the URL for the adabas database
341 '/// <b>sUser:</b> the user for connect
342 '/// <b>sPassword:</b> the password for connect
343 '/// <b><i>optional</i> sRegister:</b> the name under which the database is registered
348 if ( app.Dir( ConvertPath(sFileName) ) ) <> "" then
349 app.kill(ConvertPath(sFileName))
354 '/// --- Create new Adabas data source ---
355 printlog "--- Create new adabas data source ---"
356 Kontext "DocumentWriter"
357 if (DocumentWriter.exists(1)) then
358 DocumentWriter.UseMenu
360 Kontext "DocumentBackground"
361 DocumentBackground.UseMenu
369 Kontext "DatabaseWizard"
370 ConnectToDatabase.Check
372 DatabaseType.select ( hGetDatabaseDisplayName( "sdbc:adabas:*" ) )
378 Kontext "DatabaseWizard"
382 Kontext "DataSourceSelection"
386 Kontext "CreateNewAdabasDatabase"
387 DatabaseName.setText sDatabaseName
388 Administrator.setText sSuperUser
389 AdminPasswordBtn.Click
393 Kontext "PasswordDLG"
394 Password.setText sSuperPassword
395 PasswordConfirm.setText sSuperPassword
398 Kontext "CreateNewAdabasDatabase"
399 CreateNewAdabasDatabase.OK
402 Kontext "DataSourceSelection"
403 DataSourceSelection.OK
405 Kontext "DatabaseWizard"
407 printlog "click Next"
411 printlog "click Next"
415 printlog "click finish"
418 Kontext "SpeichernDlg"
419 Dateiname.setText ConvertPath(sFileName)
424 ' register the database
425 if ( IsMissing(sRegister) ) then
426 printlog "don't register datasource"
428 printlog "register datasource with name " + sRegister
429 call fRegisterDatabaseFile(ConvertPath(sFilename),sRegister)
433 printlog "*** Succeed *** Data source was created"
437 warnlog "*** Failed *** Data source was not created"
441 fCreateLocalAdabasDatasource = bOK
444 call fCloseDatabase(true)
447 '-------------------------------------------------------------------------
448 function fCreateHSQLDatasource(sFileName, optional sRegister) as boolean
449 '/// create a new hsql database file with the given filename
450 '/// <u>parameter:</u>
451 '/// <b>sFielName:</b> the file name for the database file
452 '/// <b><i>optional</i> sRegister:</b> the name under which the database is registered
457 if ( app.Dir( ConvertPath(sFileName) ) ) <> "" then
458 app.kill(ConvertPath(sFileName))
463 Kontext "DocumentWriter"
464 if (DocumentWriter.exists(1)) then
465 DocumentWriter.UseMenu
467 Kontext "DocumentBackground"
468 DocumentBackground.UseMenu
476 Kontext "DatabaseWizard"
477 CreateNewDatabase.Check
484 Kontext "SpeichernDlg"
485 Dateiname.setText ConvertPath(sFileName)
490 if MessageBox.exists then
497 if ( IsMissing(sRegister) ) then
498 printlog "don't register datasource"
500 printlog "register datasource with name " + sRegister
501 call fRegisterDatabaseFile(ConvertPath(sFilename),sRegister)
504 call fCloseDatabase(true)
512 printlog "--- End of function - *** Succeed ***"
514 warnlog "--- End of function - *** Failed *** Data source was not created"
517 fCreateHSQLDatasource = bOK
522 '-------------------------------------------------------------------------
523 function fCreateJDBCDatasource(sFileName,sDriverClass,sURL,sClassPath,sUserName, optional sRegister) as boolean
526 'ExitRestartTheOffice ' because the change the classpath wich is only used after a restart
527 'Printlog "restart the office to make the classpath work"
529 '/// create a new JDBC database file with the given filename
530 '///+ and the given URL
531 '/// <u>parameter:</u>
532 '/// <b>sFileName:</b> the file name for the database file
533 '/// <b>sDatabaseName:</b> the name of the mysql database
534 '/// <b>sHost:</b> the host where the mysql database is running
535 '/// <b>sPort:</b> the port where the mysql database is running
536 '/// <b>sUser:</b> the user for the connection
537 '/// <b><i>optional</i> sRegister:</b> the name under which the database is be registered
541 call fSetJDBCDriverFiles(sClassPath)
544 if ( app.Dir( ConvertPath(sFileName) ) ) <> "" then
545 app.kill(ConvertPath(sFileName))
548 FileOpen "FileName", "private:factory/sdatabase?Interactive" , "FrameName", "_blank" , "SynchronMode" ,True
550 Kontext "SpeichernDlg"
551 Dateiname.setText ConvertPath(sFileName)
556 if MessageBox.exists then
563 DatabaseType.Select "JDBC"
566 Kontext "ConnectionType"
569 Kontext "TabConnection"
572 printlog "add the URL"
573 ConnectURL.setText "jdbc:" + sURL
575 '/// add the user name
576 printlog "add the user name"
577 UserName.setText sUserName
579 '/// check the password required checkbox
580 printlog "check the password required checkbox"
581 PasswordRequired.Check
583 JDBCDriverClass.setText sDriverClass
586 Kontext "ConnectionType"
590 if ( IsMissing(sRegister) ) then
591 printlog "don't register datasource"
593 printlog "register datasource with name " + sRegister
594 call fRegisterDatabaseFile(ConvertPath(sFilename),sRegister)
599 printlog "--- End of function - *** Succeed ***"
601 warnlog "--- End of function - *** Failed *** Data source was not created"
604 fCreateJDBCDatasource = bOK
608 call fCloseDatabase(true)
611 '-------------------------------------------------------------------------
612 function fCreateODBCDatasource(sDSName,sUser,sPassword) as boolean
614 qaerrorlog "not implemented yet"
615 fCreateODBCDatasource = false
618 '-------------------------------------------------------------------------
619 function fCreateDbaseDatasource(sFileName,sURL, optional sRegister) as boolean
620 '/// create a new dbase database file with the given filename
621 '///+ and the given URL as dbase path
622 '/// <u>parameter:</u>
623 '/// <b>sFielName:</b> the file name for the database file
624 '/// <b>sURL:</b> the dbase path for the database
625 '/// <b><i>optional</i> bRegister:</b> if true the register the database with the name tt_dBase
630 if ( app.Dir( ConvertPath(sFileName) ) ) <> "" then
631 app.kill(ConvertPath(sFileName))
634 Kontext "DocumentWriter"
635 if (DocumentWriter.exists(1)) then
636 DocumentWriter.UseMenu
638 Kontext "DocumentBackground"
639 DocumentBackground.UseMenu
647 Kontext "DatabaseWizard"
648 ConnectToDatabase.Check
650 DatabaseType.select ( hGetDatabaseDisplayName( "sdbc:dbase:*" ) )
654 dBasePath.setText "sdbc:dbase:" + ConvertPath(sURL)
660 Kontext "SpeichernDlg"
661 Dateiname.setText ConvertPath(sFileName)
666 if ( IsMissing(sRegister) ) then
667 printlog "don't register datasource"
669 printlog "register datasource with name " + sRegister
670 call fRegisterDatabaseFile(sFileName,sRegister)
675 ' printlog "--- End of function - *** Succeed ***"'
677 ' warnlog "--- End of function - *** Failed *** Data source was not created"
680 fCreatedBaseDatasource = bOK
684 call fClosedatabase(true)
687 '-------------------------------------------------------------------------
688 function fCreateADODatasource(sFileName,sURL,optional sRegister) as boolean
689 '/// create a new ADO database file with the given filename
690 '///+ and the given URL as dbase path
691 '/// <u>parameter:</u>
692 '/// <b>sFielName:</b> the file name for the database file
693 '/// <b>sURL:</b> the ADO url
694 '/// <b><i>optional</i> sRegister:</b> if set, the database is registed under the given name
699 if ( app.Dir( ConvertPath(sFileName) ) ) <> "" then
700 app.kill(ConvertPath(sFileName))
703 Kontext "DocumentWriter"
704 if (DocumentWriter.exists(1)) then
705 DocumentWriter.UseMenu
707 Kontext "DocumentBackground"
708 DocumentBackground.UseMenu
715 Kontext "DatabaseWizard"
716 ConnectToDatabase.Check
718 DatabaseType.select ( hGetDatabaseDisplayName( "sdbc:ado:*" ) )
723 printlog "add the URL " + sURL
724 AdoURL.setText "sdbc:ado:" + sURL
729 Kontext "SpeichernDlg"
730 Dateiname.setText ConvertPath(sFileName)
735 if ( IsMissing(sRegister) ) then
736 printlog "don't register datasource"
738 printlog "register datasource with name " + sRegister
739 call fRegisterDatabaseFile(sFileName,sRegister)
744 printlog "--- End of function - *** Succeed ***"
746 warnlog "--- End of function - *** Failed *** Data source was not created"
749 fCreateADODatasource = bOK
753 call fClosedatabase(true)
756 '-------------------------------------------------------------------------
757 function fCreateTextDatasource(sFileName,sURL, optional sRegister) as boolean
758 '/// create a new text database file with the given filename
759 '///+ and the given URL as dbase path
760 '/// <u>parameter:</u>
761 '/// <b>sFielName:</b> the file name for the database file
762 '/// <b>sURL:</b> the Text url
763 '/// <b><i>optional</i> sRegister:</b> if set, the database is registed under the given name
767 '/// --- Create new Text data source ---
768 printlog "--- Create new " + sFileName + " data source ---"
769 printlog "--- with the URL " + sURL + " ---"
771 Kontext "DocumentWriter"
772 if (DocumentWriter.exists(1)) then
773 DocumentWriter.UseMenu
775 Kontext "DocumentBackground"
776 DocumentBackground.UseMenu
784 Kontext "DatabaseWizard"
785 ConnectToDatabase.Check
787 DatabaseType.select ( hGetDatabaseDisplayName( "sdbc:flat:*" ) )
791 TextPath.setText "sdbc:flat:" + ConvertPath(sURL)
796 Kontext "SpeichernDlg"
797 Dateiname.setText ConvertPath(sFileName)
802 if MessageBox.exists then
808 if ( IsMissing(sRegister) ) then
809 printlog "don't register datasource"
811 printlog "register datasource with name " + sRegister
812 call fRegisterDatabaseFile(sFileName,sRegister)
818 printlog "--- End of function - *** Succeed ***"
820 warnlog "--- End of function - *** Failed *** Data source was not created"
823 fCreateTextDatasource = bOK
827 call fClosedatabase(true)
830 '-------------------------------------------------------------------------
831 function fCreateSpreadsheetDatasource(sFileName,sURL, optional sRegister) as boolean
832 '/// create a new spreadsheet database file with the given filename
833 '///+ and the given URL as dbase path
834 '/// <u>parameter:</u>
835 '/// <b>sFielName:</b> the file name for the database file
836 '/// <b>sURL:</b> the spreadsheet file name
837 '/// <b><i>optional</i> bRegister:</b> if true the register the database with the given name
842 if ( app.Dir( ConvertPath(sFileName) ) ) <> "" then
843 app.kill(ConvertPath(sFileName))
846 Kontext "DocumentWriter"
847 if (DocumentWriter.exists(1)) then
848 DocumentWriter.UseMenu
850 Kontext "DocumentBackground"
851 DocumentBackground.UseMenu
859 Kontext "DatabaseWizard"
860 ConnectToDatabase.Check
862 DatabaseType.Select (hGetDatabaseDisplayName( "sdbc:calc:*" ))
867 printlog "add the URL"
868 SpreadsheetPath.setText "sdbc:calc:" + ConvertPath(sURL)
871 printlog "click finish"
874 Kontext "SpeichernDlg"
875 Dateiname.setText ConvertPath(sFileName)
880 if MessageBox.exists then
886 if ( IsMissing(sRegister) ) then
887 printlog "don't register datasource"
889 printlog "register datasource with name " + sRegister
890 call fRegisterDatabaseFile(sFileName,sRegister)
895 printlog "--- End of function - *** Succeed ***"
897 warnlog "--- End of function - *** Failed *** Data source was not created"
900 fCreateSpreadsheetDatasource = bOK
904 call fClosedatabase(true)
907 '-------------------------------------------------------------------------
908 function fCreateLDAPAddressbookDatasource(sFileName,sHostName,sBaseDN,sPortNr,optional sRegister) as boolean
909 '/// create a new LDAP Addressbook database with the given filename
910 '/// <u>parameter:</u>
911 '/// <b>sFileName:</b> the file name for the database file
912 '/// <b><i>optional</i> sRegister:</b> if true then register the database
918 if ( app.Dir( ConvertPath(sFileName) ) ) <> "" then
919 app.kill(ConvertPath(sFileName))
923 Kontext "DocumentWriter"
924 if (DocumentWriter.exists(1)) then
925 DocumentWriter.UseMenu
927 Kontext "DocumentBackground"
928 DocumentBackground.UseMenu
936 Kontext "DatabaseWizard"
937 ConnectToDatabase.Check
939 DatabaseType.select ( hGetDatabaseDisplayName( "sdbc:address:ldap:*" ) )
943 LDAPHostName.setText sHostName
945 BaseDN.setText(sBaseDN)
950 Kontext "SpeichernDlg"
951 Dateiname.setText ConvertPath(sFileName)
956 if MessageBox.exists then
963 if ( IsMissing(sRegister) ) then
964 printlog "don't register datasource"
966 printlog "register datasource with name " + sRegister
967 call fRegisterDatabaseFile(sFileName,sRegister)
969 printlog "*** Succeed *** Data source was created"
972 ' warnlog "*** Failed *** Data source was not created"
976 fCreateLDAPAddressbookDatasource = bOK
980 call fClosedatabase(true)
983 '-------------------------------------------------------------------------
984 function fCreateEvolutionAddressbookDatasource(sFileName, optional sRegister) as boolean
985 '/// create a new Evolution Addressbook database with the given filename
986 '/// <u>parameter:</u>
987 '/// <b>sFielName:</b> the file name for the database file
988 '/// <b><i>optional</i> sRegister:</b> if true then register the database
994 if ( app.Dir( ConvertPath(sFileName) ) ) <> "" then
995 app.kill(ConvertPath(sFileName))
998 Kontext "DocumentWriter"
999 if (DocumentWriter.exists(1)) then
1000 DocumentWriter.UseMenu
1002 Kontext "DocumentBackground"
1003 DocumentBackground.UseMenu
1011 Kontext "DatabaseWizard"
1012 ConnectToDatabase.Check
1014 DatabaseType.select ( hGetDatabaseDisplayName( "sdbc:address:evolution:ldap" ) )
1019 printlog "click finish"
1022 Kontext "SpeichernDlg"
1023 Dateiname.setText ConvertPath(sFileName)
1027 Kontext "MessageBox"
1028 if MessageBox.exists then
1034 if ( IsMissing(sRegister) ) then
1035 printlog "don't register datasource"
1037 printlog "register datasource with name " + sRegister
1038 call fRegisterDatabaseFile(sFileName,sRegister)
1041 call fClosedatabase(true)
1043 printlog "*** Succeed *** Data source was created"
1046 warnlog "*** Failed *** Data source was not created"
1050 fCreateEvolutionAddressbookDatasource = bOK
1055 '-------------------------------------------------------------------------
1056 function fCreateKDEAddressbookDatasource(sFileName , optional sRegister) as boolean
1057 '/// create a new KDE Addressbook database with the given filename
1058 '/// <u>parameter:</u>
1059 '/// <b>sFileName:</b> the file name for the database file
1060 '/// <b><i>optional</i> sRegister:</b> if true then register the database
1066 if ( app.Dir( ConvertPath(sFileName) ) ) <> "" then
1067 app.kill(ConvertPath(sFileName))
1070 Kontext "DocumentWriter"
1071 if (DocumentWriter.exists(1)) then
1072 DocumentWriter.UseMenu
1074 Kontext "DocumentBackground"
1075 DocumentBackground.UseMenu
1083 Kontext "DatabaseWizard"
1084 ConnectToDatabase.Check
1086 DatabaseType.select ( hGetDatabaseDisplayName( "sdbc:address:kab" ) )
1091 printlog "click finish"
1094 Kontext "SpeichernDlg"
1095 Dateiname.setText ConvertPath(sFileName)
1099 Kontext "MessageBox"
1100 if MessageBox.exists then
1106 if ( IsMissing(sRegister) ) then
1107 printlog "don't register datasource"
1109 printlog "register datasource with name " + sRegister
1110 call fRegisterDatabaseFile(sFileName,sRegister)
1113 call fClosedatabase(true)
1115 printlog "*** Succeed *** Data source was created"
1118 warnlog "*** Failed *** Data source was not created"
1122 fCreateKDEAddressbookDatasource = bOK
1127 '-------------------------------------------------------------------------
1128 function fCreateWindowsAddressbookDatasource(sFileName , optional sRegister) as boolean
1129 '/// create a new Windows Addressbook database with the given filename
1130 '/// <u>parameter:</u>
1131 '/// <b>sFileName:</b> the file name for the database file
1132 '/// <b><i>optional</i> sRegister:</b> if true then register the database
1138 if ( app.Dir( ConvertPath(sFileName) ) ) <> "" then
1139 app.kill(ConvertPath(sFileName))
1142 Kontext "DocumentWriter"
1143 if (DocumentWriter.exists(1)) then
1144 DocumentWriter.UseMenu
1146 Kontext "DocumentBackground"
1147 DocumentBackground.UseMenu
1155 Kontext "DatabaseWizard"
1156 ConnectToDatabase.Check
1158 DatabaseType.select ( hGetDatabaseDisplayName( "sdbc:address:outlookexp" ) )
1163 printlog "click finish"
1166 Kontext "SpeichernDlg"
1167 Dateiname.setText ConvertPath(sFileName)
1171 Kontext "MessageBox"
1172 if MessageBox.exists then
1178 if ( IsMissing(sRegister) ) then
1179 printlog "don't register datasource"
1181 printlog "register datasource with name " + sRegister
1182 call fRegisterDatabaseFile(sFileName,sRegister)
1185 call fClosedatabase(true)
1187 printlog "*** Succeed *** Data source was created"
1190 warnlog "*** Failed *** Data source was not created"
1194 fCreateWindowsAddressbookDatasource = bOK
1199 '-------------------------------------------------------------------------
1200 function fCreateOutlookAddressbookDatasource(sFileName, optional sRegister) as boolean
1201 '/// create a new Outlook Addressbook database with the given filename
1202 '/// <u>parameter:</u>
1203 '/// <b>sFileName:</b> the file name for the database file
1204 '/// <b><i>optional</i> sRegister:</b> if true then register the database
1210 if ( app.Dir( ConvertPath(sFileName) ) ) <> "" then
1211 app.kill(ConvertPath(sFileName))
1214 Kontext "DocumentWriter"
1215 if (DocumentWriter.exists(1)) then
1216 DocumentWriter.UseMenu
1218 Kontext "DocumentBackground"
1219 DocumentBackground.UseMenu
1227 Kontext "DatabaseWizard"
1228 ConnectToDatabase.Check
1230 DatabaseType.select ( hGetDatabaseDisplayName( "sdbc:address:outlook" ) )
1235 printlog "click finish"
1238 Kontext "SpeichernDlg"
1239 Dateiname.setText ConvertPath(sFileName)
1243 Kontext "MessageBox"
1244 if MessageBox.exists then
1250 if ( IsMissing(sRegister) ) then
1251 printlog "don't register datasource"
1253 printlog "register datasource with name " + sRegister
1254 call fRegisterDatabaseFile(sFileName,sRegister)
1257 call fClosedatabase(true)
1259 printlog "*** Succeed *** Data source was created"
1262 warnlog "*** Failed *** Data source was not created"
1266 fCreateOutlookAddressbookDatasource = bOK
1271 '-------------------------------------------------------------------------
1272 function fCreateMozillaAddressbookDatasource(sFileName, optional sRegister) as boolean
1273 '/// create a new mozilla addressbook database file with the given filename
1274 '/// <u>parameter:</u>
1275 '/// <b>sFielName:</b> the file name for the database file
1276 '/// <b><i>optional</i> sRegister:</b> the name under which the database is registered
1282 if ( app.Dir( ConvertPath(sFileName) ) ) <> "" then
1283 app.kill(ConvertPath(sFileName))
1286 Kontext "DocumentWriter"
1287 if (DocumentWriter.exists(1)) then
1288 DocumentWriter.UseMenu
1290 Kontext "DocumentBackground"
1291 DocumentBackground.UseMenu
1299 Kontext "DatabaseWizard"
1300 ConnectToDatabase.Check
1302 DatabaseType.select ( hGetDatabaseDisplayName( "sdbc:address:mozilla:" ) )
1307 printlog "click finish"
1310 Kontext "SpeichernDlg"
1311 Dateiname.setText ConvertPath(sFileName)
1315 Kontext "MessageBox"
1316 if MessageBox.exists then
1322 if ( IsMissing(sRegister) ) then
1323 printlog "don't register datasource"
1325 printlog "register datasource with name " + sRegister
1326 call fRegisterDatabaseFile(sFileName,sRegister)
1328 printlog "*** Succeed *** Data source was created"
1331 call fClosedatabase(true)
1334 qaerrorlog "*** Failed *** Data source was not created"
1338 fCreateMozillaAddressbookDatasource = bOK
1343 '--------------------------------------------------------------------
1344 function fRegisterDatabaseFile( sFileName, sName)
1345 '/// register a database
1346 '/// <u>parameter:</u>
1347 '/// <b>sFielName:</b> the file name for the database file
1348 '/// <b>sName:</b> The name under which the database is registered
1354 call hToolsOptions ( "Datasources", "Databases" )
1356 '/// remove registration if exists
1358 Kontext "TabRegisteredDatabase"
1359 for i = 1 to RegisteredDatabases.GetItemCount
1360 RegisteredDatabases.select i
1361 if RegisteredDatabases.getSeltext() = sName then
1371 Kontext "TabRegisteredDatabase"
1374 Kontext "CreateDatabaseLink"
1375 DatabaseFile.setText(sFileName)
1376 RegisteredName.setText(sName)
1377 CreateDatabaseLink.OK
1380 Kontext "OptionenDlg"
1384 '--------------------------------------------------------------------
1385 function fDeRegisterDatabaseFile( sName)
1386 '/// deregister a database
1387 '/// <u>parameter:</u>
1388 '/// <b>sName:</b> The registered name which should be deregistered
1393 call hToolsOptions ( "Datasources", "Databases" )
1395 '/// remove registration for the database
1396 printlog "remove registration for the database " + sName
1398 Kontext "TabRegisteredDatabase"
1399 for i = 1 to RegisteredDatabases.GetItemCount
1400 RegisteredDatabases.select i
1401 if RegisteredDatabases.getSeltext() = sName then
1414 Kontext "OptionenDlg"
1418 '-------------------------------------------------------------------------
1419 function fSetJDBCDriverFiles(sClassPath) as boolean
1420 '/// set the java classpath
1421 '/// <u>parameter:</u>
1422 '/// <b>sClassPath:</b> The Classpath
1424 Dim x_DriverInstall as boolean
1425 x_DriverInstall = FALSE
1428 printlog "insert classpath: " + sClassPath
1430 call hToolsOptions ( "StarOffice", "JAVA" )
1435 Kontext "JavaClassPath"
1438 Kontext "GeneralFileDialog"
1439 Dateiname.setText ConvertPath(sClassPath)
1442 '/// if the class file allready exists a messages box pops up
1443 Kontext "MessageBox"
1444 if ( MessageBox.exists(3) ) then
1448 Kontext "JavaClassPath"
1451 Kontext "MessageBox"
1452 if ( MessageBox.exists(3) ) then
1456 Kontext "OptionenDlg"
1462 '-------------------------------------------------------------------------
1463 private const VERBOSE = false
1465 function hGetInstalledDatabaseDrivers( dbDriverList() as string ) as integer
1467 ' This function returns the number of currently installed database drivers.
1468 ' Additionally it fills a given list (which should be large enough to hold
1469 ' the names of all installed drivers) with the names and makes the list
1470 ' compatible to the listfunctions (which places the list size in element 0)
1471 ' The list is platform dependent and might be locale dependent
1472 ' Note that some drivers (like e.g. HSQL Database Engine) do *not* show up
1473 ' in the Database Wizards listbox!
1475 dim oUnoOfficeConnection as object
1476 dim oUnoConfigurationAccess as object
1477 dim aPropertyValue(1) as new com.sun.star.beans.PropertyValue
1478 dim xViewRoot as object
1479 dim aElements() as string
1480 dim iCurrentDriver as integer
1481 dim iDriverCount as integer
1483 const CFN = "global::tools::includes::optional::t_database.inc::hGetInstalledDatabaseDrivers(): "
1485 ' Path to the node, searches all files below "Drivers" for "Installed"
1486 aPropertyValue( 0 ).Name = "nodepath"
1487 aPropertyValue( 0 ).Value = "org.openoffice.Office.DataAccess.Drivers/Installed"
1489 ' Connect to remote UNO
1490 oUnoOfficeConnection = hGetUnoService( TRUE )
1492 if ( isNull( oUnoOfficeConnection )) then
1493 warnlog( CFN & "Failed to establish UNO connection, hGetUnoService failed" )
1494 hGetInstalledDatabaseDrivers() = 0
1496 ' Get a configuration provider
1497 oUnoConfigurationAccess = oUnoOfficeConnection.createInstance( "com.sun.star.configuration.ConfigurationProvider" )
1500 xViewRoot = oUnoConfigurationAccess.createInstanceWithArguments( "com.sun.star.configuration.ConfigurationAccess", aPropertyValue() )
1501 aElements() = xViewRoot.getElementNames()
1503 iDriverCount = ubound( aElements() )
1504 dbDriverList( 0 ) = iDriverCount
1505 for iCurrentDriver = 1 to iDriverCount
1506 dbDriverList( iCurrentDriver ) = xViewRoot.getByName( aElements( iCurrentDriver ) ).getByName( "DriverTypeDisplayName" )
1512 printlog( CFN & "Returning " & iDriverCount & " drivers" )
1514 hGetInstalledDatabaseDrivers() = iDriverCount
1518 '*******************************************************************************
1520 function hGetDatabaseDisplayName( dbDriverURL as string ) as string
1522 ' The xcu files (based on dev300m47) hold following driver definitions
1523 ' which are used as parameter to this function. You get a plain text
1524 ' localized driver name as returnvalue which can be used directly to select
1525 ' a driver in the Database Wizard.
1527 ' adabas.xcu: "sdbc:adabas:*"
1528 ' calc.xcu: "sdbc:calc:*"
1529 ' dbase.xcu: "sdbc:dbase:*"
1530 ' evoab.xcu: "sdbc:address:evolution:ldap"
1531 ' evoab.xcu: "sdbc:address:evolution:groupwise"
1532 ' flat.xcu: "sdbc:flat:*"
1533 ' ado.xcu: "sdbc:ado:*"
1534 ' hsqldb.xcu: "sdbc:embedded:hsqldb"
1535 ' kab.xcu: "sdbc:address:kab"
1536 ' mozab.xcu: "sdbc:address:outlook"
1537 ' mozab.xcu: "sdbc:address:outlookexp"
1538 ' mozab.xcu: "sdbc:address:mozilla:"
1539 ' mozab.xcu: "sdbc:address:thunderbird:"
1540 ' mozab.xcu: "sdbc:address:ldap:*"
1541 ' mysql.xcu: "sdbc:mysql:jdbc:*"
1542 ' mysql.xcu: "sdbc:mysql:odbc:*"
1543 ' odbc.xcu: "sdbc:odbc:*"
1544 ' jdbc.xcu: "jdbc:*"
1545 ' jdbc.xcu: "jdbc:oracle:thin:*"
1546 ' mysql.xcu: "sdbc:mysql:jdbc:*"
1549 ' Note that some drivers (like e.g. HSQL Database Engine) do *not* show up
1550 ' in the Database Wizards listbox!
1553 dim oUnoOfficeConnection as object
1554 dim oUnoConfigurationAccess as object
1555 dim aPropertyValue(1) as new com.sun.star.beans.PropertyValue
1556 dim oConfig as object
1557 dim oDriver as object
1558 dim sDatabaseName as string
1560 const CFN = "global::tools::includes::optional::t_database.inc::hGetDatabaseDisplayName(): "
1562 ' Path to the node, searches all files below "Drivers" for "Installed"
1563 aPropertyValue( 0 ).Name = "nodepath"
1564 aPropertyValue( 0 ).Value = "org.openoffice.Office.DataAccess.Drivers/Installed/"
1566 ' Connect to remote UNO
1567 oUnoOfficeConnection = hGetUnoService( TRUE )
1569 if ( isNull( oUnoOfficeConnection )) then
1570 warnlog( CFN & "Failed to establish UNO connection, hGetUnoService failed" )
1573 ' Get a configuration provider
1574 oUnoConfigurationAccess = oUnoOfficeConnection.createInstance( "com.sun.star.configuration.ConfigurationProvider" )
1577 oConfig = oUnoConfigurationAccess.createInstanceWithArguments( "com.sun.star.configuration.ConfigurationAccess", aPropertyValue() )
1579 oDriver = oConfig.getByName( dbDriverURL )
1580 sDatabaseName = oDriver.getByName( "DriverTypeDisplayName" )
1582 warnlog( CFN & "Invalid driver or driver unsupported on this platform" )
1589 printlog( CFN & "Database display string: " & sDatabaseName )
1591 hGetDataBaseDisplayName() = sDatabaseName