summaryrefslogtreecommitdiff
path: root/extensions/source/propctrlr/formcontroller.cxx
blob: 05fe59a6ed4113eda5cf394aa7d3bd6af16a8fcd (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
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
/*************************************************************************
 *
 *  $RCSfile: formcontroller.cxx,v $
 *
 *  $Revision: 1.53 $
 *
 *  last change: $Author: fs $ $Date: 2002-12-10 17:51:04 $
 *
 *  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): _______________________________________
 *
 *
 ************************************************************************/
#define ITEMID_MACRO SID_ATTR_MACROITEM

#ifndef _EXTENSIONS_PROPCTRLR_PROPCONTROLLER_HXX_
#include "propcontroller.hxx"
#endif
#ifndef _EXTENSIONS_PROPCTRLR_USERCONTROL_HXX_
#include "usercontrol.hxx"
#endif
#ifndef _COMPHELPER_PROPERTY_HXX_
#include <comphelper/property.hxx>
#endif
#ifndef _COMPHELPER_TYPES_HXX_
#include <comphelper/types.hxx>
#endif
#ifndef _EXTENSIONS_FORMSCTRLR_FORMBROWSERTOOLS_HXX_
#include "formbrowsertools.hxx"
#endif
#ifndef _EXTENSIONS_PROPCTRLR_MODULEPRC_HXX_
#include "modulepcr.hxx"
#endif
#ifndef _EXTENSIONS_PROPCTRLR_LINEDESCRIPTOR_HXX_
#include "linedescriptor.hxx"
#endif
#ifndef _EXTENSIONS_FORMSCTRLR_FORMSTRINGS_HXX_
#include "formstrings.hxx"
#endif
#ifndef _EXTENSIONS_PROPCTRLR_PROPRESID_HRC_
#include "propresid.hrc"
#endif
#ifndef _EXTENSIONS_PROPCTRLR_FORMMETADATA_HXX_
#include "formmetadata.hxx"
#endif
#ifndef _COMPHELPER_EXTRACT_HXX_
#include <comphelper/extract.hxx>
#endif
#ifndef _TOOLS_DEBUG_HXX
#include <tools/debug.hxx>
#endif
#ifndef _SVX_SVXIDS_HRC
#include <svx/svxids.hrc>
#endif
#ifndef _SFXITEMSET_HXX
#include <svtools/itemset.hxx>
#endif
#ifndef _SFXAPP_HXX
#include <sfx2/app.hxx>
#endif
#ifndef _COM_SUN_STAR_UI_DIALOGS_EXTENDEDFILEPICKERELEMENTIDS_HPP_
#include <com/sun/star/ui/dialogs/ExtendedFilePickerElementIds.hpp>
#endif
#ifndef _COM_SUN_STAR_UI_DIALOGS_XFILEPICKERCONTROLACCESS_HPP_
#include <com/sun/star/ui/dialogs/XFilePickerControlAccess.hpp>
#endif
#ifndef _COM_SUN_STAR_UI_DIALOGS_XFILEPICKER_HPP_
#include <com/sun/star/ui/dialogs/XFilePicker.hpp>
#endif
#ifndef _COM_SUN_STAR_AWT_FONTDESCRIPTOR_HPP_
#include <com/sun/star/awt/FontDescriptor.hpp>
#endif
#ifndef _COM_SUN_STAR_SDBC_XDATASOURCE_HPP_
#include <com/sun/star/sdbc/XDataSource.hpp>
#endif
#ifndef _COM_SUN_STAR_UTIL_XMODIFIABLE_HPP_
#include <com/sun/star/util/XModifiable.hpp>
#endif
#ifndef _COM_SUN_STAR_BEANS_PROPERTYATTRIBUTE_HPP_
#include <com/sun/star/beans/PropertyAttribute.hpp>
#endif
#ifndef _COM_SUN_STAR_UTIL_XNUMBERFORMATSSUPPLIER_HPP_
#include <com/sun/star/util/XNumberFormatsSupplier.hpp>
#endif
#ifndef _COM_SUN_STAR_UTIL_XNUMBERFORMATTYPES_HPP_
#include <com/sun/star/util/XNumberFormatTypes.hpp>
#endif
#ifndef _COM_SUN_STAR_SDBC_XPREPAREDSTATEMENT_HPP_
#include <com/sun/star/sdbc/XPreparedStatement.hpp>
#endif
#ifndef _COM_SUN_STAR_SDBCX_XTABLESSUPPLIER_HPP_
#include <com/sun/star/sdbcx/XTablesSupplier.hpp>
#endif
#ifndef _COM_SUN_STAR_FORM_LISTSOURCETYPE_HPP_
#include <com/sun/star/form/ListSourceType.hpp>
#endif
#ifndef _COM_SUN_STAR_SDB_XQUERIESSUPPLIER_HPP_
#include <com/sun/star/sdb/XQueriesSupplier.hpp>
#endif
#ifndef _COM_SUN_STAR_SDBCX_XCOLUMNSSUPPLIER_HPP_
#include <com/sun/star/sdbcx/XColumnsSupplier.hpp>
#endif
#ifndef _COM_SUN_STAR_FORM_FORMCOMPONENTTYPE_HPP_
#include <com/sun/star/form/FormComponentType.hpp>
#endif
#ifndef _COM_SUN_STAR_UNO_XNAMINGSERVICE_HPP_
#include <com/sun/star/uno/XNamingService.hpp>
#endif
#ifndef _COM_SUN_STAR_FORM_XGRIDCOLUMNFACTORY_HPP_
#include <com/sun/star/form/XGridColumnFactory.hpp>
#endif
#ifndef _CONNECTIVITY_DBTOOLS_HXX_
#include <connectivity/dbtools.hxx>
#endif
#ifndef _DBHELPER_DBEXCEPTION_HXX_
#include <connectivity/dbexception.hxx>
#endif
#ifndef _TOOLKIT_HELPER_VCLUNOHELPER_HXX_
#include <toolkit/helper/vclunohelper.hxx>
#endif
#ifndef _NUMUNO_HXX
#include <svtools/numuno.hxx>
#endif
#ifndef _SFXINTITEM_HXX
#include <svtools/intitem.hxx>
#endif
#define ITEMID_NUMBERINFO   SID_ATTR_NUMBERFORMAT_INFO
#ifndef _SVX_NUMINF_HXX
#include <svx/numinf.hxx>
#endif
#ifndef _BASEDLGS_HXX
#include <sfx2/basedlgs.hxx>
#endif
#ifndef _SV_WRKWIN_HXX
#include <vcl/wrkwin.hxx>
#endif
#ifndef _SVX_NUMFMT_HXX
#include <svx/numfmt.hxx>
#endif
#ifndef _SV_MSGBOX_HXX
#include <vcl/msgbox.hxx>
#endif
#ifndef _EXTENSIONS_PROPCTRLR_PROPERTYEDITOR_HXX_
#include "propertyeditor.hxx"
#endif
#ifndef _SV_WAITOBJ_HXX
#include <vcl/waitobj.hxx>
#endif
#ifndef _EXTENSIONS_PROPCTRLR_FONTDIALOG_HXX_
#include "fontdialog.hxx"
#endif
#ifndef _FILEDLGHELPER_HXX
#include <sfx2/filedlghelper.hxx>
#endif

#ifndef _TOOLKIT_HELPER_VCLUNOHELPER_HXX_
#include <toolkit/unohlp.hxx>
#endif
#ifndef _COM_SUN_STAR_SDB_XSQLQUERYCOMPOSERFACTORY_HPP_
#include <com/sun/star/sdb/XSQLQueryComposerFactory.hpp>
#endif
#ifndef _COM_SUN_STAR_SDB_SQLCONTEXT_HPP_
#include <com/sun/star/sdb/SQLContext.hpp>
#endif
#ifndef _CTRLTOOL_HXX
#include <svtools/ctrltool.hxx>
#endif
#ifndef _SVX_CHARDLG_HXX
#include <svx/chardlg.hxx>
#endif
#ifndef _EXTENSIONS_FORMCTRLR_PROPRESID_HRC_
#include "formresid.hrc"
#endif

// event handling
#ifndef _COM_SUN_STAR_SCRIPT_SCRIPTEVENTDESCRIPTOR_HPP_
#include <com/sun/star/script/ScriptEventDescriptor.hpp>
#endif
#ifndef _COM_SUN_STAR_SCRIPT_XSCRIPTEVENTSSUPPLIER_HPP_
#include <com/sun/star/script/XScriptEventsSupplier.hpp>
#endif
#ifndef _COM_SUN_STAR_CONTAINER_XNAMECONTAINER_HPP_
#include <com/sun/star/container/XNameContainer.hpp>
#endif

#ifndef _MACROPG_HXX
#include <sfx2/macropg.hxx>
#endif
#ifndef _COM_SUN_STAR_CONTAINER_XINDEXACCESS_HPP_
#include <com/sun/star/container/XIndexAccess.hpp>
#endif
#ifndef _SFXMACITEM_HXX
#include <svtools/macitem.hxx>
#endif
#define LINETYPE_EVENT  reinterpret_cast<void*>(0xFFFFFFFF)

#ifndef _EXTENSIONS_FORMCTRLR_FORMHELPID_HRC_
#include "formhelpid.hrc"
#endif
#ifndef _COMPHELPER_STLTYPES_HXX_
#include <comphelper/stl_types.hxx>
#endif

#ifndef _SV_COLRDLG_HXX
#include <svtools/colrdlg.hxx>
#endif
#ifndef _EXTENSIONS_PROPCTRLR_SELECTLABELDIALOG_HXX_
#include "selectlabeldialog.hxx"
#endif
#ifndef SVTOOLS_URIHELPER_HXX
#include <svtools/urihelper.hxx>
#endif

//............................................................................
namespace pcr
{
//............................................................................

    using namespace ::com::sun::star::uno;
    using namespace ::com::sun::star::form;
    using namespace ::com::sun::star::sdb;
    using namespace ::com::sun::star::sdbc;
    using namespace ::com::sun::star::sdbcx;
    using namespace ::com::sun::star::beans;
    using namespace ::com::sun::star::script;
    using namespace ::com::sun::star::lang;
    using namespace ::com::sun::star::util;
    using namespace ::com::sun::star::ui::dialogs;
    using namespace ::com::sun::star::container;
    using namespace ::dbtools;

    //========================================================================
    //= helper
    //========================================================================
    Sequence< ::rtl::OUString> getEventMethods(const Type& type)
    {
        typelib_InterfaceTypeDescription *pType=0;
        type.getDescription( (typelib_TypeDescription**)&pType);

        if (!pType)
            return Sequence< ::rtl::OUString>();

        Sequence< ::rtl::OUString> aNames(pType->nMembers);
        ::rtl::OUString* pNames = aNames.getArray();
        for (sal_Int32 i=0;i<pType->nMembers;i++,++pNames)
        {
            // the decription reference
            typelib_TypeDescriptionReference* pMemberDescriptionReference = pType->ppMembers[i];
            // the description for the reference
            typelib_TypeDescription* pMemberDescription = NULL;
            typelib_typedescriptionreference_getDescription(&pMemberDescription, pMemberDescriptionReference);
            if (pMemberDescription)
            {
                typelib_InterfaceMemberTypeDescription* pRealMemberDescription =
                    reinterpret_cast<typelib_InterfaceMemberTypeDescription*>(pMemberDescription);
                *pNames = pRealMemberDescription->pMemberName;
            }
        }

        typelib_typedescription_release( (typelib_TypeDescription *)pType );
        return aNames;
    }

    //------------------------------------------------------------------------
    class OLineDescriptorLess
    {
    public:
        bool operator() (const OLineDescriptor& lhs, const OLineDescriptor& rhs) const
        {
            return lhs.nUniqueButtonId < rhs.nUniqueButtonId;
        }
    };

    //========================================================================
    //= OPropertyBrowserController
    //========================================================================
    //------------------------------------------------------------------------
    void OPropertyBrowserController::initFormStuff()
    {
        m_pPropertyInfo = new OFormPropertyInfoService();
    }

    //------------------------------------------------------------------------
    void OPropertyBrowserController::deinitFormStuff()
    {
        delete static_cast<const OFormPropertyInfoService*>(m_pPropertyInfo);
        m_pPropertyInfo = NULL;
    }

    //------------------------------------------------------------------------
    ::rtl::OUString OPropertyBrowserController::AnyToString( const Any& rValue, const Property& _rProp, sal_Int32 _nPropId)
    {
        ::rtl::OUString sReturn;
        if (!rValue.hasValue())
            return sReturn;

        try
        {
            sReturn = convertSimpleToString(rValue);

            // translations for some known types
            switch(rValue.getValueTypeClass())
            {
                // booleans
                case TypeClass_BOOLEAN:
                {
                    String aEntries(ModuleRes(RID_STR_BOOL));
                    sReturn = ::comphelper::getBOOL(rValue) ? aEntries.GetToken(1) : aEntries.GetToken(0);
                }
                break;

                // sequences
                case TypeClass_SEQUENCE:
                {
                    // string sequences
                    if (rValue.getValueType() == ::getCppuType((const Sequence< ::rtl::OUString>*)0))
                    {
                        Sequence< ::rtl::OUString> aStringSeq;
                        rValue >>= aStringSeq;

                        String aRet;

                        // loop through the elements and concatenate the elements (separated by a line break)
                        const ::rtl::OUString* pStringArray = aStringSeq.getConstArray();
                        sal_uInt32 nCount = aStringSeq.getLength();
                        for (sal_uInt32 i=0; i<nCount; ++i, ++pStringArray )
                        {
                            aRet += pStringArray->getStr();
                            if (i!=(nCount-1))
                                aRet += '\n';
                        }
                        sReturn = aRet;
                    }
                    // uInt16 sequences
                    else if (rValue.getValueType() == ::getCppuType((Sequence<sal_uInt16>*)0))
                    {
                        String aRet;
                        Sequence<sal_uInt16> aValues;
                        rValue >>= aValues;

                        // loop through the elements and concatenate the string representations of the integers
                        // (separated by a line break)
                        const sal_uInt16* pArray = aValues.getConstArray();
                        sal_uInt32 nCount = aValues.getLength();
                        for (sal_uInt32 i=0; i<nCount; ++i, ++pArray)
                        {
                            aRet += String::CreateFromInt32(*pArray);
                            if (i!=(nCount-1) )
                                aRet += '\n';
                        }
                        sReturn = aRet;
                    }
                    // Int16 sequences
                    else if (rValue.getValueType() == ::getCppuType((const Sequence<sal_Int16>*)0))
                    {
                        String aRet;
                        Sequence<sal_Int16> aValues;
                        rValue >>= aValues;

                        // loop through the elements and concatenate the string representations of the integers
                        // (separated by a line break)
                        const sal_Int16* pArray = aValues.getConstArray();
                        sal_uInt32 nCount = aValues.getLength();
                        for (sal_uInt32 i=0; i<nCount; ++i, ++pArray)
                        {
                            aRet += String::CreateFromInt32(*pArray);
                            if (i!=(nCount-1) )
                                aRet += '\n';
                        }
                        sReturn = aRet;
                    }
                    // uInt32 sequences
                    else if (rValue.getValueType() == ::getCppuType((const Sequence<sal_uInt32>*)0))
                    {
                        String aRet;
                        Sequence<sal_uInt32> aValues;
                        rValue >>= aValues;

                        // loop through the elements and concatenate the string representations of the integers
                        // (separated by a line break)
                        const sal_uInt32* pArray = aValues.getConstArray();
                        sal_uInt32 nCount = aValues.getLength();
                        for (sal_uInt32 i=0; i<nCount; ++i, ++pArray )
                        {
                            aRet += String::CreateFromInt32(*pArray);
                            if (i!=(nCount-1) )
                                aRet += '\n';
                        }
                        sReturn = aRet;
                    }
                    // Int32 sequences
                    else if (rValue.getValueType() == ::getCppuType((const Sequence<sal_Int16>*)0))
                    {
                        String aRet;
                        Sequence<sal_Int32> aValues;
                        rValue >>= aValues;

                        // loop through the elements and concatenate the string representations of the integers
                        // (separated by a line break)
                        const sal_Int32* pArray = aValues.getConstArray();
                        sal_uInt32 nCount = aValues.getLength();
                        for (sal_uInt32 i=0; i<nCount; ++i, ++pArray )
                        {
                            aRet += String::CreateFromInt32(*pArray);
                            if (i!=(nCount-1) )
                                aRet += '\n';
                        }
                        sReturn = aRet;
                    }


                }
                break;

            }

    // TODO TODO TODO
    // this is surely heavyly formdependent. Need another mechanism for converting Any->Display-String
            switch (_nPropId)
            {
                // ListTypen
                case PROPERTY_ID_ALIGN:
                case PROPERTY_ID_DATEFORMAT:
                case PROPERTY_ID_TIMEFORMAT:
                case PROPERTY_ID_BORDER:
                case PROPERTY_ID_DEFAULT_CHECKED:
                case PROPERTY_ID_STATE:
                case PROPERTY_ID_COMMANDTYPE:
                case PROPERTY_ID_CYCLE:
                case PROPERTY_ID_LISTSOURCETYPE:
                case PROPERTY_ID_NAVIGATION:
                case PROPERTY_ID_BUTTONTYPE:
                case PROPERTY_ID_PUSHBUTTONTYPE:
                case PROPERTY_ID_SUBMIT_METHOD:
                case PROPERTY_ID_SUBMIT_ENCODING:
                case PROPERTY_ID_ORIENTATION:
                case PROPERTY_ID_IMAGEALIGN:
                {
                    if (m_pPropertyInfo)
                    {
                        sal_Int32 nIntValue = -1;
                        if (::cppu::enum2int(nIntValue, rValue) && m_pPropertyInfo)
                        {
                            Sequence< ::rtl::OUString > aEnumStrings = m_pPropertyInfo->getPropertyEnumRepresentations(_nPropId);
                            if ((nIntValue >= 0) && (nIntValue < aEnumStrings.getLength()))
                            {
                                sReturn = aEnumStrings[nIntValue];
                            }
                            else
                                DBG_ERROR("OPropertyBrowserController::AnyToString: could not translate an enum value");
                        }
                    }
                }
                break;

                case PROPERTY_ID_CONTROLLABEL:
                {
                    String aReturn;
                    Reference< XPropertySet >  xSet;
                    rValue >>= xSet;
                    if (xSet.is() && ::comphelper::hasProperty(PROPERTY_LABEL, xSet))
                    {
                        aReturn = '<';
                        aReturn += ::comphelper::getString(xSet->getPropertyValue(PROPERTY_LABEL)).getStr();
                        aReturn += '>';
                    }
                    sReturn = aReturn;
                }
                break;
            }
        }
        catch (Exception&)
        {
            DBG_ERROR("OPropertyBrowserController::AnyToString: caught an exception!")
        }

        return sReturn;
    }

    //------------------------------------------------------------------------
    Any OPropertyBrowserController::StringToAny( const ::rtl::OUString& _rString, const Property& _rProp, sal_Int32 _nPropId)
    {
        Any aReturn;
        try
        {
            // void values
            if ((_rProp.Attributes & PropertyAttribute::MAYBEVOID) && !_rString.getLength() )
                return aReturn;

            //////////////////////////////////////////////////////////////////////
            // TypeClass
            Type  aPropertyType = _rProp.Type;
            TypeClass ePropertyType = aPropertyType.getTypeClass();

            // (one more) special handling : we have a prop which has a TypeClass "ANY" and needs a double
            // (originally it needed a double _or_ a string, but our UI only supports a double for it)
            if ((TypeClass_ANY == ePropertyType) && ((PROPERTY_ID_EFFECTIVE_DEFAULT == _nPropId) || (PROPERTY_ID_EFFECTIVE_VALUE == _nPropId)))
                ePropertyType = TypeClass_DOUBLE;

            switch (ePropertyType)
            {
                case TypeClass_STRING:
                case TypeClass_FLOAT:
                case TypeClass_DOUBLE:
                case TypeClass_BYTE:
                case TypeClass_SHORT:
                case TypeClass_LONG:
                case TypeClass_HYPER:
                case TypeClass_UNSIGNED_SHORT:
                case TypeClass_UNSIGNED_LONG:
                case TypeClass_UNSIGNED_HYPER:
                    // TODO: same as above ... the type converter is expensive
                    try
                    {
                        aReturn = m_xTypeConverter->convertToSimpleType(makeAny(_rString), ePropertyType);
                    }
                    catch(CannotConvertException&) { }
                    catch(IllegalArgumentException&) { }
                    break;
            }

            switch( ePropertyType )
            {

                case TypeClass_BOOLEAN:
                {
                    String sBooleanValues(ModuleRes(RID_STR_BOOL));
                    if (sBooleanValues.GetToken(0) == String(_rString))
                        aReturn <<= (sal_Bool)sal_False;
                    else
                        aReturn <<= (sal_Bool)sal_True;
                }
                break;

                case TypeClass_SEQUENCE:
                {
                    Type aElementType = ::comphelper::getSequenceElementType(aPropertyType);

                    String aStr(_rString);
                    switch (aElementType.getTypeClass())
                    {
                        case TypeClass_STRING:
                        {
                            sal_uInt32 nEntryCount = aStr.GetTokenCount('\n');
                            Sequence< ::rtl::OUString> aStringSeq( nEntryCount );
                            ::rtl::OUString* pStringArray = aStringSeq.getArray();

                            for (sal_Int32 i=0; i<aStringSeq.getLength(); ++i, ++pStringArray)
                                *pStringArray = aStr.GetToken((sal_uInt16)i, '\n');
                            aReturn <<= aStringSeq;
                        }
                        break;
                        case TypeClass_UNSIGNED_SHORT:
                        {
                            sal_uInt32 nEntryCount = aStr.GetTokenCount('\n');
                            Sequence<sal_uInt16> aSeq( nEntryCount );

                            sal_uInt16* pArray = aSeq.getArray();

                            for (sal_Int32 i=0; i<aSeq.getLength(); ++i, ++pArray)
                                *pArray = (sal_uInt16)aStr.GetToken((sal_uInt16)i, '\n').ToInt32();

                            aReturn <<= aSeq;

                        }
                        break;
                        case TypeClass_SHORT:
                        {
                            sal_uInt32 nEntryCount = aStr.GetTokenCount('\n');
                            Sequence<sal_Int16> aSeq( nEntryCount );

                            sal_Int16* pArray = aSeq.getArray();

                            for (sal_Int32 i=0; i<aSeq.getLength(); ++i, ++pArray)
                                *pArray = (sal_Int16)aStr.GetToken((sal_uInt16)i, '\n').ToInt32();

                            aReturn <<= aSeq;

                        }
                        break;
                        case TypeClass_LONG:
                        {
                            sal_uInt32 nEntryCount = aStr.GetTokenCount('\n');
                            Sequence<sal_Int32> aSeq( nEntryCount );

                            sal_Int32* pArray = aSeq.getArray();

                            for (sal_Int32 i=0; i<aSeq.getLength(); ++i, ++pArray)
                                *pArray = aStr.GetToken((sal_uInt16)i, '\n').ToInt32();

                            aReturn <<= aSeq;

                        }
                        break;
                        case TypeClass_UNSIGNED_LONG:
                        {
                            sal_uInt32 nEntryCount = aStr.GetTokenCount('\n');
                            Sequence<sal_uInt32> aSeq( nEntryCount );

                            sal_uInt32* pArray = aSeq.getArray();

                            for (sal_Int32 i=0; i<aSeq.getLength(); ++i, ++pArray)
                                *pArray = aStr.GetToken((sal_uInt16)i, '\n').ToInt32();

                            aReturn <<= aSeq;

                        }
                    }
                }
                break;
            }

            switch( _nPropId )
            {
                case PROPERTY_ID_ALIGN:
                case PROPERTY_ID_DATEFORMAT:
                case PROPERTY_ID_TIMEFORMAT:
                case PROPERTY_ID_BORDER:
                case PROPERTY_ID_DEFAULT_CHECKED:
                case PROPERTY_ID_STATE:
                case PROPERTY_ID_COMMANDTYPE:
                case PROPERTY_ID_CYCLE:
                case PROPERTY_ID_LISTSOURCETYPE:
                case PROPERTY_ID_NAVIGATION:
                case PROPERTY_ID_BUTTONTYPE:
                case PROPERTY_ID_PUSHBUTTONTYPE:
                case PROPERTY_ID_SUBMIT_METHOD:
                case PROPERTY_ID_SUBMIT_ENCODING:
                case PROPERTY_ID_ORIENTATION:
                case PROPERTY_ID_IMAGEALIGN:
                    if (m_pPropertyInfo)
                    {
                        Sequence< ::rtl::OUString > aEnumStrings = m_pPropertyInfo->getPropertyEnumRepresentations(_nPropId);
                        sal_Int32 nPos = GetStringPos(_rString, aEnumStrings);
                        if (-1 != nPos)
                        {
                            switch (aPropertyType.getTypeClass())
                            {
                                case TypeClass_ENUM:
                                    aReturn = ::cppu::int2enum(nPos, aPropertyType);
                                    break;
                                case TypeClass_SHORT:
                                    aReturn <<= (sal_Int16)nPos;
                                    break;
                                case TypeClass_UNSIGNED_SHORT:
                                    aReturn <<= (sal_uInt16)nPos;
                                    break;
                                case TypeClass_UNSIGNED_LONG:
                                    aReturn <<= (sal_uInt32)nPos;
                                    break;
                                default:
                                    aReturn <<= (sal_Int32)nPos;
                                    break;
                            }
                        }
                        else
                            DBG_ERROR("OPropertyBrowserController::StringToAny: could not translate the enum string!");
                    }
                break;
            }
        }
        catch(Exception&)
        {
            DBG_ERROR("OPropertyBrowserController::StringToAny: caught an exception !")
        }

        return aReturn;
    }

    //------------------------------------------------------------------------
    void OPropertyBrowserController::ChangeFormatProperty(const ::rtl::OUString& _rName, const ::rtl::OUString& _rCurVal)
    {
        // create the itemset for the dialog
        SfxItemSet aCoreSet(SFX_APP()->GetPool(),
            SID_ATTR_NUMBERFORMAT_VALUE, SID_ATTR_NUMBERFORMAT_VALUE,
            SID_ATTR_NUMBERFORMAT_INFO, SID_ATTR_NUMBERFORMAT_INFO,
            0);     // ripped this somewhere ... don't understand it :(

        // get the number formats supplier
        Reference< XNumberFormatsSupplier >  xSupplier;
        m_xPropValueAccess->getPropertyValue(PROPERTY_FORMATSSUPPLIER) >>= xSupplier;

        DBG_ASSERT(xSupplier.is(), "OPropertyBrowserController::ChangeFormatProperty : invalid call !");
        Reference< XUnoTunnel > xTunnel(xSupplier,UNO_QUERY);
        DBG_ASSERT(xTunnel.is(), "OPropertyBrowserController::ChangeFormatProperty : xTunnel is invalid!");
        SvNumberFormatsSupplierObj* pSupplier = (SvNumberFormatsSupplierObj*)xTunnel->getSomething(SvNumberFormatsSupplierObj::getUnoTunnelId());
        //  SvNumberFormatsSupplierObj* pSupplier = (SvNumberFormatsSupplierObj*)xSupplier->getImplementation(::getCppuType((const SvNumberFormatsSupplierObj*)0));

        DBG_ASSERT(pSupplier != NULL, "OPropertyBrowserController::ChangeFormatProperty : invalid call !");

        sal_Int32 nFormatKey = String(_rCurVal.getStr()).ToInt32();
        aCoreSet.Put(SfxUInt32Item(SID_ATTR_NUMBERFORMAT_VALUE, nFormatKey));

        SvNumberFormatter* pFormatter = pSupplier->GetNumberFormatter();
        double dPreviewVal = 1234.56789;
        SvxNumberInfoItem aFormatter(pFormatter, dPreviewVal, SID_ATTR_NUMBERFORMAT_INFO);
        aCoreSet.Put(aFormatter);

        // a tab dialog with a single page
        SfxSingleTabDialog* pDlg = new SfxSingleTabDialog(GetpApp()->GetAppWindow(), aCoreSet, 0);
        SvxNumberFormatTabPage* pPage = (SvxNumberFormatTabPage*) SvxNumberFormatTabPage::Create(pDlg, aCoreSet);
        const SfxPoolItem& rInfoItem = pPage->GetItemSet().Get(SID_ATTR_NUMBERFORMAT_INFO);
        pDlg->SetTabPage(pPage);

        if (RET_OK == pDlg->Execute())
        {
            const SfxItemSet* pResult = pDlg->GetOutputItemSet();

            const SfxPoolItem* pItem = pResult->GetItem( SID_ATTR_NUMBERFORMAT_INFO );
            const SvxNumberInfoItem* pInfoItem = static_cast<const SvxNumberInfoItem*>(pItem);
            if (pInfoItem && pInfoItem->GetDelCount())
            {
                const sal_uInt32* pDeletedKeys = pInfoItem->GetDelArray();

                for (sal_uInt16 i=0; i< pInfoItem->GetDelCount(); ++i, ++pDeletedKeys)
                    pFormatter->DeleteEntry(*pDeletedKeys);
            }

            pItem = NULL;
            if (SFX_ITEM_SET == pResult->GetItemState(SID_ATTR_NUMBERFORMAT_VALUE, sal_False, &pItem))
                Commit(_rName, ::rtl::OUString::valueOf((sal_Int32)((SfxUInt32Item*)pItem)->GetValue()), pSupplier);
        }
        delete pDlg;
    }

    //------------------------------------------------------------------------
    void OPropertyBrowserController::SetFields( OLineDescriptor& rProperty )
    {
        try
        {
            WaitObject aWaitCursor(m_pView);

            rProperty.eControlType = BCT_COMBOBOX;
            Reference< XPreparedStatement >  xStatement;

            // get the form of the control we're inspecting
            Reference< XChild > xChild(m_xPropValueAccess, UNO_QUERY);
            Reference< XPropertySet > xFormSet;
            if (xChild.is())
                xFormSet = Reference< XPropertySet >(xChild->getParent(), UNO_QUERY);

            if (Reference< XGridColumnFactory >(xFormSet, UNO_QUERY).is())
            {   // we're inspecting a grid column -> the form is one step above
                xChild = Reference< XChild >(xFormSet, UNO_QUERY);
                if (xChild.is())
                    xFormSet = Reference< XPropertySet >(xChild->getParent(), UNO_QUERY);
                else
                    xFormSet.clear();
            }
            if (!xFormSet.is())
                return;

            ::rtl::OUString aObjectName = ::comphelper::getString(xFormSet->getPropertyValue(PROPERTY_COMMAND));
            // when there is no command we don't need to ask for columns
            if (aObjectName.getLength())
            {
                ::rtl::OUString aDatabaseName = ::comphelper::getString(xFormSet->getPropertyValue(PROPERTY_DATASOURCE));
                sal_Int32 nObjectType = ::comphelper::getINT32(xFormSet->getPropertyValue(PROPERTY_COMMANDTYPE));

                // Festellen des Feldes
                Reference< XNameAccess >  xFields;
                Reference< XPropertySet >  xField;
                try
                {
                    Reference< XConnection > xConnection = ensureRowsetConnection();
                    if (!xConnection.is())
                        return;

                    switch (nObjectType)
                    {
                        case 0:
                        {
                            Reference< XTablesSupplier >  xSupplyTables(xConnection, UNO_QUERY);
                            Reference< XColumnsSupplier >  xSupplyColumns;
                            xSupplyTables->getTables()->getByName(aObjectName) >>= xSupplyColumns;
                            xFields = xSupplyColumns->getColumns();
                        }
                        break;
                        case 1:
                        {
                            Reference< XQueriesSupplier >  xSupplyQueries(xConnection, UNO_QUERY);
                            Reference< XColumnsSupplier >  xSupplyColumns;
                            xSupplyQueries->getQueries()->getByName(aObjectName) >>= xSupplyColumns;
                            xFields = xSupplyColumns->getColumns();
                        }
                        break;
                        default:
                        {
                            ::rtl::OUString sStatementToExecute( aObjectName );

                            // try to let a query composer analyze the statement
                            try
                            {
                                Reference< XSQLQueryComposerFactory > xComposerFac( xConnection, UNO_QUERY );
                                Reference< XSQLQueryComposer > xComposer;
                                if ( xComposerFac.is() )
                                    xComposer = xComposerFac->createQueryComposer( );
                                if ( xComposer.is() )
                                {
                                    xComposer->setQuery( sStatementToExecute );

                                    // Now set the filter to a dummy restriction which will result in an empty
                                    // result set.

                                    // Unfortunately, if the statement already has a non-empty filter it is not
                                    // removed when setting a new one. Instead, everything set with "setQuery",
                                    // counts as base, everything added later (setQuery/setOrder and such) is
                                    // _added_. So we need to strip the original WHERE clause (if there is one)
                                    // manually
                                    {
                                        ::rtl::OUString sComplete = xComposer->getComposedQuery( );
                                            // this way we norm it: now there's really a "WHERE", not only a "where" or such ...
                                        sal_Int32 nWherePos = sComplete.lastIndexOf( ::rtl::OUString::createFromAscii( "WHERE" ) );
                                        if ( -1 < nWherePos )
                                        {
                                            sComplete = sComplete.copy( 0, nWherePos );
                                                // this is not correct. The "WHERE" may have been a part of e.g. a filter itself
                                                // (something like "WHERE <field> = 'WHERE'"), but without an API
                                                // for _analyzing_ (and not only _composing_) queries, we don't have
                                                // much of a chance ...
                                            try
                                            {
                                                xComposer->setQuery( sComplete );
                                            }
                                            catch( const Exception& )
                                            {
                                                // just in case we found the wrong WHERE substring ....
                                            }
                                        }
                                    }

                                    xComposer->setFilter( ::rtl::OUString::createFromAscii( "0=1" ) );
                                    sStatementToExecute = xComposer->getComposedQuery( );
                                    // We're interested in columns only. And this "WHERE 0=1" restriction we applied
                                    // on the statement allows the driver to calc the columns only, without
                                    // retrieving any data (which would be expensive)
                                }
                            }
                            catch( const Exception& )
                            {
                                // silent this error, this was just a try
                            }

                            xStatement = xConnection->prepareStatement( sStatementToExecute );
                            // not interested in any results
                            Reference< XPropertySet > (xStatement,UNO_QUERY)->setPropertyValue( ::rtl::OUString::createFromAscii("MaxRows"),makeAny(sal_Int32(0)));
                            Reference< XColumnsSupplier >  xSupplyCols(xStatement->executeQuery(), UNO_QUERY);
                            if (xSupplyCols.is())
                                xFields = xSupplyCols->getColumns();
                        }
                    }
                }
                catch (Exception&)
                {
                    DBG_ERROR("OPropertyBrowserController::SetFields: Exception occured!");
                }


                if (!xFields.is())
                    return;

                Sequence< ::rtl::OUString> aFields(xFields->getElementNames());
                const ::rtl::OUString* pFields = aFields.getConstArray();
                for (sal_Int32 i=0; i<aFields.getLength(); i++,++pFields )
                    rProperty.aListValues.push_back(*pFields);
            }
        }
        catch (Exception&)
        {
            DBG_ERROR("OPropertyBrowserController::SetFields : caught an exception !")
        }
    }

    //------------------------------------------------------------------------
    void OPropertyBrowserController::SetTables( OLineDescriptor& rProperty )
    {
        try
        {
            WaitObject aWaitCursor(m_pView);

            rProperty.eControlType = BCT_COMBOBOX;

            Reference< XTablesSupplier >  xTables;
            try
            {
                xTables = Reference< XTablesSupplier >( ensureRowsetConnection( ), UNO_QUERY );
            }
            catch (Exception&)
            {
                return;
            }

            Reference< XNameAccess >  xAccess;
            if (xTables.is())
                xAccess = xTables->getTables();
            if (!xAccess.is())
                return;

            Sequence< ::rtl::OUString> aTableNameSeq = xAccess->getElementNames();
            sal_uInt32 nCount = aTableNameSeq.getLength();
            const ::rtl::OUString* pTableNames = aTableNameSeq.getConstArray();

            for (sal_uInt32 i=0; i<nCount; ++i ,++pTableNames)
                rProperty.aListValues.push_back( *pTableNames);
        }

        catch (Exception&)
        {
            DBG_ERROR("OPropertyBrowserController::SetTables : caught an exception !")
        }
    }

    //------------------------------------------------------------------------
    void OPropertyBrowserController::SetQueries( OLineDescriptor& rProperty )
    {
        try
        {
            WaitObject aWaitCursor(m_pView);

            rProperty.eControlType = BCT_COMBOBOX;

            Reference< XQueriesSupplier >  xSupplyQueries;
            try
            {
                xSupplyQueries = Reference< XQueriesSupplier >( ensureRowsetConnection(), UNO_QUERY );
            }
            catch (Exception&)
            {
                return;
            }

            Reference< XNameAccess >  xAccess;
            if (xSupplyQueries.is())
                xAccess = xSupplyQueries->getQueries();


            if (!xAccess.is())
                return;

            Sequence< ::rtl::OUString> aQueryNameSeq = xAccess->getElementNames();
            sal_uInt32 nCount = aQueryNameSeq.getLength();
            const ::rtl::OUString* pQueryNames = aQueryNameSeq.getConstArray();
            for (sal_uInt32 i=0; i<nCount; i++,++pQueryNames )
                rProperty.aListValues.push_back( *pQueryNames );
        }
        catch (Exception&)
        {
            DBG_ERROR("OPropertyBrowserController::SetQueries : caught an exception !")
        }
    }

    //------------------------------------------------------------------------
    void OPropertyBrowserController::cleanupRowsetConnection()
    {
        Reference< XComponent > xConnComp( m_xRowsetConnection, UNO_QUERY );
        if ( xConnComp.is() )
            xConnComp->dispose();
        m_xRowsetConnection.clear();
    }

    //------------------------------------------------------------------------
    Reference< XConnection > OPropertyBrowserController::ensureRowsetConnection()
    {
        Reference< XConnection > xReturn;

        // get the row set we're working for
        Reference< XPropertySet > xProps( getRowSet( ), UNO_QUERY );
        if ( xProps.is() )
        {
            // get it's current active connection
            xProps->getPropertyValue( PROPERTY_ACTIVE_CONNECTION ) >>= xReturn;
            // do we need to connect?
            if ( !xReturn.is() )
            {
                connectRowset( );
                // get the property again
                xProps->getPropertyValue( PROPERTY_ACTIVE_CONNECTION ) >>= xReturn;
            }
        }

        // outta here
        return xReturn;
    }

    //------------------------------------------------------------------------
    Reference< XRowSet > OPropertyBrowserController::getRowSet( ) const
    {
        Reference< XRowSet > xRowSet(m_xPropValueAccess, UNO_QUERY);
        if (!xRowSet.is())
        {
            // are we inspecting a control?
            if ( 0 != m_nClassId )
            {
                xRowSet = Reference< XRowSet >(m_xObjectParent, UNO_QUERY);
                if (!xRowSet.is())
                {
                    // are we inspecting a grid column?
                    if (Reference< XGridColumnFactory >(m_xObjectParent, UNO_QUERY).is())
                    {   // we're inspecting a grid column
                        Reference< XChild > xParentAsChild(m_xObjectParent, UNO_QUERY);
                        if (xParentAsChild.is())
                            xRowSet = Reference< XRowSet >(xParentAsChild->getParent(), UNO_QUERY);
                    }
                }
            }

        }
        DBG_ASSERT( xRowSet.is(), "OPropertyBrowserController::SetQueries: could not obtain the rowset for the introspectee!" );
        return xRowSet;
    }

    //------------------------------------------------------------------------
    void OPropertyBrowserController::connectRowset()
    {
        // if we have a previous connection, dispose it
        if ( haveRowsetConnection() )
            cleanupRowsetConnection();

        SQLExceptionInfo aErrorInfo;
        try
        {
            // the rowset
            Reference< XRowSet > xRowSet( getRowSet() );
            Reference< XPropertySet > xRowSetProps( xRowSet, UNO_QUERY );
            if (xRowSetProps.is())
            {
                // does the rowset already have a connection?
                Reference< XConnection > xConnection;
                xRowSetProps->getPropertyValue( PROPERTY_ACTIVE_CONNECTION ) >>= xConnection;

                if ( !xConnection.is() )
                {   // no -> calculate one
                    if (m_pView)
                    {
                        WaitObject aWaitCursor(m_pView);
                        xConnection = ::dbtools::connectRowset( xRowSet, m_xORB, sal_False );
                    }
                    else
                    {
                        xConnection = ::dbtools::connectRowset( xRowSet, m_xORB, sal_False );
                    }

                    // set on the row set
                    xRowSetProps->setPropertyValue( PROPERTY_ACTIVE_CONNECTION, makeAny( xConnection ) );

                    // remember for later disposal
                    // (we opened the connection, thus we own it)
                    m_xRowsetConnection = xConnection;
                }
            }
        }
        catch (SQLContext& e) { aErrorInfo = e; }
        catch (SQLWarning& e) { aErrorInfo = e; }
        catch (SQLException& e) { aErrorInfo = e; }
        catch (Exception&) { }

        if (aErrorInfo.isValid() && haveView())
        {
            ::rtl::OUString sDataSourceName;
            try
            {
                Reference< XPropertySet > xRSP( getRowSet(), UNO_QUERY );
                if ( xRSP.is() )
                    xRSP->getPropertyValue( PROPERTY_DATASOURCE ) >>= sDataSourceName;
            }
            catch( const Exception& )
            {
                DBG_ERROR( "OPropertyBrowserController::connectRowset: caught an exception during error handling!" );
            }
            // additional info about what happended
            String sInfo( ModuleRes( RID_STR_UNABLETOCONNECT ) );
            sInfo.SearchAndReplaceAllAscii( "$name$", sDataSourceName );

            SQLContext aContext;
            aContext.Message = sInfo;
            aContext.NextException = aErrorInfo.get();
            showError( aContext, VCLUnoHelper::GetInterface( m_pView ), m_xORB);
        }
    }

    //------------------------------------------------------------------------
    void OPropertyBrowserController::SetCursorSource(sal_Bool bInit)
    {
        try
        {
            if (!m_bHasCursorSource)
                return;

            WaitObject aWaitCursor(m_pView);

            // force the data page to be shown
            if (getPropertyBox()->GetCurPage() != m_nDataPageId)
                getPropertyBox()->SetPage(m_nDataPageId);

            ////////////////////////////////////////////////////////////
            // Auslesen des CursorSourceTypes
            String sCommandType = GetPropertyValue(PROPERTY_COMMANDTYPE);
            String sCommand = GetPropertyValue(PROPERTY_COMMAND);

            ////////////////////////////////////////////////////////////
            // Setzen der UI-Daten
            OLineDescriptor aProperty;
            aProperty.eControlType = BCT_COMBOBOX;

            aProperty.sName = (const ::rtl::OUString&)PROPERTY_COMMAND;
            aProperty.sTitle = m_pPropertyInfo->getPropertyTranslation(PROPERTY_ID_COMMAND);
            aProperty.pControl = NULL;
            aProperty.bHasBrowseButton = sal_False;
            aProperty.bIsHyperlink = sal_False;
            aProperty.bIsLocked = sal_False;

            aProperty.nHelpId = m_pPropertyInfo->getPropertyHelpId(PROPERTY_ID_COMMAND);
            if (bInit)
                aProperty.sValue = sCommand;
            else
                aProperty.sValue = String();

            if ( bInit )
                connectRowset();

            ////////////////////////////////////////////////////////////
            // Enums setzen

            sal_Bool bFailedToConnect = bInit && !haveRowsetConnection();
            if ( !bFailedToConnect )
            {
                Sequence< ::rtl::OUString > aCommandTypes = m_pPropertyInfo->getPropertyEnumRepresentations(PROPERTY_ID_COMMANDTYPE);
                sal_Int32 nPos = GetStringPos(sCommandType, aCommandTypes);
                if (0 == nPos)
                    SetTables(aProperty);
                else if (1 == nPos)
                    SetQueries(aProperty);
            }

            getPropertyBox()->ChangeEntry(aProperty, getPropertyBox()->GetPropertyPos(aProperty.sName));
            Commit(aProperty.sName, aProperty.sValue, NULL);
        }
        catch (Exception&)
        {
            DBG_ERROR("OPropertyBrowserController::SetCursorSource : caught an exception !")
        }
    }

    //------------------------------------------------------------------------
    void OPropertyBrowserController::SetListSource(sal_Bool bInit)
    {
        try
        {
            if (!m_bHasListSource)
                return;

            WaitObject aWaitCursor(m_pView);

            // force the data page to be shown
            if (getPropertyBox()->GetCurPage() != m_nDataPageId)
                getPropertyBox()->SetPage(m_nDataPageId);

            ////////////////////////////////////////////////////////////
            // Auslesen des ListSourceTypes
            Any aListSourceTypeAny;

            ::rtl::OUString aStrVal;
            if (m_xPropStateAccess.is())
                aListSourceTypeAny = m_xPropValueAccess->getPropertyValue(PROPERTY_LISTSOURCETYPE );

            sal_Int32 nListSourceType;
            ::cppu::enum2int(nListSourceType,aListSourceTypeAny);

            ::rtl::OUString aListSource = GetPropertyValue( PROPERTY_LISTSOURCE );

            ////////////////////////////////////////////////////////////
            // Setzen der UI-Daten
            OLineDescriptor aProperty;
            aProperty.eControlType = BCT_MEDIT;
            aProperty.sName = (const ::rtl::OUString&)PROPERTY_LISTSOURCE;
            aProperty.sTitle = m_pPropertyInfo->getPropertyTranslation(PROPERTY_ID_LISTSOURCE);
            aProperty.pControl = NULL;
            aProperty.bHasBrowseButton = sal_False;
            aProperty.bIsHyperlink = sal_False;
            aProperty.bIsLocked = sal_False;
            aProperty.nHelpId=m_pPropertyInfo->getPropertyHelpId(PROPERTY_ID_LISTSOURCE);



            if (bInit)
                aProperty.sValue = aListSource;
            else
                aProperty.sValue = String();

            ////////////////////////////////////////////////////////////
            // Enums setzen
            switch( nListSourceType )
            {
                case ListSourceType_VALUELIST:
                    aProperty.eControlType = BCT_LEDIT;
                    break;

                case ListSourceType_TABLEFIELDS:
                case ListSourceType_TABLE:
                    SetTables( aProperty );
                    break;
                case ListSourceType_QUERY:
                    SetQueries( aProperty );
                    break;
            }

            ////////////////////////////////////////////////////////////
            // Eintrag umsetzen
            sal_uInt16 nCurPage = getPropertyBox()->GetCurPage();
            getPropertyBox()->SetPage( m_nDataPageId );
            getPropertyBox()->ChangeEntry( aProperty, getPropertyBox()->GetPropertyPos(aProperty.sName) );
            Commit( aProperty.sName, aProperty.sValue, NULL );
            getPropertyBox()->SetPage( nCurPage );
        }
        catch (Exception&)
        {
            DBG_ERROR("OPropertyBrowserController::SetListSource : caught an exception !")
        }
    }

    //------------------------------------------------------------------------
    void OPropertyBrowserController::ChangeFontProperty( const ::rtl::OUString& rName )
    {
        // create an item set for use with the dialog
        SfxItemSet* pSet = NULL;
        SfxItemPool* pPool = NULL;
        SfxPoolItem** pDefaults = NULL;
        ControlCharacterDialog::createItemSet(pSet, pPool, pDefaults);
        ControlCharacterDialog::translatePropertiesToItems(m_xPropValueAccess, pSet);

        {   // do this in an own block. The dialog needs to be destroyed before we call
            // destroyItemSet
            ControlCharacterDialog aDlg(GetpApp()->GetAppWindow(), *pSet);
            if (RET_OK == aDlg.Execute())
            {
                const SfxItemSet* pOut = aDlg.GetOutputItemSet();
                String sNewFontName = ControlCharacterDialog::translatePropertiesToItems(pOut, m_xPropValueAccess);
                if (0 != sNewFontName.Len())
                    getPropertyBox()->SetPropertyValue( String::CreateFromAscii("Font"), sNewFontName);
            }
        }

        ControlCharacterDialog::destroyItemSet(pSet, pPool, pDefaults);
    }

    //------------------------------------------------------------------------
    void OPropertyBrowserController::ChangeEventProperty( const ::rtl::OUString& _Name )
    {
        SfxMacroAssignDlg* pMacroDlg = NULL;
        String rName(_Name.getStr());

        if (rName.GetTokenCount()==0)
            return;

        ::rtl::OUString sListenerClassName = rName.GetToken( 0);
        ::rtl::OUString sMethodName = rName.GetToken(1);

        ::std::vector< ::rtl::OUString> aNameArray;

        try
        {

            Reference< XIndexAccess >  xIndexAcc(m_xObjectParent, UNO_QUERY);

            sal_Int32 nObjIdx=-1;
            // calc the index of the object with it's parent
            if (xIndexAcc.is())
            {
                sal_Int32 nCount = xIndexAcc->getCount();

                Reference< XPropertySet >  xTestSet;
                for (sal_Int32 i=0;i<nCount; ++i)
                {
                    ::cppu::extractInterface(xTestSet, xIndexAcc->getByIndex(i));
                    if (xTestSet.get() == m_xPropValueAccess.get())
                    {
                        nObjIdx=i;
                        break;
                    }
                }
            }

            // the the script events for this index
            sal_uInt32 nScrEvts=0;

            // For dialog editor mode, no EventManager but xEventsSupplier
            Reference< XScriptEventsSupplier > xEventsSupplier;

            Sequence< ScriptEventDescriptor > aSeqScrEvts;
            if (nObjIdx>=0 && m_xEventManager.is())
            {
                 aSeqScrEvts = m_xEventManager->getScriptEvents(nObjIdx);
            }
            else
            {
                // Dialog editor mode, no EventManager
                ::cppu::extractInterface( xEventsSupplier, m_aIntrospectee );
                if( xEventsSupplier.is() )
                {
                    Reference< XNameContainer > xEventCont = xEventsSupplier->getEvents();
                    Sequence< ::rtl::OUString > aNames = xEventCont->getElementNames();
                    sal_Int32 nLen = aNames.getLength();

                    const ::rtl::OUString* pNames = aNames.getConstArray();
                    aSeqScrEvts.realloc( nLen );
                    ScriptEventDescriptor* pDescs = aSeqScrEvts.getArray();

                    for( sal_Int32 i = 0 ; i < nLen ; i++ )
                    {
                        Any aElem = xEventCont->getByName( pNames[i] );
                        aElem >>= pDescs[i];
                    }
                }
            }
            nScrEvts = aSeqScrEvts.getLength();


            sal_uInt32 nLength = m_aObjectListenerTypes.getLength();
            const Type * pListeners = m_aObjectListenerTypes.getConstArray();
            const ScriptEventDescriptor* pEvDes = aSeqScrEvts.getConstArray();

            SvxMacroTableDtor aTable;

            sal_uInt16 nIndex=0;
            sal_uInt32 i;

            String aListener;
            ::rtl::OUString aOUListener;
            ::rtl::OUString aListenerClassName;
            Sequence< ::rtl::OUString> aMethSeq;

            for (i = 0 ; i < nLength ; i++ ,++pListeners)
            {
                // Namen besorgen
                aOUListener = pListeners->getTypeName();
                aListener = aOUListener;
                sal_Int32 nTokenCount = aListener.GetTokenCount('.');

                if (nTokenCount>0)
                    aListenerClassName= aListener.GetToken(nTokenCount-1, '.' );
                else
                    aListenerClassName= aListener;

                if (aListenerClassName.getLength()>0)
                {
                    // Methoden der Listener ausgeben
                    aMethSeq = getEventMethods( *pListeners );
                    const ::rtl::OUString * pMethods = aMethSeq.getConstArray();
                    sal_uInt32 nMethCount = aMethSeq.getLength();

                    for (sal_uInt32 j = 0 ; j < nMethCount ; ++j,++pMethods )
                    {

                        EventDisplayDescription* pEventDisplayDescription = GetEvtTranslation(*pMethods);

                        // be sure that the event method isn't mentioned twice
                        if (pEventDisplayDescription != NULL)
                        {
                            if (sListenerClassName == aListenerClassName && sMethodName == (*pMethods))
                            {
                                nIndex=aNameArray.size();
                            }


                            const ScriptEventDescriptor* pEvent = pEvDes;
                            for ( sal_uInt32 nI=0; nI<nScrEvts; ++nI, ++pEvent)
                            {
                                if  (   (   ( pEvent->ListenerType == aListenerClassName )
                                        ||  ( pEvent->ListenerType == aOUListener )
                                        )
                                    &&  ( pEvent->EventMethod == (*pMethods) )
                                    )
                                {
                                    SvxMacro* pMacro = NULL;

                                    if  (   (pEvent->ScriptCode.getLength() > 0)
                                        &&  (pEvent->ScriptType.getLength() > 0)
                                        )
                                    {
                                        ::rtl::OUString sScriptType = pEvent->ScriptType;
                                        ::rtl::OUString sScriptCode = pEvent->ScriptCode;
                                        ::rtl::OUString sLibName;

                                        if ( 0 == sScriptType.compareToAscii( "StarBasic" ) )
                                        {   // it's a StarBasic macro
                                            // strip the prefix from the macro name (if any)

                                            sal_Int32 nPrefixLen = sScriptCode.indexOf( ':' );
                                            if ( nPrefixLen >= 0 )
                                            {   // it contains a prefix
                                                ::rtl::OUString sPrefix = sScriptCode.copy( 0, nPrefixLen );
                                                sScriptCode = sScriptCode.copy( nPrefixLen + 1 );
                                                if ( 0 == sPrefix.compareToAscii( "application" ) )
                                                {
                                                    sLibName = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "StarOffice" ) );
                                                }
                                                else if ( 0 == sPrefix.compareToAscii( "document" ) )
                                                {
                                                    // ??? document name is unknown here!
                                                }
                                                else
                                                    DBG_ERROR( "OPropertyBrowserController::ChangeEventProperty: invalid (unknown) prefix" );
                                            }
                                        }

                                        SvxMacro aTypeTranslator( sScriptCode, sScriptType );
                                        pMacro = new SvxMacro( sScriptCode, sLibName, aTypeTranslator.GetScriptType() );
                                    }

                                    aTable.Insert(aNameArray.size(), pMacro);
                                }
                            }

                            aNameArray.push_back(pEventDisplayDescription->sDisplayName);
                        }
                    }
                }
            }

            SvxMacroItem aMacroItem;

            aMacroItem.SetMacroTable(aTable);

            SfxItemSet aSet( SFX_APP()->GetPool(), SID_ATTR_MACROITEM, SID_ATTR_MACROITEM );
            aSet.Put(aMacroItem, SID_ATTR_MACROITEM);
            pMacroDlg = new SfxMacroAssignDlg(
                GetpApp()->GetAppWindow(), aSet );
            SfxMacroTabPage* pMacroTabPage = (SfxMacroTabPage*)pMacroDlg->GetTabPage();

            for (sal_uInt32 j = 0 ; j < aNameArray.size(); j++ )
                pMacroTabPage->AddEvent( aNameArray[j], (sal_uInt16)j);

            if (nIndex<aNameArray.size())
                pMacroTabPage->SelectEvent( aNameArray[nIndex], nIndex);

            if ( pMacroDlg->Execute() == RET_OK )
            {
                // OJ: #96105#
                {
                    Reference<XChild> xChild;
                    m_aIntrospectee >>= xChild;
                    Reference<XModifiable> xModifiable(xChild,UNO_QUERY);
                    while( !xModifiable.is() && xChild.is() )
                    {
                        Reference<XInterface> xParent = xChild->getParent();
                        xModifiable = Reference<XModifiable>(xParent,UNO_QUERY);
                        xChild = Reference<XChild>(xParent,UNO_QUERY);
                    }

                    if ( xModifiable.is() )
                        xModifiable->setModified(sal_True);
                }

                const SvxMacroTableDtor& aTab = pMacroTabPage->GetMacroTbl();

                if ( nObjIdx>=0 && m_xEventManager.is() )
                    m_xEventManager->revokeScriptEvents( nObjIdx );


                sal_uInt16 nEventCount = (sal_uInt16)aTab.Count();
                sal_uInt16 nEventIndex = 0;

                Sequence< ScriptEventDescriptor > aSeqScriptEvts(nEventCount);

                ScriptEventDescriptor* pWriteScriptEvents = aSeqScriptEvts.getArray();
                nIndex=0;

                String aListenerClassName,aName,aListener;

                pListeners = m_aObjectListenerTypes.getConstArray();

                ::rtl::OUString sScriptCode;
                for (i = 0 ; i < nLength ; ++i, ++pListeners )
                {
                    // Methode ansprechen

                    // Namen besorgen
                    aListener = pListeners->getTypeName();
                    sal_Int32 nTokenCount=aListener.GetTokenCount('.');

                    if (nTokenCount>0)
                        aListenerClassName = aListener.GetToken(nTokenCount-1, '.' );
                    else
                        aListenerClassName = aListener;

                    if (aListenerClassName.Len() != 0)
                    {
                        // Methoden der Listener ausgeben
                        aMethSeq = getEventMethods( *pListeners );

                        const ::rtl::OUString* pMethods     =               +   aMethSeq.getConstArray();
                        const ::rtl::OUString* pMethodsEnd  =   pMethods    +   aMethSeq.getLength();
                        for ( ; pMethods != pMethodsEnd; ++pMethods )
                        {
                            EventDisplayDescription* pEventDisplayDescription = GetEvtTranslation( *pMethods );

                            if ( pEventDisplayDescription )
                            {
                                SvxMacro* pMacro = aTab.Get( nIndex++ );
                                if ( pMacro )
                                {
                                    sScriptCode = pMacro->GetMacName();
                                    if ( nEventIndex < nEventCount )
                                    {
                                        if ( m_xEventManager.is() )
                                        {
                                            pWriteScriptEvents->ListenerType = aListenerClassName;
                                        }
                                        else
                                        {   // Dialog editor mode
                                            pWriteScriptEvents->ListenerType = aListener;
                                        }

                                        sal_Bool bApplicationMacro = pMacro->GetLibName().EqualsAscii("StarOffice");

                                        sScriptCode = ::rtl::OUString::createFromAscii( bApplicationMacro ? "application:" : "document:" );
                                        sScriptCode += pMacro->GetMacName();

                                        pWriteScriptEvents->ScriptCode = sScriptCode;
                                        pWriteScriptEvents->EventMethod = *pMethods;
                                        pWriteScriptEvents->ScriptType = pMacro->GetLanguage();

                                        ++nEventIndex;
                                        ++pWriteScriptEvents;
                                    }
                                }
                                else
                                    sScriptCode = ::rtl::OUString();

                                // set the new "property value"
                                aName = aListenerClassName;
                                aName += ';';
                                aName += pMethods->getStr();
                                getPropertyBox()->SetPropertyValue( aName, sScriptCode);
                            }
                        }
                    }
                }

                if (nObjIdx>=0 && m_xEventManager.is())
                {
                    m_xEventManager->registerScriptEvents(nObjIdx,aSeqScriptEvts);
                }
                else if( xEventsSupplier.is() )
                {
                    Reference< XNameContainer > xEventCont = xEventsSupplier->getEvents();

                    // Make it simple: Revove all old events...
                    Sequence< ::rtl::OUString > aNames = xEventCont->getElementNames();
                    sal_Int32 nLen = aNames.getLength();
                    const ::rtl::OUString* pNames = aNames.getConstArray();
                    for( sal_Int32 i = nLen - 1; i >= 0 ; i-- )
                        xEventCont->removeByName( pNames[i] );

                    // ... and insert the new ones
                    const ScriptEventDescriptor* pDescs = aSeqScriptEvts.getConstArray();
                    sal_Int32 nNewCount = aSeqScriptEvts.getLength();
                    for( i = 0 ; i < nNewCount ; i++ )
                    {
                        const ScriptEventDescriptor& rDesc = pDescs[ i ];
                        ::rtl::OUString aName = rDesc.ListenerType;
                        aName += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "::" ) );
                        aName += rDesc.EventMethod;

                        Any aEventAny;
                        aEventAny <<= rDesc;
                        xEventCont->insertByName( aName, aEventAny );
                    }
                }
            }
        }
        catch (Exception&)
        {
            DBG_ERROR("OPropertyBrowserController::ChangeEventProperty : caught an exception !")
        }

        delete pMacroDlg;
    }

    //------------------------------------------------------------------------
    void OPropertyBrowserController::InsertEvents()
    {
        //////////////////////////////////////////////////////////////////////
        // Seite fuer Events
        m_nEventPageId = getPropertyBox()->AppendPage(String(ModuleRes(RID_STR_EVENTS)), HID_FM_PROPDLG_TAB_EVT);

        sal_Bool  bRemoveFlag = sal_True;

        try
        {
            Reference< XIndexAccess >  xIndexAcc(m_xObjectParent, UNO_QUERY);
            sal_Int32 nObjIdx=-1;

            // get the index of the inspected object within it's parent container
            if (xIndexAcc.is() && m_xPropValueAccess.is())
            {
                sal_Int32 nCount = xIndexAcc->getCount();
                Reference< XPropertySet >  xTestSet;
                for (sal_Int32 i=0; i<nCount; ++i)
                {
                    ::cppu::extractInterface(xTestSet, xIndexAcc->getByIndex(i));
                    if (xTestSet.get() == m_xPropValueAccess.get())
                    {
                        nObjIdx=i;
                        break;
                    }
                }
            }

            // get the current script events for this index
            sal_uInt32 nScrEvts=0;
            sal_Bool bShowEventPage = sal_False;
            Sequence< ScriptEventDescriptor > aSeqScrEvts;
            if (nObjIdx>=0 && m_xEventManager.is())
            {
                aSeqScrEvts = m_xEventManager->getScriptEvents(nObjIdx);
                bShowEventPage = sal_True;
            }
            else
            {
                // Dialog editor mode, no EventManager
                Reference< XScriptEventsSupplier > xEventsSupplier;
                ::cppu::extractInterface( xEventsSupplier, m_aIntrospectee );
                if( xEventsSupplier.is() )
                {
                    Reference< XNameContainer > xEventCont = xEventsSupplier->getEvents();
                    Sequence< ::rtl::OUString > aNames = xEventCont->getElementNames();
                    sal_Int32 nLen = aNames.getLength();

                    const ::rtl::OUString* pNames = aNames.getConstArray();
                    aSeqScrEvts.realloc( nLen );
                    ScriptEventDescriptor* pDescs = aSeqScrEvts.getArray();

                    for( sal_Int32 i = 0 ; i < nLen ; i++ )
                    {
                        Any aElem = xEventCont->getByName( pNames[i] );
                        aElem >>= pDescs[i];
                    }
                    bShowEventPage = sal_True;
                }
            }
            nScrEvts = aSeqScrEvts.getLength();

            if( !bShowEventPage )
            {   // could not obtain the position in the event attacher manager
                // (or don't have this manager)
                // -> no event page
                if (m_nEventPageId)
                    getPropertyBox()->RemovePage(m_nEventPageId);
                m_nEventPageId=0;
                return;
            }

            sal_uInt32 nLength = m_aObjectListenerTypes.getLength();
            const Type * pListeners = m_aObjectListenerTypes.getConstArray();

            OLineDescriptor aProperty;
            aProperty.pDataPtr = LINETYPE_EVENT;
            aProperty.bIsLocked = sal_True;

            DECLARE_STL_SET( OLineDescriptor, OLineDescriptorLess, LineDescriptorSet );
            LineDescriptorSet aEventLines;

            const ScriptEventDescriptor* pEvDes = aSeqScrEvts.getConstArray();
            String aListener;
            String aListenerClassName;
            String aMethName;
            for (sal_uInt32 i = 0 ; i < nLength ; ++i, ++pListeners )
            {
                // Methode ansprechen
                //  const Reference< XIdlClass > & rxClass = pListeners[i];

                // Namen besorgen
                aListener = pListeners->getTypeName();
                sal_uInt32 nTokenCount = aListener.GetTokenCount('.');


                if (nTokenCount>0)
                    aListenerClassName= aListener.GetToken((sal_uInt16)nTokenCount-1, '.');
                else
                    aListenerClassName= aListener;

                if (aListenerClassName.Len() != 0)
                {
                    // Methoden der Listener ausgeben
                    Sequence< ::rtl::OUString > aMethSeq(getEventMethods( *pListeners ));
                    const ::rtl::OUString * pMethods = aMethSeq.getConstArray();
                    sal_uInt32 nMethCount = aMethSeq.getLength();

                    for (sal_uInt32 j = 0 ; j < nMethCount ; j++,++pMethods )
                    {
                        //  Reference< XIdlMethod >  xMethod = pMethods[ j ];

                        //  aMethName=xMethod->getName();
                        aProperty.eControlType = BCT_EDIT;
                        aProperty.sName = aListenerClassName;
                        aProperty.sName += String(';');
                        aProperty.sName += (const sal_Unicode*)*pMethods;
                        aProperty.sTitle = *pMethods;
                        aProperty.nHelpId=0;
                        aProperty.sValue = String();
                        aProperty.bHasBrowseButton = sal_True;

                        for (sal_uInt32 nI=0; nI<nScrEvts;nI++)
                        {
                            const ScriptEventDescriptor& rEvDe = pEvDes[nI];
                            if ( (aListenerClassName.Equals((const sal_Unicode*)rEvDe.ListenerType)
                                 || aListener.Equals((const sal_Unicode*)rEvDe.ListenerType) )
                                && pMethods->equals(rEvDe.EventMethod))
                                aProperty.sValue = rEvDe.ScriptCode;
                        }

                        EventDisplayDescription* pEventDescription = GetEvtTranslation(*pMethods);
                        if (pEventDescription)
                        {
                            aProperty.sTitle = pEventDescription->sDisplayName;
                            aProperty.nHelpId = pEventDescription->nHelpId;
                            aProperty.nUniqueButtonId = pEventDescription->nIndex;
                            aEventLines.insert(aProperty);
                        }
                    }
                }
            }

            for (   ConstLineDescriptorSetIterator iter = aEventLines.begin();
                    iter != aEventLines.end();
                    ++iter
                )
            {
                // Now set the right id
                OLineDescriptor aData(*iter);
                aData.nUniqueButtonId = UID_EVT_MACRODLG;
                getPropertyBox()->InsertEntry( aData );
            }

            bRemoveFlag = aEventLines.empty();
        }
        catch (Exception&)
        {
            DBG_ERROR("OPropertyBrowserController::InsertEvents : caught an exception !")
            bRemoveFlag=sal_True;
        }

        if (bRemoveFlag)
        {
            getPropertyBox()->RemovePage(m_nEventPageId);
            m_nEventPageId=0;
        }
    }

    //------------------------------------------------------------------------
    void OPropertyBrowserController::UpdateUI()
    {
        // Introspection auswerten
        try
        {
            getPropertyBox()->DisableUpdate();

            sal_Bool bHaveFocus = getPropertyBox()->HasChildPathFocus();

            InsertEvents();
            sal_uInt32 nPropCount = m_aObjectProperties.getLength();
            const Property* pProps = m_aObjectProperties.getConstArray();
            OLineDescriptor* pProperty = NULL;
            sal_Bool bRemoveDatPage=sal_True;

            TypeClass eType;
            Any aVal,aSupplier,aKey,aDigits,aSeparator,aDefault;
            ::rtl::OUString aStrVal;
            PropertyState eState;

            // get control type
            sal_Int16 nControlType = getControlType();

            for (sal_uInt32 i=0; i<nPropCount; ++i, ++pProps)
            {
                sal_Int32 nPropId = m_pPropertyInfo->getPropertyId(pProps->Name);
                String sDisplayName = m_pPropertyInfo->getPropertyTranslation(nPropId);
                if (!sDisplayName.Len())
                    continue;

                pProperty = new OLineDescriptor();


                //////////////////////////////////////////////////////////////////////
                // TypeClass des Property ermitteln
                eType = pProps->Type.getTypeClass();

                //////////////////////////////////////////////////////////////////////
                // Wert holen und in ::rtl::OUString wandeln
                eState=PropertyState_DIRECT_VALUE;
                if (m_xPropStateAccess.is())
                    eState=m_xPropStateAccess->getPropertyState(pProps->Name);

                aVal = m_xPropValueAccess->getPropertyValue( pProps->Name );
                aStrVal = AnyToString(aVal, *pProps, nPropId);

                //////////////////////////////////////////////////////////////////////
                // Default Properties
                pProperty->eControlType = BCT_EDIT;
                pProperty->sName = pProps->Name;
                pProperty->sTitle = pProps->Name;
                pProperty->sValue = aStrVal;
                pProperty->pControl = NULL;
                pProperty->bIsLocked = sal_False;
                pProperty->bHasBrowseButton = sal_False;
                pProperty->bIsHyperlink = sal_False;

                if ((pProps->Attributes & PropertyAttribute::MAYBEVOID) && nPropId != PROPERTY_ID_BORDER) //&& eState!=DIRECT_VALUE
                {
                    pProperty->bHasDefaultValue = sal_True;
                    if (!aVal.hasValue())
                        pProperty->sValue = m_sStandard;
                }
                else
                    pProperty->bHasDefaultValue =sal_False;

                //////////////////////////////////////////////////////////////////////
                // Font
                sal_Bool bFilter = sal_True;
                if (nPropId == PROPERTY_ID_FONT_NAME)
                {
                    bFilter = sal_False;

                    pProperty->sName = String::CreateFromAscii("Font");
                    pProperty->sTitle = pProperty->sName;
                    pProperty->bIsLocked = sal_True;
                    pProperty->bHasBrowseButton = sal_True;
                    pProperty->nUniqueButtonId = UID_PROP_DLG_FONT_TYPE;
                    ::rtl::OUString sValue;
                    aVal >>= sValue;
                    pProperty->sValue = sValue;
                }
                else if (nPropId == PROPERTY_ID_TARGET_URL)
                {
                    pProperty->bHasBrowseButton = sal_True;
                    pProperty->nUniqueButtonId = UID_PROP_DLG_ATTR_TARGET_URL;
                }
                else if (nPropId == PROPERTY_ID_IMAGE_URL)
                {
                    pProperty->bHasBrowseButton = sal_True;
                    pProperty->nUniqueButtonId = UID_PROP_DLG_IMAGE_URL;
                }

                else if (nPropId== PROPERTY_ID_ECHO_CHAR)
                {
                    pProperty->eControlType = BCT_CHAREDIT;  //@ new CharEdit
                }
                //////////////////////////////////////////////////////////////////////
                // Color
                else if (nPropId== PROPERTY_ID_BACKGROUNDCOLOR )
                {
                    bFilter = sal_False;
                    pProperty->eControlType = BCT_COLORBOX;  //@ new ColorListbox
                    pProperty->bIsLocked = sal_True;
                    pProperty->bHasBrowseButton = sal_True;
                    pProperty->nUniqueButtonId = UID_PROP_DLG_BACKGROUNDCOLOR;
                }
                else if (nPropId== PROPERTY_ID_FILLCOLOR )
                {
                    bFilter = sal_False;
                    pProperty->eControlType = BCT_COLORBOX;  //@ new ColorListbox
                    pProperty->bIsLocked = sal_True;
                    pProperty->bHasBrowseButton = sal_True;
                    pProperty->nUniqueButtonId = UID_PROP_DLG_FILLCOLOR;
                }
                else if (nPropId == PROPERTY_ID_LABEL)
                {
                    pProperty->eControlType = BCT_MEDIT;
                }
                else if (nPropId == PROPERTY_ID_DEFAULT_TEXT)
                {
                    if (FormComponentType::FILECONTROL == m_nClassId)
                        pProperty->eControlType = BCT_EDIT;
                    else
                        pProperty->eControlType = BCT_MEDIT;
                }
                else if (nPropId == PROPERTY_ID_TEXT)
                {
                    if ( m_xIntrospecteeAsProperty.is() )
                    {
                        Reference< XServiceInfo > xInfo(m_xIntrospecteeAsProperty, UNO_QUERY);
                        if ( xInfo.is() )
                        {
                            if ( xInfo->supportsService( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.UnoControlFormattedFieldModel" ) ) ) )
                            {
                                delete pProperty;
                                continue;
                            }
                        }

                        Reference< XPropertySetInfo > xPropInfo = m_xIntrospecteeAsProperty->getPropertySetInfo();
                        if ( xPropInfo.is() )
                        {
                            if ( xPropInfo->hasPropertyByName( PROPERTY_MULTILINE ) )
                                pProperty->eControlType = BCT_MEDIT;
                        }
                    }
                }
                else if (PROPERTY_ID_CONTROLLABEL == nPropId)
                {
                    bFilter = sal_False;
                    pProperty->bHasBrowseButton = sal_True;
                    pProperty->bIsLocked = sal_True;
                    pProperty->sValue = AnyToString(aVal, *pProps, PROPERTY_ID_CONTROLLABEL);
                    pProperty->nUniqueButtonId = UID_PROP_DLG_CONTROLLABEL;
                }
                else if ((PROPERTY_ID_FORMATKEY == nPropId) || (PROPERTY_ID_EFFECTIVE_MIN == nPropId)
                    || (PROPERTY_ID_EFFECTIVE_MAX == nPropId) || (PROPERTY_ID_EFFECTIVE_DEFAULT == nPropId)
                    || (PROPERTY_ID_EFFECTIVE_VALUE == nPropId))
                {
                    // only if the set has a formatssupplier, too
                    if  (   !::comphelper::hasProperty(PROPERTY_FORMATSSUPPLIER, m_xPropValueAccess)
                        ||  (FormComponentType::DATEFIELD == m_nClassId)
                        ||  (FormComponentType::TIMEFIELD == m_nClassId)
                        )
                    {
                        delete pProperty;
                        continue;
                    }

                    // and the supplier is really available
                    Reference< XNumberFormatsSupplier >  xSupplier;
                    m_xPropValueAccess->getPropertyValue(PROPERTY_FORMATSSUPPLIER) >>= xSupplier;
                    if (xSupplier.is())
                    {
                        Reference< XUnoTunnel > xTunnel(xSupplier,UNO_QUERY);
                        DBG_ASSERT(xTunnel.is(), "OPropertyBrowserController::ChangeFormatProperty : xTunnel is invalid!");
                        SvNumberFormatsSupplierObj* pSupplier = (SvNumberFormatsSupplierObj*)xTunnel->getSomething(SvNumberFormatsSupplierObj::getUnoTunnelId());

                        if (pSupplier != NULL)
                        {
                            bFilter = sal_False;    // don't do further checks
                            sal_Bool bIsFormatKey = (PROPERTY_ID_FORMATKEY == nPropId);

                            pProperty->eControlType = BCT_USERDEFINED;

                            pProperty->bIsLocked = bIsFormatKey;
                            pProperty->bHasBrowseButton = bIsFormatKey;

                            if (bIsFormatKey)
                            {
                                pProperty->pControl = new OFormatDescriptionControl(getPropertyBox(), WB_READONLY | WB_TABSTOP | WB_BORDER);
                                    // HACK : the Control need's a non-null parent, but we don't have one ... so use the property box
                                ((OFormatDescriptionControl*)pProperty->pControl)->SetFormatSupplier(pSupplier);

                                pProperty->nUniqueButtonId = UID_PROP_DLG_NUMBER_FORMAT;
                            }
                            else
                            {
                                pProperty->pControl = new OFormattedNumericControl(getPropertyBox(), WB_TABSTOP | WB_BORDER);
                                    // HACK : same as above

                                FormatDescription aDesc;
                                aDesc.pSupplier = pSupplier;
                                aKey = m_xPropValueAccess->getPropertyValue(PROPERTY_FORMATKEY);
                                aDesc.nKey = aKey.hasValue() ? ::comphelper::getINT32(aKey) : 0;
                                ((OFormattedNumericControl*)pProperty->pControl)->SetFormatDescription(aDesc);
                            }

                            // the initial value
                            if (aVal.hasValue())
                            {
                                if (bIsFormatKey)
                                {
                                    pProperty->sValue = String::CreateFromInt32(::comphelper::getINT32(aVal));
                                }
                                else
                                {
                                    if (aVal.getValueTypeClass() == TypeClass_DOUBLE)
                                        pProperty->sValue = convertSimpleToString(aVal);
                                    else
                                        DBG_WARNING("OPropertyBrowserController::UpdateUI : non-double values not supported for Effective*-properties !");
                                        // our UI supports only setting double values for the min/max/default, but by definition
                                        // the default may be a string if the field is not in numeric mode ....
                                }
                            }
                        }
                    }
                }
                //////////////////////////////////////////////////////////////////////
                // ::rtl::OUString Sequence
                else if (eType == TypeClass_SEQUENCE )
                {
                    pProperty->eControlType = BCT_LEDIT;
                    bFilter = sal_False;
                }

                else if (TypeClass_BYTE <=eType && eType<=TypeClass_DOUBLE)
                {
                    if (nPropId==PROPERTY_ID_DATEMIN || nPropId==PROPERTY_ID_DATEMAX || nPropId==PROPERTY_ID_DEFAULT_DATE || nPropId==PROPERTY_ID_DATE)
                        pProperty->eControlType = BCT_DATEFIELD;
                    else if (nPropId==PROPERTY_ID_TIMEMIN || nPropId==PROPERTY_ID_TIMEMAX || nPropId==PROPERTY_ID_DEFAULT_TIME || nPropId==PROPERTY_ID_TIME)
                        pProperty->eControlType = BCT_TIMEFIELD;
                    else
                    {
                        if (nPropId== PROPERTY_ID_VALUEMIN || nPropId== PROPERTY_ID_VALUEMAX || nPropId==PROPERTY_ID_DEFAULT_VALUE || nPropId==PROPERTY_ID_VALUE)
                        {
                            pProperty->eControlType = BCT_USERDEFINED;
                            pProperty->pControl = new OFormattedNumericControl(getPropertyBox(), WB_TABSTOP | WB_BORDER | WB_SPIN);
                                // HACK : same as above

                            // we don't set a formatter so the control uses a default (which uses the application
                            // language and a default numeric format)
                            // but we set the decimal digits
                            aDigits = m_xPropValueAccess->getPropertyValue(PROPERTY_DECIMAL_ACCURACY);
                            ((OFormattedNumericControl*)pProperty->pControl)->SetDecimalDigits(::comphelper::getINT16(aDigits));

                            // and the thousands separator
                            aSeparator = m_xPropValueAccess->getPropertyValue(PROPERTY_SHOWTHOUSANDSEP);
                            ((OFormattedNumericControl*)pProperty->pControl)->SetThousandsSep(::comphelper::getBOOL(aSeparator));

                            // and the default value for the property
                            try
                            {
                                if (m_xPropStateAccess.is() && ((PROPERTY_ID_VALUEMIN == nPropId) || (PROPERTY_ID_VALUEMAX == nPropId)))
                                {
                                    aDefault = m_xPropStateAccess->getPropertyDefault(pProps->Name);
                                    if (aDefault.getValueTypeClass() == TypeClass_DOUBLE)

                                        ((OFormattedNumericControl*)pProperty->pControl)->SetDefaultValue(::comphelper::getDouble(aDefault));
                                }
                            }
                            catch (Exception&)
                            {
                                // just ignore it
                            }

                            // and allow empty values only for the default value and the value
                            static_cast< OFormattedNumericControl* >( pProperty->pControl )
                                ->EnableEmptyField( ( PROPERTY_ID_DEFAULT_VALUE == nPropId )
                                                ||  ( PROPERTY_ID_VALUE == nPropId ) );
}
                        else
                        {
                            if ( (nPropId== PROPERTY_ID_HEIGHT || nPropId== PROPERTY_ID_WIDTH || nPropId== PROPERTY_ID_ROWHEIGHT)
                                && nControlType == CONTROL_TYPE_FORM )
                                pProperty->nDigits=1;

                            pProperty->eControlType = BCT_NUMFIELD;
                        }
                    }
                }

                // don't filter dialog controls
                if ( nControlType == CONTROL_TYPE_DIALOG )
                    bFilter = sal_False;

                //////////////////////////////////////////////////////////////////////
                // Filter
                if (bFilter)
                {
                    switch( eType )     // TypeClass Inspection
                    {
                    case TypeClass_INTERFACE:
                    case TypeClass_ARRAY:
                        delete pProperty->pControl;
                        delete pProperty;
                        continue;
                    }

                    switch( aVal.getValueTypeClass() )      // TypeClass Any

                    {
                    case TypeClass_VOID:
                        if (pProps->Attributes & PropertyAttribute::MAYBEVOID)
                            break;

                    case TypeClass_INTERFACE:
                    case TypeClass_ARRAY:
                    case TypeClass_UNKNOWN:
                        delete pProperty->pControl;
                        delete pProperty;
                        continue;
                    }

                    if (pProps->Name.compareTo(::rtl::OUString::createFromAscii("type unknown")) == COMPARE_EQUAL )
                    {
                        delete pProperty->pControl;
                        delete pProperty;
                        continue;
                    }

                    if (pProps->Attributes & PropertyAttribute::TRANSIENT )
                    {
                        delete pProperty->pControl;
                        delete pProperty;
                        continue;
                    }

                    else if (pProps->Attributes & PropertyAttribute::READONLY )
                    {
                        delete pProperty->pControl;
                        delete pProperty;
                        continue;
                    }
                }

                //////////////////////////////////////////////////////////////////////
                // sal_Bool-Werte
                if (eType == TypeClass_BOOLEAN )
                {
                    String aEntries(ModuleRes(RID_STR_BOOL));
                    for ( xub_StrLen i=0; i<2; ++i )
                        pProperty->aListValues.push_back( aEntries.GetToken(i) );

                    pProperty->eControlType = BCT_LISTBOX;
                }

                //////////////////////////////////////////////////////////////////////
                // TYPECLASS_VOID
                else if (eType == TypeClass_VOID )
                    pProperty->sValue = String();

                //////////////////////////////////////////////////////////////////////
                // Listen mit ResStrings fuellen
                switch( nPropId )
                {
                    case PROPERTY_ID_COMMANDTYPE:
                    case PROPERTY_ID_ALIGN:
                    case PROPERTY_ID_BUTTONTYPE:
                    case PROPERTY_ID_PUSHBUTTONTYPE:
                    case PROPERTY_ID_SUBMIT_METHOD:
                    case PROPERTY_ID_SUBMIT_ENCODING:
                    case PROPERTY_ID_DATEFORMAT:
                    case PROPERTY_ID_TIMEFORMAT:
                    case PROPERTY_ID_BORDER:
                    case PROPERTY_ID_CYCLE:
                    case PROPERTY_ID_NAVIGATION:
                    case PROPERTY_ID_TARGET_FRAME:
                    case PROPERTY_ID_DEFAULT_CHECKED:
                    case PROPERTY_ID_STATE:
                    case PROPERTY_ID_LISTSOURCETYPE:
                    case PROPERTY_ID_ORIENTATION:
                    case PROPERTY_ID_IMAGEALIGN:
                    {
                        Sequence< ::rtl::OUString > aEnumValues = m_pPropertyInfo->getPropertyEnumRepresentations(nPropId);
                        const ::rtl::OUString* pStart = aEnumValues.getConstArray();
                        const ::rtl::OUString* pEnd = pStart + aEnumValues.getLength();

                        // for a checkbox: if "ambiguous" is not allowed, remove this from the sequence
                        if (PROPERTY_ID_DEFAULT_CHECKED == nPropId || PROPERTY_ID_STATE == nPropId)
                            if (::comphelper::hasProperty(PROPERTY_TRISTATE, m_xPropValueAccess))
                            {
                                if (!::comphelper::getBOOL(m_xPropValueAccess->getPropertyValue(PROPERTY_TRISTATE)))
                                {   // remove the last sequence element
                                    if (pEnd > pStart)
                                        --pEnd;
                                }
                            }
                            else
                                --pEnd;

                        if (PROPERTY_ID_LISTSOURCETYPE == nPropId)
                            if (FormComponentType::COMBOBOX == m_nClassId)
                                // remove the first sequence element
                                ++pStart;

                        // copy the sequence
                        for (const ::rtl::OUString* pLoop = pStart; pLoop != pEnd; ++pLoop)
                            pProperty->aListValues.push_back(*pLoop);

                        pProperty->eControlType =
                                PROPERTY_ID_TARGET_FRAME == nPropId
                            ?   BCT_COMBOBOX
                            :   BCT_LISTBOX;
                    }
                    break;

                    case PROPERTY_ID_MAXTEXTLEN:
                    case PROPERTY_ID_TABINDEX:
                    case PROPERTY_ID_BOUNDCOLUMN:
                        pProperty->nMaxValue = 0x7FFFFFFF;
                        pProperty->bHaveMinMax = sal_True;
                        switch (nPropId)
                        {
                            case PROPERTY_ID_MAXTEXTLEN:    pProperty->nMinValue = -1; break;
                            case PROPERTY_ID_TABINDEX:      pProperty->nMinValue = 0; break;
                            case PROPERTY_ID_BOUNDCOLUMN:   pProperty->nMinValue = 1; break;
                        }
                        break;

                    case PROPERTY_ID_DECIMAL_ACCURACY:
                        pProperty->nMaxValue = 20;
                        pProperty->nMinValue = 0;
                        pProperty->bHaveMinMax = sal_True;
                        break;
                }

                //////////////////////////////////////////////////////////////////////
                // DataSource
                if (nPropId == PROPERTY_ID_DATASOURCE )
                {
                    pProperty->nUniqueButtonId = UID_PROP_DLG_ATTR_DATASOURCE;
                    // if the form already belong to a Database, don't set this property
                    Reference< XInterface > xInter;
                    m_aIntrospectee >>= xInter;
                    pProperty->bHasBrowseButton = sal_False;
                    pProperty->eControlType = BCT_COMBOBOX;

                    Reference< XNameAccess > xDatabaseContext(m_xORB->createInstance(SERVICE_DATABASE_CONTEXT), UNO_QUERY);
                    if (xDatabaseContext.is())
                    {
                        Sequence< ::rtl::OUString > aDatasources = xDatabaseContext->getElementNames();
                        const ::rtl::OUString* pBegin = aDatasources.getConstArray();
                        const ::rtl::OUString* pEnd = pBegin + aDatasources.getLength();
                        for (; pBegin != pEnd;++pBegin)
                            pProperty->aListValues.push_back(*pBegin);
                    }
                }

                //////////////////////////////////////////////////////////////////////
                // ControlSource
                else if (nPropId == PROPERTY_ID_CONTROLSOURCE )
                    SetFields( *pProperty );

                //////////////////////////////////////////////////////////////////////
                // CursorSource
                else if (nPropId == PROPERTY_ID_COMMAND)
                    m_bHasCursorSource = sal_True;

                //////////////////////////////////////////////////////////////////////
                // ListSource
                else if (nPropId == PROPERTY_ID_LISTSOURCE )
                    m_bHasListSource = sal_True;

                //////////////////////////////////////////////////////////////////////
                // UI-Eintrag
                switch( nPropId )       // DataPage
                {
                    case PROPERTY_ID_COMMAND:
                    case PROPERTY_ID_CONTROLSOURCE:
                    case PROPERTY_ID_LISTSOURCE:
                    case PROPERTY_ID_LISTSOURCETYPE:
                    case PROPERTY_ID_BOUNDCOLUMN:
                    case PROPERTY_ID_MASTERFIELDS:
                    case PROPERTY_ID_DETAILFIELDS:
                    case PROPERTY_ID_DATASOURCE:
                    case PROPERTY_ID_COMMANDTYPE:
                    case PROPERTY_ID_INSERTONLY:
                    case PROPERTY_ID_NAVIGATION:
                    case PROPERTY_ID_CYCLE:
                    case PROPERTY_ID_ALLOWADDITIONS:
                    case PROPERTY_ID_ALLOWEDITS:
                    case PROPERTY_ID_ALLOWDELETIONS:
                    case PROPERTY_ID_ESCAPE_PROCESSING:
                    case PROPERTY_ID_FILTER_CRITERIA:
                    case PROPERTY_ID_SORT:
                    case PROPERTY_ID_EMPTY_IS_NULL:
                    case PROPERTY_ID_FILTERPROPOSAL:
                        bRemoveDatPage =sal_False;
                        getPropertyBox()->SetPage( m_nDataPageId );
                        break;
                    default:
                        getPropertyBox()->SetPage( m_nGenericPageId );
                }

                pProperty->nHelpId = m_pPropertyInfo->getPropertyHelpId(nPropId);
                pProperty->sTitle = sDisplayName;

                if (PropertyState_AMBIGUOUS_VALUE == eState)
                {
                    pProperty->bUnknownValue = sal_True;
                    pProperty->sValue = String();
                }

                sal_uInt32 nPropertyUIFlags = m_pPropertyInfo->getPropertyUIFlags( nPropId );
                if ( ( nControlType == CONTROL_TYPE_FORM   && ((nPropertyUIFlags & PROP_FORM_VISIBLE) == PROP_FORM_VISIBLE) ) ||
                     ( nControlType == CONTROL_TYPE_DIALOG && ((nPropertyUIFlags & PROP_DIALOG_VISIBLE) == PROP_DIALOG_VISIBLE) ) )
                {
                    getPropertyBox()->InsertEntry(*pProperty);
                }
                else
                    delete pProperty->pControl;

                delete pProperty;
            }

            SetCursorSource(sal_True);
            SetListSource(sal_True);

            if (bRemoveDatPage && !m_bHasCursorSource && !m_bHasListSource)
            {
                getPropertyBox()->RemovePage(m_nDataPageId);
                m_nDataPageId=0;
            }

            getPropertyBox()->SetPage( m_nDataPageId );

            getPropertyBox()->EnableUpdate();

            if ( bHaveFocus )
                getPropertyBox()->GrabFocus();
        }
        catch (Exception&)
        {
            DBG_ERROR("OPropertyBrowserController::UpdateUI : caught an exception !")
        }
    }

    //------------------------------------------------------------------------
    void OPropertyBrowserController::Modified( const String& aName, const String& aVal, void* pData )
    {
        try
        {
            sal_Int32 nPropId = m_pPropertyInfo->getPropertyId( aName );

            // Wenn CursorSourceType veraendert wurde, CursorSource anpassen
            if (PROPERTY_ID_COMMANDTYPE == nPropId)
            {
                Commit( aName, aVal, pData );
                SetCursorSource();
            }

            //////////////////////////////////////////////////////////////////////
            // Wenn ListSourceType veraendert wurde, ListSource anpassen
            if (PROPERTY_ID_LISTSOURCETYPE == nPropId)
            {
                Commit( aName, aVal, pData );
                SetListSource();
            }
        }
        catch (Exception&)
        {
            DBG_ERROR("OPropertyBrowserController::Modified : caught an exception !")
        }
    }

    //------------------------------------------------------------------------
    void OPropertyBrowserController::OnImageURLClicked( const String& _rName, const String& _rVal, void* _pData )
    {
            ::rtl::OUString aStrTrans = m_pPropertyInfo->getPropertyTranslation( PROPERTY_ID_IMAGE_URL );

            ::sfx2::FileDialogHelper aFileDlg(SFXWB_GRAPHIC);

            aFileDlg.SetTitle(aStrTrans);

            Reference< XFilePickerControlAccess > xController(aFileDlg.GetFilePicker(), UNO_QUERY);
            DBG_ASSERT(xController.is(), "OPropertyBrowserController::Clicked: missing the controller interface on the file picker!");
            if (xController.is())
            {
                // do a preview by default
                xController->setValue(ExtendedFilePickerElementIds::CHECKBOX_PREVIEW, 0, ::cppu::bool2any(sal_True));

                // "as link" is checked, but disabled
                xController->setValue(ExtendedFilePickerElementIds::CHECKBOX_LINK, 0, ::cppu::bool2any(sal_True));
                xController->enableControl(ExtendedFilePickerElementIds::CHECKBOX_LINK, sal_False);
            }

            if (_rVal.Len() != 0)
            {
                aFileDlg.SetDisplayDirectory(_rVal);
                // TODO: need to set the display directory _and_ the default name
            }

            if (!aFileDlg.Execute())
                Commit( _rName, aFileDlg.GetPath(), _pData );
    }

    //------------------------------------------------------------------------
    void OPropertyBrowserController::Clicked( const String& aName, const String& aVal, void* pData )
    {
        try
        {
            sal_Int32 nPropId = m_pPropertyInfo->getPropertyId(aName);

            //////////////////////////////////////////////////////////////////////
            // DataSource & ImageURL
            if (PROPERTY_ID_TARGET_URL == nPropId)
            {
                ::sfx2::FileDialogHelper aFileDlg(WB_3DLOOK);

                INetURLObject aParser( aVal );
                if ( INET_PROT_FILE == aParser.GetProtocol() )
                    // set the initial directory only for file-URLs. Everything else
                    // is considered to be potentially expensive
                    // 106126 - 2002/12/10 - fs@openoffice.org
                    aFileDlg.SetDisplayDirectory( aVal );

                if (0 == aFileDlg.Execute())
                {
                    String aDataSource = aFileDlg.GetPath();
                    Commit( aName, aDataSource, pData );
                }
            }


            //////////////////////////////////////////////////////////////////////
            // Bei Datenquelle auch Cursor-/ListSource fuellen
            else if (PROPERTY_ID_DATASOURCE == nPropId)
            {
                String aUserVal=aVal;

                Reference< XNamingService >  xDatabaseAccesses(m_xORB->createInstance(SERVICE_DATABASE_CONTEXT), UNO_QUERY);
                if (xDatabaseAccesses.is())
                {
                    Reference< XDataSource >  xDataSource;
                    try
                    {
                        xDataSource = Reference< XDataSource >(xDatabaseAccesses->getRegisteredObject(aVal), UNO_QUERY);
                    }
                    catch(NoSuchElementException&)
                    {
                        DBG_ERROR("Use of unknown datasource name");
                    }
                }
            }

            //////////////////////////////////////////////////////////////////////
            // URL
            else if (nPropId == PROPERTY_ID_IMAGE_URL)
            {
                OnImageURLClicked(aName, aVal, pData);
            }


            //////////////////////////////////////////////////////////////////////
            // Color
            else if (nPropId == PROPERTY_ID_BACKGROUNDCOLOR || nPropId == PROPERTY_ID_FILLCOLOR )
            {
                sal_uInt32 nColor = aVal.ToInt32();
                Color aColor( nColor );
                SvColorDialog aColorDlg( GetpApp()->GetAppWindow() );
                aColorDlg.SetColor( aColor );

                if (aColorDlg.Execute() )
                {
                    aColor = aColorDlg.GetColor();
                    nColor = aColor.GetColor();

                    String aColorString = String::CreateFromInt32( (sal_Int32)nColor );
                    Commit( aName, aColorString, pData );
                }
            }

            else if (PROPERTY_ID_FORMATKEY == nPropId)
            {
                ChangeFormatProperty(aName, aVal);
            }

            else if (PROPERTY_ID_CONTROLLABEL == nPropId)
            {
                OSelectLabelDialog dlgSelectLabel(GetpApp()->GetAppWindow(), m_xPropValueAccess);
                if (RET_OK == dlgSelectLabel.Execute())
                {
                    // if the properties transport would be via UsrAnys (instead of strings) we would have a chance
                    // to use the regular commit mechanism here ....
                    Reference< XPropertySet >  xSelected(dlgSelectLabel.GetSelected());
                    if (xSelected.is())
                        m_xPropValueAccess->setPropertyValue(PROPERTY_CONTROLLABEL, makeAny(xSelected));
                    else
                        m_xPropValueAccess->setPropertyValue(PROPERTY_CONTROLLABEL, Any());
                }
            }

            //////////////////////////////////////////////////////////////////////
            // Font
            else if (aName.EqualsAscii("Font"))
            {
                ChangeFontProperty(aName);
            }
            else if (pData == LINETYPE_EVENT)
            {
                ChangeEventProperty(aName);
            }
        }
        catch (Exception&)
        {
            DBG_ERROR("OPropertyBrowserController::Clicked : caught an exception !")
        }
    }

    //------------------------------------------------------------------------
    void OPropertyBrowserController::Commit( const String& rName, const String& aVal, void* pData )
    {
        if (m_pChangeMultiplexer)
            m_pChangeMultiplexer->lock();

        try
        {
            //////////////////////////////////////////////////////////////////////
            // Property-Info holen
            sal_Int32 nPropId = m_pPropertyInfo->getPropertyId( rName );

            Property aProp = getIntrospecteeProperty( rName );

            String aUserVal=aVal;

            //////////////////////////////////////////////////////////////////////
            // URL- Adresse koennte relativ sein
            if ((nPropId == PROPERTY_ID_TARGET_URL || nPropId == PROPERTY_ID_IMAGE_URL) && aVal.Len())
            {
                aUserVal = URIHelper::SmartRelToAbs(aVal);
            }

            Any aValue;
            if (!(m_sStandard.equals(aVal) &&(aProp.Attributes & PropertyAttribute::MAYBEVOID)))
            {
                aValue = StringToAny( aUserVal, aProp, nPropId);
            }

            if  (   (   (nPropId == PROPERTY_ID_DEFAULT_VALUE) || (nPropId == PROPERTY_ID_VALUE)
                    ||  (nPropId == PROPERTY_ID_DEFAULT_DATE)  || (nPropId == PROPERTY_ID_DATE)
                    ||  (nPropId == PROPERTY_ID_DEFAULT_TIME)  || (nPropId == PROPERTY_ID_TIME)
                    ||  (nPropId==PROPERTY_ID_BOUNDCOLUMN)
                    )
                &&  (0 == aVal.Len())
                )
            {
                aValue = Any();
            }

            //////////////////////////////////////////////////////////////////////
            // Wert setzen
            sal_Bool bDontForwardToPropSet = !(aProp.Attributes & PropertyAttribute::MAYBEVOID) &&
                        aValue.getValueType().equals( ::getVoidCppuType());


            if (PROPERTY_ID_CONTROLLABEL == nPropId)
            {
                bDontForwardToPropSet = sal_True;
                // the string fo the control label is not to be set as PropertyValue, it's only for displaying
            }

            if (!bDontForwardToPropSet)
                m_xPropValueAccess->setPropertyValue( rName, aValue );

            //////////////////////////////////////////////////////////////////////
            // Wert neu holen und ggf. neu setzen
            Any aNewValue = m_xPropValueAccess->getPropertyValue(rName);
            ::rtl::OUString aNewStrVal = AnyToString(aNewValue, aProp, nPropId);

            getPropertyBox()->SetPropertyValue( rName, aNewStrVal );

            if (nPropId==PROPERTY_ID_TRISTATE)
            {
                ::rtl::OUString aStateName;
                sal_Int32 nStateId;
                sal_Int16 nControlType = getControlType();

                if ( nControlType == CONTROL_TYPE_FORM )
                {
                    aStateName = PROPERTY_DEFAULTCHECKED;
                    nStateId = PROPERTY_ID_DEFAULT_CHECKED;
                }
                else if ( nControlType == CONTROL_TYPE_DIALOG )
                {
                    aStateName = PROPERTY_STATE;
                    nStateId = PROPERTY_ID_STATE;
                }

                OLineDescriptor aProperty;
                aProperty.sName             =   aStateName;
                aProperty.sTitle            =   m_pPropertyInfo->getPropertyTranslation(nStateId);
                aProperty.nHelpId           =   m_pPropertyInfo->getPropertyHelpId(nStateId);
                aProperty.eControlType      =   BCT_LISTBOX;
                aProperty.sValue            =   getPropertyBox()->GetPropertyValue(aStateName);
                sal_uInt16 nPos             =   getPropertyBox()->GetPropertyPos(aStateName);

                Sequence< ::rtl::OUString > aEntries =
                    m_pPropertyInfo->getPropertyEnumRepresentations(nStateId);
                sal_Int32 nEntryCount = aEntries.getLength();

                if (!::comphelper::getBOOL(aNewValue))
                    // tristate not allowed -> remove the "don't know" state
                    --nEntryCount;

                sal_Bool bValidDefaultCheckedValue = sal_False;

                const ::rtl::OUString* pStart = aEntries.getConstArray();
                const ::rtl::OUString* pEnd = pStart + nEntryCount;
                for (const ::rtl::OUString* pLoop = pStart; pLoop != pEnd; ++pLoop)
                {
                    aProperty.aListValues.push_back(*pLoop);
                    if (pLoop->equals(aProperty.sValue))
                        bValidDefaultCheckedValue = sal_True;
                }

                if (!bValidDefaultCheckedValue)
                    aProperty.sValue = *pStart;

                if (nPos != EDITOR_LIST_APPEND)
                    getPropertyBox()->ChangeEntry(aProperty,nPos);

                Commit(aProperty.sName, aProperty.sValue, NULL);
            }
            else if ((PROPERTY_ID_DECIMAL_ACCURACY == nPropId) || (PROPERTY_ID_SHOWTHOUSANDSEP == nPropId))
            {
                sal_Bool bAccuracy = (PROPERTY_ID_DECIMAL_ACCURACY == nPropId);
                sal_uInt16  nNewDigits = bAccuracy ? ::comphelper::getINT16(aNewValue) : 0;
                sal_Bool    bUseSep = bAccuracy ? sal_False : ::comphelper::getBOOL(aNewValue);

                getPropertyBox()->DisableUpdate();

                // propagate the changes to the min/max/default fields
                Any aCurrentProp;
                ::rtl::OUString aAffectedProps[] = { PROPERTY_DEFAULT_VALUE, PROPERTY_VALUEMIN, PROPERTY_VALUEMAX };
                for (sal_uInt16 i=0; i<sizeof(aAffectedProps)/sizeof(aAffectedProps[0]); ++i)
                {
                    OFormattedNumericControl* pField = (OFormattedNumericControl*)getPropertyBox()->GetPropertyControl(aAffectedProps[i]);
                    if (pField)
                        if (bAccuracy)
                            pField->SetDecimalDigits(nNewDigits);
                        else
                            pField->SetThousandsSep(bUseSep);
                }

                getPropertyBox()->EnableUpdate();
            }
            else if (PROPERTY_ID_FORMATKEY == nPropId)
            {
                FormatDescription aNewDesc;

                Any aSupplier = m_xPropValueAccess->getPropertyValue(PROPERTY_FORMATSSUPPLIER);
                DBG_ASSERT(aSupplier.getValueType().equals(::getCppuType(
                    (const Reference< XNumberFormatsSupplier>*)0)),

                    "OPropertyBrowserController::Commit : invalid property change !");
                    // we only allowed the FormatKey property to be displayed if the set had a valid FormatsSupplier
                Reference< XNumberFormatsSupplier >  xSupplier;
                aSupplier >>= xSupplier;
                DBG_ASSERT(xSupplier.is(), "OPropertyBrowserController::Commit : invalid property change !");
                    // same argument
                Reference< XUnoTunnel > xTunnel(xSupplier,UNO_QUERY);
                DBG_ASSERT(xTunnel.is(), "OPropertyBrowserController::ChangeFormatProperty : xTunnel is invalid!");
                SvNumberFormatsSupplierObj* pSupplier = (SvNumberFormatsSupplierObj*)xTunnel->getSomething(SvNumberFormatsSupplierObj::getUnoTunnelId());
                    // the same again

                aNewDesc.pSupplier = pSupplier;
                aNewDesc.nKey = aVal.ToInt32();
                    // nKey will be zero if aVal is empty or standard

                // give each control which has to know this an own copy of the description
                IBrowserControl* pControl = getPropertyBox()->GetPropertyControl(PROPERTY_EFFECTIVE_MIN);
                if (pControl)
                    ((OFormattedNumericControl*)pControl)->SetFormatDescription(aNewDesc);

                pControl = getPropertyBox()->GetPropertyControl(PROPERTY_EFFECTIVE_MAX);
                if (pControl)
                    ((OFormattedNumericControl*)pControl)->SetFormatDescription(aNewDesc);

                pControl = getPropertyBox()->GetPropertyControl(PROPERTY_EFFECTIVE_DEFAULT);
                if (pControl)
                    ((OFormattedNumericControl*)pControl)->SetFormatDescription(aNewDesc);

                pControl = getPropertyBox()->GetPropertyControl(PROPERTY_EFFECTIVE_VALUE);
                if (pControl)
                    ((OFormattedNumericControl*)pControl)->SetFormatDescription(aNewDesc);
            }

                //////////////////////////////////////////////////////////////////////
            // Bei Datenquelle auch Cursor-/ListSource fuellen
            if (nPropId == PROPERTY_ID_DATASOURCE )
            {
                Property aProp = getIntrospecteeProperty( rName );

                Any aValue = StringToAny( aUserVal, aProp, nPropId);

                sal_Bool bFlag= !(aProp.Attributes & PropertyAttribute::MAYBEVOID) && !aValue.hasValue();


                if (!bFlag)
                    m_xPropValueAccess->setPropertyValue(rName, aValue );

                if (m_xPropStateAccess.is()&& !aValue.hasValue())
                {
                    m_xPropStateAccess->setPropertyToDefault(rName);
                }

                // try to open a connection for the new data source. Needed for filling the table list etc., but the methods doing this
                // don't display errors, and we want to have an error message.
                connectRowset();

                SetCursorSource(sal_False);
                SetListSource();
            }
        }
        catch(PropertyVetoException& eVetoException)
        {
            InfoBox(m_pView, eVetoException.Message).Execute();
        }
        catch(Exception&)
        {
            DBG_ERROR("OPropertyBrowserController::Commit : caught an exception !")
        }

        if (m_pChangeMultiplexer)
            m_pChangeMultiplexer->unlock();
    }

    //------------------------------------------------------------------------
    void OPropertyBrowserController::Select( const String& aName, void* pData )
    {
    }

//............................................................................
} // namespace pcr
//............................................................................

/*************************************************************************
 * history:
 *  $Log: not supported by cvs2svn $
 *  Revision 1.52  2002/12/02 13:16:38  fs
 *  #105726# properly EnableEmptyFieldValue (broken in 1.44)
 *
 *  Revision 1.51  2002/10/25 12:49:51  fs
 *  #104512# fixed some controls leaking
 *
 *  Revision 1.50  2002/08/22 10:49:52  oj
 *  #96105# set the modified flag at the model
 *
 *  Revision 1.49  2002/08/06 08:14:05  oj
 *  #102058# set control type to BCT_COMBOBOX
 *
 *  Revision 1.48  2001/12/10 07:13:25  fs
 *  #95263# when retrieving the columns of a SQL-command form, use a '0=1' filter instead of the one supplied with the statement
 *
 *  Revision 1.47  2001/12/07 11:12:31  tbe
 *  #92755# Assign Standard Values for Basic Controls in Designmode
 *
 *  Revision 1.46  2001/11/09 13:35:20  tbe
 *  #92755# Assign Standard Values for Basic Controls in Designmode
 *
 *  Revision 1.0 10.01.01 08:51:55  fs
 ************************************************************************/