summaryrefslogtreecommitdiff
path: root/dbaccess/source/ui/dlg/dbadmin.cxx
blob: 3864e25b3774ca0e377e893b4cc48083d520cfb4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
/*************************************************************************
 *
 *  $RCSfile: dbadmin.cxx,v $
 *
 *  $Revision: 1.83 $
 *
 *  last change: $Author: oj $ $Date: 2002-11-21 15:23:00 $
 *
 *  The Contents of this file are made available subject to the terms of
 *  either of the following licenses
 *
 *         - GNU Lesser General Public License Version 2.1
 *         - Sun Industry Standards Source License Version 1.1
 *
 *  Sun Microsystems Inc., October, 2000
 *
 *  GNU Lesser General Public License Version 2.1
 *  =============================================
 *  Copyright 2000 by Sun Microsystems, Inc.
 *  901 San Antonio Road, Palo Alto, CA 94303, USA
 *
 *  This library is free software; you can redistribute it and/or
 *  modify it under the terms of the GNU Lesser General Public
 *  License version 2.1, as published by the Free Software Foundation.
 *
 *  This library is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 *  Lesser General Public License for more details.
 *
 *  You should have received a copy of the GNU Lesser General Public
 *  License along with this library; if not, write to the Free Software
 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston,
 *  MA  02111-1307  USA
 *
 *
 *  Sun Industry Standards Source License Version 1.1
 *  =================================================
 *  The contents of this file are subject to the Sun Industry Standards
 *  Source License Version 1.1 (the "License"); You may not use this file
 *  except in compliance with the License. You may obtain a copy of the
 *  License at http://www.openoffice.org/license.html.
 *
 *  Software provided under this License is provided on an "AS IS" basis,
 *  WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING,
 *  WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
 *  MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
 *  See the License for the specific provisions governing your rights and
 *  obligations concerning the Software.
 *
 *  The Initial Developer of the Original Code is: Sun Microsystems, Inc..
 *
 *  Copyright: 2000 by Sun Microsystems, Inc.
 *
 *  All Rights Reserved.
 *
 *  Contributor(s): _______________________________________
 *
 *
 ************************************************************************/

#ifndef _DBAUI_DBADMIN_HXX_
#include "dbadmin.hxx"
#endif
#ifndef _DBAUI_DBADMIN_HRC_
#include "dbadmin.hrc"
#endif
#ifndef _DBU_DLG_HRC_
#include "dbu_dlg.hrc"
#endif
#ifndef _DBAUI_MODULE_DBU_HXX_
#include "moduledbu.hxx"
#endif
#ifndef _DBAUI_DATASOURCEITEMS_HXX_
#include "dsitems.hxx"
#endif
#ifndef _SFXSTRITEM_HXX
#include <svtools/stritem.hxx>
#endif
#ifndef _SFXENUMITEM_HXX
#include <svtools/eitem.hxx>
#endif
#ifndef _SFXINTITEM_HXX
#include <svtools/intitem.hxx>
#endif
#ifndef _VCL_STDTEXT_HXX
#include <vcl/stdtext.hxx>
#endif
#ifndef _SV_MSGBOX_HXX
#include <vcl/msgbox.hxx>
#endif
#ifndef _SVTOOLS_LOGINDLG_HXX_
#include <svtools/logindlg.hxx>
#endif
#ifndef _COM_SUN_STAR_SDB_SQLCONTEXT_HPP_
#include <com/sun/star/sdb/SQLContext.hpp>
#endif
#ifndef _COM_SUN_STAR_BEANS_PROPERTYATTRIBUTE_HPP_
#include <com/sun/star/beans/PropertyAttribute.hpp>
#endif
#ifndef _COM_SUN_STAR_UNO_XNAMINGSERVICE_HPP_
#include <com/sun/star/uno/XNamingService.hpp>
#endif
#ifndef _COM_SUN_STAR_UTIL_XFLUSHABLE_HPP_
#include <com/sun/star/util/XFlushable.hpp>
#endif
#ifndef DBACCESS_SHARED_DBUSTRINGS_HRC
#include "dbustrings.hrc"
#endif
#ifndef _COMPHELPER_EXTRACT_HXX_
#include <comphelper/extract.hxx>
#endif
#ifndef _DBAUI_ADMINPAGES_HXX_
#include "adminpages.hxx"
#endif
#ifndef _DBAUI_DETAILPAGES_HXX_
#include "detailpages.hxx"
#endif
#ifndef _DBAUI_COMMONPAGES_HXX_
#include "commonpages.hxx"
#endif
#ifndef _DBAUI_TABLESPAGE_HXX_
#include "tablespage.hxx"
#endif
#ifndef _DBAUI_GENERALPAGE_HXX_
#include "generalpage.hxx"
#endif
#ifndef _DBAUI_LOCALRESACCESS_HXX_
#include "localresaccess.hxx"
#endif
#ifndef _DBAUI_STRINGLISTITEM_HXX_
#include "stringlistitem.hxx"
#endif
#ifndef _TYPELIB_TYPEDESCRIPTION_HXX_
#include <typelib/typedescription.hxx>
#endif
#ifndef _COMPHELPER_PROPERTY_HXX_
#include <comphelper/property.hxx>
#endif
#ifndef _COMPHELPER_SEQUENCE_HXX_
#include <comphelper/sequence.hxx>
#endif
#ifndef _DBAUI_PROPERTYSETITEM_HXX_
#include "propertysetitem.hxx"
#endif
#ifndef DBAUI_ADABASPAGE_HXX
#include "AdabasPage.hxx"
#endif
#ifndef _DBHELPER_DBEXCEPTION_HXX_
#include <connectivity/dbexception.hxx>
#endif
#ifndef DBAUI_TOOLS_HXX
#include "UITools.hxx"
#endif
#ifndef _SV_WAITOBJ_HXX
#include <vcl/waitobj.hxx>
#endif
#ifndef _COM_SUN_STAR_SDBC_XDRIVERACCESS_HPP_
#include <com/sun/star/sdbc/XDriverAccess.hpp>
#endif
#ifndef _COM_SUN_STAR_SDBC_XDRIVER_HPP_
#include <com/sun/star/sdbc/XDriver.hpp>
#endif
#ifndef DBAUI_USERADMIN_HXX
#include "UserAdmin.hxx"
#endif

#include <algorithm>
#include <functional>

