summaryrefslogtreecommitdiff
path: root/forms/source/component/DatabaseForm.cxx
blob: de7505c1ae52c59ff858bc78a5b86fbfb3fab2f6 (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
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
3359
3360
3361
3362
3363
3364
3365
3366
3367
3368
3369
3370
3371
3372
3373
3374
3375
3376
3377
3378
3379
3380
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390
3391
3392
3393
3394
3395
3396
3397
3398
3399
3400
3401
3402
3403
3404
3405
3406
3407
3408
3409
3410
3411
3412
3413
3414
3415
3416
3417
3418
3419
3420
3421
3422
3423
3424
3425
3426
3427
3428
3429
3430
3431
3432
3433
3434
3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
3447
3448
3449
3450
3451
3452
3453
3454
3455
3456
3457
3458
3459
3460
3461
3462
3463
3464
3465
3466
3467
3468
3469
3470
3471
3472
3473
3474
3475
3476
3477
3478
3479
3480
3481
3482
3483
3484
3485
3486
3487
3488
3489
3490
3491
3492
3493
3494
3495
3496
3497
3498
3499
3500
3501
3502
3503
3504
3505
3506
3507
3508
3509
3510
3511
3512
3513
3514
3515
3516
3517
3518
3519
3520
3521
3522
3523
3524
3525
3526
3527
3528
3529
3530
3531
3532
3533
3534
3535
3536
3537
3538
3539
3540
3541
3542
3543
3544
3545
3546
3547
3548
3549
3550
3551
3552
3553
3554
3555
3556
3557
3558
3559
3560
3561
3562
3563
3564
3565
3566
3567
3568
3569
3570
3571
3572
3573
3574
3575
3576
3577
3578
3579
3580
3581
3582
3583
3584
3585
3586
3587
3588
3589
3590
3591
3592
3593
3594
3595
3596
3597
3598
3599
3600
3601
3602
3603
3604
3605
3606
3607
3608
3609
3610
3611
3612
3613
3614
3615
3616
3617
3618
3619
3620
3621
3622
3623
3624
3625
3626
3627
3628
3629
3630
3631
3632
3633
3634
3635
3636
3637
3638
3639
3640
3641
3642
3643
3644
3645
3646
3647
3648
3649
3650
3651
3652
3653
3654
3655
3656
3657
3658
3659
3660
3661
3662
3663
3664
3665
3666
3667
3668
3669
3670
3671
3672
3673
3674
3675
3676
3677
3678
3679
3680
3681
3682
3683
3684
3685
3686
3687
3688
3689
3690
3691
3692
3693
3694
3695
3696
3697
3698
3699
3700
3701
3702
3703
3704
3705
3706
3707
3708
3709
3710
3711
3712
3713
3714
3715
3716
3717
3718
3719
3720
3721
3722
3723
3724
3725
3726
3727
3728
3729
3730
3731
3732
3733
3734
3735
3736
3737
3738
3739
3740
3741
3742
3743
3744
3745
3746
3747
3748
3749
3750
3751
3752
3753
3754
3755
3756
3757
3758
3759
3760
3761
3762
3763
3764
3765
3766
3767
3768
3769
3770
3771
3772
3773
3774
3775
3776
3777
3778
3779
3780
3781
3782
3783
3784
3785
3786
3787
3788
3789
3790
3791
3792
3793
3794
3795
3796
3797
3798
3799
3800
3801
3802
3803
3804
3805
3806
3807
3808
3809
3810
3811
3812
3813
3814
3815
3816
3817
3818
3819
3820
3821
3822
3823
3824
3825
3826
3827
3828
3829
3830
3831
3832
3833
3834
3835
3836
3837
3838
3839
3840
3841
3842
3843
3844
3845
3846
3847
3848
3849
3850
3851
3852
3853
3854
3855
3856
3857
3858
3859
3860
3861
3862
3863
3864
3865
3866
3867
3868
3869
3870
3871
3872
3873
3874
3875
3876
3877
3878
3879
3880
3881
3882
3883
3884
3885
3886
3887
3888
3889
3890
3891
3892
3893
3894
3895
3896
3897
3898
3899
3900
3901
3902
3903
3904
3905
3906
3907
3908
3909
3910
3911
3912
3913
3914
3915
3916
3917
3918
3919
3920
3921
3922
3923
3924
3925
3926
3927
3928
3929
3930
3931
3932
3933
3934
3935
3936
3937
3938
3939
3940
3941
3942
3943
3944
3945
3946
3947
3948
3949
3950
3951
3952
3953
3954
3955
3956
3957
3958
3959
3960
3961
3962
3963
3964
3965
3966
3967
3968
3969
3970
3971
3972
3973
3974
3975
3976
3977
3978
3979
3980
3981
3982
3983
3984
3985
3986
3987
3988
3989
3990
3991
3992
3993
3994
3995
3996
3997
3998
3999
4000
4001
4002
4003
4004
4005
4006
4007
4008
4009
4010
4011
4012
4013
4014
4015
4016
4017
4018
4019
4020
4021
4022
4023
4024
4025
4026
4027
4028
4029
4030
4031
4032
4033
4034
4035
4036
4037
4038
4039
4040
4041
4042
4043
4044
4045
4046
4047
4048
4049
4050
4051
4052
4053
4054
4055
4056
4057
4058
4059
4060
4061
4062
4063
4064
4065
4066
4067
4068
4069
4070
4071
4072
4073
4074
4075
4076
4077
4078
4079
4080
4081
4082
4083
4084
4085
4086
4087
4088
4089
4090
4091
4092
4093
4094
4095
4096
4097
4098
4099
4100
4101
4102
4103
4104
4105
4106
4107
4108
4109
4110
4111
4112
4113
4114
4115
4116
4117
4118
4119
4120
4121
4122
4123
4124
4125
4126
4127
4128
4129
4130
4131
4132
4133
4134
4135
4136
4137
4138
4139
4140
4141
4142
4143
4144
4145
4146
4147
4148
4149
4150
4151
4152
4153
4154
4155
4156
4157
4158
4159
4160
4161
4162
4163
4164
4165
4166
4167
4168
4169
4170
4171
4172
4173
4174
4175
4176
4177
4178
4179
4180
4181
4182
4183
4184
4185
4186
4187
4188
4189
4190
4191
4192
4193
4194
4195
4196
4197
4198
4199
4200
4201
4202
4203
4204
4205
4206
4207
4208
4209
4210
4211
4212
4213
4214
4215
4216
4217
4218
4219
4220
4221
4222
4223
4224
4225
4226
4227
4228
4229
4230
4231
4232
4233
4234
4235
4236
4237
4238
4239
4240
4241
4242
4243
4244
4245
4246
4247
4248
4249
4250
4251
4252
4253
4254
4255
4256
4257
4258
4259
4260
4261
4262
4263
4264
4265
4266
4267
4268
4269
4270
4271
4272
4273
4274
4275
4276
4277
4278
4279
4280
4281
4282
4283
4284
4285
4286
4287
4288
4289
4290
4291
4292
4293
4294
4295
4296
4297
4298
4299
4300
4301
4302
4303
4304
4305
4306
4307
4308
4309
4310
4311
4312
4313
4314
4315
4316
4317
4318
4319
4320
4321
4322
4323
4324
4325
4326
4327
4328
4329
4330
/*************************************************************************
 *
 *  $RCSfile: DatabaseForm.cxx,v $
 *
 *  $Revision: 1.40 $
 *
 *  last change: $Author: fs $ $Date: 2001-10-22 15:28:38 $
 *
 *  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 EXPRESSED 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): _______________________________________
 *
 *
 ************************************************************************/

#include <stdio.h>
#include <ctype.h>

#ifndef _FRM_DATABASEFORM_HXX_
#include "DatabaseForm.hxx"
#endif
#ifndef _FRM_EVENT_THREAD_HXX_
#include "EventThread.hxx"
#endif
#ifndef _FORMS_LISTBOX_HXX_
#include "ListBox.hxx"
#endif
#ifndef _FRM_RESOURCE_HXX_
#include "frm_resource.hxx"
#endif
#ifndef _FRM_RESOURCE_HRC_
#include "frm_resource.hrc"
#endif

#ifndef _COM_SUN_STAR_SDB_XSQLQUERYCOMPOSERFACTORY_HPP_
#include <com/sun/star/sdb/XSQLQueryComposerFactory.hpp>
#endif
#ifndef _COM_SUN_STAR_UTIL_XCANCELLABLE_HPP_
#include <com/sun/star/util/XCancellable.hpp>
#endif
#ifndef _COM_SUN_STAR_SDBC_RESULTSETTYPE_HPP_
#include <com/sun/star/sdbc/ResultSetType.hpp>
#endif
#ifndef _COM_SUN_STAR_SDBC_RESULTSETCONCURRENCY_HPP_
#include <com/sun/star/sdbc/ResultSetConcurrency.hpp>
#endif
#ifndef _COM_SUN_STAR_SDBC_DATATYPE_HPP_
#include <com/sun/star/sdbc/DataType.hpp>
#endif
#ifndef _COM_SUN_STAR_IO_XOBJECTINPUTSTREAM_HPP_
#include <com/sun/star/io/XObjectInputStream.hpp>
#endif
#ifndef _COM_SUN_STAR_IO_XOBJECTOUTPUTSTREAM_HPP_
#include <com/sun/star/io/XObjectOutputStream.hpp>
#endif
#ifndef _COM_SUN_STAR_FORM_DATASELECTIONTYPE_HPP_
#include <com/sun/star/form/DataSelectionType.hpp>
#endif
#ifndef _COM_SUN_STAR_SDB_SQLCONTEXT_HPP_
#include <com/sun/star/sdb/SQLContext.hpp>
#endif
#ifndef _COM_SUN_STAR_FORM_FORMCOMPONENTTYPE_HPP_
#include <com/sun/star/form/FormComponentType.hpp>
#endif
#ifndef _COM_SUN_STAR_FRAME_XDISPATCHPROVIDER_HPP_
#include <com/sun/star/frame/XDispatchProvider.hpp>
#endif
#ifndef _COM_SUN_STAR_FRAME_FRAMESEARCHFLAG_HPP_
#include <com/sun/star/frame/FrameSearchFlag.hpp>
#endif
#ifndef _COM_SUN_STAR_FRAME_XDISPATCH_HPP_
#include <com/sun/star/frame/XDispatch.hpp>
#endif
#ifndef _COM_SUN_STAR_FRAME_XMODEL_HPP_
#include <com/sun/star/frame/XModel.hpp>
#endif
#ifndef _COM_SUN_STAR_SDB_COMMANDTYPE_HPP_
#include <com/sun/star/sdb/CommandType.hpp>
#endif
#ifndef _COM_SUN_STAR_SDB_ROWSETVETOEXCEPTION_HPP_
#include <com/sun/star/sdb/RowSetVetoException.hpp>
#endif
#ifndef _COM_SUN_STAR_SDBCX_XCOLUMNSSUPPLIER_HPP_
#include <com/sun/star/sdbcx/XColumnsSupplier.hpp>
#endif
#ifndef _COM_SUN_STAR_SDB_XPARAMETERSSUPPLIER_HPP_
#include <com/sun/star/sdb/XParametersSupplier.hpp>
#endif
#ifndef _COM_SUN_STAR_SDBCX_PRIVILEGE_HPP_
#include <com/sun/star/sdbcx/Privilege.hpp>
#endif
#ifndef _COM_SUN_STAR_SDBC_XROWSET_HPP_
#include <com/sun/star/sdbc/XRowSet.hpp>
#endif
#ifndef _COM_SUN_STAR_FORM_TABULATORCYCLE_HPP_
#include <com/sun/star/form/TabulatorCycle.hpp>
#endif
#ifndef _COM_SUN_STAR_AWT_XCONTROLCONTAINER_HPP_
#include <com/sun/star/awt/XControlContainer.hpp>
#endif
#ifndef _COM_SUN_STAR_AWT_XTEXTCOMPONENT_HPP_
#include <com/sun/star/awt/XTextComponent.hpp>
#endif
#ifndef _COM_SUN_STAR_UTIL_XURLTRANSFORMER_HPP_
#include <com/sun/star/util/XURLTransformer.hpp>
#endif

#ifndef _TOOLS_DEBUG_HXX
#include <tools/debug.hxx>
#endif

#ifndef _SV_TIMER_HXX
#include <vcl/timer.hxx>
#endif

#ifndef _FRM_GROUPMANAGER_HXX_
#include "GroupManager.hxx"
#endif

#ifndef _FRM_PROPERTY_HRC_
#include "property.hrc"
#endif
#ifndef _FRM_PROPERTY_HXX_
#include "property.hxx"
#endif
#ifndef _FRM_SERVICES_HXX_
#include "services.hxx"
#endif
#ifndef _FRM_IDS_HXX_
#include "ids.hxx"
#endif

#ifndef _FSYS_HXX
#include <tools/fsys.hxx>
#endif
#ifndef _TOOLS_INETMSG_HXX
#include <tools/inetmsg.hxx>
#endif
#ifndef _INETSTRM_HXX //autogen
#include <svtools/inetstrm.hxx>
#endif
#ifndef _CPPUHELPER_IMPLBASE2_HXX_
#include <cppuhelper/implbase2.hxx>
#endif
#ifndef _COMPHELPER_STLTYPES_HXX_
#include <comphelper/stl_types.hxx>
#endif
#ifndef _COMPHELPER_SEQUENCE_HXX_
#include <comphelper/sequence.hxx>
#endif
#ifndef _COMPHELPER_STLTYPES_HXX_
#include <comphelper/stl_types.hxx>
#endif
#ifndef _COMPHELPER_UNO3_HXX_
#include <comphelper/uno3.hxx>
#endif
#ifndef _COMPHELPER_SEQSTREAM_HXX
#include <comphelper/seqstream.hxx>
#endif
#ifndef _COMPHELPER_ENUMHELPER_HXX_
#include <comphelper/enumhelper.hxx>
#endif
#ifndef _COMPHELPER_CONTAINER_HXX_
#include <comphelper/container.hxx>
#endif
#ifndef _CONNECTIVITY_DBTOOLS_HXX_
#include <connectivity/dbtools.hxx>
#endif
#ifndef _OSL_MUTEX_HXX_
#include <osl/mutex.hxx>
#endif
#ifndef _URLOBJ_HXX
#include <tools/urlobj.hxx>
#endif
#ifndef _TOOLS_SOLMATH_HXX
#include <tools/solmath.hxx>
#endif
#ifndef _INETTYPE_HXX
#include <svtools/inettype.hxx>
#endif
#ifndef _COMPHELPER_EXTRACT_HXX_
#include <comphelper/extract.hxx>
#endif
#ifndef _VOS_MUTEX_HXX_
#include <vos/mutex.hxx>
#endif
#ifndef _SV_SVAPP_HXX   // because of the solar mutex
#include <vcl/svapp.hxx>
#endif
#ifndef _RTL_TENCINFO_H
#include <rtl/tencinfo.h>
#endif
#ifndef _UNTOOLS_UCBLOCKBYTES_HXX
#include <unotools/ucblockbytes.hxx>
#endif
#ifndef _UNTOOLS_UCBSTREAMHELPER_HXX
#include <unotools/ucbstreamhelper.hxx>
#endif

// compatiblity: DatabaseCursorType is dead, but for compatiblity reasons we still have to write it ...
namespace com {
namespace sun {
namespace star {
namespace data {

enum DatabaseCursorType
{
    DatabaseCursorType_FORWARD = 0,
    DatabaseCursorType_SNAPSHOT = 1,
    DatabaseCursorType_KEYSET = 2,
    DatabaseCursorType_DYNAMIC = 3,
    DatabaseCursorType_MAKE_FIXED_SIZE = SAL_MAX_ENUM
};

} } } }

#ifndef _COMPHELPER_INTERACTION_HXX_
#include <comphelper/interaction.hxx>
#endif
#ifndef _COM_SUN_STAR_SDB_XINTERACTIONSUPPLYPARAMETERS_HPP_
#include <com/sun/star/sdb/XInteractionSupplyParameters.hpp>
#endif
#ifndef _COM_SUN_STAR_SDB_PARAMETERSREQUEST_HPP_
#include <com/sun/star/sdb/ParametersRequest.hpp>
#endif

#define DATABASEFORM_IMPLEMENTATION_NAME    ::rtl::OUString::createFromAscii("com.sun.star.comp.forms.ODatabaseForm")

using namespace ::dbtools;
using namespace ::comphelper;
using namespace ::com::sun::star::uno;
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::container;
using namespace ::com::sun::star::task;
using namespace ::com::sun::star::frame;
using namespace ::com::sun::star::form;
using namespace ::com::sun::star::awt;
using namespace ::com::sun::star::io;
using namespace ::com::sun::star::lang;
using namespace ::com::sun::star::data;
using namespace ::com::sun::star::util;

//.........................................................................
namespace frm
{
//.........................................................................


//------------------------------------------------------------------
Reference< XModel> getXModel(const Reference< XInterface>& xIface)
{
    Reference< XModel> xModel(xIface, UNO_QUERY);
    if (xModel.is())
        return xModel;
    else
    {
        Reference< XChild> xChild(xIface, UNO_QUERY);
        if (xChild.is())
        {
            Reference< XInterface> xParent( xChild->getParent());
            return getXModel(xParent);
        }
        else
            return NULL;
    }
}

//==================================================================
// OParameterContinuation
//==================================================================
class OParameterContinuation : public OInteraction< XInteractionSupplyParameters >
{
    Sequence< PropertyValue >       m_aValues;

public:
    OParameterContinuation() { }

    Sequence< PropertyValue >   getValues() const { return m_aValues; }

// XInteractionSupplyParameters
    virtual void SAL_CALL setParameters( const Sequence< PropertyValue >& _rValues ) throw(RuntimeException);
};

//------------------------------------------------------------------
void SAL_CALL OParameterContinuation::setParameters( const Sequence< PropertyValue >& _rValues ) throw(RuntimeException)
{
    m_aValues = _rValues;
}

//==================================================================
//= OParameterWrapper
//=-----------------------------------------------------------------
//= wraps a parameter property set got from an SQLQueryComposer
//= so it has an additional property "Value", which is forwarded to
//= an XParameters interface
//==================================================================

class OParameterWrapper
        :public ::cppu::OWeakObject
        ,public ::cppu::OPropertySetHelper
        ,public ::comphelper::OAggregationArrayUsageHelper<OParameterWrapper>
{
    Any                         m_aValue;
    ::osl::Mutex                m_aMutex;
    ::cppu::OBroadcastHelper    m_aBroadcastHelper;
    OImplementationIdsRef       m_aHoldIdHelper;

    Reference<XPropertySet>     m_xPseudoAggregate;
    Reference<XParameters>      m_xValueDestination;
    sal_Int32                   m_nIndex;


    virtual ~OParameterWrapper();
public:
    OParameterWrapper(const Reference<XPropertySet>& _rxColumn, const Reference<XParameters>& _rxAllParameters, sal_Int32 _nIndex);

    // UNO
    DECLARE_UNO3_DEFAULTS(OParameterWrapper, OWeakObject);
    virtual Any SAL_CALL queryInterface(const Type& _rType) throw (RuntimeException);
    virtual Sequence<sal_Int8>          SAL_CALL getImplementationId() throw(RuntimeException);
    virtual Sequence<Type>  SAL_CALL getTypes() throw(RuntimeException);

    // XPropertySet
    virtual Reference<XPropertySetInfo> SAL_CALL getPropertySetInfo() throw( RuntimeException );
    virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper();

    // OPropertySetHelper
    virtual sal_Bool SAL_CALL convertFastPropertyValue( Any& rConvertedValue, Any& rOldValue, sal_Int32 nHandle, const Any& rValue) throw( IllegalArgumentException );
    virtual void SAL_CALL setFastPropertyValue_NoBroadcast( sal_Int32 nHandle, const Any& rValue ) throw( Exception );
    virtual void SAL_CALL getFastPropertyValue( Any& rValue, sal_Int32 nHandle ) const;

    // OAggregationArrayUsageHelper
    virtual void fillProperties(
        Sequence< Property >& /* [out] */ _rProps,
        Sequence< Property >& /* [out] */ _rAggregateProps
        ) const;

protected:
    ::rtl::OUString getPseudoAggregatePropertyName(sal_Int32 _nHandle) const;
};

DBG_NAME(OParameterWrapper)
//------------------------------------------------------------------------------
OParameterWrapper::OParameterWrapper(const Reference<XPropertySet>& _rxColumn, const Reference<XParameters>& _rxAllParameters, sal_Int32 _nIndex)
    :OPropertySetHelper(m_aBroadcastHelper)
    ,m_aBroadcastHelper(m_aMutex)
    ,m_xPseudoAggregate(_rxColumn)
    ,m_xValueDestination(_rxAllParameters)
    ,m_nIndex(_nIndex)
{
    DBG_CTOR(OParameterWrapper, NULL);
}

//------------------------------------------------------------------------------
OParameterWrapper::~OParameterWrapper()
{
    DBG_DTOR(OParameterWrapper, NULL);
}

//------------------------------------------------------------------------------
Any SAL_CALL OParameterWrapper::queryInterface(const Type& _rType) throw (RuntimeException)
{
    Any aReturn;
    aReturn = OWeakObject::queryInterface(_rType);

    if (!aReturn.hasValue())
        OPropertySetHelper::queryInterface(_rType);

    return aReturn;
}

//------------------------------------------------------------------------------
Sequence< Type > SAL_CALL OParameterWrapper::getTypes(  ) throw(RuntimeException)
{
    Sequence< Type > aWeakTypes(1);
    aWeakTypes.getArray()[0] = ::getCppuType(static_cast<Reference<XWeak>*>(NULL));

    Sequence< Type > aPropertyTypes(3);
    aPropertyTypes.getArray()[0] = ::getCppuType(static_cast<Reference<XPropertySet>*>(NULL));
    aPropertyTypes.getArray()[1] = ::getCppuType(static_cast<Reference<XFastPropertySet>*>(NULL));
    aPropertyTypes.getArray()[2] = ::getCppuType(static_cast<Reference<XMultiPropertySet>*>(NULL));

    return concatSequences(aWeakTypes, aPropertyTypes);
}

//------------------------------------------------------------------------------
Sequence<sal_Int8> SAL_CALL OParameterWrapper::getImplementationId() throw(RuntimeException)
{
    Reference<XTypeProvider> xMyTpes;
    query_interface(static_cast<XWeak*>(this), xMyTpes);
    return OImplementationIds::getImplementationId(xMyTpes);
}

//------------------------------------------------------------------------------
::rtl::OUString OParameterWrapper::getPseudoAggregatePropertyName(sal_Int32 _nHandle) const
{
    Reference<XPropertySetInfo>  xInfo = const_cast<OParameterWrapper*>(this)->getPropertySetInfo();
    Sequence<Property> aProperties = xInfo->getProperties();
    const Property* pProperties = aProperties.getConstArray();
    for (sal_Int32 i=0; i<aProperties.getLength(); ++i, ++pProperties)
    {
        if (pProperties->Handle == _nHandle)
            return pProperties->Name;
    }

    DBG_ERROR("OParameterWrapper::getPseudoAggregatePropertyName : invalid argument !");
    return ::rtl::OUString();
}

//------------------------------------------------------------------------------
Reference<XPropertySetInfo>  OParameterWrapper::getPropertySetInfo() throw( RuntimeException )
{
    Reference<XPropertySetInfo>  xInfo( createPropertySetInfo( getInfoHelper() ) );
    return xInfo;
}

//------------------------------------------------------------------------------
void OParameterWrapper::fillProperties(
        Sequence< Property >& _rProps,
        Sequence< Property >& _rAggregateProps ) const
{
    BEGIN_AGGREGATION_PROPERTY_HELPER(1, m_xPseudoAggregate)
        DECL_PROP2(VALUE,       ::rtl::OUString, TRANSIENT, MAYBEVOID);
    END_AGGREGATION_PROPERTY_HELPER();
}

//------------------------------------------------------------------------------
::cppu::IPropertyArrayHelper& OParameterWrapper::getInfoHelper()
{
    return *const_cast<OParameterWrapper*>(this)->getArrayHelper();
}

//------------------------------------------------------------------------------
sal_Bool OParameterWrapper::convertFastPropertyValue(Any& rConvertedValue, Any& rOldValue, sal_Int32 nHandle, const Any& rValue) throw( IllegalArgumentException )
{
    DBG_ASSERT(PROPERTY_ID_VALUE == nHandle, "OParameterWrapper::convertFastPropertyValue : the only non-readonly prop should be our PROPERTY_VALUE");
    // we're lazy here ...
    rOldValue = m_aValue;
    rConvertedValue = rValue;
    return sal_True;    // assume "modified" ...
}

//------------------------------------------------------------------------------
void OParameterWrapper::setFastPropertyValue_NoBroadcast( sal_Int32 nHandle, const Any& rValue ) throw( Exception )
{
    if (nHandle == PROPERTY_ID_VALUE)
    {
        // get the type of the param
        Any aParamType = m_xPseudoAggregate->getPropertyValue(PROPERTY_FIELDTYPE);
        DBG_ASSERT(aParamType.getValueType().getTypeClass() == TypeClass_LONG, "ODatabaseForm::setPropertyValue : invalid parameter field !");
        sal_Int32 nScale = 0;
        if (hasProperty(PROPERTY_SCALE, m_xPseudoAggregate))
        {
            Any aScale = m_xPseudoAggregate->getPropertyValue(PROPERTY_SCALE);
            DBG_ASSERT(aScale.getValueType().getTypeClass() == TypeClass_LONG, "ODatabaseForm::setPropertyValue : invalid parameter field !");
            nScale = getINT32(aScale);
        }
        // TODO : aParamType & nScale can be obtained within the constructor ....

        try
        {
            m_xValueDestination->setObjectWithInfo(m_nIndex + 1, rValue, getINT32(aParamType), nScale);
                // the index of the parameters is one-based
            m_aValue = rValue;
        }
        catch(SQLException& e)
        {
            WrappedTargetException aExceptionWrapper;
            aExceptionWrapper.Context = e.Context;
            aExceptionWrapper.Message = e.Message;
            aExceptionWrapper.TargetException <<= e;
            throw WrappedTargetException(aExceptionWrapper);
        }
    }
    else
    {
        ::rtl::OUString aName = getPseudoAggregatePropertyName(nHandle);
        m_xPseudoAggregate->setPropertyValue(aName, rValue);
    }
}

//------------------------------------------------------------------------------
void OParameterWrapper::getFastPropertyValue( Any& rValue, sal_Int32 nHandle ) const
{
    if (nHandle == PROPERTY_ID_VALUE)
    {
        rValue = m_aValue;
    }
    else
    {
        ::rtl::OUString aName = getPseudoAggregatePropertyName(nHandle);
        rValue = m_xPseudoAggregate->getPropertyValue(aName);
    }
}

//==================================================================
//= OParametersImpl
//=-----------------------------------------------------------------
//= class for the parameter event see approveParameter
//==================================================================

typedef ::cppu::WeakImplHelper2<XIndexAccess, XEnumerationAccess> OParametersImplBase;
class OParametersImpl : public OParametersImplBase
{
public:
    typedef ::std::vector<Reference<XPropertySet> > Parameters;
    typedef Parameters::iterator                    ParametersIterator;

private:
    Parameters      m_aParameters;

public:
    // UNO
    DECLARE_UNO3_AGG_DEFAULTS(OParametersImpl, OParametersImplBase);

    // XElementAccess
    virtual Type SAL_CALL getElementType() throw( RuntimeException );
    virtual sal_Bool SAL_CALL hasElements() throw( RuntimeException );

    // XEnumerationAccess
    virtual Reference<XEnumeration> SAL_CALL createEnumeration() throw( RuntimeException );

    // XIndexAccess
    virtual sal_Int32 SAL_CALL getCount() throw( RuntimeException );
    virtual Any SAL_CALL getByIndex(sal_Int32 _rIndex) throw( IndexOutOfBoundsException, WrappedTargetException, RuntimeException );

    Parameters& getParameters() { return m_aParameters; }
};

// XElementAccess
//------------------------------------------------------------------------------
Type SAL_CALL OParametersImpl::getElementType() throw( RuntimeException )
{
    return ::getCppuType(static_cast<Reference<XPropertySet>*>(NULL));
}

//------------------------------------------------------------------------------
sal_Bool SAL_CALL OParametersImpl::hasElements() throw( RuntimeException )
{
    return m_aParameters.size() != 0;
}

// XIndexAccess
//------------------------------------------------------------------------------
sal_Int32 SAL_CALL OParametersImpl::getCount() throw( RuntimeException )
{
    return m_aParameters.size();
}

//------------------------------------------------------------------------------
Any SAL_CALL OParametersImpl::getByIndex(sal_Int32 _nIndex) throw( IndexOutOfBoundsException, WrappedTargetException, RuntimeException )
{
    if ((_nIndex < 0) || (_nIndex >= (sal_Int32)m_aParameters.size()))
        throw IndexOutOfBoundsException();

    return makeAny(m_aParameters[_nIndex]);
}

// XEnumerationAccess
//------------------------------------------------------------------------------
Reference<XEnumeration>  OParametersImpl::createEnumeration() throw( RuntimeException )
{
    return new OEnumerationByIndex(reinterpret_cast<XIndexAccess*>(this));
}

//==================================================================
//= OParameterInfoImpl
//=-----------------------------------------------------------------
//= class which collects all information for parameter filling
//==================================================================
DECLARE_STL_USTRINGACCESS_MAP(sal_Int32, MapUString2INT32);

struct OParameterInfoImpl
{
    sal_Int32                   nCount;                 //  Number of Parameters
    Reference<XSQLQueryComposer>    xComposer;
    Reference<XNameAccess>          xParamsAsNames;
    OParametersImpl*        pParameters;
    MapUString2INT32        aParamMapping;

    OParameterInfoImpl():nCount(0),pParameters(NULL){}
    ~OParameterInfoImpl()
    {
        if (pParameters)
            pParameters->release();
    }
};

//==================================================================
//= OFormSubmitResetThread
//=-----------------------------------------------------------------
//= submitting and resetting html-forms asynchronously
//==================================================================

//------------------------------------------------------------------
class OFormSubmitResetThread: public OComponentEventThread
{
protected:

    // duplicate an event with respect to it's type
    virtual EventObject *cloneEvent( const EventObject *pEvt ) const;

    // process an event. while processing the mutex isn't locked, and pCompImpl
    // is made sure to remain valid
    virtual void processEvent( ::cppu::OComponentHelper* _pCompImpl,
                               const EventObject* _pEvt,
                               const Reference<XControl>& _rControl,
                               sal_Bool _bSubmit);

public:

    OFormSubmitResetThread(ODatabaseForm* pControl) : OComponentEventThread(pControl) { }
};

//------------------------------------------------------------------
EventObject* OFormSubmitResetThread::cloneEvent(
        const EventObject *pEvt ) const
{
    return new MouseEvent( *(MouseEvent *)pEvt );
}

//------------------------------------------------------------------
void OFormSubmitResetThread::processEvent(
        ::cppu::OComponentHelper* pCompImpl,
        const EventObject *_pEvt,
        const Reference<XControl>& _rControl,
        sal_Bool _bSubmit)
{
    if (_bSubmit)
        ((ODatabaseForm *)pCompImpl)->submit_impl(_rControl, *reinterpret_cast<const MouseEvent*>(_pEvt), true);
    else
        ((ODatabaseForm *)pCompImpl)->reset_impl(true);
}

//==================================================================
//= ODatabaseForm
//==================================================================

//------------------------------------------------------------------
InterfaceRef SAL_CALL ODatabaseForm_CreateInstance(const Reference<XMultiServiceFactory>& _rxFactory)
{
    return *(new ODatabaseForm(_rxFactory));
}

//------------------------------------------------------------------------------
Sequence<sal_Int8> SAL_CALL ODatabaseForm::getImplementationId() throw(RuntimeException)
{
    return OImplementationIds::getImplementationId(getTypes());
}

//------------------------------------------------------------------
Sequence<Type> SAL_CALL ODatabaseForm::getTypes() throw(RuntimeException)
{
    // ask the aggregate
    Sequence<Type> aAggregateTypes;
    Reference<XTypeProvider> xAggregateTypes;
    if (query_aggregation(m_xAggregate, xAggregateTypes))
        aAggregateTypes = xAggregateTypes->getTypes();

    Sequence<Type> aRet = concatSequences(aAggregateTypes, ODatabaseForm_BASE1::getTypes(), OFormComponents::getTypes());
    return concatSequences(aRet,ODatabaseForm_BASE2::getTypes(), ODatabaseForm_BASE3::getTypes());
}

//------------------------------------------------------------------
Any SAL_CALL ODatabaseForm::queryAggregation(const Type& _rType) throw(RuntimeException)
{
    Any aReturn = ODatabaseForm_BASE1::queryInterface(_rType);
    // our own interfaces
    if (!aReturn.hasValue())
    {
        aReturn = ODatabaseForm_BASE2::queryInterface(_rType);
        // property set related interfaces
        if (!aReturn.hasValue())
        {
            aReturn = OPropertySetAggregationHelper::queryInterface(_rType);

            // form component collection related interfaces
            if (!aReturn.hasValue())
            {
                aReturn = OFormComponents::queryAggregation(_rType);

                // interfaces already present in the aggregate which we want to reroute
                // only available if we could create the aggregate
                if (!aReturn.hasValue() && m_xAggregateAsRowSet.is())
                    aReturn = ODatabaseForm_BASE3::queryInterface(_rType);

                // aggregate interfaces
                // (ask the aggregated object _after_ the OComponentHelper (base of OFormComponents),
                // so calls to the XComponent interface reach us and not the aggreagtion)
                if (!aReturn.hasValue() && m_xAggregate.is())
                    aReturn = m_xAggregate->queryAggregation(_rType);
            }
        }
    }

    return aReturn;
}

DBG_NAME(ODatabaseForm);
//------------------------------------------------------------------
ODatabaseForm::ODatabaseForm(const Reference<XMultiServiceFactory>& _rxFactory)
        :OFormComponents(_rxFactory)
        ,OPropertySetAggregationHelper(OComponentHelper::rBHelper)
        ,OPropertyChangeListener(m_aMutex)
        ,m_aLoadListeners(m_aMutex)
        ,m_aRowSetApproveListeners(m_aMutex)
        ,m_aRowSetListeners(m_aMutex)
        ,m_aParameterListeners(m_aMutex)
        ,m_aResetListeners(m_aMutex)
        ,m_aSubmitListeners(m_aMutex)
        ,m_aErrorListeners(m_aMutex)
        ,m_bLoaded(sal_False)
        ,m_bSubForm(sal_False)
        ,m_eNavigation(NavigationBarMode_CURRENT)
        ,m_nPrivileges(0)
        ,m_pParameterInfo(NULL)
        ,m_pThread(NULL)
        ,m_eSubmitMethod(FormSubmitMethod_GET)
        ,m_eSubmitEncoding(FormSubmitEncoding_URL)
        ,m_bAllowDelete(sal_True)
        ,m_bAllowUpdate(sal_True)
        ,m_bAllowInsert(sal_True)
        ,m_pLoadTimer(NULL)
        ,m_nResetsPending(0)
        ,m_bForwardingConnection(sal_False)
        ,m_pAggregatePropertyMultiplexer(NULL)
        ,m_bSharingConnection( sal_False )
{
    DBG_CTOR(ODatabaseForm,NULL);

    // aggregate a row set
    increment(m_refCount);

    {
        m_xAggregate = Reference<XAggregation>(m_xServiceFactory->createInstance(SRV_SDB_ROWSET), UNO_QUERY);
        //  m_xAggregate = Reference<XAggregation>(m_xServiceFactory->createInstance(rtl::OUString::createFromAscii("com.sun.star.sdb.dbaccess.ORowSet")), UNO_QUERY);
        DBG_ASSERT(m_xAggregate.is(), "ODatabaseForm::ODatabaseForm : could not instantiate an SDB rowset !");
        m_xAggregateAsRowSet = Reference<XRowSet> (m_xAggregate,UNO_QUERY);
        setAggregation(m_xAggregate);
    }

    // listen for the properties, important for Parameters
    if (m_xAggregateSet.is())
    {
        m_pAggregatePropertyMultiplexer = new OPropertyChangeMultiplexer(this, m_xAggregateSet, sal_False);
        m_pAggregatePropertyMultiplexer->acquire();
        m_pAggregatePropertyMultiplexer->addProperty(PROPERTY_COMMAND);
        m_pAggregatePropertyMultiplexer->addProperty(PROPERTY_FILTER_CRITERIA);
        m_pAggregatePropertyMultiplexer->addProperty(PROPERTY_APPLYFILTER);
        m_pAggregatePropertyMultiplexer->addProperty(PROPERTY_ACTIVE_CONNECTION);
    }

    if (m_xAggregate.is())
    {
        m_xAggregate->setDelegator(static_cast<XWeak*>(this));
    }

    decrement(m_refCount);

    m_pGroupManager = new OGroupManager(this);
    m_pGroupManager->acquire();
}

//------------------------------------------------------------------
ODatabaseForm::~ODatabaseForm()
{
    DBG_DTOR(ODatabaseForm,NULL);

    m_pGroupManager->release();

    if (m_xAggregate.is())
        m_xAggregate->setDelegator(InterfaceRef());

    if (m_pAggregatePropertyMultiplexer)
    {
        m_pAggregatePropertyMultiplexer->dispose();
        m_pAggregatePropertyMultiplexer->release();
        m_pAggregatePropertyMultiplexer = NULL;
    }
}

//==============================================================================
// html tools
//------------------------------------------------------------------------
::rtl::OUString ODatabaseForm::GetDataURLEncoded(const Reference<XControl>& SubmitButton, const MouseEvent& MouseEvt)
{

    // Liste von successful Controls fuellen
    HtmlSuccessfulObjList aSuccObjList;
    FillSuccessfulList( aSuccObjList, SubmitButton, MouseEvt );


    // Liste zu ::rtl::OUString zusammensetzen
    ::rtl::OUString aResult;
    ::rtl::OUString aName;
    ::rtl::OUString aValue;

    for (   HtmlSuccessfulObjListIterator pSuccObj = aSuccObjList.begin();
            pSuccObj < aSuccObjList.end();
            ++pSuccObj
        )
    {
        aName = pSuccObj->aName;
        aValue = pSuccObj->aValue;
        if( pSuccObj->nRepresentation == SUCCESSFUL_REPRESENT_FILE && aValue.getLength() )
        {
            // Bei File-URLs wird der Dateiname und keine URL uebertragen,
            // weil Netscape dies so macht.
            INetURLObject aURL;
            aURL.SetSmartProtocol(INET_PROT_FILE);
            aURL.SetSmartURL(aValue);
            if( INET_PROT_FILE == aURL.GetProtocol() )
                aValue = INetURLObject::decode(aURL.PathToFileName(), '%', INetURLObject::DECODE_UNAMBIGUOUS);
        }
        Encode( aName );
        Encode( aValue );
        aResult += aName;
        aResult += UniString('=');
        aResult += aValue;
        if (pSuccObj < aSuccObjList.end() - 1)
            aResult += UniString('&');
    }


    aSuccObjList.clear();

    return aResult;
}

//==============================================================================
// html tools
//------------------------------------------------------------------------
::rtl::OUString ODatabaseForm::GetDataTextEncoded(const Reference<XControl>& SubmitButton, const MouseEvent& MouseEvt)
{

    // Liste von successful Controls fuellen
    HtmlSuccessfulObjList aSuccObjList;
    FillSuccessfulList( aSuccObjList, SubmitButton, MouseEvt );
    // Liste zu ::rtl::OUString zusammensetzen
    ::rtl::OUString aResult;
    ::rtl::OUString aName;
    ::rtl::OUString aValue;

    for (   HtmlSuccessfulObjListIterator pSuccObj = aSuccObjList.begin();
            pSuccObj < aSuccObjList.end();
            ++pSuccObj
        )
    {
        aName = pSuccObj->aName;
        aValue = pSuccObj->aValue;
        if (pSuccObj->nRepresentation == SUCCESSFUL_REPRESENT_FILE && aValue.getLength())
        {
            // Bei File-URLs wird der Dateiname und keine URL uebertragen,
            // weil Netscape dies so macht.
            INetURLObject aURL;
            aURL.SetSmartProtocol(INET_PROT_FILE);
            aURL.SetSmartURL(aValue);
            if( INET_PROT_FILE == aURL.GetProtocol() )
                aValue = INetURLObject::decode(aURL.PathToFileName(), '%', INetURLObject::DECODE_UNAMBIGUOUS);
        }
        Encode( aName );
        Encode( aValue );
        aResult += pSuccObj->aName;
        aResult += UniString('=');
        aResult += pSuccObj->aValue;
        if (pSuccObj < aSuccObjList.end() - 1)
            aResult += ::rtl::OUString::createFromAscii("\r\n");
    }


    // Liste loeschen
    aSuccObjList.clear();

    return aResult;
}

//------------------------------------------------------------------------
Sequence<sal_Int8> ODatabaseForm::GetDataMultiPartEncoded(const Reference<XControl>& SubmitButton, const MouseEvent& MouseEvt, ::rtl::OUString& rContentType)
{

    // Parent erzeugen
    INetMIMEMessage aParent;
    aParent.EnableAttachChild( INETMSG_MULTIPART_FORM_DATA );


    // Liste von successful Controls fuellen
    HtmlSuccessfulObjList aSuccObjList;
    FillSuccessfulList( aSuccObjList, SubmitButton, MouseEvt );


    // Liste zu ::rtl::OUString zusammensetzen
    ::rtl::OUString aResult;
    for (   HtmlSuccessfulObjListIterator pSuccObj = aSuccObjList.begin();
            pSuccObj < aSuccObjList.end();
            ++pSuccObj
        )
    {
        if( pSuccObj->nRepresentation == SUCCESSFUL_REPRESENT_TEXT )
            InsertTextPart( aParent, pSuccObj->aName, pSuccObj->aValue );
        else if( pSuccObj->nRepresentation == SUCCESSFUL_REPRESENT_FILE )
            InsertFilePart( aParent, pSuccObj->aName, pSuccObj->aValue );
    }


    // Liste loeschen
    aSuccObjList.clear();

    // Fuer Parent MessageStream erzeugen
    INetMIMEMessageStream aMessStream;
    aMessStream.SetSourceMessage( &aParent );
    aMessStream.GenerateHeader( sal_False );

    // MessageStream in SvStream kopieren
    SvMemoryStream aMemStream;
    char* pBuf = new char[1025];
    int nRead;
    while( (nRead = aMessStream.Read(pBuf, 1024)) > 0 )
        aMemStream.Write( pBuf, nRead );
    delete[] pBuf;

    aMemStream.Flush();
    aMemStream.Seek( 0 );
    void* pData = (void*)aMemStream.GetData();
    sal_Int32 nLen = aMemStream.Seek(STREAM_SEEK_TO_END);

    rContentType = UniString(aParent.GetContentType());
    return Sequence<sal_Int8>((sal_Int8*)pData, nLen);
}

//------------------------------------------------------------------------
void ODatabaseForm::AppendComponent(HtmlSuccessfulObjList& rList, const Reference<XPropertySet>& xComponentSet, const ::rtl::OUString& rNamePrefix,
                     const Reference<XControl>& rxSubmitButton, const MouseEvent& MouseEvt)
{
    if (!xComponentSet.is())
        return;

    // MIB 25.6.98: Geschachtelte Formulare abfangen ... oder muesste
    // man sie submitten?
    if (!hasProperty(PROPERTY_CLASSID, xComponentSet))
        return;

    // Namen ermitteln
    if (!hasProperty(PROPERTY_NAME, xComponentSet))
        return;

    sal_Int16 nClassId;
    xComponentSet->getPropertyValue(PROPERTY_CLASSID) >>= nClassId;
    ::rtl::OUString aName;
    xComponentSet->getPropertyValue( PROPERTY_NAME ) >>= aName;
    if( !aName.getLength() && nClassId != FormComponentType::IMAGEBUTTON)
        return;
    else    // Name um den Prefix erweitern
        aName = rNamePrefix + aName;

    switch( nClassId )
    {
        // Buttons
        case FormComponentType::COMMANDBUTTON:
        {
            // Es wird nur der gedrueckte Submit-Button ausgewertet
            // MIB: Sofern ueberhaupt einer uebergeben wurde
            if( rxSubmitButton.is() )
            {
                Reference<XPropertySet>  xSubmitButtonComponent(rxSubmitButton->getModel(), UNO_QUERY);
                if (xSubmitButtonComponent == xComponentSet && hasProperty(PROPERTY_LABEL, xComponentSet))
                {
                    // <name>=<label>
                    ::rtl::OUString aLabel;
                    xComponentSet->getPropertyValue( PROPERTY_LABEL ) >>= aLabel;
                    rList.push_back( HtmlSuccessfulObj(aName, aLabel) );
                }
            }
        } break;

        // ImageButtons
        case FormComponentType::IMAGEBUTTON:
        {
            // Es wird nur der gedrueckte Submit-Button ausgewertet
            // MIB: Sofern ueberhaupt einer uebergeben wurde
            if( rxSubmitButton.is() )
            {
                Reference<XPropertySet>  xSubmitButtonComponent(rxSubmitButton->getModel(), UNO_QUERY);
                if (xSubmitButtonComponent == xComponentSet)
                {
                    // <name>.x=<pos.X>&<name>.y=<pos.Y>
                    ::rtl::OUString aLhs = aName;
                    ::rtl::OUString aRhs = ::rtl::OUString::valueOf( MouseEvt.X );

                    // nur wenn ein Name vorhanden ist, kann ein name.x
                    aLhs += aName.getLength() ? UniString::CreateFromAscii(".x") : UniString::CreateFromAscii("x");
                    rList.push_back( HtmlSuccessfulObj(aLhs, aRhs) );

                    aLhs = aName;
                    aRhs = ::rtl::OUString::valueOf( MouseEvt.Y );
                    aLhs += aName.getLength() ? UniString::CreateFromAscii(".y") : UniString::CreateFromAscii("y");
                    rList.push_back( HtmlSuccessfulObj(aLhs, aRhs) );

                }
            }
        } break;

        // CheckBoxen / RadioButtons
        case FormComponentType::CHECKBOX:
        case FormComponentType::RADIOBUTTON:
        {
            // <name>=<refValue>
            if( !hasProperty(PROPERTY_STATE, xComponentSet) )
                break;
            sal_Int16 nChecked;
            xComponentSet->getPropertyValue( PROPERTY_STATE ) >>= nChecked;
            if( nChecked != 1 )
                break;

            ::rtl::OUString aStrValue;
            if( hasProperty(PROPERTY_REFVALUE, xComponentSet) )
                xComponentSet->getPropertyValue( PROPERTY_REFVALUE ) >>= aStrValue;

            rList.push_back( HtmlSuccessfulObj(aName, aStrValue) );
        } break;

        // Edit
        case FormComponentType::TEXTFIELD:
        {
            // <name>=<text>
            if( !hasProperty(PROPERTY_TEXT, xComponentSet) )
                break;

            // MIB: Spezial-Behandlung fuer Multiline-Edit nur dann, wenn
            // es auch ein Control dazu gibt.
            Any aTmp = xComponentSet->getPropertyValue( PROPERTY_MULTILINE );
            sal_Bool bMulti =   rxSubmitButton.is()
                            && (aTmp.getValueType().getTypeClass() == TypeClass_BOOLEAN)
                            && getBOOL(aTmp);
            ::rtl::OUString sText;
            if ( bMulti )   // Bei MultiLineEdit Text am Control abholen
            {

                Reference<XControlContainer>  xControlContainer(rxSubmitButton->getContext(), UNO_QUERY);
                if( !xControlContainer.is() ) break;

                Sequence<Reference<XControl> > aControlSeq = xControlContainer->getControls();
                Reference<XControl>  xControl;
                Reference<XFormComponent>  xControlComponent;

                // Richtiges Control suchen
                sal_Int32 i;
                for( i=0; i<aControlSeq.getLength(); i++ )
                {
                    xControl = aControlSeq.getConstArray()[i];
                    Reference<XPropertySet>  xModel(xControl->getModel(), UNO_QUERY);
                    if (xModel == xComponentSet)
                    {
                        Reference<XTextComponent>  xTextComponent(xControl, UNO_QUERY);
                        if( xTextComponent.is() )
                            sText = xTextComponent->getText();
                        break;
                    }
                }
                // Control nicht gefunden oder nicht existent, (Edit im Grid)
                if (i == aControlSeq.getLength())
                    xComponentSet->getPropertyValue( PROPERTY_TEXT ) >>= sText;
            }
            else
                xComponentSet->getPropertyValue( PROPERTY_TEXT ) >>= sText;

            rList.push_back( HtmlSuccessfulObj(aName, sText) );
        } break;

        // ComboBox, Patternfield
        case FormComponentType::COMBOBOX:
        case FormComponentType::PATTERNFIELD:
        {
            // <name>=<text>
            if( hasProperty(PROPERTY_TEXT, xComponentSet) )
            {
                ::rtl::OUString aText;
                xComponentSet->getPropertyValue( PROPERTY_TEXT ) >>= aText;
                rList.push_back( HtmlSuccessfulObj(aName, aText) );
            }
        } break;
        case FormComponentType::CURRENCYFIELD:
        case FormComponentType::NUMERICFIELD:
        {
            // <name>=<wert> // wert wird als double mit Punkt als Decimaltrenner
                             // kein Wert angegeben (NULL) -> wert leer
            if( hasProperty(PROPERTY_VALUE, xComponentSet) )
            {
                ::rtl::OUString aText;
                Any aVal  = xComponentSet->getPropertyValue( PROPERTY_VALUE );

                double aDoubleVal;
                if (aVal >>= aDoubleVal)
                {
                    sal_Int16 nScale;
                    xComponentSet->getPropertyValue( PROPERTY_DECIMAL_ACCURACY ) >>= nScale;
                    String aTempText = UniString(aText);
                        // TODO : remove this if SolarMath works with unicode strings
                    SolarMath::DoubleToString(aTempText, aDoubleVal, 'F', nScale, '.', sal_True);
                }
                rList.push_back( HtmlSuccessfulObj(aName, aText) );
            }
        }   break;
        case FormComponentType::DATEFIELD:
        {
            // <name>=<wert> // Wert wird als Datum im Format (MM-DD-YYYY)
                             // kein Wert angegeben (NULL) -> wert leer
            if( hasProperty(PROPERTY_DATE, xComponentSet) )
            {
                ::rtl::OUString aText;
                Any aVal  = xComponentSet->getPropertyValue( PROPERTY_DATE );
                sal_Int32 nInt32Val;
                if (aVal >>= nInt32Val)
                {
                    ::Date aDate(nInt32Val);
                    char s[11];
                    sprintf(s,"%02d-%02d-%04d",
                    (int)aDate.GetMonth(),
                    (int)aDate.GetDay(),
                    (int)aDate.GetYear());
                    s[10] = 0;
                    aText = ::rtl::OUString::createFromAscii(s);
                }
                rList.push_back( HtmlSuccessfulObj(aName, aText) );
            }
        }   break;
        case FormComponentType::TIMEFIELD:
        {
            // <name>=<wert> // Wert wird als Zeit im Format (HH:MM:SS) angegeben
                             // kein Wert angegeben (NULL) -> wert leer
            if( hasProperty(PROPERTY_TIME, xComponentSet) )
            {
                ::rtl::OUString aText;
                Any aVal  = xComponentSet->getPropertyValue( PROPERTY_TIME );
                sal_Int32 nInt32Val;
                if (aVal >>= nInt32Val)
                {
                    ::Time aTime(nInt32Val);
                    char s[10];
                    sprintf(s,"%02d:%02d:%02d",
                    (int)aTime.GetHour(),
                    (int)aTime.GetMin(),
                    (int)aTime.GetSec());
                    s[8] = 0;
                    aText = ::rtl::OUString::createFromAscii(s);
                }
                rList.push_back( HtmlSuccessfulObj(aName, aText) );
            }
        }   break;

        // starform
        case FormComponentType::HIDDENCONTROL:
        {

            // <name>=<value>
            if( hasProperty(PROPERTY_HIDDEN_VALUE, xComponentSet) )
            {
                ::rtl::OUString aText;
                xComponentSet->getPropertyValue( PROPERTY_HIDDEN_VALUE ) >>= aText;
                rList.push_back( HtmlSuccessfulObj(aName, aText) );
            }
        } break;

        // starform
        case FormComponentType::FILECONTROL:
        {
            // <name>=<text>
            if( hasProperty(PROPERTY_TEXT, xComponentSet) )
            {

                ::rtl::OUString aText;
                xComponentSet->getPropertyValue( PROPERTY_TEXT ) >>= aText;
                rList.push_back( HtmlSuccessfulObj(aName, aText, SUCCESSFUL_REPRESENT_FILE) );
            }
        } break;

        // starform
        case FormComponentType::LISTBOX:
        {

            // <name>=<Token0>&<name>=<Token1>&...&<name>=<TokenN> (Mehrfachselektion)
            if (!hasProperty(PROPERTY_SELECT_SEQ, xComponentSet) ||
                !hasProperty(PROPERTY_STRINGITEMLIST, xComponentSet))
                break;

            // angezeigte Werte
            Sequence< ::rtl::OUString > aVisibleList;
            xComponentSet->getPropertyValue( PROPERTY_STRINGITEMLIST ) >>= aVisibleList;
            sal_Int32 nStringCnt = aVisibleList.getLength();
            const ::rtl::OUString* pStrings = aVisibleList.getConstArray();

            // Werte-Liste
            Sequence< ::rtl::OUString > aValueList;
            xComponentSet->getPropertyValue( PROPERTY_VALUE_SEQ ) >>= aValueList;
            sal_Int32 nValCnt = aValueList.getLength();
            const ::rtl::OUString* pVals = aValueList.getConstArray();

            // Selektion
            Sequence<sal_Int16> aSelectList;
            xComponentSet->getPropertyValue( PROPERTY_SELECT_SEQ ) >>= aSelectList;
            sal_Int32 nSelCount = aSelectList.getLength();
            const sal_Int16* pSels = aSelectList.getConstArray();

            // Einfach- oder Mehrfach-Selektion
            // Bei Einfach-Selektionen beruecksichtigt MT nur den ersten Eintrag
            // in der Liste.
            if (nSelCount > 1 && !getBOOL(xComponentSet->getPropertyValue(PROPERTY_MULTISELECTION)))
                nSelCount = 1;

            // Die Indizes in der Selektions-Liste koennen auch ungueltig sein,
            // also muss man die gueltigen erstmal raussuchen um die Laenge
            // der neuen Liste zu bestimmen.
            sal_Int32 nCurCnt = 0;
            sal_Int32 i;
            for( i=0; i<nSelCount; ++i )
            {
                if( pSels[i] < nStringCnt )
                    ++nCurCnt;
            }

            ::rtl::OUString aSubValue;
            for(i=0; i<nCurCnt; ++i )
            {
                sal_Int16  nSelPos = pSels[i];
                // Wenn Index in WerteListe, Eintrag aus Werteliste holen
                // ansonsten angezeigten Wert nehmen. Ein
                // LISTBOX_EMPTY_VALUE entspricht einem leeren, aber
                // vorhandenem VALUE des Option-Tags.
                if (nSelPos < nValCnt && pVals[nSelPos].getLength())
                {
                    if( pVals[nSelPos] == LISTBOX_EMPTY_VALUE )
                        aSubValue = ::rtl::OUString();
                    else
                        aSubValue = pVals[nSelPos];
                }
                else
                {
                    aSubValue = pStrings[nSelPos];
                }
                rList.push_back( HtmlSuccessfulObj(aName, aSubValue) );
            }
        } break;
        case FormComponentType::GRIDCONTROL:
        {
            // Die einzelnen Spaltenwerte werden verschickt,
            // der Name wird mit dem Prefix des Names des Grids erweitert
            Reference<XIndexAccess>  xContainer(xComponentSet, UNO_QUERY);
            if (!xContainer.is())
                break;

            aName += UniString('.');

            Reference<XPropertySet>  xSet;
            sal_Int32 nCount = xContainer->getCount();
            for (sal_Int32 i = 0; i < nCount; ++i)
            {
                xContainer->getByIndex(i) >>= xSet;
                if (xSet.is())
                    AppendComponent(rList, xSet, aName, rxSubmitButton, MouseEvt);
            }
        }
    }
}

//------------------------------------------------------------------------
void ODatabaseForm::FillSuccessfulList( HtmlSuccessfulObjList& rList,
    const Reference<XControl>& rxSubmitButton, const MouseEvent& MouseEvt )
{
    // Liste loeschen
    rList.clear();
    // Ueber Components iterieren
    Reference<XPropertySet>         xComponentSet;
    ::rtl::OUString aPrefix;

    for( sal_Int32 nIndex=0; nIndex < getCount(); nIndex++ )
    {
        getByIndex( nIndex ) >>= xComponentSet;
        AppendComponent(rList, xComponentSet, aPrefix, rxSubmitButton, MouseEvt);
    }
}

//------------------------------------------------------------------------
void ODatabaseForm::Encode( ::rtl::OUString& rString ) const
{
    ::rtl::OUString aResult;

    // Immer ANSI #58641
//  rString.Convert(CHARSET_SYSTEM, CHARSET_ANSI);


    // Zeilenendezeichen werden als CR dargestellt
    UniString sConverter = rString;
    sConverter.ConvertLineEnd( LINEEND_CR );
    rString = sConverter;


    // Jeden einzelnen Character ueberpruefen
    sal_Int32 nStrLen = rString.getLength();
    sal_Unicode nCharCode;
    for( sal_Int32 nCurPos=0; nCurPos < nStrLen; ++nCurPos )
    {
        nCharCode = rString[nCurPos];

        // Behandlung fuer chars, die kein alphanumerisches Zeichen sind
        // und CharacterCodes > 127
        if( (!isalnum(nCharCode) && nCharCode != (sal_Unicode)' ') || nCharCode > 127 )
        {
            switch( nCharCode )
            {
                case 13:    // CR
                    aResult += ::rtl::OUString::createFromAscii("%0D%0A");  // Hex-Darstellung CR LF
                    break;


                // Netscape Sonderbehandlung
                case 42:    // '*'
                case 45:    // '-'
                case 46:    // '.'
                case 64:    // '@'
                case 95:    // '_'
                    aResult += UniString(nCharCode);
                    break;

                default:
                {
                    // In Hex umrechnen
                    short nHi = ((sal_Int16)nCharCode) / 16;
                    short nLo = ((sal_Int16)nCharCode) - (nHi*16);
                    if( nHi > 9 ) nHi += (int)'A'-10; else nHi += (int)'0';
                    if( nLo > 9 ) nLo += (int)'A'-10; else nLo += (int)'0';
                    aResult += UniString('%');
                    aResult += UniString((sal_Unicode)nHi);
                    aResult += UniString((sal_Unicode)nLo);
                }
            }
        }
        else
            aResult += UniString(nCharCode);
    }


    // Spaces durch '+' ersetzen
    aResult = aResult.replace(' ', '+');

    rString = aResult;
}

//------------------------------------------------------------------------
void ODatabaseForm::InsertTextPart( INetMIMEMessage& rParent, const ::rtl::OUString& rName,
    const ::rtl::OUString& rData )
{

    // Part als Message-Child erzeugen
    INetMIMEMessage* pChild = new INetMIMEMessage();


    // Header
    ::rtl::OUString aContentDisp = ::rtl::OUString::createFromAscii("form-data; name=\"");
    aContentDisp += rName;
    aContentDisp += UniString('\"');
    pChild->SetContentDisposition( aContentDisp );
    pChild->SetContentType( UniString::CreateFromAscii("text/plain") );

    rtl_TextEncoding eSystemEncoding = gsl_getSystemTextEncoding();
    const sal_Char* pBestMatchingEncoding = rtl_getBestMimeCharsetFromTextEncoding( eSystemEncoding );
    UniString aBestMatchingEncoding = UniString::CreateFromAscii( pBestMatchingEncoding );
    pChild->SetContentTransferEncoding(aBestMatchingEncoding);

    // Body
    SvMemoryStream* pStream = new SvMemoryStream;
    pStream->WriteLine( ByteString( UniString(rData), rtl_getTextEncodingFromMimeCharset(pBestMatchingEncoding) ) );
    pStream->Flush();
    pStream->Seek( 0 );
    pChild->SetDocumentLB( new SvLockBytes(pStream, sal_True) );
    rParent.AttachChild( *pChild );
}

//------------------------------------------------------------------------
sal_Bool ODatabaseForm::InsertFilePart( INetMIMEMessage& rParent, const ::rtl::OUString& rName,
    const ::rtl::OUString& rFileName )
{
    UniString aFileName( rFileName );
    UniString aContentType(UniString::CreateFromAscii(CONTENT_TYPE_STR_TEXT_PLAIN));
    SvStream *pStream = 0;

    if( aFileName.Len() )
    {
        // Bisher koennen wir nur File-URLs verarbeiten
        INetURLObject aURL;
        aURL.SetSmartProtocol(INET_PROT_FILE);
        aURL.SetSmartURL(rFileName);
        if( INET_PROT_FILE == aURL.GetProtocol() )
        {
            aFileName = INetURLObject::decode(aURL.PathToFileName(), '%', INetURLObject::DECODE_UNAMBIGUOUS);
            DirEntry aDirEntry( aFileName );
            if( aDirEntry.Exists() )
            {
                pStream = ::utl::UcbStreamHelper::CreateStream(aFileName, STREAM_READ);
                if (!pStream || (pStream->GetError() != ERRCODE_NONE))
                {
                    delete pStream;
                    pStream = 0;
                }
            }
            INetContentType eContentType = INetContentTypes::GetContentType4Extension(
                                                                aDirEntry.GetExtension() );
            if (eContentType != CONTENT_TYPE_UNKNOWN)
                aContentType = INetContentTypes::GetContentType(eContentType);
        }
    }

    // Wenn irgendetwas nicht geklappt hat, legen wir einen leeren
    // MemoryStream an
    if( !pStream )
        pStream = new SvMemoryStream;


    // Part als Message-Child erzeugen
    INetMIMEMessage* pChild = new INetMIMEMessage;


    // Header
    ::rtl::OUString aContentDisp = ::rtl::OUString::createFromAscii( "form-data; name=\"" );
    aContentDisp += rName;
    aContentDisp += UniString('\"');
    aContentDisp += ::rtl::OUString::createFromAscii("; filename=\"");
    aContentDisp += aFileName;
    aContentDisp += UniString('\"');
    pChild->SetContentDisposition( aContentDisp );
    pChild->SetContentType( aContentType );
    pChild->SetContentTransferEncoding( UniString(::rtl::OUString::createFromAscii("8bit")) );


    // Body
    pChild->SetDocumentLB( new SvLockBytes(pStream, sal_True) );
    rParent.AttachChild( *pChild );

    return sal_True;
}

//==============================================================================
// internals
//------------------------------------------------------------------------------
void ODatabaseForm::onError(const SQLErrorEvent& _rEvent)
{
    NOTIFY_LISTENERS(m_aErrorListeners, XSQLErrorListener, errorOccured, _rEvent);
}

//------------------------------------------------------------------------------
void ODatabaseForm::onError(SQLException& _rException, const ::rtl::OUString& _rContextDescription)
{
    if (!m_aErrorListeners.getLength())
        return;

    SQLContext aError = prependContextInfo(_rException, static_cast<XWeak*>(this), _rContextDescription);
    SQLErrorEvent aEvent(static_cast<XWeak*>(this), makeAny(aError));

    onError(aEvent);
}

//------------------------------------------------------------------------------
void ODatabaseForm::createParameterInfo()
{
    DELETEZ( m_pParameterInfo );
    m_pParameterInfo = new OParameterInfoImpl;

    // create and fill a composer
    Reference<XSQLQueryComposer>  xComposer = getCurrentSettingsComposer(m_xAggregateSet, m_xServiceFactory);
    Reference<XParametersSupplier>  xSetParameters = Reference<XParametersSupplier> (xComposer, UNO_QUERY);

    // if there is no parsable statement return
    if (!xSetParameters.is())
        return;

    Reference<XIndexAccess>  xParamsAsIndicies = xSetParameters->getParameters();
    Reference<XNameAccess>   xParamsAsNames(xParamsAsIndicies, UNO_QUERY);
    sal_Int32 nParamCount = xParamsAsIndicies.is() ? xParamsAsIndicies->getCount() : 0;
    // without parameters return
    if (!xParamsAsNames.is() || (nParamCount == 0))
        return;

    // now evaluate the parameters
    m_pParameterInfo->nCount = nParamCount;
    m_pParameterInfo->xParamsAsNames = xParamsAsNames;
    m_pParameterInfo->pParameters = new OParametersImpl();
    m_pParameterInfo->pParameters->acquire();
    OParametersImpl::Parameters& rParams = m_pParameterInfo->pParameters->getParameters();

    // we need to map the parameter names (which is all we can get from our parent) to indicies (which are
    // needed by the XParameters interface of the row set)
    MapUString2INT32& rParamMapping = m_pParameterInfo->aParamMapping;
    Reference<XPropertySet> xParam;
    for (sal_Int32 i = 0; i<nParamCount; ++i)
    {
        ::cppu::extractInterface(xParam, xParamsAsIndicies->getByIndex(i));

        // remember the param fields
        rParams.push_back(xParam);
        ::rtl::OUString sName;
        xParam->getPropertyValue(PROPERTY_NAME) >>= sName;
        rParamMapping[sName] = i;
    }

    // check for a matching of my param master fields with the parent's columns
    Reference<XColumnsSupplier>  xParentColsSuppl(m_xParent, UNO_QUERY);
    if (xParentColsSuppl.is())
    {
        Reference<XNameAccess>  xParentCols = xParentColsSuppl->getColumns();
        if (xParentCols.is())
        {
            sal_Int32 nMasterLen = m_aMasterFields.getLength();
            sal_Int32 nSlaveLen = m_aDetailFields.getLength();
            if (xParentCols->hasElements() && (nMasterLen == nSlaveLen) && (nMasterLen > 0))
            {
                const ::rtl::OUString* pMasterFields = m_aMasterFields.getConstArray();
                const ::rtl::OUString* pDetailFields = m_aDetailFields.getConstArray();

                OParametersImpl::ParametersIterator iter;
                for (sal_Int32 i = 0; i < nMasterLen; ++i, ++pMasterFields, ++pDetailFields)
                {
                    Reference<XPropertySet>  xMasterField, xDetailField;

                    if (xParentCols->hasByName(*pMasterFields) &&
                        xParamsAsNames->hasByName(*pDetailFields))
                    {
                        // parameter defined by master slave definition
                        ::cppu::extractInterface(xDetailField, xParamsAsNames->getByName(*pDetailFields));

                        DBG_ASSERT(rParamMapping.find(*pDetailFields) != rParamMapping.end(), "ODatabaseForm::createParameterInfo: invalid XParametersSupplier !");
                            // the mapping was build from the XParametersSupplier interface of the composer, and the
                            // XNameAccess interface of the composer said hasByName(...)==sal_True ... so what ?

                        // delete the wrapper as the parameter is set
                        iter = find(rParams.begin(), rParams.end(), xDetailField);
                        DBG_ASSERT(iter != rParams.end(), "ODatabaseForm::createParameterInfo: Parameter not found");
                        if (iter != rParams.end())
                            rParams.erase(iter);
                    }
                }
            }
        }
    }

    // now set the remaining params
    sal_Int32 nParamsLeft = rParams.size();
    if (nParamsLeft)
    {
        Reference<XParameters>  xExecutionParams(m_xAggregate, UNO_QUERY);
        ::rtl::OUString sName;
        Reference<XPropertySet>  xParam;
        Reference<XPropertySet>  xWrapper;
        for (sal_Int32 j = nParamsLeft; j; )
        {
            --j;
            xParam = rParams[j];
            xParam->getPropertyValue(PROPERTY_NAME) >>= sName;
            // need a wrapper for this .... the params supplied by xMyParamsAsIndicies don't have a "Value"
            // property, but the parameter listeners expect such a property. So we need an object "aggregating"
            // xParam and supplying an additional property ("Value")
            // (it's no real aggregation of course ...)

            // get the position of the parameter
            sal_Int32 nPos = rParamMapping[sName];
            if ((sal_Int32)m_aParameterVisited.size() > nPos && m_aParameterVisited[nPos] == true)
            {
                // parameter already set from outside
                OParametersImpl::ParametersIterator aPos = rParams.begin() + j;
                if (aPos != rParams.end())
                    rParams.erase(aPos);
            }
            else
            {
                xWrapper = new OParameterWrapper(xParam, xExecutionParams, rParamMapping[sName]);
                rParams[j] = xWrapper;
            }
        }
    }
}

//------------------------------------------------------------------------------
bool ODatabaseForm::hasValidParent() const
{
    // do we have to fill the parameters again?
    if (m_bSubForm)
    {
        Reference<XResultSet>  xResultSet(m_xParent, UNO_QUERY);
        if (!xResultSet.is())
        {
            DBG_ERROR("ODatabaseForm::hasValidParent() : no parent resultset !");
            return false;
        }
        try
        {
            Reference<XPropertySet>  xSet(m_xParent, UNO_QUERY);
            // only if the parent has a command we have to check if the parent is positioned on a valid row
            if (getString(xSet->getPropertyValue(PROPERTY_COMMAND)).getLength() &&
                (xResultSet->isBeforeFirst() || xResultSet->isAfterLast() ||
                 getBOOL(xSet->getPropertyValue(PROPERTY_ISNEW))))
                return false;
        }
        catch(Exception&)
        {
            // parent could be forwardonly?
            return false;
        }
    }
    return true;
}

//------------------------------------------------------------------------------
bool ODatabaseForm::fillParameters(ReusableMutexGuard& _rClearForNotifies, const Reference< XInteractionHandler >& _rxCompletionHandler)
{
    Reference<XParameters>  xExecutionParams;
    if (!query_aggregation( m_xAggregate, xExecutionParams))
    {
        DBG_ERROR("ODatabaseForm::fillParameters : invalid row set (doesn't support parameters) !");
        // normally the row set should support parameters ...
        return true;
    }

    // do we have to fill the parameters again?
    if ( !m_pParameterInfo )
        createParameterInfo();

    if (!m_pParameterInfo || m_pParameterInfo->nCount == 0)
        return true;

    // is there a valid parent?
    if (m_bSubForm && !hasValidParent())
        return true;

    // do we have to fill the parent parameters?
    OParametersImpl::Parameters& rParams = m_pParameterInfo->pParameters->getParameters();

    // do we have to fill the parent parameters?
    if (m_pParameterInfo->nCount > (sal_Int32)rParams.size())
    {
        Reference<XColumnsSupplier>  xParentColsSuppl(m_xParent, UNO_QUERY);
        if (xParentColsSuppl.is())
        {
            Reference<XNameAccess>  xParentCols = xParentColsSuppl->getColumns();
            sal_Int32 nMasterLen = m_aMasterFields.getLength();
            if (xParentCols->hasElements() && (nMasterLen > 0))
            {
                const ::rtl::OUString* pMasterFields = m_aMasterFields.getConstArray();
                const ::rtl::OUString* pDetailFields = m_aDetailFields.getConstArray();

                Any aParamType,aScale,aValue;
                for (sal_Int32 i = 0; i < nMasterLen; ++i, ++pMasterFields, ++pDetailFields)
                {
                    Reference<XPropertySet>  xMasterField, xDetailField;
                    if (xParentCols->hasByName(*pMasterFields) &&
                        m_pParameterInfo->xParamsAsNames->hasByName(*pDetailFields))
                    {
                        // parameter defined by master slave definition
                        ::cppu::extractInterface(xMasterField, xParentCols->getByName(*pMasterFields));
                        ::cppu::extractInterface(xDetailField, m_pParameterInfo->xParamsAsNames->getByName(*pDetailFields));

                        // get the type of the param
                        aParamType = xDetailField->getPropertyValue(PROPERTY_FIELDTYPE);
                        DBG_ASSERT(aParamType.getValueType().getTypeClass() == TypeClass_LONG, "ODatabaseForm::fillParameters : invalid parameter field !");
                        sal_Int32 nScale = 0;
                        if (hasProperty(PROPERTY_SCALE, xDetailField))
                        {
                            aScale = xDetailField->getPropertyValue(PROPERTY_SCALE);
                            DBG_ASSERT(aScale.getValueType().getTypeClass() == TypeClass_LONG, "ODatabaseForm::fillParameters : invalid parameter field !");
                            nScale = getINT32(aScale);
                        }
                        // and fill the param value
                        aValue = xMasterField->getPropertyValue(PROPERTY_VALUE);
                        // parameters are based at 1
                        xExecutionParams->setObjectWithInfo(m_pParameterInfo->aParamMapping[*pDetailFields] + 1, aValue, getINT32(aParamType), nScale);
                    }
                    else
                        // no column matching so leave the parameter setting
                        return true;
                }
            }
        }
    }

    // now fill the remaining params
    bool bCanceled = false;
    if (_rxCompletionHandler.is())
    {
        // ask the handler for the missing parameters

        // ensure we're connected
        if (!implEnsureConnection())
            return sal_False;

        // two continuations (Ok and Cancel)
        OInteractionAbort* pAbort = new OInteractionAbort;
        OParameterContinuation* pParams = new OParameterContinuation;

        // the request
        ParametersRequest aRequest;
        aRequest.Parameters = m_pParameterInfo->pParameters;
        aRequest.Connection = getConnection();
        OInteractionRequest* pRequest = new OInteractionRequest(makeAny(aRequest));
        Reference< XInteractionRequest > xRequest(pRequest);

        // some knittings
        pRequest->addContinuation(pAbort);
        pRequest->addContinuation(pParams);

        // execute the request
        _rxCompletionHandler->handle(xRequest);

        if (!pParams->wasSelected())
            // canceled by the user (i.e. (s)he canceled the dialog)
            return sal_False;

        // transfer the values from the continuation object to the parameter columns
        Sequence< PropertyValue > aFinalValues = pParams->getValues();
        const PropertyValue* pFinalValues = aFinalValues.getConstArray();
        for (sal_Int32 i=0; i<aFinalValues.getLength(); ++i, ++pFinalValues)
        {
            Reference< XPropertySet > xParamColumn;
            ::cppu::extractInterface(xParamColumn, aRequest.Parameters->getByIndex(i));
            if (xParamColumn.is())
            {
#ifdef DBG_UTIL
                ::rtl::OUString sName;
                xParamColumn->getPropertyValue(PROPERTY_NAME) >>= sName;
                DBG_ASSERT(sName.equals(pFinalValues->Name), "ODatabaseForm::fillParameters: inconsistent parameter names!");
#endif
                xParamColumn->setPropertyValue(PROPERTY_VALUE, pFinalValues->Value);
                    // the property sets are wrapper classes, translating the Value property into a call to
                    // the appropriate XParameters interface
            }
        }
    }
    else
    {
        sal_Int32 nParamsLeft = rParams.size();
        if (nParamsLeft)
        {
            ::cppu::OInterfaceIteratorHelper aIter(m_aParameterListeners);
            DatabaseParameterEvent aEvt(static_cast<XWeak*>(this), m_pParameterInfo->pParameters);

            _rClearForNotifies.clear();
            while (aIter.hasMoreElements() && !bCanceled)
                bCanceled = !((XDatabaseParameterListener*)aIter.next())->approveParameter(aEvt);
            _rClearForNotifies.attach(m_aMutex);
        }
    }
    return !bCanceled;
}

//------------------------------------------------------------------------------
sal_Bool ODatabaseForm::executeRowSet(ReusableMutexGuard& _rClearForNotifies, sal_Bool bMoveToFirst, const Reference< XInteractionHandler >& _rxCompletionHandler)
{
    if (!m_xAggregateAsRowSet.is())
        return sal_False;

    if (!fillParameters(_rClearForNotifies, _rxCompletionHandler))
        return sal_False;
    sal_Bool bInsertOnly = sal_False;

    // ensure the aggregated row set has the correct properties
    sal_Int32 nConcurrency;
    // if we have a parent, who is not positioned on a valid row
    // we can't be updatable!
    if (m_bSubForm && !hasValidParent())
    {
        // don't use any parameters if we don't have a valid parent
        nConcurrency = ResultSetConcurrency::READ_ONLY;
        //  clearParameters();
        if(m_pParameterInfo && m_pParameterInfo->nCount > 0)
        {
            Reference<XParameters>  xExecutionParams;
            query_aggregation( m_xAggregate, xExecutionParams); // we don't have to look if this work otherwise previous calls don't work
            for (sal_Int32 nPos=1;nPos <= m_pParameterInfo->nCount; ++nPos)
                xExecutionParams->setNull(nPos,DataType::VARCHAR);

            m_aIgnoreResult = m_xAggregateSet->getPropertyValue(PROPERTY_INSERTONLY);
            m_xAggregateSet->setPropertyValue(PROPERTY_INSERTONLY,makeAny(sal_True));
        }
    }
    else if (m_bAllowInsert || m_bAllowUpdate || m_bAllowDelete)
        nConcurrency = ResultSetConcurrency::UPDATABLE;
    else
        nConcurrency = ResultSetConcurrency::READ_ONLY;

    if (m_bSubForm && hasValidParent() && m_aIgnoreResult.hasValue() && m_pParameterInfo && m_pParameterInfo->nCount > 0)
    {
        m_xAggregateSet->setPropertyValue(PROPERTY_INSERTONLY,m_aIgnoreResult);
        m_aIgnoreResult = Any();
    }

    m_xAggregateSet->setPropertyValue(PROPERTY_RESULTSET_CONCURRENCY, makeAny(nConcurrency));

    sal_Int32 nResultSetType = ResultSetType::SCROLL_SENSITIVE;
    m_xAggregateSet->setPropertyValue(PROPERTY_RESULTSET_TYPE, makeAny(nResultSetType));

    sal_Bool bSuccess = sal_False;
    try
    {
        m_xAggregateAsRowSet->execute();
        bSuccess = sal_True;
    }
    catch(RowSetVetoException& eVeto)
    {
        eVeto;
    }
    catch(SQLException& eDb)
    {
        _rClearForNotifies.clear();
        if (m_sCurrentErrorContext.getLength())
            onError(eDb, m_sCurrentErrorContext);
        else
            onError(eDb, FRM_RES_STRING(RID_STR_READERROR));
        _rClearForNotifies.attach(m_aMutex);
    }

    if (bSuccess)
    {
        // adjust the privilege property
        //  m_nPrivileges;
        m_xAggregateSet->getPropertyValue(PROPERTY_PRIVILEGES) >>= m_nPrivileges;
        if (!m_bAllowInsert)
            m_nPrivileges &= ~Privilege::INSERT;
        if (!m_bAllowUpdate)
            m_nPrivileges &= ~Privilege::UPDATE;
        if (!m_bAllowDelete)
            m_nPrivileges &= ~Privilege::DELETE;

        if (bMoveToFirst)
        {
            // the row set is positioned _before_ the first row (per definitionem), so move the set ...
            try
            {
                // if we have an insert only rowset we move to the insert row
                next();
                if (((m_nPrivileges & Privilege::INSERT) == Privilege::INSERT)
                    && isAfterLast())
                {
                    // move on the insert row of set
                    // resetting must be done later, after the load events have been posted
                    // see :moveToInsertRow and load , reload
                    Reference<XResultSetUpdate>  xUpdate;
                    if (query_aggregation( m_xAggregate, xUpdate))
                        xUpdate->moveToInsertRow();
                }
            }
            catch(SQLException& eDB)
            {
                _rClearForNotifies.clear();
                if (m_sCurrentErrorContext.getLength())
                    onError(eDB, m_sCurrentErrorContext);
                else
                    onError(eDB, FRM_RES_STRING(RID_STR_READERROR));
                _rClearForNotifies.attach(m_aMutex);
                bSuccess = sal_False;
            }
        }
    }
    return bSuccess;
}

//------------------------------------------------------------------
void ODatabaseForm::disposing()
{
    if (m_pAggregatePropertyMultiplexer)
        m_pAggregatePropertyMultiplexer->dispose();

    if (m_bLoaded)
        unload();

    // cancel the submit/reset-thread
    {
        ::osl::MutexGuard aGuard( m_aMutex );
        if (m_pThread)
        {
            m_pThread->release();
            m_pThread = NULL;
        }
    }

    EventObject aEvt(static_cast<XWeak*>(this));
    m_aLoadListeners.disposeAndClear(aEvt);
    m_aRowSetApproveListeners.disposeAndClear(aEvt);
    m_aParameterListeners.disposeAndClear(aEvt);
    m_aResetListeners.disposeAndClear(aEvt);
    m_aSubmitListeners.disposeAndClear(aEvt);
    m_aErrorListeners.disposeAndClear(aEvt);

    OFormComponents::disposing();
    OPropertySetAggregationHelper::disposing();

    // stop listening on the aggregate
    if (m_xAggregateAsRowSet.is())
        m_xAggregateAsRowSet->removeRowSetListener(this);

    // dispose the active connection
    Reference<XComponent>  xAggregationComponent;
    if (query_aggregation(m_xAggregate, xAggregationComponent))
        xAggregationComponent->dispose();
}

//------------------------------------------------------------------------------
Reference< XConnection >  ODatabaseForm::getConnection()
{
    Reference< XConnection > xConn;
    m_xAggregateSet->getPropertyValue( PROPERTY_ACTIVE_CONNECTION ) >>= xConn;
    return xConn;
}

//==============================================================================
// property handling
//------------------------------------------------------------------------------
void ODatabaseForm::fillProperties(
        Sequence< Property >& _rProps,
        Sequence< Property >& _rAggregateProps ) const
{
    BEGIN_AGGREGATION_PROPERTY_HELPER(15, m_xAggregateSet)
        // this property is overwritten by the form
        RemoveProperty(_rAggregateProps, PROPERTY_PRIVILEGES);
        RemoveProperty(_rAggregateProps, PROPERTY_DATASOURCE);
        RemoveProperty(_rAggregateProps, PROPERTY_ACTIVE_CONNECTION);
            // we remove and re-declare the DataSourceName property, 'cause we want it to be constrained, and the
            // original property of our aggregate isn't

        DECL_IFACE_PROP3(ACTIVE_CONNECTION,         XConnection,    BOUND, TRANSIENT, MAYBEVOID);
        DECL_PROP1(NAME,            ::rtl::OUString,                BOUND);
        DECL_PROP1(MASTERFIELDS,    StringSequence,                 BOUND);
        DECL_PROP1(DETAILFIELDS,    StringSequence,                 BOUND);
        DECL_PROP2(DATASOURCE,      ::rtl::OUString,                BOUND, CONSTRAINED);
        DECL_PROP3(CYCLE,           TabulatorCycle,                 BOUND, MAYBEVOID, MAYBEDEFAULT);
        DECL_PROP1(NAVIGATION,      NavigationBarMode,              BOUND);
        DECL_BOOL_PROP1(ALLOWADDITIONS,                             BOUND);
        DECL_BOOL_PROP1(ALLOWEDITS,                                 BOUND);
        DECL_BOOL_PROP1(ALLOWDELETIONS,                             BOUND);
        DECL_PROP2(PRIVILEGES,      sal_Int32,                      TRANSIENT, READONLY);
        DECL_PROP1(TARGET_URL,      ::rtl::OUString,                BOUND);
        DECL_PROP1(TARGET_FRAME,    ::rtl::OUString,                BOUND);
        DECL_PROP1(SUBMIT_METHOD,   FormSubmitMethod,       BOUND);
        DECL_PROP1(SUBMIT_ENCODING, FormSubmitEncoding, BOUND);
    END_AGGREGATION_PROPERTY_HELPER();
}

//------------------------------------------------------------------------------
::cppu::IPropertyArrayHelper& ODatabaseForm::getInfoHelper()
{
    return *const_cast<ODatabaseForm*>(this)->getArrayHelper();
}

//------------------------------------------------------------------------------
Reference<XPropertySetInfo>  ODatabaseForm::getPropertySetInfo() throw( RuntimeException )
{
    Reference<XPropertySetInfo>  xDescriptorInfo( createPropertySetInfo( getInfoHelper() ) );
    return xDescriptorInfo;
}

//------------------------------------------------------------------------------
void ODatabaseForm::fire( sal_Int32* pnHandles, const Any* pNewValues, const Any* pOldValues, sal_Int32 nCount, sal_Bool bVetoable )
{
    // same as in getFastPropertyValue(INT32) : if we're resetting currently don't fire any changes of the
    // IsModified property from FALSE to TRUE, as this is only temporary 'til the reset is done
    if (m_nResetsPending > 0)
    {
        // look for the PROPERTY_ID_ISMODIFIED
        sal_Int32 nPos = 0;
        for (nPos=0; nPos<nCount; ++nPos)
            if (pnHandles[nPos] == PROPERTY_ID_ISMODIFIED)
                break;

        if ((nPos < nCount) && (pNewValues[nPos].getValueType().getTypeClass() == TypeClass_BOOLEAN) && getBOOL(pNewValues[nPos]))
        {   // yeah, we found it, and it changed to TRUE
            if (nPos == 0)
            {   // just cut the first element
                ++pnHandles;
                ++pNewValues;
                ++pOldValues;
                --nCount;
            }
            else if (nPos == nCount - 1)
                // just cut the last element
                --nCount;
            else
            {   // split into two base class calls
                OPropertySetAggregationHelper::fire(pnHandles, pNewValues, pOldValues, nPos, bVetoable);
                ++nPos;
                OPropertySetAggregationHelper::fire(pnHandles + nPos, pNewValues + nPos, pOldValues + nPos, nCount - nPos, bVetoable);
                return;
            }
        }
    }

    OPropertySetAggregationHelper::fire(pnHandles, pNewValues, pOldValues, nCount, bVetoable);
}

//------------------------------------------------------------------------------
Any SAL_CALL ODatabaseForm::getFastPropertyValue( sal_Int32 nHandle )
       throw(UnknownPropertyException, WrappedTargetException, RuntimeException)
{
    if ((nHandle == PROPERTY_ID_ISMODIFIED) && (m_nResetsPending > 0))
        return ::cppu::bool2any((sal_False));
        // don't allow the aggregate which is currently reset to return a (temporary) "yes"
    else
        return OPropertySetAggregationHelper::getFastPropertyValue(nHandle);
}

//------------------------------------------------------------------------------
void ODatabaseForm::getFastPropertyValue( Any& rValue, sal_Int32 nHandle ) const
{
    switch (nHandle)
    {
        case PROPERTY_ID_DATASOURCE:
        {
            rValue = makeAny(::rtl::OUString());
            try
            {
                rValue = m_xAggregateSet->getPropertyValue(PROPERTY_DATASOURCE);
            }
            catch(Exception&) { }
        }
        break;
        case PROPERTY_ID_ACTIVE_CONNECTION:
        {
            try
            {
                rValue = m_xAggregateSet->getPropertyValue(PROPERTY_ACTIVE_CONNECTION);
            }
            catch(Exception&) { }
        }
        break;
        case PROPERTY_ID_TARGET_URL:
            rValue <<= m_aTargetURL;
            break;
        case PROPERTY_ID_TARGET_FRAME:
            rValue <<= m_aTargetFrame;
            break;
        case PROPERTY_ID_SUBMIT_METHOD:
            rValue <<= m_eSubmitMethod;
            break;
        case PROPERTY_ID_SUBMIT_ENCODING:
            rValue <<= m_eSubmitEncoding;
            break;
        case PROPERTY_ID_NAME:
            rValue <<= m_sName;
            break;
        case PROPERTY_ID_MASTERFIELDS:
            rValue <<= m_aMasterFields;
            break;
        case PROPERTY_ID_DETAILFIELDS:
            rValue <<= m_aDetailFields;
            break;
        case PROPERTY_ID_CYCLE:
            rValue = m_aCycle;
            break;
        case PROPERTY_ID_NAVIGATION:
            rValue <<= m_eNavigation;
            break;
        case PROPERTY_ID_ALLOWADDITIONS:
            rValue <<= (sal_Bool)m_bAllowInsert;
            break;
        case PROPERTY_ID_ALLOWEDITS:
            rValue <<= (sal_Bool)m_bAllowUpdate;
            break;
        case PROPERTY_ID_ALLOWDELETIONS:
            rValue <<= (sal_Bool)m_bAllowDelete;
            break;
        case PROPERTY_ID_PRIVILEGES:
            rValue <<= (sal_Int32)m_nPrivileges;
            break;
    }
}

//------------------------------------------------------------------------------
sal_Bool ODatabaseForm::convertFastPropertyValue( Any& rConvertedValue, Any& rOldValue,
                                                sal_Int32 nHandle, const Any& rValue ) throw( IllegalArgumentException )
{
    sal_Bool bModified(sal_False);
    switch (nHandle)
    {
        case PROPERTY_ID_DATASOURCE:
        {
            Any aAggregateProperty;
            getFastPropertyValue(aAggregateProperty, PROPERTY_ID_DATASOURCE);
            bModified = tryPropertyValue(rConvertedValue, rOldValue, rValue, aAggregateProperty, ::getCppuType(static_cast<const ::rtl::OUString*>(NULL)));
        }
        break;
        case PROPERTY_ID_ACTIVE_CONNECTION:
        {
            Any aAggregateProperty;
            getFastPropertyValue(aAggregateProperty, PROPERTY_ID_ACTIVE_CONNECTION);
            bModified = tryPropertyValue(rConvertedValue, rOldValue, rValue, aAggregateProperty, ::getCppuType(static_cast<const Reference<XConnection>*>(NULL)));
        }
        break;
        case PROPERTY_ID_TARGET_URL:
            bModified = tryPropertyValue(rConvertedValue, rOldValue, rValue, m_aTargetURL);
            break;
        case PROPERTY_ID_TARGET_FRAME:
            bModified = tryPropertyValue(rConvertedValue, rOldValue, rValue, m_aTargetFrame);
            break;
        case PROPERTY_ID_SUBMIT_METHOD:
            bModified = tryPropertyValue(rConvertedValue, rOldValue, rValue, m_eSubmitMethod);
            break;
        case PROPERTY_ID_SUBMIT_ENCODING:
            bModified = tryPropertyValue(rConvertedValue, rOldValue, rValue, m_eSubmitEncoding);
            break;
        case PROPERTY_ID_NAME:
            bModified = tryPropertyValue(rConvertedValue, rOldValue, rValue, m_sName);
            break;
        case PROPERTY_ID_MASTERFIELDS:
            bModified = tryPropertyValue(rConvertedValue, rOldValue, rValue, m_aMasterFields);
            break;
        case PROPERTY_ID_DETAILFIELDS:
            bModified = tryPropertyValue(rConvertedValue, rOldValue, rValue, m_aDetailFields);
            break;
        case PROPERTY_ID_CYCLE:
            bModified = tryPropertyValue(rConvertedValue, rOldValue, rValue, m_aCycle, ::getCppuType(static_cast<const TabulatorCycle*>(NULL)));
            break;
        case PROPERTY_ID_NAVIGATION:
            bModified = tryPropertyValue(rConvertedValue, rOldValue, rValue, m_eNavigation);
            break;
        case PROPERTY_ID_ALLOWADDITIONS:
            bModified = tryPropertyValue(rConvertedValue, rOldValue, rValue, m_bAllowInsert);
            break;
        case PROPERTY_ID_ALLOWEDITS:
            bModified = tryPropertyValue(rConvertedValue, rOldValue, rValue, m_bAllowUpdate);
            break;
        case PROPERTY_ID_ALLOWDELETIONS:
            bModified = tryPropertyValue(rConvertedValue, rOldValue, rValue, m_bAllowDelete);
            break;
        default:
            DBG_ERROR("ODatabaseForm::convertFastPropertyValue : unknown property !");
    }
    return bModified;
}

//------------------------------------------------------------------------------
void ODatabaseForm::setFastPropertyValue_NoBroadcast( sal_Int32 nHandle, const Any& rValue ) throw( Exception )
{
    switch (nHandle)
    {
        case PROPERTY_ID_DATASOURCE:
            try
            {
                m_xAggregateSet->setPropertyValue(PROPERTY_DATASOURCE, rValue);
            }
            catch(Exception&) { }
            break;
        case PROPERTY_ID_ACTIVE_CONNECTION:
            try
            {
                if ( m_bSharingConnection )
                    stopSharingConnection( );

                m_bForwardingConnection = sal_True;
                m_xAggregateSet->setPropertyValue(PROPERTY_ACTIVE_CONNECTION, rValue);
                m_bForwardingConnection = sal_False;
            }
            catch(Exception&) { }
            break;
        case PROPERTY_ID_TARGET_URL:
            rValue >>= m_aTargetURL;
            break;
        case PROPERTY_ID_TARGET_FRAME:
            rValue >>= m_aTargetFrame;
            break;
        case PROPERTY_ID_SUBMIT_METHOD:
            rValue >>= m_eSubmitMethod;
            break;
        case PROPERTY_ID_SUBMIT_ENCODING:
            rValue >>= m_eSubmitEncoding;
            break;
        case PROPERTY_ID_NAME:
            rValue >>= m_sName;
            break;
        case PROPERTY_ID_MASTERFIELDS:
            rValue >>= m_aMasterFields;
            invlidateParameters();
            break;
        case PROPERTY_ID_DETAILFIELDS:
            rValue >>= m_aDetailFields;
            invlidateParameters();
            break;
        case PROPERTY_ID_CYCLE:
            m_aCycle = rValue;
            break;
        case PROPERTY_ID_NAVIGATION:
            rValue >>= m_eNavigation;
            break;
        case PROPERTY_ID_ALLOWADDITIONS:
            m_bAllowInsert = getBOOL(rValue);
            break;
        case PROPERTY_ID_ALLOWEDITS:
            m_bAllowUpdate = getBOOL(rValue);
            break;
        case PROPERTY_ID_ALLOWDELETIONS:
            m_bAllowDelete = getBOOL(rValue);
            break;
        default:
            DBG_ERROR("ODatabaseForm::setFastPropertyValue_NoBroadcast : unknown property !");
    }
}

//==============================================================================
// com::sun::star::beans::XPropertyState
//------------------------------------------------------------------
PropertyState ODatabaseForm::getPropertyStateByHandle(sal_Int32 nHandle)
{
    PropertyState eState;
    switch (nHandle)
    {
        case PROPERTY_ID_NAVIGATION:
            return (NavigationBarMode_CURRENT == m_eNavigation) ? PropertyState_DEFAULT_VALUE : PropertyState_DIRECT_VALUE;
            break;
        case PROPERTY_ID_CYCLE:
            if (!m_aCycle.hasValue())
                eState = PropertyState_DEFAULT_VALUE;
            else
                eState = PropertyState_DIRECT_VALUE;
            break;
        default:
            eState = OPropertySetAggregationHelper::getPropertyStateByHandle(nHandle);
    }
    return eState;
}

//------------------------------------------------------------------
void ODatabaseForm::setPropertyToDefaultByHandle(sal_Int32 nHandle)
{
    switch (nHandle)
    {
        case PROPERTY_ID_NAVIGATION:
            setFastPropertyValue(nHandle, makeAny(NavigationBarMode_CURRENT));
            break;
        case PROPERTY_ID_CYCLE:
            setFastPropertyValue(nHandle, Any());
            break;
        default:
            OPropertySetAggregationHelper::setPropertyToDefaultByHandle(nHandle);
    }
}

//------------------------------------------------------------------
Any ODatabaseForm::getPropertyDefaultByHandle( sal_Int32 nHandle ) const
{
    switch (nHandle)
    {
        case PROPERTY_ID_NAVIGATION:
            return makeAny(NavigationBarMode_CURRENT);
            break;
        case PROPERTY_ID_CYCLE:
            return Any();
        default:
            return OPropertySetAggregationHelper::getPropertyDefaultByHandle(nHandle);
    }
}

//==============================================================================
// com::sun::star::form::XReset
//------------------------------------------------------------------------------
void SAL_CALL ODatabaseForm::reset() throw( RuntimeException )
{
    ReusableMutexGuard aGuard(m_aMutex);

    if (isLoaded())
    {
        ::osl::MutexGuard aResetGuard(m_aResetSafety);
        ++m_nResetsPending;
        reset_impl(true);
        return;
    }

    if (m_aResetListeners.getLength())
    {
        ::osl::MutexGuard aResetGuard(m_aResetSafety);
        ++m_nResetsPending;
        // create an own thread if we have (approve-)reset-listeners (so the listeners can't do that much damage
        // to this thread which is probably the main one)
        if (!m_pThread)
        {
            m_pThread = new OFormSubmitResetThread(this);
            m_pThread->acquire();
            m_pThread->create();
        }
        EventObject aEvt;
        m_pThread->addEvent(&aEvt, sal_False);
    }
    else
    {
        // direct call without any approving by the listeners
        aGuard.clear();

        ::osl::MutexGuard aResetGuard(m_aResetSafety);
        ++m_nResetsPending;
        reset_impl(false);
    }
}

//-----------------------------------------------------------------------------
void ODatabaseForm::reset_impl(bool _bAproveByListeners)
{
    if (_bAproveByListeners)
    {
        bool bCanceled = false;
        ::cppu::OInterfaceIteratorHelper aIter(m_aResetListeners);
        EventObject aEvt(static_cast<XWeak*>(this));

        while (aIter.hasMoreElements() && !bCanceled)
            if (!((XResetListener*)aIter.next())->approveReset(aEvt))
                bCanceled = true;
        if (bCanceled)
            return;
    }

    ReusableMutexGuard aResetGuard(m_aResetSafety);
    // do we have a database connected form and stay on the insert row
    sal_Bool bInsertRow = sal_False;
    if (m_xAggregateSet.is())
        bInsertRow = getBOOL(m_xAggregateSet->getPropertyValue(PROPERTY_ISNEW));
    if (bInsertRow)
    {
        // Iterate through all columns and set the default value
//      Reference< XColumnsSupplier > xColsSuppl(m_xAggregateSet, UNO_QUERY);
//      Reference< XIndexAccess > xIndexCols(xColsSuppl->getColumns(), UNO_QUERY);
//      for (sal_Int32 i = 0; i < xIndexCols->getCount(); i++)
//      {
//          Reference< XPropertySet > xColProps;
//          xIndexCols->getByIndex(i) >>= xColProps;
//
//          //  ::rtl::OUString sDefault;
//          xColProps->getPropertyValue(PROPERTY_DEFAULT_VALUE) >>= sDefault;
//          // TODO: the rowset needs columns which have a default value ....
//
//          // OJ: it isn't valid to set everything to null see #88888#
//          if (!::cppu::any2bool(xColProps->getPropertyValue(PROPERTY_ISREADONLY)))
//          {
//              try
//              {
//                  Reference< XColumnUpdate > xColUpdate(xColProps, UNO_QUERY);
//                  if (sDefault.getLength())
//                      xColUpdate->updateString(sDefault);
//                  else
//                      xColUpdate->updateNull();
//              }
//              catch(Exception&)
//              {
//              }
//          }
//      }

        if (m_bSubForm)
        {
            // Iterate through all columns and set the default value
            Reference<XColumnsSupplier>  xColsSuppl(m_xAggregateSet, UNO_QUERY);

            // now set the values on which a subform depends
            Reference<XColumnsSupplier>  xParentColsSuppl(m_xParent, UNO_QUERY);
            Reference<XNameAccess>  xParentCols = xParentColsSuppl->getColumns();
            sal_Int32 nMasterLen = m_aMasterFields.getLength();
            if (xParentCols->hasElements() && (nMasterLen > 0))
            {
                try
                {
                    // analyze our parameters
                    if ( !m_pParameterInfo )
                        createParameterInfo();

                    Reference<XNameAccess>  xCols(xColsSuppl->getColumns(), UNO_QUERY);

                    const ::rtl::OUString* pMasterFields = m_aMasterFields.getConstArray();
                    const ::rtl::OUString* pDetailFields = m_aDetailFields.getConstArray();
                    const ::rtl::OUString* pDetailFieldsEnd = pDetailFields + m_aDetailFields.getLength();
                    for (pDetailFields; pDetailFields < pDetailFieldsEnd; ++pDetailFields, ++pMasterFields)
                    {
                        Reference<XPropertySet>  xMasterField, xField;
                        if (m_pParameterInfo->xParamsAsNames->hasByName(*pDetailFields))
                        {   // we really have a parameter column with this name
                            Reference< XPropertySet > xParamColumn;
                            m_pParameterInfo->xParamsAsNames->getByName(*pDetailFields) >>= xParamColumn;
                            if (xParamColumn.is())
                            {   // we really really have it :)
                                ::rtl::OUString sParamColumnRealName;
                                xParamColumn->getPropertyValue(PROPERTY_REALNAME) >>= sParamColumnRealName;
                                if (xCols->hasByName(sParamColumnRealName))
                                {   // our own columns have a column which's name equals the real name of the param column
                                    if (xParentCols->hasByName(*pMasterFields))
                                    {   // and our parent's cols know the master field which is connected to the current detail field

                                        // -> transfer the value property
                                        xParentCols->getByName(*pMasterFields) >>= xMasterField;
                                        xCols->getByName(sParamColumnRealName) >>= xField;
                                        if (xField.is() && xMasterField.is())
                                            xField->setPropertyValue(PROPERTY_VALUE, xMasterField->getPropertyValue(PROPERTY_VALUE));
                                    }
                                }
                            }
                        }
                    }
                }
                catch(const Exception&)
                {
                    OSL_ENSURE(sal_False, "ODatabaseForm::reset_impl: could not initialize the mater-detail-driven parameters!");
                }
            }
        }
    }

    aResetGuard.clear();
    // iterate through all components. don't use an XIndexAccess as this will cause massive
    // problems with the count.
    Reference<XEnumeration>  xIter = createEnumeration();
    while (xIter->hasMoreElements())
    {
        Reference<XReset> xReset;
        xIter->nextElement() >>= xReset;
        if (xReset.is())
        {
            // TODO : all reset-methods have to be thread-safe
            xReset->reset();
        }
    }

    aResetGuard.attach(m_aResetSafety);
    // ensure that the row isn't modified
    // (do this _before_ the listeners are notified ! their reaction (maybe asynchronous) may depend
    // on the modified state of the row
    // 21.02.00 - 73265 - FS)
    if (bInsertRow)
        m_xAggregateSet->setPropertyValue(PROPERTY_ISMODIFIED, ::cppu::bool2any(sal_Bool(sal_False)));

    aResetGuard.clear();
    {
        EventObject aEvt(static_cast<XWeak*>(this));
        NOTIFY_LISTENERS(m_aResetListeners, XResetListener, resetted, aEvt);
    }

    aResetGuard.attach(m_aResetSafety);
    // and again : ensure the row isn't modified
    // we already did this after we (and maybe our dependents) resetted the values, but the listeners may have changed the row, too
    if (bInsertRow)
        m_xAggregateSet->setPropertyValue(PROPERTY_ISMODIFIED, ::cppu::bool2any((sal_False)));

    --m_nResetsPending;
}

//-----------------------------------------------------------------------------
void SAL_CALL ODatabaseForm::addResetListener(const Reference<XResetListener>& _rListener) throw( RuntimeException )
{
    m_aResetListeners.addInterface(_rListener);
}

//-----------------------------------------------------------------------------
void SAL_CALL ODatabaseForm::removeResetListener(const Reference<XResetListener>& _rListener) throw( RuntimeException )
{
    m_aResetListeners.removeInterface(_rListener);
}

//==============================================================================
// com::sun::star::form::XSubmit
//------------------------------------------------------------------------------
void SAL_CALL ODatabaseForm::submit( const Reference<XControl>& Control,
                              const MouseEvent& MouseEvt ) throw( RuntimeException )
{
    {
        ::osl::MutexGuard aGuard(m_aMutex);
        // Sind Controls und eine Submit-URL vorhanden?
        if( !getCount() || !m_aTargetURL.getLength() )
            return;
    }

    ::osl::ClearableMutexGuard aGuard(m_aMutex);
    if (m_aSubmitListeners.getLength())
    {
        // create an own thread if we have (approve-)submit-listeners (so the listeners can't do that much damage
        // to this thread which is probably the main one)
        if (!m_pThread)
        {
            m_pThread = new OFormSubmitResetThread(this);
            m_pThread->acquire();
            m_pThread->create();
        }
        m_pThread->addEvent(&MouseEvt, Control, sal_True);
    }
    else
    {
        // direct call without any approving by the listeners
        aGuard.clear();
        submit_impl( Control, MouseEvt, true );
    }
}

//------------------------------------------------------------------------------
void ODatabaseForm::submit_impl(const Reference<XControl>& Control, const MouseEvent& MouseEvt, bool _bAproveByListeners)
{

    if (_bAproveByListeners)
    {
        ::cppu::OInterfaceIteratorHelper aIter(m_aSubmitListeners);
        EventObject aEvt(static_cast<XWeak*>(this));
        sal_Bool bCanceled = sal_False;
        while (aIter.hasMoreElements() && !bCanceled)
        {
            if (!((XSubmitListener*)aIter.next())->approveSubmit(aEvt))
                bCanceled = sal_True;
        }

        if (bCanceled)
            return;
    }

    FormSubmitEncoding eSubmitEncoding;
    FormSubmitMethod eSubmitMethod;
    ::rtl::OUString aURLStr;
    ::rtl::OUString aReferer;
    ::rtl::OUString aTargetName;
    Reference< XModel >  xModel;
    {
        ::vos::OGuard aGuard( Application::GetSolarMutex() );
        // starform->Forms

        Reference<XChild>  xParent(m_xParent, UNO_QUERY);

        if (xParent.is())
            xModel = getXModel(xParent->getParent());

        if (xModel.is())
            aReferer = xModel->getURL();

        // TargetItem
        aTargetName = m_aTargetFrame;

        eSubmitEncoding = m_eSubmitEncoding;
        eSubmitMethod = m_eSubmitMethod;
        aURLStr = m_aTargetURL;
    }

    if (!xModel.is())
        return;

    Reference<XURLTransformer>
        xTransformer(m_xServiceFactory->createInstance(
            ::rtl::OUString::createFromAscii("com.sun.star.util.URLTransformer")), UNO_QUERY);
    DBG_ASSERT(xTransformer.is(), "ODatabaseForm::submit_impl : could not create an URL transformer !");

    // URL-Encoding
    if( eSubmitEncoding == FormSubmitEncoding_URL )
    {
        ::rtl::OUString aData;
        {
            ::vos::OGuard aGuard( Application::GetSolarMutex() );
            aData = GetDataURLEncoded( Control, MouseEvt );
        }

        Reference< XFrame >  xFrame = xModel->getCurrentController()->getFrame();
        if (!xFrame.is())
            return;

        URL aURL;
        // FormMethod GET
        if( eSubmitMethod == FormSubmitMethod_GET )
        {
            INetURLObject aUrlObj( aURLStr, INetURLObject::WAS_ENCODED );
            aUrlObj.SetParam( aData, INetURLObject::ENCODE_ALL );
            aURL.Complete = aUrlObj.GetMainURL( INetURLObject::DECODE_UNAMBIGUOUS );
            if (xTransformer.is())
                xTransformer->parseStrict(aURL);

            Reference< XDispatch >  xDisp = Reference< XDispatchProvider > (xFrame,UNO_QUERY)->queryDispatch(aURL, aTargetName,
                    FrameSearchFlag::SELF | FrameSearchFlag::PARENT | FrameSearchFlag::CHILDREN |
                    FrameSearchFlag::SIBLINGS | FrameSearchFlag::CREATE | FrameSearchFlag::TASKS);

            if (xDisp.is())
            {
                Sequence<PropertyValue> aArgs(1);
                aArgs.getArray()->Name = ::rtl::OUString::createFromAscii("Referer");
                aArgs.getArray()->Value <<= aReferer;
                xDisp->dispatch(aURL, aArgs);
            }
        }
        // FormMethod POST
        else if( eSubmitMethod == FormSubmitMethod_POST )
        {
            aURL.Complete = aURLStr;
            xTransformer->parseStrict(aURL);

            Reference< XDispatch >  xDisp = Reference< XDispatchProvider > (xFrame,UNO_QUERY)->queryDispatch(aURL, aTargetName,
                FrameSearchFlag::SELF | FrameSearchFlag::PARENT | FrameSearchFlag::CHILDREN |
                FrameSearchFlag::SIBLINGS | FrameSearchFlag::CREATE | FrameSearchFlag::TASKS);

            if (xDisp.is())
            {
                Sequence<PropertyValue> aArgs(2);
                aArgs.getArray()[0].Name = ::rtl::OUString::createFromAscii("Referer");
                aArgs.getArray()[0].Value <<= aReferer;

                // build a sequence from the to-be-submitted string
                ByteString a8BitData(aData.getStr(), (sal_uInt16)aData.getLength(), RTL_TEXTENCODING_MS_1252);
                    // always ANSI #58641
                Sequence< sal_Int8 > aPostData((sal_Int8*)a8BitData.GetBuffer(), a8BitData.Len());
                Reference< XInputStream > xPostData = new SequenceInputStream(aPostData);

                aArgs.getArray()[1].Name = ::rtl::OUString::createFromAscii("PostData");
                aArgs.getArray()[1].Value <<= xPostData;

                xDisp->dispatch(aURL, aArgs);
            }
        }
    }
    else if( eSubmitEncoding == FormSubmitEncoding_MULTIPART )
    {
        Reference< XFrame >  xFrame = xModel->getCurrentController()->getFrame();
        if (!xFrame.is())
            return;

        URL aURL;
        aURL.Complete = aURLStr;
        xTransformer->parseStrict(aURL);

        Reference< XDispatch >  xDisp = Reference< XDispatchProvider > (xFrame,UNO_QUERY)->queryDispatch(aURL, aTargetName,
                FrameSearchFlag::SELF | FrameSearchFlag::PARENT | FrameSearchFlag::CHILDREN |
                FrameSearchFlag::SIBLINGS | FrameSearchFlag::CREATE | FrameSearchFlag::TASKS);

        if (xDisp.is())
        {
            ::rtl::OUString aContentType;
            Sequence<sal_Int8> aData;
            {
                ::vos::OGuard aGuard( Application::GetSolarMutex() );
                aData = GetDataMultiPartEncoded(Control, MouseEvt, aContentType);
            }
            if (!aData.getLength())
                return;

            Sequence<PropertyValue> aArgs(3);
            aArgs.getArray()[0].Name = ::rtl::OUString::createFromAscii("Referer");
            aArgs.getArray()[0].Value <<= aReferer;
            aArgs.getArray()[1].Name = ::rtl::OUString::createFromAscii("ContentType");
            aArgs.getArray()[1].Value <<= aContentType;

            // build a sequence from the to-be-submitted string
            Reference< XInputStream > xPostData = new SequenceInputStream(aData);

            aArgs.getArray()[2].Name = ::rtl::OUString::createFromAscii("PostData");
            aArgs.getArray()[2].Value <<= xPostData;

            xDisp->dispatch(aURL, aArgs);
        }
    }
    else if( eSubmitEncoding == FormSubmitEncoding_TEXT )
    {
        ::rtl::OUString aData;
        {
            ::vos::OGuard aGuard( Application::GetSolarMutex() );
            aData = GetDataTextEncoded( Reference<XControl> (), MouseEvt );
        }

        Reference< XFrame >  xFrame = xModel->getCurrentController()->getFrame();
        if (!xFrame.is())
            return;

        URL aURL;

        aURL.Complete = aURLStr;
        xTransformer->parseStrict(aURL);

        Reference< XDispatch >  xDisp = Reference< XDispatchProvider > (xFrame,UNO_QUERY)->queryDispatch(aURL, aTargetName,
            FrameSearchFlag::SELF | FrameSearchFlag::PARENT | FrameSearchFlag::CHILDREN |
            FrameSearchFlag::SIBLINGS | FrameSearchFlag::CREATE | FrameSearchFlag::TASKS);

        if (xDisp.is())
        {
            Sequence<PropertyValue> aArgs(2);
            aArgs.getArray()[0].Name = ::rtl::OUString::createFromAscii("Referer");
            aArgs.getArray()[0].Value <<= aReferer;

            // build a sequence from the to-be-submitted string
            ByteString aSystemEncodedData(aData.getStr(), (sal_uInt16)aData.getLength(), osl_getThreadTextEncoding());
            Sequence< sal_Int8 > aPostData((sal_Int8*)aSystemEncodedData.GetBuffer(), aSystemEncodedData.Len());
            Reference< XInputStream > xPostData = new SequenceInputStream(aPostData);

            aArgs.getArray()[1].Name = ::rtl::OUString::createFromAscii("PostData");
            aArgs.getArray()[1].Value <<= xPostData;

            xDisp->dispatch(aURL, aArgs);
        }
    }
    else
        DBG_ERROR("ODatabaseForm::submit_Impl : wrong encoding !");

}

// XSubmit
//------------------------------------------------------------------------------
void SAL_CALL ODatabaseForm::addSubmitListener(const Reference<XSubmitListener>& _rListener) throw( RuntimeException )
{
    m_aSubmitListeners.addInterface(_rListener);
}

//------------------------------------------------------------------------------
void SAL_CALL ODatabaseForm::removeSubmitListener(const Reference<XSubmitListener>& _rListener) throw( RuntimeException )
{
    m_aSubmitListeners.removeInterface(_rListener);
}

//==============================================================================
// com::sun::star::sdbc::XSQLErrorBroadcaster
//------------------------------------------------------------------------------
void SAL_CALL ODatabaseForm::addSQLErrorListener(const Reference<XSQLErrorListener>& _rListener) throw( RuntimeException )
{
    m_aErrorListeners.addInterface(_rListener);
}

//------------------------------------------------------------------------------
void SAL_CALL ODatabaseForm::removeSQLErrorListener(const Reference<XSQLErrorListener>& _rListener) throw( RuntimeException )
{
    m_aErrorListeners.removeInterface(_rListener);
}

//------------------------------------------------------------------------------
void ODatabaseForm::invlidateParameters()
{
    ::osl::MutexGuard aGuard(m_aMutex);
    DELETEZ(m_pParameterInfo);
    clearParameters();
}

//==============================================================================
// OChangeListener
//------------------------------------------------------------------------------
void ODatabaseForm::_propertyChanged(const PropertyChangeEvent& evt) throw( RuntimeException )
{
    if ((0 == evt.PropertyName.compareToAscii(PROPERTY_ACTIVE_CONNECTION)) && !m_bForwardingConnection)
    {
        // the rowset changed it's active connection itself (without interaction from our side), so
        // we need to fire this event, too
        sal_Int32 nHandle = PROPERTY_ID_ACTIVE_CONNECTION;
        fire(&nHandle, &evt.NewValue, &evt.OldValue, 1, sal_False);
    }
    else    // it was one of the statement relevant props
    {
        // if the statement has changed we have to delete the parameter info
        invlidateParameters();
    }
}

//==============================================================================
// smartXChild
//------------------------------------------------------------------------------
void SAL_CALL ODatabaseForm::setParent(const InterfaceRef& Parent) throw ( ::com::sun::star::lang::NoSupportException, ::com::sun::star::uno::RuntimeException)
{
    ReusableMutexGuard aGuard(m_aMutex);

    Reference<XForm>  xParentForm(getParent(), UNO_QUERY);
    if (xParentForm.is())
    {
        Reference<XRowSetApproveBroadcaster>  xParentApprBroadcast(xParentForm, UNO_QUERY);
        if (xParentApprBroadcast.is())
            xParentApprBroadcast->removeRowSetApproveListener(this);
        Reference<XLoadable>  xParentLoadable(xParentForm, UNO_QUERY);
        if (xParentLoadable.is())
            xParentLoadable->removeLoadListener(this);
    }

    OFormComponents::setParent(Parent);

    xParentForm = Reference<XForm> (getParent(), UNO_QUERY);
    if (xParentForm.is())
    {
        Reference<XRowSetApproveBroadcaster>  xParentApprBroadcast(xParentForm, UNO_QUERY);
        if (xParentApprBroadcast.is())
            xParentApprBroadcast->addRowSetApproveListener(this);
        Reference<XLoadable>  xParentLoadable(xParentForm, UNO_QUERY);
        if (xParentLoadable.is())
            xParentLoadable->addLoadListener(this);
    }
}

//==============================================================================
// smartXTabControllerModel
//------------------------------------------------------------------------------
sal_Bool SAL_CALL ODatabaseForm::getGroupControl() throw(com::sun::star::uno::RuntimeException)
{
    ReusableMutexGuard aGuard(m_aMutex);

    // Sollen Controls in einer TabOrder gruppe zusammengefaßt werden?
    if (m_aCycle.hasValue())
    {
        sal_Int32 nCycle;
        ::cppu::enum2int(nCycle, m_aCycle);
        return nCycle != TabulatorCycle_PAGE;
    }

    if (isLoaded() && getConnection().is())
        return sal_True;

    return sal_False;
}

//------------------------------------------------------------------------------
void SAL_CALL ODatabaseForm::setControlModels(const Sequence<Reference<XControlModel> >& rControls) throw( RuntimeException )
{
    ReusableMutexGuard aGuard(m_aMutex);

    // TabIndex in der Reihenfolge der Sequence setzen
    const Reference<XControlModel>* pControls = rControls.getConstArray();
    sal_Int16 nTabIndex = 1;
    sal_Int32 nCount = getCount();
    sal_Int32 nNewCount = rControls.getLength();

    // HiddenControls und Formulare werden nicht aufgefuehrt
    if (nNewCount <= nCount)
    {
        Any aElement;
        for (sal_Int32 i=0; i < nNewCount; ++i, ++pControls)
        {
            Reference<XFormComponent>  xComp(*pControls, UNO_QUERY);
            if (xComp.is())
            {
                // suchen der Componente in der Liste
                for (sal_Int32 j = 0; j < nCount; ++j)
                {
                    Reference<XFormComponent> xElement;
                    ::cppu::extractInterface(xElement, getByIndex(j));
                    if (xComp == xElement)
                    {
                        Reference<XPropertySet>  xSet(xComp, UNO_QUERY);
                        if (xSet.is() && hasProperty(PROPERTY_TABINDEX, xSet))
                            xSet->setPropertyValue( PROPERTY_TABINDEX, makeAny(nTabIndex++) );
                        break;
                    }
                }
            }
        }
    }
}

//------------------------------------------------------------------------------
Sequence<Reference<XControlModel> > SAL_CALL ODatabaseForm::getControlModels() throw( RuntimeException )
{
    ::osl::MutexGuard aGuard(m_aMutex);
    return m_pGroupManager->getControlModels();
}

//------------------------------------------------------------------------------
void SAL_CALL ODatabaseForm::setGroup( const Sequence<Reference<XControlModel> >& _rGroup, const ::rtl::OUString& Name ) throw( RuntimeException )
{
    ::osl::MutexGuard aGuard(m_aMutex);

    // Die Controls werden gruppiert, indem ihr Name dem Namen des ersten
    // Controls der Sequenz angepasst wird
    const Reference<XControlModel>* pControls = _rGroup.getConstArray();
    Reference<XPropertySet>     xSet;
    ::rtl::OUString sGroupName;

    for( sal_Int32 i=0; i<_rGroup.getLength(); ++i, ++pControls )
    {
        Reference<XPropertySet> xSet(*pControls, UNO_QUERY);

        if (!sGroupName.getLength())
            xSet->getPropertyValue(PROPERTY_NAME) >>= sGroupName;
        else
            xSet->setPropertyValue(PROPERTY_NAME, makeAny(sGroupName));
    }
}

//------------------------------------------------------------------------------
sal_Int32 SAL_CALL ODatabaseForm::getGroupCount() throw( RuntimeException )
{
    ::osl::MutexGuard aGuard(m_aMutex);
    return m_pGroupManager->getGroupCount();
}

//------------------------------------------------------------------------------
void SAL_CALL ODatabaseForm::getGroup( sal_Int32 nGroup, Sequence<Reference<XControlModel> >& _rGroup, ::rtl::OUString& _rName ) throw( RuntimeException )
{
    ::osl::MutexGuard aGuard(m_aMutex);
    _rGroup.realloc(0);
    _rName = ::rtl::OUString();

    if ((nGroup < 0) || (nGroup >= m_pGroupManager->getGroupCount()))
        return;
    m_pGroupManager->getGroup( nGroup, _rGroup, _rName  );
}

//------------------------------------------------------------------------------
void SAL_CALL ODatabaseForm::getGroupByName(const ::rtl::OUString& Name, Sequence< Reference<XControlModel>  >& _rGroup) throw( RuntimeException )
{
    ::osl::MutexGuard aGuard(m_aMutex);
    _rGroup.realloc(0);
    m_pGroupManager->getGroupByName( Name, _rGroup );
}

//==============================================================================
// com::sun::star::lang::XEventListener
//------------------------------------------------------------------------------
void SAL_CALL ODatabaseForm::disposing(const EventObject& Source) throw( RuntimeException )
{
    // does the call come from the connection which we are sharing with our parent?
    if ( isSharingConnection() )
    {
        Reference< XConnection > xConnSource( Source.Source, UNO_QUERY );
        if ( xConnSource.is() )
        {
#ifdef _DEBUG
            Reference< XConnection > xActiveConn;
            m_xAggregateSet->getPropertyValue( PROPERTY_ACTIVE_CONNECTION ) >>= xActiveConn;
            OSL_ENSURE( xActiveConn.get() == xConnSource.get(), "ODatabaseForm::disposing: where did this come from?" );
                // there should be exactly one XConnection object we're listening at - our aggregate connection
#endif
            disposingSharedConnection( xConnSource );
        }
    }

    OInterfaceContainer::disposing(Source);

    // does the disposing come from the aggregate ?
    if (m_xAggregate.is())
    {   // no -> forward it
        com::sun::star::uno::Reference<com::sun::star::lang::XEventListener> xListener;
        if (query_aggregation(m_xAggregate, xListener))
            xListener->disposing(Source);
    }
}

//==============================================================================
// com::sun::star::form::XLoadListener
//------------------------------------------------------------------------------
void SAL_CALL ODatabaseForm::loaded(const EventObject& aEvent) throw( RuntimeException )
{
    // now start the rowset listening to recover cursor events
    load_impl(sal_True);
    {
        ::osl::MutexGuard aGuard(m_aMutex);
        Reference<XRowSet>  xParentRowSet(m_xParent, UNO_QUERY);
        if (xParentRowSet.is())
            xParentRowSet->addRowSetListener(this);

        m_pLoadTimer = new Timer();
        m_pLoadTimer->SetTimeout(100);
        m_pLoadTimer->SetTimeoutHdl(LINK(this,ODatabaseForm,OnTimeout));
    }
}

//------------------------------------------------------------------------------
void SAL_CALL ODatabaseForm::unloading(const EventObject& aEvent) throw( RuntimeException )
{
    {
        // now stop the rowset listening if we are a subform
        ::osl::MutexGuard aGuard(m_aMutex);
        DELETEZ(m_pLoadTimer);

        Reference<XRowSet>  xParentRowSet(m_xParent, UNO_QUERY);
        if (xParentRowSet.is())
            xParentRowSet->removeRowSetListener(this);
    }

    unload();
}

//------------------------------------------------------------------------------
void SAL_CALL ODatabaseForm::unloaded(const EventObject& aEvent) throw( RuntimeException )
{
    // nothing to do
}

//------------------------------------------------------------------------------
void SAL_CALL ODatabaseForm::reloading(const EventObject& aEvent) throw( RuntimeException )
{
    // now stop the rowset listening if we are a subform
    ::osl::MutexGuard aGuard(m_aMutex);
    Reference<XRowSet>  xParentRowSet(m_xParent, UNO_QUERY);
    if (xParentRowSet.is())
        xParentRowSet->removeRowSetListener(this);

    if (m_pLoadTimer && m_pLoadTimer->IsActive())
        m_pLoadTimer->Stop();
}

//------------------------------------------------------------------------------
void SAL_CALL ODatabaseForm::reloaded(const EventObject& aEvent) throw( RuntimeException )
{
    reload_impl(sal_True);
    {
        ::osl::MutexGuard aGuard(m_aMutex);
        Reference<XRowSet>  xParentRowSet(m_xParent, UNO_QUERY);
        if (xParentRowSet.is())
            xParentRowSet->addRowSetListener(this);
    }
}

//------------------------------------------------------------------------------
IMPL_LINK( ODatabaseForm, OnTimeout, void*, EMPTYARG )
{
    reload_impl(sal_True);
    return 1;
}

//==============================================================================
// com::sun::star::form::XLoadable
//------------------------------------------------------------------------------
void SAL_CALL ODatabaseForm::load() throw( RuntimeException )
{
    load_impl(sal_False);
}

//------------------------------------------------------------------------------
sal_Bool ODatabaseForm::canShareConnection( const Reference< XPropertySet >& _rxParentProps )
{
    // our own data source
    ::rtl::OUString sOwnDatasource;
    m_xAggregateSet->getPropertyValue( PROPERTY_DATASOURCE ) >>= sOwnDatasource;

    // our parents data source
    ::rtl::OUString sParentDataSource;
    OSL_ENSURE( _rxParentProps.is() && _rxParentProps->getPropertySetInfo().is() && _rxParentProps->getPropertySetInfo()->hasPropertyByName( PROPERTY_DATASOURCE ),
        "ODatabaseForm::doShareConnection: invalid parent form!" );
    if ( _rxParentProps.is() )
        _rxParentProps->getPropertyValue( PROPERTY_DATASOURCE ) >>= sParentDataSource;

    sal_Bool bCanShareConnection = sal_False;

    // both rowsets share are connected to the same data source
    if ( sParentDataSource == sOwnDatasource )
    {
        if ( 0 != sParentDataSource.getLength() )
            // and it's really a data source name (not empty)
            bCanShareConnection = sal_True;
        else
        {   // the data source name is empty
            // -> ook for the URL
            ::rtl::OUString sParentURL;
            ::rtl::OUString sMyURL;
            _rxParentProps->getPropertyValue( PROPERTY_URL ) >>= sParentURL;
            m_xAggregateSet->getPropertyValue( PROPERTY_URL ) >>= sMyURL;

            bCanShareConnection = (sParentURL == sMyURL);
        }
    }

    if ( bCanShareConnection )
    {
        // check for the user/password

        // take the user property on the rowset (if any) into account
        ::rtl::OUString sParentUser, sParentPwd;
        _rxParentProps->getPropertyValue( PROPERTY_USER ) >>= sParentUser;
        _rxParentProps->getPropertyValue( PROPERTY_PASSWORD ) >>= sParentPwd;

        ::rtl::OUString sMyUser, sMyPwd;
        m_xAggregateSet->getPropertyValue( PROPERTY_USER ) >>= sMyUser;
        m_xAggregateSet->getPropertyValue( PROPERTY_PASSWORD ) >>= sMyPwd;

        bCanShareConnection =
                ( sParentUser == sMyUser )
            &&  ( sParentPwd == sMyPwd );
    }

    return bCanShareConnection;
}

//------------------------------------------------------------------------------
void ODatabaseForm::doShareConnection( const Reference< XPropertySet >& _rxParentProps )
{
    // get the conneciton of the parent
    Reference< XConnection > xParentConn;
    _rxParentProps->getPropertyValue( PROPERTY_ACTIVE_CONNECTION ) >>= xParentConn;
    OSL_ENSURE( xParentConn.is(), "ODatabaseForm::doShareConnection: we're a valid sub-form, but the parent has no connection??!!!" );

    if ( xParentConn.is() )
    {
        // add as dispose listener to the connection
        Reference< XComponent > xParentConnComp( xParentConn, UNO_QUERY );
        OSL_ENSURE( xParentConnComp.is(), "ODatabaseForm::doShareConnection: invalid connection!" );
        xParentConnComp->addEventListener( static_cast< XLoadListener* >( this ) );

        // forward the connection to our own aggreagte
        m_bForwardingConnection = sal_True;
        m_xAggregateSet->setPropertyValue( PROPERTY_ACTIVE_CONNECTION, makeAny( xParentConn ) );
        m_bForwardingConnection = sal_False;

        m_bSharingConnection = sal_True;
    }
    else
        m_bSharingConnection = sal_False;
}

//------------------------------------------------------------------------------
void ODatabaseForm::disposingSharedConnection( const Reference< XConnection >& _rxConn )
{
    stopSharingConnection();

    // TODO: we could think about whether or not to re-connect.
    unload( );
}

//------------------------------------------------------------------------------
void ODatabaseForm::stopSharingConnection( )
{
    OSL_ENSURE( m_bSharingConnection, "ODatabaseForm::stopSharingConnection: invalid call!" );

    if ( m_bSharingConnection )
    {
        // get the connection
        Reference< XConnection > xSharedConn;
        m_xAggregateSet->getPropertyValue( PROPERTY_ACTIVE_CONNECTION ) >>= xSharedConn;
        OSL_ENSURE( xSharedConn.is(), "ODatabaseForm::stopSharingConnection: there's no conn!" );

        // remove ourself as event listener
        Reference< XComponent > xSharedConnComp( xSharedConn, UNO_QUERY );
        if ( xSharedConnComp.is() )
            xSharedConnComp->removeEventListener( static_cast< XLoadListener* >( this ) );

        // no need to dispose the conn: we're not the owner, this is our parent
        // (in addition, this method may be called if the connection is beeing disposed while we use it)

        // reset the property
        xSharedConn.clear();
        m_bForwardingConnection = sal_True;
        m_xAggregateSet->setPropertyValue( PROPERTY_ACTIVE_CONNECTION, makeAny( xSharedConn ) );
        m_bForwardingConnection = sal_False;

        // reset the flag
        m_bSharingConnection = sal_False;
    }
}

//------------------------------------------------------------------------------
sal_Bool ODatabaseForm::implEnsureConnection()
{
    try
    {
        if ( getConnection( ).is() )
            // if our aggregate already has a connection, nothing needs to be done about it
            return sal_True;

        m_bSharingConnection = sal_False;

        // if we're a sub form, we try to re-use the connection of our parent
        if (m_bSubForm)
        {
            OSL_ENSURE( Reference< XForm >( getParent(), UNO_QUERY ).is(),
                "ODatabaseForm::implEnsureConnection: m_bSubForm is TRUE, but the parent is no form?" );

            Reference< XPropertySet > xParentProps( getParent(), UNO_QUERY );

            // can we re-use (aka share) the connection of the parent?
            if ( canShareConnection( xParentProps ) )
            {
                // yep -> do it
                doShareConnection( xParentProps );
                // success?
                if ( m_bSharingConnection )
                    // yes -> outta here
                    return sal_True;
            }
        }

        if (m_xAggregateSet.is())
        {
            // do we have a connection in the hierarchy than take that connection
            // this overwrites all the other connnections
            Reference< XConnection >  xConnection = calcConnection(
                Reference<XRowSet> (m_xAggregate, UNO_QUERY),
                m_xServiceFactory
            );      // will set a calculated connection implicitly
            return xConnection.is();
        }
    }
    catch(SQLException& eDB)
    {
        onError(eDB, FRM_RES_STRING(RID_STR_CONNECTERROR));
    }

    return sal_False;
}

//------------------------------------------------------------------------------
void ODatabaseForm::load_impl(sal_Bool bCausedByParentForm, sal_Bool bMoveToFirst, const Reference< XInteractionHandler >& _rxCompletionHandler ) throw( RuntimeException )
{
    ReusableMutexGuard aGuard(m_aMutex);

    // are we already loaded?
    if (isLoaded())
        return;

    m_bSubForm = bCausedByParentForm;

    // if we don't have a connection, we are not intended to be a database form or the aggregate was not able
    // to establish a connection
    sal_Bool bConnected = implEnsureConnection();

    // we don't have to execute if we do not have a command to execute
    sal_Bool bExecute = bConnected && m_xAggregateSet.is() && getString(m_xAggregateSet->getPropertyValue(PROPERTY_COMMAND)).getLength();

    // a database form always uses caching
    // we use starting fetchsize with at least 10 rows
    if (bConnected)
        m_xAggregateSet->setPropertyValue(PROPERTY_FETCHSIZE, makeAny((sal_Int32)10));

    // if we're loaded as sub form we got a "rowSetChanged" from the parent rowset _before_ we got the "loaded"
    // so we don't need to execute the statement again, this was already done
    // (and there were no relevant changes between these two listener calls, the "load" of a form is quite an
    // atomar operation.)

    sal_Bool bSuccess = sal_False;
    if (bExecute)
    {
        m_sCurrentErrorContext = FRM_RES_STRING(RID_ERR_LOADING_FORM);
        bSuccess = executeRowSet(aGuard, bMoveToFirst, _rxCompletionHandler);
    }

    if (bSuccess)
    {
        m_bLoaded = sal_True;
        aGuard.clear();
        EventObject aEvt(static_cast<XWeak*>(this));
        NOTIFY_LISTENERS(m_aLoadListeners, XLoadListener, loaded, aEvt);

        // if we are on the insert row, we have to reset all controls
        // to set the default values
        if (bExecute && getBOOL(m_xAggregateSet->getPropertyValue(PROPERTY_ISNEW)))
            reset();
    }
}

//------------------------------------------------------------------------------
void SAL_CALL ODatabaseForm::unload() throw( RuntimeException )
{
    ReusableMutexGuard aGuard(m_aMutex);
    if (!isLoaded())
        return;

    DELETEZ(m_pLoadTimer);

    aGuard.clear();
    EventObject aEvt(static_cast<XWeak*>(this));
    NOTIFY_LISTENERS(m_aLoadListeners, XLoadListener, unloading, aEvt);

    if (m_xAggregateAsRowSet.is())
    {
        // clear the parameters if there are any
        invlidateParameters();

        try
        {
            // close the aggregate
            Reference<XCloseable>  xCloseable;
            query_aggregation( m_xAggregate, xCloseable);
            aGuard.clear();
            if (xCloseable.is())
                xCloseable->close();
        }
        catch(SQLException& eDB)
        {
            eDB;
        }
        aGuard.attach(m_aMutex);
    }

    m_bLoaded = sal_False;

    // if the connection we used while we were loaded is only shared with our parent, we
    // reset it
    if ( isSharingConnection() )
        stopSharingConnection();

    aGuard.clear();
    NOTIFY_LISTENERS(m_aLoadListeners, XLoadListener, unloaded, aEvt);
}

//------------------------------------------------------------------------------
void SAL_CALL ODatabaseForm::reload() throw( RuntimeException )
{
    reload_impl(sal_True);
}

//------------------------------------------------------------------------------
void ODatabaseForm::reload_impl(sal_Bool bMoveToFirst, const Reference< XInteractionHandler >& _rxCompletionHandler ) throw( RuntimeException )
{
    ReusableMutexGuard aGuard(m_aMutex);
    if (!isLoaded())
        return;

    EventObject aEvent(static_cast<XWeak*>(this));
    {
        // only if there is no approve listener we can post the event at this time
        // otherwise see approveRowsetChange
        // the aprrovement is done by the aggregate
        if (!m_aRowSetApproveListeners.getLength())
        {
            ::cppu::OInterfaceIteratorHelper aIter(m_aLoadListeners);
            aGuard.clear();

            while (aIter.hasMoreElements())
                ((XLoadListener*)aIter.next())->reloading(aEvent);

            aGuard.attach(m_aMutex);
        }
    }

    sal_Bool bSuccess = sal_True;
    try
    {
        m_sCurrentErrorContext = FRM_RES_STRING(RID_ERR_REFRESHING_FORM);
        bSuccess = executeRowSet(aGuard, bMoveToFirst, _rxCompletionHandler);
    }
    catch(SQLException& e)
    {
        DBG_ERROR("ODatabaseForm::reload_impl : shouldn't executeRowSet catch this exception ?");
        e;
    }

    if (bSuccess)
    {
        ::cppu::OInterfaceIteratorHelper aIter(m_aLoadListeners);
        aGuard.clear();
        while (aIter.hasMoreElements())
            ((XLoadListener*)aIter.next())->reloaded(aEvent);

        // if we are on the insert row, we have to reset all controls
        // to set the default values
        if (getBOOL(m_xAggregateSet->getPropertyValue(PROPERTY_ISNEW)))
            reset();
    }
    else
        m_bLoaded = sal_False;
}

//------------------------------------------------------------------------------
sal_Bool SAL_CALL ODatabaseForm::isLoaded() throw( RuntimeException )
{
    return m_bLoaded;
}

//------------------------------------------------------------------------------
void SAL_CALL ODatabaseForm::addLoadListener(const Reference<XLoadListener>& aListener) throw( RuntimeException )
{
    m_aLoadListeners.addInterface(aListener);
}

//------------------------------------------------------------------------------
void SAL_CALL ODatabaseForm::removeLoadListener(const Reference<XLoadListener>& aListener) throw( RuntimeException )
{
    m_aLoadListeners.removeInterface(aListener);
}

//==============================================================================
// com::sun::star::sdbc::XCloseable
//==============================================================================
void SAL_CALL ODatabaseForm::close() throw( SQLException, RuntimeException )
{
    // unload will close the aggregate
    unload();
}

//==============================================================================
// com::sun::star::sdbc::XRowSetListener
//------------------------------------------------------------------------------
void SAL_CALL ODatabaseForm::cursorMoved(const EventObject& event) throw( RuntimeException )
{
    // reload the subform with the new parameters of the parent
    // do this handling delayed to provide of execute too many SQL Statements
    ReusableMutexGuard aGuard(m_aMutex);
    if (m_pLoadTimer->IsActive())
        m_pLoadTimer->Stop();

    // and start the timer again
    m_pLoadTimer->Start();
}

//------------------------------------------------------------------------------
void SAL_CALL ODatabaseForm::rowChanged(const EventObject& event) throw( RuntimeException )
{
    // ignore it
}

//------------------------------------------------------------------------------
void SAL_CALL ODatabaseForm::rowSetChanged(const EventObject& event) throw( RuntimeException )
{
    // not interested in :
    // if our parent is an ODatabaseForm, too, then after this rowSetChanged we'll get a "reloaded"
    // or a "loaded" event.
    // If somebody gave us another parent which is an XRowSet but doesn't handle an execute as
    // "load" respectivly "reload" ... can't do anything ....
}

//------------------------------------------------------------------------------
sal_Bool SAL_CALL ODatabaseForm::approveCursorMove(const EventObject& event) throw( RuntimeException )
{
    // is our aggregate calling?
    if (event.Source == InterfaceRef(static_cast<XWeak*>(this)))
    {
        // Our aggregate doesn't have any ApproveRowSetListeners (expect ourself), as we re-routed the queryInterface
        // for XRowSetApproveBroadcaster-interface.
        // So we have to multiplex this approve request.
        ::cppu::OInterfaceIteratorHelper aIter(m_aRowSetApproveListeners);
        while (aIter.hasMoreElements())
            if (!((XRowSetApproveListener*)aIter.next())->approveCursorMove(event))
                return sal_False;
    }
    else
    {
        // this is a call from our parent ...
        // a parent's cursor move will result in a re-execute of our own row-set, so we have to
        // ask our own RowSetChangesListeners, too
        ::cppu::OInterfaceIteratorHelper aIter(m_aRowSetApproveListeners);
        while (aIter.hasMoreElements())
            if (!((XRowSetApproveListener*)aIter.next())->approveRowSetChange(event))
                return sal_False;
    }
    return sal_True;
}

//------------------------------------------------------------------------------
sal_Bool SAL_CALL ODatabaseForm::approveRowChange(const RowChangeEvent& event) throw( RuntimeException )
{
    // is our aggregate calling?
    if (event.Source == InterfaceRef(static_cast<XWeak*>(this)))
    {
        // Our aggregate doesn't have any ApproveRowSetListeners (expect ourself), as we re-routed the queryInterface
        // for XRowSetApproveBroadcaster-interface.
        // So we have to multiplex this approve request.
        ::cppu::OInterfaceIteratorHelper aIter(m_aRowSetApproveListeners);
        while (aIter.hasMoreElements())
            if (!((XRowSetApproveListener*)aIter.next())->approveRowChange(event))
                return sal_False;
    }
    return sal_True;
}

//------------------------------------------------------------------------------
sal_Bool SAL_CALL ODatabaseForm::approveRowSetChange(const EventObject& event) throw( RuntimeException )
{
    if (event.Source == InterfaceRef(static_cast<XWeak*>(this)))    // ignore our aggregate as we handle this approve ourself
    {
        ::cppu::OInterfaceIteratorHelper aIter(m_aRowSetApproveListeners);
        while (aIter.hasMoreElements())
        if (!((XRowSetApproveListener*)aIter.next())->approveRowSetChange(event))
            return sal_False;

        if (isLoaded())
        {
            ::cppu::OInterfaceIteratorHelper aLoadIter(m_aLoadListeners);
            while (aLoadIter.hasMoreElements())
                ((XLoadListener*)aLoadIter.next())->reloading(event);
        }
    }
    else
    {
        // this is a call from our parent ...
        // a parent's cursor move will result in a re-execute of our own row-set, so we have to
        // ask our own RowSetChangesListeners, too
        ::cppu::OInterfaceIteratorHelper aIter(m_aRowSetApproveListeners);
        while (aIter.hasMoreElements())
            if (!((XRowSetApproveListener*)aIter.next())->approveRowSetChange(event))
                return sal_False;
    }
    return sal_True;
}

//==============================================================================
// com::sun::star::sdb::XRowSetApproveBroadcaster
//------------------------------------------------------------------------------
void SAL_CALL ODatabaseForm::addRowSetApproveListener(const Reference<XRowSetApproveListener>& _rListener) throw( RuntimeException )
{
    ReusableMutexGuard aGuard(m_aMutex);
    m_aRowSetApproveListeners.addInterface(_rListener);

    // do we have to multiplex ?
    if (m_aRowSetApproveListeners.getLength() == 1)
    {
        Reference<XRowSetApproveBroadcaster>  xBroadcaster;
        if (query_aggregation( m_xAggregate, xBroadcaster))
        {
            Reference<XRowSetApproveListener>  xListener((XRowSetApproveListener*)this);
            xBroadcaster->addRowSetApproveListener(xListener);
        }
    }
}

//------------------------------------------------------------------------------
void SAL_CALL ODatabaseForm::removeRowSetApproveListener(const Reference<XRowSetApproveListener>& _rListener) throw( RuntimeException )
{
    ReusableMutexGuard aGuard(m_aMutex);
    // do we have to remove the multiplex ?
    if (m_aRowSetApproveListeners.getLength() == 1)
    {
        Reference<XRowSetApproveBroadcaster>  xBroadcaster;
        if (query_aggregation( m_xAggregate, xBroadcaster))
        {
            Reference<XRowSetApproveListener>  xListener((XRowSetApproveListener*)this);
            xBroadcaster->removeRowSetApproveListener(xListener);
        }
    }
    m_aRowSetApproveListeners.removeInterface(_rListener);
}

//==============================================================================
// com::sun:star::form::XDatabaseParameterBroadcaster
//------------------------------------------------------------------------------
void SAL_CALL ODatabaseForm::addParameterListener(const Reference<XDatabaseParameterListener>& _rListener) throw( RuntimeException )
{
    m_aParameterListeners.addInterface(_rListener);
}
//------------------------------------------------------------------------------
void SAL_CALL ODatabaseForm::removeParameterListener(const Reference<XDatabaseParameterListener>& _rListener) throw( RuntimeException )
{
    m_aParameterListeners.removeInterface(_rListener);
}

//==============================================================================
// com::sun::star::sdb::XCompletedExecution
//------------------------------------------------------------------------------
void SAL_CALL ODatabaseForm::executeWithCompletion( const Reference< XInteractionHandler >& _rxHandler ) throw(SQLException, RuntimeException)
{
    ReusableMutexGuard aGuard(m_aMutex);
    // the difference between execute and load is, that we position on the first row in case of load
    // after execute we remain before the first row
    if (!isLoaded())
    {
        aGuard.clear();
        load_impl(sal_False, sal_False, _rxHandler);
    }
    else
    {
        EventObject event(static_cast< XWeak* >(this));
        ::cppu::OInterfaceIteratorHelper aIter(m_aRowSetApproveListeners);
        aGuard.clear();

        while (aIter.hasMoreElements())
            if (!((XRowSetApproveListener*)aIter.next())->approveRowSetChange(event))
                return;

        // we're loaded and somebody want's to execute ourself -> this means a reload
        reload_impl(sal_False, _rxHandler);
    }
}

//==============================================================================
// com::sun::star::sdbc::XRowSet
//------------------------------------------------------------------------------
void SAL_CALL ODatabaseForm::execute() throw( SQLException, RuntimeException )
{
    ReusableMutexGuard aGuard(m_aMutex);
    // if somebody calls an execute and we're not loaded we reroute this call to our load method.

    // the difference between execute and load is, that we position on the first row in case of load
    // after execute we remain before the first row
    if (!isLoaded())
    {
        aGuard.clear();
        load_impl(sal_False, sal_False);
    }
    else
    {
        EventObject event(static_cast< XWeak* >(this));
        ::cppu::OInterfaceIteratorHelper aIter(m_aRowSetApproveListeners);
        aGuard.clear();

        while (aIter.hasMoreElements())
            if (!((XRowSetApproveListener*)aIter.next())->approveRowSetChange(event))
                return;

        // we're loaded and somebody want's to execute ourself -> this means a reload
        reload_impl(sal_False);
    }
}

//------------------------------------------------------------------------------
void SAL_CALL ODatabaseForm::addRowSetListener(const Reference<XRowSetListener>& _rListener) throw( RuntimeException )
{
    if (m_xAggregateAsRowSet.is())
        m_xAggregateAsRowSet->addRowSetListener(_rListener);
}

//------------------------------------------------------------------------------
void SAL_CALL ODatabaseForm::removeRowSetListener(const Reference<XRowSetListener>& _rListener) throw( RuntimeException )
{
    if (m_xAggregateAsRowSet.is())
        m_xAggregateAsRowSet->removeRowSetListener(_rListener);
}

//==============================================================================
// com::sun::star::sdbc::XResultSet
//------------------------------------------------------------------------------
sal_Bool SAL_CALL ODatabaseForm::next() throw( SQLException, RuntimeException )
{
    return m_xAggregateAsRowSet->next();
}

//------------------------------------------------------------------------------
sal_Bool SAL_CALL ODatabaseForm::isBeforeFirst() throw( SQLException, RuntimeException )
{
    return m_xAggregateAsRowSet->isBeforeFirst();
}

//------------------------------------------------------------------------------
sal_Bool SAL_CALL ODatabaseForm::isAfterLast() throw( SQLException, RuntimeException )
{
    return m_xAggregateAsRowSet->isAfterLast();
}

//------------------------------------------------------------------------------
sal_Bool SAL_CALL ODatabaseForm::isFirst() throw( SQLException, RuntimeException )
{
    return m_xAggregateAsRowSet->isFirst();
}

//------------------------------------------------------------------------------
sal_Bool SAL_CALL ODatabaseForm::isLast() throw( SQLException, RuntimeException )
{
    return m_xAggregateAsRowSet->isLast();
}

//------------------------------------------------------------------------------
void SAL_CALL ODatabaseForm::beforeFirst() throw( SQLException, RuntimeException )
{
    m_xAggregateAsRowSet->beforeFirst();
}

//------------------------------------------------------------------------------
void SAL_CALL ODatabaseForm::afterLast() throw( SQLException, RuntimeException )
{
    m_xAggregateAsRowSet->afterLast();
}

//------------------------------------------------------------------------------
sal_Bool SAL_CALL ODatabaseForm::first() throw( SQLException, RuntimeException )
{
    return m_xAggregateAsRowSet->first();
}

//------------------------------------------------------------------------------
sal_Bool SAL_CALL ODatabaseForm::last() throw( SQLException, RuntimeException )
{
    return m_xAggregateAsRowSet->last();
}

//------------------------------------------------------------------------------
sal_Int32 SAL_CALL ODatabaseForm::getRow() throw( SQLException, RuntimeException )
{
    return m_xAggregateAsRowSet->getRow();
}

//------------------------------------------------------------------------------
sal_Bool SAL_CALL ODatabaseForm::absolute(sal_Int32 row) throw( SQLException, RuntimeException )
{
    return m_xAggregateAsRowSet->absolute(row);
}

//------------------------------------------------------------------------------
sal_Bool SAL_CALL ODatabaseForm::relative(sal_Int32 rows) throw( SQLException, RuntimeException )
{
    return m_xAggregateAsRowSet->relative(rows);
}

//------------------------------------------------------------------------------
sal_Bool SAL_CALL ODatabaseForm::previous() throw( SQLException, RuntimeException )
{
    return m_xAggregateAsRowSet->previous();
}

//------------------------------------------------------------------------------
void SAL_CALL ODatabaseForm::refreshRow() throw( SQLException, RuntimeException )
{
    m_xAggregateAsRowSet->refreshRow();
}

//------------------------------------------------------------------------------
sal_Bool SAL_CALL ODatabaseForm::rowUpdated() throw( SQLException, RuntimeException )
{
    return m_xAggregateAsRowSet->rowUpdated();
}

//------------------------------------------------------------------------------
sal_Bool SAL_CALL ODatabaseForm::rowInserted() throw( SQLException, RuntimeException )
{
    return m_xAggregateAsRowSet->rowInserted();
}

//------------------------------------------------------------------------------
sal_Bool SAL_CALL ODatabaseForm::rowDeleted() throw( SQLException, RuntimeException )
{
    return m_xAggregateAsRowSet->rowDeleted();
}

//------------------------------------------------------------------------------
InterfaceRef SAL_CALL ODatabaseForm::getStatement() throw( SQLException, RuntimeException )
{
    return m_xAggregateAsRowSet->getStatement();
}

// com::sun::star::sdbc::XResultSetUpdate
// exceptions during insert update and delete will be forwarded to the errorlistener
//------------------------------------------------------------------------------
void SAL_CALL ODatabaseForm::insertRow() throw( SQLException, RuntimeException )
{
    try
    {
        Reference<XResultSetUpdate>  xUpdate;
        if (query_aggregation( m_xAggregate, xUpdate))
            xUpdate->insertRow();
    }
    catch(RowSetVetoException& eVeto)
    {
        eVeto;
        throw;
    }
    catch(SQLException& eDb)
    {
        onError(eDb, FRM_RES_STRING(RID_STR_ERR_INSERTRECORD));
        throw;
    }
}

//------------------------------------------------------------------------------
void SAL_CALL ODatabaseForm::updateRow() throw( SQLException, RuntimeException )
{
    try
    {
        Reference<XResultSetUpdate>  xUpdate;
        if (query_aggregation( m_xAggregate, xUpdate))
            xUpdate->updateRow();
    }
    catch(RowSetVetoException& eVeto)
    {
        eVeto;
        throw;
    }
    catch(SQLException& eDb)
    {
        onError(eDb, FRM_RES_STRING(RID_STR_ERR_UPDATERECORD));
        throw;
    }
}

//------------------------------------------------------------------------------
void SAL_CALL ODatabaseForm::deleteRow() throw( SQLException, RuntimeException )
{
    try
    {
        Reference<XResultSetUpdate>  xUpdate;
        if (query_aggregation( m_xAggregate, xUpdate))
            xUpdate->deleteRow();
    }
    catch(RowSetVetoException& eVeto)
    {
        eVeto;
        throw;
    }
    catch(SQLException& eDb)
    {
        onError(eDb, FRM_RES_STRING(RID_STR_ERR_DELETERECORD));
        throw;
    }
}

//------------------------------------------------------------------------------
void SAL_CALL ODatabaseForm::cancelRowUpdates() throw( SQLException, RuntimeException )
{
    Reference<XResultSetUpdate>  xUpdate;
    if (query_aggregation( m_xAggregate, xUpdate))
        xUpdate->cancelRowUpdates();
}

//------------------------------------------------------------------------------
void SAL_CALL ODatabaseForm::moveToInsertRow() throw( SQLException, RuntimeException )
{
    Reference<XResultSetUpdate>  xUpdate;
    if (query_aggregation( m_xAggregate, xUpdate))
    {
        // do we go on the insert row?
        if (!getBOOL(m_xAggregateSet->getPropertyValue(PROPERTY_ISNEW)))
            xUpdate->moveToInsertRow();

        // then set the default values and the parameters given from the parent
        reset();
    }
}

//------------------------------------------------------------------------------
void SAL_CALL ODatabaseForm::moveToCurrentRow() throw( SQLException, RuntimeException )
{
    Reference<XResultSetUpdate>  xUpdate;
    if (query_aggregation( m_xAggregate, xUpdate))
        xUpdate->moveToCurrentRow();
}

// com::sun::star::sdbcx::XDeleteRows
//------------------------------------------------------------------------------
Sequence<sal_Int32> SAL_CALL ODatabaseForm::deleteRows(const Sequence<Any>& rows) throw( SQLException, RuntimeException )
{
    try
    {
        Reference<XDeleteRows>  xDelete;
        if (query_aggregation( m_xAggregate, xDelete))
            return xDelete->deleteRows(rows);
    }
    catch(RowSetVetoException& eVeto)
    {
        eVeto; // make compiler happy
        throw;
    }
    catch(SQLException& eDb)
    {
        onError(eDb, FRM_RES_STRING(RID_STR_ERR_DELETERECORDS));
        throw;
    }

    return Sequence< sal_Int32 >();
}

// com::sun::star::sdbc::XParameters
//------------------------------------------------------------------------------
#define PARAMETER_VISITED(method)                                       \
    ::osl::MutexGuard aGuard(m_aMutex);                                 \
    Reference<XParameters>  xParameters;                \
    if (query_aggregation( m_xAggregate, xParameters))                  \
        xParameters->method;                                            \
                                                                        \
    if ((sal_Int32)m_aParameterVisited.size() < parameterIndex)                 \
    {                                                                   \
        for (sal_Int32 i = 0; i < parameterIndex; i++)                  \
            m_aParameterVisited.push_back(false);                       \
    }                                                                   \
    m_aParameterVisited[parameterIndex - 1] = true

//------------------------------------------------------------------------------
void SAL_CALL ODatabaseForm::setNull(sal_Int32 parameterIndex, sal_Int32 sqlType) throw( SQLException, RuntimeException )
{
    PARAMETER_VISITED(setNull(parameterIndex, sqlType));
}

//------------------------------------------------------------------------------
void SAL_CALL ODatabaseForm::setObjectNull(sal_Int32 parameterIndex, sal_Int32 sqlType, const ::rtl::OUString& typeName) throw( SQLException, RuntimeException )
{
    PARAMETER_VISITED(setObjectNull(parameterIndex, sqlType, typeName));
}

//------------------------------------------------------------------------------
void SAL_CALL ODatabaseForm::setBoolean(sal_Int32 parameterIndex, sal_Bool x) throw( SQLException, RuntimeException )
{
    PARAMETER_VISITED(setBoolean(parameterIndex, x));
}

//------------------------------------------------------------------------------
void SAL_CALL ODatabaseForm::setByte(sal_Int32 parameterIndex, sal_Int8 x) throw( SQLException, RuntimeException )
{
    PARAMETER_VISITED(setByte(parameterIndex, x));
}

//------------------------------------------------------------------------------
void SAL_CALL ODatabaseForm::setShort(sal_Int32 parameterIndex, sal_Int16 x) throw( SQLException, RuntimeException )
{
    PARAMETER_VISITED(setShort(parameterIndex, x));
}

//------------------------------------------------------------------------------
void SAL_CALL ODatabaseForm::setInt(sal_Int32 parameterIndex, sal_Int32 x) throw( SQLException, RuntimeException )
{
    PARAMETER_VISITED(setInt(parameterIndex, x));
}

//------------------------------------------------------------------------------
void SAL_CALL ODatabaseForm::setLong(sal_Int32 parameterIndex, sal_Int64 x) throw( SQLException, RuntimeException )
{
    PARAMETER_VISITED(setLong(parameterIndex, x));
}

//------------------------------------------------------------------------------
void SAL_CALL ODatabaseForm::setFloat(sal_Int32 parameterIndex, float x) throw( SQLException, RuntimeException )
{
    PARAMETER_VISITED(setFloat(parameterIndex, x));
}

//------------------------------------------------------------------------------
void SAL_CALL ODatabaseForm::setDouble(sal_Int32 parameterIndex, double x) throw( SQLException, RuntimeException )
{
    PARAMETER_VISITED(setDouble(parameterIndex, x));
}

//------------------------------------------------------------------------------
void SAL_CALL ODatabaseForm::setString(sal_Int32 parameterIndex, const ::rtl::OUString& x) throw( SQLException, RuntimeException )
{
    PARAMETER_VISITED(setString(parameterIndex, x));
}

//------------------------------------------------------------------------------
void SAL_CALL ODatabaseForm::setBytes(sal_Int32 parameterIndex, const Sequence< sal_Int8 >& x) throw( SQLException, RuntimeException )
{
    PARAMETER_VISITED(setBytes(parameterIndex, x));
}

//------------------------------------------------------------------------------
void SAL_CALL ODatabaseForm::setDate(sal_Int32 parameterIndex, const ::com::sun::star::util::Date& x) throw( SQLException, RuntimeException )
{
    PARAMETER_VISITED(setDate(parameterIndex, x));
}

//------------------------------------------------------------------------------
void SAL_CALL ODatabaseForm::setTime(sal_Int32 parameterIndex, const ::com::sun::star::util::Time& x) throw( SQLException, RuntimeException )
{
    PARAMETER_VISITED(setTime(parameterIndex, x));
}

//------------------------------------------------------------------------------
void SAL_CALL ODatabaseForm::setTimestamp(sal_Int32 parameterIndex, const ::com::sun::star::util::DateTime& x) throw( SQLException, RuntimeException )
{
    PARAMETER_VISITED(setTimestamp(parameterIndex, x));
}

//------------------------------------------------------------------------------
void SAL_CALL ODatabaseForm::setBinaryStream(sal_Int32 parameterIndex, const Reference<XInputStream>& x, sal_Int32 length) throw( SQLException, RuntimeException )
{
    PARAMETER_VISITED(setBinaryStream(parameterIndex, x, length));
}

//------------------------------------------------------------------------------
void SAL_CALL ODatabaseForm::setCharacterStream(sal_Int32 parameterIndex, const Reference<XInputStream>& x, sal_Int32 length) throw( SQLException, RuntimeException )
{
    PARAMETER_VISITED(setCharacterStream(parameterIndex, x, length));
}

//------------------------------------------------------------------------------
void SAL_CALL ODatabaseForm::setObjectWithInfo(sal_Int32 parameterIndex, const Any& x, sal_Int32 targetSqlType, sal_Int32 scale) throw( SQLException, RuntimeException )
{
    PARAMETER_VISITED(setObjectWithInfo(parameterIndex, x, targetSqlType, scale));
}

//------------------------------------------------------------------------------
void SAL_CALL ODatabaseForm::setObject(sal_Int32 parameterIndex, const Any& x) throw( SQLException, RuntimeException )
{
    PARAMETER_VISITED(setObject(parameterIndex, x));
}

//------------------------------------------------------------------------------
void SAL_CALL ODatabaseForm::setRef(sal_Int32 parameterIndex, const Reference<XRef>& x) throw( SQLException, RuntimeException )
{
    PARAMETER_VISITED(setRef(parameterIndex, x));
}

//------------------------------------------------------------------------------
void SAL_CALL ODatabaseForm::setBlob(sal_Int32 parameterIndex, const Reference<XBlob>& x) throw( SQLException, RuntimeException )
{
    PARAMETER_VISITED(setBlob(parameterIndex, x));
}

//------------------------------------------------------------------------------
void SAL_CALL ODatabaseForm::setClob(sal_Int32 parameterIndex, const Reference<XClob>& x) throw( SQLException, RuntimeException )
{
    PARAMETER_VISITED(setClob(parameterIndex, x));
}

//------------------------------------------------------------------------------
void SAL_CALL ODatabaseForm::setArray(sal_Int32 parameterIndex, const Reference<XArray>& x) throw( SQLException, RuntimeException )
{
    PARAMETER_VISITED(setArray(parameterIndex, x));
}

//------------------------------------------------------------------------------
void SAL_CALL ODatabaseForm::clearParameters() throw( SQLException, RuntimeException )
{
    ::osl::MutexGuard aGuard(m_aMutex);
    Reference<XParameters>  xParameters;
    if (query_aggregation(m_xAggregate, xParameters))
        xParameters->clearParameters();
    m_aParameterVisited.clear();
}

// com::sun::star::lang::XServiceInfo
//------------------------------------------------------------------------------
::rtl::OUString SAL_CALL ODatabaseForm::getImplementationName() throw( RuntimeException )
{
    return DATABASEFORM_IMPLEMENTATION_NAME;
}

//------------------------------------------------------------------------------
StringSequence SAL_CALL ODatabaseForm::getSupportedServiceNames() throw( RuntimeException )
{
    StringSequence aServices;
    Reference<com::sun::star::lang::XServiceInfo> xInfo;
    if (query_aggregation(m_xAggregate, xInfo))
        aServices = xInfo->getSupportedServiceNames();

    sal_Int32 nOldLen = aServices.getLength();
    aServices.realloc(nOldLen + 6);
    ::rtl::OUString* pAdditionalServices = aServices.getArray() + nOldLen;
    *pAdditionalServices++ = ::rtl::OUString::createFromAscii("com.sun.star.form.FormComponent");
    *pAdditionalServices++ = ::rtl::OUString::createFromAscii("com.sun.star.form.FormComponents");
    *pAdditionalServices++ = FRM_SUN_COMPONENT_FORM;
    *pAdditionalServices++ = FRM_SUN_COMPONENT_HTMLFORM;
    *pAdditionalServices++ = FRM_SUN_COMPONENT_DATAFORM;
    return aServices;
}

//------------------------------------------------------------------------------
sal_Bool SAL_CALL ODatabaseForm::supportsService(const ::rtl::OUString& ServiceName) throw( RuntimeException )
{
    StringSequence aSupported(getSupportedServiceNames());
    const ::rtl::OUString* pArray = aSupported.getConstArray();
    for( sal_Int32 i = 0; i < aSupported.getLength(); ++i, ++pArray )
        if( pArray->equals(ServiceName) )
            return sal_True;
    return sal_False;
}

//==============================================================================
// com::sun::star::io::XPersistObject
//------------------------------------------------------------------------------

const sal_uInt16 CYCLE              = 0x0001;
const sal_uInt16 DONTAPPLYFILTER    = 0x0002;

//------------------------------------------------------------------------------
::rtl::OUString ODatabaseForm::getServiceName() throw( RuntimeException )
{
    return FRM_COMPONENT_FORM;  // old (non-sun) name for compatibility !
}

//------------------------------------------------------------------------------
void SAL_CALL ODatabaseForm::write(const Reference<XObjectOutputStream>& _rxOutStream) throw( IOException, RuntimeException )
{
    DBG_ASSERT(m_xAggregateSet.is(), "ODatabaseForm::write : only to be called if the aggregate exists !");

    // all children
    OFormComponents::write(_rxOutStream);

    // version
    _rxOutStream->writeShort(0x0003);

    // Name
    _rxOutStream << m_sName;

    ::rtl::OUString sDataSource;
    if (m_xAggregateSet.is())
        m_xAggregateSet->getPropertyValue(PROPERTY_DATASOURCE) >>= sDataSource;
    _rxOutStream << sDataSource;

    // former CursorSource
    ::rtl::OUString sCommand;
    if (m_xAggregateSet.is())
        m_xAggregateSet->getPropertyValue(PROPERTY_COMMAND) >>= sCommand;
    _rxOutStream << sCommand;

    // former MasterFields
    _rxOutStream << m_aMasterFields;
    // former DetailFields
    _rxOutStream << m_aDetailFields;

    // former DataSelectionType
    DataSelectionType eTranslated = DataSelectionType_TABLE;
    if (m_xAggregateSet.is())
    {
        sal_Int32 nCommandType;
        m_xAggregateSet->getPropertyValue(PROPERTY_COMMANDTYPE) >>= nCommandType;
        switch (nCommandType)
        {
            case CommandType::TABLE : eTranslated = DataSelectionType_TABLE; break;
            case CommandType::QUERY : eTranslated = DataSelectionType_QUERY; break;
            case CommandType::COMMAND:
            {
                sal_Bool bEscapeProcessing = getBOOL(m_xAggregateSet->getPropertyValue(PROPERTY_ESCAPE_PROCESSING));
                eTranslated = bEscapeProcessing ? DataSelectionType_SQL : DataSelectionType_SQLPASSTHROUGH;
            }
            break;
            default : DBG_ERROR("ODatabaseForm::write : wrong CommandType !");
        }
    }
    _rxOutStream->writeShort((sal_Int16)eTranslated);           // former DataSelectionType

    // very old versions expect a CursorType here
    _rxOutStream->writeShort(DatabaseCursorType_KEYSET);

    _rxOutStream->writeBoolean(m_eNavigation != NavigationBarMode_NONE);

    // former DataEntry
    if (m_xAggregateSet.is())
        _rxOutStream->writeBoolean(getBOOL(m_xAggregateSet->getPropertyValue(PROPERTY_INSERTONLY)));
    else
        _rxOutStream->writeBoolean(sal_False);

    _rxOutStream->writeBoolean(m_bAllowInsert);
    _rxOutStream->writeBoolean(m_bAllowUpdate);
    _rxOutStream->writeBoolean(m_bAllowDelete);

    // html form stuff
    ::rtl::OUString sTmp = INetURLObject::decode(INetURLObject::AbsToRel( m_aTargetURL ), '%', INetURLObject::DECODE_UNAMBIGUOUS);
    _rxOutStream << sTmp;
    _rxOutStream->writeShort( (sal_Int16)m_eSubmitMethod );
    _rxOutStream->writeShort( (sal_Int16)m_eSubmitEncoding );
    _rxOutStream << m_aTargetFrame;

    // version 2 didn't know some options and the "default" state
    sal_Int32 nCycle = TabulatorCycle_RECORDS;
    if (m_aCycle.hasValue())
    {
        ::cppu::enum2int(nCycle, m_aCycle);
        if (m_aCycle == TabulatorCycle_PAGE)
                // unknown in earlier versions
            nCycle = TabulatorCycle_RECORDS;
    }
    _rxOutStream->writeShort((sal_Int16) nCycle);

    _rxOutStream->writeShort((sal_Int16)m_eNavigation);

    ::rtl::OUString sFilter;
    ::rtl::OUString sOrder;
    if (m_xAggregateSet.is())
    {
        m_xAggregateSet->getPropertyValue(PROPERTY_FILTER_CRITERIA) >>= sFilter;
        m_xAggregateSet->getPropertyValue(PROPERTY_SORT) >>= sOrder;
    }
    _rxOutStream << sFilter;
    _rxOutStream << sOrder;


    // version 3
    sal_uInt16 nAnyMask = 0;
    if (m_aCycle.hasValue())
        nAnyMask |= CYCLE;

    if (m_xAggregateSet.is() && !getBOOL(m_xAggregateSet->getPropertyValue(PROPERTY_APPLYFILTER)))
        nAnyMask |= DONTAPPLYFILTER;

    _rxOutStream->writeShort(nAnyMask);

    if (nAnyMask & CYCLE)
    {
        sal_Int32 nCycle;
        ::cppu::enum2int(nCycle, m_aCycle);
        _rxOutStream->writeShort((sal_Int16)nCycle);
    }
}

//------------------------------------------------------------------------------
void SAL_CALL ODatabaseForm::read(const Reference<XObjectInputStream>& _rxInStream) throw( IOException, RuntimeException )
{
    DBG_ASSERT(m_xAggregateSet.is(), "ODatabaseForm::read : only to be called if the aggregate exists !");

    OFormComponents::read(_rxInStream);

    // version
    sal_uInt16 nVersion = _rxInStream->readShort();

    _rxInStream >> m_sName;

    ::rtl::OUString sAggregateProp;
    _rxInStream >> sAggregateProp;
    if (m_xAggregateSet.is())
        m_xAggregateSet->setPropertyValue(PROPERTY_DATASOURCE, makeAny(sAggregateProp));
    _rxInStream >> sAggregateProp;
    if (m_xAggregateSet.is())
        m_xAggregateSet->setPropertyValue(PROPERTY_COMMAND, makeAny(sAggregateProp));

    _rxInStream >> m_aMasterFields;
    _rxInStream >> m_aDetailFields;

    sal_Int16 nCursorSourceType = _rxInStream->readShort();
    sal_Int32 nCommandType = 0;
    switch ((DataSelectionType)nCursorSourceType)
    {
        case DataSelectionType_TABLE : nCommandType = CommandType::TABLE; break;
        case DataSelectionType_QUERY : nCommandType = CommandType::QUERY; break;
        case DataSelectionType_SQL:
        case DataSelectionType_SQLPASSTHROUGH:
        {
            nCommandType = CommandType::COMMAND;
            sal_Bool bEscapeProcessing = ((DataSelectionType)nCursorSourceType) != DataSelectionType_SQLPASSTHROUGH;
            m_xAggregateSet->setPropertyValue(PROPERTY_ESCAPE_PROCESSING, makeAny((sal_Bool)bEscapeProcessing));
        }
        break;
        default : DBG_ERROR("ODatabaseForm::read : wrong CommandType !");
    }
    if (m_xAggregateSet.is())
        m_xAggregateSet->setPropertyValue(PROPERTY_COMMANDTYPE, makeAny(nCommandType));

    // obsolete
    sal_Int16 nDummy = _rxInStream->readShort();

    // navigation mode was a boolean in version 1
    // war in der version 1 ein sal_Bool
    sal_Bool bNavigation = _rxInStream->readBoolean();
    if (nVersion == 1)
        m_eNavigation = bNavigation ? NavigationBarMode_CURRENT : NavigationBarMode_NONE;

    sal_Bool bInsertOnly = _rxInStream->readBoolean();
    if (m_xAggregateSet.is())
        m_xAggregateSet->setPropertyValue(PROPERTY_INSERTONLY, makeAny(bInsertOnly));

    m_bAllowInsert      = _rxInStream->readBoolean();
    m_bAllowUpdate      = _rxInStream->readBoolean();
    m_bAllowDelete      = _rxInStream->readBoolean();

    // html stuff
    ::rtl::OUString sTmp;
    _rxInStream >> sTmp;
    m_aTargetURL = INetURLObject::decode(INetURLObject::RelToAbs( sTmp ), '%', INetURLObject::DECODE_UNAMBIGUOUS);
    m_eSubmitMethod     = (FormSubmitMethod)_rxInStream->readShort();
    m_eSubmitEncoding       = (FormSubmitEncoding)_rxInStream->readShort();
    _rxInStream >> m_aTargetFrame;

    if (nVersion > 1)
    {
        sal_Int32 nCycle = _rxInStream->readShort();
        m_aCycle = ::cppu::int2enum(nCycle, ::getCppuType(static_cast<const TabulatorCycle*>(NULL)));
        m_eNavigation = (NavigationBarMode)_rxInStream->readShort();

        _rxInStream >> sAggregateProp;
        if (m_xAggregateSet.is())
            m_xAggregateSet->setPropertyValue(PROPERTY_FILTER_CRITERIA, makeAny(sAggregateProp));
        _rxInStream >> sAggregateProp;
        if (m_xAggregateSet.is())
            m_xAggregateSet->setPropertyValue(PROPERTY_SORT, makeAny(sAggregateProp));
    }

    sal_uInt16 nAnyMask = 0;
    if (nVersion > 2)
    {
        nAnyMask = _rxInStream->readShort();
        if (nAnyMask & CYCLE)
        {
            sal_Int32 nCycle = _rxInStream->readShort();
            m_aCycle = ::cppu::int2enum(nCycle, ::getCppuType(static_cast<const TabulatorCycle*>(NULL)));
        }
        else
            m_aCycle.clear();
    }
    if (m_xAggregateSet.is())
        m_xAggregateSet->setPropertyValue(PROPERTY_APPLYFILTER, makeAny((sal_Bool)((nAnyMask & DONTAPPLYFILTER) == 0)));
}

//------------------------------------------------------------------------------
void ODatabaseForm::implInserted(const InterfaceRef& _rxObject)
{
    OFormComponents::implInserted( _rxObject );

    Reference<XSQLErrorBroadcaster>  xBroadcaster(_rxObject, UNO_QUERY);
    Reference<XForm>  xForm(_rxObject, UNO_QUERY);
    if (xBroadcaster.is() && !xForm.is())
    {   // the object is an error broadcaster, but no form itself -> add ourself as listener
        xBroadcaster->addSQLErrorListener(this);
    }
}

//------------------------------------------------------------------------------
void ODatabaseForm::implRemoved(const InterfaceRef& _rxObject)
{
    OFormComponents::implRemoved( _rxObject );

    Reference<XSQLErrorBroadcaster>  xBroadcaster(_rxObject, UNO_QUERY);
    Reference<XForm>  xForm(_rxObject, UNO_QUERY);
    if (xBroadcaster.is() && !xForm.is())
    {   // the object is an error broadcaster, but no form itself -> remove ourself as listener
        xBroadcaster->removeSQLErrorListener(this);
    }
}

//------------------------------------------------------------------------------
void SAL_CALL ODatabaseForm::errorOccured(const SQLErrorEvent& _rEvent) throw( RuntimeException )
{
    // give it to my own error listener
    onError(_rEvent);
    // TODO : think about extending the chain with an SQLContext object saying
    // "this was an error of one of my children"
}

// com::sun::star::container::XNamed
//------------------------------------------------------------------------------
::rtl::OUString SAL_CALL ODatabaseForm::getName() throw( RuntimeException )
{
    ::rtl::OUString sReturn;
    OPropertySetHelper::getFastPropertyValue(PROPERTY_ID_NAME) >>= sReturn;
    return sReturn;
}

//------------------------------------------------------------------------------
void SAL_CALL ODatabaseForm::setName(const ::rtl::OUString& aName) throw( RuntimeException )
{
    setFastPropertyValue(PROPERTY_ID_NAME, makeAny(aName));
}

//.........................................................................
}   // namespace frm
//.........................................................................