summaryrefslogtreecommitdiff
path: root/svx/source/form/fmtools.cxx
blob: 659f1c1127d14cc1045af8544f0a49cb2aa9dd75 (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
/*************************************************************************
 *
 *  $RCSfile: fmtools.cxx,v $
 *
 *  $Revision: 1.25 $
 *
 *  last change: $Author: fs $ $Date: 2002-10-14 13:50:03 $
 *
 *  The Contents of this file are made available subject to the terms of
 *  either of the following licenses
 *
 *         - GNU Lesser General Public License Version 2.1
 *         - Sun Industry Standards Source License Version 1.1
 *
 *  Sun Microsystems Inc., October, 2000
 *
 *  GNU Lesser General Public License Version 2.1
 *  =============================================
 *  Copyright 2000 by Sun Microsystems, Inc.
 *  901 San Antonio Road, Palo Alto, CA 94303, USA
 *
 *  This library is free software; you can redistribute it and/or
 *  modify it under the terms of the GNU Lesser General Public
 *  License version 2.1, as published by the Free Software Foundation.
 *
 *  This library is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 *  Lesser General Public License for more details.
 *
 *  You should have received a copy of the GNU Lesser General Public
 *  License along with this library; if not, write to the Free Software
 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston,
 *  MA  02111-1307  USA
 *
 *
 *  Sun Industry Standards Source License Version 1.1
 *  =================================================
 *  The contents of this file are subject to the Sun Industry Standards
 *  Source License Version 1.1 (the "License"); You may not use this file
 *  except in compliance with the License. You may obtain a copy of the
 *  License at http://www.openoffice.org/license.html.
 *
 *  Software provided under this License is provided on an "AS IS" basis,
 *  WITHOUT WARRANTY OF ANY KIND, EITHER 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): _______________________________________
 *
 *
 ************************************************************************/
#pragma hdrstop

#ifndef _COM_SUN_STAR_LANG_XSERVICEINFO_HPP_
#include <com/sun/star/lang/XServiceInfo.hpp>
#endif
#ifndef _COM_SUN_STAR_IO_XPERSISTOBJECT_HPP_
#include <com/sun/star/io/XPersistObject.hpp>
#endif
#ifndef _COM_SUN_STAR_UI_DIALOGS_XEXECUTABLEDIALOG_HPP_
#include <com/sun/star/ui/dialogs/XExecutableDialog.hpp>
#endif
#ifndef _COM_SUN_STAR_SDB_XCOMPLETEDCONNECTION_HPP_
#include <com/sun/star/sdb/XCompletedConnection.hpp>
#endif
#ifndef _COM_SUN_STAR_SDBCX_PRIVILEGE_HPP_
#include <com/sun/star/sdbcx/Privilege.hpp>
#endif
#ifndef _ISOLANG_HXX
#include <tools/isolang.hxx>
#endif
#ifndef _COM_SUN_STAR_LANG_LOCALE_HPP_
#include <com/sun/star/lang/Locale.hpp>
#endif
#ifndef _SVX_FMTOOLS_HXX
#include "fmtools.hxx"
#endif
#ifndef SVX_DBTOOLSCLIENT_HXX
#include "dbtoolsclient.hxx"
#endif
#ifndef _SVX_FMSERVS_HXX
#include "fmservs.hxx"
#endif
#ifndef _SVX_FMGLOB_HXX
#include "fmglob.hxx"
#endif
#ifndef _VCL_STDTEXT_HXX
#include <vcl/stdtext.hxx>
#endif
#ifndef _TOOLKIT_HELPER_VCLUNOHELPER_HXX_
#include <toolkit/unohlp.hxx>
#endif

#include <stdlib.h>
#include <stdio.h>
#include <wchar.h>

#ifndef _COM_SUN_STAR_UNO_XNAMINGSERVICE_HPP_
#include <com/sun/star/uno/XNamingService.hpp>
#endif
#ifndef _COM_SUN_STAR_SDBC_XDATASOURCE_HPP_
#include <com/sun/star/sdbc/XDataSource.hpp>
#endif
#ifndef _COM_SUN_STAR_SDB_COMMANDTYPE_HPP_
#include <com/sun/star/sdb/CommandType.hpp>
#endif
#ifndef _COM_SUN_STAR_SDB_XQUERIESSUPPLIER_HPP_
#include <com/sun/star/sdb/XQueriesSupplier.hpp>
#endif
#ifndef _COM_SUN_STAR_SDB_SQLCONTEXT_HPP_
#include <com/sun/star/sdb/SQLContext.hpp>
#endif
#ifndef _COM_SUN_STAR_SDBCX_XTABLESSUPPLIER_HPP_
#include <com/sun/star/sdbcx/XTablesSupplier.hpp>
#endif
#ifndef _COM_SUN_STAR_SDB_XRESULTSETACCESS_HPP_
#include <com/sun/star/sdb/XResultSetAccess.hpp>
#endif
#ifndef _COM_SUN_STAR_SDBC_DATATYPE_HPP_
#include <com/sun/star/sdbc/DataType.hpp>
#endif

#ifndef _COM_SUN_STAR_UTIL_NUMBERFORMAT_HPP_
#include <com/sun/star/util/NumberFormat.hpp>
#endif
#ifndef _COM_SUN_STAR_IO_XACTIVEDATASINK_HPP_
#include <com/sun/star/io/XActiveDataSink.hpp>
#endif
#ifndef _COM_SUN_STAR_IO_XACTIVEDATASOURCE_HPP_
#include <com/sun/star/io/XActiveDataSource.hpp>
#endif
#ifndef _COM_SUN_STAR_SCRIPT_XEVENTATTACHERMANAGER_HPP_
#include <com/sun/star/script/XEventAttacherManager.hpp>
#endif
#ifndef _COM_SUN_STAR_FORM_XFORM_HPP_
#include <com/sun/star/form/XForm.hpp>
#endif
#ifndef _COM_SUN_STAR_FORM_XFORMCOMPONENT_HPP_
#include <com/sun/star/form/XFormComponent.hpp>
#endif
#ifndef _COM_SUN_STAR_UTIL_XNUMBERFORMATTER_HPP_
#include <com/sun/star/util/XNumberFormatter.hpp>
#endif
#ifndef _COM_SUN_STAR_UTIL_XNUMBERFORMATSSUPPLIER_HPP_
#include <com/sun/star/util/XNumberFormatsSupplier.hpp>
#endif
#ifndef _COM_SUN_STAR_UTIL_LANGUAGE_HPP_
#include <com/sun/star/util/Language.hpp>
#endif
#ifndef _COM_SUN_STAR_UTIL_XNUMBERFORMATS_HPP_
#include <com/sun/star/util/XNumberFormats.hpp>
#endif
#ifndef _COM_SUN_STAR_UTIL_XNUMBERFORMATTYPES_HPP_
#include <com/sun/star/util/XNumberFormatTypes.hpp>
#endif
#ifndef _COM_SUN_STAR_UTIL_XCLONEABLE_HPP_
#include <com/sun/star/util/XCloneable.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_REFLECTION_XIDLCLASS_HPP_
#include <com/sun/star/reflection/XIdlClass.hpp>
#endif
#ifndef _COM_SUN_STAR_REFLECTION_XIDLMETHOD_HPP_
#include <com/sun/star/reflection/XIdlMethod.hpp>
#endif
#ifndef _COM_SUN_STAR_BEANS_XINTROSPECTION_HPP_
#include <com/sun/star/beans/XIntrospection.hpp>
#endif
#ifndef _COM_SUN_STAR_BEANS_PROPERTYATTRIBUTE_HPP_
#include <com/sun/star/beans/PropertyAttribute.hpp>
#endif
#ifndef _COM_SUN_STAR_CONTAINER_XCHILD_HPP_
#include <com/sun/star/container/XChild.hpp>
#endif
#ifndef _COM_SUN_STAR_TASK_XINTERACTIONHANDLER_HPP_
#include <com/sun/star/task/XInteractionHandler.hpp>
#endif

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

#ifndef _STRING_HXX
#include <tools/string.hxx>
#endif

#ifndef _SBXVAR_HXX //autogen
#include <svtools/sbxvar.hxx>
#endif

#ifndef _TOOLS_SOLMATH_HXX //autogen wg. SolarMath
#include <tools/solmath.hxx>
#endif

#ifndef _SV_SVAPP_HXX //autogen
#include <vcl/svapp.hxx>
#endif

#ifndef _INTN_HXX //autogen
#include <tools/intn.hxx>
#endif

#ifndef _SVX_FMPROP_HRC
#include "fmprop.hrc"
#endif

#ifndef _SFX_BINDINGS_HXX //autogen wg. SfxBindings
#include <sfx2/bindings.hxx>
#endif

#ifndef _SFXENUMITEM_HXX //autogen wg. SfxBoolItem
#include <svtools/eitem.hxx>
#endif

#ifndef _SFXSTRITEM_HXX //autogen wg. SfxStringItem
#include <svtools/stritem.hxx>
#endif

#ifndef _CPPUHELPER_SERVICEFACTORY_HXX_
#include <cppuhelper/servicefactory.hxx>
#endif
#ifndef _COMPHELPER_TYPES_HXX_
#include <comphelper/types.hxx>
#endif
#ifndef _COMPHELPER_PROPERTY_HXX_
#include <comphelper/property.hxx>
#endif
#ifndef _COMPHELPER_CONTAINER_HXX_
#include <comphelper/container.hxx>
#endif
#ifndef _CONNECTIVITY_DBTOOLS_HXX_
#include <connectivity/dbtools.hxx>
#endif
#ifndef _COMPHELPER_PROCESSFACTORY_HXX_
#include <comphelper/processfactory.hxx>
#endif
#ifndef _COMPHELPER_SEQUENCE_HXX_
#include <comphelper/sequence.hxx>
#endif
#ifndef _FM_STATIC_HXX_
#include "fmstatic.hxx"
#endif
#ifndef _COMPHELPER_EXTRACT_HXX_
#include <comphelper/extract.hxx>
#endif
#ifndef _COMPHELPER_UNO3_HXX_
#include <comphelper/uno3.hxx>
#endif
#ifndef _DBHELPER_DBEXCEPTION_HXX_
#include <connectivity/dbexception.hxx>
#endif
#ifndef _COMPHELPER_EXTRACT_HXX_
#include <comphelper/extract.hxx>
#endif

namespace svxform
{

    IMPLEMENT_CONSTASCII_USTRING(DATA_MODE,"DataMode");
    IMPLEMENT_CONSTASCII_USTRING(FILTER_MODE,"FilterMode");

}   // namespace svxform

using namespace ::com::sun::star::uno;
using namespace ::com::sun::star::util;
using namespace ::com::sun::star::lang;
using namespace ::com::sun::star::frame;
using namespace ::com::sun::star::awt;
using namespace ::com::sun::star::beans;
using namespace ::com::sun::star::container;
using namespace ::com::sun::star::ui::dialogs;
using namespace ::com::sun::star::sdbc;
using namespace ::com::sun::star::sdbcx;
using namespace ::com::sun::star::sdb;
using namespace ::com::sun::star::task;
using namespace ::svxform;
using namespace ::connectivity::simple;

//  ------------------------------------------------------------------------------
void displayException(const Any& _rExcept, Window* _pParent = NULL)
{
    try
    {
        // the parent window
        Window* pParentWindow = _pParent ? _pParent : GetpApp()->GetDefDialogParent();
        Reference< XWindow > xParentWindow = VCLUnoHelper::GetInterface(pParentWindow);

        Sequence< Any > aArgs(2);
        aArgs[0] <<= PropertyValue(::rtl::OUString::createFromAscii("SQLException"), 0, makeAny(_rExcept), PropertyState_DIRECT_VALUE);
        aArgs[1] <<= PropertyValue(::rtl::OUString::createFromAscii("ParentWindow"), 0, makeAny(xParentWindow), PropertyState_DIRECT_VALUE);

        static ::rtl::OUString s_sDialogServiceName = ::rtl::OUString::createFromAscii("com.sun.star.sdb.ErrorMessageDialog");
        Reference< XExecutableDialog > xErrorDialog(
            ::comphelper::getProcessServiceFactory()->createInstanceWithArguments(s_sDialogServiceName, aArgs), UNO_QUERY);
        if (xErrorDialog.is())
            xErrorDialog->execute();
        else
            ShowServiceNotAvailableError(pParentWindow, s_sDialogServiceName, sal_True);
    }
    catch(Exception&)
    {
        OSL_ENSURE(sal_False, "displayException: could not display the error message!");
    }
}

//  ------------------------------------------------------------------------------
void displayException(const ::com::sun::star::sdbc::SQLException& _rExcept, Window* _pParent)
{
    displayException(makeAny(_rExcept), _pParent);
}

//  ------------------------------------------------------------------------------
void displayException(const ::com::sun::star::sdbc::SQLWarning& _rExcept, Window* _pParent)
{
    displayException(makeAny(_rExcept), _pParent);
}

//  ------------------------------------------------------------------------------
void displayException(const ::com::sun::star::sdb::SQLContext& _rExcept, Window* _pParent)
{
    displayException(makeAny(_rExcept), _pParent);
}

//  ------------------------------------------------------------------------------
void displayException(const ::com::sun::star::sdb::SQLErrorEvent& _rEvent, Window* _pParent)
{
    displayException(_rEvent.Reason, _pParent);
}

//------------------------------------------------------------------------------
// Vergleichen von Properties
extern "C" int
#if defined( WNT )
 __cdecl
#endif
#if defined( ICC ) && defined( OS2 )
_Optlink
#endif
    PropertyCompare( const void* pFirst, const void* pSecond)
{
    return ((::com::sun::star::beans::Property*)pFirst)->Name.compareTo(((::com::sun::star::beans::Property*)pSecond)->Name);
}

//------------------------------------------------------------------------------
Reference< XInterface> clone(const Reference< ::com::sun::star::io::XPersistObject>& _xObj)
{
    Reference< XInterface> xClone;
    if (!_xObj.is())
        return Reference< XInterface>();

    // ::std::copy it by streaming

    // creating a pipe
    Reference< ::com::sun::star::io::XOutputStream> xOutPipe(::comphelper::getProcessServiceFactory()->createInstance(::rtl::OUString::createFromAscii("com.sun.star.io.Pipe")), UNO_QUERY);
    Reference< ::com::sun::star::io::XInputStream> xInPipe(xOutPipe, UNO_QUERY);

    // creating the mark streams
    Reference< ::com::sun::star::io::XInputStream> xMarkIn(::comphelper::getProcessServiceFactory()->createInstance(::rtl::OUString::createFromAscii("com.sun.star.io.MarkableInputStream")), UNO_QUERY);
    Reference< ::com::sun::star::io::XActiveDataSink> xMarkSink(xMarkIn, UNO_QUERY);
    xMarkSink->setInputStream(xInPipe);

    Reference< ::com::sun::star::io::XOutputStream> xMarkOut(::comphelper::getProcessServiceFactory()->createInstance(::rtl::OUString::createFromAscii("com.sun.star.io.MarkableOutputStream")), UNO_QUERY);
    Reference< ::com::sun::star::io::XActiveDataSource> xMarkSource(xMarkOut, UNO_QUERY);
    xMarkSource->setOutputStream(xOutPipe);

    // connect mark and sink
    Reference< ::com::sun::star::io::XActiveDataSink> xSink(::comphelper::getProcessServiceFactory()->createInstance(::rtl::OUString::createFromAscii("com.sun.star.io.ObjectInputStream")), UNO_QUERY);
    xSink->setInputStream(xMarkIn);

    // connect mark and source
    Reference< ::com::sun::star::io::XActiveDataSource> xSource(::comphelper::getProcessServiceFactory()->createInstance(::rtl::OUString::createFromAscii("com.sun.star.io.ObjectOutputStream")), UNO_QUERY);
    xSource->setOutputStream(xMarkOut);

    // write the string to source
    Reference< ::com::sun::star::io::XObjectOutputStream> xOutStrm(xSource, UNO_QUERY);
    xOutStrm->writeObject(_xObj);
    xOutStrm->closeOutput();

    Reference< ::com::sun::star::io::XObjectInputStream> xInStrm(xSink, UNO_QUERY);
    xClone = xInStrm->readObject();
    xInStrm->closeInput();

    return xClone;
}

//------------------------------------------------------------------------------
Reference< XInterface> cloneUsingProperties(const Reference< ::com::sun::star::io::XPersistObject>& _xObj)
{
    if (!_xObj.is())
        return Reference< XInterface>();

    // create a new object
    ::rtl::OUString aObjectService = _xObj->getServiceName();
    Reference< ::com::sun::star::beans::XPropertySet> xDestSet(::comphelper::getProcessServiceFactory()->createInstance(aObjectService), UNO_QUERY);
    if (!xDestSet.is())
    {
        DBG_ERROR("cloneUsingProperties : could not instantiate an object of the given type !");
        return Reference< XInterface>();
    }
    // transfer properties
    Reference< ::com::sun::star::beans::XPropertySet> xSourceSet(_xObj, UNO_QUERY);
    Reference< ::com::sun::star::beans::XPropertySetInfo> xSourceInfo( xSourceSet->getPropertySetInfo());
    Sequence< ::com::sun::star::beans::Property> aSourceProperties = xSourceInfo->getProperties();
    Reference< ::com::sun::star::beans::XPropertySetInfo> xDestInfo( xDestSet->getPropertySetInfo());
    Sequence< ::com::sun::star::beans::Property> aDestProperties = xDestInfo->getProperties();
    int nDestLen = aDestProperties.getLength();

    ::com::sun::star::beans::Property* pSourceProps = aSourceProperties.getArray();
    ::com::sun::star::beans::Property* pDestProps = aDestProperties.getArray();

    for (sal_Int16 i=0; i<aSourceProperties.getLength(); ++i)
    {
        ::com::sun::star::beans::Property* pResult = (::com::sun::star::beans::Property*) bsearch(pSourceProps + i, (void*)pDestProps, nDestLen, sizeof(::com::sun::star::beans::Property),
            &PropertyCompare);
        if  (   pResult
            &&  (pResult->Attributes == pSourceProps[i].Attributes)
            &&  ((pResult->Attributes &  ::com::sun::star::beans::PropertyAttribute::READONLY) == 0)
            &&  (pResult->Type.equals(pSourceProps[i].Type))
            )
        {   // Attribute/type are the same and the prop isn't readonly
            try
            {
                xDestSet->setPropertyValue(pResult->Name, xSourceSet->getPropertyValue(pResult->Name));
            }
            catch(::com::sun::star::lang::IllegalArgumentException e)
            {
                e;
#ifdef DBG_UTIL
                ::rtl::OString sMessage("cloneUsingProperties : could not transfer the value for property \"");
                sMessage = sMessage + ::rtl::OString(pResult->Name.getStr(), pResult->Name.getLength(), RTL_TEXTENCODING_ASCII_US);
                sMessage = sMessage + '\"';
                DBG_ERROR(sMessage);
#endif
            }

        }
    }

    return xDestSet;
}

//------------------------------------------------------------------------------
void CloneForms(const Reference< ::com::sun::star::container::XIndexContainer>& _xSource, const Reference< ::com::sun::star::container::XIndexContainer>& _xDest)
{
    DBG_ASSERT(_xSource.is() && _xDest.is(), "CloneForms : invalid argument !");

    sal_Int32 nSourceCount = _xSource->getCount();
    Reference< ::com::sun::star::sdbc::XRowSet> xCurrent;
    for (sal_Int32 i=nSourceCount-1; i>=0; --i)
    {
        _xSource->getByIndex(i) >>= xCurrent;
        if (!xCurrent.is())
            continue;

        Reference< ::com::sun::star::io::XPersistObject> xCurrentPersist(xCurrent, UNO_QUERY);
        DBG_ASSERT(xCurrentPersist.is(), "CloneForms : a form should always be a PersistObject !");

        // don't use a simple clone on xCurrentPersist as this would clone all childs, too
        Reference< XInterface> xNewObject( cloneUsingProperties(xCurrentPersist));
        Reference< ::com::sun::star::sdbc::XRowSet> xNew(xNewObject, UNO_QUERY);
        if (!xNew.is())
        {
            DBG_ERROR("CloneForms : could not clone a form object !");
            ::comphelper::disposeComponent(xNewObject);
            continue;
        }
        _xDest->insertByIndex(0, makeAny(xNew));

        Reference< ::com::sun::star::container::XIndexContainer> xStepIntoSource(xCurrent, UNO_QUERY);
        Reference< ::com::sun::star::container::XIndexContainer> xStepIntoDest(xNew, UNO_QUERY);
        if (xStepIntoSource.is() && xStepIntoDest.is())
            CloneForms(xStepIntoSource, xStepIntoDest);
    }
}

//------------------------------------------------------------------------------
sal_Bool searchElement(const Reference< ::com::sun::star::container::XIndexAccess>& xCont, const Reference< XInterface>& xElement)
{
    if (!xCont.is() || !xElement.is())
        return sal_False;

    sal_Int32 nCount = xCont->getCount();
    Reference< XInterface> xComp;
    for (sal_Int32 i = 0; i < nCount; i++)
    {
        try
        {
            xCont->getByIndex(i) >>= xComp;
            if (xComp.is())
            {
                if (((XInterface *)xElement.get()) == (XInterface*)xComp.get())
                    return sal_True;
                else
                {
                    Reference< ::com::sun::star::container::XIndexAccess> xCont2(xComp, UNO_QUERY);
                    if (xCont2.is() && searchElement(xCont2, xElement))
                        return sal_True;
                }
            }
        }
        catch(Exception&)
        {
        }
    }
    return sal_False;
}

//------------------------------------------------------------------------------
sal_Int32 getElementPos(const Reference< ::com::sun::star::container::XIndexAccess>& xCont, const Reference< XInterface>& xElement)
{
    sal_Int32 nIndex = -1;
    if (!xCont.is())
        return nIndex;


    Reference< XInterface > xNormalized( xElement, UNO_QUERY );
    DBG_ASSERT( xNormalized.is(), "getElementPos: invalid element!" );
    if ( xNormalized.is() )
    {
        // Feststellen an welcher Position sich das Kind befindet
        nIndex = xCont->getCount();
        while (nIndex--)
        {
            try
            {
                Reference< XInterface > xCurrent;
                xCont->getByIndex( nIndex ) >>= xCurrent;
                DBG_ASSERT( xCurrent.get() == Reference< XInterface >( xCurrent, UNO_QUERY ).get(),
                    "getElementPos: container element not normalized!" );
                if ( xNormalized.get() == xCurrent.get() )
                    break;
            }
            catch(Exception&)
            {
                DBG_ERROR( "getElementPos: caught an exception!" );
            }

        }
    }
    return nIndex;
}

//------------------------------------------------------------------
String getFormComponentAccessPath(const Reference< XInterface>& _xElement, Reference< XInterface>& _rTopLevelElement)
{
    Reference< ::com::sun::star::form::XFormComponent> xChild(_xElement, UNO_QUERY);
    Reference< ::com::sun::star::container::XIndexAccess> xParent;
    if (xChild.is())
        xParent = Reference< ::com::sun::star::container::XIndexAccess>(xChild->getParent(), UNO_QUERY);

    // while the current content is a form
    String sReturn;
    String sCurrentIndex;
    while (xChild.is())
    {
        // get the content's relative pos within it's parent container
        sal_Int32 nPos = getElementPos(xParent, xChild);

        // prepend this current relaive pos
        sCurrentIndex = String::CreateFromInt32(nPos);
        if (sReturn.Len() != 0)
        {
            sCurrentIndex += '\\';
            sCurrentIndex += sReturn;
        }

        sReturn = sCurrentIndex;

        // travel up
        if (::comphelper::query_interface((Reference< XInterface >)xParent,xChild))
            xParent = Reference< ::com::sun::star::container::XIndexAccess>(xChild->getParent(), UNO_QUERY);
    }

    _rTopLevelElement = xParent;
    return sReturn;
}

//------------------------------------------------------------------
String getFormComponentAccessPath(const Reference< XInterface>& _xElement)
{
    Reference< XInterface> xDummy;
    return getFormComponentAccessPath(_xElement, xDummy);
}

//------------------------------------------------------------------------------
Reference< XInterface> getElementFromAccessPath(const Reference< ::com::sun::star::container::XIndexAccess>& _xParent, const String& _rRelativePath)
{
    if (!_xParent.is())
        return Reference< XInterface>();
    Reference< ::com::sun::star::container::XIndexAccess> xContainer(_xParent);
    Reference< XInterface> xElement( _xParent);

    String sPath(_rRelativePath);
    while (sPath.Len() && xContainer.is())
    {
        xub_StrLen nSepPos = sPath.Search((sal_Unicode)'\\');

        String sIndex(sPath.Copy(0, (nSepPos == STRING_NOTFOUND) ? sPath.Len() : nSepPos));
        //  DBG_ASSERT(sIndex.IsNumeric(), "getElementFromAccessPath : invalid path !");

        sPath = sPath.Copy((nSepPos == STRING_NOTFOUND) ? sPath.Len() : nSepPos+1);

        ::cppu::extractInterface(xElement, xContainer->getByIndex(sIndex.ToInt32()));
        xContainer = Reference< ::com::sun::star::container::XIndexAccess>::query(xElement);
    }

    if (sPath.Len() != 0)
        // the loop terminated because an element wasn't a container, but we stil have a path -> the path is invalid
        xElement = NULL;

    return xElement;
}

//------------------------------------------------------------------
// Vergleichen von PropertyInfo
extern "C" int
#if defined( WNT )
 __cdecl
#endif
#if defined( ICC ) && defined( OS2 )
_Optlink
#endif
    NameCompare(const void* pFirst, const void* pSecond)
{
    return ((::rtl::OUString*)pFirst)->compareTo(*(::rtl::OUString*)pSecond);
}

//------------------------------------------------------------------------------
sal_Bool hasString(const ::rtl::OUString& aStr, const Sequence< ::rtl::OUString>& rList)
{
    const ::rtl::OUString* pStrList = rList.getConstArray();
    ::rtl::OUString* pResult = (::rtl::OUString*) bsearch(&aStr, (void*)pStrList, rList.getLength(), sizeof(::rtl::OUString),
        &NameCompare);

    return pResult != NULL;
}

//------------------------------------------------------------------------------
sal_Int32 findPos(const ::rtl::OUString& aStr, const Sequence< ::rtl::OUString>& rList)
{
    const ::rtl::OUString* pStrList = rList.getConstArray();
    ::rtl::OUString* pResult = (::rtl::OUString*) bsearch(&aStr, (void*)pStrList, rList.getLength(), sizeof(::rtl::OUString),
        &NameCompare);

    if (pResult)
        return (pResult - pStrList);
    else
        return -1;
}

//------------------------------------------------------------------
void ModifyPropertyAttributes(Sequence< ::com::sun::star::beans::Property>& seqProps, const ::rtl::OUString& ustrPropName, sal_Int16 nAddAttrib, sal_Int16 nRemoveAttrib)
{
    sal_Int32 nLen = seqProps.getLength();

    // binaere Suche
    Type type;
    ::com::sun::star::beans::Property propSearchDummy(ustrPropName, 0, type, 0);
    ::com::sun::star::beans::Property* pResult = (::com::sun::star::beans::Property*) bsearch(&propSearchDummy, (void*)seqProps.getArray(), nLen, sizeof(::com::sun::star::beans::Property),
        &PropertyCompare);

    // gefunden ?
    if (pResult)
    {
        pResult->Attributes |= nAddAttrib;
        pResult->Attributes &= ~nRemoveAttrib;
    }
}

//------------------------------------------------------------------
void RemoveProperty(Sequence< ::com::sun::star::beans::Property>& seqProps, const ::rtl::OUString& ustrPropName)
{
    sal_Int32 nLen = seqProps.getLength();

    // binaere Suche
    Type type;
    ::com::sun::star::beans::Property propSearchDummy(ustrPropName, 0, type, 0);
    const ::com::sun::star::beans::Property* pProperties = seqProps.getConstArray();
    ::com::sun::star::beans::Property* pResult = (::com::sun::star::beans::Property*) bsearch(&propSearchDummy, (void*)pProperties, nLen, sizeof(::com::sun::star::beans::Property),
        &PropertyCompare);

    // gefunden ?
    if (pResult)
    {
        DBG_ASSERT(pResult->Name == ustrPropName, "::RemoveProperty Properties nicht sortiert");
        ::comphelper::removeElementAt(seqProps, pResult - pProperties);
    }
}

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

//------------------------------------------------------------------
::rtl::OUString getLabelName(const Reference< ::com::sun::star::beans::XPropertySet>& xControlModel)
{
    if (!xControlModel.is())
        return ::rtl::OUString();

    if (::comphelper::hasProperty(FM_PROP_CONTROLLABEL, xControlModel))
    {
        Reference< ::com::sun::star::beans::XPropertySet> xLabelSet;
        xControlModel->getPropertyValue(FM_PROP_CONTROLLABEL) >>= xLabelSet;
        if (xLabelSet.is() && ::comphelper::hasProperty(FM_PROP_LABEL, xLabelSet))
        {
            Any aLabel( xLabelSet->getPropertyValue(FM_PROP_LABEL) );
            if ((aLabel.getValueTypeClass() == TypeClass_STRING) && ::comphelper::getString(aLabel).getLength())
                return ::comphelper::getString(aLabel);
        }
    }

    return ::comphelper::getString(xControlModel->getPropertyValue(FM_PROP_CONTROLSOURCE));
}



//------------------------------------------------------------------
//sal_Bool set_impl(Reflection* pRefl, void* pData, const Any& rValue)
//{
//  sal_Bool bRes = sal_True;
//  void* pConv = TypeConversion::to(pRefl, rValue);
//
//  if (!pConv && pRefl->getTypeClass() != TypeClass_ANY)
//      bRes = pRefl->getTypeClass() == TypeClass_VOID;
//  else
//  {
//      switch (pRefl->getTypeClass())
//      {
//          case TypeClass_BOOLEAN:
//              *(sal_Bool*)pData = *(sal_Bool *)pConv; break;
//          case TypeClass_CHAR:
//              *(char*)pData = *(char *)pConv; break;
//          case TypeClass_STRING:
//              *(::rtl::OUString*)pData = *(::rtl::OUString *)pConv; break;
//          case TypeClass_FLOAT:
//              *(float*)pData = *(float *)pConv; break;
//          case TypeClass_DOUBLE:
//              *(double*)pData = *(double *)pConv; break;
//          case TypeClass_BYTE:
//              *(BYTE*)pData = *(BYTE *)pConv; break;
//          case TypeClass_SHORT:
//              *(sal_Int16*)pData = *(sal_Int16 *)pConv; break;
//          case TypeClass_LONG:
//              *(sal_Int32*)pData = *(sal_Int32 *)pConv; break;
//          case TypeClass_UNSIGNED_SHORT:
//              *(sal_uInt16*)pData = *(sal_uInt16 *)pConv; break;
//          case TypeClass_UNSIGNED_LONG:
//              *(sal_uInt32*)pData = *(sal_uInt32 *)pConv; break;
//          case TypeClass_ANY:
//              *(Any*)pData = rValue; break;
//          default:
//              bRes = sal_False;
//      }
//  }
//  return bRes;
//}


//------------------------------------------------------------------------------
sal_uInt32 findValue(const Sequence< Any>& rList, const Any& rValue)
{
    sal_uInt32 nLen = rList.getLength();
    const Any* pArray = (const Any*)rList.getConstArray();
    sal_uInt32 i;
    for (i = 0; i < nLen; i++)
    {
        if (::comphelper::compare(rValue, pArray[i]))
            break;
    }
    return (i < nLen) ? i : LIST_ENTRY_NOTFOUND;
}

//------------------------------------------------------------------------------
Sequence<sal_Int16> findValueINT16(const Sequence< ::rtl::OUString>& rList, const ::rtl::OUString& rValue, sal_Bool bOnlyFirst )
{
    if( bOnlyFirst )
    {
        //////////////////////////////////////////////////////////////////////
        // An welcher Position finde ich den Wert?
        sal_Int32 nPos = -1;
        const ::rtl::OUString* pTArray = (const ::rtl::OUString*)rList.getConstArray();
        for (sal_uInt32 i = 0; i < (sal_uInt32)rList.getLength(); i++)
        {
            if( rValue==pTArray[i] )
            {
                nPos = i;
                break;
            }
        }

        //////////////////////////////////////////////////////////////////////
        // Sequence fuellen
        if( nPos>-1 )
        {
            Sequence<sal_Int16> aRetSeq( 1 );
            aRetSeq.getArray()[0] = (sal_Int16)nPos;

            return aRetSeq;
        }

        return Sequence<sal_Int16>();

    }
    else
    {
        //////////////////////////////////////////////////////////////////////
        // Wie oft kommt der Wert vor?
        sal_uInt32 nCount = 0;
        const ::rtl::OUString* pTArray = (const ::rtl::OUString*)rList.getConstArray();
        sal_uInt32 i;
        for (i = 0; i < (sal_uInt32)rList.getLength(); i++)
        {
            if( rValue==pTArray[i] )
                nCount++;
        }

        //////////////////////////////////////////////////////////////////////
        // Jetzt Sequence fuellen
        Sequence<sal_Int16> aRetSeq( nCount );
        sal_uInt32 j = 0;
        for (i = 0; i < (sal_uInt32)rList.getLength(); i++)
        {
            if( rValue==pTArray[i] )
            {
                aRetSeq.getArray()[j] = (sal_Int16)i;
                j++;
            }
        }

        return aRetSeq;
    }
}

//------------------------------------------------------------------------------
Sequence<sal_Int16> findValue(const Sequence< ::rtl::OUString>& rList, const ::rtl::OUString& rValue, sal_Bool bOnlyFirst )
{
    if( bOnlyFirst )
    {
        //////////////////////////////////////////////////////////////////////
        // An welcher Position finde ich den Wert?
        sal_Int32 nPos = -1;
        const ::rtl::OUString* pTArray = (const ::rtl::OUString*)rList.getConstArray();
        for (sal_uInt32 i = 0; i < (sal_uInt32)rList.getLength(); ++i, ++pTArray)
        {
            if( rValue == *pTArray )
            {
                nPos = i;
                break;
            }
        }

        //////////////////////////////////////////////////////////////////////
        // Sequence fuellen
        if( nPos>-1 )
        {
            Sequence<sal_Int16> aRetSeq( 1 );
            aRetSeq.getArray()[0] = (sal_Int16)nPos;

            return aRetSeq;
        }

        return Sequence<sal_Int16>();

    }

    else
    {
        //////////////////////////////////////////////////////////////////////
        // Wie oft kommt der Wert vor?
        sal_uInt32 nCount = 0;
        const ::rtl::OUString* pTArray = (const ::rtl::OUString*)rList.getConstArray();
        sal_uInt32 i;
        for (i = 0; i < (sal_uInt32)rList.getLength(); i++)
        {
            if( rValue==pTArray[i] )
                ++nCount;
        }

        //////////////////////////////////////////////////////////////////////
        // Jetzt Sequence fuellen
        Sequence<sal_Int16> aRetSeq( nCount );
        sal_uInt32 j = 0;
        for (i = 0; i < (sal_uInt32)rList.getLength(); i++)
        {
            if( rValue==pTArray[i] )
            {
                aRetSeq.getArray()[j] = (sal_Int16)i;
                ++j;
            }
        }

        return aRetSeq;
    }
}

//------------------------------------------------------------------------------
sal_uInt32 findValue1(const Sequence< ::rtl::OUString>& rList, const ::rtl::OUString& rValue)
{
    const ::rtl::OUString* pTArray = rList.getConstArray();
    const ::rtl::OUString* pTArrayStart = pTArray;
    const ::rtl::OUString* pTArrayEnd = pTArray + rList.getLength();
    for (; pTArray < pTArrayEnd; ++pTArray)
    {
        if (*pTArray == rValue)
            break;
    }
    return (pTArray < pTArrayEnd) ? (pTArray - pTArrayStart) : LIST_ENTRY_NOTFOUND;
}


//==================================================================
// StringConversion
//==================================================================
::rtl::OUString AnyToStr( const Any& aValue)
{
    UniString aRetStr;

    switch( aValue.getValueTypeClass() )
    {
        case TypeClass_INTERFACE:       aRetStr.AssignAscii("TYPE INTERFACE");          break;
        case TypeClass_SERVICE:         aRetStr.AssignAscii("TYPE SERVICE");            break;
        case TypeClass_MODULE:          aRetStr.AssignAscii("TYPE MODULE");             break;
        case TypeClass_STRUCT:          aRetStr.AssignAscii("TYPE STRUCT");             break;
        case TypeClass_TYPEDEF:         aRetStr.AssignAscii("TYPE TYPEDEF");            break;
        case TypeClass_UNION:           aRetStr.AssignAscii("TYPE UNION");              break;
        case TypeClass_ENUM:                aRetStr.AssignAscii("TYPE ENUM");               break;
        case TypeClass_EXCEPTION:       aRetStr.AssignAscii("TYPE EXCEPTION");          break;
        case TypeClass_ARRAY:           aRetStr.AssignAscii("TYPE ARRAY");              break;
        case TypeClass_SEQUENCE:            aRetStr.AssignAscii("TYPE SEQUENCE");           break;
        case TypeClass_VOID:                aRetStr.AssignAscii("");                        break;
        case TypeClass_ANY:             aRetStr.AssignAscii("TYPE any");                break;
        case TypeClass_UNKNOWN:         aRetStr.AssignAscii("TYPE unknown");            break;
        case TypeClass_BOOLEAN:         aRetStr = ::comphelper::getBOOL(aValue) ? '1' : '0';    break;
        case TypeClass_CHAR:                aRetStr = String::CreateFromInt32(::comphelper::getINT16(aValue));          break;
        case TypeClass_STRING:          aRetStr = (const sal_Unicode*)::comphelper::getString(aValue);  break;
        //  case TypeClass_FLOAT:           SolarMath::DoubleToString( aRetStr, ::comphelper::getFloat(aValue), 'F', 40, '.', sal_True); break;
        //  case TypeClass_DOUBLE:          SolarMath::DoubleToString( aRetStr, ::comphelper::getDouble(aValue), 'F', 400, '.', sal_True); break;
        case TypeClass_FLOAT:           aRetStr = String::CreateFromFloat( ::comphelper::getFloat(aValue));break;
        case TypeClass_DOUBLE:          aRetStr = String::CreateFromDouble( ::comphelper::getDouble(aValue));break;
                // use SolarMath::DoubleToString instead of sprintf as it is more flexible
                // with respect to the decimal digits (sprintf uses a default value for the number
                // of dec digits and isn't able to cut trailing zeros)
                // 67901 - 27.07.99 - FS
        case TypeClass_BYTE:                aRetStr = String::CreateFromInt32(::comphelper::getINT16(aValue));      break;
        case TypeClass_SHORT:           aRetStr = String::CreateFromInt32(::comphelper::getINT16(aValue));      break;
        case TypeClass_LONG:                aRetStr = String::CreateFromInt32(::comphelper::getINT32(aValue));      break;
        case TypeClass_HYPER:           aRetStr.AssignAscii("TYPE HYPER");          break;
        case TypeClass_UNSIGNED_SHORT:  aRetStr = String::CreateFromInt32(::comphelper::getINT16(aValue));      break;
        case TypeClass_UNSIGNED_LONG:   aRetStr = String::CreateFromInt32(::comphelper::getINT32(aValue));      break;
        case TypeClass_UNSIGNED_HYPER:  aRetStr.AssignAscii("TYPE UNSIGNED_HYPER"); break;
    }

    return aRetStr;
}

// Hilfs-Funktion, um ein ::rtl::OUString in einen Any zu konvertieren
Any StringToAny( ::rtl::OUString _Str, TypeClass eTargetType )
{
    String aStr(_Str);
    Any aRetAny;
    switch( eTargetType )
    {
        case TypeClass_INTERFACE:       break;
        case TypeClass_SERVICE:         break;
        case TypeClass_MODULE:          break;
        case TypeClass_STRUCT:          break;
        case TypeClass_TYPEDEF:         break;
        case TypeClass_UNION:           break;
        case TypeClass_ENUM:                break;
        case TypeClass_EXCEPTION:       break;
        case TypeClass_ARRAY:           break;
        case TypeClass_SEQUENCE:            break;
        case TypeClass_VOID:                break;
        case TypeClass_ANY:             break;
        case TypeClass_UNKNOWN:         break;
        case TypeClass_BOOLEAN:
            {
                sal_Bool bB = (aStr.ToInt32() != 0);
                aRetAny.setValue(&bB,getBooleanCppuType() );
                break;
            }
        case TypeClass_CHAR:
            {
                sal_Char cC = (sal_Char)(aStr.GetChar(0));
                aRetAny.setValue(&cC,getCharCppuType() );       break;
            }
        case TypeClass_STRING:          aRetAny <<= _Str;           break;
        case TypeClass_FLOAT:           aRetAny <<= aStr.ToFloat(); break;
        case TypeClass_DOUBLE:          aRetAny <<= aStr.ToDouble(); break;
        case TypeClass_BYTE:                aRetAny <<=  (sal_uInt8)aStr.ToInt32(); break;
        case TypeClass_SHORT:           aRetAny <<=  (sal_Int16)aStr.ToInt32(); break;
        case TypeClass_LONG:                aRetAny <<=  (sal_Int32)aStr.ToInt32(); break;
        case TypeClass_HYPER:           break;
        case TypeClass_UNSIGNED_SHORT:  aRetAny <<=  (sal_uInt16)aStr.ToInt32();    break;
        case TypeClass_UNSIGNED_LONG:   aRetAny <<=  (sal_uInt32)aStr.ToInt32();    break;
        case TypeClass_UNSIGNED_HYPER:  break;
    }
    return aRetAny;
}


//========================================================================
// = CursorWrapper
//------------------------------------------------------------------------
CursorWrapper::CursorWrapper(const Reference< ::com::sun::star::sdbc::XRowSet>& _rxCursor, sal_Bool bUseCloned)
{
    ImplConstruct(Reference< ::com::sun::star::sdbc::XResultSet>(_rxCursor, UNO_QUERY), bUseCloned);
}

//------------------------------------------------------------------------
CursorWrapper::CursorWrapper(const Reference< ::com::sun::star::sdbc::XResultSet>& _rxCursor, sal_Bool bUseCloned)
{
    ImplConstruct(_rxCursor, bUseCloned);
}

//------------------------------------------------------------------------
void CursorWrapper::ImplConstruct(const Reference< ::com::sun::star::sdbc::XResultSet>& _rxCursor, sal_Bool bUseCloned)
{
    if (bUseCloned)
    {
        Reference< ::com::sun::star::sdb::XResultSetAccess> xAccess(_rxCursor, UNO_QUERY);
        try
        {
            m_xMoveOperations = xAccess.is() ? xAccess->createResultSet() : Reference< ::com::sun::star::sdbc::XResultSet>();
        }
        catch(Exception&)
        {
        }
    }
    else
        m_xMoveOperations   = _rxCursor;

    m_xBookmarkOperations   = m_xBookmarkOperations.query( m_xMoveOperations );
    m_xColumnsSupplier      = m_xColumnsSupplier.query( m_xMoveOperations );
    m_xPropertyAccess       = m_xPropertyAccess.query( m_xMoveOperations );

    if ( !m_xMoveOperations.is() || !m_xBookmarkOperations.is() || !m_xColumnsSupplier.is() || !m_xPropertyAccess.is() )
    {   // all or nothing !!
        m_xMoveOperations = NULL;
        m_xBookmarkOperations = NULL;
        m_xColumnsSupplier = NULL;
    }
    else
        m_xGeneric = m_xMoveOperations.get();
}

//------------------------------------------------------------------------
const CursorWrapper& CursorWrapper::operator=(const Reference< ::com::sun::star::sdbc::XRowSet>& _rxCursor)
{
    m_xMoveOperations = Reference< ::com::sun::star::sdbc::XResultSet>(_rxCursor, UNO_QUERY);
    m_xBookmarkOperations = Reference< ::com::sun::star::sdbcx::XRowLocate>(_rxCursor, UNO_QUERY);
    m_xColumnsSupplier = Reference< ::com::sun::star::sdbcx::XColumnsSupplier>(_rxCursor, UNO_QUERY);
    if (!m_xMoveOperations.is() || !m_xBookmarkOperations.is() || !m_xColumnsSupplier.is())
    {   // all or nothing !!
        m_xMoveOperations = NULL;
        m_xBookmarkOperations = NULL;
        m_xColumnsSupplier = NULL;
    }
    return *this;
}

//==============================================================================
//==============================================================================
//IndexAccessIterator::IndexAccessIterator(Reference< XInterface> xStartingPoint)
//  :m_xStartingPoint(xStartingPoint)
//  ,m_xCurrentObject(NULL)
//{
//  DBG_ASSERT(m_xStartingPoint.is(), "IndexAccessIterator::IndexAccessIterator : no starting point !");
//}
//
//  ------------------------------------------------------------------------------
//Reference< XInterface> IndexAccessIterator::Next()
//{
//  sal_Bool bCheckingStartingPoint = !m_xCurrentObject.is();
//      // ist die aktuelle Node der Anfangspunkt ?
//  sal_Bool bAlreadyCheckedCurrent = m_xCurrentObject.is();
//      // habe ich die aktuelle Node schon mal mittels ShouldHandleElement testen ?
//  if (!m_xCurrentObject.is())
//      m_xCurrentObject = m_xStartingPoint;
//
//  Reference< XInterface> xSearchLoop( m_xCurrentObject);
//  sal_Bool bHasMoreToSearch = sal_True;
//  sal_Bool bFoundSomething = sal_False;
//  while (!bFoundSomething && bHasMoreToSearch)
//  {
//      // pre-order-traversierung
//      if (!bAlreadyCheckedCurrent && ShouldHandleElement(xSearchLoop))
//      {
//          m_xCurrentObject = xSearchLoop;
//          bFoundSomething = sal_True;
//      }
//      else
//      {
//          // zuerst absteigen, wenn moeglich
//          Reference< ::com::sun::star::container::XIndexAccess> xContainerAccess(xSearchLoop, UNO_QUERY);
//          if (xContainerAccess.is() && xContainerAccess->getCount() && ShouldStepInto(xContainerAccess))
//          {   // zum ersten Child
//              Any aElement(xContainerAccess->getByIndex(0));
//              xSearchLoop = *(Reference< XInterface>*)aElement.getValue();
//              bCheckingStartingPoint = sal_False;
//
//              m_arrChildIndizies.Insert(ULONG(0), m_arrChildIndizies.Count());
//          }
//          else
//          {
//              // dann nach oben und nach rechts, wenn moeglich
//              while (m_arrChildIndizies.Count() > 0)
//              {   // (mein Stack ist nich leer, also kann ich noch nach oben gehen)
//                  Reference< ::com::sun::star::container::XChild> xChild(xSearchLoop, UNO_QUERY);
//                  DBG_ASSERT(xChild.is(), "IndexAccessIterator::Next : a content has no approriate interface !");
//
//                  Reference< XInterface> xParent( xChild->getParent());
//                  xContainerAccess = Reference< ::com::sun::star::container::XIndexAccess>(xParent, UNO_QUERY);
//                  DBG_ASSERT(xContainerAccess.is(), "IndexAccessIterator::Next : a content has an invalid parent !");
//
//                  // den Index, den SearchLoop in diesem Parent hatte, von meinem 'Stack'
//                  ULONG nOldSearchChildIndex = m_arrChildIndizies.GetObject(m_arrChildIndizies.Count() - 1);
//                  m_arrChildIndizies.Remove(m_arrChildIndizies.Count() - 1);
//
//                  if (nOldSearchChildIndex < xContainerAccess->getCount() - 1)
//                  {   // auf dieser Ebene geht es noch nach rechts
//                      ++nOldSearchChildIndex;
//                      // also das naechste Child
//                      Any aElement(xContainerAccess->getByIndex(nOldSearchChildIndex));
//                      xSearchLoop = *(Reference< XInterface>*) aElement.getValue();
//                      bCheckingStartingPoint = sal_False;
//                      // und dessen Position auf den 'Stack'
//                      m_arrChildIndizies.Insert(ULONG(nOldSearchChildIndex), m_arrChildIndizies.Count());
//
//                      break;
//                  }
//                  // hierher komme ich, wenn es auf der aktuellen Ebene nicht nach rechts geht, dann mache ich eine darueber weiter
//                  xSearchLoop = xParent;
//                  bCheckingStartingPoint = sal_False;
//              }
//
//              if ((m_arrChildIndizies.Count() == 0) && !bCheckingStartingPoint)
//              {   // das ist genau dann der Fall, wenn ich keinen rechten Nachbarn fuer irgendeinen der direkten Vorfahren des
//                  // urspruenglichen xSearchLoop gefunden habe
//                  bHasMoreToSearch = sal_False;
//              }
//          }
//
//          if (bHasMoreToSearch)
//          {   // ich habe in xSearchLoop jetzt ein Interface eines 'Knotens' meines 'Baumes', den ich noch abtesten kann
//              if (ShouldHandleElement(xSearchLoop))
//              {
//                  m_xCurrentObject = xSearchLoop;
//                  bFoundSomething = sal_True;
//              }
//              else
//                  if (bCheckingStartingPoint)
//                      // ich bin noch am Anfang, konnte nicht absteigen, und habe an diesem Anfang nix gefunden -> nix mehr zu tun
//                      bHasMoreToSearch = sal_False;
//              bAlreadyCheckedCurrent = sal_True;
//          }
//      }
//  }
//
//  if (!bFoundSomething)
//  {
//      DBG_ASSERT(m_arrChildIndizies.Count() == 0, "IndexAccessIterator::Next : items left on stack ! how this ?");
//      Invalidate();
//  }
//
//  return m_xCurrentObject;
//}


//------------------------------------------------------------------------------
FmXDisposeListener::~FmXDisposeListener()
{
    setAdapter(NULL);
}

//------------------------------------------------------------------------------
void FmXDisposeListener::setAdapter(FmXDisposeMultiplexer* pAdapter)
{
    if (m_pAdapter)
    {
        ::osl::MutexGuard aGuard(m_rMutex);
        m_pAdapter->release();
        m_pAdapter = NULL;
    }

    if (pAdapter)
    {
        ::osl::MutexGuard aGuard(m_rMutex);
        m_pAdapter = pAdapter;
        m_pAdapter->acquire();
    }
}

//==============================================================================
DBG_NAME(FmXDisposeMultiplexer);
//------------------------------------------------------------------------------
FmXDisposeMultiplexer::FmXDisposeMultiplexer(FmXDisposeListener* _pListener, const Reference< ::com::sun::star::lang::XComponent>& _rxObject, sal_Int16 _nId)
    :m_pListener(_pListener)
    ,m_xObject(_rxObject)
    ,m_nId(_nId)
{
    DBG_CTOR(FmXDisposeMultiplexer, NULL);
    m_pListener->setAdapter(this);

    if (m_xObject.is())
        m_xObject->addEventListener(this);
}

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

// ::com::sun::star::lang::XEventListener
//------------------------------------------------------------------
void FmXDisposeMultiplexer::disposing(const ::com::sun::star::lang::EventObject& _Source) throw( RuntimeException )
{
    Reference< ::com::sun::star::lang::XEventListener> xPreventDelete(this);

    if (m_pListener)
    {
        m_pListener->disposing(_Source, m_nId);
        m_pListener->setAdapter(NULL);
        m_pListener = NULL;
    }
    m_xObject = NULL;
}

//------------------------------------------------------------------
void FmXDisposeMultiplexer::dispose()
{
    if (m_xObject.is())
    {
        Reference< ::com::sun::star::lang::XEventListener> xPreventDelete(this);

        m_xObject->removeEventListener(this);
        m_xObject = NULL;

        m_pListener->setAdapter(NULL);
        m_pListener = NULL;
    }
}

//==============================================================================
//------------------------------------------------------------------------------
sal_Int16 getControlTypeByObject(const Reference< ::com::sun::star::lang::XServiceInfo>& _rxObject)
{
    // ask for the persistent service name
    Reference< ::com::sun::star::io::XPersistObject> xPersistence(_rxObject, UNO_QUERY);
    DBG_ASSERT(xPersistence.is(), "::getControlTypeByObject : argument shold be an ::com::sun::star::io::XPersistObject !");
    if (!xPersistence.is())
        return OBJ_FM_CONTROL;

    ::rtl::OUString sPersistentServiceName = xPersistence->getServiceName();
    if (sPersistentServiceName.equals(FM_COMPONENT_EDIT))   // 5.0-Name
    {
        // may be a simple edit field or a formatted field, dependent of the supported services
        if (_rxObject->supportsService(FM_SUN_COMPONENT_FORMATTEDFIELD))
            return OBJ_FM_FORMATTEDFIELD;
        return OBJ_FM_EDIT;
    }
    if (sPersistentServiceName.equals(FM_COMPONENT_TEXTFIELD))
        return OBJ_FM_EDIT;
    if (sPersistentServiceName.equals(FM_COMPONENT_COMMANDBUTTON))
        return OBJ_FM_BUTTON;
    if (sPersistentServiceName.equals(FM_COMPONENT_FIXEDTEXT))
        return OBJ_FM_FIXEDTEXT;
    if (sPersistentServiceName.equals(FM_COMPONENT_LISTBOX))
        return OBJ_FM_LISTBOX;
    if (sPersistentServiceName.equals(FM_COMPONENT_CHECKBOX))
        return OBJ_FM_CHECKBOX;
    if (sPersistentServiceName.equals(FM_COMPONENT_RADIOBUTTON))
        return OBJ_FM_RADIOBUTTON;
    if (sPersistentServiceName.equals(FM_COMPONENT_GROUPBOX))
        return OBJ_FM_GROUPBOX;
    if (sPersistentServiceName.equals(FM_COMPONENT_COMBOBOX))
        return OBJ_FM_COMBOBOX;
    if (sPersistentServiceName.equals(FM_COMPONENT_GRID))   // 5.0-Name
        return OBJ_FM_GRID;
    if (sPersistentServiceName.equals(FM_COMPONENT_GRIDCONTROL))
        return OBJ_FM_GRID;
    if (sPersistentServiceName.equals(FM_COMPONENT_IMAGEBUTTON))
        return OBJ_FM_IMAGEBUTTON;
    if (sPersistentServiceName.equals(FM_COMPONENT_FILECONTROL))
        return OBJ_FM_FILECONTROL;
    if (sPersistentServiceName.equals(FM_COMPONENT_DATEFIELD))
        return OBJ_FM_DATEFIELD;
    if (sPersistentServiceName.equals(FM_COMPONENT_TIMEFIELD))
        return OBJ_FM_TIMEFIELD;
    if (sPersistentServiceName.equals(FM_COMPONENT_NUMERICFIELD))
        return OBJ_FM_NUMERICFIELD;
    if (sPersistentServiceName.equals(FM_COMPONENT_CURRENCYFIELD))
        return OBJ_FM_CURRENCYFIELD;
    if (sPersistentServiceName.equals(FM_COMPONENT_PATTERNFIELD))
        return OBJ_FM_PATTERNFIELD;
    if (sPersistentServiceName.equals(FM_COMPONENT_HIDDEN)) // 5.0-Name
        return OBJ_FM_HIDDEN;
    if (sPersistentServiceName.equals(FM_COMPONENT_HIDDENCONTROL))
        return OBJ_FM_HIDDEN;
    if (sPersistentServiceName.equals(FM_COMPONENT_IMAGECONTROL))
        return OBJ_FM_IMAGECONTROL;
    if (sPersistentServiceName.equals(FM_COMPONENT_FORMATTEDFIELD))
    {
        DBG_ERROR("::getControlTypeByObject : suspicious persistent service name (formatted field) !");
            // objects with that service name should exist as they aren't compatible with older versions
        return OBJ_FM_FORMATTEDFIELD;
    }

    DBG_ERROR("::getControlTypeByObject : unknown object type !");
    return OBJ_FM_CONTROL;
}

/*
sal_Int16 getControlTypeByModelName(const ::rtl::OUString& rModel)
{
    if (rModel.equals(FM_COMPONENT_EDIT))   // 5.0-Name
        return OBJ_FM_EDIT;
    if (rModel.equals(FM_COMPONENT_TEXTFIELD))
        return OBJ_FM_EDIT;
    if (rModel.equals(FM_COMPONENT_COMMANDBUTTON))
        return OBJ_FM_BUTTON;
    if (rModel.equals(FM_COMPONENT_FIXEDTEXT))
        return OBJ_FM_FIXEDTEXT;
    if (rModel.equals(FM_COMPONENT_LISTBOX))
        return OBJ_FM_LISTBOX;
    if (rModel.equals(FM_COMPONENT_CHECKBOX))
        return OBJ_FM_CHECKBOX;
    if (rModel.equals(FM_COMPONENT_RADIOBUTTON))
        return OBJ_FM_RADIOBUTTON;
    if (rModel.equals(FM_COMPONENT_GROUPBOX))
        return OBJ_FM_GROUPBOX;
    if (rModel.equals(FM_COMPONENT_COMBOBOX))
        return OBJ_FM_COMBOBOX;
    if (rModel.equals(FM_COMPONENT_GRID))   // 5.0-Name
        return OBJ_FM_GRID;
    if (rModel.equals(FM_COMPONENT_GRIDCONTROL))
        return OBJ_FM_GRID;
    if (rModel.equals(FM_COMPONENT_IMAGEBUTTON))
        return OBJ_FM_IMAGEBUTTON;
    if (rModel.equals(FM_COMPONENT_FILECONTROL))
        return OBJ_FM_FILECONTROL;
    if (rModel.equals(FM_COMPONENT_DATEFIELD))
        return OBJ_FM_DATEFIELD;
    if (rModel.equals(FM_COMPONENT_TIMEFIELD))
        return OBJ_FM_TIMEFIELD;
    if (rModel.equals(FM_COMPONENT_NUMERICFIELD))
        return OBJ_FM_NUMERICFIELD;
    if (rModel.equals(FM_COMPONENT_CURRENCYFIELD))
        return OBJ_FM_CURRENCYFIELD;
    if (rModel.equals(FM_COMPONENT_PATTERNFIELD))
        return OBJ_FM_PATTERNFIELD;
    if (rModel.equals(FM_COMPONENT_HIDDEN)) // 5.0-Name
        return OBJ_FM_HIDDEN;
    if (rModel.equals(FM_COMPONENT_HIDDENCONTROL))
        return OBJ_FM_HIDDEN;
    if (rModel.equals(FM_COMPONENT_IMAGECONTROL))
        return OBJ_FM_IMAGECONTROL;
    if (rModel.equals(FM_COMPONENT_FORMATTEDFIELD))
        return OBJ_FM_FORMATTEDFIELD;
    return OBJ_FM_CONTROL;
}
*/

//------------------------------------------------------------------------------
::rtl::OUString getServiceNameByControlType(sal_Int16 nType)
{
    switch (nType)
    {
        case OBJ_FM_EDIT            : return FM_COMPONENT_TEXTFIELD;
        case OBJ_FM_BUTTON          : return FM_COMPONENT_COMMANDBUTTON;
        case OBJ_FM_FIXEDTEXT       : return FM_COMPONENT_FIXEDTEXT;
        case OBJ_FM_LISTBOX         : return FM_COMPONENT_LISTBOX;
        case OBJ_FM_CHECKBOX        : return FM_COMPONENT_CHECKBOX;
        case OBJ_FM_RADIOBUTTON     : return FM_COMPONENT_RADIOBUTTON;
        case OBJ_FM_GROUPBOX        : return FM_COMPONENT_GROUPBOX;
        case OBJ_FM_COMBOBOX        : return FM_COMPONENT_COMBOBOX;
        case OBJ_FM_GRID            : return FM_COMPONENT_GRIDCONTROL;
        case OBJ_FM_IMAGEBUTTON     : return FM_COMPONENT_IMAGEBUTTON;
        case OBJ_FM_FILECONTROL     : return FM_COMPONENT_FILECONTROL;
        case OBJ_FM_DATEFIELD       : return FM_COMPONENT_DATEFIELD;
        case OBJ_FM_TIMEFIELD       : return FM_COMPONENT_TIMEFIELD;
        case OBJ_FM_NUMERICFIELD    : return FM_COMPONENT_NUMERICFIELD;
        case OBJ_FM_CURRENCYFIELD   : return FM_COMPONENT_CURRENCYFIELD;
        case OBJ_FM_PATTERNFIELD    : return FM_COMPONENT_PATTERNFIELD;
        case OBJ_FM_HIDDEN          : return FM_COMPONENT_HIDDENCONTROL;
        case OBJ_FM_IMAGECONTROL    : return FM_COMPONENT_IMAGECONTROL;
        case OBJ_FM_FORMATTEDFIELD  : return FM_COMPONENT_FORMATTEDFIELD;
    }
    return ::rtl::OUString();
}
//------------------------------------------------------------------------------
Sequence< ::rtl::OUString> getEventMethods(const Type& type)
{
    typelib_InterfaceTypeDescription *pType=0;
    type.getDescription( (typelib_TypeDescription**)&pType);

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

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

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


//------------------------------------------------------------------------------
void TransferEventScripts(const Reference< ::com::sun::star::awt::XControlModel>& xModel, const Reference< ::com::sun::star::awt::XControl>& xControl,
    const Sequence< ::com::sun::star::script::ScriptEventDescriptor>& rTransferIfAvailable)
{
    // first check if we have a XEventAttacherManager for the model
    Reference< ::com::sun::star::container::XChild> xModelChild(xModel, UNO_QUERY);
    if (!xModelChild.is())
        return; // nothing to do

    Reference< ::com::sun::star::script::XEventAttacherManager> xEventManager(xModelChild->getParent(), UNO_QUERY);
    if (!xEventManager.is())
        return; // nothing to do

    if (!rTransferIfAvailable.getLength())
        return; // nothing to do

    // check for the index of the model within it's parent
    Reference< ::com::sun::star::container::XIndexAccess> xParentIndex(xModelChild->getParent(), UNO_QUERY);
    if (!xParentIndex.is())
        return; // nothing to do
    sal_Int32 nIndex = getElementPos(xParentIndex, xModel);
    if (nIndex<0 || nIndex>=xParentIndex->getCount())
        return; // nothing to do

    // then we need informations about the listeners supported by the control and the model
    Sequence< Type> aModelListeners;
    Sequence< Type> aControlListeners;

    Reference< ::com::sun::star::beans::XIntrospection> xModelIntrospection(::comphelper::getProcessServiceFactory()->createInstance(::rtl::OUString::createFromAscii("com.sun.star.beans.Introspection")), UNO_QUERY);
    Reference< ::com::sun::star::beans::XIntrospection> xControlIntrospection(::comphelper::getProcessServiceFactory()->createInstance(::rtl::OUString::createFromAscii("com.sun.star.beans.Introspection")), UNO_QUERY);

    if (xModelIntrospection.is() && xModel.is())
    {
        Any aModel(makeAny(xModel));
        aModelListeners = xModelIntrospection->inspect(aModel)->getSupportedListeners();
    }

    if (xControlIntrospection.is() && xControl.is())
    {
        Any aControl(makeAny(xControl));
        aControlListeners = xControlIntrospection->inspect(aControl)->getSupportedListeners();
    }

    sal_Int32 nMaxNewLen = aModelListeners.getLength() + aControlListeners.getLength();
    if (!nMaxNewLen)
        return; // the model and the listener don't support any listeners (or we were unable to retrieve these infos)

    Sequence< ::com::sun::star::script::ScriptEventDescriptor>  aTransferable(nMaxNewLen);
    ::com::sun::star::script::ScriptEventDescriptor* pTransferable = aTransferable.getArray();

    const ::com::sun::star::script::ScriptEventDescriptor* pCurrent = rTransferIfAvailable.getConstArray();
    sal_Int32 i,j,k;
    for (i=0; i<rTransferIfAvailable.getLength(); ++i, ++pCurrent)
    {
        // search the model/control idl classes for the event described by pCurrent
        for (   Sequence< Type>* pCurrentArray = &aModelListeners;
                pCurrentArray;
                pCurrentArray = (pCurrentArray == &aModelListeners) ? &aControlListeners : NULL
            )
        {
            const Type* pCurrentListeners = pCurrentArray->getConstArray();
            for (j=0; j<pCurrentArray->getLength(); ++j, ++pCurrentListeners)
            {
                UniString aListener = (*pCurrentListeners).getTypeName();
                sal_Int32 nTokens = aListener.GetTokenCount('.');
                if (nTokens)
                    aListener = aListener.GetToken(nTokens - 1, '.');

                if (aListener == pCurrent->ListenerType.getStr())
                    // the current ::com::sun::star::script::ScriptEventDescriptor doesn't match the current listeners class
                    continue;

                // now check the methods
                Sequence< ::rtl::OUString> aMethodsNames = getEventMethods(*pCurrentListeners);
                const ::rtl::OUString* pMethodsNames = aMethodsNames.getConstArray();
                for (k=0; k<aMethodsNames.getLength(); ++k, ++pMethodsNames)
                {
                    if ((*pMethodsNames).compareTo(pCurrent->EventMethod) != COMPARE_EQUAL)
                        // the current ::com::sun::star::script::ScriptEventDescriptor doesn't match the current listeners current method
                        continue;

                    // we can transfer the script event : the model (control) supports it
                    *pTransferable = *pCurrent;
                    ++pTransferable;
                    break;
                }
                if (k<aMethodsNames.getLength())
                    break;
            }
        }
    }

    sal_Int32 nRealNewLen = pTransferable - aTransferable.getArray();
    aTransferable.realloc(nRealNewLen);

    xEventManager->registerScriptEvents(nIndex, aTransferable);
}

//------------------------------------------------------------------------------
sal_Int16   GridModel2ViewPos(const Reference< ::com::sun::star::container::XIndexAccess>& rColumns, sal_Int16 nModelPos)
{
    try
    {
        if (rColumns.is())
        {
            // invalid pos ?
            if (nModelPos >= rColumns->getCount())
                return (sal_Int16)-1;

            // the column itself shouldn't be hidden
            Reference< ::com::sun::star::beans::XPropertySet> xAskedFor;
            rColumns->getByIndex(nModelPos) >>= xAskedFor;
            if (::comphelper::getBOOL(xAskedFor->getPropertyValue(FM_PROP_HIDDEN)))
            {
                DBG_ERROR("GridModel2ViewPos : invalid argument !");
                return (sal_Int16)-1;
            }

            sal_Int16 nViewPos = nModelPos;
            Reference< ::com::sun::star::beans::XPropertySet> xCur;
            for (sal_Int16 i=0; i<nModelPos; ++i)
            {
                rColumns->getByIndex(i) >>= xCur;
                if (::comphelper::getBOOL(xCur->getPropertyValue(FM_PROP_HIDDEN)))
                    --nViewPos;
            }
            return nViewPos;
        }
    }
    catch(const Exception&)
    {
        DBG_ERROR("GridModel2ViewPos Exception occured!");
    }
    return (sal_Int16)-1;
}

//------------------------------------------------------------------------------
sal_Int16   GridView2ModelPos(const Reference< ::com::sun::star::container::XIndexAccess>& rColumns, sal_Int16 nViewPos)
{
    try
    {
        if (rColumns.is())
        {
            // loop through all columns
            sal_Int16 i;
            Reference< ::com::sun::star::beans::XPropertySet> xCur;
            for (i=0; i<rColumns->getCount(); ++i)
            {
                rColumns->getByIndex(i) >>= xCur;
                if (!::comphelper::getBOOL(xCur->getPropertyValue(FM_PROP_HIDDEN)))
                    // for every visible col : if nViewPos is greater zero, decrement it, else we
                    // have found the model position
                    if (!nViewPos)
                        break;
                    else
                        --nViewPos;
            }
            if (i<rColumns->getCount())
                return i;
        }
    }
    catch(const Exception&)
    {
        DBG_ERROR("GridView2ModelPos Exception occured!");
    }
    return (sal_Int16)-1;
}

//------------------------------------------------------------------------------
sal_Int16   GridViewColumnCount(const Reference< ::com::sun::star::container::XIndexAccess>& rColumns)
{
    try
    {
        if (rColumns.is())
        {
            sal_Int16 nCount = (sal_Int16)rColumns->getCount();
            // loop through all columns
            Reference< ::com::sun::star::beans::XPropertySet> xCur;
            for (sal_Int16 i=0; i<rColumns->getCount(); ++i)
            {
                rColumns->getByIndex(i) >>= xCur;
                if (::comphelper::getBOOL(xCur->getPropertyValue(FM_PROP_HIDDEN)))
                    --nCount;
            }
            return nCount;
        }
    }
    catch(const Exception&)
    {
        DBG_ERROR("GridView2ModelPos Exception occured!");
    }
    return 0;
}
//------------------------------------------------------------------------------
//==============================================================================
// FmSlotDispatch - some kind of translator between the Sfx-Slots and the UNO-dispatchers
//==============================================================================

//  SMART_UNO_IMPLEMENTATION(FmSlotDispatch, UsrObject);


DBG_NAME(FmSlotDispatch);
//------------------------------------------------------------------------------
FmSlotDispatch::FmSlotDispatch(const  URL& rUrl, sal_Int16 nSlotId, SfxBindings& rBindings)
    :SfxControllerItem(nSlotId, rBindings)
    ,m_aDisposeListeners(m_aAccessSafety)
    ,m_aStatusListeners(m_aAccessSafety)
    ,m_aUrl(rUrl)
    ,m_nSlot(nSlotId)
{
    DBG_CTOR(FmSlotDispatch,NULL);

}

//------------------------------------------------------------------------------
FmSlotDispatch::~FmSlotDispatch()
{

    DBG_DTOR(FmSlotDispatch,NULL);
}

//------------------------------------------------------------------------------
void FmSlotDispatch::BroadcastCurrentState( )
{
    SfxPoolItem* pCurrentState = NULL;
    SfxItemState eCurrentState = GetBindings().QueryState( m_nSlot, pCurrentState );
    NotifyState( eCurrentState, pCurrentState );
    delete pCurrentState;
}

//------------------------------------------------------------------------------
void FmSlotDispatch::dispatch(const  URL& aURL, const Sequence< ::com::sun::star::beans::PropertyValue>& aArgs) throw( RuntimeException )
{
    DBG_ASSERT(aURL.Main.compareTo(m_aUrl.Main) == COMPARE_EQUAL, "FmSlotDispatch::dispatch : invalid argument !");
    DBG_ASSERT(m_aExecutor.IsSet(), "FmSlotDispatch::dispatch : no executor !");
    // if we have no executor we would have disabled this feature in statusChanged-calls

    m_aExecutor.Call(this);
}

//------------------------------------------------------------------------------
void FmSlotDispatch::NotifyState(SfxItemState eState, const SfxPoolItem* pState, const Reference< ::com::sun::star::frame::XStatusListener>& rListener)
{
    ::com::sun::star::frame::FeatureStateEvent aEvent = BuildEvent(eState, pState);

    if (rListener.is())
        rListener->statusChanged(aEvent);
    else
        NOTIFY_LISTENERS(m_aStatusListeners, ::com::sun::star::frame::XStatusListener, statusChanged, aEvent);
}

//------------------------------------------------------------------------------
void SAL_CALL FmSlotDispatch::addStatusListener( const Reference< ::com::sun::star::frame::XStatusListener >& xControl, const URL& aURL ) throw(RuntimeException)
{
    DBG_ASSERT((aURL.Main.getLength() == 0) || (aURL.Main.compareTo(m_aUrl.Main) == COMPARE_EQUAL),
        "FmSlotDispatch::addStatusListener: invalid argument !");
    m_aStatusListeners.addInterface( xControl );

    // acknowledge the initial status
    SfxPoolItem* pState = NULL;
    SfxItemState eInitialState = GetBindings().QueryState(m_nSlot, pState);

    NotifyState(eInitialState, pState, xControl);
}

//------------------------------------------------------------------------------
void SAL_CALL FmSlotDispatch::removeStatusListener( const Reference< ::com::sun::star::frame::XStatusListener >& xControl, const URL& aURL ) throw(RuntimeException)
{
    DBG_ASSERT((aURL.Main.getLength() == 0) || (aURL.Main.compareTo(m_aUrl.Main) == COMPARE_EQUAL),
        "FmSlotDispatch::removeStatusListener: invalid argument !");
    m_aStatusListeners.removeInterface( xControl );
}

//------------------------------------------------------------------------------
void SAL_CALL FmSlotDispatch::dispose(  ) throw(RuntimeException)
{
    Reference< XInterface > xXInterface((*this));
    ::com::sun::star::lang::EventObject aEvt(xXInterface);
    m_aDisposeListeners.disposeAndClear(aEvt);
    m_aStatusListeners.disposeAndClear(aEvt);
}

//------------------------------------------------------------------------------
void SAL_CALL FmSlotDispatch::addEventListener( const Reference< ::com::sun::star::lang::XEventListener >& xListener ) throw(RuntimeException)
{
    m_aDisposeListeners.addInterface( xListener );
}

//------------------------------------------------------------------------------
void SAL_CALL FmSlotDispatch::removeEventListener( const Reference< ::com::sun::star::lang::XEventListener >& aListener ) throw(RuntimeException)
{
    m_aDisposeListeners.removeInterface( aListener );
}

//------------------------------------------------------------------------------
void FmSlotDispatch::StateChanged(USHORT _nSID, SfxItemState _eState, const SfxPoolItem* _pState)
{
    DBG_ASSERT(_nSID == m_nSlot, "FmSlotDispatch::StateChanged : where did this come from ?");

    ::com::sun::star::frame::FeatureStateEvent eEvent = BuildEvent(_eState, _pState);
    NOTIFY_LISTENERS(m_aStatusListeners, ::com::sun::star::frame::XStatusListener, statusChanged, eEvent);
}

//------------------------------------------------------------------------------
::com::sun::star::frame::FeatureStateEvent FmSlotDispatch::BuildEvent(SfxItemState eState, const SfxPoolItem* pState)
{
    ::com::sun::star::frame::FeatureStateEvent aReturn;
    aReturn.Source = static_cast< ::cppu::OWeakObject* >( this );
    aReturn.FeatureURL = m_aUrl;
    aReturn.IsEnabled = (SFX_ITEM_DISABLED != eState) && m_aExecutor.IsSet();
    aReturn.Requery = sal_False;

    if (pState)
    {
        if (pState->ISA(SfxBoolItem))
            aReturn.State <<= ((SfxBoolItem*)pState)->GetValue();
        else if (pState->ISA(SfxStringItem))
            aReturn.State <<= ::rtl::OUString(((SfxStringItem*)pState)->GetValue());
#if DBG_UTIL
        else if (!pState->ISA(SfxVoidItem))
            DBG_ERROR("FmSlotDispatch::BuildEvent : don't know what to do with the ItemState !");
#endif
    }

    return aReturn;
}

// search in the hierarchy for a connection
//------------------------------------------------------------------------------
Reference< ::com::sun::star::sdbc::XConnection> findConnection(const Reference< XInterface>& xParent)
{
    Reference< ::com::sun::star::sdbc::XConnection> xConnection(xParent, UNO_QUERY);
    if (!xConnection.is())
    {
        Reference< ::com::sun::star::container::XChild> xChild(xParent, UNO_QUERY);
        if (xChild.is())
            return findConnection(xChild->getParent());
    }
    return xConnection;
}

//========================================================================
//= FmXDispatchInterceptorImpl
//========================================================================

DBG_NAME(FmXDispatchInterceptorImpl);
//------------------------------------------------------------------------
FmXDispatchInterceptorImpl::FmXDispatchInterceptorImpl(
            const Reference< XDispatchProviderInterception>& _rxToIntercept, FmDispatchInterceptor* _pMaster,
            sal_Int16 _nId, Sequence< ::rtl::OUString > _rInterceptedSchemes)
    :FmXDispatchInterceptorImpl_BASE(_pMaster && _pMaster->getInterceptorMutex() ? *_pMaster->getInterceptorMutex() : m_aFallback)
    ,m_xIntercepted(_rxToIntercept)
    ,m_pMaster(_pMaster)
    ,m_nId(_nId)
    ,m_aInterceptedURLSchemes(_rInterceptedSchemes)
    ,m_bListening(sal_False)
{
    DBG_CTOR(FmXDispatchInterceptorImpl,NULL);

    ::osl::MutexGuard aGuard(getAccessSafety());
    ::comphelper::increment(m_refCount);
    if (_rxToIntercept.is())
    {
        _rxToIntercept->registerDispatchProviderInterceptor((::com::sun::star::frame::XDispatchProviderInterceptor*)this);
        // this should make us the top-level dispatch-provider for the component, via a call to our
        // setDispatchProvider we should have got an fallback for requests we (i.e. our master) cannot fullfill
        Reference< ::com::sun::star::lang::XComponent> xInterceptedComponent(_rxToIntercept, UNO_QUERY);
        if (xInterceptedComponent.is())
        {
            xInterceptedComponent->addEventListener(this);
            m_bListening = sal_True;
        }
    }
    ::comphelper::decrement(m_refCount);
}

//------------------------------------------------------------------------
FmXDispatchInterceptorImpl::~FmXDispatchInterceptorImpl()
{
    if (!rBHelper.bDisposed)
        dispose();

    DBG_DTOR(FmXDispatchInterceptorImpl,NULL);
}

//------------------------------------------------------------------------------
Sequence< sal_Int8 > SAL_CALL FmXDispatchInterceptorImpl::getImplementationId() throw(RuntimeException)
{
    return ::form::OImplementationIds::getImplementationId(getTypes());
}
//------------------------------------------------------------------------------
Reference< ::com::sun::star::frame::XDispatch > SAL_CALL FmXDispatchInterceptorImpl::queryDispatch( const URL& aURL, const ::rtl::OUString& aTargetFrameName, sal_Int32 nSearchFlags ) throw(RuntimeException)
{
    ::osl::MutexGuard aGuard(getAccessSafety());
    Reference< ::com::sun::star::frame::XDispatch> xResult;
    // ask our 'real' interceptor
    if (m_pMaster)
        xResult = m_pMaster->interceptedQueryDispatch(m_nId, aURL, aTargetFrameName, nSearchFlags);

    // ask our slave provider
    if (!xResult.is() && m_xSlaveDispatcher.is())
        xResult = m_xSlaveDispatcher->queryDispatch(aURL, aTargetFrameName, nSearchFlags);

    return xResult;
}

//------------------------------------------------------------------------------
Sequence< Reference< ::com::sun::star::frame::XDispatch > > SAL_CALL
FmXDispatchInterceptorImpl::queryDispatches( const Sequence< ::com::sun::star::frame::DispatchDescriptor >& aDescripts ) throw(RuntimeException)
{
    ::osl::MutexGuard aGuard(getAccessSafety());
    Sequence< Reference< ::com::sun::star::frame::XDispatch> > aReturn(aDescripts.getLength());
    Reference< ::com::sun::star::frame::XDispatch>* pReturn = aReturn.getArray();
    const ::com::sun::star::frame::DispatchDescriptor* pDescripts = aDescripts.getConstArray();
    for (sal_Int16 i=0; i<aDescripts.getLength(); ++i, ++pReturn, ++pDescripts)
    {
        *pReturn = queryDispatch(pDescripts->FeatureURL, pDescripts->FrameName, pDescripts->SearchFlags);
    }
    return aReturn;
}

//------------------------------------------------------------------------------
Reference< ::com::sun::star::frame::XDispatchProvider > SAL_CALL FmXDispatchInterceptorImpl::getSlaveDispatchProvider(  ) throw(RuntimeException)
{
    ::osl::MutexGuard aGuard(getAccessSafety());
    return m_xSlaveDispatcher;
}

//------------------------------------------------------------------------------
void SAL_CALL FmXDispatchInterceptorImpl::setSlaveDispatchProvider(const Reference< ::com::sun::star::frame::XDispatchProvider>& xNewDispatchProvider) throw( RuntimeException )
{
    ::osl::MutexGuard aGuard(getAccessSafety());
    m_xSlaveDispatcher = xNewDispatchProvider;
}

//------------------------------------------------------------------------------
Reference< ::com::sun::star::frame::XDispatchProvider> SAL_CALL FmXDispatchInterceptorImpl::getMasterDispatchProvider(void) throw( RuntimeException )
{
    ::osl::MutexGuard aGuard(getAccessSafety());
    return m_xMasterDispatcher;
}

//------------------------------------------------------------------------------
void SAL_CALL FmXDispatchInterceptorImpl::setMasterDispatchProvider(const Reference< ::com::sun::star::frame::XDispatchProvider>& xNewSupplier) throw( RuntimeException )
{
    ::osl::MutexGuard aGuard(getAccessSafety());
    m_xMasterDispatcher = xNewSupplier;
}

//------------------------------------------------------------------------------
Sequence< ::rtl::OUString > SAL_CALL FmXDispatchInterceptorImpl::getInterceptedURLs(  ) throw(RuntimeException)
{
    return m_aInterceptedURLSchemes;
}

//------------------------------------------------------------------------------
void SAL_CALL FmXDispatchInterceptorImpl::disposing(const ::com::sun::star::lang::EventObject& Source) throw( ::com::sun::star::uno::RuntimeException )
{
    if (m_bListening)
    {
        Reference< XDispatchProviderInterception > xIntercepted(m_xIntercepted.get(), UNO_QUERY);
        if (Source.Source == xIntercepted)
            ImplDetach();
    }
}

//------------------------------------------------------------------------------
void FmXDispatchInterceptorImpl::ImplDetach()
{
    ::osl::MutexGuard aGuard(getAccessSafety());
    OSL_ENSURE(m_bListening, "FmXDispatchInterceptorImpl::ImplDetach: invalid call!");

    // deregister ourself from the interception component
    Reference< XDispatchProviderInterception > xIntercepted(m_xIntercepted.get(), UNO_QUERY);
    if (xIntercepted.is())
        xIntercepted->releaseDispatchProviderInterceptor(static_cast<XDispatchProviderInterceptor*>(this));

//  m_xIntercepted = Reference< XDispatchProviderInterception >();
        // Don't reset m_xIntercepted: It may be needed by our owner to check for which object we were
        // responsible. As we hold the object with a weak reference only, this should be no problem.
        // 88936 - 23.07.2001 - frank.schoenheit@sun.com
    m_pMaster = NULL;
    m_bListening = sal_False;
}

//------------------------------------------------------------------------------
void FmXDispatchInterceptorImpl::disposing()
{
    // remove ourself as event listener from the interception component
    if (m_bListening)
    {
        Reference< ::com::sun::star::lang::XComponent> xInterceptedComponent(m_xIntercepted.get(), UNO_QUERY);
        if (xInterceptedComponent.is())
            xInterceptedComponent->removeEventListener(static_cast<XEventListener*>(this));

        // detach from the interception component
        ImplDetach();
    }
}

//==============================================================================
//==============================================================================

//------------------------------------------------------------------------------
sal_Bool isLoadable(const Reference< XInterface>& xLoad)
{
    // determines whether a form should be loaded or not
    // if there is no datasource or connection there is no reason to load a form
    Reference< ::com::sun::star::beans::XPropertySet> xSet(xLoad, UNO_QUERY);
    if (xSet.is())
    {
        try
        {
            // is there already a active connection
            Reference< XInterface> xConn;
            xSet->getPropertyValue(FM_PROP_ACTIVE_CONNECTION) >>= xConn;
            return (xConn.is() ||
                    ::comphelper::getString(xSet->getPropertyValue(FM_PROP_DATASOURCE)).getLength() ||
                    ::comphelper::getString(xSet->getPropertyValue(FM_PROP_URL)).getLength() ||
                    ::findConnection(xLoad).is());
        }
        catch(Exception&)
        {
            DBG_ERROR("isLoadable Exception occured!");
        }

    }
    return sal_False;
}

//------------------------------------------------------------------------------
void setConnection(const Reference< ::com::sun::star::sdbc::XRowSet>& _rxRowSet, const Reference< ::com::sun::star::sdbc::XConnection>& _rxConn)
{
    Reference< ::com::sun::star::beans::XPropertySet> xRowSetProps(_rxRowSet, UNO_QUERY);
    if (xRowSetProps.is())
    {
        try
        {
            Any aConn(makeAny(_rxConn));
            xRowSetProps->setPropertyValue(FM_PROP_ACTIVE_CONNECTION, aConn);
        }
        catch(Exception&)
        {
            DBG_ERROR("::setConnection : could not set the connection !");
        }

    }
}
//------------------------------------------------------------------------------
sal_Bool isRowSetAlive(const Reference< XInterface>& _rxRowSet)
{
    sal_Bool bIsAlive = sal_False;
    Reference< ::com::sun::star::sdbcx::XColumnsSupplier> xSupplyCols(_rxRowSet, UNO_QUERY);
    Reference< ::com::sun::star::container::XIndexAccess> xCols;
    if (xSupplyCols.is())
        xCols = Reference< ::com::sun::star::container::XIndexAccess>(xSupplyCols->getColumns(), UNO_QUERY);
    if (xCols.is() && (xCols->getCount() > 0))
        bIsAlive = sal_True;

    return bIsAlive;
}


//==============================================================================
DataColumn::DataColumn(const Reference< ::com::sun::star::beans::XPropertySet>& _rxIFace)
{
    m_xPropertySet = _rxIFace;
    m_xColumn = Reference< ::com::sun::star::sdb::XColumn>(_rxIFace, UNO_QUERY);
    m_xColumnUpdate = Reference< ::com::sun::star::sdb::XColumnUpdate>(_rxIFace, UNO_QUERY);

    if (!m_xPropertySet.is() || !m_xColumn.is())
    {
        m_xPropertySet = NULL;
        m_xColumn = NULL;
        m_xColumnUpdate = NULL;
    }
}