//.........................................................................
namespace dbaui
{
//.........................................................................
using namespace dbtools;
using namespace com::sun::star::uno;
using namespace com::sun::star::sdbc;
using namespace com::sun::star::sdb;
using namespace com::sun::star::lang;
using namespace com::sun::star::util;
using namespace com::sun::star::beans;
using namespace com::sun::star::container;

//=========================================================================
//= ODbAdminDialog
//=========================================================================
//-------------------------------------------------------------------------
ODbAdminDialog::ODbAdminDialog(Window* _pParent, SfxItemSet* _pItems, const Reference< XMultiServiceFactory >& _rxORB)
    :SfxTabDialog(_pParent, ModuleRes(DLG_DATABASE_ADMINISTRATION), _pItems)
    ,m_aSelector(this, ResId(WND_DATASOURCESELECTOR))
    ,m_bResetting(sal_False)
    ,m_bApplied(sal_False)
    ,m_aDatasources(_rxORB)
    ,m_xORB(_rxORB)
    ,m_nPostApplyPage(0)
    ,m_pPostApplyPageSettings(NULL)
    ,m_eMode(omFull)
    ,m_bUIEnabled( sal_True )
{
    // add the initial tab pages
    AddTabPage(PAGE_GENERAL, String(ResId(STR_PAGETITLE_GENERAL)), OGeneralPage::Create, NULL);
    AddTabPage(PAGE_TABLESUBSCRIPTION, String(ResId(STR_PAGETITLE_TABLESUBSCRIPTION)), OTableSubscriptionPage::Create, NULL);
    AddTabPage(PAGE_QUERYADMINISTRATION, String(ResId(STR_PAGETITLE_QUERIES)), OQueryAdministrationPage::Create, NULL);
    AddTabPage(PAGE_DOCUMENTLINKS, String(ResId(STR_PAGETITLE_DOCUMENTS)), ODocumentLinksPage::Create, NULL);
    // no local resources needed anymore
    FreeResource();

    /// initialize the property translation map
    // direct properties of a data source
    m_aDirectPropTranslator.insert(MapInt2String::value_type(DSID_CONNECTURL, PROPERTY_URL));
    m_aDirectPropTranslator.insert(MapInt2String::value_type(DSID_NAME, PROPERTY_NAME));
    m_aDirectPropTranslator.insert(MapInt2String::value_type(DSID_USER, PROPERTY_USER));
    m_aDirectPropTranslator.insert(MapInt2String::value_type(DSID_PASSWORD, PROPERTY_PASSWORD));
    m_aDirectPropTranslator.insert(MapInt2String::value_type(DSID_PASSWORDREQUIRED, PROPERTY_ISPASSWORDREQUIRED));
    m_aDirectPropTranslator.insert(MapInt2String::value_type(DSID_TABLEFILTER, PROPERTY_TABLEFILTER));
    m_aDirectPropTranslator.insert(MapInt2String::value_type(DSID_READONLY, PROPERTY_ISREADONLY));
    m_aDirectPropTranslator.insert(MapInt2String::value_type(DSID_SUPPRESSVERSIONCL, PROPERTY_SUPPRESSVERSIONCL));

    // implicit properties, to be found in the direct property "Info"
    m_aIndirectPropTranslator.insert(MapInt2String::value_type(DSID_JDBCDRIVERCLASS, ::rtl::OUString::createFromAscii("JavaDriverClass")));
    m_aIndirectPropTranslator.insert(MapInt2String::value_type(DSID_TEXTFILEEXTENSION, ::rtl::OUString::createFromAscii("Extension")));
    m_aIndirectPropTranslator.insert(MapInt2String::value_type(DSID_CHARSET, ::rtl::OUString::createFromAscii("CharSet")));
    m_aIndirectPropTranslator.insert(MapInt2String::value_type(DSID_TEXTFILEHEADER, ::rtl::OUString::createFromAscii("HeaderLine")));
    m_aIndirectPropTranslator.insert(MapInt2String::value_type(DSID_FIELDDELIMITER, ::rtl::OUString::createFromAscii("FieldDelimiter")));
    m_aIndirectPropTranslator.insert(MapInt2String::value_type(DSID_TEXTDELIMITER, ::rtl::OUString::createFromAscii("StringDelimiter")));
    m_aIndirectPropTranslator.insert(MapInt2String::value_type(DSID_DECIMALDELIMITER, ::rtl::OUString::createFromAscii("DecimalDelimiter")));
    m_aIndirectPropTranslator.insert(MapInt2String::value_type(DSID_THOUSANDSDELIMITER, ::rtl::OUString::createFromAscii("ThousandDelimiter")));
    m_aIndirectPropTranslator.insert(MapInt2String::value_type(DSID_SHOWDELETEDROWS, ::rtl::OUString::createFromAscii("ShowDeleted")));
    m_aIndirectPropTranslator.insert(MapInt2String::value_type(DSID_ALLOWLONGTABLENAMES, ::rtl::OUString::createFromAscii("NoNameLengthLimit")));
    m_aIndirectPropTranslator.insert(MapInt2String::value_type(DSID_ADDITIONALOPTIONS, ::rtl::OUString::createFromAscii("SystemDriverSettings")));
    m_aIndirectPropTranslator.insert(MapInt2String::value_type(DSID_SQL92CHECK, PROPERTY_ENABLESQL92CHECK));
    m_aIndirectPropTranslator.insert(MapInt2String::value_type(DSID_AUTOINCREMENTVALUE, PROPERTY_AUTOINCREMENTCREATION));
    m_aIndirectPropTranslator.insert(MapInt2String::value_type(DSID_AUTORETRIEVEVALUE, ::rtl::OUString::createFromAscii("AutoRetrievingStatement")));
    m_aIndirectPropTranslator.insert(MapInt2String::value_type(DSID_AUTORETRIEVEENABLED, ::rtl::OUString::createFromAscii("IsAutoRetrievingEnabled")));

    // special settings for adabas
    m_aIndirectPropTranslator.insert(MapInt2String::value_type(DSID_CONN_SHUTSERVICE, ::rtl::OUString::createFromAscii("ShutdownDatabase")));
    m_aIndirectPropTranslator.insert(MapInt2String::value_type(DSID_CONN_DATAINC, ::rtl::OUString::createFromAscii("DataCacheSizeIncrement")));
    m_aIndirectPropTranslator.insert(MapInt2String::value_type(DSID_CONN_CACHESIZE, ::rtl::OUString::createFromAscii("DataCacheSize")));
    m_aIndirectPropTranslator.insert(MapInt2String::value_type(DSID_CONN_CTRLUSER, ::rtl::OUString::createFromAscii("ControlUser")));
    m_aIndirectPropTranslator.insert(MapInt2String::value_type(DSID_CONN_CTRLPWD, ::rtl::OUString::createFromAscii("ControlPassword")));
    // extra settings for odbc
    m_aIndirectPropTranslator.insert(MapInt2String::value_type(DSID_USECATALOG, ::rtl::OUString::createFromAscii("UseCatalog")));
    // extra settings for a ldap address book
    m_aIndirectPropTranslator.insert(MapInt2String::value_type(DSID_CONN_LDAP_HOSTNAME, ::rtl::OUString::createFromAscii("HostName")));
    m_aIndirectPropTranslator.insert(MapInt2String::value_type(DSID_CONN_LDAP_BASEDN, ::rtl::OUString::createFromAscii("BaseDN")));
    m_aIndirectPropTranslator.insert(MapInt2String::value_type(DSID_CONN_LDAP_PORTNUMBER, ::rtl::OUString::createFromAscii("PortNumber")));
    m_aIndirectPropTranslator.insert(MapInt2String::value_type(DSID_CONN_LDAP_ROWCOUNT, ::rtl::OUString::createFromAscii("MaxRowCount")));

    // remove the reset button - it's meaning is much too ambiguous in this dialog
    RemoveResetButton();

    // enable an apply button
    EnableApplyButton(sal_True);
    SetApplyHandler(LINK(this, ODbAdminDialog, OnApplyChanges));
    // disable the apply button
    GetApplyButton()->Enable(sal_False);

    // register the view window
    SetViewWindow(&m_aSelector);
    SetViewAlign(WINDOWALIGN_LEFT);
    AdjustLayout();

    // do some knittings
    m_aSelector.setSelectHandler(LINK(this, ODbAdminDialog, OnDatasourceSelected));
    m_aSelector.setNewHandler(LINK(this, ODbAdminDialog, OnNewDatasource));
    m_aSelector.setDeleteHandler(LINK(this, ODbAdminDialog, OnDeleteDatasource));
    m_aSelector.setRestoreHandler(LINK(this, ODbAdminDialog, OnRestoreDatasource));

    ::rtl::OUString sInitialSelection;  // will be the initial selection

    if (!m_aDatasources.isValid())
    {
        ShowServiceNotAvailableError(_pParent, String(SERVICE_SDB_DATABASECONTEXT), sal_True);
        m_aSelector.Disable();
    }
    else
    {
        m_xDatabaseContext = m_aDatasources.getContext();
        m_xDynamicContext = Reference< XNamingService >(m_xDatabaseContext, UNO_QUERY);
        DBG_ASSERT(m_xDynamicContext.is(), "ODbAdminDialog::ODbAdminDialog : no XNamingService interface !");

        // fill the listbox with the names of the registered datasources
        ODatasourceMap::Iterator aDatasourceLoop = m_aDatasources.begin();
        while (aDatasourceLoop != m_aDatasources.end())
        {
            m_aSelector.insert(*aDatasourceLoop);
            m_aValidDatasources.insert(*aDatasourceLoop);

            ++aDatasourceLoop;
        }

        if (!m_aDatasources.size())
        {
            WarningBox(_pParent, ModuleRes(ERR_NOREGISTEREDDATASOURCES)).Execute();
        }
        else
            sInitialSelection = *m_aDatasources.begin();
    }

    implSelectDatasource(sInitialSelection);

    GetApplyButton()->Enable(sal_False);
        // nothing modified 'til now -> now apply
}

//-------------------------------------------------------------------------
ODbAdminDialog::~ODbAdminDialog()
{
    SetInputSet(NULL);
    DELETEZ(pExampleSet);
}
// -----------------------------------------------------------------------------
String ODbAdminDialog::getConnectionURL() const
{
    SFX_ITEMSET_GET(*GetExampleSet(), pUrlItem, SfxStringItem, DSID_CONNECTURL, sal_True);
    return pUrlItem->GetValue();
}

// -----------------------------------------------------------------------------
Reference< XPropertySet > ODbAdminDialog::getCurrentDataSource()
{
    ODatasourceMap::ODatasourceInfo aDatasourceInfo = m_aDatasources[m_sCurrentDatasource];
    Reference< XPropertySet > xCurrentDatasource = aDatasourceInfo.getDatasource();
    DBG_ASSERT(xCurrentDatasource.is(), "ODbAdminDialog::getCurrentDataSource: no data source!");
    return xCurrentDatasource;
}

// -----------------------------------------------------------------------------
Reference< XDriver > ODbAdminDialog::getDriver()
{
    // get the global DriverManager
    Reference< XDriverAccess > xDriverManager;
    String sCurrentActionError = String(ModuleRes(STR_COULDNOTCREATE_DRIVERMANAGER));
        // in case an error occures
    sCurrentActionError.SearchAndReplaceAscii("#servicename#", (::rtl::OUString)SERVICE_SDBC_CONNECTIONPOOL);
    try
    {
        xDriverManager = Reference< XDriverAccess >(getORB()->createInstance(SERVICE_SDBC_CONNECTIONPOOL), UNO_QUERY);
        DBG_ASSERT(xDriverManager.is(), "ODbAdminDialog::getDriver: could not instantiate the driver manager, or it does not provide the necessary interface!");
    }
    catch (Exception& e)
    {
        // wrap the exception into an SQLException
        SQLException aSQLWrapper(e.Message, getORB(), ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("S1000")), 0, Any());
        throw SQLException(sCurrentActionError, getORB(), ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("S1000")), 0, makeAny(aSQLWrapper));
    }
    if (!xDriverManager.is())
        throw SQLException(sCurrentActionError, getORB(), ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("S1000")), 0, Any());


    Reference< XDriver > xDriver = xDriverManager->getDriverByURL(getConnectionURL());
    if (!xDriver.is())
    {
        sCurrentActionError = String(ModuleRes(STR_NOREGISTEREDDRIVER));
        sCurrentActionError.SearchAndReplaceAscii("#connurl#", getConnectionURL());
        // will be caught and translated into an SQLContext exception
        throw SQLException(sCurrentActionError, getORB(), ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("S1000")), 0, Any());
    }
    return xDriver;
}
// -----------------------------------------------------------------------------
Reference<XConnection> ODbAdminDialog::createConnection()
{
    Reference<XConnection> xConnection;
//  //  if (bValid)
    {   // get the current table list from the connection for the current settings
        // the PropertyValues for the current dialog settings
        Sequence< PropertyValue > aConnectionParams;
        if (getCurrentSettings(aConnectionParams))
        {
            // the current DSN
            // fill the table list with this connection information
            SQLExceptionInfo aErrorInfo;
            try
            {
                WaitObject aWaitCursor(this);
                xConnection = getDriver()->connect(getConnectionURL(), aConnectionParams);
            }
            catch (::com::sun::star::sdb::SQLContext& e) { aErrorInfo = SQLExceptionInfo(e); }
            catch (::com::sun::star::sdbc::SQLWarning& e) { aErrorInfo = SQLExceptionInfo(e); }
            catch (::com::sun::star::sdbc::SQLException& e) { aErrorInfo = SQLExceptionInfo(e); }

            showError(aErrorInfo,this,getORB());
        }
    }
    if(xConnection.is())
        successfullyConnected();// notify the admindlg to save the password

    return xConnection;
}
//-------------------------------------------------------------------------
short ODbAdminDialog::Execute()
{
    // in "single edit" mode ...
    if (omFull != getMode())
        // ... we initially show the detail page for convenience
        PostUserEvent( LINK( this, ODbAdminDialog, OnAsyncSelectDetailsPage ) );

    short nResult = SfxTabDialog::Execute();

    // within it's dtor, the SfxTabDialog saves (amongst others) the currently selected tab page and
    // reads it upon the next Execute (dependent on the resource id, which thus has to be globally unique,
    // though our's isn't)
    // As this is not wanted if e.g. the table subscription page is selected, we show the GeneralPage here
    ShowPage(PAGE_GENERAL);

    // clear the temporary SfxItemSets we created
    m_aDatasources.clear();

    return m_bApplied ? RET_OK : nResult;
        // the result as returned by SfxTabDialog::Execute may not be correct
        // in case the user applied some changes, and after this, simply prssed OK, the base class method will return
        // RET_CANCEL ('cause it thinks nothing changed), but in real it is an RET_OK
}

//-------------------------------------------------------------------------
void ODbAdminDialog::setMode(const OperationMode _eMode)
{
    DBG_ASSERT(!IsInExecute(), "ODbAdminDialog::setMode: not to be called while beeing executed!");

    if (_eMode == m_eMode)
        // nothing to do
        return;

    m_eMode = _eMode;

    // if we're in a "edit the current data source only" mode, we hide the selection listbox and the new
    // button
    m_aSelector.Show( omFull == m_eMode );
    AdjustLayout();
}

//-------------------------------------------------------------------------
sal_Bool ODbAdminDialog::insertDataSource(const ::rtl::OUString& _rName)
{
    if (!prepareSwitchDatasource())
        return sal_False;

    if (!_rName.getLength())
        return sal_False;

    if (!isValidNewName(_rName))
        return sal_False;

    return implInsertNew_noCheck(_rName);
}

//-------------------------------------------------------------------------
IMPL_LINK( ODbAdminDialog, OnAsyncSelectDetailsPage, void*, NOTINTERESTEDIN )
{
    sal_uInt16 nDetailPageId = 0;
    switch (getDatasourceType(*GetInputSetImpl()))
    {
        case DST_DBASE      : nDetailPageId = PAGE_GENERAL; break;  // There are settings to be done on the general page (URL)
        case DST_JDBC       : nDetailPageId = PAGE_JDBC; break;
        case DST_ADO        : nDetailPageId = PAGE_ADO; break;
        case DST_TEXT       : nDetailPageId = PAGE_TEXT; break;
        case DST_ODBC       : nDetailPageId = PAGE_ODBC; break;
        case DST_ADABAS     : nDetailPageId = PAGE_ADABAS; break;
        case DST_ADDRESSBOOK: nDetailPageId = PAGE_LDAP; /* juest a guess */ break;
        case DST_MYSQL_ODBC :
        case DST_MYSQL_JDBC : nDetailPageId = PAGE_MYSQL; break;
    }
    if (nDetailPageId)
    {
        ShowPage(nDetailPageId);
        if (GetTabPage(nDetailPageId))
            GetTabPage(nDetailPageId)->GrabFocus();
    }

    return 0L;
}

//-------------------------------------------------------------------------
void ODbAdminDialog::selectDataSource(const ::rtl::OUString& _rName)
{
    if (m_aDatasources.exists(_rName))
        implSelectDatasource(_rName);
}

//-------------------------------------------------------------------------
void ODbAdminDialog::clearPassword()
{
    if (pExampleSet)
        pExampleSet->ClearItem(DSID_PASSWORD);
}

//-------------------------------------------------------------------------
void ODbAdminDialog::successfullyConnected()
{
    DBG_ASSERT(GetExampleSet(), "ODbAdminDialog::successfullyConnected: not to be called without an example set!");
    if (!GetExampleSet())
        return;

    if (hasAuthentication(*GetExampleSet()))
    {
        SFX_ITEMSET_GET(*GetExampleSet(), pPassword, SfxStringItem, DSID_PASSWORD, sal_True);
        if (pPassword && (0 != pPassword->GetValue().Len()))
        {
            ::rtl::OUString sPassword = pPassword->GetValue();

            Reference< XPropertySet > xCurrentDatasource = getCurrentDataSource();
            if (xCurrentDatasource.is())
            {
                try
                {
                    xCurrentDatasource->setPropertyValue(m_aDirectPropTranslator[DSID_PASSWORD], makeAny(sPassword));
                }
                catch(const Exception&)
                {
                    DBG_ERROR("ODbAdminDialog::successfullyConnected: caught an exception!");
                }
            }
        }
    }
}

