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 : Library with function for creating all possible databases
32 '***************************************************************************************
34 ' #1 fCreateMySQL_ODBC_Datasource
35 ' #1 fCreateMySQL_JDBC_Datasource
36 ' #1 fCreateAdabasDatasource
37 ' #1 fCreateLocalAdabasDatasource
38 ' #1 fCreateJDBCDatasource
39 ' #1 fCreateODBCDatasource
40 ' #1 fCreateDbaseDatasource
41 ' #1 fCreateADODatasource
42 ' #1 fCreateTextDatasource
43 ' #1 fCreateSpreadsheetDatasource
44 ' #1 fCreateLDAPAddressbookDatasource
45 ' #1 fCreateEvolutionAddressbookDatasource
46 ' #1 fCreateWindowsAddressbookDatasource
47 ' #1 fCreateOutlookAddressbookDatasource
48 ' #1 fCreateMozillaAddressbookDatasource
49 ' #1 fRegisterDatabaseFile
50 ' #1 fDeRegisterDatabaseFile
51 ' #1 fSetJDBCDriverFiles
52 ' #1 getIdForDatabaseType
54 '\***********************************************************************************
56 private const VERBOSE = true
58 function fCreateMySQL_ODBC_Datasource(sFileName, sOdbcDSN, sUser,optional sRegister) as boolean
59 '/// create a new MySQL database via ODBC file with the given filename
60 '///+ and the given URL
61 '/// <u>parameter:</u>
62 '/// <b>sFileName:</b> the file name for the database file
63 '/// <b>sOdbcDSN:</b> the name of the odbc datasource
64 '/// <b>sUser:</b> the user for the connection
65 '/// <b>sPassword:</b> the password for the connection
66 '/// <b><i>optional</i> sRegister:</b> the name under which the database is be registered
71 if ( app.Dir( ConvertPath(sFileName) ) ) <> "" then
72 app.kill(ConvertPath(sFileName))
75 Kontext "DocumentWriter"
76 if (DocumentWriter.exists(1)) then
77 DocumentWriter.UseMenu
79 Kontext "DocumentBackground"
80 DocumentBackground.UseMenu
88 Kontext "DatabaseWizard"
89 ConnectToDatabase.Check
91 DatabaseType.select( hGetDatabaseDisplayName( "sdbc:mysql:odbc:*" ) )
98 Kontext "DatabaseWizard"
101 printlog "add the URL"
102 MySQLODBCDSName.setText "sdbc:mysql:odbc:" + sOdbcDSN
104 Kontext "DatabaseWizard"
107 Kontext "DatabaseWizard"
108 '/// add the user name
109 printlog "add the user name"
110 UserName.setText sUser
112 '/// check the password required checkbox
113 printlog "check the password required checkbox"
114 PasswordRequired.Check
116 Kontext "DatabaseWizard"
119 Kontext "DatabaseWizard"
122 Kontext "SpeichernDlg"
123 Dateiname.setText ConvertPath(sFileName)
128 if ( IsMissing(sRegister) ) then
129 printlog "don't register datasource"
131 printlog "register datasource with name " + sRegister
132 call fRegisterDatabaseFile(ConvertPath(sFilename),sRegister)
137 printlog "--- End of function - *** Succeed ***"
139 warnlog "--- End of function - *** Failed *** Data source was not created"
142 call fCloseDatabase(true)
144 fCreateMySQL_ODBC_Datasource = bOK
147 '-------------------------------------------------------------------------
148 function fCreateMySQL_JDBC_Datasource(sFileName,sDatabaseName,sHost,sPort,sUser,optional sRegister) as boolean
149 '/// create a new MySQL database via JDBC file with the given filename
150 '///+ and the given URL
151 '/// <u>parameter:</u>
152 '/// <b>sFielName:</b> the file name for the database file
153 '/// <b>sDatabaseName:</b> the name of the mysql database
154 '/// <b>sHost:</b> the host where the mysql database is running
155 '/// <b>sPort:</b> the port where the mysql database is running
156 '/// <b>sUser:</b> the user for the connection
157 '/// <b><i>optional</i> sRegister:</b> the name under which the database is be registered
164 if ( app.Dir( ConvertPath(sFileName) ) ) <> "" then
165 app.kill(ConvertPath(sFileName))
168 Kontext "DocumentWriter"
169 if (DocumentWriter.exists(1)) then
170 DocumentWriter.UseMenu
172 Kontext "DocumentBackground"
173 DocumentBackground.UseMenu
181 Kontext "DatabaseWizard"
182 ConnectToDatabase.Check
184 sEntry = hGetDatabaseDisplayName( "sdbc:mysql:jdbc:*" )
185 'cut off the (JDBC) string
186 sEntry = Mid( sEntry , 1, len(sEntry) - Instr(sEntry,"(") )
187 printlog "entry = " + sEntry
188 DatabaseType.select( sEntry )
195 MySQLDatabaseName.setText(sDatabaseName)
196 MySQLHostName.setText(sHost)
197 MySQLPort.setText(sPort)
202 '/// add the user name
203 printlog "add the user name"
204 UserName.setText sUser
206 '/// check the password required checkbox
207 printlog "check the password required checkbox"
208 PasswordRequired.Check
213 Kontext "SpeichernDlg"
214 Dateiname.setText ConvertPath(sFileName)
219 if ( IsMissing(sRegister) ) then
220 printlog "don't register datasource"
222 printlog "register datasource with name " + sRegister
223 call fRegisterDatabaseFile(ConvertPath(sFilename),sRegister)
228 printlog "--- End of function - *** Succeed ***"
230 warnlog "--- End of function - *** Failed *** Data source was not created"
233 fCreateMySQL_JDBC_Datasource = bOK
237 call fCloseDatabase(true)
240 '-------------------------------------------------------------------------
241 function fCreateAdabasDatasource(sFileName,sURL,sUser, optional sRegister) as boolean
242 '/// create a new adabas database file with the given filename
243 '///+ and the given URL
244 '/// <u>parameter:</u>
245 '/// <b>sFielName:</b> the file name for the database file
246 '/// <b>sURL:</b> the URL for the adabas database
247 '/// <b>sUser:</b> the user for connect
248 '/// <b><i>optional</i> sRegister:</b> the name under which the database is registered
255 if ( app.Dir( ConvertPath(sFileName) ) ) <> "" then
256 app.kill(ConvertPath(sFileName))
261 Kontext "DocumentWriter"
262 if (DocumentWriter.exists(1)) then
263 DocumentWriter.UseMenu
265 Kontext "DocumentBackground"
266 DocumentBackground.UseMenu
274 Kontext "DatabaseWizard"
275 ConnectToDatabase.Check
277 DatabaseType.select ( hGetDatabaseDisplayName( "sdbc:adabas:*" ) )
281 '/// insert the adabas database name
282 printlog "insert the adabas database name"
283 AdabasDBName.setText("sdbc:adabas:" + sURL)
286 printlog "click Next"
290 printlog "insert the user"
291 UserName.setText sUser
292 PasswordRequired.Check
295 printlog "click Next"
299 printlog "click finish"
302 Kontext "SpeichernDlg"
303 Dateiname.setText ConvertPath(sFileName)
308 if MessageBox.exists then
314 ' register the database
315 if ( IsMissing(sRegister) ) then
316 printlog "don't register datasource"
318 printlog "register datasource with name " + sRegister
319 call fRegisterDatabaseFile(ConvertPath(sFilename),sRegister)
323 printlog "*** Succeed *** Data source was created"
325 fCreateAdabasDatasource = bOK
328 call fCloseDatabase(true)
332 warnlog "*** Failed *** Data source was not created"
337 '-------------------------------------------------------------------------
338 function fCreateLocalAdabasDatasource(sFileName,sDatabaseName,sSuperUser,sSuperPassword, optional sRegister) as boolean
339 '/// create a new adabas database file with the given filename
340 '///+ and the given URL
341 '/// <u>parameter:</u>
342 '/// <b>sFielName:</b> the file name for the database file
343 '/// <b>sURL:</b> the URL for the adabas database
344 '/// <b>sUser:</b> the user for connect
345 '/// <b>sPassword:</b> the password for connect
346 '/// <b><i>optional</i> sRegister:</b> the name under which the database is registered
351 if ( app.Dir( ConvertPath(sFileName) ) ) <> "" then
352 app.kill(ConvertPath(sFileName))
357 '/// --- Create new Adabas data source ---
358 printlog "--- Create new adabas data source ---"
359 Kontext "DocumentWriter"
360 if (DocumentWriter.exists(1)) then
361 DocumentWriter.UseMenu
363 Kontext "DocumentBackground"
364 DocumentBackground.UseMenu
372 Kontext "DatabaseWizard"
373 ConnectToDatabase.Check
375 DatabaseType.select ( hGetDatabaseDisplayName( "sdbc:adabas:*" ) )
381 Kontext "DatabaseWizard"
385 Kontext "DataSourceSelection"
389 Kontext "CreateNewAdabasDatabase"
390 DatabaseName.setText sDatabaseName
391 Administrator.setText sSuperUser
392 AdminPasswordBtn.Click
396 Kontext "PasswordDLG"
397 Password.setText sSuperPassword
398 PasswordConfirm.setText sSuperPassword
401 Kontext "CreateNewAdabasDatabase"
402 CreateNewAdabasDatabase.OK
405 Kontext "DataSourceSelection"
406 DataSourceSelection.OK
408 Kontext "DatabaseWizard"
410 printlog "click Next"
414 printlog "click Next"
418 printlog "click finish"
421 Kontext "SpeichernDlg"
422 Dateiname.setText ConvertPath(sFileName)
427 ' register the database
428 if ( IsMissing(sRegister) ) then
429 printlog "don't register datasource"
431 printlog "register datasource with name " + sRegister
432 call fRegisterDatabaseFile(ConvertPath(sFilename),sRegister)
436 printlog "*** Succeed *** Data source was created"
440 warnlog "*** Failed *** Data source was not created"
444 fCreateLocalAdabasDatasource = bOK
447 call fCloseDatabase(true)
450 '-------------------------------------------------------------------------
451 function fCreateHSQLDatasource(sFileName, optional sRegister) as boolean
452 '/// create a new hsql database file with the given filename
453 '/// <u>parameter:</u>
454 '/// <b>sFielName:</b> the file name for the database file
455 '/// <b><i>optional</i> sRegister:</b> the name under which the database is registered
460 if ( app.Dir( ConvertPath(sFileName) ) ) <> "" then
461 app.kill(ConvertPath(sFileName))
466 Kontext "DocumentWriter"
467 if (DocumentWriter.exists(1)) then
468 DocumentWriter.UseMenu
470 Kontext "DocumentBackground"
471 DocumentBackground.UseMenu
479 Kontext "DatabaseWizard"
480 CreateNewDatabase.Check
487 Kontext "SpeichernDlg"
488 Dateiname.setText ConvertPath(sFileName)
493 if MessageBox.exists then
500 if ( IsMissing(sRegister) ) then
501 printlog "don't register datasource"
503 printlog "register datasource with name " + sRegister
504 call fRegisterDatabaseFile(ConvertPath(sFilename),sRegister)
507 call fCloseDatabase(true)
515 printlog "--- End of function - *** Succeed ***"
517 warnlog "--- End of function - *** Failed *** Data source was not created"
520 fCreateHSQLDatasource = bOK
525 '-------------------------------------------------------------------------
526 function fCreateJDBCDatasource(sFileName,sDriverClass,sURL,sClassPath,sUserName, optional sRegister) as boolean
529 'ExitRestartTheOffice ' because the change the classpath wich is only used after a restart
530 'Printlog "restart the office to make the classpath work"
532 '/// create a new JDBC database file with the given filename
533 '///+ and the given URL
534 '/// <u>parameter:</u>
535 '/// <b>sFileName:</b> the file name for the database file
536 '/// <b>sDatabaseName:</b> the name of the mysql database
537 '/// <b>sHost:</b> the host where the mysql database is running
538 '/// <b>sPort:</b> the port where the mysql database is running
539 '/// <b>sUser:</b> the user for the connection
540 '/// <b><i>optional</i> sRegister:</b> the name under which the database is be registered
544 call fSetJDBCDriverFiles(sClassPath)
547 if ( app.Dir( ConvertPath(sFileName) ) ) <> "" then
548 app.kill(ConvertPath(sFileName))
551 FileOpen "FileName", "private:factory/sdatabase?Interactive" , "FrameName", "_blank" , "SynchronMode" ,True
553 Kontext "SpeichernDlg"
554 Dateiname.setText ConvertPath(sFileName)
559 if MessageBox.exists then
566 DatabaseType.Select "JDBC"
569 Kontext "ConnectionType"
572 Kontext "TabConnection"
575 printlog "add the URL"
576 ConnectURL.setText "jdbc:" + sURL
578 '/// add the user name
579 printlog "add the user name"
580 UserName.setText sUserName
582 '/// check the password required checkbox
583 printlog "check the password required checkbox"
584 PasswordRequired.Check
586 JDBCDriverClass.setText sDriverClass
589 Kontext "ConnectionType"
593 if ( IsMissing(sRegister) ) then
594 printlog "don't register datasource"
596 printlog "register datasource with name " + sRegister
597 call fRegisterDatabaseFile(ConvertPath(sFilename),sRegister)
602 printlog "--- End of function - *** Succeed ***"
604 warnlog "--- End of function - *** Failed *** Data source was not created"
607 fCreateJDBCDatasource = bOK
611 call fCloseDatabase(true)
614 '-------------------------------------------------------------------------
615 function fCreateODBCDatasource(sDSName,sUser,sPassword) as boolean
617 qaerrorlog "not implemented yet"
618 fCreateODBCDatasource = false
621 '-------------------------------------------------------------------------
622 function fCreateDbaseDatasource(sFileName,sURL, optional sRegister) as boolean
623 '/// create a new dbase database file with the given filename
624 '///+ and the given URL as dbase path
625 '/// <u>parameter:</u>
626 '/// <b>sFielName:</b> the file name for the database file
627 '/// <b>sURL:</b> the dbase path for the database
628 '/// <b><i>optional</i> bRegister:</b> if true the register the database with the name tt_dBase
633 if ( app.Dir( ConvertPath(sFileName) ) ) <> "" then
634 app.kill(ConvertPath(sFileName))
637 Kontext "DocumentWriter"
638 if (DocumentWriter.exists(1)) then
639 DocumentWriter.UseMenu
641 Kontext "DocumentBackground"
642 DocumentBackground.UseMenu
650 Kontext "DatabaseWizard"
651 ConnectToDatabase.Check
653 DatabaseType.select ( hGetDatabaseDisplayName( "sdbc:dbase:*" ) )
657 dBasePath.setText "sdbc:dbase:" + ConvertPath(sURL)
663 Kontext "SpeichernDlg"
664 Dateiname.setText ConvertPath(sFileName)
669 if ( IsMissing(sRegister) ) then
670 printlog "don't register datasource"
672 printlog "register datasource with name " + sRegister
673 call fRegisterDatabaseFile(sFileName,sRegister)
678 ' printlog "--- End of function - *** Succeed ***"'
680 ' warnlog "--- End of function - *** Failed *** Data source was not created"
683 fCreatedBaseDatasource = bOK
687 call fClosedatabase(true)
690 '-------------------------------------------------------------------------
691 function fCreateADODatasource(sFileName,sURL,optional sRegister) as boolean
692 '/// create a new ADO database file with the given filename
693 '///+ and the given URL as dbase path
694 '/// <u>parameter:</u>
695 '/// <b>sFielName:</b> the file name for the database file
696 '/// <b>sURL:</b> the ADO url
697 '/// <b><i>optional</i> sRegister:</b> if set, the database is registed under the given name
702 if ( app.Dir( ConvertPath(sFileName) ) ) <> "" then
703 app.kill(ConvertPath(sFileName))
706 Kontext "DocumentWriter"
707 if (DocumentWriter.exists(1)) then
708 DocumentWriter.UseMenu
710 Kontext "DocumentBackground"
711 DocumentBackground.UseMenu
718 Kontext "DatabaseWizard"
719 ConnectToDatabase.Check
721 DatabaseType.select ( hGetDatabaseDisplayName( "sdbc:ado:*" ) )
726 printlog "add the URL " + sURL
727 AdoURL.setText "sdbc:ado:" + sURL
732 Kontext "SpeichernDlg"
733 Dateiname.setText ConvertPath(sFileName)
738 if ( IsMissing(sRegister) ) then
739 printlog "don't register datasource"
741 printlog "register datasource with name " + sRegister
742 call fRegisterDatabaseFile(sFileName,sRegister)
747 printlog "--- End of function - *** Succeed ***"
749 warnlog "--- End of function - *** Failed *** Data source was not created"
752 fCreateADODatasource = bOK
756 call fClosedatabase(true)
759 '-------------------------------------------------------------------------
760 function fCreateTextDatasource(sFileName,sURL, optional sRegister) as boolean
761 '/// create a new text database file with the given filename
762 '///+ and the given URL as dbase path
763 '/// <u>parameter:</u>
764 '/// <b>sFielName:</b> the file name for the database file
765 '/// <b>sURL:</b> the Text url
766 '/// <b><i>optional</i> sRegister:</b> if set, the database is registed under the given name
770 '/// --- Create new Text data source ---
771 printlog "--- Create new " + sFileName + " data source ---"
772 printlog "--- with the URL " + sURL + " ---"
774 Kontext "DocumentWriter"
775 if (DocumentWriter.exists(1)) then
776 DocumentWriter.UseMenu
778 Kontext "DocumentBackground"
779 DocumentBackground.UseMenu
787 Kontext "DatabaseWizard"
788 ConnectToDatabase.Check
790 DatabaseType.select ( hGetDatabaseDisplayName( "sdbc:flat:*" ) )
794 TextPath.setText "sdbc:flat:" + ConvertPath(sURL)
799 Kontext "SpeichernDlg"
800 Dateiname.setText ConvertPath(sFileName)
805 if MessageBox.exists then
811 if ( IsMissing(sRegister) ) then
812 printlog "don't register datasource"
814 printlog "register datasource with name " + sRegister
815 call fRegisterDatabaseFile(sFileName,sRegister)
821 printlog "--- End of function - *** Succeed ***"
823 warnlog "--- End of function - *** Failed *** Data source was not created"
826 fCreateTextDatasource = bOK
830 call fClosedatabase(true)
833 '-------------------------------------------------------------------------
834 function fCreateSpreadsheetDatasource(sFileName,sURL, optional sRegister) as boolean
835 '/// create a new spreadsheet database file with the given filename
836 '///+ and the given URL as dbase path
837 '/// <u>parameter:</u>
838 '/// <b>sFielName:</b> the file name for the database file
839 '/// <b>sURL:</b> the spreadsheet file name
840 '/// <b><i>optional</i> bRegister:</b> if true the register the database with the given name
845 if ( app.Dir( ConvertPath(sFileName) ) ) <> "" then
846 app.kill(ConvertPath(sFileName))
849 Kontext "DocumentWriter"
850 if (DocumentWriter.exists(1)) then
851 DocumentWriter.UseMenu
853 Kontext "DocumentBackground"
854 DocumentBackground.UseMenu
862 Kontext "DatabaseWizard"
863 ConnectToDatabase.Check
865 DatabaseType.Select (hGetDatabaseDisplayName( "sdbc:calc:*" ))
870 printlog "add the URL"
871 SpreadsheetPath.setText "sdbc:calc:" + ConvertPath(sURL)
874 printlog "click finish"
877 Kontext "SpeichernDlg"
878 Dateiname.setText ConvertPath(sFileName)
883 if MessageBox.exists then
889 if ( IsMissing(sRegister) ) then
890 printlog "don't register datasource"
892 printlog "register datasource with name " + sRegister
893 call fRegisterDatabaseFile(sFileName,sRegister)
898 printlog "--- End of function - *** Succeed ***"
900 warnlog "--- End of function - *** Failed *** Data source was not created"
903 fCreateSpreadsheetDatasource = bOK
907 call fClosedatabase(true)
910 '-------------------------------------------------------------------------
911 function fCreateLDAPAddressbookDatasource(sFileName,sHostName,sBaseDN,sPortNr,optional sRegister) as boolean
912 '/// create a new LDAP Addressbook database with the given filename
913 '/// <u>parameter:</u>
914 '/// <b>sFileName:</b> the file name for the database file
915 '/// <b><i>optional</i> sRegister:</b> if true then register the database
921 if ( app.Dir( ConvertPath(sFileName) ) ) <> "" then
922 app.kill(ConvertPath(sFileName))
926 Kontext "DocumentWriter"
927 if (DocumentWriter.exists(1)) then
928 DocumentWriter.UseMenu
930 Kontext "DocumentBackground"
931 DocumentBackground.UseMenu
939 Kontext "DatabaseWizard"
940 ConnectToDatabase.Check
942 DatabaseType.select ( hGetDatabaseDisplayName( "sdbc:address:ldap:*" ) )
946 LDAPHostName.setText sHostName
948 BaseDN.setText(sBaseDN)
953 Kontext "SpeichernDlg"
954 Dateiname.setText ConvertPath(sFileName)
959 if MessageBox.exists then
966 if ( IsMissing(sRegister) ) then
967 printlog "don't register datasource"
969 printlog "register datasource with name " + sRegister
970 call fRegisterDatabaseFile(sFileName,sRegister)
972 printlog "*** Succeed *** Data source was created"
975 ' warnlog "*** Failed *** Data source was not created"
979 fCreateLDAPAddressbookDatasource = bOK
983 call fClosedatabase(true)
986 '-------------------------------------------------------------------------
987 function fCreateEvolutionAddressbookDatasource(sFileName, optional sRegister) as boolean
988 '/// create a new Evolution Addressbook database with the given filename
989 '/// <u>parameter:</u>
990 '/// <b>sFielName:</b> the file name for the database file
991 '/// <b><i>optional</i> sRegister:</b> if true then register the database
997 if ( app.Dir( ConvertPath(sFileName) ) ) <> "" then
998 app.kill(ConvertPath(sFileName))
1001 Kontext "DocumentWriter"
1002 if (DocumentWriter.exists(1)) then
1003 DocumentWriter.UseMenu
1005 Kontext "DocumentBackground"
1006 DocumentBackground.UseMenu
1014 Kontext "DatabaseWizard"
1015 ConnectToDatabase.Check
1017 DatabaseType.select ( hGetDatabaseDisplayName( "sdbc:address:evolution:ldap" ) )
1022 printlog "click finish"
1025 Kontext "SpeichernDlg"
1026 Dateiname.setText ConvertPath(sFileName)
1030 Kontext "MessageBox"
1031 if MessageBox.exists then
1037 if ( IsMissing(sRegister) ) then
1038 printlog "don't register datasource"
1040 printlog "register datasource with name " + sRegister
1041 call fRegisterDatabaseFile(sFileName,sRegister)
1044 call fClosedatabase(true)
1046 printlog "*** Succeed *** Data source was created"
1049 warnlog "*** Failed *** Data source was not created"
1053 fCreateEvolutionAddressbookDatasource = bOK
1058 '-------------------------------------------------------------------------
1059 function fCreateKDEAddressbookDatasource(sFileName , optional sRegister) as boolean
1060 '/// create a new KDE Addressbook database with the given filename
1061 '/// <u>parameter:</u>
1062 '/// <b>sFileName:</b> the file name for the database file
1063 '/// <b><i>optional</i> sRegister:</b> if true then register the database
1069 if ( app.Dir( ConvertPath(sFileName) ) ) <> "" then
1070 app.kill(ConvertPath(sFileName))
1073 Kontext "DocumentWriter"
1074 if (DocumentWriter.exists(1)) then
1075 DocumentWriter.UseMenu
1077 Kontext "DocumentBackground"
1078 DocumentBackground.UseMenu
1086 Kontext "DatabaseWizard"
1087 ConnectToDatabase.Check
1089 DatabaseType.select ( hGetDatabaseDisplayName( "sdbc:address:kab" ) )
1094 printlog "click finish"
1097 Kontext "SpeichernDlg"
1098 Dateiname.setText ConvertPath(sFileName)
1102 Kontext "MessageBox"
1103 if MessageBox.exists then
1109 if ( IsMissing(sRegister) ) then
1110 printlog "don't register datasource"
1112 printlog "register datasource with name " + sRegister
1113 call fRegisterDatabaseFile(sFileName,sRegister)
1116 call fClosedatabase(true)
1118 printlog "*** Succeed *** Data source was created"
1121 warnlog "*** Failed *** Data source was not created"
1125 fCreateKDEAddressbookDatasource = bOK
1130 '-------------------------------------------------------------------------
1131 function fCreateWindowsAddressbookDatasource(sFileName , optional sRegister) as boolean
1132 '/// create a new Windows Addressbook database with the given filename
1133 '/// <u>parameter:</u>
1134 '/// <b>sFileName:</b> the file name for the database file
1135 '/// <b><i>optional</i> sRegister:</b> if true then register the database
1141 if ( app.Dir( ConvertPath(sFileName) ) ) <> "" then
1142 app.kill(ConvertPath(sFileName))
1145 Kontext "DocumentWriter"
1146 if (DocumentWriter.exists(1)) then
1147 DocumentWriter.UseMenu
1149 Kontext "DocumentBackground"
1150 DocumentBackground.UseMenu
1158 Kontext "DatabaseWizard"
1159 ConnectToDatabase.Check
1161 DatabaseType.select ( hGetDatabaseDisplayName( "sdbc:address:outlookexp" ) )
1166 printlog "click finish"
1169 Kontext "SpeichernDlg"
1170 Dateiname.setText ConvertPath(sFileName)
1174 Kontext "MessageBox"
1175 if MessageBox.exists then
1181 if ( IsMissing(sRegister) ) then
1182 printlog "don't register datasource"
1184 printlog "register datasource with name " + sRegister
1185 call fRegisterDatabaseFile(sFileName,sRegister)
1188 call fClosedatabase(true)
1190 printlog "*** Succeed *** Data source was created"
1193 warnlog "*** Failed *** Data source was not created"
1197 fCreateWindowsAddressbookDatasource = bOK
1202 '-------------------------------------------------------------------------
1203 function fCreateOutlookAddressbookDatasource(sFileName, optional sRegister) as boolean
1204 '/// create a new Outlook Addressbook database with the given filename
1205 '/// <u>parameter:</u>
1206 '/// <b>sFileName:</b> the file name for the database file
1207 '/// <b><i>optional</i> sRegister:</b> if true then register the database
1213 if ( app.Dir( ConvertPath(sFileName) ) ) <> "" then
1214 app.kill(ConvertPath(sFileName))
1217 Kontext "DocumentWriter"
1218 if (DocumentWriter.exists(1)) then
1219 DocumentWriter.UseMenu
1221 Kontext "DocumentBackground"
1222 DocumentBackground.UseMenu
1230 Kontext "DatabaseWizard"
1231 ConnectToDatabase.Check
1233 DatabaseType.select ( hGetDatabaseDisplayName( "sdbc:address:outlook" ) )
1238 printlog "click finish"
1241 Kontext "SpeichernDlg"
1242 Dateiname.setText ConvertPath(sFileName)
1246 Kontext "MessageBox"
1247 if MessageBox.exists then
1253 if ( IsMissing(sRegister) ) then
1254 printlog "don't register datasource"
1256 printlog "register datasource with name " + sRegister
1257 call fRegisterDatabaseFile(sFileName,sRegister)
1260 call fClosedatabase(true)
1262 printlog "*** Succeed *** Data source was created"
1265 warnlog "*** Failed *** Data source was not created"
1269 fCreateOutlookAddressbookDatasource = bOK
1274 '-------------------------------------------------------------------------
1275 function fCreateMozillaAddressbookDatasource(sFileName, optional sRegister) as boolean
1276 '/// create a new mozilla addressbook database file with the given filename
1277 '/// <u>parameter:</u>
1278 '/// <b>sFielName:</b> the file name for the database file
1279 '/// <b><i>optional</i> sRegister:</b> the name under which the database is registered
1285 if ( app.Dir( ConvertPath(sFileName) ) ) <> "" then
1286 app.kill(ConvertPath(sFileName))
1289 Kontext "DocumentWriter"
1290 if (DocumentWriter.exists(1)) then
1291 DocumentWriter.UseMenu
1293 Kontext "DocumentBackground"
1294 DocumentBackground.UseMenu
1302 Kontext "DatabaseWizard"
1303 ConnectToDatabase.Check
1305 DatabaseType.select ( hGetDatabaseDisplayName( "sdbc:address:mozilla:" ) )
1310 printlog "click finish"
1313 Kontext "SpeichernDlg"
1314 Dateiname.setText ConvertPath(sFileName)
1318 Kontext "MessageBox"
1319 if MessageBox.exists then
1325 if ( IsMissing(sRegister) ) then
1326 printlog "don't register datasource"
1328 printlog "register datasource with name " + sRegister
1329 call fRegisterDatabaseFile(sFileName,sRegister)
1331 printlog "*** Succeed *** Data source was created"
1334 call fClosedatabase(true)
1337 qaerrorlog "*** Failed *** Data source was not created"
1341 fCreateMozillaAddressbookDatasource = bOK
1346 '--------------------------------------------------------------------
1347 function fRegisterDatabaseFile( sFileName, sName)
1348 '/// register a database
1349 '/// <u>parameter:</u>
1350 '/// <b>sFielName:</b> the file name for the database file
1351 '/// <b>sName:</b> The name under which the database is registered
1357 call hToolsOptions ( "Datasources", "Databases" )
1359 '/// remove registration if exists
1361 Kontext "TabRegisteredDatabase"
1362 for i = 1 to RegisteredDatabases.GetItemCount
1363 RegisteredDatabases.select i
1364 if RegisteredDatabases.getSeltext() = sName then
1374 Kontext "TabRegisteredDatabase"
1377 Kontext "CreateDatabaseLink"
1379 RegisteredName.setText(sName)
1380 DatabaseFile.setText(sFileName)
1382 CreateDatabaseLink.OK
1385 Kontext "OptionenDlg"
1389 '--------------------------------------------------------------------
1390 function fDeRegisterDatabaseFile( sName)
1391 '/// deregister a database
1392 '/// <u>parameter:</u>
1393 '/// <b>sName:</b> The registered name which should be deregistered
1398 call hToolsOptions ( "Datasources", "Databases" )
1400 '/// remove registration for the database
1401 printlog "remove registration for the database " + sName
1403 Kontext "TabRegisteredDatabase"
1404 for i = 1 to RegisteredDatabases.GetItemCount
1405 RegisteredDatabases.select i
1406 if RegisteredDatabases.getSeltext() = sName then
1419 Kontext "OptionenDlg"
1423 '-------------------------------------------------------------------------
1424 function fSetJDBCDriverFiles(sClassPath) as boolean
1425 '/// set the java classpath
1426 '/// <u>parameter:</u>
1427 '/// <b>sClassPath:</b> The Classpath
1429 Dim x_DriverInstall as boolean
1430 x_DriverInstall = FALSE
1433 printlog "insert classpath: " + sClassPath
1435 call hToolsOptions ( "StarOffice", "JAVA" )
1440 Kontext "JavaClassPath"
1443 Kontext "GeneralFileDialog"
1444 Dateiname.setText ConvertPath(sClassPath)
1447 '/// if the class file allready exists a messages box pops up
1448 Kontext "MessageBox"
1449 if ( MessageBox.exists(3) ) then
1453 Kontext "JavaClassPath"
1456 Kontext "MessageBox"
1457 if ( MessageBox.exists(3) ) then
1461 Kontext "OptionenDlg"
1468 '-------------------------------------------------------------------------
1470 function hGetInstalledDatabaseDrivers( dbDriverList() as string ) as integer
1472 ' This function returns the number of currently installed database drivers.
1473 ' Additionally it fills a given list (which should be large enough to hold
1474 ' the names of all installed drivers) with the url and makes the list
1475 ' compatible to the listfunctions (which places the list size in element 0)
1476 ' The list is platform dependent and might be locale dependent
1477 ' Note that some drivers (like e.g. HSQL Database Engine) do *not* show up
1478 ' in the Database Wizards listbox!
1480 dim oUnoOfficeConnection as object
1481 dim oUnoConfigurationAccess as object
1482 dim aPropertyValue(1) as new com.sun.star.beans.PropertyValue
1483 dim xViewRoot as object
1484 dim aElements() as string
1485 dim iCurrentDriver as integer
1486 dim iDriverCount as integer
1488 const CFN = "dbaccess::tools::dbcreatetools.inc::hGetInstalledDatabaseDrivers(): "
1490 ' Path to the node, searches all files below "Drivers" for "Installed"
1491 aPropertyValue( 0 ).Name = "nodepath"
1492 aPropertyValue( 0 ).Value = "org.openoffice.Office.DataAccess.Drivers/Installed"
1494 ' Connect to remote UNO
1495 oUnoOfficeConnection = hGetUnoService( TRUE )
1497 if ( isNull( oUnoOfficeConnection )) then
1498 warnlog( CFN & "Failed to establish UNO connection, hGetUnoService failed" )
1499 hGetInstalledDatabaseDrivers() = 0
1501 ' Get a configuration provider
1502 oUnoConfigurationAccess = oUnoOfficeConnection.createInstance( "com.sun.star.configuration.ConfigurationProvider" )
1505 xViewRoot = oUnoConfigurationAccess.createInstanceWithArguments( "com.sun.star.configuration.ConfigurationAccess", aPropertyValue() )
1506 aElements() = xViewRoot.getElementNames()
1508 iDriverCount = ubound( aElements() )
1509 dbDriverList( 0 ) = iDriverCount
1510 for iCurrentDriver = 1 to iDriverCount
1511 dbDriverList( iCurrentDriver ) = aElements( iCurrentDriver )
1516 if ( GVERBOSE ) then
1517 printlog( CFN & "Returning " & iDriverCount & " drivers" )
1520 hGetInstalledDatabaseDrivers() = iDriverCount
1524 '-------------------------------------------------------------------------
1526 function hGetDatabaseDisplayName( dbDriverURL as string ) as string
1528 ' The xcu files (based on dev300m47) hold following driver definitions
1529 ' which are used as parameter to this function. You get a plain text
1530 ' localized driver name as returnvalue which can be used directly to select
1531 ' a driver in the Database Wizard.
1533 ' adabas.xcu: "sdbc:adabas:*"
1534 ' calc.xcu: "sdbc:calc:*"
1535 ' dbase.xcu: "sdbc:dbase:*"
1536 ' evoab.xcu: "sdbc:address:evolution:ldap"
1537 ' evoab.xcu: "sdbc:address:evolution:groupwise"
1538 ' flat.xcu: "sdbc:flat:*"
1539 ' ado.xcu: "sdbc:ado:*"
1540 ' hsqldb.xcu: "sdbc:embedded:hsqldb"
1541 ' kab.xcu: "sdbc:address:kab"
1542 ' mozab.xcu: "sdbc:address:outlook"
1543 ' mozab.xcu: "sdbc:address:outlookexp"
1544 ' mozab.xcu: "sdbc:address:mozilla:"
1545 ' mozab.xcu: "sdbc:address:thunderbird:"
1546 ' mozab.xcu: "sdbc:address:ldap:*"
1547 ' mysql.xcu: "sdbc:mysql:jdbc:*"
1548 ' mysql.xcu: "sdbc:mysql:odbc:*"
1549 ' odbc.xcu: "sdbc:odbc:*"
1550 ' jdbc.xcu: "jdbc:*"
1551 ' jdbc.xcu: "jdbc:oracle:thin:*"
1552 ' mysql.xcu: "sdbc:mysql:jdbc:*"
1555 ' Note that some drivers (like e.g. HSQL Database Engine) do *not* show up
1556 ' in the Database Wizards listbox!
1559 dim oUnoOfficeConnection as object
1560 dim oUnoConfigurationAccess as object
1561 dim aPropertyValue(1) as new com.sun.star.beans.PropertyValue
1562 dim oConfig as object
1563 dim oDriver as object
1564 dim sDatabaseName as string
1566 const CFN = "dbaccess::tools::dbcreatetools.inc::hGetDatabaseDisplayName(): "
1568 ' Path to the node, searches all files below "Drivers" for "Installed"
1569 aPropertyValue( 0 ).Name = "nodepath"
1570 aPropertyValue( 0 ).Value = "org.openoffice.Office.DataAccess.Drivers/Installed/"
1572 ' Connect to remote UNO
1573 oUnoOfficeConnection = hGetUnoService( TRUE )
1575 if ( isNull( oUnoOfficeConnection )) then
1576 warnlog( CFN & "Failed to establish UNO connection, hGetUnoService failed" )
1579 ' Get a configuration provider
1580 oUnoConfigurationAccess = oUnoOfficeConnection.createInstance( "com.sun.star.configuration.ConfigurationProvider" )
1583 oConfig = oUnoConfigurationAccess.createInstanceWithArguments( "com.sun.star.configuration.ConfigurationAccess", aPropertyValue() )
1585 oDriver = oConfig.getByName( dbDriverURL )
1586 sDatabaseName = oDriver.getByName( "DriverTypeDisplayName" )
1588 warnlog( CFN & "Invalid driver or driver unsupported on this platform" )
1594 if ( GVERBOSE ) then
1595 printlog( CFN & "Database display string: " & sDatabaseName )
1597 hGetDataBaseDisplayName() = sDatabaseName
1600 '-------------------------------------------------------------------------
1601 function isDriverInstalled( dbDriverURL as string ) as string
1603 ' This function return true or false if a driver for a given URL is installed
1605 Dim myDriverList(20) as string
1607 Dim sDriver as string
1608 Dim breturn as boolean
1611 const CFN = "dbaccess::tools::dbcreatetools.inc::isDriverInstalled(): "
1615 printlog "url to search for : " + dbDriverURL
1618 hGetInstalledDatabaseDrivers( myDriverList() )
1620 for i = 1 to ubound(myDriverList)
1621 sDriver = myDriverList(i)
1623 printlog "found url : " + sDriver
1625 if sDriver = dbDriverURL then
1630 isDriverInstalled = breturn