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
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#include "sal/config.h"
#include <cassert>
#include <cstdlib>
#include <set>
#include <stack>
#include <vector>
#include "boost/noncopyable.hpp"
#include "com/sun/star/container/NoSuchElementException.hpp"
#include "com/sun/star/container/XHierarchicalNameAccess.hpp"
#include "com/sun/star/lang/XInitialization.hpp"
#include "com/sun/star/lang/XMultiComponentFactory.hpp"
#include "com/sun/star/reflection/InvalidTypeNameException.hpp"
#include "com/sun/star/reflection/NoSuchTypeNameException.hpp"
#include "com/sun/star/reflection/TypeDescriptionSearchDepth.hpp"
#include "com/sun/star/reflection/XConstantTypeDescription.hpp"
#include "com/sun/star/reflection/XConstantsTypeDescription.hpp"
#include "com/sun/star/reflection/XEnumTypeDescription.hpp"
#include "com/sun/star/reflection/XIndirectTypeDescription.hpp"
#include "com/sun/star/reflection/XInterfaceAttributeTypeDescription2.hpp"
#include "com/sun/star/reflection/XInterfaceMethodTypeDescription.hpp"
#include "com/sun/star/reflection/XInterfaceTypeDescription2.hpp"
#include "com/sun/star/reflection/XModuleTypeDescription.hpp"
#include "com/sun/star/reflection/XPublished.hpp"
#include "com/sun/star/reflection/XServiceTypeDescription2.hpp"
#include "com/sun/star/reflection/XSingletonTypeDescription2.hpp"
#include "com/sun/star/reflection/XStructTypeDescription.hpp"
#include "com/sun/star/reflection/XTypeDescriptionEnumeration.hpp"
#include "com/sun/star/reflection/XTypeDescriptionEnumerationAccess.hpp"
#include "com/sun/star/registry/InvalidRegistryException.hpp"
#include "com/sun/star/registry/XSimpleRegistry.hpp"
#include "com/sun/star/uno/Any.hxx"
#include "com/sun/star/uno/DeploymentException.hpp"
#include "com/sun/star/uno/Reference.hxx"
#include "com/sun/star/uno/RuntimeException.hpp"
#include "com/sun/star/uno/Sequence.hxx"
#include "com/sun/star/uno/TypeClass.hpp"
#include "com/sun/star/uno/XComponentContext.hpp"
#include "com/sun/star/uno/XInterface.hpp"
#include "cppuhelper/compbase2.hxx"
#include "cppuhelper/implbase1.hxx"
#include "cppuhelper/unoidl.hxx"
#include "osl/file.hxx"
#include "osl/mutex.hxx"
#include "rtl/ref.hxx"
#include "rtl/ustring.hxx"
#include "sal/types.h"
#include "paths.hxx"
#include "typedescriptionprovider.hxx"
#include "unoidlprovider.hxx"
namespace {
css::uno::Reference< css::reflection::XTypeDescription > resolve(
css::uno::Reference< css::uno::XComponentContext > const & context,
rtl::OUString const & name)
{
assert(context.is());
try {
return css::uno::Reference< css::reflection::XTypeDescription >(
(css::uno::Reference< css::container::XHierarchicalNameAccess >(
context->getValueByName(
"/singletons/"
"com.sun.star.reflection.theTypeDescriptionManager"),
css::uno::UNO_QUERY_THROW)->
getByHierarchicalName(name)),
css::uno::UNO_QUERY_THROW);
} catch (css::container::NoSuchElementException & e) {
throw css::uno::DeploymentException(
("cannot resolve type \"" + name + "\"; NoSuchElementException: "
+ e.Message),
e.Context);
}
}
class PublishableDescription:
public cppu::WeakImplHelper1< css::reflection::XPublished >,
private boost::noncopyable
{
protected:
PublishableDescription(bool published): published_(published) {}
virtual ~PublishableDescription() {}
private:
virtual sal_Bool SAL_CALL isPublished() throw (css::uno::RuntimeException)
{ return published_; }
bool published_;
};
class ModuleDescription:
public cppu::WeakImplHelper1< css::reflection::XModuleTypeDescription >,
private boost::noncopyable
{
public:
ModuleDescription(
css::uno::Reference< css::uno::XComponentContext > const & context,
rtl::OUString const & name,
rtl::Reference< cppu::unoidl::ModuleEntity > const & entity):
context_(context), name_(name), entity_(entity)
{ assert(entity.is()); }
private:
virtual ~ModuleDescription() {}
virtual css::uno::TypeClass SAL_CALL getTypeClass()
throw (css::uno::RuntimeException)
{ return css::uno::TypeClass_MODULE; }
virtual rtl::OUString SAL_CALL getName() throw (css::uno::RuntimeException)
{ return name_; }
virtual
css::uno::Sequence<
css::uno::Reference< css::reflection::XTypeDescription > >
SAL_CALL getMembers() throw (css::uno::RuntimeException);
css::uno::Reference< css::uno::XComponentContext > context_;
rtl::OUString name_;
rtl::Reference< cppu::unoidl::ModuleEntity > entity_;
};
css::uno::Sequence< css::uno::Reference< css::reflection::XTypeDescription > >
ModuleDescription::getMembers() throw (css::uno::RuntimeException) {
std::vector< rtl::OUString > names(entity_->getMemberNames());
assert(names.size() <= SAL_MAX_INT32);
sal_Int32 n = static_cast< sal_Int32 >(names.size());
css::uno::Sequence<
css::uno::Reference< css::reflection::XTypeDescription > > s(n);
for (sal_Int32 i = 0; i != n; ++i) {
s[i] = resolve(context_, name_ + "." + names[i]);
}
return s;
}
typedef cppu::ImplInheritanceHelper1<
PublishableDescription, css::reflection::XEnumTypeDescription >
EnumTypeDescription_Base;
class EnumTypeDescription: public EnumTypeDescription_Base {
public:
EnumTypeDescription(
rtl::OUString const & name,
rtl::Reference< cppu::unoidl::EnumTypeEntity > const & entity):
EnumTypeDescription_Base(entity->isPublished()), name_(name),
entity_(entity)
{ assert(entity.is()); }
private:
virtual ~EnumTypeDescription() {}
virtual css::uno::TypeClass SAL_CALL getTypeClass()
throw (css::uno::RuntimeException)
{ return css::uno::TypeClass_ENUM; }
virtual rtl::OUString SAL_CALL getName() throw (css::uno::RuntimeException)
{ return name_; }
virtual sal_Int32 SAL_CALL getDefaultEnumValue()
throw (css::uno::RuntimeException)
{ return entity_->getMembers()[0].value; }
virtual css::uno::Sequence< rtl::OUString > SAL_CALL getEnumNames()
throw (css::uno::RuntimeException);
virtual css::uno::Sequence< sal_Int32 > SAL_CALL getEnumValues()
throw (css::uno::RuntimeException);
rtl::OUString name_;
rtl::Reference< cppu::unoidl::EnumTypeEntity > entity_;
};
css::uno::Sequence< rtl::OUString > EnumTypeDescription::getEnumNames()
throw (css::uno::RuntimeException)
{
assert(entity_->getMembers().size() <= SAL_MAX_INT32);
sal_Int32 n = static_cast< sal_Int32 >(entity_->getMembers().size());
css::uno::Sequence< rtl::OUString > s(n);
for (sal_Int32 i = 0; i != n; ++i) {
s[i] = entity_->getMembers()[i].name;
}
return s;
}
css::uno::Sequence< sal_Int32 > EnumTypeDescription::getEnumValues()
throw (css::uno::RuntimeException)
{
assert(entity_->getMembers().size() <= SAL_MAX_INT32);
sal_Int32 n = static_cast< sal_Int32 >(entity_->getMembers().size());
css::uno::Sequence< sal_Int32 > s(n);
for (sal_Int32 i = 0; i != n; ++i) {
s[i] = entity_->getMembers()[i].value;
}
return s;
}
typedef cppu::ImplInheritanceHelper1<
PublishableDescription, css::reflection::XStructTypeDescription >
PlainStructTypeDescription_Base;
class PlainStructTypeDescription: public PlainStructTypeDescription_Base {
public:
PlainStructTypeDescription(
css::uno::Reference< css::uno::XComponentContext > const & context,
rtl::OUString const & name,
rtl::Reference< cppu::unoidl::PlainStructTypeEntity > const & entity):
PlainStructTypeDescription_Base(entity->isPublished()),
context_(context), name_(name), entity_(entity)
{ assert(entity.is()); }
private:
virtual ~PlainStructTypeDescription() {}
virtual css::uno::TypeClass SAL_CALL getTypeClass()
throw (css::uno::RuntimeException)
{ return css::uno::TypeClass_STRUCT; }
virtual rtl::OUString SAL_CALL getName() throw (css::uno::RuntimeException)
{ return name_; }
virtual css::uno::Reference< css::reflection::XTypeDescription > SAL_CALL
getBaseType() throw (css::uno::RuntimeException) {
return entity_->getDirectBase().isEmpty()
? css::uno::Reference< css::reflection::XTypeDescription >()
: resolve(context_, entity_->getDirectBase());
}
virtual
css::uno::Sequence<
css::uno::Reference< css::reflection::XTypeDescription > >
SAL_CALL getMemberTypes() throw (css::uno::RuntimeException);
virtual css::uno::Sequence< rtl::OUString > SAL_CALL getMemberNames()
throw (css::uno::RuntimeException);
virtual css::uno::Sequence< rtl::OUString > SAL_CALL getTypeParameters()
throw (css::uno::RuntimeException)
{ return css::uno::Sequence< rtl::OUString >(); }
virtual
css::uno::Sequence<
css::uno::Reference< css::reflection::XTypeDescription > >
SAL_CALL getTypeArguments() throw (css::uno::RuntimeException) {
return css::uno::Sequence<
css::uno::Reference< css::reflection::XTypeDescription > >();
}
css::uno::Reference< css::uno::XComponentContext > context_;
rtl::OUString name_;
rtl::Reference< cppu::unoidl::PlainStructTypeEntity > entity_;
};
css::uno::Sequence< css::uno::Reference< css::reflection::XTypeDescription > >
PlainStructTypeDescription::getMemberTypes() throw (css::uno::RuntimeException)
{
assert(entity_->getDirectMembers().size() <= SAL_MAX_INT32);
sal_Int32 n = static_cast< sal_Int32 >(entity_->getDirectMembers().size());
css::uno::Sequence<
css::uno::Reference< css::reflection::XTypeDescription > > s(n);
for (sal_Int32 i = 0; i != n; ++i) {
s[i] = resolve(context_, entity_->getDirectMembers()[i].type);
}
return s;
}
css::uno::Sequence< rtl::OUString > PlainStructTypeDescription::getMemberNames()
throw (css::uno::RuntimeException)
{
assert(entity_->getDirectMembers().size() <= SAL_MAX_INT32);
sal_Int32 n = static_cast< sal_Int32 >(entity_->getDirectMembers().size());
css::uno::Sequence< rtl::OUString > s(n);
for (sal_Int32 i = 0; i != n; ++i) {
s[i] = entity_->getDirectMembers()[i].name;
}
return s;
}
class ParameterizedMemberTypeDescription:
public cppu::WeakImplHelper1< css::reflection::XTypeDescription >,
private boost::noncopyable
{
public:
explicit ParameterizedMemberTypeDescription(
rtl::OUString const & typeParameterName):
typeParameterName_(typeParameterName)
{}
private:
virtual ~ParameterizedMemberTypeDescription() {}
virtual css::uno::TypeClass SAL_CALL getTypeClass()
throw (css::uno::RuntimeException)
{ return css::uno::TypeClass_UNKNOWN; }
virtual rtl::OUString SAL_CALL getName() throw (css::uno::RuntimeException)
{ return typeParameterName_; }
rtl::OUString typeParameterName_;
};
typedef cppu::ImplInheritanceHelper1<
PublishableDescription, css::reflection::XStructTypeDescription >
PolymorphicStructTypeTemplateDescription_Base;
class PolymorphicStructTypeTemplateDescription:
public PolymorphicStructTypeTemplateDescription_Base
{
public:
PolymorphicStructTypeTemplateDescription(
css::uno::Reference< css::uno::XComponentContext > const & context,
rtl::OUString const & name,
rtl::Reference< cppu::unoidl::PolymorphicStructTypeTemplateEntity >
const & entity):
PolymorphicStructTypeTemplateDescription_Base(entity->isPublished()),
context_(context), name_(name), entity_(entity)
{ assert(entity.is()); }
private:
virtual ~PolymorphicStructTypeTemplateDescription() {}
virtual css::uno::TypeClass SAL_CALL getTypeClass()
throw (css::uno::RuntimeException)
{ return css::uno::TypeClass_STRUCT; }
virtual rtl::OUString SAL_CALL getName() throw (css::uno::RuntimeException)
{ return name_; }
virtual css::uno::Reference< css::reflection::XTypeDescription > SAL_CALL
getBaseType() throw (css::uno::RuntimeException)
{ return css::uno::Reference< css::reflection::XTypeDescription >(); }
virtual
css::uno::Sequence<
css::uno::Reference< css::reflection::XTypeDescription > >
SAL_CALL getMemberTypes() throw (css::uno::RuntimeException);
virtual css::uno::Sequence< rtl::OUString > SAL_CALL getMemberNames()
throw (css::uno::RuntimeException);
virtual css::uno::Sequence< rtl::OUString > SAL_CALL getTypeParameters()
throw (css::uno::RuntimeException);
virtual
css::uno::Sequence<
css::uno::Reference< css::reflection::XTypeDescription > >
SAL_CALL getTypeArguments() throw (css::uno::RuntimeException) {
return css::uno::Sequence<
css::uno::Reference< css::reflection::XTypeDescription > >();
}
css::uno::Reference< css::uno::XComponentContext > context_;
rtl::OUString name_;
rtl::Reference< cppu::unoidl::PolymorphicStructTypeTemplateEntity > entity_;
};
css::uno::Sequence< css::uno::Reference< css::reflection::XTypeDescription > >
PolymorphicStructTypeTemplateDescription::getMemberTypes()
throw (css::uno::RuntimeException)
{
assert(entity_->getMembers().size() <= SAL_MAX_INT32);
sal_Int32 n = static_cast< sal_Int32 >(entity_->getMembers().size());
css::uno::Sequence<
css::uno::Reference< css::reflection::XTypeDescription > > s(n);
for (sal_Int32 i = 0; i != n; ++i) {
s[i] = entity_->getMembers()[i].parameterized
? new ParameterizedMemberTypeDescription(
entity_->getMembers()[i].type)
: resolve(context_, entity_->getMembers()[i].type);
}
return s;
}
css::uno::Sequence< rtl::OUString >
PolymorphicStructTypeTemplateDescription::getMemberNames()
throw (css::uno::RuntimeException)
{
assert(entity_->getMembers().size() <= SAL_MAX_INT32);
sal_Int32 n = static_cast< sal_Int32 >(entity_->getMembers().size());
css::uno::Sequence< rtl::OUString > s(n);
for (sal_Int32 i = 0; i != n; ++i) {
s[i] = entity_->getMembers()[i].name;
}
return s;
}
css::uno::Sequence< rtl::OUString >
PolymorphicStructTypeTemplateDescription::getTypeParameters()
throw (css::uno::RuntimeException)
{
assert(entity_->getTypeParameters().size() <= SAL_MAX_INT32);
sal_Int32 n = static_cast< sal_Int32 >(entity_->getTypeParameters().size());
css::uno::Sequence< rtl::OUString > s(n);
for (sal_Int32 i = 0; i != n; ++i) {
s[i] = entity_->getTypeParameters()[i];
}
return s;
}
typedef cppu::ImplInheritanceHelper1<
PublishableDescription, css::reflection::XCompoundTypeDescription >
ExceptionTypeDescription_Base;
class ExceptionTypeDescription: public ExceptionTypeDescription_Base {
public:
ExceptionTypeDescription(
css::uno::Reference< css::uno::XComponentContext > const & context,
rtl::OUString const & name,
rtl::Reference< cppu::unoidl::ExceptionTypeEntity > const & entity):
ExceptionTypeDescription_Base(entity->isPublished()), context_(context),
name_(name), entity_(entity)
{ assert(entity.is()); }
private:
virtual ~ExceptionTypeDescription() {}
virtual css::uno::TypeClass SAL_CALL getTypeClass()
throw (css::uno::RuntimeException)
{ return css::uno::TypeClass_EXCEPTION; }
virtual rtl::OUString SAL_CALL getName() throw (css::uno::RuntimeException)
{ return name_; }
virtual css::uno::Reference< css::reflection::XTypeDescription > SAL_CALL
getBaseType() throw (css::uno::RuntimeException) {
return entity_->getDirectBase().isEmpty()
? css::uno::Reference< css::reflection::XTypeDescription >()
: resolve(context_, entity_->getDirectBase());
}
virtual
css::uno::Sequence<
css::uno::Reference< css::reflection::XTypeDescription > >
SAL_CALL getMemberTypes() throw (css::uno::RuntimeException);
virtual css::uno::Sequence< rtl::OUString > SAL_CALL getMemberNames()
throw (css::uno::RuntimeException);
css::uno::Reference< css::uno::XComponentContext > context_;
rtl::OUString name_;
rtl::Reference< cppu::unoidl::ExceptionTypeEntity > entity_;
};
css::uno::Sequence< css::uno::Reference< css::reflection::XTypeDescription > >
ExceptionTypeDescription::getMemberTypes() throw (css::uno::RuntimeException) {
assert(entity_->getDirectMembers().size() <= SAL_MAX_INT32);
sal_Int32 n = static_cast< sal_Int32 >(entity_->getDirectMembers().size());
css::uno::Sequence<
css::uno::Reference< css::reflection::XTypeDescription > > s(n);
for (sal_Int32 i = 0; i != n; ++i) {
s[i] = resolve(context_, entity_->getDirectMembers()[i].type);
}
return s;
}
css::uno::Sequence< rtl::OUString > ExceptionTypeDescription::getMemberNames()
throw (css::uno::RuntimeException)
{
assert(entity_->getDirectMembers().size() <= SAL_MAX_INT32);
sal_Int32 n = static_cast< sal_Int32 >(entity_->getDirectMembers().size());
css::uno::Sequence< rtl::OUString > s(n);
for (sal_Int32 i = 0; i != n; ++i) {
s[i] = entity_->getDirectMembers()[i].name;
}
return s;
}
css::uno::Reference< css::reflection::XTypeDescription > resolveTypedefs(
css::uno::Reference< css::reflection::XTypeDescription > const & type)
{
css::uno::Reference< css::reflection::XTypeDescription > resolved(type);
while (resolved->getTypeClass() == css::uno::TypeClass_TYPEDEF) {
resolved
= (css::uno::Reference< css::reflection::XIndirectTypeDescription >(
resolved, css::uno::UNO_QUERY_THROW)->
getReferencedType());
}
return resolved;
}
class BaseOffset: private boost::noncopyable {
public:
BaseOffset(
css::uno::Reference< css::reflection::XInterfaceTypeDescription2 >
const & description);
sal_Int32 get() const { return offset_; }
private:
void calculateBases(
css::uno::Reference< css::reflection::XInterfaceTypeDescription2 >
const & description);
void calculate(
css::uno::Reference< css::reflection::XInterfaceTypeDescription2 >
const & description);
std::set< rtl::OUString > set_;
sal_Int32 offset_;
};
BaseOffset::BaseOffset(
css::uno::Reference< css::reflection::XInterfaceTypeDescription2 > const &
description):
offset_(0)
{
calculateBases(description);
}
void BaseOffset::calculateBases(
css::uno::Reference< css::reflection::XInterfaceTypeDescription2 > const &
description)
{
css::uno::Sequence<
css::uno::Reference < css::reflection::XTypeDescription > > bases(
description->getBaseTypes());
for (sal_Int32 i = 0; i != bases.getLength(); ++i) {
calculate(
css::uno::Reference< css::reflection::XInterfaceTypeDescription2 >(
resolveTypedefs(bases[i]), css::uno::UNO_QUERY_THROW));
}
}
void BaseOffset::calculate(
css::uno::Reference< css::reflection::XInterfaceTypeDescription2 > const &
description)
{
if (set_.insert(description->getName()).second) {
calculateBases(description);
offset_ += description->getMembers().getLength();
}
}
class AttributeDescription:
public cppu::WeakImplHelper1<
css::reflection::XInterfaceAttributeTypeDescription2 >,
private boost::noncopyable
{
public:
AttributeDescription(
css::uno::Reference< css::uno::XComponentContext > const & context,
rtl::OUString const & name,
cppu::unoidl::InterfaceTypeEntity::Attribute const & attribute,
sal_Int32 position):
context_(context), name_(name), attribute_(attribute),
position_(position)
{}
private:
virtual ~AttributeDescription() {}
virtual css::uno::TypeClass SAL_CALL getTypeClass()
throw (css::uno::RuntimeException)
{ return css::uno::TypeClass_INTERFACE_ATTRIBUTE; }
virtual rtl::OUString SAL_CALL getName() throw (css::uno::RuntimeException)
{ return name_; }
virtual rtl::OUString SAL_CALL getMemberName()
throw (css::uno::RuntimeException)
{ return attribute_.name; }
virtual sal_Int32 SAL_CALL getPosition() throw (css::uno::RuntimeException)
{ return position_; }
virtual sal_Bool SAL_CALL isReadOnly() throw (css::uno::RuntimeException)
{ return attribute_.readOnly; }
virtual css::uno::Reference< css::reflection::XTypeDescription > SAL_CALL
getType() throw (css::uno::RuntimeException)
{ return resolve(context_, attribute_.type); }
virtual sal_Bool SAL_CALL isBound() throw (css::uno::RuntimeException)
{ return attribute_.bound; }
virtual
css::uno::Sequence<
css::uno::Reference< css::reflection::XCompoundTypeDescription > >
SAL_CALL getGetExceptions() throw (css::uno::RuntimeException);
virtual
css::uno::Sequence<
css::uno::Reference< css::reflection::XCompoundTypeDescription > >
SAL_CALL getSetExceptions() throw (css::uno::RuntimeException);
css::uno::Reference< css::uno::XComponentContext > context_;
rtl::OUString name_;
cppu::unoidl::InterfaceTypeEntity::Attribute attribute_;
sal_Int32 position_;
};
css::uno::Sequence<
css::uno::Reference< css::reflection::XCompoundTypeDescription > >
AttributeDescription::getGetExceptions() throw (css::uno::RuntimeException) {
assert(attribute_.getExceptions.size() <= SAL_MAX_INT32);
sal_Int32 n = static_cast< sal_Int32 >(attribute_.getExceptions.size());
css::uno::Sequence<
css::uno::Reference< css::reflection::XCompoundTypeDescription > > s(n);
for (sal_Int32 i = 0; i != n; ++i) {
s[i].set(
resolve(context_, attribute_.getExceptions[i]),
css::uno::UNO_QUERY_THROW);
}
return s;
}
css::uno::Sequence<
css::uno::Reference< css::reflection::XCompoundTypeDescription > >
AttributeDescription::getSetExceptions() throw (css::uno::RuntimeException) {
assert(attribute_.setExceptions.size() <= SAL_MAX_INT32);
sal_Int32 n = static_cast< sal_Int32 >(attribute_.setExceptions.size());
css::uno::Sequence<
css::uno::Reference< css::reflection::XCompoundTypeDescription > > s(n);
for (sal_Int32 i = 0; i != n; ++i) {
s[i].set(
resolve(context_, attribute_.setExceptions[i]),
css::uno::UNO_QUERY_THROW);
}
return s;
}
class MethodParameter:
public cppu::WeakImplHelper1< css::reflection::XMethodParameter >,
private boost::noncopyable
{
public:
MethodParameter(
css::uno::Reference< css::uno::XComponentContext > const & context,
cppu::unoidl::InterfaceTypeEntity::Method::Parameter const & parameter,
sal_Int32 position):
context_(context), parameter_(parameter), position_(position)
{}
private:
virtual ~MethodParameter() {}
virtual rtl::OUString SAL_CALL getName() throw (css::uno::RuntimeException)
{ return parameter_.name; }
virtual css::uno::Reference< css::reflection::XTypeDescription > SAL_CALL
getType() throw (css::uno::RuntimeException)
{ return resolve(context_, parameter_.type); }
virtual sal_Bool SAL_CALL isIn() throw (css::uno::RuntimeException) {
return
(parameter_.direction
== cppu::unoidl::InterfaceTypeEntity::Method::Parameter::
DIRECTION_IN)
|| (parameter_.direction
== cppu::unoidl::InterfaceTypeEntity::Method::Parameter::
DIRECTION_IN_OUT);
}
virtual sal_Bool SAL_CALL isOut() throw (css::uno::RuntimeException) {
return
(parameter_.direction
== cppu::unoidl::InterfaceTypeEntity::Method::Parameter::
DIRECTION_OUT)
|| (parameter_.direction
== cppu::unoidl::InterfaceTypeEntity::Method::Parameter::
DIRECTION_IN_OUT);
}
virtual sal_Int32 SAL_CALL getPosition() throw (css::uno::RuntimeException)
{ return position_; }
css::uno::Reference< css::uno::XComponentContext > context_;
cppu::unoidl::InterfaceTypeEntity::Method::Parameter parameter_;
sal_Int32 position_;
};
class MethodDescription:
public cppu::WeakImplHelper1<
css::reflection::XInterfaceMethodTypeDescription >,
private boost::noncopyable
{
public:
MethodDescription(
css::uno::Reference< css::uno::XComponentContext > const & context,
rtl::OUString const & name,
cppu::unoidl::InterfaceTypeEntity::Method const & method,
sal_Int32 position):
context_(context), name_(name), method_(method), position_(position)
{}
private:
virtual ~MethodDescription() {}
virtual css::uno::TypeClass SAL_CALL getTypeClass()
throw (css::uno::RuntimeException)
{ return css::uno::TypeClass_INTERFACE_METHOD; }
virtual rtl::OUString SAL_CALL getName() throw (css::uno::RuntimeException)
{ return name_; }
virtual rtl::OUString SAL_CALL getMemberName()
throw (css::uno::RuntimeException)
{ return method_.name; }
virtual sal_Int32 SAL_CALL getPosition() throw (css::uno::RuntimeException)
{ return position_; }
virtual css::uno::Reference< css::reflection::XTypeDescription > SAL_CALL
getReturnType() throw (css::uno::RuntimeException)
{ return resolve(context_, method_.returnType); }
virtual sal_Bool SAL_CALL isOneway() throw (css::uno::RuntimeException)
{ return false; }
virtual
css::uno::Sequence<
css::uno::Reference< css::reflection::XMethodParameter > >
SAL_CALL getParameters() throw (css::uno::RuntimeException);
virtual
css::uno::Sequence<
css::uno::Reference< css::reflection::XTypeDescription > >
SAL_CALL getExceptions() throw (css::uno::RuntimeException);
css::uno::Reference< css::uno::XComponentContext > context_;
rtl::OUString name_;
cppu::unoidl::InterfaceTypeEntity::Method method_;
sal_Int32 position_;
};
css::uno::Sequence< css::uno::Reference< css::reflection::XMethodParameter > >
MethodDescription::getParameters() throw (css::uno::RuntimeException) {
assert(method_.parameters.size() <= SAL_MAX_INT32);
sal_Int32 n = static_cast< sal_Int32 >(method_.parameters.size());
css::uno::Sequence<
css::uno::Reference< css::reflection::XMethodParameter > > s(n);
for (sal_Int32 i = 0; i != n; ++i) {
s[i] = new MethodParameter(context_, method_.parameters[i], i);
}
return s;
}
css::uno::Sequence< css::uno::Reference< css::reflection::XTypeDescription > >
MethodDescription::getExceptions() throw (css::uno::RuntimeException) {
assert(method_.exceptions.size() <= SAL_MAX_INT32);
sal_Int32 n = static_cast< sal_Int32 >(method_.exceptions.size());
css::uno::Sequence<
css::uno::Reference< css::reflection::XTypeDescription > > s(n);
for (sal_Int32 i = 0; i != n; ++i) {
s[i] = resolve(context_, method_.exceptions[i]);
}
return s;
}
typedef cppu::ImplInheritanceHelper1<
PublishableDescription, css::reflection::XInterfaceTypeDescription2 >
InterfaceTypeDescription_Base;
class InterfaceTypeDescription: public InterfaceTypeDescription_Base {
public:
InterfaceTypeDescription(
css::uno::Reference< css::uno::XComponentContext > const & context,
rtl::OUString const & name,
rtl::Reference< cppu::unoidl::InterfaceTypeEntity > const & entity):
InterfaceTypeDescription_Base(entity->isPublished()), context_(context),
name_(name), entity_(entity)
{ assert(entity.is()); }
private:
virtual ~InterfaceTypeDescription() {}
virtual css::uno::TypeClass SAL_CALL getTypeClass()
throw (css::uno::RuntimeException)
{ return css::uno::TypeClass_INTERFACE; }
virtual rtl::OUString SAL_CALL getName() throw (css::uno::RuntimeException)
{ return name_; }
virtual css::uno::Reference< css::reflection::XTypeDescription > SAL_CALL
getBaseType() throw (css::uno::RuntimeException) {
return entity_->getDirectMandatoryBases().empty()
? css::uno::Reference< css::reflection::XTypeDescription >()
: resolve(context_, entity_->getDirectMandatoryBases()[0]);
}
virtual css::uno::Uik SAL_CALL getUik() throw (css::uno::RuntimeException)
{ return css::uno::Uik(); }
virtual
css::uno::Sequence<
css::uno::Reference<
css::reflection::XInterfaceMemberTypeDescription > >
SAL_CALL getMembers() throw (css::uno::RuntimeException);
virtual
css::uno::Sequence<
css::uno::Reference< css::reflection::XTypeDescription > >
SAL_CALL getBaseTypes() throw (css::uno::RuntimeException);
virtual
css::uno::Sequence<
css::uno::Reference< css::reflection::XTypeDescription > >
SAL_CALL getOptionalBaseTypes() throw (css::uno::RuntimeException);
css::uno::Reference< css::uno::XComponentContext > context_;
rtl::OUString name_;
rtl::Reference< cppu::unoidl::InterfaceTypeEntity > entity_;
};
css::uno::Sequence<
css::uno::Reference< css::reflection::XInterfaceMemberTypeDescription > >
InterfaceTypeDescription::getMembers() throw (css::uno::RuntimeException) {
assert(
entity_->getDirectAttributes().size() <= SAL_MAX_INT32
&& (entity_->getDirectMethods().size()
<= SAL_MAX_INT32 - entity_->getDirectAttributes().size()));
sal_Int32 n1 = static_cast< sal_Int32 >(
entity_->getDirectAttributes().size());
sal_Int32 n2 = static_cast< sal_Int32 >(entity_->getDirectMethods().size());
css::uno::Sequence<
css::uno::Reference<
css::reflection::XInterfaceMemberTypeDescription > > s(n1 + n2);
sal_Int32 off = BaseOffset(this).get();
for (sal_Int32 i = 0; i != n1; ++i) {
s[i] = new AttributeDescription(
context_, name_ + "::" + entity_->getDirectAttributes()[i].name,
entity_->getDirectAttributes()[i], off + i);
}
for (sal_Int32 i = 0; i != n2; ++i) {
s[n1 + i] = new MethodDescription(
context_, name_ + "::" + entity_->getDirectMethods()[i].name,
entity_->getDirectMethods()[i], off + n1 + i);
}
return s;
}
css::uno::Sequence< css::uno::Reference< css::reflection::XTypeDescription > >
InterfaceTypeDescription::getBaseTypes() throw (css::uno::RuntimeException) {
assert(entity_->getDirectMandatoryBases().size() <= SAL_MAX_INT32);
sal_Int32 n = static_cast< sal_Int32 >(
entity_->getDirectMandatoryBases().size());
css::uno::Sequence<
css::uno::Reference< css::reflection::XTypeDescription > > s(n);
for (sal_Int32 i = 0; i != n; ++i) {
s[i] = resolve(context_, entity_->getDirectMandatoryBases()[i]);
}
return s;
}
css::uno::Sequence< css::uno::Reference< css::reflection::XTypeDescription > >
InterfaceTypeDescription::getOptionalBaseTypes()
throw (css::uno::RuntimeException)
{
assert(entity_->getDirectOptionalBases().size() <= SAL_MAX_INT32);
sal_Int32 n = static_cast< sal_Int32 >(
entity_->getDirectOptionalBases().size());
css::uno::Sequence<
css::uno::Reference< css::reflection::XTypeDescription > > s(n);
for (sal_Int32 i = 0; i != n; ++i) {
s[i] = resolve(context_, entity_->getDirectOptionalBases()[i]);
}
return s;
}
class ConstantDescription:
public cppu::WeakImplHelper1< css::reflection::XConstantTypeDescription >,
private boost::noncopyable
{
public:
ConstantDescription(
rtl::OUString const & name, css::uno::Any const & value):
name_(name), value_(value)
{}
private:
virtual ~ConstantDescription() {}
virtual css::uno::TypeClass SAL_CALL getTypeClass()
throw (css::uno::RuntimeException)
{ return css::uno::TypeClass_CONSTANT; }
virtual rtl::OUString SAL_CALL getName() throw (css::uno::RuntimeException)
{ return name_; }
virtual css::uno::Any SAL_CALL getConstantValue()
throw (css::uno::RuntimeException)
{ return value_; }
rtl::OUString name_;
css::uno::Any value_;
};
typedef cppu::ImplInheritanceHelper1<
PublishableDescription, css::reflection::XConstantsTypeDescription >
ConstantGroupDescription_Base;
class ConstantGroupDescription: public ConstantGroupDescription_Base {
public:
ConstantGroupDescription(
css::uno::Reference< css::uno::XComponentContext > const & context,
rtl::OUString const & name,
rtl::Reference< cppu::unoidl::ConstantGroupEntity > const & entity):
ConstantGroupDescription_Base(entity->isPublished()), context_(context),
name_(name), entity_(entity)
{ assert(entity.is()); }
private:
virtual ~ConstantGroupDescription() {}
virtual css::uno::TypeClass SAL_CALL getTypeClass()
throw (css::uno::RuntimeException)
{ return css::uno::TypeClass_CONSTANTS; }
virtual rtl::OUString SAL_CALL getName() throw (css::uno::RuntimeException)
{ return name_; }
virtual
css::uno::Sequence<
css::uno::Reference< css::reflection::XConstantTypeDescription > >
SAL_CALL getConstants() throw (css::uno::RuntimeException);
css::uno::Reference< css::uno::XComponentContext > context_;
rtl::OUString name_;
rtl::Reference< cppu::unoidl::ConstantGroupEntity > entity_;
};
css::uno::Sequence<
css::uno::Reference< css::reflection::XConstantTypeDescription > >
ConstantGroupDescription::getConstants() throw (css::uno::RuntimeException) {
assert(entity_->getMembers().size() <= SAL_MAX_INT32);
sal_Int32 n = static_cast< sal_Int32 >(entity_->getMembers().size());
css::uno::Sequence<
css::uno::Reference< css::reflection::XConstantTypeDescription > > s(n);
for (sal_Int32 i = 0; i != n; ++i) {
//TODO: use entity_->getMembers()[i].value directly?
s[i].set(
resolve(context_, name_ + "." + entity_->getMembers()[i].name),
css::uno::UNO_QUERY_THROW);
}
return s;
}
typedef cppu::ImplInheritanceHelper1<
PublishableDescription, css::reflection::XIndirectTypeDescription >
TypedefDescription_Base;
class TypedefDescription: public TypedefDescription_Base {
public:
TypedefDescription(
css::uno::Reference< css::uno::XComponentContext > const & context,
rtl::OUString const & name,
rtl::Reference< cppu::unoidl::TypedefEntity > const & entity):
TypedefDescription_Base(entity->isPublished()), context_(context),
name_(name), entity_(entity)
{ assert(entity.is()); }
private:
virtual ~TypedefDescription() {}
virtual css::uno::TypeClass SAL_CALL getTypeClass()
throw (css::uno::RuntimeException)
{ return css::uno::TypeClass_TYPEDEF; }
virtual rtl::OUString SAL_CALL getName() throw (css::uno::RuntimeException)
{ return name_; }
virtual css::uno::Reference< css::reflection::XTypeDescription > SAL_CALL
getReferencedType() throw (css::uno::RuntimeException)
{ return resolve(context_, entity_->getType()); }
css::uno::Reference< css::uno::XComponentContext > context_;
rtl::OUString name_;
rtl::Reference< cppu::unoidl::TypedefEntity > entity_;
};
class ConstructorParameter:
public cppu::WeakImplHelper1< css::reflection::XParameter >,
private boost::noncopyable
{
public:
ConstructorParameter(
css::uno::Reference< css::uno::XComponentContext > const & context,
cppu::unoidl::SingleInterfaceBasedServiceEntity::Constructor::Parameter
const & parameter,
sal_Int32 position):
context_(context), parameter_(parameter), position_(position)
{}
private:
virtual ~ConstructorParameter() {}
virtual rtl::OUString SAL_CALL getName() throw (css::uno::RuntimeException)
{ return parameter_.name; }
virtual css::uno::Reference< css::reflection::XTypeDescription > SAL_CALL
getType() throw (css::uno::RuntimeException)
{ return resolve(context_, parameter_.type); }
virtual sal_Bool SAL_CALL isIn() throw (css::uno::RuntimeException)
{ return true; }
virtual sal_Bool SAL_CALL isOut() throw (css::uno::RuntimeException)
{ return false; }
virtual sal_Int32 SAL_CALL getPosition() throw (css::uno::RuntimeException)
{ return position_; }
virtual sal_Bool SAL_CALL isRestParameter()
throw (css::uno::RuntimeException)
{ return parameter_.rest; }
css::uno::Reference< css::uno::XComponentContext > context_;
cppu::unoidl::SingleInterfaceBasedServiceEntity::Constructor::Parameter
parameter_;
sal_Int32 position_;
};
class ConstructorDescription:
public cppu::WeakImplHelper1<
css::reflection::XServiceConstructorDescription >,
private boost::noncopyable
{
public:
ConstructorDescription(
css::uno::Reference< css::uno::XComponentContext > const & context,
cppu::unoidl::SingleInterfaceBasedServiceEntity::Constructor const &
constructor):
context_(context), constructor_(constructor)
{}
private:
virtual ~ConstructorDescription() {}
virtual sal_Bool SAL_CALL isDefaultConstructor()
throw (css::uno::RuntimeException)
{ return constructor_.defaultConstructor; }
virtual rtl::OUString SAL_CALL getName() throw (css::uno::RuntimeException)
{ return constructor_.name; }
virtual
css::uno::Sequence<
css::uno::Reference< css::reflection::XParameter > >
SAL_CALL getParameters() throw (css::uno::RuntimeException);
virtual
css::uno::Sequence<
css::uno::Reference< css::reflection::XCompoundTypeDescription > >
SAL_CALL getExceptions() throw (css::uno::RuntimeException);
css::uno::Reference< css::uno::XComponentContext > context_;
cppu::unoidl::SingleInterfaceBasedServiceEntity::Constructor constructor_;
};
css::uno::Sequence< css::uno::Reference< css::reflection::XParameter > >
ConstructorDescription::getParameters() throw (css::uno::RuntimeException) {
assert(constructor_.parameters.size() <= SAL_MAX_INT32);
sal_Int32 n = static_cast< sal_Int32 >(constructor_.parameters.size());
css::uno::Sequence< css::uno::Reference< css::reflection::XParameter > > s(
n);
for (sal_Int32 i = 0; i != n; ++i) {
s[i] = new ConstructorParameter(
context_, constructor_.parameters[i], i);
}
return s;
}
css::uno::Sequence<
css::uno::Reference< css::reflection::XCompoundTypeDescription > >
ConstructorDescription::getExceptions() throw (css::uno::RuntimeException) {
assert(constructor_.exceptions.size() <= SAL_MAX_INT32);
sal_Int32 n = static_cast< sal_Int32 >(constructor_.exceptions.size());
css::uno::Sequence<
css::uno::Reference< css::reflection::XCompoundTypeDescription > > s(n);
for (sal_Int32 i = 0; i != n; ++i) {
s[i].set(
resolve(context_, constructor_.exceptions[i]),
css::uno::UNO_QUERY_THROW);
}
return s;
}
typedef cppu::ImplInheritanceHelper1<
PublishableDescription, css::reflection::XServiceTypeDescription2 >
SingleInterfaceBasedServiceDescription_Base;
class SingleInterfaceBasedServiceDescription:
public SingleInterfaceBasedServiceDescription_Base
{
public:
SingleInterfaceBasedServiceDescription(
css::uno::Reference< css::uno::XComponentContext > const & context,
rtl::OUString const & name,
rtl::Reference< cppu::unoidl::SingleInterfaceBasedServiceEntity >
const & entity):
SingleInterfaceBasedServiceDescription_Base(entity->isPublished()),
context_(context), name_(name), entity_(entity)
{ assert(entity.is()); }
private:
virtual ~SingleInterfaceBasedServiceDescription() {}
virtual css::uno::TypeClass SAL_CALL getTypeClass()
throw (css::uno::RuntimeException)
{ return css::uno::TypeClass_SERVICE; }
virtual rtl::OUString SAL_CALL getName() throw (css::uno::RuntimeException)
{ return name_; }
virtual
css::uno::Sequence<
css::uno::Reference< css::reflection::XServiceTypeDescription > >
SAL_CALL getMandatoryServices() throw (css::uno::RuntimeException)
{
return css::uno::Sequence<
css::uno::Reference< css::reflection::XServiceTypeDescription > >();
}
virtual
css::uno::Sequence<
css::uno::Reference< css::reflection::XServiceTypeDescription > >
SAL_CALL getOptionalServices() throw (css::uno::RuntimeException)
{
return css::uno::Sequence<
css::uno::Reference< css::reflection::XServiceTypeDescription > >();
}
virtual
css::uno::Sequence<
css::uno::Reference< css::reflection::XInterfaceTypeDescription > >
SAL_CALL getMandatoryInterfaces() throw (css::uno::RuntimeException)
{
return css::uno::Sequence<
css::uno::Reference<
css::reflection::XInterfaceTypeDescription > >();
}
virtual
css::uno::Sequence<
css::uno::Reference< css::reflection::XInterfaceTypeDescription > >
SAL_CALL getOptionalInterfaces() throw (css::uno::RuntimeException)
{
return css::uno::Sequence<
css::uno::Reference<
css::reflection::XInterfaceTypeDescription > >();
}
virtual
css::uno::Sequence<
css::uno::Reference< css::reflection::XPropertyTypeDescription > >
SAL_CALL getProperties() throw (css::uno::RuntimeException)
{
return css::uno::Sequence<
css::uno::Reference<
css::reflection::XPropertyTypeDescription > >();
}
virtual sal_Bool SAL_CALL isSingleInterfaceBased()
throw (css::uno::RuntimeException)
{ return true; }
virtual css::uno::Reference< css::reflection::XTypeDescription > SAL_CALL
getInterface() throw (css::uno::RuntimeException)
{ return resolve(context_, entity_->getBase()); }
virtual
css::uno::Sequence<
css::uno::Reference< css::reflection::XServiceConstructorDescription > >
SAL_CALL getConstructors() throw (css::uno::RuntimeException);
css::uno::Reference< css::uno::XComponentContext > context_;
rtl::OUString name_;
rtl::Reference< cppu::unoidl::SingleInterfaceBasedServiceEntity > entity_;
};
css::uno::Sequence<
css::uno::Reference< css::reflection::XServiceConstructorDescription > >
SingleInterfaceBasedServiceDescription::getConstructors()
throw (css::uno::RuntimeException)
{
assert(entity_->getConstructors().size() <= SAL_MAX_INT32);
sal_Int32 n = static_cast< sal_Int32 >(entity_->getConstructors().size());
css::uno::Sequence<
css::uno::Reference< css::reflection::XServiceConstructorDescription > >
s(n);
for (sal_Int32 i = 0; i != n; ++i) {
s[i] = new ConstructorDescription(
context_, entity_->getConstructors()[i]);
}
return s;
}
class PropertyDescription:
public cppu::WeakImplHelper1< css::reflection::XPropertyTypeDescription >,
private boost::noncopyable
{
public:
PropertyDescription(
css::uno::Reference< css::uno::XComponentContext > const & context,
cppu::unoidl::AccumulationBasedServiceEntity::Property const &
property):
context_(context), property_(property)
{}
private:
virtual ~PropertyDescription() {}
virtual css::uno::TypeClass SAL_CALL getTypeClass()
throw (css::uno::RuntimeException)
{ return css::uno::TypeClass_PROPERTY; }
virtual rtl::OUString SAL_CALL getName() throw (css::uno::RuntimeException)
{ return property_.name; }
virtual sal_Int16 SAL_CALL getPropertyFlags()
throw (css::uno::RuntimeException)
{ return property_.attributes; }
virtual css::uno::Reference< css::reflection::XTypeDescription > SAL_CALL
getPropertyTypeDescription() throw (css::uno::RuntimeException)
{ return resolve(context_, property_.type); }
css::uno::Reference< css::uno::XComponentContext > context_;
cppu::unoidl::AccumulationBasedServiceEntity::Property property_;
};
typedef cppu::ImplInheritanceHelper1<
PublishableDescription, css::reflection::XServiceTypeDescription2 >
AccumulationBasedServiceDescription_Base;
class AccumulationBasedServiceDescription:
public AccumulationBasedServiceDescription_Base
{
public:
AccumulationBasedServiceDescription(
css::uno::Reference< css::uno::XComponentContext > const & context,
rtl::OUString const & name,
rtl::Reference< cppu::unoidl::AccumulationBasedServiceEntity > const &
entity):
AccumulationBasedServiceDescription_Base(entity->isPublished()),
context_(context), name_(name), entity_(entity)
{ assert(entity.is()); }
private:
virtual ~AccumulationBasedServiceDescription() {}
virtual css::uno::TypeClass SAL_CALL getTypeClass()
throw (css::uno::RuntimeException)
{ return css::uno::TypeClass_SERVICE; }
virtual rtl::OUString SAL_CALL getName() throw (css::uno::RuntimeException)
{ return name_; }
virtual
css::uno::Sequence<
css::uno::Reference< css::reflection::XServiceTypeDescription > >
SAL_CALL getMandatoryServices() throw (css::uno::RuntimeException);
virtual
css::uno::Sequence<
css::uno::Reference< css::reflection::XServiceTypeDescription > >
SAL_CALL getOptionalServices() throw (css::uno::RuntimeException);
virtual
css::uno::Sequence<
css::uno::Reference< css::reflection::XInterfaceTypeDescription > >
SAL_CALL getMandatoryInterfaces() throw (css::uno::RuntimeException);
virtual
css::uno::Sequence<
css::uno::Reference< css::reflection::XInterfaceTypeDescription > >
SAL_CALL getOptionalInterfaces() throw (css::uno::RuntimeException);
virtual
css::uno::Sequence<
css::uno::Reference< css::reflection::XPropertyTypeDescription > >
SAL_CALL getProperties() throw (css::uno::RuntimeException);
virtual sal_Bool SAL_CALL isSingleInterfaceBased()
throw (css::uno::RuntimeException)
{ return false; }
virtual css::uno::Reference< css::reflection::XTypeDescription > SAL_CALL
getInterface() throw (css::uno::RuntimeException)
{ return css::uno::Reference< css::reflection::XTypeDescription >(); }
virtual
css::uno::Sequence<
css::uno::Reference< css::reflection::XServiceConstructorDescription > >
SAL_CALL getConstructors() throw (css::uno::RuntimeException)
{
return css::uno::Sequence<
css::uno::Reference<
css::reflection::XServiceConstructorDescription > >();
}
css::uno::Reference< css::uno::XComponentContext > context_;
rtl::OUString name_;
rtl::Reference< cppu::unoidl::AccumulationBasedServiceEntity > entity_;
};
css::uno::Sequence<
css::uno::Reference< css::reflection::XServiceTypeDescription > >
AccumulationBasedServiceDescription::getMandatoryServices()
throw (css::uno::RuntimeException)
{
assert(entity_->getDirectMandatoryBaseServices().size() <= SAL_MAX_INT32);
sal_Int32 n = static_cast< sal_Int32 >(
entity_->getDirectMandatoryBaseServices().size());
css::uno::Sequence<
css::uno::Reference< css::reflection::XServiceTypeDescription > > s(n);
for (sal_Int32 i = 0; i != n; ++i) {
s[i].set(
resolve(context_, entity_->getDirectMandatoryBaseServices()[i]),
css::uno::UNO_QUERY_THROW);
}
return s;
}
css::uno::Sequence<
css::uno::Reference< css::reflection::XServiceTypeDescription > >
AccumulationBasedServiceDescription::getOptionalServices()
throw (css::uno::RuntimeException)
{
assert(entity_->getDirectOptionalBaseServices().size() <= SAL_MAX_INT32);
sal_Int32 n = static_cast< sal_Int32 >(
entity_->getDirectOptionalBaseServices().size());
css::uno::Sequence<
css::uno::Reference< css::reflection::XServiceTypeDescription > > s(n);
for (sal_Int32 i = 0; i != n; ++i) {
s[i].set(
resolve(context_, entity_->getDirectOptionalBaseServices()[i]),
css::uno::UNO_QUERY_THROW);
}
return s;
}
css::uno::Sequence<
css::uno::Reference< css::reflection::XInterfaceTypeDescription > >
AccumulationBasedServiceDescription::getMandatoryInterfaces()
throw (css::uno::RuntimeException)
{
assert(entity_->getDirectMandatoryBaseInterfaces().size() <= SAL_MAX_INT32);
sal_Int32 n = static_cast< sal_Int32 >(
entity_->getDirectMandatoryBaseInterfaces().size());
css::uno::Sequence<
css::uno::Reference< css::reflection::XInterfaceTypeDescription > > s(
n);
for (sal_Int32 i = 0; i != n; ++i) {
s[i].set(
resolveTypedefs(
resolve(
context_, entity_->getDirectMandatoryBaseInterfaces()[i])),
css::uno::UNO_QUERY_THROW);
}
return s;
}
css::uno::Sequence<
css::uno::Reference< css::reflection::XInterfaceTypeDescription > >
AccumulationBasedServiceDescription::getOptionalInterfaces()
throw (css::uno::RuntimeException)
{
assert(entity_->getDirectOptionalBaseInterfaces().size() <= SAL_MAX_INT32);
sal_Int32 n = static_cast< sal_Int32 >(
entity_->getDirectOptionalBaseInterfaces().size());
css::uno::Sequence<
css::uno::Reference< css::reflection::XInterfaceTypeDescription > > s(
n);
for (sal_Int32 i = 0; i != n; ++i) {
s[i].set(
resolveTypedefs(
resolve(
context_, entity_->getDirectOptionalBaseInterfaces()[i])),
css::uno::UNO_QUERY_THROW);
}
return s;
}
css::uno::Sequence<
css::uno::Reference< css::reflection::XPropertyTypeDescription > >
AccumulationBasedServiceDescription::getProperties()
throw (css::uno::RuntimeException)
{
assert(entity_->getDirectProperties().size() <= SAL_MAX_INT32);
sal_Int32 n = static_cast< sal_Int32 >(
entity_->getDirectProperties().size());
css::uno::Sequence<
css::uno::Reference< css::reflection::XPropertyTypeDescription > > s(n);
for (sal_Int32 i = 0; i != n; ++i) {
s[i] = new PropertyDescription(
context_, entity_->getDirectProperties()[i]);
}
return s;
}
typedef cppu::ImplInheritanceHelper1<
PublishableDescription, css::reflection::XSingletonTypeDescription2 >
InterfaceBasedSingletonDescription_Base;
class InterfaceBasedSingletonDescription:
public InterfaceBasedSingletonDescription_Base
{
public:
InterfaceBasedSingletonDescription(
css::uno::Reference< css::uno::XComponentContext > const & context,
rtl::OUString const & name,
rtl::Reference< cppu::unoidl::InterfaceBasedSingletonEntity > const &
entity):
InterfaceBasedSingletonDescription_Base(entity->isPublished()),
context_(context), name_(name), entity_(entity)
{ assert(entity.is()); }
private:
virtual ~InterfaceBasedSingletonDescription() {}
virtual css::uno::TypeClass SAL_CALL getTypeClass()
throw (css::uno::RuntimeException)
{ return css::uno::TypeClass_SINGLETON; }
virtual rtl::OUString SAL_CALL getName() throw (css::uno::RuntimeException)
{ return name_; }
virtual css::uno::Reference< css::reflection::XServiceTypeDescription >
SAL_CALL getService() throw (css::uno::RuntimeException)
{
return
css::uno::Reference< css::reflection::XServiceTypeDescription >();
}
virtual sal_Bool SAL_CALL isInterfaceBased()
throw (css::uno::RuntimeException)
{ return true; }
virtual css::uno::Reference< css::reflection::XTypeDescription >
SAL_CALL getInterface() throw (css::uno::RuntimeException)
{ return resolve(context_, entity_->getBase()); }
css::uno::Reference< css::uno::XComponentContext > context_;
rtl::OUString name_;
rtl::Reference< cppu::unoidl::InterfaceBasedSingletonEntity > entity_;
};
typedef cppu::ImplInheritanceHelper1<
PublishableDescription, css::reflection::XSingletonTypeDescription2 >
ServiceBasedSingletonDescription_Base;
class ServiceBasedSingletonDescription:
public ServiceBasedSingletonDescription_Base
{
public:
ServiceBasedSingletonDescription(
css::uno::Reference< css::uno::XComponentContext > const & context,
rtl::OUString const & name,
rtl::Reference< cppu::unoidl::ServiceBasedSingletonEntity > const &
entity):
ServiceBasedSingletonDescription_Base(entity_->isPublished()),
context_(context), name_(name), entity_(entity)
{ assert(entity.is()); }
private:
virtual ~ServiceBasedSingletonDescription() {}
virtual css::uno::TypeClass SAL_CALL getTypeClass()
throw (css::uno::RuntimeException)
{ return css::uno::TypeClass_SINGLETON; }
virtual rtl::OUString SAL_CALL getName() throw (css::uno::RuntimeException)
{ return name_; }
virtual css::uno::Reference< css::reflection::XServiceTypeDescription >
SAL_CALL getService() throw (css::uno::RuntimeException)
{
return css::uno::Reference< css::reflection::XServiceTypeDescription >(
resolve(context_, entity_->getBase()), css::uno::UNO_QUERY_THROW);
}
virtual sal_Bool SAL_CALL isInterfaceBased()
throw (css::uno::RuntimeException)
{ return false; }
virtual css::uno::Reference< css::reflection::XTypeDescription >
SAL_CALL getInterface() throw (css::uno::RuntimeException)
{ return css::uno::Reference< css::reflection::XTypeDescription >(); }
css::uno::Reference< css::uno::XComponentContext > context_;
rtl::OUString name_;
rtl::Reference< cppu::unoidl::ServiceBasedSingletonEntity > entity_;
};
class Enumeration:
public cppu::WeakImplHelper1<
css::reflection::XTypeDescriptionEnumeration >,
private boost::noncopyable
{
public:
Enumeration(
css::uno::Reference< css::uno::XComponentContext > const & context,
rtl::OUString const & prefix,
rtl::Reference< cppu::unoidl::MapCursor > const & cursor,
css::uno::Sequence< css::uno::TypeClass > const & types, bool deep):
context_(context), types_(types), deep_(deep)
{
positions_.push(Position(prefix, cursor));
findNextMatch();
}
private:
virtual ~Enumeration() {}
virtual sal_Bool SAL_CALL hasMoreElements()
throw (css::uno::RuntimeException)
{ return !positions_.empty(); }
virtual css::uno::Any SAL_CALL nextElement()
throw (
css::container::NoSuchElementException,
css::lang::WrappedTargetException, css::uno::RuntimeException)
{ return css::uno::makeAny(nextTypeDescription()); }
virtual css::uno::Reference< css::reflection::XTypeDescription > SAL_CALL
nextTypeDescription()
throw (
css::container::NoSuchElementException, css::uno::RuntimeException);
bool matches(css::uno::TypeClass tc) const;
void findNextMatch();
struct Position {
Position(
rtl::OUString const & thePrefix,
rtl::Reference< cppu::unoidl::MapCursor > const & theCursor):
prefix(thePrefix), cursor(theCursor)
{ assert(theCursor.is()); }
Position(
rtl::OUString const & thePrefix,
rtl::Reference< cppu::unoidl::ConstantGroupEntity > const &
theConstantGroup):
prefix(thePrefix), constantGroup(theConstantGroup),
constantGroupIndex(constantGroup->getMembers().begin())
{ assert(theConstantGroup.is()); }
rtl::OUString prefix;
rtl::Reference< cppu::unoidl::MapCursor > cursor;
rtl::Reference< cppu::unoidl::ConstantGroupEntity > constantGroup;
std::vector< cppu::unoidl::ConstantGroupEntity::Member >::const_iterator
constantGroupIndex;
};
css::uno::Reference< css::uno::XComponentContext > context_;
css::uno::Sequence< css::uno::TypeClass > types_;
bool deep_;
osl::Mutex mutex_;
std::stack< Position > positions_;
rtl::OUString current_;
};
css::uno::Reference< css::reflection::XTypeDescription >
Enumeration::nextTypeDescription()
throw (css::container::NoSuchElementException, css::uno::RuntimeException)
{
rtl::OUString name;
{
osl::MutexGuard g(mutex_);
if (positions_.empty()) {
throw css::container::NoSuchElementException(
"exhausted XTypeDescriptionEnumeration",
static_cast< cppu::OWeakObject * >(this));
}
name = current_;
findNextMatch();
}
return resolve(context_, name);
}
bool Enumeration::matches(css::uno::TypeClass tc) const {
if (types_.getLength() == 0) {
return true;
}
for (sal_Int32 i = 0; i != types_.getLength(); ++i) {
if (types_[i] == tc) {
return true;
}
}
return false;
}
void Enumeration::findNextMatch() {
for (;;) {
assert(!positions_.empty());
rtl::OUString name;
if (positions_.top().cursor.is()) { // root or module
rtl::Reference< cppu::unoidl::Entity > ent(
positions_.top().cursor->getNext(&name));
if (!ent.is()) {
positions_.pop();
if (positions_.empty()) {
break;
}
continue;
}
name = positions_.top().prefix + name;
css::uno::TypeClass tc;
switch (ent->getSort()) {
case cppu::unoidl::Entity::SORT_MODULE:
tc = css::uno::TypeClass_MODULE;
if (deep_) {
positions_.push(
Position(
name + ".",
static_cast< cppu::unoidl::ModuleEntity * >(
ent.get())->createCursor()));
}
break;
case cppu::unoidl::Entity::SORT_ENUM_TYPE:
tc = css::uno::TypeClass_ENUM;
break;
case cppu::unoidl::Entity::SORT_PLAIN_STRUCT_TYPE:
case cppu::unoidl::Entity::SORT_POLYMORPHIC_STRUCT_TYPE_TEMPLATE:
tc = css::uno::TypeClass_STRUCT;
break;
case cppu::unoidl::Entity::SORT_EXCEPTION_TYPE:
tc = css::uno::TypeClass_EXCEPTION;
break;
case cppu::unoidl::Entity::SORT_INTERFACE_TYPE:
tc = css::uno::TypeClass_INTERFACE;
break;
case cppu::unoidl::Entity::SORT_TYPEDEF:
tc = css::uno::TypeClass_TYPEDEF;
break;
case cppu::unoidl::Entity::SORT_CONSTANT_GROUP:
tc = css::uno::TypeClass_CONSTANTS;
if (deep_ && matches(css::uno::TypeClass_CONSTANT)) {
positions_.push(
Position(
name + ".",
static_cast< cppu::unoidl::ConstantGroupEntity * >(
ent.get())));
}
break;
case cppu::unoidl::Entity::SORT_SINGLE_INTERFACE_BASED_SERVICE:
case cppu::unoidl::Entity::SORT_ACCUMULATION_BASED_SERVICE:
tc = css::uno::TypeClass_SERVICE;
break;
case cppu::unoidl::Entity::SORT_INTERFACE_BASED_SINGLETON:
case cppu::unoidl::Entity::SORT_SERVICE_BASED_SINGLETON:
tc = css::uno::TypeClass_SINGLETON;
break;
default:
for (;;) { std::abort(); } // this cannot happen
}
if (matches(tc)) {
current_ = name;
break;
}
} else { // constant group
if (positions_.top().constantGroupIndex
== positions_.top().constantGroup->getMembers().end())
{
positions_.pop();
if (positions_.empty()) {
break;
}
continue;
}
current_ = positions_.top().prefix
+ positions_.top().constantGroupIndex++->name;
break;
}
}
}
typedef cppu::WeakComponentImplHelper2<
css::container::XHierarchicalNameAccess,
css::reflection::XTypeDescriptionEnumerationAccess >
Provider_Base;
class Provider:
private osl::Mutex, public Provider_Base, private boost::noncopyable
{
public:
Provider(
css::uno::Reference< css::uno::XComponentContext > const & context,
rtl::OUString const & uri):
Provider_Base(*static_cast< osl::Mutex * >(this)), context_(context),
provider_(new cppu::UnoidlProvider(uri))
{}
using Provider_Base::acquire;
using Provider_Base::release;
private:
virtual ~Provider() {}
virtual void SAL_CALL disposing() {} //TODO
virtual css::uno::Any SAL_CALL getByHierarchicalName(
rtl::OUString const & aName)
throw (
css::container::NoSuchElementException, css::uno::RuntimeException);
virtual sal_Bool SAL_CALL hasByHierarchicalName(
rtl::OUString const & aName) throw (css::uno::RuntimeException)
{ return provider_->find(aName) != 0; }
virtual css::uno::Reference< css::reflection::XTypeDescriptionEnumeration >
SAL_CALL createTypeDescriptionEnumeration(
rtl::OUString const & moduleName,
css::uno::Sequence< css::uno::TypeClass > const & types,
css::reflection::TypeDescriptionSearchDepth depth)
throw(
css::reflection::NoSuchTypeNameException,
css::reflection::InvalidTypeNameException,
css::uno::RuntimeException);
css::uno::Reference< css::uno::XComponentContext > context_;
rtl::Reference< cppu::UnoidlProvider > provider_;
};
css::uno::Any Provider::getByHierarchicalName(rtl::OUString const & aName)
throw (css::container::NoSuchElementException, css::uno::RuntimeException)
{
bool cnst;
sal_uInt32 off = provider_->find(aName, &cnst);
if (off == 0) {
throw css::container::NoSuchElementException(
aName, static_cast< cppu::OWeakObject * >(this));
}
if (cnst) {
return css::uno::makeAny<
css::uno::Reference< css::reflection::XTypeDescription > >(
new ConstantDescription(aName, provider_->getConstant(off)));
} else {
rtl::Reference< cppu::unoidl::Entity > ent(provider_->getEntity(off));
switch (ent->getSort()) {
case cppu::unoidl::Entity::SORT_MODULE:
return css::uno::makeAny<
css::uno::Reference< css::reflection::XTypeDescription > >(
new ModuleDescription(
context_, aName,
static_cast< cppu::unoidl::ModuleEntity * >(
ent.get())));
case cppu::unoidl::Entity::SORT_ENUM_TYPE:
return css::uno::makeAny<
css::uno::Reference< css::reflection::XTypeDescription > >(
new EnumTypeDescription(
aName,
static_cast< cppu::unoidl::EnumTypeEntity * >(
ent.get())));
case cppu::unoidl::Entity::SORT_PLAIN_STRUCT_TYPE:
return css::uno::makeAny<
css::uno::Reference< css::reflection::XTypeDescription > >(
new PlainStructTypeDescription(
context_, aName,
static_cast< cppu::unoidl::PlainStructTypeEntity * >(
ent.get())));
case cppu::unoidl::Entity::SORT_POLYMORPHIC_STRUCT_TYPE_TEMPLATE:
return css::uno::makeAny<
css::uno::Reference< css::reflection::XTypeDescription > >(
new PolymorphicStructTypeTemplateDescription(
context_, aName,
static_cast<
cppu::unoidl::PolymorphicStructTypeTemplateEntity *
>(ent.get())));
case cppu::unoidl::Entity::SORT_EXCEPTION_TYPE:
return css::uno::makeAny<
css::uno::Reference< css::reflection::XTypeDescription > >(
new ExceptionTypeDescription(
context_, aName,
static_cast< cppu::unoidl::ExceptionTypeEntity * >(
ent.get())));
case cppu::unoidl::Entity::SORT_INTERFACE_TYPE:
return css::uno::makeAny<
css::uno::Reference< css::reflection::XTypeDescription > >(
new InterfaceTypeDescription(
context_, aName,
static_cast< cppu::unoidl::InterfaceTypeEntity * >(
ent.get())));
case cppu::unoidl::Entity::SORT_TYPEDEF:
return css::uno::makeAny<
css::uno::Reference< css::reflection::XTypeDescription > >(
new TypedefDescription(
context_, aName,
static_cast< cppu::unoidl::TypedefEntity * >(
ent.get())));
case cppu::unoidl::Entity::SORT_CONSTANT_GROUP:
return css::uno::makeAny<
css::uno::Reference< css::reflection::XTypeDescription > >(
new ConstantGroupDescription(
context_, aName,
static_cast< cppu::unoidl::ConstantGroupEntity * >(
ent.get())));
case cppu::unoidl::Entity::SORT_SINGLE_INTERFACE_BASED_SERVICE:
return css::uno::makeAny<
css::uno::Reference< css::reflection::XTypeDescription > >(
new SingleInterfaceBasedServiceDescription(
context_, aName,
static_cast<
cppu::unoidl::SingleInterfaceBasedServiceEntity * >(
ent.get())));
case cppu::unoidl::Entity::SORT_ACCUMULATION_BASED_SERVICE:
return css::uno::makeAny<
css::uno::Reference< css::reflection::XTypeDescription > >(
new AccumulationBasedServiceDescription(
context_, aName,
static_cast<
cppu::unoidl::AccumulationBasedServiceEntity * >(
ent.get())));
case cppu::unoidl::Entity::SORT_INTERFACE_BASED_SINGLETON:
return css::uno::makeAny<
css::uno::Reference< css::reflection::XTypeDescription > >(
new InterfaceBasedSingletonDescription(
context_, aName,
static_cast<
cppu::unoidl::InterfaceBasedSingletonEntity * >(
ent.get())));
case cppu::unoidl::Entity::SORT_SERVICE_BASED_SINGLETON:
return css::uno::makeAny<
css::uno::Reference< css::reflection::XTypeDescription > >(
new ServiceBasedSingletonDescription(
context_, aName,
static_cast<
cppu::unoidl::ServiceBasedSingletonEntity * >(
ent.get())));
default:
for (;;) { std::abort(); } // this cannot happen
}
}
}
css::uno::Reference< css::reflection::XTypeDescriptionEnumeration >
Provider::createTypeDescriptionEnumeration(
rtl::OUString const & moduleName,
css::uno::Sequence< css::uno::TypeClass > const & types,
css::reflection::TypeDescriptionSearchDepth depth)
throw(
css::reflection::NoSuchTypeNameException,
css::reflection::InvalidTypeNameException, css::uno::RuntimeException)
{
rtl::OUString prefix;
rtl::Reference< cppu::unoidl::MapCursor > cursor;
if (moduleName.isEmpty()) {
cursor = provider_->createRootCursor();
} else {
prefix = moduleName + ".";
bool cnst;
sal_uInt32 off = provider_->find(moduleName, &cnst);
if (off == 0) {
throw css::reflection::NoSuchTypeNameException(
moduleName, static_cast< cppu::OWeakObject * >(this));
}
if (cnst) {
throw css::reflection::InvalidTypeNameException(
moduleName, static_cast< cppu::OWeakObject * >(this));
}
rtl::Reference< cppu::unoidl::Entity > ent(provider_->getEntity(off));
if (ent->getSort() != cppu::unoidl::Entity::SORT_MODULE) {
throw css::reflection::InvalidTypeNameException(
moduleName, static_cast< cppu::OWeakObject * >(this));
}
cursor = static_cast< cppu::unoidl::ModuleEntity * >(ent.get())->
createCursor();
}
return new Enumeration(
context_, prefix, cursor, types,
depth == css::reflection::TypeDescriptionSearchDepth_INFINITE);
}
css::uno::Reference< css::container::XHierarchicalNameAccess >
readLegacyRdbFile(
rtl::OUString const & uri,
css::uno::Reference< css::lang::XMultiComponentFactory > const &
serviceManager,
css::uno::Reference< css::uno::XComponentContext > const & context)
{
assert(serviceManager.is());
css::uno::Reference< css::registry::XSimpleRegistry > reg(
serviceManager->createInstanceWithContext(
"com.sun.star.comp.stoc.SimpleRegistry", context),
css::uno::UNO_QUERY_THROW);
try {
reg->open(uri, true, false);
} catch (css::registry::InvalidRegistryException & e) {
throw css::uno::DeploymentException(
"Invalid registry " + uri + ":" + e.Message,
css::uno::Reference< css::uno::XInterface >());
}
css::uno::Sequence< css::uno::Any > arg(1);
arg[0] <<= reg;
return css::uno::Reference< css::container::XHierarchicalNameAccess >(
serviceManager->createInstanceWithArgumentsAndContext(
"com.sun.star.comp.stoc.RegistryTypeDescriptionProvider", arg,
context),
css::uno::UNO_QUERY_THROW);
}
void readRdbFile(
rtl::OUString const & uri, bool optional,
css::uno::Reference< css::lang::XMultiComponentFactory > const &
serviceManager,
css::uno::Reference< css::uno::XComponentContext > const & context,
std::vector<
css::uno::Reference< css::container::XHierarchicalNameAccess > > *
providers)
{
assert(providers != 0);
css::uno::Reference< css::container::XHierarchicalNameAccess > prov;
try {
prov = new Provider(context, uri);
} catch (css::container::NoSuchElementException &) {
if (optional) {
SAL_INFO("cppuhelper", "Ignored optional " << uri);
return;
}
throw css::uno::DeploymentException(
uri + ": no such file",
css::uno::Reference< css::uno::XInterface >());
} catch (css::registry::InvalidRegistryException &) {
prov = readLegacyRdbFile(uri, serviceManager, context);
}
assert(prov.is());
providers->push_back(prov);
}
void readRdbDirectory(
rtl::OUString const & uri, bool optional,
css::uno::Reference< css::lang::XMultiComponentFactory > const &
serviceManager,
css::uno::Reference< css::uno::XComponentContext > const & context,
std::vector<
css::uno::Reference< css::container::XHierarchicalNameAccess > > *
providers)
{
osl::Directory dir(uri);
switch (dir.open()) {
case osl::FileBase::E_None:
break;
case osl::FileBase::E_NOENT:
if (optional) {
SAL_INFO("cppuhelper", "Ignored optional " << uri);
return;
}
// fall through
default:
throw css::uno::DeploymentException(
"Cannot open directory " + uri,
css::uno::Reference< css::uno::XInterface >());
}
for (;;) {
rtl::OUString fileUri;
if (!cppu::nextDirectoryItem(dir, &fileUri)) {
break;
}
readRdbFile(fileUri, optional, serviceManager, context, providers);
}
}
}
css::uno::Sequence<
css::uno::Reference< css::container::XHierarchicalNameAccess > >
cppuhelper::createTypeDescriptionProviders(
rtl::OUString const & uris,
css::uno::Reference< css::lang::XMultiComponentFactory > const &
serviceManager,
css::uno::Reference< css::uno::XComponentContext > const & context)
{
std::vector<
css::uno::Reference< css::container::XHierarchicalNameAccess > > provs;
for (sal_Int32 i = 0; i != -1;) {
rtl::OUString uri(uris.getToken(0, ' ', i));
if (uri.isEmpty()) {
continue;
}
bool optional;
bool directory;
cppu::decodeRdbUri(&uri, &optional, &directory);
if (directory) {
readRdbDirectory(uri, optional, serviceManager, context, &provs);
} else {
readRdbFile(uri, optional, serviceManager, context, &provs);
}
}
css::uno::Sequence<
css::uno::Reference< css::container::XHierarchicalNameAccess > > provs2(
static_cast< sal_Int32 >(provs.size())); //TODO: check overflow
std::vector<
css::uno::Reference<
css::container::XHierarchicalNameAccess > >::iterator i(
provs.begin());
for (sal_Int32 j = 0; j != provs2.getLength(); ++j) {
provs2[j] = *i++;
}
return provs2;
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|