//-------------------------------------------------------------------------
sal_Bool ODbAdminDialog::getCurrentSettings(Sequence< PropertyValue >& _rDriverParam)
{
    DBG_ASSERT(GetExampleSet(), "ODbAdminDialog::getCurrentSettings : not to be called without an example set!");
    if (!GetExampleSet())
        return sal_False;

    ::std::vector< PropertyValue > aReturn;
        // collecting this in a vector because it has a push_back, in opposite to sequences

    // user: DSID_USER -> "user"
    SFX_ITEMSET_GET(*GetExampleSet(), pUser, SfxStringItem, DSID_USER, sal_True);
    if (pUser && pUser->GetValue().Len())
        aReturn.push_back(
            PropertyValue(  ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("user")), 0,
                            makeAny(::rtl::OUString(pUser->GetValue())), PropertyState_DIRECT_VALUE));

    // check if the connection type requires a password
    if (hasAuthentication(*GetExampleSet()))
    {
        // password: DSID_PASSWORD -> "password"
        SFX_ITEMSET_GET(*GetExampleSet(), pPassword, SfxStringItem, DSID_PASSWORD, sal_True);
        String sPassword = pPassword ? pPassword->GetValue() : String();
        SFX_ITEMSET_GET(*GetExampleSet(), pPasswordRequired, SfxBoolItem, DSID_PASSWORDREQUIRED, sal_True);
        // if the set does not contain a password, but the item set says it requires one, ask the user
        if ((!pPassword || !pPassword->GetValue().Len()) && (pPasswordRequired && pPasswordRequired->GetValue()))
        {
            SFX_ITEMSET_GET(*GetExampleSet(), pName, SfxStringItem, DSID_NAME, sal_True);

            ::svt::LoginDialog aDlg(this,
                LF_NO_PATH | LF_NO_ACCOUNT | LF_NO_ERRORTEXT | LF_USERNAME_READONLY,
                String(), NULL);

            aDlg.SetName(pUser ? pUser->GetValue() : String());
            aDlg.ClearPassword();  // this will give the password field the focus

            String sLoginRequest(ModuleRes(STR_ENTER_CONNECTION_PASSWORD));
            sLoginRequest.SearchAndReplaceAscii("$name$", pName ? pName->GetValue() : String()),
            aDlg.SetLoginRequestText(sLoginRequest);
            aDlg.SetSavePasswordText(ModuleRes(STR_REMEMBERPASSWORD_SESSION));
            aDlg.SetSavePassword(sal_True);

            sal_Int32 nResult = aDlg.Execute();
            if (nResult != RET_OK)
                return sal_False;

            sPassword = aDlg.GetPassword();
            if (aDlg.IsSavePassword())
                pExampleSet->Put(SfxStringItem(DSID_PASSWORD, sPassword));
        }

        if (sPassword.Len())
            aReturn.push_back(
                PropertyValue(  ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("password")), 0,
                                makeAny(::rtl::OUString(sPassword)), PropertyState_DIRECT_VALUE));
    }

    _rDriverParam = Sequence< PropertyValue >(aReturn.begin(), aReturn.size());

    // append all the other stuff (charset etc.)
    fillDatasourceInfo(*GetExampleSet(), _rDriverParam);

    return sal_True;
}

//-------------------------------------------------------------------------
sal_Bool ODbAdminDialog::isCurrentModified() const
{
    if (0 == m_aSelector.count())
        return sal_False;

    String sCurrentlySelected = m_aSelector.getSelected();
    return const_cast<ODbAdminDialog*>(this)->m_aDatasources[sCurrentlySelected].isModified();
}

//-------------------------------------------------------------------------
sal_Bool ODbAdminDialog::isApplyable() const
{
    return GetApplyButton()->IsEnabled();
}

//-------------------------------------------------------------------------
void ODbAdminDialog::applyChangesAsync(const OPageSettings* _pUseTheseSettings)
{
    DBG_ASSERT(isApplyable(), "ODbAdminDialog::applyChangesAsync: invalid call!");
    DBG_ASSERT((0 == m_nPostApplyPage) && !m_pPostApplyPageSettings, "ODbAdminDialog::applyChangesAsync: already doing this!");

    sal_uInt16 nCurrentPageId = GetCurPageId();

    // get the view settings
    if (!_pUseTheseSettings)
    {
        OGenericAdministrationPage* pCurrentPage = static_cast<OGenericAdministrationPage*>(GetTabPage(nCurrentPageId));
        OPageSettings* pViewSettings = NULL;
        if (pCurrentPage)
        {   // get the pages current view settings
            pViewSettings = pCurrentPage->createViewSettings();
            pCurrentPage->fillViewSettings(pViewSettings);
        }
        m_pPostApplyPageSettings = pViewSettings;
    }
    else
        m_pPostApplyPageSettings = _pUseTheseSettings;

    // remember the page id
    m_nPostApplyPage = nCurrentPageId;

    PostUserEvent(LINK(this, ODbAdminDialog, OnAsyncApplyChanges));
}

//-------------------------------------------------------------------------
short ODbAdminDialog::Ok()
{
    SfxTabDialog::Ok();
    disabledUI();
    return ( AR_LEAVE_MODIFIED == implApplyChanges() ) ? RET_OK : RET_CANCEL;
        // TODO : AR_ERROR is not handled correctly, we always close the dialog here
}

//-------------------------------------------------------------------------
void ODbAdminDialog::PageCreated(USHORT _nId, SfxTabPage& _rPage)
{
    // register ourself as modified listener
    static_cast<OGenericAdministrationPage&>(_rPage).SetModifiedHandler(LINK(this, ODbAdminDialog, OnDatasourceModifed));

    // some registrations which depend on the type of the page
    switch (_nId)
    {
        case PAGE_GENERAL:
            static_cast<OGeneralPage&>(_rPage).SetTypeSelectHandler(LINK(this, ODbAdminDialog, OnTypeSelected));
            static_cast<OGeneralPage&>(_rPage).SetNameModifyHandler(LINK(this, ODbAdminDialog, OnNameModified));
            static_cast<OGeneralPage&>(_rPage).SetNameValidationHandler(LINK(this, ODbAdminDialog, OnValidateName));
            static_cast<OGeneralPage&>(_rPage).setServiceFactory(m_xORB);
            static_cast<OGeneralPage&>(_rPage).SetAdminDialog(this);
            break;
        case PAGE_TABLESUBSCRIPTION:
            static_cast<OTableSubscriptionPage&>(_rPage).setServiceFactory(m_xORB);
            static_cast<OTableSubscriptionPage&>(_rPage).SetAdminDialog(this);
            break;
        case PAGE_DOCUMENTLINKS:
        case PAGE_QUERYADMINISTRATION:
            static_cast<OCollectionPage&>(_rPage).setServiceFactory(m_xORB);
            static_cast<OCollectionPage&>(_rPage).SetAdminDialog(this);
            break;
        case TAB_PAG_ADABAS_SETTINGS:
            static_cast<OAdabasAdminSettings&>(_rPage).SetAdminDialog(this);
            break;
        case TAB_PAGE_USERADMIN:
            static_cast<OUserAdmin&>(_rPage).setServiceFactory(m_xORB);
            static_cast<OUserAdmin&>(_rPage).SetAdminDialog(this);
            break;
    }

    AdjustLayout();
    Window *pWin = GetViewWindow();
    if(pWin)
        pWin->Invalidate();

    SfxTabDialog::PageCreated(_nId, _rPage);
}

//-------------------------------------------------------------------------
SfxItemSet* ODbAdminDialog::createItemSet(SfxItemSet*& _rpSet, SfxItemPool*& _rpPool, SfxPoolItem**& _rppDefaults, ODsnTypeCollection* _pTypeCollection)
{
    // just to be sure ....
    _rpSet = NULL;
    _rpPool = NULL;
    _rppDefaults = NULL;

    const ::rtl::OUString sFilterAll( "%", 1, RTL_TEXTENCODING_ASCII_US );
    // create and initialize the defaults
    _rppDefaults = new SfxPoolItem*[DSID_LAST_ITEM_ID - DSID_FIRST_ITEM_ID + 1];
    SfxPoolItem** pCounter = _rppDefaults;  // want to modify this without affecting the out param _rppDefaults
    *pCounter++ = new SfxStringItem(DSID_NAME, String());
    *pCounter++ = new SfxStringItem(DSID_ORIGINALNAME, String());
    *pCounter++ = new SfxStringItem(DSID_CONNECTURL, _pTypeCollection ? _pTypeCollection->getDatasourcePrefix(DST_JDBC) : String());
    *pCounter++ = new OStringListItem(DSID_TABLEFILTER, Sequence< ::rtl::OUString >(&sFilterAll, 1));
    *pCounter++ = new DbuTypeCollectionItem(DSID_TYPECOLLECTION, _pTypeCollection);
    *pCounter++ = new SfxBoolItem(DSID_INVALID_SELECTION, sal_False);
    *pCounter++ = new SfxBoolItem(DSID_READONLY, sal_False);
    *pCounter++ = new SfxStringItem(DSID_USER, String());
    *pCounter++ = new SfxStringItem(DSID_PASSWORD, String());
    *pCounter++ = new SfxStringItem(DSID_ADDITIONALOPTIONS, String());
    *pCounter++ = new SfxStringItem(DSID_CHARSET, String());
    *pCounter++ = new SfxBoolItem(DSID_PASSWORDREQUIRED, sal_False);
    *pCounter++ = new SfxBoolItem(DSID_SHOWDELETEDROWS, sal_False);
    *pCounter++ = new SfxBoolItem(DSID_ALLOWLONGTABLENAMES, sal_False);
    *pCounter++ = new SfxStringItem(DSID_JDBCDRIVERCLASS, String());
    *pCounter++ = new SfxStringItem(DSID_FIELDDELIMITER, ';');
    *pCounter++ = new SfxStringItem(DSID_TEXTDELIMITER, '"');
    *pCounter++ = new SfxStringItem(DSID_DECIMALDELIMITER, '.');
    *pCounter++ = new SfxStringItem(DSID_THOUSANDSDELIMITER, ',');
    *pCounter++ = new SfxStringItem(DSID_TEXTFILEEXTENSION, String::CreateFromAscii("txt"));
    *pCounter++ = new SfxBoolItem(DSID_TEXTFILEHEADER, sal_True);
    *pCounter++ = new SfxBoolItem(DSID_NEWDATASOURCE, sal_False);
    *pCounter++ = new SfxBoolItem(DSID_DELETEDDATASOURCE, sal_False);
    *pCounter++ = new SfxBoolItem(DSID_SUPPRESSVERSIONCL, sal_True);
    *pCounter++ = new OPropertySetItem(DSID_DATASOURCE_UNO);
    *pCounter++ = new SfxBoolItem(DSID_CONN_SHUTSERVICE, sal_False);
    *pCounter++ = new SfxInt32Item(DSID_CONN_DATAINC, 20);
    *pCounter++ = new SfxInt32Item(DSID_CONN_CACHESIZE, 20);
    *pCounter++ = new SfxStringItem(DSID_CONN_CTRLUSER, String());
    *pCounter++ = new SfxStringItem(DSID_CONN_CTRLPWD, String());
    *pCounter++ = new SfxBoolItem(DSID_USECATALOG, sal_False);
    *pCounter++ = new SfxStringItem(DSID_CONN_LDAP_HOSTNAME, String());
    *pCounter++ = new SfxStringItem(DSID_CONN_LDAP_BASEDN, String());
    *pCounter++ = new SfxInt32Item(DSID_CONN_LDAP_PORTNUMBER, 389);
    *pCounter++ = new SfxInt32Item(DSID_CONN_LDAP_ROWCOUNT, 100);
    *pCounter++ = new SfxBoolItem(DSID_SQL92CHECK, sal_False);
    *pCounter++ = new SfxStringItem(DSID_AUTOINCREMENTVALUE, String());
    *pCounter++ = new SfxStringItem(DSID_AUTORETRIEVEVALUE, String());
    *pCounter++ = new SfxBoolItem(DSID_AUTORETRIEVEENABLED, sal_False);



    // create the pool
    static SfxItemInfo __READONLY_DATA aItemInfos[DSID_LAST_ITEM_ID - DSID_FIRST_ITEM_ID + 1] =
    {
        {0,0},
        {0,0},
        {0,0},
        {0,0},
        {0,0},
        {0,0},
        {0,0},
        {0,0},
        {0,0},
        {0,0},
        {0,0},
        {0,0},
        {0,0},
        {0,0},
        {0,0},
        {0,0},
        {0,0},
        {0,0},
        {0,0},
        {0,0},
        {0,0},
        {0,0},
        {0,0},
        {0,0},
        {0,0},
        {0,0},
        {0,0},
        {0,0},
        {0,0},
        {0,0},
        {0,0},
        {0,0},
        {0,0},
        {0,0},
        {0,0},
        {0,0},
        {0,0},
        {0,0},
        {0,0},
    };

    OSL_ENSURE(sizeof(aItemInfos)/sizeof(aItemInfos[0]) == DSID_LAST_ITEM_ID,"Invlaid Ids!");
    _rpPool = new SfxItemPool(String::CreateFromAscii("DSAItemPool"), DSID_FIRST_ITEM_ID, DSID_LAST_ITEM_ID,
        aItemInfos, _rppDefaults);
    _rpPool->FreezeIdRanges();

    // and, finally, the set
    _rpSet = new SfxItemSet(*_rpPool, sal_True);

    return _rpSet;
}

