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
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright 2000, 2010 Oracle and/or its affiliates.
*
* OpenOffice.org - a multi-platform office productivity suite
*
* This file is part of OpenOffice.org.
*
* OpenOffice.org is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License version 3
* only, as published by the Free Software Foundation.
*
* OpenOffice.org 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 version 3 for more details
* (a copy is included in the LICENSE file that accompanied this code).
*
* You should have received a copy of the GNU Lesser General Public License
* version 3 along with OpenOffice.org. If not, see
* <http://www.openoffice.org/license.html>
* for a copy of the LGPLv3 License.
*
************************************************************************/
// MARKER(update_precomp.py): autogen include statement, do not remove
#include "precompiled_stoc.hxx"
#include <string.h>
// Schalter fuer Introspection-Caching
#ifndef OS2
#define USE_INTROSPECTION_CACHE
#endif
#ifdef USE_INTROSPECTION_CACHE
#define INTROSPECTION_CACHE_MAX_SIZE 100
#endif
#include <osl/diagnose.h>
#include <osl/mutex.hxx>
#include <osl/thread.h>
#include <cppuhelper/queryinterface.hxx>
#include <cppuhelper/weak.hxx>
#include <cppuhelper/component.hxx>
#include <cppuhelper/factory.hxx>
#include <cppuhelper/implbase3.hxx>
#include <cppuhelper/typeprovider.hxx>
#include <com/sun/star/uno/DeploymentException.hpp>
#include <com/sun/star/lang/XSingleServiceFactory.hpp>
#include <com/sun/star/lang/XMultiServiceFactory.hpp>
#include <com/sun/star/lang/XServiceInfo.hpp>
#include <com/sun/star/lang/XEventListener.hpp>
#include <com/sun/star/reflection/XIdlReflection.hpp>
#include <com/sun/star/reflection/XIdlClassProvider.hpp>
#include <com/sun/star/reflection/XIdlClass.hpp>
#include <com/sun/star/reflection/XIdlField2.hpp>
#include <com/sun/star/beans/UnknownPropertyException.hpp>
#include <com/sun/star/beans/Property.hpp>
#include <com/sun/star/beans/XPropertySet.hpp>
#include <com/sun/star/beans/XFastPropertySet.hpp>
#include <com/sun/star/beans/XIntrospection.hpp>
#include <com/sun/star/beans/XIntrospectionAccess.hpp>
#include <com/sun/star/beans/XMaterialHolder.hpp>
#include <com/sun/star/beans/XExactName.hpp>
#include <com/sun/star/beans/PropertyAttribute.hpp>
#include <com/sun/star/beans/PropertyConcept.hpp>
#include <com/sun/star/beans/MethodConcept.hpp>
#include <com/sun/star/container/XNameContainer.hpp>
#include <com/sun/star/container/XIndexContainer.hpp>
#include <com/sun/star/container/XEnumerationAccess.hpp>
#include <rtl/ustrbuf.hxx>
#include <rtl/strbuf.hxx>
#include <boost/unordered_map.hpp>
using namespace com::sun::star::uno;
using namespace com::sun::star::lang;
using namespace com::sun::star::reflection;
using namespace com::sun::star::container;
using namespace com::sun::star::registry;
using namespace com::sun::star::beans;
using namespace com::sun::star::beans::PropertyAttribute;
using namespace com::sun::star::beans::PropertyConcept;
using namespace com::sun::star::beans::MethodConcept;
using namespace cppu;
using namespace osl;
using ::rtl::OUString;
using ::rtl::OUStringToOString;
using ::rtl::OString;
#define IMPLEMENTATION_NAME "com.sun.star.comp.stoc.Introspection"
#define SERVICE_NAME "com.sun.star.beans.Introspection"
namespace stoc_inspect
{
typedef WeakImplHelper3< XIntrospectionAccess, XMaterialHolder, XExactName > IntrospectionAccessHelper;
//==================================================================================================
// Spezial-Wert fuer Method-Concept, um "normale" Funktionen kennzeichnen zu koennen
#define MethodConcept_NORMAL_IMPL 0x80000000
// Methode zur Feststellung, ob eine Klasse von einer anderen abgeleitet ist
sal_Bool isDerivedFrom( Reference<XIdlClass> xToTestClass, Reference<XIdlClass> xDerivedFromClass )
{
Sequence< Reference<XIdlClass> > aClassesSeq = xToTestClass->getSuperclasses();
const Reference<XIdlClass>* pClassesArray = aClassesSeq.getConstArray();
sal_Int32 nSuperClassCount = aClassesSeq.getLength();
sal_Int32 i;
for( i = 0 ; i < nSuperClassCount ; i++ )
{
const Reference<XIdlClass>& rxClass = pClassesArray[i];
if( xDerivedFromClass->equals( rxClass ) )
{
// Treffer
return sal_True;
}
else
{
// Rekursiv weitersuchen
return isDerivedFrom( rxClass, xDerivedFromClass );
}
}
return sal_False;
}
//========================================================================
// *** Klassifizierung der Properties (kein enum, um Sequence verwenden zu koennen) ***
// Properties aus einem PropertySet-Interface
#define MAP_PROPERTY_SET 0
// Properties aus Fields
#define MAP_FIELD 1
// Properties, die durch get/set-Methoden beschrieben werden
#define MAP_GETSET 2
// Properties, die nur eine set-Methode haben
#define MAP_SETONLY 3
// Schrittweite, in der die Groesse der Sequences angepasst wird
#define ARRAY_SIZE_STEP 20
//**************************************
//*** IntrospectionAccessStatic_Impl ***
//**************************************
// Entspricht dem alten IntrospectionAccessImpl, bildet jetzt den statischen
// Anteil des neuen Instanz-bezogenen ImplIntrospectionAccess
// ACHTUNG !!! Von Hand refcounten !!!
// Hashtable fuer die Suche nach Namen
struct hashName_Impl
{
size_t operator()(const OUString Str) const
{
return (size_t)Str.hashCode();
}
};
struct eqName_Impl
{
sal_Bool operator()(const OUString Str1, const OUString Str2) const
{
return ( Str1 == Str2 );
}
};
typedef boost::unordered_map
<
OUString,
sal_Int32,
hashName_Impl,
eqName_Impl
>
IntrospectionNameMap;
// Hashtable zur Zuordnung der exakten Namen zu den zu Lower-Case
// konvertierten Namen, dient zur Unterst�tzung von XExactName
typedef boost::unordered_map
<
OUString,
OUString,
hashName_Impl,
eqName_Impl
>
LowerToExactNameMap;
class ImplIntrospectionAccess;
class IntrospectionAccessStatic_Impl
{
friend class ImplIntrospection;
friend class ImplIntrospectionAccess;
// CoreReflection halten
Reference< XIdlReflection > mxCoreReflection;
// InterfaceSequences, um Zusatz-Infos zu einer Property speichern zu koennen.
// z.B. das Field bei MAP_FIELD, die get/set-Methoden bei MAP_GETSET usw.
Sequence< Reference<XInterface> > aInterfaceSeq1;
Sequence< Reference<XInterface> > aInterfaceSeq2;
// Hashtables fuer die Namen
IntrospectionNameMap maPropertyNameMap;
IntrospectionNameMap maMethodNameMap;
LowerToExactNameMap maLowerToExactNameMap;
// Sequence aller Properties, auch zum Liefern aus getProperties()
Sequence<Property> maAllPropertySeq;
// Mapping der Properties auf Zugriffs-Arten
Sequence<sal_Int16> maMapTypeSeq;
// Klassifizierung der gefundenen Methoden
Sequence<sal_Int32> maPropertyConceptSeq;
// Anzahl der Properties
sal_Int32 mnPropCount;
// Anzahl der Properties, die den jeweiligen Konzepten zugeordnet sind
//sal_Int32 mnDangerousPropCount;
sal_Int32 mnPropertySetPropCount;
sal_Int32 mnAttributePropCount;
sal_Int32 mnMethodPropCount;
// Flag, ob ein FastPropertySet unterstuetzt wird
sal_Bool mbFastPropSet;
// Original-Handles eines FastPropertySets
sal_Int32* mpOrgPropertyHandleArray;
// MethodSequence, die alle Methoden aufnimmt
Sequence< Reference<XIdlMethod> > maAllMethodSeq;
// Klassifizierung der gefundenen Methoden
Sequence<sal_Int32> maMethodConceptSeq;
// Anzahl der Methoden
sal_Int32 mnMethCount;
// Sequence der Listener, die angemeldet werden koennen
Sequence< Type > maSupportedListenerSeq;
// BaseInit (soll spaeter in der Applikation erfolgen!)
void BaseInit( void );
// Hilfs-Methoden zur Groessen-Anpassung der Sequences
void checkPropertyArraysSize
(
Property*& rpAllPropArray,
sal_Int16*& rpMapTypeArray,
sal_Int32*& rpPropertyConceptArray,
sal_Int32 iNextIndex
);
void checkInterfaceArraySize( Sequence< Reference<XInterface> >& rSeq, Reference<XInterface>*& rpInterfaceArray,
sal_Int32 iNextIndex );
// RefCount
sal_Int32 nRefCount;
public:
IntrospectionAccessStatic_Impl( Reference< XIdlReflection > xCoreReflection_ );
~IntrospectionAccessStatic_Impl()
{
delete[] mpOrgPropertyHandleArray;
}
sal_Int32 getPropertyIndex( const OUString& aPropertyName ) const;
sal_Int32 getMethodIndex( const OUString& aMethodName ) const;
void acquire() { nRefCount++; }
void release()
{
nRefCount--;
if( nRefCount <= 0 )
delete this;
}
// Methoden von XIntrospectionAccess (ALT, jetzt nur Impl)
void setPropertyValue(const Any& obj, const OUString& aPropertyName, const Any& aValue) const;
// void setPropertyValue(Any& obj, const OUString& aPropertyName, const Any& aValue) const;
Any getPropertyValue(const Any& obj, const OUString& aPropertyName) const;
void setPropertyValueByIndex(const Any& obj, sal_Int32 nIndex, const Any& aValue) const;
// void setPropertyValueByIndex(Any& obj, sal_Int32 nIndex, const Any& aValue) const;
Any getPropertyValueByIndex(const Any& obj, sal_Int32 nIndex) const;
Sequence<Property> getProperties(void) const { return maAllPropertySeq; }
Sequence< Reference<XIdlMethod> > getMethods(void) const { return maAllMethodSeq; }
Sequence< Type > getSupportedListeners(void) const { return maSupportedListenerSeq; }
Sequence<sal_Int32> getPropertyConcepts(void) const { return maPropertyConceptSeq; }
Sequence<sal_Int32> getMethodConcepts(void) const { return maMethodConceptSeq; }
};
// Ctor
IntrospectionAccessStatic_Impl::IntrospectionAccessStatic_Impl( Reference< XIdlReflection > xCoreReflection_ )
: mxCoreReflection( xCoreReflection_ )
{
aInterfaceSeq1.realloc( ARRAY_SIZE_STEP );
aInterfaceSeq2.realloc( ARRAY_SIZE_STEP );
// Property-Daten
maAllPropertySeq.realloc( ARRAY_SIZE_STEP );
maMapTypeSeq.realloc( ARRAY_SIZE_STEP );
maPropertyConceptSeq.realloc( ARRAY_SIZE_STEP );
mbFastPropSet = sal_False;
mpOrgPropertyHandleArray = NULL;
mnPropCount = 0;
//mnDangerousPropCount = 0;
mnPropertySetPropCount = 0;
mnAttributePropCount = 0;
mnMethodPropCount = 0;
// Method-Daten
mnMethCount = 0;
// Eigenens RefCounting
nRefCount = 0;
}
// Von Hand refcounten !!!
sal_Int32 IntrospectionAccessStatic_Impl::getPropertyIndex( const OUString& aPropertyName ) const
{
sal_Int32 iHashResult = -1;
IntrospectionAccessStatic_Impl* pThis = (IntrospectionAccessStatic_Impl*)this;
IntrospectionNameMap::iterator aIt = pThis->maPropertyNameMap.find( aPropertyName );
if( !( aIt == pThis->maPropertyNameMap.end() ) )
iHashResult = (*aIt).second;
return iHashResult;
}
sal_Int32 IntrospectionAccessStatic_Impl::getMethodIndex( const OUString& aMethodName ) const
{
sal_Int32 iHashResult = -1;
IntrospectionAccessStatic_Impl* pThis = (IntrospectionAccessStatic_Impl*)this;
IntrospectionNameMap::iterator aIt = pThis->maMethodNameMap.find( aMethodName );
if( !( aIt == pThis->maMethodNameMap.end() ) )
{
iHashResult = (*aIt).second;
}
// #95159 Check if full qualified name matches
else
{
sal_Int32 nSearchFrom = aMethodName.getLength();
nSearchFrom = aMethodName.getLength();
while( true )
{
// Strategy: Search back until the first '_' is found
sal_Int32 nFound = aMethodName.lastIndexOf( '_', nSearchFrom );
if( nFound == -1 )
break;
OUString aPureMethodName = aMethodName.copy( nFound + 1 );
aIt = pThis->maMethodNameMap.find( aPureMethodName );
if( !( aIt == pThis->maMethodNameMap.end() ) )
{
// Check if it can be a type?
// Problem: Does not work if package names contain _ ?!
OUString aStr = aMethodName.copy( 0, nFound );
OUString aTypeName = aStr.replace( '_', '.' );
Reference< XIdlClass > xClass = mxCoreReflection->forName( aTypeName );
if( xClass.is() )
{
// If this is a valid class it could be the right method
// Could be the right method, type has to be checked
iHashResult = (*aIt).second;
const Reference<XIdlMethod>* pMethods = maAllMethodSeq.getConstArray();
const Reference<XIdlMethod> xMethod = pMethods[ iHashResult ];
Reference< XIdlClass > xMethClass = xMethod->getDeclaringClass();
if( xClass->equals( xMethClass ) )
{
break;
}
else
{
iHashResult = -1;
// Could also be another method with the same name
// Iterate over all methods
sal_Int32 nLen = maAllMethodSeq.getLength();
for( int i = 0 ; i < nLen ; ++i )
{
const Reference<XIdlMethod> xMethod2 = pMethods[ i ];
OUString aTestClassName = xMethod2->getDeclaringClass()->getName();
OUString aTestMethodName = xMethod2->getName();
if( xMethod2->getName() == aPureMethodName )
{
Reference< XIdlClass > xMethClass2 = xMethod2->getDeclaringClass();
if( xClass->equals( xMethClass2 ) )
{
iHashResult = i;
break;
}
}
}
if( iHashResult != -1 )
break;
}
}
}
nSearchFrom = nFound - 1;
if( nSearchFrom < 0 )
break;
}
}
return iHashResult;
}
void IntrospectionAccessStatic_Impl::setPropertyValue( const Any& obj, const OUString& aPropertyName, const Any& aValue ) const
//void IntrospectionAccessStatic_Impl::setPropertyValue( Any& obj, const OUString& aPropertyName, const Any& aValue ) const
{
sal_Int32 i = getPropertyIndex( aPropertyName );
if( i != -1 )
setPropertyValueByIndex( obj, (sal_Int32)i, aValue );
else
throw UnknownPropertyException();
}
void IntrospectionAccessStatic_Impl::setPropertyValueByIndex(const Any& obj, sal_Int32 nSequenceIndex, const Any& aValue) const
//void IntrospectionAccessStatic_Impl::setPropertyValueByIndex( Any& obj, sal_Int32 nSequenceIndex, const Any& aValue) const
{
// Handelt es sich bei dem uebergebenen Objekt ueberhaupt um was passendes?
TypeClass eObjType = obj.getValueType().getTypeClass();
Reference<XInterface> xInterface;
if( eObjType == TypeClass_INTERFACE )
{
xInterface = *( Reference<XInterface>*)obj.getValue();
}
else if( nSequenceIndex >= mnPropCount || ( eObjType != TypeClass_STRUCT && eObjType != TypeClass_EXCEPTION ) )
{
throw IllegalArgumentException();
}
// Flags pruefen
const Property* pProps = maAllPropertySeq.getConstArray();
if( (pProps[ nSequenceIndex ].Attributes & READONLY) != 0 )
{
throw UnknownPropertyException();
}
const sal_Int16* pMapTypeArray = maMapTypeSeq.getConstArray();
switch( pMapTypeArray[ nSequenceIndex ] )
{
case MAP_PROPERTY_SET:
{
// Property besorgen
const Property& rProp = maAllPropertySeq.getConstArray()[ nSequenceIndex ];
// Interface-Parameter auf den richtigen Typ bringen
sal_Bool bUseCopy = sal_False;
Any aRealValue;
TypeClass eValType = aValue.getValueType().getTypeClass();
if( eValType == TypeClass_INTERFACE )
{
Type aPropType = rProp.Type;
OUString aTypeName( aPropType.getTypeName() );
Reference< XIdlClass > xPropClass = mxCoreReflection->forName( aTypeName );
//Reference<XIdlClass> xPropClass = rProp.Type;
if( xPropClass.is() && xPropClass->getTypeClass() == TypeClass_INTERFACE )
{
Reference<XInterface> valInterface = *(Reference<XInterface>*)aValue.getValue();
if( valInterface.is() )
{
//Any queryInterface( const Type& rType );
aRealValue = valInterface->queryInterface( aPropType );
if( aRealValue.hasValue() )
bUseCopy = sal_True;
}
}
}
// Haben wir ein FastPropertySet und ein gueltiges Handle?
// ACHTUNG: An dieser Stelle wird ausgenutzt, dass das PropertySet
// zu Beginn des Introspection-Vorgangs abgefragt wird.
sal_Int32 nOrgHandle;
if( mbFastPropSet && ( nOrgHandle = mpOrgPropertyHandleArray[ nSequenceIndex ] ) != -1 )
{
// PropertySet-Interface holen
Reference<XFastPropertySet> xFastPropSet =
Reference<XFastPropertySet>::query( xInterface );
if( xFastPropSet.is() )
{
xFastPropSet->setFastPropertyValue( nOrgHandle, bUseCopy ? aRealValue : aValue );
}
else
{
// throw UnknownPropertyException
}
}
// sonst eben das normale nehmen
else
{
// PropertySet-Interface holen
Reference<XPropertySet> xPropSet =
Reference<XPropertySet>::query( xInterface );
if( xPropSet.is() )
{
xPropSet->setPropertyValue( rProp.Name, bUseCopy ? aRealValue : aValue );
}
else
{
// throw UnknownPropertyException
}
}
}
break;
case MAP_FIELD:
{
Reference<XIdlField> xField = (XIdlField*)(aInterfaceSeq1.getConstArray()[ nSequenceIndex ].get());
Reference<XIdlField2> xField2(xField, UNO_QUERY);
if( xField2.is() )
{
xField2->set( (Any&)obj, aValue );
// IllegalArgumentException
// NullPointerException
} else
if( xField.is() )
{
xField->set( obj, aValue );
// IllegalArgumentException
// NullPointerException
}
else
{
// throw IllegalArgumentException();
}
}
break;
case MAP_GETSET:
case MAP_SETONLY:
{
// set-Methode holen
Reference<XIdlMethod> xMethod = (XIdlMethod*)(aInterfaceSeq2.getConstArray()[ nSequenceIndex ].get());
if( xMethod.is() )
{
Sequence<Any> args( 1 );
args.getArray()[0] = aValue;
xMethod->invoke( obj, args );
}
else
{
// throw IllegalArgumentException();
}
}
break;
}
}
Any IntrospectionAccessStatic_Impl::getPropertyValue( const Any& obj, const OUString& aPropertyName ) const
{
sal_Int32 i = getPropertyIndex( aPropertyName );
if( i != -1 )
return getPropertyValueByIndex( obj, i );
throw UnknownPropertyException();
}
Any IntrospectionAccessStatic_Impl::getPropertyValueByIndex(const Any& obj, sal_Int32 nSequenceIndex) const
{
Any aRet;
// Handelt es sich bei dem uebergebenen Objekt ueberhaupt um was passendes?
TypeClass eObjType = obj.getValueType().getTypeClass();
Reference<XInterface> xInterface;
if( eObjType == TypeClass_INTERFACE )
{
xInterface = *(Reference<XInterface>*)obj.getValue();
}
else if( nSequenceIndex >= mnPropCount || ( eObjType != TypeClass_STRUCT && eObjType != TypeClass_EXCEPTION ) )
{
// throw IllegalArgumentException();
return aRet;
}
const sal_Int16* pMapTypeArray = maMapTypeSeq.getConstArray();
switch( pMapTypeArray[ nSequenceIndex ] )
{
case MAP_PROPERTY_SET:
{
// Property besorgen
const Property& rProp = maAllPropertySeq.getConstArray()[ nSequenceIndex ];
// Haben wir ein FastPropertySet und ein gueltiges Handle?
// ACHTUNG: An dieser Stelle wird ausgenutzt, dass das PropertySet
// zu Beginn des Introspection-Vorgangs abgefragt wird.
sal_Int32 nOrgHandle;
if( mbFastPropSet && ( nOrgHandle = mpOrgPropertyHandleArray[ nSequenceIndex ] ) != -1 )
{
// PropertySet-Interface holen
Reference<XFastPropertySet> xFastPropSet =
Reference<XFastPropertySet>::query( xInterface );
if( xFastPropSet.is() )
{
aRet = xFastPropSet->getFastPropertyValue( nOrgHandle);
}
else
{
// throw UnknownPropertyException
return aRet;
}
}
// sonst eben das normale nehmen
else
{
// PropertySet-Interface holen
Reference<XPropertySet> xPropSet =
Reference<XPropertySet>::query( xInterface );
if( xPropSet.is() )
{
aRet = xPropSet->getPropertyValue( rProp.Name );
}
else
{
// throw UnknownPropertyException
return aRet;
}
}
}
break;
case MAP_FIELD:
{
Reference<XIdlField> xField = (XIdlField*)(aInterfaceSeq1.getConstArray()[ nSequenceIndex ].get());
if( xField.is() )
{
aRet = xField->get( obj );
// IllegalArgumentException
// NullPointerException
}
else
{
// throw IllegalArgumentException();
return aRet;
}
}
break;
case MAP_GETSET:
{
// get-Methode holen
Reference<XIdlMethod> xMethod = (XIdlMethod*)(aInterfaceSeq1.getConstArray()[ nSequenceIndex ].get());
if( xMethod.is() )
{
Sequence<Any> args;
aRet = xMethod->invoke( obj, args );
}
else
{
// throw IllegalArgumentException();
return aRet;
}
}
break;
case MAP_SETONLY:
// get-Methode gibt es nicht
// throw WriteOnlyPropertyException();
return aRet;
}
return aRet;
}
// Hilfs-Methoden zur Groessen-Anpassung der Sequences
void IntrospectionAccessStatic_Impl::checkPropertyArraysSize
(
Property*& rpAllPropArray,
sal_Int16*& rpMapTypeArray,
sal_Int32*& rpPropertyConceptArray,
sal_Int32 iNextIndex
)
{
sal_Int32 nLen = maAllPropertySeq.getLength();
if( iNextIndex >= nLen )
{
maAllPropertySeq.realloc( nLen + ARRAY_SIZE_STEP );
rpAllPropArray = maAllPropertySeq.getArray();
maMapTypeSeq.realloc( nLen + ARRAY_SIZE_STEP );
rpMapTypeArray = maMapTypeSeq.getArray();
maPropertyConceptSeq.realloc( nLen + ARRAY_SIZE_STEP );
rpPropertyConceptArray = maPropertyConceptSeq.getArray();
}
}
void IntrospectionAccessStatic_Impl::checkInterfaceArraySize( Sequence< Reference<XInterface> >& rSeq,
Reference<XInterface>*& rpInterfaceArray, sal_Int32 iNextIndex )
{
sal_Int32 nLen = rSeq.getLength();
if( iNextIndex >= nLen )
{
// Neue Groesse mit ARRAY_SIZE_STEP abgleichen
sal_Int32 nMissingSize = iNextIndex - nLen + 1;
sal_Int32 nSteps = nMissingSize / ARRAY_SIZE_STEP + 1;
sal_Int32 nNewSize = nLen + nSteps * ARRAY_SIZE_STEP;
rSeq.realloc( nNewSize );
rpInterfaceArray = rSeq.getArray();
}
}
//*******************************
//*** ImplIntrospectionAdapter ***
//*******************************
// Neue Impl-Klasse im Rahmen der Introspection-Umstellung auf Instanz-gebundene
// Introspection mit Property-Zugriff ueber XPropertySet. Die alte Klasse
// ImplIntrospectionAccess lebt als IntrospectionAccessStatic_Impl
class ImplIntrospectionAdapter :
public XPropertySet, public XFastPropertySet, public XPropertySetInfo,
public XNameContainer, public XIndexContainer,
public XEnumerationAccess, public XIdlArray,
public OWeakObject
{
// Parent-Objekt
ImplIntrospectionAccess* mpAccess;
// Untersuchtes Objekt
const Any& mrInspectedObject;
// Statische Daten der Introspection
IntrospectionAccessStatic_Impl* mpStaticImpl;
// Objekt als Interface
Reference<XInterface> mxIface;
// Original-Interfaces des Objekts
Reference<XElementAccess> mxObjElementAccess;
Reference<XNameContainer> mxObjNameContainer;
Reference<XNameAccess> mxObjNameAccess;
Reference<XIndexAccess> mxObjIndexAccess;
Reference<XIndexContainer> mxObjIndexContainer;
Reference<XEnumerationAccess> mxObjEnumerationAccess;
Reference<XIdlArray> mxObjIdlArray;
public:
ImplIntrospectionAdapter( ImplIntrospectionAccess* pAccess_,
const Any& obj, IntrospectionAccessStatic_Impl* pStaticImpl_ );
~ImplIntrospectionAdapter();
// Methoden von XInterface
virtual Any SAL_CALL queryInterface( const Type& rType ) throw( RuntimeException );
virtual void SAL_CALL acquire() throw() { OWeakObject::acquire(); }
virtual void SAL_CALL release() throw() { OWeakObject::release(); }
// Methoden von XPropertySet
virtual Reference<XPropertySetInfo> SAL_CALL getPropertySetInfo() throw( RuntimeException );
virtual void SAL_CALL setPropertyValue(const OUString& aPropertyName, const Any& aValue)
throw( UnknownPropertyException, PropertyVetoException, IllegalArgumentException, WrappedTargetException, RuntimeException );
virtual Any SAL_CALL getPropertyValue(const OUString& aPropertyName)
throw( UnknownPropertyException, WrappedTargetException, RuntimeException );
virtual void SAL_CALL addPropertyChangeListener(const OUString& aPropertyName, const Reference<XPropertyChangeListener>& aListener)
throw( UnknownPropertyException, WrappedTargetException, RuntimeException );
virtual void SAL_CALL removePropertyChangeListener(const OUString& aPropertyName, const Reference<XPropertyChangeListener>& aListener)
throw( UnknownPropertyException, WrappedTargetException, RuntimeException );
virtual void SAL_CALL addVetoableChangeListener(const OUString& aPropertyName, const Reference<XVetoableChangeListener>& aListener)
throw( UnknownPropertyException, WrappedTargetException, RuntimeException );
virtual void SAL_CALL removeVetoableChangeListener(const OUString& aPropertyName, const Reference<XVetoableChangeListener>& aListener)
throw( UnknownPropertyException, WrappedTargetException, RuntimeException );
// Methoden von XFastPropertySet
virtual void SAL_CALL setFastPropertyValue(sal_Int32 nHandle, const Any& aValue)
throw( UnknownPropertyException, PropertyVetoException, IllegalArgumentException, WrappedTargetException, RuntimeException );
virtual Any SAL_CALL getFastPropertyValue(sal_Int32 nHandle)
throw( UnknownPropertyException, WrappedTargetException, RuntimeException );
// Methoden von XPropertySetInfo
virtual Sequence< Property > SAL_CALL getProperties(void) throw( RuntimeException );
virtual Property SAL_CALL getPropertyByName(const OUString& Name) throw( RuntimeException );
virtual sal_Bool SAL_CALL hasPropertyByName(const OUString& Name) throw( RuntimeException );
// Methoden von XElementAccess
virtual Type SAL_CALL getElementType(void) throw( RuntimeException );
virtual sal_Bool SAL_CALL hasElements(void) throw( RuntimeException );
// Methoden von XNameAccess
virtual Any SAL_CALL getByName(const OUString& Name)
throw( NoSuchElementException, WrappedTargetException, RuntimeException );
virtual Sequence<OUString> SAL_CALL getElementNames(void) throw( RuntimeException );
virtual sal_Bool SAL_CALL hasByName(const OUString& Name) throw( RuntimeException );
// Methoden von XNameContainer
virtual void SAL_CALL insertByName(const OUString& Name, const Any& Element)
throw( IllegalArgumentException, ElementExistException, WrappedTargetException, RuntimeException );
virtual void SAL_CALL replaceByName(const OUString& Name, const Any& Element)
throw( IllegalArgumentException, NoSuchElementException, WrappedTargetException, RuntimeException );
virtual void SAL_CALL removeByName(const OUString& Name)
throw( NoSuchElementException, WrappedTargetException, RuntimeException );
// Methoden von XIndexAccess
virtual sal_Int32 SAL_CALL getCount(void) throw( RuntimeException );
virtual Any SAL_CALL getByIndex(sal_Int32 Index)
throw( IndexOutOfBoundsException, WrappedTargetException, RuntimeException );
// Methoden von XIndexContainer
virtual void SAL_CALL insertByIndex(sal_Int32 Index, const Any& Element)
throw( IllegalArgumentException, IndexOutOfBoundsException, WrappedTargetException, RuntimeException );
virtual void SAL_CALL replaceByIndex(sal_Int32 Index, const Any& Element)
throw( IllegalArgumentException, IndexOutOfBoundsException, WrappedTargetException, RuntimeException );
virtual void SAL_CALL removeByIndex(sal_Int32 Index)
throw( IndexOutOfBoundsException, WrappedTargetException, RuntimeException );
// Methoden von XEnumerationAccess
virtual Reference<XEnumeration> SAL_CALL createEnumeration(void) throw( RuntimeException );
// Methoden von XIdlArray
virtual void SAL_CALL realloc(Any& array, sal_Int32 length)
throw( IllegalArgumentException, RuntimeException );
virtual sal_Int32 SAL_CALL getLen(const Any& array) throw( IllegalArgumentException, RuntimeException );
virtual Any SAL_CALL get(const Any& array, sal_Int32 index)
throw( IllegalArgumentException, ArrayIndexOutOfBoundsException, RuntimeException );
virtual void SAL_CALL set(Any& array, sal_Int32 index, const Any& value)
throw( IllegalArgumentException, ArrayIndexOutOfBoundsException, RuntimeException );
};
ImplIntrospectionAdapter::ImplIntrospectionAdapter( ImplIntrospectionAccess* pAccess_,
const Any& obj, IntrospectionAccessStatic_Impl* pStaticImpl_ )
: mpAccess( pAccess_), mrInspectedObject( obj ), mpStaticImpl( pStaticImpl_ )
{
mpStaticImpl->acquire();
// Objekt als Interfaceholen
TypeClass eType = mrInspectedObject.getValueType().getTypeClass();
if( eType == TypeClass_INTERFACE )
{
mxIface = *( Reference< XInterface >*)mrInspectedObject.getValue();
mxObjElementAccess = Reference<XElementAccess>::query( mxIface );
mxObjNameAccess = Reference<XNameAccess>::query( mxIface );
mxObjNameContainer = Reference<XNameContainer>::query( mxIface );
mxObjIndexAccess = Reference<XIndexAccess>::query( mxIface );
mxObjIndexContainer = Reference<XIndexContainer>::query( mxIface );
mxObjEnumerationAccess = Reference<XEnumerationAccess>::query( mxIface );
mxObjIdlArray = Reference<XIdlArray>::query( mxIface );
}
}
ImplIntrospectionAdapter::~ImplIntrospectionAdapter()
{
mpStaticImpl->release();
}
// Methoden von XInterface
Any SAL_CALL ImplIntrospectionAdapter::queryInterface( const Type& rType )
throw( RuntimeException )
{
Any aRet( ::cppu::queryInterface(
rType,
static_cast< XPropertySet * >( this ),
static_cast< XFastPropertySet * >( this ),
static_cast< XPropertySetInfo * >( this ) ) );
if( !aRet.hasValue() )
aRet = OWeakObject::queryInterface( rType );
if( !aRet.hasValue() )
{
// Wrapper fuer die Objekt-Interfaces
if( ( mxObjElementAccess.is() && (aRet = ::cppu::queryInterface
( rType, static_cast< XElementAccess* >( static_cast< XNameAccess* >( this ) ) ) ).hasValue() )
|| ( mxObjNameAccess.is() && (aRet = ::cppu::queryInterface( rType, static_cast< XNameAccess* >( this ) ) ).hasValue() )
|| ( mxObjNameContainer.is() && (aRet = ::cppu::queryInterface( rType, static_cast< XNameContainer* >( this ) ) ).hasValue() )
|| ( mxObjIndexAccess.is() && (aRet = ::cppu::queryInterface( rType, static_cast< XIndexAccess* >( this ) ) ).hasValue() )
|| ( mxObjIndexContainer.is() && (aRet = ::cppu::queryInterface( rType, static_cast< XIndexContainer* >( this ) ) ).hasValue() )
|| ( mxObjEnumerationAccess .is() && (aRet = ::cppu::queryInterface( rType, static_cast< XEnumerationAccess* >( this ) ) ).hasValue() )
|| ( mxObjIdlArray.is() && (aRet = ::cppu::queryInterface( rType, static_cast< XIdlArray* >( this ) ) ).hasValue() )
)
{
}
}
return aRet;
}
//*******************************
//*** ImplIntrospectionAccess ***
//*******************************
// Neue Impl-Klasse im Rahmen der Introspection-Umstellung auf Instanz-gebundene
// Introspection mit Property-Zugriff ueber XPropertySet. Die alte Klasse
// ImplIntrospectionAccess lebt als IntrospectionAccessStatic_Impl
class ImplIntrospectionAccess : IntrospectionAccessHelper
{
friend class ImplIntrospection;
// Untersuchtes Objekt
Any maInspectedObject;
// Als Interface
Reference<XInterface> mxIface;
// Statische Daten der Introspection
IntrospectionAccessStatic_Impl* mpStaticImpl;
// Adapter-Implementation
ImplIntrospectionAdapter* mpAdapter;
// Letzte Sequence, die bei getProperties geliefert wurde (Optimierung)
Sequence<Property> maLastPropertySeq;
sal_Int32 mnLastPropertyConcept;
// Letzte Sequence, die bei getMethods geliefert wurde (Optimierung)
Sequence<Reference<XIdlMethod> > maLastMethodSeq;
sal_Int32 mnLastMethodConcept;
public:
ImplIntrospectionAccess( const Any& obj, IntrospectionAccessStatic_Impl* pStaticImpl_ );
~ImplIntrospectionAccess();
// Methoden von XIntrospectionAccess
virtual sal_Int32 SAL_CALL getSuppliedMethodConcepts(void)
throw( RuntimeException );
virtual sal_Int32 SAL_CALL getSuppliedPropertyConcepts(void)
throw( RuntimeException );
virtual Property SAL_CALL getProperty(const OUString& Name, sal_Int32 PropertyConcepts)
throw( NoSuchElementException, RuntimeException );
virtual sal_Bool SAL_CALL hasProperty(const OUString& Name, sal_Int32 PropertyConcepts)
throw( RuntimeException );
virtual Sequence< Property > SAL_CALL getProperties(sal_Int32 PropertyConcepts)
throw( RuntimeException );
virtual Reference<XIdlMethod> SAL_CALL getMethod(const OUString& Name, sal_Int32 MethodConcepts)
throw( NoSuchMethodException, RuntimeException );
virtual sal_Bool SAL_CALL hasMethod(const OUString& Name, sal_Int32 MethodConcepts)
throw( RuntimeException );
virtual Sequence< Reference<XIdlMethod> > SAL_CALL getMethods(sal_Int32 MethodConcepts)
throw( RuntimeException );
virtual Sequence< Type > SAL_CALL getSupportedListeners(void)
throw( RuntimeException );
using OWeakObject::queryAdapter;
virtual Reference<XInterface> SAL_CALL queryAdapter( const Type& rType )
throw( IllegalTypeException, RuntimeException );
// Methoden von XMaterialHolder
virtual Any SAL_CALL getMaterial(void) throw(RuntimeException);
// Methoden von XExactName
virtual OUString SAL_CALL getExactName( const OUString& rApproximateName ) throw( RuntimeException );
};
ImplIntrospectionAccess::ImplIntrospectionAccess
( const Any& obj, IntrospectionAccessStatic_Impl* pStaticImpl_ )
: maInspectedObject( obj ), mpStaticImpl( pStaticImpl_ ), mpAdapter( NULL )
{
mpStaticImpl->acquire();
// Objekt als Interface merken, wenn moeglich
TypeClass eType = maInspectedObject.getValueType().getTypeClass();
if( eType == TypeClass_INTERFACE )
mxIface = *(Reference<XInterface>*)maInspectedObject.getValue();
mnLastPropertyConcept = -1;
mnLastMethodConcept = -1;
}
ImplIntrospectionAccess::~ImplIntrospectionAccess()
{
mpStaticImpl->release();
// Eigene Referenz loslassen
if (mpAdapter)
mpAdapter->release();
}
//***************************************************
//*** Implementation von ImplIntrospectionAdapter ***
//***************************************************
// Methoden von XPropertySet
Reference<XPropertySetInfo> ImplIntrospectionAdapter::getPropertySetInfo(void)
throw( RuntimeException )
{
return (XPropertySetInfo *)this;
}
void ImplIntrospectionAdapter::setPropertyValue(const OUString& aPropertyName, const Any& aValue)
throw( UnknownPropertyException, PropertyVetoException, IllegalArgumentException, WrappedTargetException, RuntimeException )
{
mpStaticImpl->setPropertyValue( mrInspectedObject, aPropertyName, aValue );
}
Any ImplIntrospectionAdapter::getPropertyValue(const OUString& aPropertyName)
throw( UnknownPropertyException, WrappedTargetException, RuntimeException )
{
return mpStaticImpl->getPropertyValue( mrInspectedObject, aPropertyName );
}
void ImplIntrospectionAdapter::addPropertyChangeListener(const OUString& aPropertyName, const Reference<XPropertyChangeListener>& aListener)
throw( UnknownPropertyException, WrappedTargetException, RuntimeException )
{
if( mxIface.is() )
{
Reference<XPropertySet> xPropSet =
Reference<XPropertySet>::query( mxIface );
//Reference<XPropertySet> xPropSet( mxIface, USR_QUERY );
if( xPropSet.is() )
xPropSet->addPropertyChangeListener(aPropertyName, aListener);
}
}
void ImplIntrospectionAdapter::removePropertyChangeListener(const OUString& aPropertyName, const Reference<XPropertyChangeListener>& aListener)
throw( UnknownPropertyException, WrappedTargetException, RuntimeException )
{
if( mxIface.is() )
{
Reference<XPropertySet> xPropSet =
Reference<XPropertySet>::query( mxIface );
//Reference<XPropertySet> xPropSet( mxIface, USR_QUERY );
if( xPropSet.is() )
xPropSet->removePropertyChangeListener(aPropertyName, aListener);
}
}
void ImplIntrospectionAdapter::addVetoableChangeListener(const OUString& aPropertyName, const Reference<XVetoableChangeListener>& aListener)
throw( UnknownPropertyException, WrappedTargetException, RuntimeException )
{
if( mxIface.is() )
{
Reference<XPropertySet> xPropSet =
Reference<XPropertySet>::query( mxIface );
//Reference<XPropertySet> xPropSet( mxIface, USR_QUERY );
if( xPropSet.is() )
xPropSet->addVetoableChangeListener(aPropertyName, aListener);
}
}
void ImplIntrospectionAdapter::removeVetoableChangeListener(const OUString& aPropertyName, const Reference<XVetoableChangeListener>& aListener)
throw( UnknownPropertyException, WrappedTargetException, RuntimeException )
{
if( mxIface.is() )
{
Reference<XPropertySet> xPropSet =
Reference<XPropertySet>::query( mxIface );
if( xPropSet.is() )
xPropSet->removeVetoableChangeListener(aPropertyName, aListener);
}
}
// Methoden von XFastPropertySet
void ImplIntrospectionAdapter::setFastPropertyValue(sal_Int32, const Any&)
throw( UnknownPropertyException, PropertyVetoException, IllegalArgumentException, WrappedTargetException, RuntimeException )
{
}
Any ImplIntrospectionAdapter::getFastPropertyValue(sal_Int32)
throw( UnknownPropertyException, WrappedTargetException, RuntimeException )
{
return Any();
}
// Methoden von XPropertySetInfo
Sequence< Property > ImplIntrospectionAdapter::getProperties(void) throw( RuntimeException )
{
return mpStaticImpl->getProperties();
}
Property ImplIntrospectionAdapter::getPropertyByName(const OUString& Name)
throw( RuntimeException )
{
return mpAccess->getProperty( Name, PropertyConcept::ALL );
}
sal_Bool ImplIntrospectionAdapter::hasPropertyByName(const OUString& Name)
throw( RuntimeException )
{
return mpAccess->hasProperty( Name, PropertyConcept::ALL );
}
// Methoden von XElementAccess
Type ImplIntrospectionAdapter::getElementType(void) throw( RuntimeException )
{
return mxObjElementAccess->getElementType();
}
sal_Bool ImplIntrospectionAdapter::hasElements(void) throw( RuntimeException )
{
return mxObjElementAccess->hasElements();
}
// Methoden von XNameAccess
Any ImplIntrospectionAdapter::getByName(const OUString& Name)
throw( NoSuchElementException, WrappedTargetException, RuntimeException )
{
return mxObjNameAccess->getByName( Name );
}
Sequence< OUString > ImplIntrospectionAdapter::getElementNames(void)
throw( RuntimeException )
{
return mxObjNameAccess->getElementNames();
}
sal_Bool ImplIntrospectionAdapter::hasByName(const OUString& Name)
throw( RuntimeException )
{
return mxObjNameAccess->hasByName( Name );
}
// Methoden von XNameContainer
void ImplIntrospectionAdapter::insertByName(const OUString& Name, const Any& Element)
throw( IllegalArgumentException, ElementExistException, WrappedTargetException, RuntimeException )
{
mxObjNameContainer->insertByName( Name, Element );
}
void ImplIntrospectionAdapter::replaceByName(const OUString& Name, const Any& Element)
throw( IllegalArgumentException, NoSuchElementException, WrappedTargetException, RuntimeException )
{
mxObjNameContainer->replaceByName( Name, Element );
}
void ImplIntrospectionAdapter::removeByName(const OUString& Name)
throw( NoSuchElementException, WrappedTargetException, RuntimeException )
{
mxObjNameContainer->removeByName( Name );
}
// Methoden von XIndexAccess
// Schon in XNameAccess: virtual Reference<XIdlClass> getElementType(void) const
sal_Int32 ImplIntrospectionAdapter::getCount(void) throw( RuntimeException )
{
return mxObjIndexAccess->getCount();
}
Any ImplIntrospectionAdapter::getByIndex(sal_Int32 Index)
throw( IndexOutOfBoundsException, WrappedTargetException, RuntimeException )
{
return mxObjIndexAccess->getByIndex( Index );
}
// Methoden von XIndexContainer
void ImplIntrospectionAdapter::insertByIndex(sal_Int32 Index, const Any& Element)
throw( IllegalArgumentException, IndexOutOfBoundsException, WrappedTargetException, RuntimeException )
{
mxObjIndexContainer->insertByIndex( Index, Element );
}
void ImplIntrospectionAdapter::replaceByIndex(sal_Int32 Index, const Any& Element)
throw( IllegalArgumentException, IndexOutOfBoundsException, WrappedTargetException, RuntimeException )
{
mxObjIndexContainer->replaceByIndex( Index, Element );
}
void ImplIntrospectionAdapter::removeByIndex(sal_Int32 Index)
throw( IndexOutOfBoundsException, WrappedTargetException, RuntimeException )
{
mxObjIndexContainer->removeByIndex( Index );
}
// Methoden von XEnumerationAccess
// Schon in XNameAccess: virtual Reference<XIdlClass> getElementType(void) const;
Reference<XEnumeration> ImplIntrospectionAdapter::createEnumeration(void) throw( RuntimeException )
{
return mxObjEnumerationAccess->createEnumeration();
}
// Methoden von XIdlArray
void ImplIntrospectionAdapter::realloc(Any& array, sal_Int32 length)
throw( IllegalArgumentException, RuntimeException )
{
mxObjIdlArray->realloc( array, length );
}
sal_Int32 ImplIntrospectionAdapter::getLen(const Any& array)
throw( IllegalArgumentException, RuntimeException )
{
return mxObjIdlArray->getLen( array );
}
Any ImplIntrospectionAdapter::get(const Any& array, sal_Int32 index)
throw( IllegalArgumentException, ArrayIndexOutOfBoundsException, RuntimeException )
{
return mxObjIdlArray->get( array, index );
}
void ImplIntrospectionAdapter::set(Any& array, sal_Int32 index, const Any& value)
throw( IllegalArgumentException, ArrayIndexOutOfBoundsException, RuntimeException )
{
mxObjIdlArray->set( array, index, value );
}
//**************************************************
//*** Implementation von ImplIntrospectionAccess ***
//**************************************************
// Methoden von XIntrospectionAccess
sal_Int32 ImplIntrospectionAccess::getSuppliedMethodConcepts(void)
throw( RuntimeException )
{
return MethodConcept::DANGEROUS |
PROPERTY |
LISTENER |
ENUMERATION |
NAMECONTAINER |
INDEXCONTAINER;
}
sal_Int32 ImplIntrospectionAccess::getSuppliedPropertyConcepts(void)
throw( RuntimeException )
{
return PropertyConcept::DANGEROUS |
PROPERTYSET |
ATTRIBUTES |
METHODS;
}
Property ImplIntrospectionAccess::getProperty(const OUString& Name, sal_Int32 PropertyConcepts)
throw( NoSuchElementException, RuntimeException )
{
Property aRet;
sal_Int32 i = mpStaticImpl->getPropertyIndex( Name );
sal_Bool bFound = sal_False;
if( i != -1 )
{
sal_Int32 nConcept = mpStaticImpl->getPropertyConcepts().getConstArray()[ i ];
if( (PropertyConcepts & nConcept) != 0 )
{
const Property* pProps = mpStaticImpl->getProperties().getConstArray();
aRet = pProps[ i ];
bFound = sal_True;
}
}
if( !bFound )
throw NoSuchElementException() ;
return aRet;
}
sal_Bool ImplIntrospectionAccess::hasProperty(const OUString& Name, sal_Int32 PropertyConcepts)
throw( RuntimeException )
{
sal_Int32 i = mpStaticImpl->getPropertyIndex( Name );
sal_Bool bRet = sal_False;
if( i != -1 )
{
sal_Int32 nConcept = mpStaticImpl->getPropertyConcepts().getConstArray()[ i ];
if( (PropertyConcepts & nConcept) != 0 )
bRet = sal_True;
}
return bRet;
}
Sequence< Property > ImplIntrospectionAccess::getProperties(sal_Int32 PropertyConcepts)
throw( RuntimeException )
{
// Wenn alle unterstuetzten Konzepte gefordert werden, Sequence einfach durchreichen
sal_Int32 nAllSupportedMask = PROPERTYSET |
ATTRIBUTES |
METHODS;
if( ( PropertyConcepts & nAllSupportedMask ) == nAllSupportedMask )
{
return mpStaticImpl->getProperties();
}
// Gleiche Sequence wie beim vorigen mal?
if( mnLastPropertyConcept == PropertyConcepts )
{
return maLastPropertySeq;
}
// Anzahl der zu liefernden Properties
sal_Int32 nCount = 0;
// Es gibt zur Zeit keine DANGEROUS-Properties
// if( PropertyConcepts & DANGEROUS )
// nCount += mpStaticImpl->mnDangerousPropCount;
if( PropertyConcepts & PROPERTYSET )
nCount += mpStaticImpl->mnPropertySetPropCount;
if( PropertyConcepts & ATTRIBUTES )
nCount += mpStaticImpl->mnAttributePropCount;
if( PropertyConcepts & METHODS )
nCount += mpStaticImpl->mnMethodPropCount;
// Sequence entsprechend der geforderten Anzahl reallocieren
ImplIntrospectionAccess* pThis = (ImplIntrospectionAccess*)this; // const umgehen
pThis->maLastPropertySeq.realloc( nCount );
Property* pDestProps = pThis->maLastPropertySeq.getArray();
// Alle Properties durchgehen und entsprechend der Concepte uebernehmen
Sequence<Property> aPropSeq = mpStaticImpl->getProperties();
const Property* pSourceProps = aPropSeq.getConstArray();
const sal_Int32* pConcepts = mpStaticImpl->getPropertyConcepts().getConstArray();
sal_Int32 nLen = aPropSeq.getLength();
sal_Int32 iDest = 0;
for( sal_Int32 i = 0 ; i < nLen ; i++ )
{
sal_Int32 nConcept = pConcepts[ i ];
if( nConcept & PropertyConcepts )
pDestProps[ iDest++ ] = pSourceProps[ i ];
}
// PropertyConcept merken, dies entspricht maLastPropertySeq
pThis->mnLastPropertyConcept = PropertyConcepts;
// Zusammengebastelte Sequence liefern
return maLastPropertySeq;
}
Reference<XIdlMethod> ImplIntrospectionAccess::getMethod(const OUString& Name, sal_Int32 MethodConcepts)
throw( NoSuchMethodException, RuntimeException )
{
Reference<XIdlMethod> xRet;
sal_Int32 i = mpStaticImpl->getMethodIndex( Name );
if( i != -1 )
{
sal_Int32 nConcept = mpStaticImpl->getMethodConcepts().getConstArray()[ i ];
if( (MethodConcepts & nConcept) != 0 )
{
const Reference<XIdlMethod>* pMethods = mpStaticImpl->getMethods().getConstArray();
xRet = pMethods[i];
}
}
if( !xRet.is() )
throw NoSuchMethodException();
return xRet;
}
sal_Bool ImplIntrospectionAccess::hasMethod(const OUString& Name, sal_Int32 MethodConcepts)
throw( RuntimeException )
{
sal_Int32 i = mpStaticImpl->getMethodIndex( Name );
sal_Bool bRet = sal_False;
if( i != -1 )
{
sal_Int32 nConcept = mpStaticImpl->getMethodConcepts().getConstArray()[ i ];
if( (MethodConcepts & nConcept) != 0 )
bRet = sal_True;
}
return bRet;
}
Sequence< Reference<XIdlMethod> > ImplIntrospectionAccess::getMethods(sal_Int32 MethodConcepts)
throw( RuntimeException )
{
ImplIntrospectionAccess* pThis = (ImplIntrospectionAccess*)this; // const umgehen
// Wenn alle unterstuetzten Konzepte gefordert werden, Sequence einfach durchreichen
sal_Int32 nAllSupportedMask = MethodConcept::DANGEROUS |
PROPERTY |
LISTENER |
ENUMERATION |
NAMECONTAINER |
INDEXCONTAINER |
MethodConcept_NORMAL_IMPL;
if( ( MethodConcepts & nAllSupportedMask ) == nAllSupportedMask )
{
return mpStaticImpl->getMethods();
}
// Gleiche Sequence wie beim vorigen mal?
if( mnLastMethodConcept == MethodConcepts )
{
return maLastMethodSeq;
}
// Methoden-Sequences besorgen
Sequence< Reference<XIdlMethod> > aMethodSeq = mpStaticImpl->getMethods();
const Reference<XIdlMethod>* pSourceMethods = aMethodSeq.getConstArray();
const sal_Int32* pConcepts = mpStaticImpl->getMethodConcepts().getConstArray();
sal_Int32 nLen = aMethodSeq.getLength();
// Sequence entsprechend der geforderten Anzahl reallocieren
// Anders als bei den Properties kann die Anzahl nicht durch
// Zaehler in inspect() vorher ermittelt werden, da Methoden
// mehreren Konzepten angehoeren koennen
pThis->maLastMethodSeq.realloc( nLen );
Reference<XIdlMethod>* pDestMethods = pThis->maLastMethodSeq.getArray();
// Alle Methods durchgehen und entsprechend der Concepte uebernehmen
sal_Int32 iDest = 0;
for( sal_Int32 i = 0 ; i < nLen ; i++ )
{
sal_Int32 nConcept = pConcepts[ i ];
if( nConcept & MethodConcepts )
pDestMethods[ iDest++ ] = pSourceMethods[ i ];
#if OSL_DEBUG_LEVEL > 0
static bool debug = false;
if ( debug )
{
// Methode mit Concepts ausgeben
const Reference< XIdlMethod >& rxMethod = pSourceMethods[ i ];
::rtl::OString aNameStr = ::rtl::OUStringToOString( rxMethod->getName(), osl_getThreadTextEncoding() );
::rtl::OString ConceptStr;
if( nConcept & MethodConcept::DANGEROUS )
ConceptStr += "DANGEROUS |";
if( nConcept & MethodConcept::PROPERTY )
ConceptStr += "PROPERTY |";
if( nConcept & MethodConcept::LISTENER )
ConceptStr += "LISTENER |";
if( nConcept & MethodConcept::ENUMERATION )
ConceptStr += "ENUMERATION |";
if( nConcept & MethodConcept::NAMECONTAINER )
ConceptStr += "NAMECONTAINER |";
if( nConcept & MethodConcept::INDEXCONTAINER )
ConceptStr += "INDEXCONTAINER |";
OSL_TRACE( "Method %ld: %s, Concepts = %s", i, aNameStr.getStr(), ConceptStr.getStr() );
}
#endif
}
// Auf die richtige Laenge bringen
pThis->maLastMethodSeq.realloc( iDest );
// MethodConcept merken, dies entspricht maLastMethodSeq
pThis->mnLastMethodConcept = MethodConcepts;
// Zusammengebastelte Sequence liefern
return maLastMethodSeq;
}
Sequence< Type > ImplIntrospectionAccess::getSupportedListeners(void)
throw( RuntimeException )
{
return mpStaticImpl->getSupportedListeners();
}
Reference<XInterface> SAL_CALL ImplIntrospectionAccess::queryAdapter( const Type& rType )
throw( IllegalTypeException, RuntimeException )
{
// Gibt es schon einen Adapter?
if( !mpAdapter )
{
((ImplIntrospectionAccess*)this)->mpAdapter =
new ImplIntrospectionAdapter( this, maInspectedObject, mpStaticImpl );
// Selbst eine Referenz halten
mpAdapter->acquire();
}
Reference<XInterface> xRet;
Any aIfaceAny( mpAdapter->queryInterface( rType ) );
if( aIfaceAny.hasValue() )
xRet = *(Reference<XInterface>*)aIfaceAny.getValue();
return xRet;
}
// Methoden von XMaterialHolder
Any ImplIntrospectionAccess::getMaterial(void) throw(RuntimeException)
{
return maInspectedObject;
}
// Hilfs-Funktion zur LowerCase-Wandlung eines OUString
OUString toLower( OUString aUStr )
{
// Tabelle fuer XExactName pflegen
::rtl::OUString aOWStr( aUStr.getStr() );
::rtl::OUString aOWLowerStr = aOWStr.toAsciiLowerCase();
OUString aLowerUStr( aOWLowerStr.getStr() );
return aLowerUStr;
}
// Methoden von XExactName
OUString ImplIntrospectionAccess::getExactName( const OUString& rApproximateName ) throw( RuntimeException )
{
OUString aRetStr;
LowerToExactNameMap::iterator aIt =
mpStaticImpl->maLowerToExactNameMap.find( toLower( rApproximateName ) );
if( !( aIt == mpStaticImpl->maLowerToExactNameMap.end() ) )
aRetStr = (*aIt).second;
return aRetStr;
}
//-----------------------------------------------------------------------------
#ifdef USE_INTROSPECTION_CACHE
struct hashIntrospectionKey_Impl
{
Sequence< Reference<XIdlClass> > aIdlClasses;
Reference<XPropertySetInfo> xPropInfo;
Reference<XIdlClass> xImplClass;
sal_Int32 nHitCount;
void IncHitCount() const { ((hashIntrospectionKey_Impl*)this)->nHitCount++; }
hashIntrospectionKey_Impl() : nHitCount( 0 ) {}
hashIntrospectionKey_Impl( const Sequence< Reference<XIdlClass> > & rIdlClasses,
const Reference<XPropertySetInfo> & rxPropInfo,
const Reference<XIdlClass> & rxImplClass );
};
hashIntrospectionKey_Impl::hashIntrospectionKey_Impl
(
const Sequence< Reference<XIdlClass> > & rIdlClasses,
const Reference<XPropertySetInfo> & rxPropInfo,
const Reference<XIdlClass> & rxImplClass
)
: aIdlClasses( rIdlClasses )
, xPropInfo( rxPropInfo )
, xImplClass( rxImplClass )
, nHitCount( 0 )
{}
struct hashIntrospectionAccessCache_Impl
{
size_t operator()(const hashIntrospectionKey_Impl & rObj ) const
{
return (size_t)rObj.xImplClass.get() ^ (size_t)rObj.xPropInfo.get();
}
bool operator()( const hashIntrospectionKey_Impl & rObj1,
const hashIntrospectionKey_Impl & rObj2 ) const
{
if( rObj1.xPropInfo != rObj2.xPropInfo
|| rObj1.xImplClass != rObj2.xImplClass )
return sal_False;
sal_Int32 nCount1 = rObj1.aIdlClasses.getLength();
sal_Int32 nCount2 = rObj2.aIdlClasses.getLength();
if( nCount1 != nCount2 )
return sal_False;
const Reference<XIdlClass>* pRefs1 = rObj1.aIdlClasses.getConstArray();
const Reference<XIdlClass>* pRefs2 = rObj2.aIdlClasses.getConstArray();
return memcmp( pRefs1, pRefs2, nCount1 * sizeof( Reference<XIdlClass> ) ) == 0;
}
};
typedef boost::unordered_map
<
hashIntrospectionKey_Impl,
IntrospectionAccessStatic_Impl*,
hashIntrospectionAccessCache_Impl,
hashIntrospectionAccessCache_Impl
>
IntrospectionAccessCacheMap_Impl;
class IntrospectionAccessCacheMap : public IntrospectionAccessCacheMap_Impl
{
public:
~IntrospectionAccessCacheMap()
{
IntrospectionAccessCacheMap::iterator iter = begin();
IntrospectionAccessCacheMap::iterator stop = this->end();
while( iter != stop )
{
(*iter).second->release();
(*iter).second = NULL;
++iter;
}
}
};
// For XTypeProvider
struct hashTypeProviderKey_Impl
{
Reference<XPropertySetInfo> xPropInfo;
Sequence< sal_Int8 > maImpIdSeq;
sal_Int32 nHitCount;
void IncHitCount() const { ((hashTypeProviderKey_Impl*)this)->nHitCount++; }
hashTypeProviderKey_Impl() : nHitCount( 0 ) {}
hashTypeProviderKey_Impl( const Reference<XPropertySetInfo> & rxPropInfo, const Sequence< sal_Int8 > & aImpIdSeq_ );
};
hashTypeProviderKey_Impl::hashTypeProviderKey_Impl
(
const Reference<XPropertySetInfo> & rxPropInfo,
const Sequence< sal_Int8 > & aImpIdSeq_
)
: xPropInfo( rxPropInfo )
, maImpIdSeq( aImpIdSeq_ )
, nHitCount( 0 )
{}
struct TypeProviderAccessCache_Impl
{
size_t operator()(const hashTypeProviderKey_Impl & rObj ) const;
bool operator()( const hashTypeProviderKey_Impl & rObj1,
const hashTypeProviderKey_Impl & rObj2 ) const
{
if( rObj1.xPropInfo != rObj2.xPropInfo )
return sal_False;
bool bEqual = false;
sal_Int32 nLen1 = rObj1.maImpIdSeq.getLength();
sal_Int32 nLen2 = rObj2.maImpIdSeq.getLength();
if( nLen1 == nLen2 && nLen1 > 0 )
{
const sal_Int8* pId1 = rObj1.maImpIdSeq.getConstArray();
const sal_Int8* pId2 = rObj2.maImpIdSeq.getConstArray();
bEqual = (memcmp( pId1, pId2, nLen1 * sizeof( sal_Int8 ) ) == 0 );
}
return bEqual;
}
};
size_t TypeProviderAccessCache_Impl::operator()(const hashTypeProviderKey_Impl & rObj ) const
{
const sal_Int32* pBytesAsInt32Array = (const sal_Int32*)rObj.maImpIdSeq.getConstArray();
sal_Int32 nLen = rObj.maImpIdSeq.getLength();
sal_Int32 nCount32 = nLen / 4;
sal_Int32 nMod32 = nLen % 4;
// XOR with full 32 bit values
sal_Int32 nId32 = 0;
sal_Int32 i;
for( i = 0 ; i < nCount32 ; i++ )
nId32 ^= *(pBytesAsInt32Array++);
// XOR with remaining byte values
if( nMod32 )
{
const sal_Int8* pBytes = (const sal_Int8*)pBytesAsInt32Array;
sal_Int8* pInt8_Id32 = (sal_Int8*)&nId32;
for( i = 0 ; i < nMod32 ; i++ )
*(pInt8_Id32++) ^= *(pBytes++);
}
return (size_t)nId32;
}
typedef boost::unordered_map
<
hashTypeProviderKey_Impl,
IntrospectionAccessStatic_Impl*,
TypeProviderAccessCache_Impl,
TypeProviderAccessCache_Impl
>
TypeProviderAccessCacheMap_Impl;
class TypeProviderAccessCacheMap : public TypeProviderAccessCacheMap_Impl
{
public:
~TypeProviderAccessCacheMap()
{
TypeProviderAccessCacheMap::iterator iter = begin();
TypeProviderAccessCacheMap::iterator stop = this->end();
while( iter != stop )
{
(*iter).second->release();
(*iter).second = NULL;
++iter;
}
}
};
#endif
//*************************
//*** ImplIntrospection ***
//*************************
struct OIntrospectionMutex
{
Mutex m_mutex;
};
class ImplIntrospection : public XIntrospection
, public XServiceInfo
, public OIntrospectionMutex
, public OComponentHelper
{
friend class ImplMergeIntrospection;
friend class ImplMVCIntrospection;
// Implementation der Introspection.
// ACHTUNG: RefCounting von Hand !!!
IntrospectionAccessStatic_Impl* implInspect(const Any& aToInspectObj);
// Save XMultiServiceFactory from createComponent
Reference<XMultiServiceFactory> m_xSMgr;
// CoreReflection halten
Reference< XIdlReflection > mxCoreReflection;
// Klassen, deren Methoden eine spezielle Rolle spielen
Reference<XIdlClass> mxElementAccessClass;
Reference<XIdlClass> mxNameContainerClass;
Reference<XIdlClass> mxNameAccessClass;
Reference<XIdlClass> mxIndexContainerClass;
Reference<XIdlClass> mxIndexAccessClass;
Reference<XIdlClass> mxEnumerationAccessClass;
Reference<XIdlClass> mxInterfaceClass;
Reference<XIdlClass> mxAggregationClass;
sal_Bool mbDisposed;
#ifdef USE_INTROSPECTION_CACHE
sal_uInt16 mnCacheEntryCount;
sal_uInt16 mnTPCacheEntryCount;
IntrospectionAccessCacheMap* mpCache;
TypeProviderAccessCacheMap* mpTypeProviderCache;
#endif
public:
ImplIntrospection( const Reference<XMultiServiceFactory> & rXSMgr );
// Methoden von XInterface
virtual Any SAL_CALL queryInterface( const Type& rType ) throw( RuntimeException );
virtual void SAL_CALL acquire() throw() { OComponentHelper::acquire(); }
virtual void SAL_CALL release() throw() { OComponentHelper::release(); }
// XTypeProvider
Sequence< Type > SAL_CALL getTypes( ) throw( RuntimeException );
Sequence<sal_Int8> SAL_CALL getImplementationId( ) throw( RuntimeException );
// XServiceInfo
OUString SAL_CALL getImplementationName() throw();
sal_Bool SAL_CALL supportsService(const OUString& ServiceName) throw();
Sequence< OUString > SAL_CALL getSupportedServiceNames(void) throw();
static OUString SAL_CALL getImplementationName_Static( );
static Sequence< OUString > SAL_CALL getSupportedServiceNames_Static(void) throw();
// Methoden von XIntrospection
virtual Reference<XIntrospectionAccess> SAL_CALL inspect(const Any& aToInspectObj)
throw( RuntimeException );
protected:
// some XComponent part from OComponentHelper
virtual void SAL_CALL dispose() throw(::com::sun::star::uno::RuntimeException);
};
enum MethodType
{
STANDARD_METHOD, // normale Methode, kein Bezug zu Properties oder Listenern
GETSET_METHOD, // gehoert zu einer get/set-Property
ADD_LISTENER_METHOD, // add-Methode einer Listener-Schnittstelle
REMOVE_LISTENER_METHOD, // remove-Methode einer Listener-Schnittstelle
INVALID_METHOD // Methode, deren Klasse nicht beruecksichtigt wird, z.B. XPropertySet
};
// Ctor
ImplIntrospection::ImplIntrospection( const Reference<XMultiServiceFactory> & rXSMgr )
: OComponentHelper( m_mutex )
, m_xSMgr( rXSMgr )
{
#ifdef USE_INTROSPECTION_CACHE
mnCacheEntryCount = 0;
mnTPCacheEntryCount = 0;
mpCache = NULL;
mpTypeProviderCache = NULL;
#endif
// Spezielle Klassen holen
// Reference< XInterface > xServiceIface = m_xSMgr->createInstance( OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.reflection.CoreReflection")) );
// if( xServiceIface.is() )
// mxCoreReflection = Reference< XIdlReflection >::query( xServiceIface );
Reference< XPropertySet > xProps( rXSMgr, UNO_QUERY );
OSL_ASSERT( xProps.is() );
if (xProps.is())
{
Reference< XComponentContext > xContext;
xProps->getPropertyValue(
OUString( RTL_CONSTASCII_USTRINGPARAM("DefaultContext") ) ) >>= xContext;
OSL_ASSERT( xContext.is() );
if (xContext.is())
{
xContext->getValueByName(
OUString( RTL_CONSTASCII_USTRINGPARAM("/singletons/com.sun.star.reflection.theCoreReflection") ) ) >>= mxCoreReflection;
OSL_ENSURE( mxCoreReflection.is(), "### CoreReflection singleton not accessible!?" );
}
}
if (! mxCoreReflection.is())
{
throw DeploymentException(
OUString( RTL_CONSTASCII_USTRINGPARAM("/singletons/com.sun.star.reflection.theCoreReflection singleton not accessible") ),
Reference< XInterface >() );
}
mxElementAccessClass = mxCoreReflection->forName( OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.container.XElementAccess")) );
mxNameContainerClass = mxCoreReflection->forName( OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.container.XNameContainer")) );
mxNameAccessClass = mxCoreReflection->forName( OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.container.XNameAccess")) );
mxIndexContainerClass = mxCoreReflection->forName( OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.container.XIndexContainer")) );
mxIndexAccessClass = mxCoreReflection->forName( OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.container.XIndexAccess")) );
mxEnumerationAccessClass = mxCoreReflection->forName( OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.container.XEnumerationAccess")) );
mxInterfaceClass = mxCoreReflection->forName( OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.uno.XInterface")) );
mxAggregationClass = mxCoreReflection->forName( OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.uno.XAggregation")) );
mbDisposed = sal_False;
}
// XComponent
void ImplIntrospection::dispose() throw(::com::sun::star::uno::RuntimeException)
{
OComponentHelper::dispose();
#ifdef USE_INTROSPECTION_CACHE
// Cache loeschen
delete mpCache;
mpCache = NULL;
delete mpTypeProviderCache;
mpTypeProviderCache = NULL;
#endif
mxElementAccessClass = NULL;
mxNameContainerClass = NULL;
mxNameAccessClass = NULL;
mxIndexContainerClass = NULL;
mxIndexAccessClass = NULL;
mxEnumerationAccessClass = NULL;
mxInterfaceClass = NULL;
mxAggregationClass = NULL;
mbDisposed = sal_True;
}
//-----------------------------------------------------------------------------
// XInterface
Any ImplIntrospection::queryInterface( const Type & rType )
throw(::com::sun::star::uno::RuntimeException)
{
Any aRet( ::cppu::queryInterface(
rType,
static_cast< XIntrospection * >( this ),
static_cast< XServiceInfo * >( this ) ) );
return (aRet.hasValue() ? aRet : OComponentHelper::queryInterface( rType ));
}
// XTypeProvider
Sequence< Type > ImplIntrospection::getTypes()
throw( RuntimeException )
{
static OTypeCollection * s_pTypes = 0;
if (! s_pTypes)
{
MutexGuard aGuard( Mutex::getGlobalMutex() );
if (! s_pTypes)
{
static OTypeCollection s_aTypes(
::getCppuType( (const Reference< XIntrospection > *)0 ),
::getCppuType( (const Reference< XServiceInfo > *)0 ),
OComponentHelper::getTypes() );
s_pTypes = &s_aTypes;
}
}
return s_pTypes->getTypes();
}
Sequence< sal_Int8 > ImplIntrospection::getImplementationId()
throw( RuntimeException )
{
static OImplementationId * s_pId = 0;
if (! s_pId)
{
MutexGuard aGuard( Mutex::getGlobalMutex() );
if (! s_pId)
{
static OImplementationId s_aId;
s_pId = &s_aId;
}
}
return s_pId->getImplementationId();
}
// XServiceInfo
OUString ImplIntrospection::getImplementationName() throw()
{
return getImplementationName_Static();
}
// XServiceInfo
sal_Bool ImplIntrospection::supportsService(const OUString& ServiceName) throw()
{
Sequence< OUString > aSNL = getSupportedServiceNames();
const OUString * pArray = aSNL.getConstArray();
for( sal_Int32 i = 0; i < aSNL.getLength(); i++ )
if( pArray[i] == ServiceName )
return sal_True;
return sal_False;
}
// XServiceInfo
Sequence< OUString > ImplIntrospection::getSupportedServiceNames(void) throw()
{
return getSupportedServiceNames_Static();
}
//*************************************************************************
// Helper XServiceInfo
OUString ImplIntrospection::getImplementationName_Static( )
{
return OUString(RTL_CONSTASCII_USTRINGPARAM(IMPLEMENTATION_NAME));
}
// ORegistryServiceManager_Static
Sequence< OUString > ImplIntrospection::getSupportedServiceNames_Static(void) throw()
{
Sequence< OUString > aSNS( 1 );
aSNS.getArray()[0] = OUString(RTL_CONSTASCII_USTRINGPARAM(SERVICE_NAME));
return aSNS;
}
//*************************************************************************
// Methoden von XIntrospection
Reference<XIntrospectionAccess> ImplIntrospection::inspect(const Any& aToInspectObj)
throw( RuntimeException )
{
Reference<XIntrospectionAccess> xAccess;
if ( aToInspectObj.getValueType().getTypeClass() == TypeClass_TYPE )
{
Type aType;
aToInspectObj >>= aType;
Reference< XIdlClass > xIdlClass = mxCoreReflection->forName(((Type*)(aToInspectObj.getValue()))->getTypeName());
if ( xIdlClass.is() )
{
Any aRealInspectObj;
aRealInspectObj <<= xIdlClass;
IntrospectionAccessStatic_Impl* pStaticImpl = implInspect( aRealInspectObj );
if( pStaticImpl )
xAccess = new ImplIntrospectionAccess( aRealInspectObj, pStaticImpl );
}
}
else
{
IntrospectionAccessStatic_Impl* pStaticImpl = implInspect( aToInspectObj );
if( pStaticImpl )
xAccess = new ImplIntrospectionAccess( aToInspectObj, pStaticImpl );
}
return xAccess;
}
//-----------------------------------------------------------------------------
// Hashtable fuer Pruefung auf mehrfache Beruecksichtigung von Interfaces
struct hashInterface_Impl
{
size_t operator()(const void* p) const
{
return (size_t)p;
}
};
struct eqInterface_Impl
{
bool operator()(const void* p1, const void* p2) const
{
return ( p1 == p2 );
}
};
typedef boost::unordered_map
<
void*,
void*,
hashInterface_Impl,
eqInterface_Impl
>
CheckedInterfacesMap;
// TODO: Spaeter auslagern
Reference<XIdlClass> TypeToIdlClass( const Type& rType, const Reference< XMultiServiceFactory > & xMgr )
{
static Reference< XIdlReflection > xRefl;
// void als Default-Klasse eintragen
Reference<XIdlClass> xRetClass;
typelib_TypeDescription * pTD = 0;
rType.getDescription( &pTD );
if( pTD )
{
OUString sOWName( pTD->pTypeName );
if( !xRefl.is() )
{
xRefl = Reference< XIdlReflection >( xMgr->createInstance( OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.reflection.CoreReflection")) ), UNO_QUERY );
OSL_ENSURE( xRefl.is(), "### no corereflection!" );
}
xRetClass = xRefl->forName( sOWName );
}
return xRetClass;
}
// Implementation der Introspection.
IntrospectionAccessStatic_Impl* ImplIntrospection::implInspect(const Any& aToInspectObj)
{
MutexGuard aGuard( m_mutex );
// Wenn die Introspection schon disposed ist, wird nur ein leeres Ergebnis geliefert
if( mbDisposed )
return NULL;
// Objekt untersuchen
TypeClass eType = aToInspectObj.getValueType().getTypeClass();
if( eType != TypeClass_INTERFACE && eType != TypeClass_STRUCT && eType != TypeClass_EXCEPTION )
return NULL;
Reference<XInterface> x;
if( eType == TypeClass_INTERFACE )
{
// Interface aus dem Any besorgen
x = *(Reference<XInterface>*)aToInspectObj.getValue();
if( !x.is() )
return NULL;
}
#ifdef USE_INTROSPECTION_CACHE
// Haben wir schon eine Cache-Instanz
if( !mpCache )
mpCache = new IntrospectionAccessCacheMap;
if( !mpTypeProviderCache )
mpTypeProviderCache = new TypeProviderAccessCacheMap;
IntrospectionAccessCacheMap& aCache = *mpCache;
TypeProviderAccessCacheMap& aTPCache = *mpTypeProviderCache;
// Pointer auf ggf. noetige neue IntrospectionAccess-Instanz
IntrospectionAccessStatic_Impl* pAccess = NULL;
#else
// Pointer auf ggf. noetige neue IntrospectionAccess-Instanz
IntrospectionAccessStatic_Impl* pAccess = new IntrospectionAccessStatic_Impl( mxCoreReflection );
#endif
// Pruefen: Ist schon ein passendes Access-Objekt gecached?
Sequence< Reference<XIdlClass> > SupportedClassSeq;
Sequence< Type > SupportedTypesSeq;
Reference<XIdlClassProvider> xClassProvider;
Reference<XTypeProvider> xTypeProvider;
Reference<XIdlClass> xImplClass;
Reference<XPropertySetInfo> xPropSetInfo;
Reference<XPropertySet> xPropSet;
// Bei Interfaces XTypeProvider / XIdlClassProvider- und PropertySet-Interface anfordern
if( eType == TypeClass_INTERFACE )
{
// XIdlClassProvider
xTypeProvider = Reference<XTypeProvider>::query( x );
if( xTypeProvider.is() )
{
SupportedTypesSeq = xTypeProvider->getTypes();
sal_Int32 nTypeCount = SupportedTypesSeq.getLength();
if( nTypeCount )
{
SupportedClassSeq.realloc( nTypeCount );
Reference<XIdlClass>* pClasses = SupportedClassSeq.getArray();
const Type* pTypes = SupportedTypesSeq.getConstArray();
for( sal_Int32 i = 0 ; i < nTypeCount ; i++ )
{
pClasses[ i ] = TypeToIdlClass( pTypes[ i ], m_xSMgr );
}
// TODO: Caching!
}
}
else
{
// XIdlClassProvider
xClassProvider = Reference<XIdlClassProvider>::query( x );
if( xClassProvider.is() )
{
SupportedClassSeq = xClassProvider->getIdlClasses();
if( SupportedClassSeq.getLength() )
xImplClass = SupportedClassSeq.getConstArray()[0];
}
}
// #70197, fuer InvocationAdapter: Interface-Typ im Any auch ohne
// ClassProvider unterstuetzen
if( !xClassProvider.is() && !xTypeProvider.is() )
{
xImplClass = TypeToIdlClass( aToInspectObj.getValueType(), m_xSMgr );
SupportedClassSeq.realloc( 1 );
SupportedClassSeq.getArray()[ 0 ] = xImplClass;
}
xPropSet = Reference<XPropertySet>::query( x );
// Jetzt versuchen, das PropertySetInfo zu bekommen
if( xPropSet.is() )
xPropSetInfo = xPropSet->getPropertySetInfo();
}
else
{
xImplClass = TypeToIdlClass( aToInspectObj.getValueType(), m_xSMgr );
}
#ifdef USE_INTROSPECTION_CACHE
if( xTypeProvider.is() )
{
Sequence< sal_Int8 > aImpIdSeq = xTypeProvider->getImplementationId();
sal_Int32 nIdLen = aImpIdSeq.getLength();
if( nIdLen )
{
// cache only, if the descriptor class is set
hashTypeProviderKey_Impl aKeySeq( xPropSetInfo, aImpIdSeq );
TypeProviderAccessCacheMap::iterator aIt = aTPCache.find( aKeySeq );
if( aIt == aTPCache.end() )
{
// not found
// Neue Instanz anlegen und unter dem gegebenen Key einfuegen
pAccess = new IntrospectionAccessStatic_Impl( mxCoreReflection );
// RefCount von Hand erhoehen, muss beim Entfernen
// aus der Hashtable wieder released werden
pAccess->acquire();
// Groesse begrenzen, alten Eintrag wieder rausschmeissen
if( mnTPCacheEntryCount > INTROSPECTION_CACHE_MAX_SIZE )
{
// Access mit dem kleinsten HitCount suchen
TypeProviderAccessCacheMap::iterator iter = aTPCache.begin();
TypeProviderAccessCacheMap::iterator end = aTPCache.end();
TypeProviderAccessCacheMap::iterator toDelete = iter;
while( iter != end )
{
if( (*iter).first.nHitCount < (*toDelete).first.nHitCount )
toDelete = iter;
++iter;
}
// Gefundenen Eintrag entfernen
if( (*toDelete).second )
(*toDelete).second->release();
(*toDelete).second = NULL;
aTPCache.erase( toDelete );
}
else
mnTPCacheEntryCount++;
// Neuer Eintrage rein in die Table
aKeySeq.nHitCount = 1;
aTPCache[ aKeySeq ] = pAccess;
}
else
{
// Hit-Count erhoehen
(*aIt).first.IncHitCount();
return (*aIt).second;
}
}
}
else if( xImplClass.is() )
{
// cache only, if the descriptor class is set
hashIntrospectionKey_Impl aKeySeq( SupportedClassSeq, xPropSetInfo, xImplClass );
IntrospectionAccessCacheMap::iterator aIt = aCache.find( aKeySeq );
if( aIt == aCache.end() )
{
// not found
// Neue Instanz anlegen und unter dem gegebenen Key einfuegen
pAccess = new IntrospectionAccessStatic_Impl( mxCoreReflection );
// RefCount von Hand erhoehen, muss beim Entfernen
// aus der Hashtable wieder released werden
pAccess->acquire();
// Groesse begrenzen, alten Eintrag wieder rausschmeissen
if( mnCacheEntryCount > INTROSPECTION_CACHE_MAX_SIZE )
{
// Access mit dem kleinsten HitCount suchen
IntrospectionAccessCacheMap::iterator iter = aCache.begin();
IntrospectionAccessCacheMap::iterator end = aCache.end();
IntrospectionAccessCacheMap::iterator toDelete = iter;
while( iter != end )
{
if( (*iter).first.nHitCount < (*toDelete).first.nHitCount )
toDelete = iter;
++iter;
}
// Gefundenen Eintrag entfernen
if( (*toDelete).second )
(*toDelete).second->release();
(*toDelete).second = NULL;
aCache.erase( toDelete );
}
else
mnCacheEntryCount++;
// Neuer Eintrage rein in die Table
aKeySeq.nHitCount = 1;
aCache[ aKeySeq ] = pAccess;
}
else
{
// Hit-Count erhoehen
(*aIt).first.IncHitCount();
return (*aIt).second;
}
}
#endif
// Kein Access gecached -> neu anlegen
Property* pAllPropArray;
Reference<XInterface>* pInterfaces1;
Reference<XInterface>* pInterfaces2;
sal_Int16* pMapTypeArray;
sal_Int32* pPropertyConceptArray;
sal_Int32 i;
if( !pAccess )
pAccess = new IntrospectionAccessStatic_Impl( mxCoreReflection );
// Referenzen auf wichtige Daten von pAccess
sal_Int32& rPropCount = pAccess->mnPropCount;
IntrospectionNameMap& rPropNameMap = pAccess->maPropertyNameMap;
IntrospectionNameMap& rMethodNameMap = pAccess->maMethodNameMap;
LowerToExactNameMap& rLowerToExactNameMap = pAccess->maLowerToExactNameMap;
// Schon mal Pointer auf das eigene Property-Feld holen
pAllPropArray = pAccess->maAllPropertySeq.getArray();
pInterfaces1 = pAccess->aInterfaceSeq1.getArray();
pInterfaces2 = pAccess->aInterfaceSeq2.getArray();
pMapTypeArray = pAccess->maMapTypeSeq.getArray();
pPropertyConceptArray = pAccess->maPropertyConceptSeq.getArray();
//*************************
//*** Analyse vornehmen ***
//*************************
if( eType == TypeClass_INTERFACE )
{
// Zunaechst nach speziellen Interfaces suchen, die fuer
// die Introspection von besonderer Bedeutung sind.
// XPropertySet vorhanden?
if( xPropSet.is() && xPropSetInfo.is() )
{
// Gibt es auch ein FastPropertySet?
Reference<XFastPropertySet> xDummy = Reference<XFastPropertySet>::query( x );
sal_Bool bFast = pAccess->mbFastPropSet = xDummy.is();
Sequence<Property> aPropSeq = xPropSetInfo->getProperties();
const Property* pProps = aPropSeq.getConstArray();
sal_Int32 nLen = aPropSeq.getLength();
// Bei FastPropertySet muessen wir uns die Original-Handles merken
if( bFast )
pAccess->mpOrgPropertyHandleArray = new sal_Int32[ nLen ];
for( i = 0 ; i < nLen ; i++ )
{
// Property in eigene Liste uebernehmen
pAccess->checkPropertyArraysSize
( pAllPropArray, pMapTypeArray, pPropertyConceptArray, rPropCount );
Property& rProp = pAllPropArray[ rPropCount ];
rProp = pProps[ i ];
if( bFast )
pAccess->mpOrgPropertyHandleArray[ i ] = rProp.Handle;
// PropCount als Handle fuer das eigene FastPropertySet eintragen
rProp.Handle = rPropCount;
// Art der Property merken
pMapTypeArray[ rPropCount ] = MAP_PROPERTY_SET;
pPropertyConceptArray[ rPropCount ] = PROPERTYSET;
pAccess->mnPropertySetPropCount++;
// Namen in Hashtable eintragen, wenn nicht schon bekannt
OUString aPropName = rProp.Name;
// Haben wir den Namen schon?
IntrospectionNameMap::iterator aIt = rPropNameMap.find( aPropName );
if( aIt == rPropNameMap.end() )
{
// Neuer Eintrag in die Hashtable
rPropNameMap[ aPropName ] = rPropCount;
// Tabelle fuer XExactName pflegen
rLowerToExactNameMap[ toLower( aPropName ) ] = aPropName;
}
else
{
OSL_FAIL( OString( "Introspection: Property \"" ) +
OUStringToOString( aPropName, RTL_TEXTENCODING_ASCII_US ) +
OString( "\" found more than once in PropertySet" ) );
}
// Count pflegen
rPropCount++;
}
}
// Jetzt alle weiteren implementierten Interfaces durchgehen
// Diese muessen durch das XIdlClassProvider-Interface geliefert werden.
// #70197, fuer InvocationAdapter: Interface-Typ im Any auch ohne
// ClassProvider unterstuetzen
//if( xClassProvider.is() )
{
// Indizes in die Export-Tabellen
sal_Int32 iAllExportedMethod = 0;
sal_Int32 iAllSupportedListener = 0;
// Hashtable fuer Pruefung auf mehrfache Beruecksichtigung von Interfaces
CheckedInterfacesMap aCheckedInterfacesMap;
// Flag, ob XInterface-Methoden erfasst werden sollen
// (das darf nur einmal erfolgen, initial zulassen)
sal_Bool bXInterfaceIsInvalid = sal_False;
// Flag, ob die XInterface-Methoden schon erfasst wurden. Wenn sal_True,
// wird bXInterfaceIsInvalid am Ende der Iface-Schleife aktiviert und
// XInterface-Methoden werden danach abgeklemmt.
sal_Bool bFoundXInterface = sal_False;
// Schleife ueber alle vom ClassProvider angegebenen Klassen
sal_Int32 nClassCount = SupportedClassSeq.getLength();
for( sal_Int32 nIdx = 0 ; nIdx < nClassCount; nIdx++ )
{
Reference<XIdlClass> xImplClass2 = SupportedClassSeq.getConstArray()[nIdx];
while( xImplClass2.is() )
{
// Interfaces der Implementation holen
Sequence< Reference<XIdlClass> > aClassSeq = xImplClass2->getInterfaces();
sal_Int32 nIfaceCount = aClassSeq.getLength();
aClassSeq.realloc( nIfaceCount + 1 );
aClassSeq.getArray()[ nIfaceCount ] = xImplClass2;
nIfaceCount++;
const Reference<XIdlClass>* pParamArray = aClassSeq.getConstArray();
for( sal_Int32 j = 0 ; j < nIfaceCount ; j++ )
{
const Reference<XIdlClass>& rxIfaceClass = pParamArray[j];
// Pruefen, ob das Interface schon beruecksichtigt wurde.
XInterface* pIface = SAL_STATIC_CAST( XInterface*, rxIfaceClass.get() );
if( aCheckedInterfacesMap.count( pIface ) > 0 )
{
// Kennen wir schon
continue;
}
else
{
// Sonst eintragen
aCheckedInterfacesMap[ pIface ] = pIface;
}
//********************************************************************
// 2. Fields als Properties registrieren
// Felder holen
Sequence< Reference<XIdlField> > fields = rxIfaceClass->getFields();
const Reference<XIdlField>* pFields = fields.getConstArray();
sal_Int32 nLen = fields.getLength();
for( i = 0 ; i < nLen ; i++ )
{
Reference<XIdlField> xField = pFields[i];
Reference<XIdlClass> xPropType = xField->getType();
// Ist die PropertySequence gross genug?
pAccess->checkPropertyArraysSize
( pAllPropArray, pMapTypeArray, pPropertyConceptArray, rPropCount );
// In eigenes Property-Array eintragen
Property& rProp = pAllPropArray[ rPropCount ];
OUString aFieldName = xField->getName();
rProp.Name = aFieldName;
rProp.Handle = rPropCount;
Type aFieldType( xPropType->getTypeClass(), xPropType->getName() );
rProp.Type = aFieldType;
FieldAccessMode eAccessMode = xField->getAccessMode();
rProp.Attributes = (eAccessMode == FieldAccessMode_READONLY ||
eAccessMode == FieldAccessMode_CONST)
? READONLY : 0;
// Namen in Hashtable eintragen
OUString aPropName = rProp.Name;
// Haben wir den Namen schon?
IntrospectionNameMap::iterator aIt = rPropNameMap.find( aPropName );
if( !( aIt == rPropNameMap.end() ) )
{
/* TODO
OSL_TRACE(
String( "Introspection: Property \"" ) +
OOUStringToString( aPropName, CHARSET_SYSTEM ) +
String( "\" found more than once" ) );
*/
continue;
}
// Neuer Eintrag in die Hashtable
rPropNameMap[ aPropName ] = rPropCount;
// Tabelle fuer XExactName pflegen
rLowerToExactNameMap[ toLower( aPropName ) ] = aPropName;
// Field merken
pAccess->checkInterfaceArraySize( pAccess->aInterfaceSeq1,
pInterfaces1, rPropCount );
pInterfaces1[ rPropCount ] = xField;
// Art der Property merken
pMapTypeArray[ rPropCount ] = MAP_FIELD;
pPropertyConceptArray[ rPropCount ] = ATTRIBUTES;
pAccess->mnAttributePropCount++;
// Count pflegen
rPropCount++;
}
//********************************************************************
// 3. Methoden
// Zaehler fuer die gefundenen Listener
sal_Int32 nListenerCount = 0;
// Alle Methoden holen und merken
Sequence< Reference<XIdlMethod> > methods = rxIfaceClass->getMethods();
const Reference<XIdlMethod>* pSourceMethods = methods.getConstArray();
sal_Int32 nSourceMethodCount = methods.getLength();
// 3. a) get/set- und Listener-Methoden suchen
// Feld fuer Infos ueber die Methoden anlegen, damit spaeter leicht die Methoden
// gefunden werden koennen, die nicht im Zusammenhang mit Properties oder Listenern
// stehen. NEU: auch MethodConceptArray initialisieren
MethodType* pMethodTypes = new MethodType[ nSourceMethodCount ];
sal_Int32* pLocalMethodConcepts = new sal_Int32[ nSourceMethodCount ];
for( i = 0 ; i < nSourceMethodCount ; i++ )
{
pMethodTypes[ i ] = STANDARD_METHOD;
pLocalMethodConcepts[ i ] = 0;
}
OUString aMethName;
OUString aPropName;
OUString aStartStr;
for( i = 0 ; i < nSourceMethodCount ; i++ )
{
// Methode ansprechen
const Reference<XIdlMethod>& rxMethod_i = pSourceMethods[i];
sal_Int32& rMethodConcept_i = pLocalMethodConcepts[ i ];
// Namen besorgen
aMethName = rxMethod_i->getName();
// Methoden katalogisieren
// Alle (?) Methoden von XInterface filtern, damit z.B. nicht
// vom Scripting aus aquire oder release gerufen werden kann
if( rxMethod_i->getDeclaringClass()->equals( mxInterfaceClass ) )
{
// XInterface-Methoden sind hiermit einmal beruecksichtigt
bFoundXInterface = sal_True;
if( bXInterfaceIsInvalid )
{
pMethodTypes[ i ] = INVALID_METHOD;
continue;
}
else
{
if( aMethName != OUString( RTL_CONSTASCII_USTRINGPARAM("queryInterface")) )
{
rMethodConcept_i |= MethodConcept::DANGEROUS;
continue;
}
}
}
else if( rxMethod_i->getDeclaringClass()->equals( mxAggregationClass ) )
{
if( aMethName == OUString( RTL_CONSTASCII_USTRINGPARAM("setDelegator")) )
{
rMethodConcept_i |= MethodConcept::DANGEROUS;
continue;
}
}
else if( rxMethod_i->getDeclaringClass()->equals( mxElementAccessClass ) )
{
rMethodConcept_i |= ( NAMECONTAINER |
INDEXCONTAINER |
ENUMERATION );
}
else if( rxMethod_i->getDeclaringClass()->equals( mxNameContainerClass ) ||
rxMethod_i->getDeclaringClass()->equals( mxNameAccessClass ) )
{
rMethodConcept_i |= NAMECONTAINER;
}
else if( rxMethod_i->getDeclaringClass()->equals( mxIndexContainerClass ) ||
rxMethod_i->getDeclaringClass()->equals( mxIndexAccessClass ) )
{
rMethodConcept_i |= INDEXCONTAINER;
}
else if( rxMethod_i->getDeclaringClass()->equals( mxEnumerationAccessClass ) )
{
rMethodConcept_i |= ENUMERATION;
}
// Wenn der Name zu kurz ist, wird's sowieso nichts
if( aMethName.getLength() <= 3 )
continue;
// Ist es eine get-Methode?
aStartStr = aMethName.copy( 0, 3 );
if( aStartStr == OUString( RTL_CONSTASCII_USTRINGPARAM("get")) )
{
// Namen der potentiellen Property
aPropName = aMethName.copy( 3 );
// get-Methode darf keinen Parameter haben
Sequence< Reference<XIdlClass> > getParams = rxMethod_i->getParameterTypes();
if( getParams.getLength() > 0 )
{
continue;
}
// Haben wir den Namen schon?
IntrospectionNameMap::iterator aIt = rPropNameMap.find( aPropName );
if( !( aIt == rPropNameMap.end() ) )
{
/* TODO
OSL_TRACE(
String( "Introspection: Property \"" ) +
OOUStringToString( aPropName, CHARSET_SYSTEM ) +
String( "\" found more than once" ) );
*/
continue;
}
// Eine readonly-Property ist es jetzt mindestens schon
rMethodConcept_i |= PROPERTY;
pMethodTypes[i] = GETSET_METHOD;
Reference<XIdlClass> xGetRetType = rxMethod_i->getReturnType();
// Ist die PropertySequence gross genug?
pAccess->checkPropertyArraysSize
( pAllPropArray, pMapTypeArray, pPropertyConceptArray, rPropCount );
// In eigenes Property-Array eintragen
Property& rProp = pAllPropArray[ rPropCount ];
rProp.Name = aPropName;
rProp.Handle = rPropCount;
rProp.Type = Type( xGetRetType->getTypeClass(), xGetRetType->getName() );
rProp.Attributes = READONLY;
// Neuer Eintrag in die Hashtable
rPropNameMap[ aPropName ] = rPropCount;
// Tabelle fuer XExactName pflegen
rLowerToExactNameMap[ toLower( aPropName ) ] = aPropName;
// get-Methode merken
pAccess->checkInterfaceArraySize( pAccess->aInterfaceSeq1,
pInterfaces1, rPropCount );
pInterfaces1[ rPropCount ] = rxMethod_i;
// Art der Property merken
pMapTypeArray[ rPropCount ] = MAP_GETSET;
pPropertyConceptArray[ rPropCount ] = METHODS;
pAccess->mnMethodPropCount++;
// Passende set-Methode suchen
sal_Int32 k;
for( k = 0 ; k < nSourceMethodCount ; k++ )
{
// Methode ansprechen
const Reference<XIdlMethod>& rxMethod_k = pSourceMethods[k];
// Nur Methoden nehmen, die nicht schon zugeordnet sind
if( k == i || pMethodTypes[k] != STANDARD_METHOD )
continue;
// Name holen und auswerten
OUString aMethName2 = rxMethod_k->getName();
OUString aStartStr2 = aMethName2.copy( 0, 3 );
// ACHTUNG: Wegen SDL-Bug NICHT != bei OUString verwenden !!!
if( !( aStartStr2 == OUString( RTL_CONSTASCII_USTRINGPARAM("set")) ) )
continue;
// Ist es denn der gleiche Name?
OUString aPropName2 = aMethName2.copy( 3 );
// ACHTUNG: Wegen SDL-Bug NICHT != bei OUString verwenden !!!
if( !( aPropName == aPropName2 ) )
continue;
// set-Methode muss void returnen
Reference<XIdlClass> xSetRetType = rxMethod_k->getReturnType();
if( xSetRetType->getTypeClass() != TypeClass_VOID )
{
continue;
}
// set-Methode darf nur einen Parameter haben
Sequence< Reference<XIdlClass> > setParams = rxMethod_k->getParameterTypes();
sal_Int32 nParamCount = setParams.getLength();
if( nParamCount != 1 )
{
continue;
}
// Jetzt muss nur noch der return-Typ dem Parameter-Typ entsprechen
const Reference<XIdlClass>* pParamArray2 = setParams.getConstArray();
Reference<XIdlClass> xParamType = pParamArray2[ 0 ];
if( xParamType->equals( xGetRetType ) )
{
pLocalMethodConcepts[ k ] = PROPERTY;
pMethodTypes[k] = GETSET_METHOD;
// ReadOnly-Flag wieder loschen
rProp.Attributes &= ~READONLY;
// set-Methode merken
pAccess->checkInterfaceArraySize( pAccess->aInterfaceSeq2,
pInterfaces2, rPropCount );
pInterfaces2[ rPropCount ] = rxMethod_k;
}
}
// Count pflegen
rPropCount++;
}
// Ist es eine addListener-Methode?
else if( aStartStr == OUString( RTL_CONSTASCII_USTRINGPARAM("add")) )
{
OUString aListenerStr( RTL_CONSTASCII_USTRINGPARAM("Listener" ) );
// Namen der potentiellen Property
sal_Int32 nStrLen = aMethName.getLength();
sal_Int32 nCopyLen = nStrLen - aListenerStr.getLength();
OUString aEndStr = aMethName.copy( nCopyLen > 0 ? nCopyLen : 0 );
// Endet das Teil auf Listener?
// ACHTUNG: Wegen SDL-Bug NICHT != bei OUString verwenden !!!
if( !( aEndStr == aListenerStr ) )
continue;
// Welcher Listener?
OUString aListenerName = aMethName.copy( 3, nStrLen - aListenerStr.getLength() - 3 );
// TODO: Hier koennten noch genauere Pruefungen vorgenommen werden
// - Rueckgabe-Typ
// - Anzahl und Art der Parameter
// Passende remove-Methode suchen, sonst gilt's nicht
sal_Int32 k;
for( k = 0 ; k < nSourceMethodCount ; k++ )
{
// Methode ansprechen
const Reference<XIdlMethod>& rxMethod_k = pSourceMethods[k];
// Nur Methoden nehmen, die nicht schon zugeordnet sind
if( k == i || pMethodTypes[k] != STANDARD_METHOD )
continue;
// Name holen und auswerten
OUString aMethName2 = rxMethod_k->getName();
sal_Int32 nNameLen = aMethName2.getLength();
sal_Int32 nCopyLen2 = (nNameLen < 6) ? nNameLen : 6;
OUString aStartStr2 = aMethName2.copy( 0, nCopyLen2 );
OUString aRemoveStr( RTL_CONSTASCII_USTRINGPARAM("remove" ) );
// ACHTUNG: Wegen SDL-Bug NICHT != bei OUString verwenden !!!
if( !( aStartStr2 == aRemoveStr ) )
continue;
// Ist es denn der gleiche Listener?
if( aMethName2.getLength() - aRemoveStr.getLength() <= aListenerStr.getLength() )
continue;
OUString aListenerName2 = aMethName2.copy
( 6, aMethName2.getLength() - aRemoveStr.getLength() - aListenerStr.getLength() );
// ACHTUNG: Wegen SDL-Bug NICHT != bei OUString verwenden !!!
if( !( aListenerName == aListenerName2 ) )
continue;
// TODO: Hier koennten noch genauere Pruefungen vorgenommen werden
// - Rueckgabe-Typ
// - Anzahl und Art der Parameter
// Methoden sind als Listener-Schnittstelle erkannt
rMethodConcept_i |= LISTENER;
pLocalMethodConcepts[ k ] |= LISTENER;
pMethodTypes[i] = ADD_LISTENER_METHOD;
pMethodTypes[k] = REMOVE_LISTENER_METHOD;
nListenerCount++;
}
}
}
// Jetzt koennen noch SET-Methoden ohne zugehoerige GET-Methode existieren,
// diese muessen zu Write-Only-Properties gemachte werden.
for( i = 0 ; i < nSourceMethodCount ; i++ )
{
// Methode ansprechen
const Reference<XIdlMethod>& rxMethod_i = pSourceMethods[i];
// Nur Methoden nehmen, die nicht schon zugeordnet sind
if( pMethodTypes[i] != STANDARD_METHOD )
continue;
// Namen besorgen
aMethName = rxMethod_i->getName();
// Wenn der Name zu kurz ist, wird's sowieso nichts
if( aMethName.getLength() <= 3 )
continue;
// Ist es eine set-Methode ohne zugehoerige get-Methode?
aStartStr = aMethName.copy( 0, 3 );
if( aStartStr == OUString( RTL_CONSTASCII_USTRINGPARAM("set")) )
{
// Namen der potentiellen Property
aPropName = aMethName.copy( 3 );
// set-Methode muss void returnen
Reference<XIdlClass> xSetRetType = rxMethod_i->getReturnType();
if( xSetRetType->getTypeClass() != TypeClass_VOID )
{
continue;
}
// set-Methode darf nur einen Parameter haben
Sequence< Reference<XIdlClass> > setParams = rxMethod_i->getParameterTypes();
sal_Int32 nParamCount = setParams.getLength();
if( nParamCount != 1 )
{
continue;
}
// Haben wir den Namen schon?
IntrospectionNameMap::iterator aIt = rPropNameMap.find( aPropName );
if( !( aIt == rPropNameMap.end() ) )
{
/* TODO:
OSL_TRACE(
String( "Introspection: Property \"" ) +
OOUStringToString( aPropName, CHARSET_SYSTEM ) +
String( "\" found more than once" ) );
*/
continue;
}
// Alles klar, es ist eine Write-Only-Property
pLocalMethodConcepts[ i ] = PROPERTY;
pMethodTypes[i] = GETSET_METHOD;
Reference<XIdlClass> xGetRetType = setParams.getConstArray()[0];
// Ist die PropertySequence gross genug?
pAccess->checkPropertyArraysSize
( pAllPropArray, pMapTypeArray, pPropertyConceptArray, rPropCount );
// In eigenes Property-Array eintragen
Property& rProp = pAllPropArray[ rPropCount ];
rProp.Name = aPropName;
rProp.Handle = rPropCount;
rProp.Type = Type( xGetRetType->getTypeClass(), xGetRetType->getName() );
rProp.Attributes = 0; // PROPERTY_WRITEONLY ???
// Neuer Eintrag in die Hashtable
rPropNameMap[ aPropName ] = rPropCount;
// Tabelle fuer XExactName pflegen
rLowerToExactNameMap[ toLower( aPropName ) ] = aPropName;
// set-Methode merken
pAccess->checkInterfaceArraySize( pAccess->aInterfaceSeq2,
pInterfaces2, rPropCount );
pInterfaces2[ rPropCount ] = rxMethod_i;
// Art der Property merken
pMapTypeArray[ rPropCount ] = MAP_SETONLY;
pPropertyConceptArray[ rPropCount ] = METHODS;
pAccess->mnMethodPropCount++;
// Count pflegen
rPropCount++;
}
}
//********************************************************************
// 4. Methoden in die Gesamt-Sequence uebernehmen
// Wieviele Methoden muessen in die Method-Sequence?
sal_Int32 nExportedMethodCount = 0;
sal_Int32 nSupportedListenerCount = 0;
for( i = 0 ; i < nSourceMethodCount ; i++ )
{
if( pMethodTypes[ i ] != INVALID_METHOD )
{
nExportedMethodCount++;
}
if( pMethodTypes[ i ] == ADD_LISTENER_METHOD )
{
nSupportedListenerCount++;
}
}
// Sequences im Access-Objekt entsprechend aufbohren
pAccess->maAllMethodSeq.realloc( nExportedMethodCount + iAllExportedMethod );
pAccess->maMethodConceptSeq.realloc( nExportedMethodCount + iAllExportedMethod );
pAccess->maSupportedListenerSeq.realloc( nSupportedListenerCount + iAllSupportedListener );
// Methoden reinschreiben
Reference<XIdlMethod>* pDestMethods = pAccess->maAllMethodSeq.getArray();
sal_Int32* pMethodConceptArray = pAccess->maMethodConceptSeq.getArray();
Type* pListenerClassRefs = pAccess->maSupportedListenerSeq.getArray();
for( i = 0 ; i < nSourceMethodCount ; i++ )
{
if( pMethodTypes[ i ] != INVALID_METHOD )
{
// Methode ansprechen
const Reference<XIdlMethod>& rxMethod = pSourceMethods[i];
// Namen in Hashtable eintragen, wenn nicht schon bekannt
OUString aMethName2 = rxMethod->getName();
IntrospectionNameMap::iterator aIt = rMethodNameMap.find( aMethName2 );
if( aIt == rMethodNameMap.end() )
{
// Eintragen
rMethodNameMap[ aMethName2 ] = iAllExportedMethod;
// Tabelle fuer XExactName pflegen
rLowerToExactNameMap[ toLower( aMethName2 ) ] = aMethName2;
}
else
{
sal_Int32 iHashResult = (*aIt).second;
Reference<XIdlMethod> xExistingMethod = pDestMethods[ iHashResult ];
Reference< XIdlClass > xExistingMethClass =
xExistingMethod->getDeclaringClass();
Reference< XIdlClass > xNewMethClass = rxMethod->getDeclaringClass();
if( xExistingMethClass->equals( xNewMethClass ) )
continue;
}
pDestMethods[ iAllExportedMethod ] = rxMethod;
// Wenn kein Concept gesetzt wurde, ist die Methode "normal"
sal_Int32& rMethodConcept_i = pLocalMethodConcepts[ i ];
if( !rMethodConcept_i )
rMethodConcept_i = MethodConcept_NORMAL_IMPL;
pMethodConceptArray[ iAllExportedMethod ] = rMethodConcept_i;
iAllExportedMethod++;
}
if( pMethodTypes[ i ] == ADD_LISTENER_METHOD )
{
// Klasse des Listeners ermitteln
const Reference<XIdlMethod>& rxMethod = pSourceMethods[i];
// void als Default-Klasse eintragen
Reference<XIdlClass> xListenerClass = TypeToIdlClass( getCppuVoidType(), m_xSMgr );
// ALT: Reference<XIdlClass> xListenerClass = Void_getReflection()->getIdlClass();
// 1. Moeglichkeit: Parameter nach einer Listener-Klasse durchsuchen
// Nachteil: Superklassen muessen rekursiv durchsucht werden
Sequence< Reference<XIdlClass> > aParams = rxMethod->getParameterTypes();
const Reference<XIdlClass>* pParamArray2 = aParams.getConstArray();
Reference<XIdlClass> xEventListenerClass = TypeToIdlClass( getCppuType( (Reference<XEventListener>*) NULL ), m_xSMgr );
// ALT: Reference<XIdlClass> xEventListenerClass = XEventListener_getReflection()->getIdlClass();
sal_Int32 nParamCount = aParams.getLength();
sal_Int32 k;
for( k = 0 ; k < nParamCount ; k++ )
{
const Reference<XIdlClass>& rxClass = pParamArray2[k];
// Sind wir von einem Listener abgeleitet?
if( rxClass->equals( xEventListenerClass ) ||
isDerivedFrom( rxClass, xEventListenerClass ) )
{
xListenerClass = rxClass;
break;
}
}
// 2. Moeglichkeit: Namen der Methode auswerden
// Nachteil: geht nicht bei Test-Listenern, die es nicht gibt
//aMethName = rxMethod->getName();
//aListenerName = aMethName.Copy( 3, aMethName.Len()-8-3 );
//Reference<XIdlClass> xListenerClass = reflection->forName( aListenerName );
Type aListenerType( TypeClass_INTERFACE, xListenerClass->getName() );
pListenerClassRefs[ iAllSupportedListener ] = aListenerType;
iAllSupportedListener++;
}
}
// Wenn in diesem Durchlauf XInterface-Methoden
// dabei waren, diese zukuenftig ignorieren
if( bFoundXInterface )
bXInterfaceIsInvalid = sal_True;
delete[] pMethodTypes;
delete[] pLocalMethodConcepts;
}
// Super-Klasse(n) vorhanden? Dann dort fortsetzen
Sequence< Reference<XIdlClass> > aSuperClassSeq = xImplClass2->getSuperclasses();
// Zur Zeit wird nur von einer Superklasse ausgegangen
if( aSuperClassSeq.getLength() >= 1 )
{
xImplClass2 = aSuperClassSeq.getConstArray()[0];
OSL_ENSURE( xImplClass2.is(), "super class null" );
}
else
{
xImplClass2 = NULL;
}
}
}
// Anzahl der exportierten Methoden uebernehmen und Sequences anpassen
// (kann abweichen, weil doppelte Methoden erst nach der Ermittlung
// von nExportedMethodCount herausgeworfen werden)
sal_Int32& rMethCount = pAccess->mnMethCount;
rMethCount = iAllExportedMethod;
pAccess->maAllMethodSeq.realloc( rMethCount );
pAccess->maMethodConceptSeq.realloc( rMethCount );
// Groesse der Property-Sequences anpassen
pAccess->maAllPropertySeq.realloc( rPropCount );
pAccess->maPropertyConceptSeq.realloc( rPropCount );
pAccess->maMapTypeSeq.realloc( rPropCount );
// Ende der Schleife ueber alle vom ClassProvider angegebenen Klassen
}
}
// Bei structs Fields als Properties registrieren
else //if( eType == TypeClass_STRUCT )
{
// Ist es ein Interface oder eine struct?
//Reference<XIdlClass> xClassRef = aToInspectObj.getReflection()->getIdlClass();
Reference<XIdlClass> xClassRef = TypeToIdlClass( aToInspectObj.getValueType(), m_xSMgr );
if( !xClassRef.is() )
{
OSL_FAIL( "Can't get XIdlClass from Reflection" );
return pAccess;
}
// Felder holen
Sequence< Reference<XIdlField> > fields = xClassRef->getFields();
const Reference<XIdlField>* pFields = fields.getConstArray();
sal_Int32 nLen = fields.getLength();
for( i = 0 ; i < nLen ; i++ )
{
Reference<XIdlField> xField = pFields[i];
Reference<XIdlClass> xPropType = xField->getType();
OUString aPropName = xField->getName();
// Ist die PropertySequence gross genug?
pAccess->checkPropertyArraysSize
( pAllPropArray, pMapTypeArray, pPropertyConceptArray, rPropCount );
// In eigenes Property-Array eintragen
Property& rProp = pAllPropArray[ rPropCount ];
rProp.Name = aPropName;
rProp.Handle = rPropCount;
rProp.Type = Type( xPropType->getTypeClass(), xPropType->getName() );
FieldAccessMode eAccessMode = xField->getAccessMode();
rProp.Attributes = (eAccessMode == FieldAccessMode_READONLY ||
eAccessMode == FieldAccessMode_CONST)
? READONLY : 0;
//FieldAccessMode eAccessMode = xField->getAccessMode();
//rProp.Attributes = (eAccessMode == FieldAccessMode::READONLY || eAccessMode == CONST)
//? PropertyAttribute::READONLY : 0;
// Namen in Hashtable eintragen
rPropNameMap[ aPropName ] = rPropCount;
// Tabelle fuer XExactName pflegen
rLowerToExactNameMap[ toLower( aPropName ) ] = aPropName;
// Field merken
pAccess->checkInterfaceArraySize( pAccess->aInterfaceSeq1,
pInterfaces1, rPropCount );
pInterfaces1[ rPropCount ] = xField;
// Art der Property merken
pMapTypeArray[ rPropCount ] = MAP_FIELD;
pPropertyConceptArray[ rPropCount ] = ATTRIBUTES;
pAccess->mnAttributePropCount++;
// Count pflegen
rPropCount++;
}
}
// Property-Sequence auf die richtige Laenge bringen
pAccess->maAllPropertySeq.realloc( pAccess->mnPropCount );
return pAccess;
}
//*************************************************************************
Reference< XInterface > SAL_CALL ImplIntrospection_CreateInstance( const Reference< XMultiServiceFactory > & rSMgr )
throw( RuntimeException )
{
Reference< XInterface > xService = (OWeakObject*)(OComponentHelper*)new ImplIntrospection( rSMgr );
return xService;
}
}
extern "C"
{
//==================================================================================================
void SAL_CALL component_getImplementationEnvironment(
const sal_Char ** ppEnvTypeName, uno_Environment ** )
{
*ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME;
}
//==================================================================================================
void * SAL_CALL component_getFactory(
const sal_Char * pImplName, void * pServiceManager, void * )
{
void * pRet = 0;
if (pServiceManager && rtl_str_compare( pImplName, IMPLEMENTATION_NAME ) == 0)
{
Reference< XSingleServiceFactory > xFactory( createOneInstanceFactory(
reinterpret_cast< XMultiServiceFactory * >( pServiceManager ),
OUString::createFromAscii( pImplName ),
stoc_inspect::ImplIntrospection_CreateInstance,
stoc_inspect::ImplIntrospection::getSupportedServiceNames_Static() ) );
if (xFactory.is())
{
xFactory->acquire();
pRet = xFactory.get();
}
}
return pRet;
}
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|