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
|
/*************************************************************************
*
* $RCSfile: adminpages.cxx,v $
*
* $Revision: 1.26 $
*
* last change: $Author: fs $ $Date: 2001-01-25 12:14:03 $
*
* 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 _DBA_DBACCESS_HELPID_HRC_
#include "dbaccess_helpid.hrc"
#endif
#ifndef _DBAUI_ADMINPAGES_HXX_
#include "adminpages.hxx"
#endif
#ifndef _DBAUI_DBADMIN_HRC_
#include "dbadmin.hrc"
#endif
#ifndef _DBAUI_MODULE_DBU_HXX_
#include "moduledbu.hxx"
#endif
#ifndef _DBAUI_SQLMESSAGE_HXX_
#include "sqlmessage.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 _SV_MSGBOX_HXX
#include <vcl/msgbox.hxx>
#endif
#ifndef _SV_WAITOBJ_HXX
#include <vcl/waitobj.hxx>
#endif
#ifndef _DBAUI_DATASOURCEITEMS_HXX_
#include "dsitems.hxx"
#endif
#ifndef _DBU_RESOURCE_HRC_
#include "dbu_resource.hrc"
#endif
#ifndef _DBAUI_DBFINDEX_HXX_
#include "dbfindex.hxx"
#endif
#ifndef _DBAUI_LOCALRESACCESS_HXX_
#include "localresaccess.hxx"
#endif
#ifndef _DBAUI_STRINGLISTITEM_HXX_
#include "stringlistitem.hxx"
#endif
#ifndef _DBAUI_DBADMIN_HXX_
#include "dbadmin.hxx"
#endif
#ifndef _IODLG_HXX
#include <sfx2/iodlg.hxx>
#endif
#ifndef _URLOBJ_HXX
#include <tools/urlobj.hxx>
#endif
#ifndef _DBHELPER_DBEXCEPTION_HXX_
#include <connectivity/dbexception.hxx>
#endif
#ifndef _CONNECTIVITY_DBTOOLS_HXX_
#include <connectivity/dbtools.hxx>
#endif
#ifndef _COM_SUN_STAR_SDB_SQLCONTEXT_HPP_
#include <com/sun/star/sdb/SQLContext.hpp>
#endif
#ifndef _COM_SUN_STAR_LANG_XCOMPONENT_HPP_
#include <com/sun/star/lang/XComponent.hpp>
#endif
#ifndef _COM_SUN_STAR_SDBC_XROW_HPP_
#include <com/sun/star/sdbc/XRow.hpp>
#endif
#include <stdlib.h>
#ifndef _OSL_FILE_HXX_
#include <osl/file.hxx>
#endif
#ifndef _DBAUI_DSSELECT_HXX_
#include "dsselect.hxx"
#endif
#ifndef _DBAUI_ODBC_CONFIG_HXX_
#include "odbcconfig.hxx"
#endif
using namespace ::com::sun::star::uno;
using namespace ::com::sun::star::ucb;
using namespace ::com::sun::star::sdb;
using namespace ::com::sun::star::sdbc;
using namespace ::com::sun::star::beans;
using namespace ::com::sun::star::lang;
using namespace ::dbtools;
//.........................................................................
namespace dbaui
{
//.........................................................................
#define FILL_STRING_ITEM(editcontrol, itemset, itemid, modifiedflag) \
if (editcontrol.GetText() != editcontrol.GetSavedValue()) \
{ \
itemset.Put(SfxStringItem(itemid, editcontrol.GetText())); \
modifiedflag = sal_True; \
}
//=========================================================================
//= OGenericAdministrationPage
//=========================================================================
//-------------------------------------------------------------------------
OGenericAdministrationPage::OGenericAdministrationPage(Window* _pParent, const ResId& _rId, const SfxItemSet& _rAttrSet)
:SfxTabPage(_pParent, _rId, _rAttrSet)
{
SetExchangeSupport(sal_True);
}
//-------------------------------------------------------------------------
int OGenericAdministrationPage::DeactivatePage(SfxItemSet* _pSet)
{
if (_pSet)
{
if (!checkItems())
return KEEP_PAGE;
FillItemSet(*_pSet);
}
return LEAVE_PAGE;
}
//-------------------------------------------------------------------------
void OGenericAdministrationPage::Reset(const SfxItemSet& _rCoreAttrs)
{
implInitControls(_rCoreAttrs, sal_False);
}
//-------------------------------------------------------------------------
void OGenericAdministrationPage::ActivatePage(const SfxItemSet& _rSet)
{
implInitControls(_rSet, sal_True);
}
// -----------------------------------------------------------------------
void OGenericAdministrationPage::getFlags(const SfxItemSet& _rSet, sal_Bool& _rValid, sal_Bool& _rReadonly)
{
SFX_ITEMSET_GET(_rSet, pInvalid, SfxBoolItem, DSID_INVALID_SELECTION, sal_True);
_rValid = !pInvalid || !pInvalid->GetValue();
SFX_ITEMSET_GET(_rSet, pReadonly, SfxBoolItem, DSID_READONLY, sal_True);
_rReadonly = !_rValid || (pReadonly && pReadonly->GetValue());
}
// -----------------------------------------------------------------------
IMPL_LINK(OGenericAdministrationPage, OnControlModified, Control*, EMPTYARG)
{
callModifiedHdl();
return 0L;
}
//=========================================================================
//= OGeneralPage
//=========================================================================
//-------------------------------------------------------------------------
OGeneralPage::OGeneralPage(Window* pParent, const SfxItemSet& _rItems)
:OGenericAdministrationPage(pParent, ModuleRes(PAGE_GENERAL), _rItems)
,m_aNameLabel (this, ResId(FT_DATASOURCENAME))
,m_aName (this, ResId(ET_DATASOURCENAME))
,m_aTypeBox (this, ResId(GB_CONNECTION))
,m_aDatasourceTypeLabel (this, ResId(FT_DATATYPE))
,m_aDatasourceType (this, ResId(LB_DATATYPE))
,m_aConnectionLabel (this, ResId(FT_CONNECTURL))
,m_aConnection (this, ResId(ET_CONNECTURL))
,m_aBrowseConnection (this, ResId(PB_BROWSECONNECTION))
// ,m_aTimeoutLabel (this, ResId(FT_LOGINTIMEOUT))
// ,m_aTimeoutNumber (this, ResId(ET_TIMEOUT_NUMBER))
// ,m_aTimeoutUnit (this, ResId(LB_TIMEOUT_UNIT))
,m_aSpecialMessage (this, ResId(FT_SPECIAL_MESSAGE))
,m_pCollection(NULL)
,m_eCurrentSelection(DST_UNKNOWN)
,m_bDisplayingInvalid(sal_False)
{
// fill the listbox with the UI descriptions for the possible types
// and remember the respective DSN prefixes
FreeResource();
// extract the datasource type collection from the item set
DbuTypeCollectionItem* pCollectionItem = PTR_CAST(DbuTypeCollectionItem, _rItems.GetItem(DSID_TYPECOLLECTION));
if (pCollectionItem)
m_pCollection = pCollectionItem->getCollection();
DBG_ASSERT(m_pCollection, "OGeneralPage::OGeneralPage : really need a DSN type collection !");
// initially fill the listbox
if (m_pCollection)
{
for ( ODsnTypeCollection::TypeIterator aTypeLoop = m_pCollection->begin();
aTypeLoop != m_pCollection->end();
++aTypeLoop
)
{
DATASOURCE_TYPE eType = aTypeLoop.getType();
sal_Int32 nPos = m_aDatasourceType.InsertEntry(aTypeLoop.getDisplayName());
m_aDatasourceType.SetEntryData(nPos, reinterpret_cast<void*>(eType));
}
}
// do some knittings
m_aDatasourceType.SetSelectHdl(LINK(this, OGeneralPage, OnDatasourceTypeSelected));
m_aName.SetModifyHdl(LINK(this, OGeneralPage, OnNameModified));
m_aConnection.SetModifyHdl(getControlModifiedLink());
m_aBrowseConnection.SetClickHdl(LINK(this, OGeneralPage, OnBrowseConnections));
}
//-------------------------------------------------------------------------
void OGeneralPage::initializeHistory()
{
m_aSelectionHistory.clear();
if (m_pCollection)
{
for ( ODsnTypeCollection::TypeIterator aTypeLoop = m_pCollection->begin();
aTypeLoop != m_pCollection->end();
++aTypeLoop
)
m_aSelectionHistory[aTypeLoop.getType()] = m_pCollection->getDatasourcePrefix(aTypeLoop.getType());
}
}
//-------------------------------------------------------------------------
void OGeneralPage::GetFocus()
{
OGenericAdministrationPage::GetFocus();
if (m_aName.IsEnabled())
m_aName.GrabFocus();
}
//-------------------------------------------------------------------------
sal_Bool OGeneralPage::isBrowseable(DATASOURCE_TYPE _eType) const
{
switch (_eType)
{
case DST_DBASE:
case DST_TEXT:
case DST_ADABAS:
case DST_ODBC:
return sal_True;
}
return sal_False;
}
//-------------------------------------------------------------------------
void OGeneralPage::onTypeSelected(DATASOURCE_TYPE _eType)
{
m_aBrowseConnection.Enable(isBrowseable(_eType));
// update the selection history
m_aSelectionHistory[m_eCurrentSelection] = m_aConnection.GetText();
// the the new URL text as indicated by the selection history
m_eCurrentSelection = _eType;
m_aConnection.SetText(m_aSelectionHistory[m_eCurrentSelection]);
if (m_aTypeSelectHandler.IsSet())
m_aTypeSelectHandler.Call(this);
}
//-------------------------------------------------------------------------
sal_Bool OGeneralPage::checkItems()
{
if ((0 == m_aName.GetText().Len()) && !m_bDisplayingInvalid)
{
String sErrorMsg(ModuleRes(STR_ERR_EMPTY_DSN_NAME));
ErrorBox aErrorBox(GetParent(), WB_OK, sErrorMsg);
aErrorBox.Execute();
m_aName.GrabFocus();
return sal_False;
}
return sal_True;
}
//-------------------------------------------------------------------------
void OGeneralPage::implInitControls(const SfxItemSet& _rSet, sal_Bool _bSaveValue)
{
initializeHistory();
// first check whether or not the selection is invalid or readonly (invalid implies readonly, but not vice versa)
sal_Bool bValid, bReadonly;
getFlags(_rSet, bValid, bReadonly);
// if the selection is invalid, disable evrything
m_aNameLabel.Enable(bValid);
m_aName.Enable(bValid);
m_aTypeBox.Enable(bValid);
m_aDatasourceTypeLabel.Enable(bValid);
m_aDatasourceType.Enable(bValid);
m_aConnectionLabel.Enable(bValid);
m_aConnection.Enable(bValid);
m_aBrowseConnection.Enable(bValid);
String sConnectURL, sName;
String sMessage;
m_bDisplayingInvalid = !bValid;
if (bValid)
{
// collect some items and some values
SFX_ITEMSET_GET(_rSet, pUrlItem, SfxStringItem, DSID_CONNECTURL, sal_True);
SFX_ITEMSET_GET(_rSet, pNameItem, SfxStringItem, DSID_NAME, sal_True);
DBG_ASSERT(pUrlItem, "OGeneralPage::implInitControls : missing the type attribute !");
DBG_ASSERT(pNameItem, "OGeneralPage::implInitControls : missing the name attribute !");
sConnectURL = pUrlItem->GetValue();
sName = pNameItem->GetValue();
}
else
{
SFX_ITEMSET_GET(_rSet, pDeleted, SfxBoolItem, DSID_DELETEDDATASOURCE, sal_True);
if (pDeleted && pDeleted->GetValue())
{
OLocalResourceAccess aStringResAccess(PAGE_GENERAL, RSC_TABPAGE);
sMessage = String(ResId(STR_DATASOURCEDELETED));
}
}
m_aSpecialMessage.SetText(sMessage);
// compare the DSN prefix with the registered ones
String sDisplayName;
DATASOURCE_TYPE eOldSelection = m_eCurrentSelection;
m_eCurrentSelection = DST_UNKNOWN;
if (m_pCollection && bValid)
{
m_eCurrentSelection = m_pCollection->getType(sConnectURL);
sDisplayName = m_pCollection->getTypeDisplayName(m_eCurrentSelection);
}
m_aBrowseConnection.Enable(bValid && isBrowseable(m_eCurrentSelection));
// select the correct datasource type
m_aDatasourceType.SelectEntry(sDisplayName);
if (_bSaveValue)
m_aDatasourceType.SaveValue();
// notify our listener that our type selection has changed (if so)
if (eOldSelection != m_eCurrentSelection)
onTypeSelected(m_eCurrentSelection);
m_aConnection.SetText(sConnectURL);
if (_bSaveValue)
m_aConnection.SaveValue();
// the datasource name
m_aName.SetText(sName);
if (_bSaveValue)
m_aName.SaveValue();
}
//-------------------------------------------------------------------------
SfxTabPage* OGeneralPage::Create(Window* _pParent, const SfxItemSet& _rAttrSet)
{
return ( new OGeneralPage( _pParent, _rAttrSet ) );
}
//-------------------------------------------------------------------------
void OGeneralPage::Reset(const SfxItemSet& _rCoreAttrs)
{
m_eCurrentSelection = DST_UNKNOWN;
// this ensures that our type selection link will be called, even if the new is is the same as the
// current one
OGenericAdministrationPage::Reset(_rCoreAttrs);
// there are some things which depend on the current name
LINK(this, OGeneralPage, OnNameModified).Call(&m_aName);
}
//-------------------------------------------------------------------------
BOOL OGeneralPage::FillItemSet(SfxItemSet& _rCoreAttrs)
{
sal_Bool bChangedSomething = sal_False;
if (m_aName.GetText() != m_aName.GetSavedValue())
{
_rCoreAttrs.Put(SfxStringItem(DSID_NAME, m_aName.GetText()));
bChangedSomething = sal_True;
}
if ((m_aConnection.GetText() != m_aConnection.GetSavedValue()) || (m_aDatasourceType.GetSavedValue() != m_aDatasourceType.GetSelectEntryPos()))
{
_rCoreAttrs.Put(SfxStringItem(DSID_CONNECTURL, m_aConnection.GetText()));
bChangedSomething = sal_True;
}
return bChangedSomething;
}
//-------------------------------------------------------------------------
IMPL_LINK(OGeneralPage, OnNameModified, Edit*, _pBox)
{
sal_Bool bNewNameValid = sal_True;
if (m_aNameModifiedHandler.IsSet())
bNewNameValid = (0L != m_aNameModifiedHandler.Call(this));
if (m_aName.IsEnabled())
{ // (this way we prevent overwriting a "this datasource is deleted" message)
// show a text if the name is invalid
String sNameMessage;
if (!bNewNameValid)
{
OLocalResourceAccess aStringResAccess(PAGE_GENERAL, RSC_TABPAGE);
sNameMessage = String(ResId(STR_NAMEINVALID));
}
m_aSpecialMessage.SetText(sNameMessage);
}
return 0L;
}
//-------------------------------------------------------------------------
IMPL_LINK(OGeneralPage, OnBrowseConnections, PushButton*, _pButton)
{
switch (GetSelectedType())
{
case DST_DBASE:
case DST_TEXT:
{
SfxFileDialog aFileDlg(GetParent(), WB_3DLOOK | WB_STDMODAL | WB_OPEN | SFXWB_PATHDIALOG);
String sOldPath = m_aConnection.GetTextNoPrefix();
if (sOldPath.Len())
aFileDlg.SetPath(sOldPath);
if (RET_OK == aFileDlg.Execute())
{
m_aConnection.SetTextNoPrefix(aFileDlg.GetPath());
callModifiedHdl();
}
}
break;
case DST_ADABAS:
{
// collect all names from the config dir
// and all dir's of the DBWORK/wrk or DBROOT/wrk dir
// compare the names
// collect the names of the installed databases
StringBag aInstalledDBs;
String sAdabasConfigDir,sAdabasWorkDir;
const char* pAdabasCfg = getenv("DBCONFIG");
const char* pAdabasWrk = getenv("DBWORK");
sal_Bool bOldFashion = sal_False;
if (pAdabasCfg && pAdabasWrk) // for our type of adabas this must apply
{
sAdabasConfigDir.AssignAscii(pAdabasCfg);
sAdabasWorkDir.AssignAscii(pAdabasWrk);
bOldFashion = sal_True;
}
else // we have a normal adabas installation
{ // so we check the local database names in $DBROOT/config
const char* pAdabasRoot = getenv("DBROOT");
if (pAdabasRoot)
{
sAdabasConfigDir.AssignAscii(pAdabasRoot);
sAdabasWorkDir.AssignAscii(pAdabasRoot);
}
}
if(sAdabasConfigDir.Len() && sAdabasWorkDir.Len())
{
aInstalledDBs = getInstalledAdabasDBs(sAdabasConfigDir,sAdabasWorkDir);
if(!aInstalledDBs.size() && bOldFashion)
{
const char* pAdabasRoot = getenv("DBROOT");
if (pAdabasRoot)
{
sAdabasConfigDir.AssignAscii(pAdabasRoot);
sAdabasWorkDir.AssignAscii(pAdabasRoot);
aInstalledDBs = getInstalledAdabasDBs(sAdabasConfigDir,sAdabasWorkDir);
}
}
ODatasourceSelectDialog aSelector(GetParent(), aInstalledDBs, GetSelectedType());
if (RET_OK == aSelector.Execute())
{
String aSelected;
aSelected.AssignAscii(":");
aSelected += aSelector.GetSelected();
m_aConnection.SetTextNoPrefix(aSelected);
callModifiedHdl();
}
}
else
{
OLocalResourceAccess aLocRes(PAGE_GENERAL, RSC_TABPAGE);
String sError(ModuleRes(STR_NO_ADABASE_DATASOURCES));
ErrorBox aBox(this, WB_OK, sError);
aBox.Execute();
}
}
break;
case DST_ODBC:
{
// collect all ODBC data source names
StringBag aOdbcDatasources;
OOdbcEnumeration aEnumeration;
if (!aEnumeration.isLoaded())
{
// show an error message
OLocalResourceAccess aLocRes(PAGE_GENERAL, RSC_TABPAGE);
String sError(ModuleRes(STR_COULDNOTLOAD_ODBCLIB));
sError.SearchAndReplaceAscii("#lib#", aEnumeration.getLibraryName());
ErrorBox aDialog(this, WB_OK, sError);
aDialog.Execute();
return 1L;
}
else
{
aEnumeration.getDatasourceNames(aOdbcDatasources);
// excute the select dialog
ODatasourceSelectDialog aSelector(GetParent(), aOdbcDatasources, GetSelectedType());
if (RET_OK == aSelector.Execute())
{
m_aConnection.SetTextNoPrefix(aSelector.GetSelected());
callModifiedHdl();
}
}
}
break;
}
return 0L;
}
// -----------------------------------------------------------------------------
StringBag OGeneralPage::getInstalledAdabasDBs(const String &_rConfigDir,const String &_rWorkDir)
{
String sAdabasConfigDir(_rConfigDir),sAdabasWorkDir(_rWorkDir);
if (sAdabasConfigDir.Len() && ('/' == sAdabasConfigDir.GetBuffer()[sAdabasConfigDir.Len() - 1]))
sAdabasConfigDir.AppendAscii("config");
else
sAdabasConfigDir.AppendAscii("/config");
if (sAdabasWorkDir.Len() && ('/' == sAdabasWorkDir.GetBuffer()[sAdabasWorkDir.Len() - 1]))
sAdabasWorkDir.AppendAscii("wrk");
else
sAdabasWorkDir.AppendAscii("/wrk");
// collect the names of the installed databases
StringBag aInstalledDBs;
// collect the names of the installed databases
StringBag aConfigDBs,aWrkDBs;
aConfigDBs = getInstalledAdabasDBDirs(sAdabasConfigDir,::ucb::INCLUDE_DOCUMENTS_ONLY);
aWrkDBs = getInstalledAdabasDBDirs(sAdabasWorkDir,::ucb::INCLUDE_FOLDERS_ONLY);
StringBag::const_iterator aOuter = aConfigDBs.begin();
for(;aOuter != aConfigDBs.end();++aOuter)
{
StringBag::const_iterator aInner = aWrkDBs.begin();
for(;aInner != aWrkDBs.end();++aInner)
{
if(*aInner == *aOuter)
{
aInstalledDBs.insert(*aOuter);
break;
}
}
}
return aInstalledDBs;
}
// -----------------------------------------------------------------------------
StringBag OGeneralPage::getInstalledAdabasDBDirs(const String &_rPath,const ::ucb::ResultSetInclude& _reResultSetInclude)
{
INetURLObject aNormalizer;
aNormalizer.SetSmartProtocol(INET_PROT_FILE);
aNormalizer.SetSmartURL(_rPath);
String sAdabasConfigDir = aNormalizer.GetMainURL();
::ucb::Content aAdabasConfigDir;
try
{
aAdabasConfigDir = ::ucb::Content(sAdabasConfigDir, Reference< ::com::sun::star::ucb::XCommandEnvironment >());
}
catch(::com::sun::star::ucb::ContentCreationException&)
{
return StringBag();
}
StringBag aInstalledDBs;
sal_Bool bIsFolder = sal_False;
try
{
bIsFolder = aAdabasConfigDir.isFolder();
}
catch(Exception&) // the exception is thrown when the path doesn't exists
{
}
if (bIsFolder && aAdabasConfigDir.get().is())
{ // we have a content for the directory, loop through all entries
Sequence< ::rtl::OUString > aProperties(1);
aProperties[0] = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Title"));
try
{
Reference< XResultSet > xFiles = aAdabasConfigDir.createCursor(aProperties, _reResultSetInclude);
Reference< XRow > xRow(xFiles, UNO_QUERY);
xFiles->beforeFirst();
while (xFiles->next())
aInstalledDBs.insert(xRow->getString(1));
}
catch(Exception&)
{
DBG_ERROR("OGeneralPage::OnBrowseConnections: could not enumerate the adabas config files!");
}
}
return aInstalledDBs;
}
//-------------------------------------------------------------------------
IMPL_LINK(OGeneralPage, OnDatasourceTypeSelected, ListBox*, _pBox)
{
// get the type from the entry data
sal_Int16 nSelected = _pBox->GetSelectEntryPos();
DATASOURCE_TYPE eSelectedType = static_cast<DATASOURCE_TYPE>(reinterpret_cast<sal_Int32>(_pBox->GetEntryData(nSelected)));
// let the impl method do all the stuff
onTypeSelected(eSelectedType);
// tell the listener we were modified
callModifiedHdl();
// outta here
return 0L;
}
//========================================================================
//= OCommonBehaviourTabPage
//========================================================================
OCommonBehaviourTabPage::OCommonBehaviourTabPage(Window* pParent, USHORT nResId, const SfxItemSet& _rCoreAttrs,
USHORT nControlFlags)
:OGenericAdministrationPage(pParent, ModuleRes(nResId), _rCoreAttrs)
,m_pUserNameLabel(NULL)
,m_pUserName(NULL)
,m_pPasswordRequired(NULL)
,m_pOptionsLabel(NULL)
,m_pOptions(NULL)
,m_pCharsetLabel(NULL)
,m_pCharset(NULL)
,m_nControlFlags(nControlFlags)
{
if ((m_nControlFlags & CBTP_USE_UIDPWD) == CBTP_USE_UIDPWD)
{
m_pUserNameLabel = new FixedText(this, ResId(FT_USERNAME));
m_pUserName = new Edit(this, ResId(ET_USERNAME));
m_pUserName->SetModifyHdl(getControlModifiedLink());
m_pPasswordRequired = new CheckBox(this, ResId(CB_PASSWORD_REQUIRED));
m_pPasswordRequired->SetClickHdl(getControlModifiedLink());
}
if ((m_nControlFlags & CBTP_USE_OPTIONS) == CBTP_USE_OPTIONS)
{
m_pOptionsLabel = new FixedText(this, ResId(FT_OPTIONS));
m_pOptions = new Edit(this, ResId(ET_OPTIONS));
m_pOptions->SetModifyHdl(getControlModifiedLink());
}
if ((m_nControlFlags & CBTP_USE_CHARSET) == CBTP_USE_CHARSET)
{
m_pCharsetLabel = new FixedText(this, ResId(FT_CHARSET));
m_pCharset = new ListBox(this, ResId(LB_CHARSET));
m_pCharset->SetSelectHdl(getControlModifiedLink());
OCharsetDisplay::const_iterator aLoop = m_aCharsets.begin();
while (aLoop != m_aCharsets.end())
{
m_pCharset->InsertEntry((*aLoop).getDisplayName());
++aLoop;
}
}
}
// -----------------------------------------------------------------------
OCommonBehaviourTabPage::~OCommonBehaviourTabPage()
{
DELETEZ(m_pUserNameLabel);
DELETEZ(m_pUserName);
DELETEZ(m_pPasswordRequired);
DELETEZ(m_pOptionsLabel);
DELETEZ(m_pOptions);
DELETEZ(m_pCharsetLabel);
DELETEZ(m_pCharset);
}
// -----------------------------------------------------------------------
void OCommonBehaviourTabPage::implInitControls(const SfxItemSet& _rSet, sal_Bool _bSaveValue)
{
// check whether or not the selection is invalid or readonly (invalid implies readonly, but not vice versa)
sal_Bool bValid, bReadonly;
getFlags(_rSet, bValid, bReadonly);
// collect the items
SFX_ITEMSET_GET(_rSet, pUidItem, SfxStringItem, DSID_USER, sal_True);
SFX_ITEMSET_GET(_rSet, pPwdItem, SfxStringItem, DSID_PASSWORD, sal_True);
SFX_ITEMSET_GET(_rSet, pOptionsItem, SfxStringItem, DSID_ADDITIONALOPTIONS, sal_True);
SFX_ITEMSET_GET(_rSet, pCharsetItem, SfxStringItem, DSID_CHARSET, sal_True);
SFX_ITEMSET_GET(_rSet, pAllowEmptyPwd, SfxBoolItem, DSID_PASSWORDREQUIRED, sal_True);
// forward the values to the controls
if (bValid)
{
if ((m_nControlFlags & CBTP_USE_UIDPWD) == CBTP_USE_UIDPWD)
{
m_pUserName->SetText(pUidItem->GetValue());
m_pPasswordRequired->Check(pAllowEmptyPwd->GetValue());
m_pUserName->ClearModifyFlag();
if (_bSaveValue)
{
m_pUserName->SaveValue();
m_pPasswordRequired->SaveValue();
}
}
if ((m_nControlFlags & CBTP_USE_OPTIONS) == CBTP_USE_OPTIONS)
{
m_pOptions->SetText(pOptionsItem->GetValue());
m_pOptions->ClearModifyFlag();
if (_bSaveValue)
m_pOptions->SaveValue();
}
if ((m_nControlFlags & CBTP_USE_CHARSET) == CBTP_USE_CHARSET)
{
OCharsetDisplay::const_iterator aFind = m_aCharsets.find(pCharsetItem->GetValue(), OCharsetDisplay::IANA());
if (aFind == m_aCharsets.end())
{
DBG_ERROR("OCommonBehaviourTabPage::implInitControls: unjknown charset falling back to system language!");
aFind = m_aCharsets.find(RTL_TEXTENCODING_DONTKNOW);
// fallback: system language
}
if (aFind == m_aCharsets.end())
m_pCharset->SelectEntry(String());
else
m_pCharset->SelectEntry((*aFind).getDisplayName());
if (_bSaveValue)
m_pCharset->SaveValue();
}
}
if (bReadonly)
{
if ((m_nControlFlags & CBTP_USE_UIDPWD) == CBTP_USE_UIDPWD)
{
m_pUserNameLabel->Disable();
m_pUserName->Disable();
m_pPasswordRequired->Disable();
}
if ((m_nControlFlags & CBTP_USE_OPTIONS) == CBTP_USE_OPTIONS)
{
m_pOptionsLabel->Disable();
m_pOptions->Disable();
}
if ((m_nControlFlags & CBTP_USE_CHARSET) == CBTP_USE_CHARSET)
{
m_pCharsetLabel->Disable();
m_pCharset->Disable();
}
}
}
// -----------------------------------------------------------------------
sal_Bool OCommonBehaviourTabPage::FillItemSet(SfxItemSet& _rSet)
{
sal_Bool bChangedSomething = sal_False;
if ((m_nControlFlags & CBTP_USE_UIDPWD) == CBTP_USE_UIDPWD)
{
if (m_pUserName->GetText() != m_pUserName->GetSavedValue())
{
_rSet.Put(SfxStringItem(DSID_USER, m_pUserName->GetText()));
_rSet.Put(SfxStringItem(DSID_PASSWORD, String()));
bChangedSomething = sal_True;
}
if (m_pPasswordRequired->IsChecked() != m_pPasswordRequired->GetSavedValue())
{
_rSet.Put(SfxBoolItem(DSID_PASSWORDREQUIRED, m_pPasswordRequired->IsChecked()));
bChangedSomething = sal_True;
}
}
if ((m_nControlFlags & CBTP_USE_OPTIONS) == CBTP_USE_OPTIONS)
{
if( m_pOptions->GetText() != m_pOptions->GetSavedValue() )
{
_rSet.Put(SfxStringItem(DSID_ADDITIONALOPTIONS, m_pOptions->GetText()));
bChangedSomething = sal_True;
}
}
if ((m_nControlFlags & CBTP_USE_CHARSET) == CBTP_USE_CHARSET)
{
if (m_pCharset->GetSelectEntryPos() != m_pCharset->GetSavedValue())
{
OCharsetDisplay::const_iterator aFind = m_aCharsets.find(m_pCharset->GetSelectEntry(), OCharsetDisplay::Display());
DBG_ASSERT(aFind != m_aCharsets.end(), "OCommonBehaviourTabPage::FillItemSet: could not translate the selected character set!");
if (aFind != m_aCharsets.end())
_rSet.Put(SfxStringItem(DSID_CHARSET, (*aFind).getIanaName()));
bChangedSomething = sal_True;
}
}
return bChangedSomething;
}
//========================================================================
//= ODbaseDetailsPage
//========================================================================
//------------------------------------------------------------------------
ODbaseDetailsPage::ODbaseDetailsPage( Window* pParent, const SfxItemSet& _rCoreAttrs )
:OCommonBehaviourTabPage(pParent, PAGE_DBASE, _rCoreAttrs, CBTP_USE_CHARSET)
,m_aFrame (this, ResId(GB_DBASE_MAIN))
,m_aShowDeleted (this, ResId(CB_SHOWDELETEDROWS))
,m_aIndexes (this, ResId(PB_INDICIES))
{
m_aIndexes.SetClickHdl(LINK(this, ODbaseDetailsPage, OnButtonClicked));
m_aShowDeleted.SetClickHdl(LINK(this, ODbaseDetailsPage, OnButtonClicked));
// correct the z-order which is mixed-up because the base class constructed some controls before we did
m_pCharset->SetZOrder(&m_aShowDeleted, WINDOW_ZORDER_BEHIND);
FreeResource();
}
// -----------------------------------------------------------------------
ODbaseDetailsPage::~ODbaseDetailsPage()
{
}
// -----------------------------------------------------------------------
sal_Int32* ODbaseDetailsPage::getDetailIds()
{
static sal_Int32* pRelevantIds = NULL;
if (!pRelevantIds)
{
static sal_Int32 nRelevantIds[] =
{
DSID_SHOWDELETEDROWS,
DSID_CHARSET,
0
};
pRelevantIds = nRelevantIds;
}
return pRelevantIds;
}
// -----------------------------------------------------------------------
SfxTabPage* ODbaseDetailsPage::Create( Window* pParent, const SfxItemSet& _rAttrSet )
{
return ( new ODbaseDetailsPage( pParent, _rAttrSet ) );
}
// -----------------------------------------------------------------------
void ODbaseDetailsPage::implInitControls(const SfxItemSet& _rSet, sal_Bool _bSaveValue)
{
OCommonBehaviourTabPage::implInitControls(_rSet, _bSaveValue);
// check whether or not the selection is invalid or readonly (invalid implies readonly, but not vice versa)
sal_Bool bValid, bReadonly;
getFlags(_rSet, bValid, bReadonly);
// get the DSN string (needed for the index dialog)
SFX_ITEMSET_GET(_rSet, pUrlItem, SfxStringItem, DSID_CONNECTURL, sal_True);
SFX_ITEMSET_GET(_rSet, pTypesItem, DbuTypeCollectionItem, DSID_TYPECOLLECTION, sal_True);
ODsnTypeCollection* pTypeCollection = pTypesItem ? pTypesItem->getCollection() : NULL;
if (pTypeCollection && pUrlItem && pUrlItem->GetValue().Len())
m_sDsn = pTypeCollection->cutPrefix(pUrlItem->GetValue());
// get the other relevant items
SFX_ITEMSET_GET(_rSet, pDeletedItem, SfxBoolItem, DSID_SHOWDELETEDROWS, sal_True);
sal_Bool bDeleted = sal_False, bLongNames = sal_False;
if (bValid)
bDeleted = pDeletedItem->GetValue();
m_aShowDeleted.Check(pDeletedItem->GetValue());
if (_bSaveValue)
m_aShowDeleted.SaveValue();
if (bReadonly)
m_aShowDeleted.Disable();
}
// -----------------------------------------------------------------------
sal_Bool ODbaseDetailsPage::FillItemSet( SfxItemSet& _rSet )
{
sal_Bool bChangedSomething = OCommonBehaviourTabPage::FillItemSet(_rSet);
if( m_aShowDeleted.IsChecked() != m_aShowDeleted.GetSavedValue() )
{
_rSet.Put( SfxBoolItem(DSID_SHOWDELETEDROWS, m_aShowDeleted.IsChecked() ) );
bChangedSomething = sal_True;
}
return bChangedSomething;
}
//------------------------------------------------------------------------
IMPL_LINK( ODbaseDetailsPage, OnButtonClicked, Button*, pButton )
{
if (&m_aIndexes == pButton)
{
ODbaseIndexDialog aIndexDialog(this, m_sDsn);
aIndexDialog.Execute();
}
else
// it was one of the checkboxes -> we count as modified from now on
callModifiedHdl();
return 0;
}
//========================================================================
//= OJdbcDetailsPage
//========================================================================
OJdbcDetailsPage::OJdbcDetailsPage( Window* pParent, const SfxItemSet& _rCoreAttrs )
:OCommonBehaviourTabPage(pParent, PAGE_JDBC, _rCoreAttrs, CBTP_USE_UIDPWD | CBTP_USE_CHARSET)
,m_aDriverLabel (this, ResId(FT_JDBCDRIVERCLASS))
,m_aDriver (this, ResId(ET_JDBCDRIVERCLASS))
,m_aJdbcUrlLabel (this, ResId(FT_CONNECTURL))
,m_aJdbcUrl (this, ResId(ET_CONNECTURL))
,m_aSeparator1 (this, ResId(FL_SEPARATOR1))
{
m_aDriver.SetModifyHdl(getControlModifiedLink());
m_aJdbcUrl.SetModifyHdl(getControlModifiedLink());
m_pUserName->SetZOrder(&m_aJdbcUrl, WINDOW_ZORDER_BEHIND);
m_pPasswordRequired->SetZOrder(m_pUserName, WINDOW_ZORDER_BEHIND);
m_pCharset->SetZOrder(m_pPasswordRequired, WINDOW_ZORDER_BEHIND);
FreeResource();
}
// -----------------------------------------------------------------------
OJdbcDetailsPage::~OJdbcDetailsPage()
{
}
// -----------------------------------------------------------------------
sal_Int32* OJdbcDetailsPage::getDetailIds()
{
static sal_Int32* pRelevantIds = NULL;
if (!pRelevantIds)
{
static sal_Int32 nRelevantIds[] =
{
DSID_JDBCDRIVERCLASS,
DSID_CHARSET,
0
};
pRelevantIds = nRelevantIds;
}
return pRelevantIds;
}
// -----------------------------------------------------------------------
SfxTabPage* OJdbcDetailsPage::Create( Window* pParent, const SfxItemSet& _rAttrSet )
{
return ( new OJdbcDetailsPage( pParent, _rAttrSet ) );
}
// -----------------------------------------------------------------------
void OJdbcDetailsPage::implInitControls(const SfxItemSet& _rSet, sal_Bool _bSaveValue)
{
OCommonBehaviourTabPage::implInitControls(_rSet, _bSaveValue);
// check whether or not the selection is invalid or readonly (invalid implies readonly, but not vice versa)
sal_Bool bValid, bReadonly;
getFlags(_rSet, bValid, bReadonly);
SFX_ITEMSET_GET(_rSet, pJdbcDrvItem, SfxStringItem, DSID_JDBCDRIVERCLASS, sal_True);
SFX_ITEMSET_GET(_rSet, pUrlItem, SfxStringItem, DSID_CONNECTURL, sal_True);
String sDriver, sURL;
if (bValid)
{
sDriver = pJdbcDrvItem->GetValue();
sURL = pUrlItem->GetValue();
}
m_aDriver.SetText(sDriver);
m_aJdbcUrl.SetText(sURL);
m_aDriver.ClearModifyFlag();
m_aJdbcUrl.ClearModifyFlag();
if (_bSaveValue)
{
m_aDriver.SaveValue();
m_aJdbcUrl.SaveValue();
}
if (bReadonly)
{
m_aDriverLabel.Disable();
m_aDriver.Disable();
m_aJdbcUrlLabel.Disable();
m_aJdbcUrl.Disable();
}
}
// -----------------------------------------------------------------------
sal_Bool OJdbcDetailsPage::FillItemSet( SfxItemSet& _rSet )
{
sal_Bool bChangedSomething = OCommonBehaviourTabPage::FillItemSet(_rSet);
FILL_STRING_ITEM(m_aDriver, _rSet, DSID_JDBCDRIVERCLASS, bChangedSomething);
FILL_STRING_ITEM(m_aJdbcUrl, _rSet, DSID_CONNECTURL, bChangedSomething);
return bChangedSomething;
}
//========================================================================
//= OAdoDetailsPage
//========================================================================
OAdoDetailsPage::OAdoDetailsPage( Window* pParent, const SfxItemSet& _rCoreAttrs )
:OCommonBehaviourTabPage(pParent, PAGE_ADO, _rCoreAttrs, CBTP_USE_UIDPWD)
,m_aAdoUrlLabel (this, ResId(FT_CONNECTURL))
,m_aAdoUrl (this, ResId(ET_CONNECTURL))
{
m_aAdoUrl.SetModifyHdl(getControlModifiedLink());
m_pUserName->SetZOrder(&m_aAdoUrl, WINDOW_ZORDER_BEHIND);
m_pPasswordRequired->SetZOrder(m_pUserName, WINDOW_ZORDER_BEHIND);
FreeResource();
}
// -----------------------------------------------------------------------
OAdoDetailsPage::~OAdoDetailsPage()
{
}
// -----------------------------------------------------------------------
sal_Int32* OAdoDetailsPage::getDetailIds()
{
static sal_Int32* pRelevantIds = NULL;
if (!pRelevantIds)
{
static sal_Int32 nRelevantIds[] =
{
0
};
pRelevantIds = nRelevantIds;
}
return pRelevantIds;
}
// -----------------------------------------------------------------------
SfxTabPage* OAdoDetailsPage::Create( Window* pParent, const SfxItemSet& _rAttrSet )
{
return ( new OAdoDetailsPage( pParent, _rAttrSet ) );
}
// -----------------------------------------------------------------------
void OAdoDetailsPage::implInitControls(const SfxItemSet& _rSet, sal_Bool _bSaveValue)
{
OCommonBehaviourTabPage::implInitControls(_rSet, _bSaveValue);
// check whether or not the selection is invalid or readonly (invalid implies readonly, but not vice versa)
sal_Bool bValid, bReadonly;
getFlags(_rSet, bValid, bReadonly);
SFX_ITEMSET_GET(_rSet, pUrlItem, SfxStringItem, DSID_CONNECTURL, sal_True);
String sURL;
if (bValid)
sURL = pUrlItem->GetValue();
m_aAdoUrl.SetText(sURL);
m_aAdoUrl.ClearModifyFlag();
if (_bSaveValue)
{
m_aAdoUrl.SaveValue();
}
if (bReadonly)
{
m_aAdoUrlLabel.Disable();
m_aAdoUrl.Disable();
}
}
// -----------------------------------------------------------------------
sal_Bool OAdoDetailsPage::FillItemSet( SfxItemSet& _rSet )
{
sal_Bool bChangedSomething = OCommonBehaviourTabPage::FillItemSet(_rSet);
FILL_STRING_ITEM(m_aAdoUrl, _rSet, DSID_CONNECTURL, bChangedSomething);
return bChangedSomething;
}
//========================================================================
//= OOdbcDetailsPage
//========================================================================
OOdbcDetailsPage::OOdbcDetailsPage( Window* pParent, const SfxItemSet& _rCoreAttrs )
:OCommonBehaviourTabPage(pParent, PAGE_ODBC, _rCoreAttrs, CBTP_USE_UIDPWD | CBTP_USE_CHARSET | CBTP_USE_OPTIONS)
,m_aSeparator1 (this, ResId(FL_SEPARATOR1))
{
FreeResource();
}
// -----------------------------------------------------------------------
SfxTabPage* OOdbcDetailsPage::Create( Window* pParent, const SfxItemSet& _rAttrSet )
{
return ( new OOdbcDetailsPage( pParent, _rAttrSet ) );
}
// -----------------------------------------------------------------------
sal_Int32* OOdbcDetailsPage::getDetailIds()
{
static sal_Int32* pRelevantIds = NULL;
if (!pRelevantIds)
{
static sal_Int32 nRelevantIds[] =
{
DSID_ADDITIONALOPTIONS,
DSID_CHARSET,
0
};
pRelevantIds = nRelevantIds;
}
return pRelevantIds;
}
//========================================================================
//= OAdabasDetailsPage
//========================================================================
OAdabasDetailsPage::OAdabasDetailsPage( Window* pParent, const SfxItemSet& _rCoreAttrs )
:OCommonBehaviourTabPage(pParent, PAGE_ODBC, _rCoreAttrs, CBTP_USE_UIDPWD | CBTP_USE_CHARSET)
// Yes, we're using the resource for the ODBC page here. It contains two controls which we don't use
// and except that it's excatly what we need here.
,m_aSeparator1 (this, ResId(FL_SEPARATOR1))
{
// move the charset related control some pixel up (as they are positioned as if above them there are the option
// controls, which is the case for the ODBC page only)
Size aMovesize(LogicToPixel(Size(0, 15), MAP_APPFONT));
Point aPos = m_pCharsetLabel->GetPosPixel();
m_pCharsetLabel->SetPosPixel(Point(aPos.X(), aPos.Y() - aMovesize.Height()));
aPos = m_pCharset->GetPosPixel();
m_pCharset->SetPosPixel(Point(aPos.X(), aPos.Y() - aMovesize.Height()));
FreeResource();
// don't use the ODBC help ids
m_pUserName->SetHelpId(HID_DSADMIN_USER_ADABAS);
m_pPasswordRequired->SetHelpId(HID_DSADMIN_PWDREC_ADABAS);
m_pCharset->SetHelpId(HID_DSADMIN_CHARSET_ADABAS);
}
// -----------------------------------------------------------------------
SfxTabPage* OAdabasDetailsPage::Create( Window* pParent, const SfxItemSet& _rAttrSet )
{
return ( new OAdabasDetailsPage( pParent, _rAttrSet ) );
}
// -----------------------------------------------------------------------
sal_Int32* OAdabasDetailsPage::getDetailIds()
{
static sal_Int32* pRelevantIds = NULL;
if (!pRelevantIds)
{
static sal_Int32 nRelevantIds[] =
{
DSID_CHARSET,
0
};
pRelevantIds = nRelevantIds;
}
return pRelevantIds;
}
//========================================================================
//= OTextDetailsPage
//========================================================================
//------------------------------------------------------------------------
OTextDetailsPage::OTextDetailsPage( Window* pParent, const SfxItemSet& _rCoreAttrs )
:OCommonBehaviourTabPage(pParent, PAGE_TEXT, _rCoreAttrs, CBTP_USE_CHARSET)
,m_aHeader (this, ResId(CB_HEADER))
,m_aFieldSeparatorLabel (this, ResId(FT_FIELDSEPARATOR))
,m_aFieldSeparator (this, ResId(CM_FIELDSEPARATOR))
,m_aTextSeparatorLabel (this, ResId(FT_TEXTSEPARATOR))
,m_aTextSeparator (this, ResId(CM_TEXTSEPARATOR))
,m_aDecimalSeparatorLabel (this, ResId(FT_DECIMALSEPARATOR))
,m_aDecimalSeparator (this, ResId(CM_DECIMALSEPARATOR))
,m_aThousandsSeparatorLabel (this, ResId(FT_THOUSANDSSEPARATOR))
,m_aThousandsSeparator (this, ResId(CM_THOUSANDSSEPARATOR))
,m_aSeparator1 (this, ResId(FL_SEPARATOR1))
,m_aExtensionLabel (this, ResId(FT_EXTENSION))
,m_aExtension (this, ResId(CM_EXTENSION))
,m_aFieldSeparatorList (ResId(STR_FIELDSEPARATORLIST))
,m_aTextSeparatorList (ResId(STR_TEXTSEPARATORLIST))
{
xub_StrLen nCnt = m_aFieldSeparatorList.GetTokenCount( '\t' );
for( xub_StrLen i=0 ; i<nCnt ; i+=2 )
m_aFieldSeparator.InsertEntry( m_aFieldSeparatorList.GetToken( i, '\t' ) );
nCnt = m_aTextSeparatorList.GetTokenCount( '\t' );
for( i=0 ; i<nCnt ; i+=2 )
m_aTextSeparator.InsertEntry( m_aTextSeparatorList.GetToken( i, '\t' ) );
// set the modify handlers
m_aHeader.SetClickHdl(getControlModifiedLink());
m_aFieldSeparator.SetUpdateDataHdl(getControlModifiedLink());
m_aFieldSeparator.SetSelectHdl(getControlModifiedLink());
m_aTextSeparator.SetUpdateDataHdl(getControlModifiedLink());
m_aTextSeparator.SetSelectHdl(getControlModifiedLink());
m_aExtension.SetSelectHdl(getControlModifiedLink());
m_aFieldSeparator.SetModifyHdl(getControlModifiedLink());
m_aTextSeparator.SetModifyHdl(getControlModifiedLink());
m_aDecimalSeparator.SetModifyHdl(getControlModifiedLink());
m_aThousandsSeparator.SetModifyHdl(getControlModifiedLink());
m_aExtension.SetModifyHdl(getControlModifiedLink());
m_aExtension.EnableAutocomplete(sal_True, sal_True);
m_pCharset->SetZOrder(&m_aExtension, WINDOW_ZORDER_BEHIND);
FreeResource();
}
// -----------------------------------------------------------------------
OTextDetailsPage::~OTextDetailsPage()
{
}
// -----------------------------------------------------------------------
sal_Int32* OTextDetailsPage::getDetailIds()
{
static sal_Int32* pRelevantIds = NULL;
if (!pRelevantIds)
{
static sal_Int32 nRelevantIds[] =
{
DSID_FIELDDELIMITER,
DSID_TEXTDELIMITER,
DSID_DECIMALDELIMITER,
DSID_THOUSANDSDELIMITER,
DSID_TEXTFILEEXTENSION,
DSID_TEXTFILEHEADER,
DSID_CHARSET,
0
};
pRelevantIds = nRelevantIds;
}
return pRelevantIds;
}
// -----------------------------------------------------------------------
SfxTabPage* OTextDetailsPage::Create( Window* pParent, const SfxItemSet& _rAttrSet )
{
return ( new OTextDetailsPage( pParent, _rAttrSet ) );
}
// -----------------------------------------------------------------------
void OTextDetailsPage::implInitControls(const SfxItemSet& _rSet, sal_Bool _bSaveValue)
{
OCommonBehaviourTabPage::implInitControls(_rSet, _bSaveValue);
// first check whether or not the selection is invalid or readonly (invalid implies readonly, but not vice versa)
sal_Bool bValid, bReadonly;
getFlags(_rSet, bValid, bReadonly);
SFX_ITEMSET_GET(_rSet, pDelItem, SfxStringItem, DSID_FIELDDELIMITER, sal_True);
SFX_ITEMSET_GET(_rSet, pStrItem, SfxStringItem, DSID_TEXTDELIMITER, sal_True);
SFX_ITEMSET_GET(_rSet, pDecdelItem, SfxStringItem, DSID_DECIMALDELIMITER, sal_True);
SFX_ITEMSET_GET(_rSet, pThodelItem, SfxStringItem, DSID_THOUSANDSDELIMITER, sal_True);
SFX_ITEMSET_GET(_rSet, pExtensionItem, SfxStringItem, DSID_TEXTFILEEXTENSION, sal_True);
SFX_ITEMSET_GET(_rSet, pHdrItem, SfxBoolItem, DSID_TEXTFILEHEADER, sal_True);
if (bValid)
{
m_aHeader.Check( pHdrItem->GetValue() );
SetSeparator(m_aFieldSeparator, m_aFieldSeparatorList, pDelItem->GetValue());
SetSeparator(m_aTextSeparator, m_aTextSeparatorList, pStrItem->GetValue());
m_aDecimalSeparator.SetText(pDecdelItem->GetValue());
m_aThousandsSeparator.SetText(pThodelItem->GetValue());
m_aExtension.SetText(pExtensionItem->GetValue());
}
if (_bSaveValue)
{
m_aHeader.SaveValue();
m_aFieldSeparator.SaveValue();
m_aTextSeparator.SaveValue();
m_aDecimalSeparator.SaveValue();
m_aThousandsSeparator.SaveValue();
m_aExtension.SaveValue();
}
if (bReadonly)
{
m_aHeader.Disable();
m_aFieldSeparatorLabel.Disable();
m_aFieldSeparator.Disable();
m_aTextSeparatorLabel.Disable();
m_aTextSeparator.Disable();
m_aDecimalSeparatorLabel.Disable();
m_aDecimalSeparator.Disable();
m_aThousandsSeparatorLabel.Disable();
m_aThousandsSeparator.Disable();
m_aExtensionLabel.Disable();
m_aExtension.Disable();
}
}
// -----------------------------------------------------------------------
sal_Bool OTextDetailsPage::checkItems()
{
OLocalResourceAccess aStringResAccess(PAGE_TEXT, RSC_TABPAGE);
// for accessing the strings which are local to our own resource block
String aErrorText;
Control* pErrorWin = NULL;
// if (!m_aFieldSeparator.GetText().Len())
// bug (#42168) if this line is compiled under OS2 (in a product environent)
// -> use a temporary variable
String aDelText(m_aFieldSeparator.GetText());
if(!aDelText.Len())
{ // Kein FeldTrenner
aErrorText = String(ResId(STR_DELIMITER_MISSING));
aErrorText.SearchAndReplaceAscii("#1",m_aFieldSeparatorLabel.GetText());
pErrorWin = &m_aFieldSeparator;
}
else if (!m_aDecimalSeparator.GetText().Len())
{ // kein Decimaltrenner
aErrorText = String(ResId(STR_DELIMITER_MISSING));
aErrorText.SearchAndReplaceAscii("#1",m_aDecimalSeparatorLabel.GetText());
pErrorWin = &m_aDecimalSeparator;
}
else if (m_aTextSeparator.GetText() == m_aFieldSeparator.GetText())
{ // Feld und TextTrenner duerfen nicht gleich sein
aErrorText = String(ResId(STR_DELIMITER_MUST_DIFFER));
aErrorText.SearchAndReplaceAscii("#1",m_aTextSeparatorLabel.GetText());
aErrorText.SearchAndReplaceAscii("#2",m_aFieldSeparatorLabel.GetText());
pErrorWin = &m_aTextSeparator;
}
else if (m_aDecimalSeparator.GetText() == m_aThousandsSeparator.GetText())
{ // Tausender und DecimalTrenner duerfen nicht gleich sein
aErrorText = String(ResId(STR_DELIMITER_MUST_DIFFER));
aErrorText.SearchAndReplaceAscii("#1",m_aDecimalSeparatorLabel.GetText());
aErrorText.SearchAndReplaceAscii("#2",m_aThousandsSeparatorLabel.GetText());
pErrorWin = &m_aDecimalSeparator;
}
else if (m_aFieldSeparator.GetText() == m_aThousandsSeparator.GetText())
{ // Tausender und FeldTrenner duerfen nicht gleich sein
aErrorText = String(ResId(STR_DELIMITER_MUST_DIFFER));
aErrorText.SearchAndReplaceAscii("#1",m_aFieldSeparatorLabel.GetText());
aErrorText.SearchAndReplaceAscii("#2",m_aThousandsSeparatorLabel.GetText());
pErrorWin = &m_aFieldSeparator;
}
else if (m_aFieldSeparator.GetText() == m_aDecimalSeparator.GetText())
{ // Zehner und FeldTrenner duerfen nicht gleich sein
aErrorText = String(ResId(STR_DELIMITER_MUST_DIFFER));
aErrorText.SearchAndReplaceAscii("#1",m_aFieldSeparatorLabel.GetText());
aErrorText.SearchAndReplaceAscii("#2",m_aDecimalSeparatorLabel.GetText());
pErrorWin = &m_aFieldSeparator;
}
else if (m_aTextSeparator.GetText() == m_aThousandsSeparator.GetText())
{ // Tausender und TextTrenner duerfen nicht gleich sein
aErrorText = String(ResId(STR_DELIMITER_MUST_DIFFER));
aErrorText.SearchAndReplaceAscii("#1",m_aTextSeparatorLabel.GetText());
aErrorText.SearchAndReplaceAscii("#2",m_aThousandsSeparatorLabel.GetText());
pErrorWin = &m_aTextSeparator;
}
else if (m_aTextSeparator.GetText() == m_aDecimalSeparator.GetText())
{ // Zehner und TextTrenner duerfen nicht gleich sein
aErrorText = String(ResId(STR_DELIMITER_MUST_DIFFER));
aErrorText.SearchAndReplaceAscii("#1",m_aTextSeparatorLabel.GetText());
aErrorText.SearchAndReplaceAscii("#2",m_aDecimalSeparatorLabel.GetText());
pErrorWin = &m_aTextSeparator;
}
else if ( (m_aExtension.GetText().Search('*') != STRING_NOTFOUND)
||
(m_aExtension.GetText().Search('?') != STRING_NOTFOUND)
)
{
aErrorText = String(ResId(STR_NO_WILDCARDS));
aErrorText.SearchAndReplaceAscii("#1",m_aExtensionLabel.GetText());
pErrorWin = &m_aExtension;
}
else
return sal_True;
aErrorText.EraseAllChars('~');
ErrorBox(NULL, WB_OK, aErrorText).Execute();
pErrorWin->GrabFocus();
return 0;
}
// -----------------------------------------------------------------------
sal_Bool OTextDetailsPage::FillItemSet( SfxItemSet& rSet )
{
sal_Bool bChangedSomething = OCommonBehaviourTabPage::FillItemSet(rSet);
if( m_aHeader.IsChecked() != m_aHeader.GetSavedValue() )
{
rSet.Put( SfxBoolItem(DSID_TEXTFILEHEADER, m_aHeader.IsChecked() ) );
bChangedSomething = sal_True;
}
if( m_aFieldSeparator.GetText() != m_aFieldSeparator.GetSavedValue() )
{
rSet.Put( SfxStringItem(DSID_FIELDDELIMITER, GetSeparator( m_aFieldSeparator, m_aFieldSeparatorList) ) );
bChangedSomething = sal_True;
}
if( m_aTextSeparator.GetText() != m_aTextSeparator.GetSavedValue() )
{
rSet.Put( SfxStringItem(DSID_TEXTDELIMITER, GetSeparator( m_aTextSeparator, m_aTextSeparatorList) ) );
bChangedSomething = sal_True;
}
if( m_aDecimalSeparator.GetText() != m_aDecimalSeparator.GetSavedValue() )
{
rSet.Put( SfxStringItem(DSID_DECIMALDELIMITER, m_aDecimalSeparator.GetText().Copy(0, 1) ) );
bChangedSomething = sal_True;
}
if( m_aThousandsSeparator.GetText() != m_aThousandsSeparator.GetSavedValue() )
{
rSet.Put( SfxStringItem(DSID_THOUSANDSDELIMITER, m_aThousandsSeparator.GetText().Copy(0,1) ) );
bChangedSomething = sal_True;
}
if( m_aExtension.GetText() != m_aExtension.GetSavedValue() )
{
rSet.Put( SfxStringItem(DSID_TEXTFILEEXTENSION, m_aExtension.GetText()));
bChangedSomething = sal_True;
}
return bChangedSomething;
}
//------------------------------------------------------------------------
String OTextDetailsPage::GetSeparator( const ComboBox& rBox, const String& rList )
{
sal_Unicode nTok = '\t';
sal_Int32 nRet(0);
xub_StrLen nPos(rBox.GetEntryPos( rBox.GetText() ));
if( nPos == COMBOBOX_ENTRY_NOTFOUND )
return rBox.GetText().Copy(0);
else
return String(rList.GetToken((nPos*2)+1, nTok ).ToInt32());
// somewhat strange ... translates for instance an "32" into " "
}
//------------------------------------------------------------------------
void OTextDetailsPage::SetSeparator( ComboBox& rBox, const String& rList, const String& rVal )
{
char nTok = '\t';
xub_StrLen nCnt(rList.GetTokenCount( nTok ));
xub_StrLen i;
for( i=0 ; i<nCnt ; i+=2 )
{
String sTVal(rList.GetToken( i+1, nTok ).ToInt32());
if( sTVal == rVal )
{
rBox.SetText( rList.GetToken( i, nTok ) );
break;
}
}
if( i >= nCnt )
{
rBox.SetText( rVal.Copy(0, 1) );
}
}
//========================================================================
//= OTableSubscriptionPage
//========================================================================
//------------------------------------------------------------------------
OTableSubscriptionPage::OTableSubscriptionPage( Window* pParent, const SfxItemSet& _rCoreAttrs )
:OGenericAdministrationPage( pParent, ModuleRes(PAGE_TABLESUBSCRIPTION), _rCoreAttrs )
,m_aTables (this, ResId(GB_TABLESUBSCRIPTION))
,m_aIncludeAll (this, ResId(RB_INCLUDEALL))
,m_aIncludeNone (this, ResId(RB_INCLUDENONE))
,m_aIncludeSelected (this, ResId(RB_INCLUDESPECIFIC))
,m_aTablesList (this, ResId(CTL_TABLESUBSCRIPTION))
,m_aSuppressVersionColumns(this, ResId(CB_SUPPRESVERSIONCL))
,m_bCheckedAll (sal_True)
,m_bCatalogAtStart (sal_True)
,m_bInitializingControls(sal_False)
,m_pLastCheckedButton (NULL)
,m_pAdminDialog (NULL)
{
m_aIncludeAll.SetClickHdl(LINK(this, OTableSubscriptionPage, OnRadioButtonClicked));
m_aIncludeNone.SetClickHdl(LINK(this, OTableSubscriptionPage, OnRadioButtonClicked));
m_aIncludeSelected.SetClickHdl(LINK(this, OTableSubscriptionPage, OnRadioButtonClicked));
m_aTablesList.SetCheckHandler(getControlModifiedLink());
m_aSuppressVersionColumns.SetClickHdl(getControlModifiedLink());
// initialize the TabListBox
m_aTablesList.SetSelectionMode( MULTIPLE_SELECTION );
m_aTablesList.SetDragDropMode( 0 );
m_aTablesList.EnableInplaceEditing( sal_False );
m_aTablesList.SetWindowBits(WB_BORDER | WB_HASLINES | WB_HASLINESATROOT | WB_SORT | WB_HASBUTTONS | WB_HSCROLL |WB_HASBUTTONSATROOT);
m_aTablesList.Clear();
FreeResource();
m_aTablesList.SetCheckButtonHdl(getControlModifiedLink());
}
//------------------------------------------------------------------------
OTableSubscriptionPage::~OTableSubscriptionPage()
{
}
//------------------------------------------------------------------------
SfxTabPage* OTableSubscriptionPage::Create( Window* pParent, const SfxItemSet& rAttrSet )
{
return ( new OTableSubscriptionPage( pParent, rAttrSet ) );
}
//------------------------------------------------------------------------
void OTableSubscriptionPage::implCheckTables(const Sequence< ::rtl::OUString >& _rTables)
{
// the meta data for the current connection, used for splitting up table names
Reference< XDatabaseMetaData > xMeta;
try
{
if (m_xCurrentConnection.is())
xMeta = m_xCurrentConnection->getMetaData();
}
catch(SQLException&)
{
DBG_ERROR("OTableSubscriptionPage::implCheckTables : could not retrieve the current connection's meta data!");
}
// uncheck all
SvLBoxEntry* pUncheckLoop = m_aTablesList.First();
while (pUncheckLoop)
{
m_aTablesList.SetCheckButtonState(pUncheckLoop, SV_BUTTON_UNCHECKED);
pUncheckLoop = m_aTablesList.Next(pUncheckLoop);
}
// check the ones which are in the list
String aListBoxTable;
::rtl::OUString aCatalog,aSchema,aName;
const ::rtl::OUString* pIncludeTable = _rTables.getConstArray();
for (sal_Int32 i=0; i<_rTables.getLength(); ++i, ++pIncludeTable)
{
if (xMeta.is())
qualifiedNameComponents(xMeta, pIncludeTable->getStr(), aCatalog, aSchema, aName);
else
aName = pIncludeTable->getStr();
SvLBoxEntry* pCatalog = m_aTablesList.GetEntryPosByName(aCatalog);
SvLBoxEntry* pSchema = m_aTablesList.GetEntryPosByName(aSchema,pCatalog);
SvLBoxEntry* pEntry = m_aTablesList.GetEntryPosByName(aName,pSchema);
if(pEntry)
m_aTablesList.SetCheckButtonState(pEntry, SV_BUTTON_CHECKED);
}
m_aTablesList.CheckButtons();
m_bCheckedAll = sal_False;
m_aLastDetailedSelection = _rTables;
}
//------------------------------------------------------------------------
void OTableSubscriptionPage::implInitControls(const SfxItemSet& _rSet, sal_Bool _bSaveValue)
{
// check whether or not the selection is invalid or readonly (invalid implies readonly, but not vice versa)
sal_Bool bValid, bReadonly;
getFlags(_rSet, bValid, bReadonly);
bValid = bValid && m_xCurrentConnection.is();
bReadonly = bReadonly || !bValid;
m_aTables.Enable(!bReadonly);
m_aTablesList.Enable(!bReadonly);
m_aIncludeAll.Enable(!bReadonly);
m_aIncludeNone.Enable(!bReadonly);
m_aIncludeSelected.Enable(!bReadonly);
m_aSuppressVersionColumns.Enable(!bReadonly);
m_bCheckedAll = sal_True;
// get the current table filter
SFX_ITEMSET_GET(_rSet, pTableFilter, OStringListItem, DSID_TABLEFILTER, sal_True);
SFX_ITEMSET_GET(_rSet, pSuppress, SfxBoolItem, DSID_SUPPRESSVERSIONCL, sal_True);
Sequence< ::rtl::OUString > aTableFilter;
sal_Bool bSuppressVersionColumns = sal_True;
if (pTableFilter)
aTableFilter = pTableFilter->getList();
if (pSuppress)
bSuppressVersionColumns = pSuppress->GetValue();
m_bInitializingControls = sal_True;
if (!aTableFilter.getLength())
{ // no tables visible
CheckAll(sal_False);
m_aIncludeNone.Check();
LINK(this, OTableSubscriptionPage, OnRadioButtonClicked).Call(&m_aIncludeNone);
}
else
{
if ((1 == aTableFilter.getLength()) && aTableFilter[0].equalsAsciiL("%", 1))
{ // all tables visible
CheckAll(sal_True);
m_aIncludeAll.Check();
LINK(this, OTableSubscriptionPage, OnRadioButtonClicked).Call(&m_aIncludeAll);
}
else
{
m_aLastDetailedSelection = aTableFilter;
m_aIncludeSelected.Check();
LINK(this, OTableSubscriptionPage, OnRadioButtonClicked).Call(&m_aIncludeSelected);
}
}
m_bInitializingControls = sal_False;
if (!bValid)
m_aSuppressVersionColumns.Check(!bSuppressVersionColumns);
if (_bSaveValue)
m_aSuppressVersionColumns.SaveValue();
if (!bValid)
{
if (m_pLastCheckedButton)
m_pLastCheckedButton->Check(sal_False);
m_pLastCheckedButton = NULL;
}
}
//------------------------------------------------------------------------
void OTableSubscriptionPage::CheckAll( sal_Bool bCheck )
{
SvButtonState eState = bCheck ? SV_BUTTON_CHECKED : SV_BUTTON_UNCHECKED;
SvLBoxEntry* pEntry = m_aTablesList.GetModel()->First();
while(pEntry)
{
m_aTablesList.SetCheckButtonState( pEntry, eState);
pEntry = m_aTablesList.GetModel()->Next(pEntry);
}
m_bCheckedAll = bCheck;
}
//------------------------------------------------------------------------
int OTableSubscriptionPage::DeactivatePage(SfxItemSet* _pSet)
{
int nResult = OGenericAdministrationPage::DeactivatePage(_pSet);
// dispose the connection, we don't need it anymore, so we're not wasting resources
Reference< XComponent > xComp(m_xCurrentConnection, UNO_QUERY);
if (xComp.is())
try { xComp->dispose(); } catch (RuntimeException&) { }
m_xCurrentConnection = NULL;
return nResult;
}
//------------------------------------------------------------------------
void OTableSubscriptionPage::ActivatePage(const SfxItemSet& _rSet)
{
DBG_ASSERT(!m_xCurrentConnection.is(), "OTableSubscriptionPage::ActivatePage: already have an active connection! ");
// check whether or not the selection is invalid or readonly (invalid implies readonly, but not vice versa)
sal_Bool bValid, bReadonly;
getFlags(_rSet, bValid, bReadonly);
if (bValid)
{ // get the current table list from the connection for the current settings
// the PropertyValues for the current dialog settings
Sequence< PropertyValue > aConnectionParams;
DBG_ASSERT(m_pAdminDialog, "OTableSubscriptionPage::ActivatePage : need a parent dialog doing the translation!");
if (m_pAdminDialog)
if (!m_pAdminDialog->getCurrentSettings(aConnectionParams))
{
OGenericAdministrationPage::ActivatePage(_rSet);
m_aTablesList.Clear();
return;
}
// the current DSN
String sURL;
SFX_ITEMSET_GET(_rSet, pUrlItem, SfxStringItem, DSID_CONNECTURL, sal_True);
sURL = pUrlItem->GetValue();
// fill the table list with this connection information
SQLExceptionInfo aErrorInfo;
try
{
WaitObject aWaitCursor(this);
m_xCurrentConnection = m_aTablesList.UpdateTableList(sURL, aConnectionParams);
}
catch (SQLContext& e) { aErrorInfo = SQLExceptionInfo(e); }
catch (SQLWarning& e) { aErrorInfo = SQLExceptionInfo(e); }
catch (SQLException& e) { aErrorInfo = SQLExceptionInfo(e); }
if (aErrorInfo.isValid())
{
// establishing the connection failed. Show an error window and exit.
OSQLMessageBox aMessageBox(GetParent(), aErrorInfo, WB_OK | WB_DEF_OK, OSQLMessageBox::Error);
aMessageBox.Execute();
m_aTablesList.Enable(sal_False);
m_aTables.Enable(sal_False);
m_aSuppressVersionColumns.Enable(sal_False);
m_aTablesList.Clear();
}
else
{
// in addition, we need some infos about the connection used
m_sCatalogSeparator = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(".")); // (default)
m_bCatalogAtStart = sal_True; // (default)
try
{
Reference< XDatabaseMetaData > xMeta;
if (m_xCurrentConnection.is())
xMeta = m_xCurrentConnection->getMetaData();
if (xMeta.is())
{
m_sCatalogSeparator = xMeta->getCatalogSeparator();
m_bCatalogAtStart = xMeta->isCatalogAtStart();
}
}
catch(SQLException&)
{
DBG_ERROR("OTableSubscriptionPage::ActivatePage : could not retrieve the qualifier separator for the used connection !");
}
}
}
m_pLastCheckedButton = NULL;
OGenericAdministrationPage::ActivatePage(_rSet);
}
//------------------------------------------------------------------------
Sequence< ::rtl::OUString > OTableSubscriptionPage::collectDetailedSelection() const
{
Sequence< ::rtl::OUString > aTableFilter;
static const ::rtl::OUString sDot(RTL_CONSTASCII_USTRINGPARAM("."));
::rtl::OUString sComposedName;
SvLBoxEntry* pEntry = m_aTablesList.GetModel()->First();
while(pEntry)
{
if(m_aTablesList.GetCheckButtonState(pEntry) == SV_BUTTON_CHECKED && !m_aTablesList.GetModel()->HasChilds(pEntry))
{ // checked and a leaf, which means it's no catalog, not schema, but a real table
::rtl::OUString sCatalog;
if(m_aTablesList.GetModel()->HasParent(pEntry))
{
SvLBoxEntry* pSchema = m_aTablesList.GetModel()->GetParent(pEntry);
if(m_aTablesList.GetModel()->HasParent(pSchema))
{
SvLBoxEntry* pCatalog = m_aTablesList.GetModel()->GetParent(pSchema);
if (m_bCatalogAtStart)
{
sComposedName += m_aTablesList.GetEntryText( pCatalog );
sComposedName += m_sCatalogSeparator;
}
else
{
sCatalog += m_sCatalogSeparator;
sCatalog += m_aTablesList.GetEntryText( pCatalog );
}
}
sComposedName += m_aTablesList.GetEntryText( pSchema );
sComposedName += sDot;
}
sComposedName += m_aTablesList.GetEntryText( pEntry );
if (!m_bCatalogAtStart)
sComposedName += sCatalog;
// need some space
sal_Int32 nOldLen = aTableFilter.getLength();
aTableFilter.realloc(nOldLen + 1);
// add the new name
aTableFilter[nOldLen] = sComposedName;
// reset the composed name
sComposedName = String();
}
pEntry = m_aTablesList.GetModel()->Next(pEntry);
}
return aTableFilter;
}
//------------------------------------------------------------------------
sal_Bool OTableSubscriptionPage::FillItemSet( SfxItemSet& _rCoreAttrs )
{
/////////////////////////////////////////////////////////////////////////
// create the output string which contains all the table names
Sequence< ::rtl::OUString > aTableFilter;
if (m_aIncludeAll.IsChecked())
{
aTableFilter.realloc(1);
aTableFilter[0] = ::rtl::OUString("%", 1, RTL_TEXTENCODING_ASCII_US);
}
else if (m_aIncludeNone.IsChecked())
{
// nothing to do: the sequence is already empty, which means "no tables"
}
else
{
aTableFilter = collectDetailedSelection();
}
_rCoreAttrs.Put( OStringListItem(DSID_TABLEFILTER, aTableFilter) );
if (m_aSuppressVersionColumns.IsChecked() != m_aSuppressVersionColumns.GetSavedValue())
_rCoreAttrs.Put( SfxBoolItem(DSID_SUPPRESSVERSIONCL, !m_aSuppressVersionColumns.IsChecked()) );
return sal_True;
}
//------------------------------------------------------------------------
IMPL_LINK( OTableSubscriptionPage, OnRadioButtonClicked, Button*, pButton )
{
if (&m_aIncludeSelected == m_pLastCheckedButton)
m_aLastDetailedSelection = collectDetailedSelection();
m_pLastCheckedButton = static_cast<RadioButton*>(pButton);
if (m_aIncludeAll.IsChecked() || m_aIncludeNone.IsChecked())
{
m_aTablesList.Enable(sal_False);
CheckAll(m_aIncludeAll.IsChecked());
}
else
{
m_aTablesList.Enable(sal_True);
implCheckTables(m_aLastDetailedSelection);
}
// as the enable state has been changed, invalidate the control
m_aTablesList.Invalidate();
if (!m_bInitializingControls)
callModifiedHdl();
return 0L;
}
//.........................................................................
} // namespace dbaui
//.........................................................................
/*************************************************************************
* history:
* $Log: not supported by cvs2svn $
* Revision 1.25 2001/01/04 11:21:45 fs
* #81485# +OAdoDetailsPage
*
* Revision 1.24 2001/01/04 09:43:26 fs
* #81615# auto completion for the extension checkbox is case sensitive
*
* Revision 1.23 2000/12/11 16:33:15 fs
* reversed the semantics of the SuppressVersionColumns checkbox
*
* Revision 1.22 2000/12/07 15:04:40 fs
* #81490# reset the password when changing the user
*
* Revision 1.21 2000/12/07 14:27:53 fs
* #80939# clear the tables list when cancelling the password dialog
*
* Revision 1.20 2000/12/07 14:15:42 oj
* #81131# check installed adabas dbs
*
* Revision 1.19 2000/12/01 08:06:01 kso
* #80644# - ::ucb::ContentCreationException -> ::com::sun::star::ucb::ContentCreationException
*
* Revision 1.18 2000/11/30 08:32:30 fs
* #80003# changed some sal_uInt16 to sal_Int32 (need some -1's)
*
* Revision 1.17 2000/11/29 22:29:40 fs
* #80003# implementation of the character set map changed
*
* Revision 1.16 2000/11/28 13:48:15 fs
* #80152# m_bDisplayingDeleted -> m_bDisplayingInvalid
*
* Revision 1.15 2000/11/28 11:41:42 oj
* #80827# check dbroot if dbconfig failed
*
* Revision 1.14 2000/11/22 15:44:05 oj
* #80269# remove property long names
*
* Revision 1.13 2000/11/10 17:35:29 fs
* no parameter in checkItems anymore - did not make sense in the context it is called / some small bug fixes
*
* Revision 1.12 2000/11/02 15:20:04 fs
* #79983# +isBrowseable / #79830# +checkItems
*
* Revision 1.11 2000/11/02 14:18:21 fs
* #79967# check the getenv return against NULL
*
* Revision 1.10 2000/10/30 15:22:25 fs
* no password fields anymore - don't want to have them in and _data source aministration_ dialog
*
* Revision 1.9 2000/10/30 13:48:29 fs
* some help ids
*
* Revision 1.8 2000/10/24 12:11:15 fs
* functionality added: browsing for system data sources (ODBC/Adabas/dbase/text)
*
* Revision 1.7 2000/10/20 09:53:17 fs
* handling for the SuppresVersionColumns property of a data source
*
* Revision 1.6 2000/10/18 08:48:16 obo
* Syntax error with linux compiler #65293#
*
* Revision 1.5 2000/10/13 16:04:22 fs
* Separator changed to string / getDetailIds
*
* Revision 1.4 2000/10/12 16:20:42 fs
* new implementations ... still under construction
*
* Revision 1.3 2000/10/11 11:31:02 fs
* new implementations - still under construction
*
* Revision 1.2 2000/10/09 12:39:28 fs
* some (a lot of) new imlpementations - still under development
*
* Revision 1.1 2000/10/05 10:04:12 fs
* initial checkin
*
*
* Revision 1.0 26.09.00 11:47:18 fs
************************************************************************/
|