//-------------------------------------------------------------------------
void ODbAdminDialog::destroyItemSet(SfxItemSet*& _rpSet, SfxItemPool*& _rpPool, SfxPoolItem**& _rppDefaults)
{
    // _first_ delete the set (refering the pool)
    if (_rpSet)
    {
        delete _rpSet;
        _rpSet = NULL;
    }

    // delete the pool
    if (_rpPool)
    {
        _rpPool->ReleaseDefaults(sal_True);
            // the "true" means delete the items, too
        delete _rpPool;
        _rpPool = NULL;
    }

    // reset the defaults ptr
    _rppDefaults = NULL;
        // no need to explicitly delete the defaults, this has been done by the ReleaseDefaults
}

//-------------------------------------------------------------------------
IMPL_LINK(ODbAdminDialog, OnDatasourceSelected, ListBox*, _pBox)
{
    // sometimes, the listbox calls the select handler even if the user simply clicked onto the already selected
    // entry. To avoid problems raising from this, we check this condition and do nothing then
    // 97122 - 30.01.2002 - fs@openoffice.org
    if ( DELETED == m_aSelector.getSelectedState() )
    {
        if ( m_aSelector.getSelectedAccessKey() == m_nCurrentDeletedDataSource )
            return 0L;
    }
    else
        if ( m_aSelector.getSelected() == String( m_sCurrentDatasource ) )
            return 0L;


    if (!prepareSwitchDatasource())
    {   // restore the old selection
        if (m_sCurrentDatasource.getLength())
            m_aSelector.select(m_sCurrentDatasource);
        else
            m_aSelector.select(m_nCurrentDeletedDataSource);
    }

    // switch the content of the pages
    if (DELETED == m_aSelector.getSelectedState())
        implSelectDeleted(m_aSelector.getSelectedAccessKey());
    else
        implSelectDatasource(m_aSelector.getSelected());

    return 0L;
}

//-------------------------------------------------------------------------
IMPL_LINK(ODbAdminDialog, OnDatasourceModifed, SfxTabPage*, _pTabPage)
{
    // check if the currently selected entry is already marked as modified
    String sCurrentlySelected = m_aSelector.getSelected();
    if (m_aDatasources[sCurrentlySelected].isModified())
        // yes -> nothing to do
        return 0L;

    // no -> mark the item as modified
    m_aSelector.modified(sCurrentlySelected);
    m_aDatasources.update(sCurrentlySelected, *pExampleSet);

    // enable the apply button
    GetApplyButton()->Enable(sal_True);

    return 0L;
}

//-------------------------------------------------------------------------
IMPL_LINK(ODbAdminDialog, OnValidateName, OGeneralPage*, _pTabPage)
{
    ::rtl::OUString sNewStringSuggestion = _pTabPage->GetCurrentName();

    // check if there's already a data source with the suggested name
    ConstStringSetIterator aExistentPos = m_aValidDatasources.find(sNewStringSuggestion);
        // !! m_aValidDatasources contains _all_ data source names _except_ the currently selected one !!

    sal_Bool bValid = m_aValidDatasources.end() == aExistentPos;

    return bValid ? 1L : 0L;
}

//-------------------------------------------------------------------------
IMPL_LINK(ODbAdminDialog, OnNameModified, OGeneralPage*, _pTabPage)
{
    if (!m_bResetting)
    {
        sal_Bool bValid = ( 0 != OnValidateName( _pTabPage ) );

        // the user is not allowed to leave the current data source (or to commit the dialog) as long
        // as the name is invalid
        m_aSelector.Enable( bValid && m_aDatasources.isValid() && ( omFull == getMode() ) );
        GetOKButton().Enable(bValid);
        GetApplyButton()->Enable(bValid);

        // if this is the first modification for this data source, we have to adjust the DS list accordingly
        String sSelected = m_aSelector.getSelected();
        if (!m_aDatasources[sSelected].isModified())
        {   // (we could do it all the time here, but as this link is called every time a single character
            // of the name changes, this maybe would be too expensive.)
            m_aSelector.modified(sSelected);
            m_aDatasources.update(sSelected, *pExampleSet);
        }

        // enable the apply button
        GetApplyButton()->Enable(sal_True && bValid);

        return bValid ? 1L : 0L;
    }
    return 1L;
}
// -----------------------------------------------------------------------------
void ODbAdminDialog::removeDetailPages()
{
    // remove all current detail pages
    while (m_aCurrentDetailPages.size())
    {
        RemoveTabPage((USHORT)m_aCurrentDetailPages.top());
        m_aCurrentDetailPages.pop();
    }
}

// -----------------------------------------------------------------------------
void ODbAdminDialog::addDetailPage(USHORT _nPageId, USHORT _nTextId, CreateTabPage _pCreateFunc)
{
    // open our own resource block, as the page titles are strings local to this block
    OLocalResourceAccess aDummy(DLG_DATABASE_ADMINISTRATION, RSC_TABDIALOG);

    AddTabPage(_nPageId, String(ResId(_nTextId)), _pCreateFunc, 0, sal_False, 1);
    m_aCurrentDetailPages.push(_nPageId);
}

//-------------------------------------------------------------------------
IMPL_LINK(ODbAdminDialog, OnTypeSelected, OGeneralPage*, _pTabPage)
{
    // doe have to reset the "password required" flag to false? (in case the datasource does not support passwords)
    sal_Bool bResetPasswordRequired = sal_False;
    _pTabPage->enableConnectionURL();

    // remove all current detail pages
    removeDetailPages();

    // and insert the new ones
    switch (_pTabPage->GetSelectedType())
    {
        case DST_DBASE:
            addDetailPage(PAGE_DBASE, STR_PAGETITLE_DBASE, ODbaseDetailsPage::Create);
            bResetPasswordRequired = sal_True;
            break;

        case DST_JDBC:
            addDetailPage(PAGE_JDBC, STR_PAGETITLE_JDBC, OJdbcDetailsPage::Create);
            break;

        case DST_ADO:
            addDetailPage(PAGE_ADO, STR_PAGETITLE_ADO, OAdoDetailsPage::Create);
            break;

        case DST_TEXT:
            addDetailPage(PAGE_TEXT, STR_PAGETITLE_TEXT, OTextDetailsPage::Create);
            bResetPasswordRequired = sal_True;
            break;

        case DST_ODBC:
            addDetailPage(PAGE_ODBC, STR_PAGETITLE_ODBC, OOdbcDetailsPage::Create);
            break;

        case DST_MYSQL_ODBC:
        case DST_MYSQL_JDBC:
            addDetailPage(PAGE_MYSQL, STR_PAGETITLE_MYSQL, OMySQLDetailsPage::Create);
            break;

        case DST_ADABAS:
            // for adabas we have more than one page
            // CAUTION: the order of inserting pages matters.
            // the major detail page should be inserted last always (thus, it becomes the first page after
            // the general page)
            addDetailPage(TAB_PAGE_USERADMIN, STR_PAGETITLE_USERADMIN, OUserAdmin::Create);
            addDetailPage(TAB_PAG_ADABAS_SETTINGS, STR_PAGETITLE_ADABAS_STATISTIC, OAdabasAdminSettings::Create);
            addDetailPage(PAGE_ADABAS, STR_PAGETITLE_ADABAS, OAdabasDetailsPage::Create);
            break;

        case DST_ADDRESSBOOK:
        {
            String sConnectionURL = _pTabPage->getConnectionURL( );
            switch ( AddressBookTypes::getAddressType( sConnectionURL ) )
            {
                case ABT_LDAP:
                    addDetailPage(PAGE_LDAP,STR_PAGETITLE_LDAP,OLDAPDetailsPage::Create);
                    break;

                case ABT_UNKNOWN:
                    // no sub-type selected, yet
                    // -> default it
#ifdef UNX
                    sConnectionURL = AddressBookTypes::getAddressURL( ABT_MORK );
#else
                    sConnectionURL = AddressBookTypes::getAddressURL( ABT_OE );
#endif
                    // re-initialize the current page
                    _pTabPage->changeConnectionURL( sConnectionURL );
                    break;
            }
            _pTabPage->disableConnectionURL();
        }
        break;
    }

    if (bResetPasswordRequired)
    {
        GetInputSetImpl()->Put(SfxBoolItem(DSID_PASSWORDREQUIRED, sal_False));
        if (pExampleSet)
            pExampleSet->Put(SfxBoolItem(DSID_PASSWORDREQUIRED, sal_False));
    }

    return 0L;
}

//-------------------------------------------------------------------------
Reference< XPropertySet > ODbAdminDialog::getDatasource(const ::rtl::OUString& _rName)
{
    DBG_ASSERT(m_aDatasources.isValid(), "ODbAdminDialog::getDatasource : have no database context!");
    if (!m_aDatasources.exists(_rName))
        return Reference< XPropertySet >();

    return m_aDatasources[_rName]->getDatasource();
}

//-------------------------------------------------------------------------
void ODbAdminDialog::implSelectDeleted(sal_Int32 _nKey)
{
    m_aSelector.select(_nKey);

    // insert the previously selected data source into our "all valid datasources" set
    if (m_sCurrentDatasource.getLength())   // previous selection was not on a deleted data source
        m_aValidDatasources.insert(m_sCurrentDatasource);
    m_sCurrentDatasource = ::rtl::OUString();
    m_nCurrentDeletedDataSource = _nKey;

    // reset the tag pages
    resetPages(Reference< XPropertySet >(), sal_True);

    // disallow reset for deleted pages
    //  GetResetButton().Enable(sal_False);
}

//-------------------------------------------------------------------------
void ODbAdminDialog::implSelectDatasource(const ::rtl::OUString& _rRegisteredName)
{
    m_aSelector.select(_rRegisteredName);

    // insert the previously selected data source into our set
    if (m_sCurrentDatasource.getLength())   // previous selection was not on a deleted data source
        m_aValidDatasources.insert(m_sCurrentDatasource);
    m_sCurrentDatasource = _rRegisteredName;
    m_nCurrentDeletedDataSource = -1;
    // remove the now selected data source from our set
    m_aValidDatasources.erase(m_sCurrentDatasource);

    // reset the tag pages
    Reference< XPropertySet > xDatasource = getDatasource(_rRegisteredName);
    resetPages(xDatasource, sal_False);

    // allow reset for non-deleted pages
    //  GetResetButton().Enable(sal_True);
}

//-------------------------------------------------------------------------
void ODbAdminDialog::resetPages(const Reference< XPropertySet >& _rxDatasource, sal_Bool _bDeleted)
{
    // the selection is valid if and only if we have a datasource now
    GetInputSetImpl()->Put(SfxBoolItem(DSID_INVALID_SELECTION, !_rxDatasource.is()));
        // (sal_False tells the tab pages to disable and reset all their controls, which is different
        // from "just set them to readonly")

    // reset the pages

    sal_uInt16 nOldSelectedPage = GetCurPageId();

    // prevent flicker
    SetUpdateMode(sal_False);

    m_bResetting = sal_True;
    ShowPage(PAGE_GENERAL);
    m_bResetting = sal_False;

    // remove all tab pages (except the general one)
    // remove all current detail pages
    while (m_aCurrentDetailPages.size())
    {
        RemoveTabPage((USHORT)m_aCurrentDetailPages.top());
        m_aCurrentDetailPages.pop();
    }
    // remove the table/query tab pages
    RemoveTabPage(PAGE_TABLESUBSCRIPTION);
    RemoveTabPage(PAGE_QUERYADMINISTRATION);
    RemoveTabPage(PAGE_DOCUMENTLINKS);

    // remove all items which relate to indirect properties from the input set
    // (without this, the following may happen: select an arbitrary data source where some indirect properties
    // are set. Select another data source of the same type, where the indirect props are not set (yet). Then,
    // the indirect property values of the first ds are shown in the second ds ...)
    for (   ConstMapInt2StringIterator aIndirect = m_aIndirectPropTranslator.begin();
            aIndirect != m_aIndirectPropTranslator.end();
            ++aIndirect
        )
        GetInputSetImpl()->ClearItem( (sal_uInt16)aIndirect->first );

    // extract all relevant data from the property set of the data source
    translateProperties(_rxDatasource, *GetInputSetImpl());

    // reset some meta data items in the input set which are for tracking the state of the current ds
    GetInputSetImpl()->Put(SfxBoolItem(DSID_NEWDATASOURCE, sal_False));
    GetInputSetImpl()->Put(SfxBoolItem(DSID_DELETEDDATASOURCE, _bDeleted));
    GetInputSetImpl()->Put(OPropertySetItem(DSID_DATASOURCE_UNO, _rxDatasource));

    // fill in the remembered settings for the data source
    if (m_sCurrentDatasource.getLength())   // the current datasource is not deleted
        if (m_aDatasources[m_sCurrentDatasource]->isModified()) // the current data source was modified before
            GetInputSetImpl()->Put(*m_aDatasources[m_sCurrentDatasource]->getModifications());

    // propagate this set as our new input set and reset the example set
    SetInputSet(GetInputSetImpl());
    delete pExampleSet;
    pExampleSet = new SfxItemSet(*GetInputSetImpl());

    // and again, add the non-details tab pages
    if ( !_bDeleted )
    {
        OLocalResourceAccess aDummy(DLG_DATABASE_ADMINISTRATION, RSC_TABDIALOG);
        AddTabPage(PAGE_TABLESUBSCRIPTION, String(ResId(STR_PAGETITLE_TABLESUBSCRIPTION)), OTableSubscriptionPage::Create, NULL);
        if ( omFull == getMode() )
        {
            AddTabPage(PAGE_QUERYADMINISTRATION, String(ResId(STR_PAGETITLE_QUERIES)), OQueryAdministrationPage::Create, NULL);
            AddTabPage(PAGE_DOCUMENTLINKS, String(ResId(STR_PAGETITLE_DOCUMENTS)), ODocumentLinksPage::Create, NULL);
        }
    }

    m_bResetting = sal_True;

    // unfortunately, I have no chance if a page with ID nOldSelectedPage still exists
    // So we first select the general page (which is always available) and the the old page (which may not be there)

    ShowPage( PAGE_GENERAL );
    // propagate the new data to the general tab page the general tab page
    SfxTabPage* pGeneralPage = GetTabPage(PAGE_GENERAL);
    if (pGeneralPage)
        pGeneralPage->Reset(*GetInputSetImpl());
    // if this is NULL, the page has not been created yet, which means we're called before the
    // dialog was displayed (probably from inside the ctor)

    if ( isUIEnabled() )
    {
        ShowPage( nOldSelectedPage );
        // same for the previously selected page, if it is still there
        SfxTabPage* pOldPage = GetTabPage( nOldSelectedPage );
        if (pOldPage)
            pOldPage->Reset(*GetInputSetImpl());
    }

    SetUpdateMode(sal_True);

    m_bResetting = sal_False;
}

//-------------------------------------------------------------------------
Any ODbAdminDialog::implTranslateProperty(const SfxPoolItem* _pItem)
{
    // translate the SfxPoolItem
    Any aValue;
    if (_pItem->ISA(SfxStringItem))
        aValue <<= ::rtl::OUString(PTR_CAST(SfxStringItem, _pItem)->GetValue().GetBuffer());
    else if (_pItem->ISA(SfxBoolItem))
        aValue = ::cppu::bool2any(PTR_CAST(SfxBoolItem, _pItem)->GetValue());
    else if (_pItem->ISA(SfxInt32Item))
        aValue <<= PTR_CAST(SfxInt32Item, _pItem)->GetValue();
    else if (_pItem->ISA(OStringListItem))
        aValue <<= PTR_CAST(OStringListItem, _pItem)->getList();
    else
    {
        DBG_ERROR("ODbAdminDialog::implTranslateProperty: unsupported item type!");
        return aValue;
    }

    return aValue;
}

//-------------------------------------------------------------------------
void ODbAdminDialog::implTranslateProperty(const Reference< XPropertySet >& _rxSet, const ::rtl::OUString& _rName, const SfxPoolItem* _pItem)
{
    Any aValue = implTranslateProperty(_pItem);
    try
    {
        _rxSet->setPropertyValue(_rName, aValue);
    }
    catch(Exception&)
    {
#ifdef DBG_UTIL
        ::rtl::OString sMessage("ODbAdminDialog::implTranslateProperty: could not set the property ");
        sMessage += ::rtl::OString(_rName.getStr(), _rName.getLength(), RTL_TEXTENCODING_ASCII_US);
        sMessage += ::rtl::OString("!");
        DBG_ERROR(sMessage.getStr());
#endif
    }
}

//-------------------------------------------------------------------------
namespace
{
    sal_Bool implCheckItemType( SfxItemSet& _rSet, const USHORT _nId, const TypeId _nExpectedItemType )
    {
        sal_Bool bCorrectType = sal_False;

        SfxItemPool* pPool = _rSet.GetPool();
        DBG_ASSERT( pPool, "implCheckItemType: invalid item pool!" );
        if ( pPool )
        {
            const SfxPoolItem& rDefItem = pPool->GetDefaultItem( _nId );
            bCorrectType = rDefItem.IsA( _nExpectedItemType );
        }
        return bCorrectType;
    }

}

#ifdef DBG_UTIL
//-------------------------------------------------------------------------
::rtl::OString ODbAdminDialog::translatePropertyId( sal_Int32 _nId )
{
    ::rtl::OUString aString;

    MapInt2String::const_iterator aPos = m_aDirectPropTranslator.find( _nId );
    if ( m_aDirectPropTranslator.end() != aPos )
    {
        aString = aPos->second;
    }
    else
    {
        MapInt2String::const_iterator aPos = m_aIndirectPropTranslator.find( _nId );
        if ( m_aIndirectPropTranslator.end() != aPos )
            aString = aPos->second;
    }

    ::rtl::OString aReturn( aString.getStr(), aString.getLength(), RTL_TEXTENCODING_ASCII_US );
    return aReturn;
}
#endif

//-------------------------------------------------------------------------
void ODbAdminDialog::implTranslateProperty( SfxItemSet& _rSet, sal_Int32  _nId, const Any& _rValue )
{
    USHORT nId = (USHORT)_nId;
    switch (_rValue.getValueType().getTypeClass())
    {
        case TypeClass_STRING:
            if ( implCheckItemType( _rSet, nId, SfxStringItem::StaticType() ) )
            {
                ::rtl::OUString sValue;
                _rValue >>= sValue;
                _rSet.Put(SfxStringItem(nId, sValue.getStr()));
            }
            else
                DBG_ERROR(
                    (   ::rtl::OString( "ODbAdminDialog::implTranslateProperty: invalid property value (" )
                    +=  ::rtl::OString( translatePropertyId( _nId ) )
                    +=  ::rtl::OString( " should be no string)!" )
                    ).getStr()
                );
            break;

        case TypeClass_BOOLEAN:
            if ( implCheckItemType( _rSet, nId, SfxBoolItem::StaticType() ) )
            {
                _rSet.Put(SfxBoolItem(nId, ::cppu::any2bool(_rValue)));
            }
            else
                DBG_ERROR(
                    (   ::rtl::OString( "ODbAdminDialog::implTranslateProperty: invalid property value (" )
                    +=  ::rtl::OString( translatePropertyId( _nId ) )
                    +=  ::rtl::OString( " should be no boolean)!" )
                    ).getStr()
                );
            break;

        case TypeClass_LONG:
            if ( implCheckItemType( _rSet, nId, SfxInt32Item::StaticType() ) )
            {
                sal_Int32 nValue = 0;
                _rValue >>= nValue;
                _rSet.Put( SfxInt32Item( nId, nValue ) );
            }
            else
                DBG_ERROR(
                    (   ::rtl::OString( "ODbAdminDialog::implTranslateProperty: invalid property value (" )
                    +=  ::rtl::OString( translatePropertyId( _nId ) )
                    +=  ::rtl::OString( " should be no int)!" )
                    ).getStr()
                );
            break;

        case TypeClass_SEQUENCE:
            if ( implCheckItemType( _rSet, nId, OStringListItem::StaticType() ) )
            {
                // determine the element type
                TypeDescription aTD(_rValue.getValueType());
                typelib_IndirectTypeDescription* pSequenceTD =
                    reinterpret_cast< typelib_IndirectTypeDescription* >(aTD.get());
                DBG_ASSERT(pSequenceTD && pSequenceTD->pType, "ODbAdminDialog::implTranslateProperty: invalid sequence type!");

                Type aElementType(pSequenceTD->pType);
                switch (aElementType.getTypeClass())
                {
                    case TypeClass_STRING:
                    {
                        Sequence< ::rtl::OUString > aStringList;
                        _rValue >>= aStringList;
                        _rSet.Put(OStringListItem(nId, aStringList));
                    }
                    break;
                    default:
                        DBG_ERROR("ODbAdminDialog::implTranslateProperty: unsupported property value type!");
                }
            }
            else
                DBG_ERROR(
                    (   ::rtl::OString( "ODbAdminDialog::implTranslateProperty: invalid property value (" )
                    +=  ::rtl::OString( translatePropertyId( _nId ) )
                    +=  ::rtl::OString( " should be no string sequence)!" )
                    ).getStr()
                );
            break;

        case TypeClass_VOID:
            _rSet.ClearItem(nId);
            break;

        default:
            DBG_ERROR("ODbAdminDialog::implTranslateProperty: unsupported property value type!");
    }
}

//-------------------------------------------------------------------------
struct PropertyValueLess
{
    bool operator() (const PropertyValue& x, const PropertyValue& y) const
        { return x.Name < y.Name ? true : false; }      // construct prevents a MSVC6 warning
};
DECLARE_STL_SET( PropertyValue, PropertyValueLess, PropertyValueSet);

//........................................................................
void ODbAdminDialog::translateProperties(const Reference< XPropertySet >& _rxSource, SfxItemSet& _rDest)
{
    ::rtl::OUString sNewConnectURL, sName, sUid, sPwd;
    Sequence< ::rtl::OUString > aTableFitler;
    sal_Bool bPasswordRequired = sal_False;
    sal_Bool bReadOnly = sal_True;

    if (_rxSource.is())
    {
        for (   ConstMapInt2StringIterator aDirect = m_aDirectPropTranslator.begin();
                aDirect != m_aDirectPropTranslator.end();
                ++aDirect
            )
        {
            // get the property value
            Any aValue;
            try
            {
                aValue = _rxSource->getPropertyValue(aDirect->second);
            }
            catch(Exception&)
            {
#if DBG_UTIL
                ::rtl::OString aMessage("ODbAdminDialog::translateProperties: could not extract the property ");
                aMessage += ::rtl::OString(aDirect->second.getStr(), aDirect->second.getLength(), RTL_TEXTENCODING_ASCII_US);
                aMessage += ::rtl::OString("!");
                DBG_ERROR(aMessage.getStr());
#endif
            }
            // transfer it into an item
            implTranslateProperty(_rDest, aDirect->first, aValue);
        }

        // get the additional informations
        Sequence< PropertyValue > aAdditionalInfo;
        try
        {
            _rxSource->getPropertyValue(PROPERTY_INFO) >>= aAdditionalInfo;
        }
        catch(Exception&) { }

        // collect the names of the additional settings
        const PropertyValue* pAdditionalInfo = aAdditionalInfo.getConstArray();
        PropertyValueSet aInfos;
        for (sal_Int32 i=0; i<aAdditionalInfo.getLength(); ++i, ++pAdditionalInfo)
        {
            if (0 == pAdditionalInfo->Name.compareToAscii("JDBCDRV"))
            {   // compatibility
                PropertyValue aCompatibility(*pAdditionalInfo);
                aCompatibility.Name = ::rtl::OUString::createFromAscii("JavaDriverClass");
                aInfos.insert(aCompatibility);
            }
            else
                aInfos.insert(*pAdditionalInfo);
        }

        // go through all known translations and check if we have such a setting
        PropertyValue aSearchFor;
        for (   ConstMapInt2StringIterator aIndirect = m_aIndirectPropTranslator.begin();
                aIndirect != m_aIndirectPropTranslator.end();
                ++aIndirect
            )
        {
            aSearchFor.Name = aIndirect->second;
            ConstPropertyValueSetIterator aInfoPos = aInfos.find(aSearchFor);
            if (aInfos.end() != aInfoPos)
                // the property is contained in the info sequence
                // -> transfer it into an item
                implTranslateProperty(_rDest, aIndirect->first, aInfoPos->Value);
        }
    }
}

//-------------------------------------------------------------------------
void ODbAdminDialog::translateProperties(const SfxItemSet& _rSource, const Reference< XPropertySet >& _rxDest)
{
    DBG_ASSERT(_rxDest.is(), "ODbAdminDialog::translateProperties: invalid property set!");
    if (!_rxDest.is())
        return;

    // the property set info
    Reference< XPropertySetInfo > xInfo;
    try { xInfo = _rxDest->getPropertySetInfo(); }
    catch(Exception&) { }

    // -----------------------------
    // transfer the direct propertis
    for (   ConstMapInt2StringIterator aDirect = m_aDirectPropTranslator.begin();
            aDirect != m_aDirectPropTranslator.end();
            ++aDirect
        )
    {
        const SfxPoolItem* pCurrentItem = _rSource.GetItem((USHORT)aDirect->first);
        if (pCurrentItem)
        {
            sal_Int16 nAttributes = PropertyAttribute::READONLY;
            if (xInfo.is())
            {
                try { nAttributes = xInfo->getPropertyByName(aDirect->second).Attributes; }
                catch(Exception&) { }
            }
            if ((nAttributes & PropertyAttribute::READONLY) == 0)
                implTranslateProperty(_rxDest, aDirect->second, pCurrentItem);
        }
    }

    // -------------------------------
    // now for the indirect properties

    Sequence< PropertyValue > aInfo;
    // the original properties
    try
    {
        _rxDest->getPropertyValue(PROPERTY_INFO) >>= aInfo;
    }
    catch(Exception&) { }

    // overwrite and extend them
    fillDatasourceInfo(_rSource, aInfo);

    // and propagate the (newly composed) sequence to the set
    try
    {
        _rxDest->setPropertyValue(PROPERTY_INFO, makeAny(aInfo));
    }
    catch(Exception&)
    {
        DBG_ERROR("ODbAdminDialog::translateProperties: could not propagate the composed info sequence to the property set!");
    }
}

//-------------------------------------------------------------------------
DATASOURCE_TYPE ODbAdminDialog::getDatasourceType(const SfxItemSet& _rSet) const
{
    SFX_ITEMSET_GET(_rSet, pConnectURL, SfxStringItem, DSID_CONNECTURL, sal_True);
    SFX_ITEMSET_GET(_rSet, pTypeCollection, DbuTypeCollectionItem, DSID_TYPECOLLECTION, sal_True);
    DBG_ASSERT(pConnectURL && pTypeCollection, "ODbAdminDialog::getDatasourceType: invalid items in the source set!");
    String sConnectURL = pConnectURL->GetValue();
    ODsnTypeCollection* pCollection = pTypeCollection->getCollection();
    DBG_ASSERT(pCollection, "ODbAdminDialog::getDatasourceType: invalid type collection!");
    return pCollection->getType(sConnectURL);
}

//-------------------------------------------------------------------------
sal_Bool ODbAdminDialog::hasAuthentication(const SfxItemSet& _rSet) const
{
    DATASOURCE_TYPE eType = getDatasourceType(_rSet);
    SFX_ITEMSET_GET(_rSet, pTypeCollection, DbuTypeCollectionItem, DSID_TYPECOLLECTION, sal_True);
    return pTypeCollection->getCollection()->hasAuthentication(eType);
}

//-------------------------------------------------------------------------
const sal_Int32* ODbAdminDialog::getRelevantItems(const SfxItemSet& _rSet) const
{
    DATASOURCE_TYPE eType = getDatasourceType(_rSet);
    const sal_Int32* pRelevantItems = NULL;
    switch (eType)
    {
        case DST_ADABAS:
            {
                static sal_Int32* pAdabasItems = NULL;
                if(!pAdabasItems)
                {
                    const sal_Int32* pFirstRelevantItems = OAdabasDetailsPage::getDetailIds();
                    const sal_Int32* pSecondRelevantItems = OAdabasAdminSettings::getDetailIds();
                    sal_Int32 nFLen = 0;
                    sal_Int32 nSLen = 0;

                    for(pRelevantItems = pFirstRelevantItems;pRelevantItems && *pRelevantItems;++pRelevantItems)
                        ++nFLen;

                    for(pRelevantItems = pSecondRelevantItems;pRelevantItems && *pRelevantItems;++pRelevantItems)
                        ++nSLen;

                    pAdabasItems = new sal_Int32[nFLen + nSLen + 1];
                    nFLen = 0;
                    for(pRelevantItems = pFirstRelevantItems;pRelevantItems && *pRelevantItems;++pRelevantItems)
                        pAdabasItems[nFLen++] = *pRelevantItems;

                    for(pRelevantItems = pSecondRelevantItems;pRelevantItems && *pRelevantItems;++pRelevantItems)
                        pAdabasItems[nFLen++] = *pRelevantItems;
                    pAdabasItems[nFLen] = 0;

                }
                pRelevantItems = pAdabasItems;
            }
            break;
        case DST_MYSQL_ODBC:
        case DST_MYSQL_JDBC:    pRelevantItems = OMySQLDetailsPage::getDetailIds(); break;
        case DST_JDBC:          pRelevantItems = OJdbcDetailsPage::getDetailIds(); break;
        case DST_ADO:           pRelevantItems = OAdoDetailsPage::getDetailIds(); break;
        case DST_ODBC:          pRelevantItems = OOdbcDetailsPage::getDetailIds(); break;
        case DST_ADDRESSBOOK:
            {
                String sConnectionURL;
                SFX_ITEMSET_GET(*GetExampleSet(), pUrlItem, SfxStringItem, DSID_CONNECTURL, sal_True);
                sConnectionURL = pUrlItem->GetValue();
                if ( ABT_LDAP == AddressBookTypes::getAddressType( sConnectionURL ) )
                    pRelevantItems = OLDAPDetailsPage::getDetailIds();
                else
                {
                    static sal_Int32 nRelevantIds[] = { 0 };
                    pRelevantItems = nRelevantIds;
                }
                break;
            }
        case DST_DBASE:         pRelevantItems = ODbaseDetailsPage::getDetailIds(); break;
        case DST_TEXT:          pRelevantItems = OTextDetailsPage::getDetailIds(); break;
        case DST_CALC:
            {
                // spreadsheet currently has no options page
                static sal_Int32 nRelevantIds[] = { 0 };
                pRelevantItems = nRelevantIds;
            }
            break;
    }
    return pRelevantItems;
}

//-------------------------------------------------------------------------
void ODbAdminDialog::fillDatasourceInfo(const SfxItemSet& _rSource, ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& _rInfo)
{
    // within the current "Info" sequence, replace the ones we can examine from the item set
    // (we don't just fill a completely new sequence with our own items, but we preserve any properties unknown to
    // us)

    // first determine which of all the items are relevant for the data source (depends on the connection url)
    const sal_Int32* pRelevantItems = getRelevantItems(_rSource);
    DBG_ASSERT(pRelevantItems, "ODbAdminDialog::translateProperties: invalid item ids got from the page!");

    // collect the translated property values for the relevant items
    PropertyValueSet aRelevantSettings;
    ConstMapInt2StringIterator aTranslation;
    while (pRelevantItems && *pRelevantItems)
    {
        const SfxPoolItem* pCurrent = _rSource.GetItem((USHORT)*pRelevantItems);
        aTranslation = m_aIndirectPropTranslator.find(*pRelevantItems);
        if (pCurrent && (m_aIndirectPropTranslator.end() != aTranslation))
            aRelevantSettings.insert(PropertyValue(aTranslation->second, 0, implTranslateProperty(pCurrent), PropertyState_DIRECT_VALUE));

        ++pRelevantItems;
    }

    // settings to preserve
    MapInt2String   aPreservedSettings;

    // now aRelevantSettings contains all the property values relevant for the current data source type,
    // check the original sequence if it already contains any of these values (which have to be overwritten, then)
    PropertyValue* pInfo = _rInfo.getArray();
    PropertyValue aSearchFor;
    sal_Int32 nObsoleteSetting = -1;
    for (sal_Int32 i=0; i<_rInfo.getLength(); ++i, ++pInfo)
    {
        aSearchFor.Name = pInfo->Name;
        PropertyValueSetIterator aOverwrittenSetting = aRelevantSettings.find(aSearchFor);
        if (aRelevantSettings.end() != aOverwrittenSetting)
        {   // the setting was present in the original sequence, and it is to be overwritten -> replace it
            *pInfo = *aOverwrittenSetting;
            aRelevantSettings.erase(aOverwrittenSetting);
        }
        else if (0 == pInfo->Name.compareToAscii("JDBCDRV"))
        {   // this is a compatibility setting, remove it from the sequence (it's replaced by JavaDriverClass)
            nObsoleteSetting = i;
        }
        else
            aPreservedSettings[i] = pInfo->Name;
    }
    if (-1 != nObsoleteSetting)
        ::comphelper::removeElementAt(_rInfo, nObsoleteSetting);

    if (aPreservedSettings.size())
    {   // check if there are settings which
        // * are known as indirect properties
        // * but not relevant for the current data source type
        // These settings have to be removed: If they're not relevant, we have no UI for changing them.
        // 25.06.2001 - 88004/87182 - frank.schoenheit@sun.com

        // for this, we need a string-controlled quick access to m_aIndirectPropTranslator
        StringSet aIndirectProps;
        ::std::transform(m_aIndirectPropTranslator.begin(),
                         m_aIndirectPropTranslator.end(),
                         ::std::insert_iterator<StringSet>(aIndirectProps,aIndirectProps.begin()),
                         ::std::select2nd<MapInt2String::value_type>());

        // now check the to-be-preserved props
        ::std::vector< sal_Int32 > aRemoveIndexes;
        sal_Int32 nPositionCorrector = 0;
        for (   ConstMapInt2StringIterator aPreserved = aPreservedSettings.begin();
                aPreserved != aPreservedSettings.end();
                ++aPreserved
            )
        {
            if (aIndirectProps.end() != aIndirectProps.find(aPreserved->second))
            {
#ifdef DBG_UTIL
                const ::rtl::OUString sName = aPreserved->second;
#endif
                aRemoveIndexes.push_back(aPreserved->first - nPositionCorrector);
                ++nPositionCorrector;
            }
        }
        // now finally remove all such props
        for (   ::std::vector< sal_Int32 >::const_iterator aRemoveIndex = aRemoveIndexes.begin();
                aRemoveIndex != aRemoveIndexes.end();
                ++aRemoveIndex
            )
            ::comphelper::removeElementAt(_rInfo, *aRemoveIndex);
#ifdef DBG_UTIL
        const PropertyValue* pWhatsLeft = _rInfo.getConstArray();
        const PropertyValue* pWhatsLeftEnd = pWhatsLeft + _rInfo.getLength();
        for (; pWhatsLeft != pWhatsLeftEnd; ++pWhatsLeft)
        {
            ::rtl::OUString sLookAtIt = pWhatsLeft->Name;
        }
#endif
    }

    // check which values are still left ('cause they were not present in the original sequence, but are to be set)
    sal_Int32 nOldLength = _rInfo.getLength();
    _rInfo.realloc(nOldLength + aRelevantSettings.size());
    PropertyValue* pAppendValues = _rInfo.getArray() + nOldLength;
    for (   ConstPropertyValueSetIterator aLoop = aRelevantSettings.begin();
            aLoop != aRelevantSettings.end();
            ++aLoop, ++pAppendValues
        )
    {
        *pAppendValues = *aLoop;
    }
}

//-------------------------------------------------------------------------
sal_Bool ODbAdminDialog::isValidNewName(const ::rtl::OUString& _rName) const
{
    DBG_ASSERT(_rName.getLength(), "ODbAdminDialog::isValidNewName: is not to be called with an empty name!");
        // checks for emptiness disabled for performance reasons

    // check if "all but the current" datasources aleady contain the to-be-checked name
    if (m_aValidDatasources.end() != m_aValidDatasources.find(_rName))
        return sal_False;
    // check if the currently selected data source allows the new name
    if (m_sCurrentDatasource.equals(_rName))
        return sal_False;

    return sal_True;
}

//-------------------------------------------------------------------------
::rtl::OUString ODbAdminDialog::getUniqueName() const
{
    ::rtl::OUString sBase = String(ModuleRes(STR_DATASOURCE_DEFAULTNAME)).GetBuffer();
    sBase += ::rtl::OUString(" ", 1, RTL_TEXTENCODING_ASCII_US);
    for (sal_Int32 i=1; i<65635; ++i)
    {
        ::rtl::OUString sCheck(sBase);
        sCheck += ::rtl::OUString::valueOf(i);

        if (!isValidNewName(sCheck))
            continue;

        // have a valid new name
        return sCheck;
    }

    DBG_ERROR("ODbAdminDialog::getUniqueName: no free names!");
    return ::rtl::OUString();
}

//-------------------------------------------------------------------------
sal_Bool ODbAdminDialog::prepareSwitchDatasource()
{
    // first ask the current page if it is allowed to leave
    if (!PrepareLeaveCurrentPage())
        // the page did not allow us to leave -> outta here
        return sal_False;

    // if the old data source is not a to-be-deleted one, save the modifications made in the tabpages
    if (m_sCurrentDatasource.getLength())
    {
        // remember the settings for this data source
        ODatasourceMap::ODatasourceInfo aPreviouslySelected = m_aDatasources[m_sCurrentDatasource];
        if (aPreviouslySelected.isModified())
            m_aDatasources.update(m_sCurrentDatasource, *pExampleSet);
        // (The modified flag is set as soon as any UI element has any change (e.g. a single new character in a edit line).
        // But when this flag is set, and other changes occur, no items are transfered.
        // That's why the above statement "if (isModified()) update()" makes sense, though it may not seem so :)

        // need a special handling for the name property
        if (aPreviouslySelected.isModified())
        {
            String sName = aPreviouslySelected.getName().getStr();
            DBG_ASSERT(m_sCurrentDatasource.equals(sName.GetBuffer()), "ODbAdminDialog::prepareSwitchDatasource: inconsistent names!");

            // first adjust the name which the datasource is stored under in our map.
            String sNewName = m_aDatasources.adjustRealName(sName);
            // if this was a real change ('cause the ds was stored under name "A", but the modifications set already contained
            // an DSID_NAME item "B", which has been corrected by the previous call), tell the selector window that
            // something changed
            if (!sNewName.Equals(sName))
            {
                // tell our selector window that the name has changed
                m_aSelector.renamed(sName, sNewName);
                // update our "current database"
                m_sCurrentDatasource = sNewName;
            }
        }
    }

    return sal_True;
}

//-------------------------------------------------------------------------
sal_Bool ODbAdminDialog::implInsertNew_noCheck(const ::rtl::OUString& _rName)
{
    // create a new datasource (not belonging to a context, yet)
    Reference< XPropertySet > xFloatingDatasource = m_aDatasources.createNew(_rName, GetInputSetImpl()->GetPool(), GetInputSetImpl()->GetRanges());
    if (!xFloatingDatasource.is())
    {
        ShowServiceNotAvailableError(this, String(SERVICE_SDB_DATASOURCE), sal_True);
        return sal_False;
    }

    GetInputSetImpl()->ClearItem();

    // insert a new entry for the new DS
    m_aSelector.insertNew(_rName);
    // update our "all-but the selected ds" structure
    m_aValidDatasources.insert(_rName);

    // and select this new entry
    m_aSelector.select(_rName);
    implSelectDatasource(_rName);

    // enable the apply button
    GetApplyButton()->Enable(sal_True);

    SfxTabPage* pGeneralPage = GetTabPage(PAGE_GENERAL);
    if (pGeneralPage)
        pGeneralPage->GrabFocus();

    return sal_True;
}

//-------------------------------------------------------------------------
IMPL_LINK(ODbAdminDialog, OnNewDatasource, Window*, _pWindow)
{
    if (!prepareSwitchDatasource())
        return 1L;

    ::rtl::OUString sNewName = getUniqueName();
    if (0 == sNewName.getLength())
        return 1L;  // no free names

    return implInsertNew_noCheck(sNewName) ? 0L : 1L;
}

//-------------------------------------------------------------------------
IMPL_LINK(ODbAdminDialog, OnDeleteDatasource, Window*, _pWindow)
{
    ::rtl::OUString sDeleteWhich = m_aSelector.getSelected();

    if (NEW == m_aSelector.getSelectedState())
    {
        // insert the previously selected data source into our "all valid datasources" set
        if (m_sCurrentDatasource.getLength())   // previous selection was not on a deleted data source
            m_aValidDatasources.insert(m_sCurrentDatasource);
        m_sCurrentDatasource = ::rtl::OUString();

        m_aDatasources.deleted(sDeleteWhich);
        m_aSelector.deleted(sDeleteWhich);
    }
    else
    {
        sal_Int32 nAccessKey = m_aDatasources.markDeleted(sDeleteWhich);
        if (-1 == nAccessKey)
            return 0L;

        // mark it as deleted
        m_aSelector.markDeleted(sDeleteWhich, nAccessKey);
        // re-select it (to reset the pages so they reflect the new state)
        implSelectDeleted(nAccessKey);
    }

    // mark the name as "available"
    m_aValidDatasources.erase(sDeleteWhich);

    // enable the apply button
    GetApplyButton()->Enable(sal_True);

    return 1L;
}

//-------------------------------------------------------------------------
IMPL_LINK(ODbAdminDialog, OnRestoreDatasource, Window*, _pWindow)
{
    sal_Int32 nAccessKey = m_aSelector.getSelectedAccessKey();
    ::rtl::OUString sName;
    if (m_aDatasources.restoreDeleted(nAccessKey, sName))
    {   // successfully restore the item in the map
        // -> restore it in the view, too
        ODatasourceMap::ODatasourceInfo aInfo(m_aDatasources[sName]);
        m_aSelector.restoreDeleted(nAccessKey, aInfo.isModified() ? MODIFIED : aInfo.isNew() ? NEW : CLEAN);

        implSelectDatasource(sName);
    }
    else
    {
        ErrorBox aError(this, ModuleRes(ERR_COULDNOTRESTOREDS));
        aError.Execute();
    }

    // enable the apply button
    GetApplyButton()->Enable(sal_True);

    return 0L;
}

//-------------------------------------------------------------------------
ODbAdminDialog::ApplyResult ODbAdminDialog::implApplyChanges()
{
    if (!PrepareLeaveCurrentPage())
    {   // the page did not allow us to leave
        return AR_KEEP;
    }

    ApplyResult eResult = AR_LEAVE_UNCHANGED;

    // save the settings for the currently selected data source
    if (m_aSelector.count() && (DELETED != m_aSelector.getSelectedState()))
    {
        ::rtl::OUString sCurrentlySelected = m_aSelector.getSelected();
        if (m_aDatasources[sCurrentlySelected]->isModified())
        {
            m_aDatasources.update(sCurrentlySelected, *pExampleSet);
            String sNewName = m_aDatasources.adjustRealName(sCurrentlySelected);
            String sOldName = sCurrentlySelected;
            // the data source has not only been modified, but renamed, too
            // -> adjust the selector and m_sCurrentDatasource
            // (we are allowed to do this here, this is no part of the committment of the changes, it just
            // leaves our structures in a consistent state for the real commitment)
            if (!sNewName.Equals(sOldName))
            {
                // tell our selector window that the name has changed
                m_aSelector.renamed(sOldName, sNewName);
                // update our "current database"
                m_sCurrentDatasource = sNewName;

                // adjust the selection
                implSelectDatasource(m_sCurrentDatasource);
            }
        }
    }

    // We allowed the user to freely rename/create/delete datasources, without committing anything ('til now).
    // This could lead to conflicts: if datasource "A" was renamed to "B", and a new ds "A" created, then we
    // would have to do the renaming before the creation. This would require us to analyze the changes in
    // m_aDatasources for any such dependencies, which could be difficult (okay, I'm not willing to do it :)
    // Instead we use another approach: If we encounter a conflict (a DS which can't be renamed or inserted),
    // we save this entry and continue with the next one. This way, the ds causing the conflict should be handled
    // first. After that, we do a new round, assuming that now the conflict is resolved.
    // A disadvantage is that this may require O(n^2) rounds, but this is not really expensive ....

    // first delete all datasources which were scheduled for deletion
    for (   ODatasourceMap::Iterator aLoopDeleted = m_aDatasources.beginDeleted();
            aLoopDeleted != m_aDatasources.endDeleted();
            ++aLoopDeleted
        )
    {
        ::rtl::OUString sDeleteWhich = aLoopDeleted->getOriginalName();
        sal_Bool bOperationSuccess = sal_False;
        try
        {
            m_xDynamicContext->revokeObject(sDeleteWhich);
            bOperationSuccess = sal_True;
        }
        catch(Exception&) { }
        if (bOperationSuccess)
        {
            eResult = AR_LEAVE_MODIFIED;
            m_aSelector.deleted(aLoopDeleted->getAccessKey());
        }
        else
        {
            DBG_ERROR("ODbAdminDialog::implApplyChanges: could not delete a data source!");
            // TODO: an error message
        }
    }
    m_aDatasources.clearDeleted();

    sal_Int32 nDelayed = 0;
    sal_Int32 nLastRoundDelayed = -1;
        // to ensure that we're not looping 'til death: If this doesn't change within one round, the DatabaseContext
        // is not in the state as this dialog started anymore. This means somebody else did some renamings
        // or insertings, causing us conflicts now.

    do
    {
        if (nLastRoundDelayed == nDelayed)
        {
            DBG_ERROR("ODbAdminDialog::implApplyChanges: somebody tampered with the context!");
            // TODO: error handling
            break;
        }

        // reset the counter
        nLastRoundDelayed = nDelayed;
        nDelayed = 0;

        // propagate all the settings made to the appropriate data source, and add/drop/rename data sources
        for (   ODatasourceMap::Iterator aLoop = m_aDatasources.begin();
                aLoop != m_aDatasources.end();
                ++aLoop
            )
        {
            // nothing to do if no modifications were done
            if (aLoop->isModified())
            {
                Reference< XPropertySet > xDatasource = aLoop->getDatasource();
                if (xDatasource.is())
                {
                    eResult = AR_LEAVE_MODIFIED;
                        // we changes something

                    // put the remembered settings into the property set
                    translateProperties(*aLoop->getModifications(), xDatasource);

                    ::rtl::OUString sName = aLoop->getName();
                    DBG_ASSERT(sName.equals(aLoop->getRealName()), "ODbAdminDialog::implApplyChanges: invalid name/realname combination!");
                        // these both names shouldn't be diefferent here anymore
                    ::rtl::OUString sOriginalName = aLoop->getOriginalName();

                    // if we need a new name, check for conflicts
                    if (aLoop->isRenamed() || aLoop->isNew())
                    {
                        sal_Bool bAlreadyHaveNewName = sal_True;
                        try
                        {
                            bAlreadyHaveNewName = m_xDatabaseContext->hasByName(sName);
                        }
                        catch(RuntimeException&) { }
                        if (bAlreadyHaveNewName)
                        {
                            ++nDelayed;
                            continue;
    //  | <---------------- continue with the next data source
                        }

                        if (aLoop->isRenamed())
                        {
                            // remove the object
                            sal_Bool bOperationSuccess = sal_False;
                            try
                            {
                                m_xDynamicContext->revokeObject(sOriginalName);
                                bOperationSuccess = sal_True;
                            }
                            catch(Exception&) { }
                            if (!bOperationSuccess)
                            {
                                DBG_ERROR("ODbAdminDialog::implApplyChanges: data source was renamed, but could not remove it (to insert it under a new name)!");
                                // TODO: an error message
                            }
                        }

                        // (re)insert the object under the new name
                        sal_Bool bOperationSuccess = sal_False;
                        try
                        {
                            m_xDynamicContext->registerObject(sName, xDatasource.get());
                            bOperationSuccess = sal_True;
                        }
                        catch(Exception&) { }
                        if (bOperationSuccess)
                        {
                            // everything's ok ...
                            // no need to flush the object anymore, this is done automatically upon insertion
                        }
                        else if (aLoop->isRenamed())
                        {
                            // oops ... we removed the ds, but could not re-insert it
                            // try to prevent data loss
                            DBG_ERROR("ODbAdminDialog::implApplyChanges: removed the entry, but could not re-insert it!");
                            // we're going to re-insert the object under it's old name
                            bOperationSuccess = sal_False;
                            try
                            {
                                m_xDynamicContext->registerObject(sOriginalName, xDatasource.get());
                                bOperationSuccess = sal_True;
                            }
                            catch(Exception&) { }
                            DBG_ASSERT(bOperationSuccess, "ODbAdminDialog::implApplyChanges: could not insert it under the old name, too ... no we have a data loss!");
                        }

                        // reset the item, so in case we need an extra round (because of delayed items) it
                        // won't be included anymore
                        m_aDatasources.clearModifiedFlag(sName);
                        // and tell the selector the new state
                        m_aSelector.flushed(sName);

                        continue;
    //  | <------------ continue with the next data source
                    }

                    // We're here if the data source was not renamed, not deleted and is not new. Just flush it.
                    Reference< XFlushable > xFlushDatasource(xDatasource, UNO_QUERY);
                    if (!xFlushDatasource.is())
                    {
                        DBG_ERROR("ODbAdminDialog::implApplyChanges: the datasource should be flushable!");
                        continue;
                    }

                    try
                    {
                        xFlushDatasource->flush();
                    }
                    catch(RuntimeException&)
                    {
                        DBG_ERROR("ODbAdminDialog::implApplyChanges: caught an exception whild flushing the data source's data!");
                    }
                    // reset the item, so in case we need an extra round (because of delayed items) it
                    // won't be included anymore
                    m_aDatasources.clearModifiedFlag(sName);
                    // and tell the selector the new state
                    m_aSelector.flushed(sName);
                }
            }
        }
    }
    while (nDelayed);

    // reset some meta-data-items in the the example set
    // 00/11/10 - 80185 - FS
    pExampleSet->Put(SfxBoolItem(DSID_NEWDATASOURCE, sal_False));
    pExampleSet->Put(SfxBoolItem(DSID_DELETEDDATASOURCE, sal_False));

    // disable the apply button
    GetApplyButton()->Enable(sal_False);


    if ( isUIEnabled() )
        ShowPage(GetCurPageId());
        // This does the usual ActivatePage, so the pages can save their current status.
        // This way, next time they're asked what has changed since now and here, they really
        // can compare with the status they have _now_ (not the one they had before this apply call).

    m_bApplied = sal_True;

    return eResult;
}

//-------------------------------------------------------------------------
IMPL_LINK(ODbAdminDialog, OnAsyncApplyChanges, void*, _OnErrorResId)
{
    SfxTabDialog::Ok();
    if (AR_KEEP != implApplyChanges())
    {
        // show the page
        if (GetCurPageId() != m_nPostApplyPage)
            ShowPage(m_nPostApplyPage);

        // restore the view settings
        if (m_pPostApplyPageSettings)
        {
            SfxTabPage* pPage = GetTabPage(m_nPostApplyPage);
            if (pPage)
                static_cast<OGenericAdministrationPage*>(pPage)->restoreViewSettings(m_pPostApplyPageSettings);

            delete m_pPostApplyPageSettings;
            m_pPostApplyPageSettings = NULL;
        }

        m_nPostApplyPage = 0;

        return 1L;
    }
    return 0L;
}

//-------------------------------------------------------------------------
IMPL_LINK(ODbAdminDialog, OnApplyChanges, PushButton*, EMPTYARG)
{
    const sal_uInt16 nOldPageId = GetCurPageId();

    // get the view settings of the current page
    SfxTabPage* pCurrentPage = GetTabPage(nOldPageId);
    OPageSettings* pViewSettings = NULL;
    if (pCurrentPage)
    {
        pViewSettings = static_cast<OGenericAdministrationPage *>(pCurrentPage)->createViewSettings();
        static_cast<OGenericAdministrationPage *>(pCurrentPage)->fillViewSettings(pViewSettings);
    }

    // really apply the changes
    implApplyChanges();

    // select the old page, again (if possible)
    const sal_uInt16 nNewPageId = GetCurPageId();

    pCurrentPage = GetTabPage(nOldPageId);
    if (pCurrentPage)
    {
        if (nNewPageId != nOldPageId)
            ShowPage(nOldPageId);

        static_cast<OGenericAdministrationPage *>(pCurrentPage)->restoreViewSettings(pViewSettings);
    }

    delete pViewSettings;
    return 0L;
}

//.........................................................................
}   // namespace dbaui
//.........................................................................

/*************************************************************************
 * history:
 *  $Log: not supported by cvs2svn $
 *  Revision 1.82  2002/11/15 12:29:30  oj
 *  #105175# check size of poolitems
 *
 *  Revision 1.81  2002/08/19 07:40:36  oj
 *  #99473# change string resource files
 *
 *  Revision 1.80  2002/07/25 07:01:22  oj
 *  #95146# new SfxItems for autoinc
 *
 *  Revision 1.79  2002/07/09 12:43:20  oj
 *  #99921# check if datasource allows to check names
 *
 *  Revision 1.78  2002/01/30 14:15:30  fs
 *  #97122# when selecting a data source, make sure it is no no-op causing unnecessary things
 *
 *  Revision 1.77  2001/10/26 16:36:25  hr
 *  #92924#: includes
 *
 *  Revision 1.76  2001/10/24 10:31:05  fs
 *  #93684# in implTranslateProperty, check for the correct SfxItem types (in case a data source has invalid indirect property types)
 *
 *  Revision 1.75  2001/09/18 15:07:35  fs
 *  #65293# syntax for SOLS
 *
 *  Revision 1.74  2001/09/11 15:08:33  fs
 *  #91304# disableUI before applying the changes in OK
 *
 *  Revision 1.73  2001/08/30 16:12:08  fs
 *  #88427# +OnValidateName
 *
 *  Revision 1.72  2001/08/27 06:57:23  oj
 *  #90015# some speedup's
 *
 *  Revision 1.71  2001/08/23 14:48:13  fs
 *  #88637# corrected error message
 *
 *  Revision 1.70  2001/08/14 14:11:33  fs
 *  #86945# +getCurrentDataSource
 *
 *  Revision 1.69  2001/08/01 08:32:04  fs
 *  #88530# if the address book type is initially selected, default the sub-type to something meaningfull
 *
 *  Revision 1.68  2001/07/31 16:01:33  fs
 *  #88530# changes to operate the dialog in a mode where no type change is possible
 *
 *  Revision 1.67  2001/07/30 11:31:52  fs
 *  #88530# changes to allow operating the dialog in a 'edit one single data source only' mode
 *
 *  Revision 1.66  2001/07/25 14:05:44  oj
 *  #90201# check ldap name
 *
 *  Revision 1.65  2001/07/17 07:30:50  oj
 *  #89533# GetMainURL changed
 *
 *  Revision 1.64  2001/07/11 10:10:30  oj
 *  #87257# change GetUILanguage
 *
 *  Revision 1.63  2001/07/06 11:33:29  oj
 *  #89359# now dialog saves password temp
 *
 *  Revision 1.62  2001/06/25 16:04:40  fs
 *  #88004# outsourced ODataSourceMap and ODataSourceSelector / adjusted fillDatasourceInfo so that settings without and UI are do not survive the method
 *
 *  Revision 1.61  2001/06/25 08:27:18  oj
 *  #88699# new control for ldap rowcount
 *
 *  Revision 1.60  2001/06/20 13:43:42  fs
 *  #88447# corrected order of detail pages
 *
 *  Revision 1.59  2001/06/20 07:08:33  oj
 *  #88434# new page for user admin
 *
 *  Revision 1.58  2001/06/14 14:18:10  fs
 *  #88242# corrected adding/removing detail pages
 *
 *  Revision 1.57  2001/06/07 15:12:36  fs
 *  #87934# removed a wrong assertion
 *
 *  Revision 1.56  2001/06/01 08:41:31  oj
 *  #87149# changed order for tabpages
 *
 *  Revision 1.55  2001/05/31 11:37:57  oj
 *  #87149# correct ldap protocol
 *
 *  Revision 1.54  2001/05/31 11:09:07  oj
 *  #87149# change subprotocol and Propertynames
 *
 *  Revision 1.53  2001/05/29 13:33:12  oj
 *  #87149# addressbook ui impl
 *
 *  Revision 1.52  2001/05/29 10:18:26  fs
 *  #86082# set the service factory on the general page
 *
 *  Revision 1.51  2001/05/23 14:16:42  oj
 *  #87149# new helpids
 *
 *  Revision 1.50  2001/05/15 15:07:06  fs
 *  #86991# save the current (modified) settings when inserting a new data source
 *
 *  Revision 1.49  2001/05/15 11:25:35  fs
 *  #86996# use the connection pool instead of the driver manager
 *
 *  Revision 1.48  2001/05/10 13:37:04  fs
 *  #86223# restore view settings after applying (no matter if syncronously or asynchronously / +successfullyConnected to make the password persistent
 *
 *  Revision 1.47  2001/04/27 15:47:03  fs
 *  resetPages: do a ShowPage(GENERAL) before removing pages
 *
 *  Revision 1.46  2001/04/26 11:40:21  fs
 *  file is alive, again - added support for data source associated bookmarks
 *
 *  Revision 1.45  2001/04/20 13:38:06  oj
 *  #85736# new checkbox for odbc
 *
 *  Revision 1.44  2001/04/04 10:38:43  oj
 *  reading uninitialized memory
 *
 *  Revision 1.43  2001/03/30 11:54:34  fs
 *  #65293# missing include
 *
 *  Revision 1.42  2001/03/29 07:44:43  fs
 *  #84826# +clearPassword
 *
 *  Revision 1.41  2001/03/29 07:34:00  oj
 *  dispose connection in dtor and type casts
 *
 *  Revision 1.0 20.09.00 10:55:58  fs
 ************************************************************************/