summaryrefslogtreecommitdiff
path: root/framework/source/services/desktop.cxx
blob: 94a66dae76cdc7027302b353ec2f1dae0b713e96 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
/*************************************************************************
 *
 *  $RCSfile: desktop.cxx,v $
 *
 *  $Revision: 1.39 $
 *
 *  last change: $Author: as $ $Date: 2002-05-24 11:33:30 $
 *
 *  The Contents of this file are made available subject to the terms of
 *  either of the following licenses
 *
 *         - GNU Lesser General Public License Version 2.1
 *         - Sun Industry Standards Source License Version 1.1
 *
 *  Sun Microsystems Inc., October, 2000
 *
 *  GNU Lesser General Public License Version 2.1
 *  =============================================
 *  Copyright 2000 by Sun Microsystems, Inc.
 *  901 San Antonio Road, Palo Alto, CA 94303, USA
 *
 *  This library is free software; you can redistribute it and/or
 *  modify it under the terms of the GNU Lesser General Public
 *  License version 2.1, as published by the Free Software Foundation.
 *
 *  This library is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 *  Lesser General Public License for more details.
 *
 *  You should have received a copy of the GNU Lesser General Public
 *  License along with this library; if not, write to the Free Software
 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston,
 *  MA  02111-1307  USA
 *
 *
 *  Sun Industry Standards Source License Version 1.1
 *  =================================================
 *  The contents of this file are subject to the Sun Industry Standards
 *  Source License Version 1.1 (the "License"); You may not use this file
 *  except in compliance with the License. You may obtain a copy of the
 *  License at http://www.openoffice.org/license.html.
 *
 *  Software provided under this License is provided on an "AS IS" basis,
 *  WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
 *  WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
 *  MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
 *  See the License for the specific provisions governing your rights and
 *  obligations concerning the Software.
 *
 *  The Initial Developer of the Original Code is: Sun Microsystems, Inc.
 *
 *  Copyright: 2000 by Sun Microsystems, Inc.
 *
 *  All Rights Reserved.
 *
 *  Contributor(s): _______________________________________
 *
 *
 ************************************************************************/

//_________________________________________________________________________________________________________________
//  my own includes
//_________________________________________________________________________________________________________________

#ifndef __FRAMEWORK_DESKTOP_HXX_
#include <services/desktop.hxx>
#endif

#ifndef __FRAMEWORK_HELPER_OCOMPONENTACCESS_HXX_
#include <helper/ocomponentaccess.hxx>
#endif

#ifndef __FRAMEWORK_DISPATCH_DISPATCHPROVIDER_HXX_
#include <dispatch/dispatchprovider.hxx>
#endif

#ifndef __FRAMEWORK_CLASSES_TASKCREATOR_HXX_
#include <classes/taskcreator.hxx>
#endif

#ifndef __FRAMEWORK_CLASSES_ARGUMENTANALYZER_HXX_
#include <classes/argumentanalyzer.hxx>
#endif

#ifndef __FRAMEWORK_CLASSES_TARGETFINDER_HXX_
#include <classes/targetfinder.hxx>
#endif

#ifndef __FRAMEWORK_THREADHELP_TRANSACTIONGUARD_HXX_
#include <threadhelp/transactionguard.hxx>
#endif

#ifndef __FRAMEWORK_THREADHELP_WRITEGUARD_HXX_
#include <threadhelp/writeguard.hxx>
#endif

#ifndef __FRAMEWORK_THREADHELP_READGUARD_HXX_
#include <threadhelp/readguard.hxx>
#endif

#ifndef __FRAMEWORK_SERVICES_H_
#include <services.h>
#endif

#ifndef __FRAMEWORK_GENERAL_H_
#include <general.h>
#endif

#include <services/documentlist.hxx>

//_________________________________________________________________________________________________________________
//  interface includes
//_________________________________________________________________________________________________________________

#ifndef _COM_SUN_STAR_BEANS_PROPERTYATTRIBUTE_HPP_
#include <com/sun/star/beans/PropertyAttribute.hpp>
#endif

#ifndef _COM_SUN_STAR_FRAME_FRAMESEARCHFLAG_HPP_
#include <com/sun/star/frame/FrameSearchFlag.hpp>
#endif

#ifndef _COM_SUN_STAR_AWT_XTOOLKIT_HPP_
#include <com/sun/star/awt/XToolkit.hpp>
#endif

#ifndef _COM_SUN_STAR_AWT_XWINDOW_HPP_
#include <com/sun/star/awt/XWindow.hpp>
#endif

#ifndef _COM_SUN_STAR_AWT_XWINDOWPEER_HPP_
#include <com/sun/star/awt/XWindowPeer.hpp>
#endif

#ifndef _COM_SUN_STAR_AWT_WINDOWDESCRIPTOR_HPP_
#include <com/sun/star/awt/WindowDescriptor.hpp>
#endif

#ifndef _COM_SUN_STAR_AWT_WINDOWATTRIBUTE_HPP_
#include <com/sun/star/awt/WindowAttribute.hpp>
#endif

#ifndef _COM_SUN_STAR_AWT_POSSIZE_HPP_
#include <com/sun/star/awt/PosSize.hpp>
#endif

#ifndef _COM_SUN_STAR_MOZILLA_XPLUGININSTANCE_HPP_
#include <com/sun/star/mozilla/XPluginInstance.hpp>
#endif

#ifndef _COM_SUN_STAR_UTIL_XURLTRANSFORMER_HPP_
#include <com/sun/star/util/XURLTransformer.hpp>
#endif

#ifndef _COM_SUN_STAR_TASK_XINTERACTIONABORT_HPP_
#include <com/sun/star/task/XInteractionAbort.hpp>
#endif

#ifndef _COM_SUN_STAR_DOCUMENT_XINTERACTIONFILTERSELECT_HPP_
#include <com/sun/star/document/XInteractionFilterSelect.hpp>
#endif

#ifndef _COM_SUN_STAR_DOCUMENT_AMBIGOUSFILTERREQUEST_HPP_
#include <com/sun/star/document/AmbigousFilterRequest.hpp>
#endif

#ifndef _COM_SUN_STAR_UCB_INTERACTIVEIOEXCEPTION_HPP_
#include <com/sun/star/ucb/InteractiveIOException.hpp>
#endif

#ifndef _COM_SUN_STAR_UCB_INTERACTIVEAUGMENTEDIOEXCEPTION_HPP_
#include <com/sun/star/ucb/InteractiveAugmentedIOException.hpp>
#endif

#ifndef _COM_SUN_STAR_FRAME_XNOTIFYINGDISPATCH_HPP_
#include <com/sun/star/frame/XNotifyingDispatch.hpp>
#endif

#ifndef _COM_SUN_STAR_FRAME_DISPATCHRESULTSTATE_HPP_
#include <com/sun/star/frame/DispatchResultState.hpp>
#endif

#ifndef _COM_SUN_STAR_LANG_ILLEGALARGUMENTEXCEPTION_HPP_
#include <com/sun/star/lang/IllegalArgumentException.hpp>
#endif

#ifndef _COM_SUN_STAR_UTIL_XCLOSEABLE_HPP_
#include <com/sun/star/util/XCloseable.hpp>
#endif

//_________________________________________________________________________________________________________________
//  includes of other projects
//_________________________________________________________________________________________________________________

#ifndef _CPPUHELPER_QUERYINTERFACE_HXX_
#include <cppuhelper/queryinterface.hxx>
#endif

#ifndef _CPPUHELPER_TYPEPROVIDER_HXX_
#include <cppuhelper/typeprovider.hxx>
#endif

#ifndef _CPPUHELPER_FACTORY_HXX_
#include <cppuhelper/factory.hxx>
#endif

#ifndef _CPPUHELPER_PROPTYPEHLP_HXX
#include <cppuhelper/proptypehlp.hxx>
#endif

#ifndef _RTL_USTRBUF_HXX_
#include <rtl/ustrbuf.hxx>
#endif

#ifndef _RTL_LOGFILE_HXX_
#include <rtl/logfile.hxx>
#endif

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

#ifndef _COMPHELPER_EXTRACT_HXX_
#include <comphelper/extract.hxx>
#endif

//_________________________________________________________________________________________________________________
//  namespace
//_________________________________________________________________________________________________________________

namespace framework{

//_________________________________________________________________________________________________________________
//  non exported const
//_________________________________________________________________________________________________________________

// names of properties
#define PROPERTYNAME_ACTIVECOMPONENT            DECLARE_ASCII("ActiveComponent"         )
#define PROPERTYNAME_ACTIVEFRAME                DECLARE_ASCII("ActiveFrame"             )
#define PROPERTYNAME_ISPLUGGED                  DECLARE_ASCII("IsPlugged"               )
#define PROPERTYNAME_SUSPENDQUICKSTARTVETO      DECLARE_ASCII("SuspendQuickstartVeto"   )

// handle of properties
#define PROPERTYHANDLE_ACTIVECOMPONENT          1
#define PROPERTYHANDLE_ACTIVEFRAME              2
#define PROPERTYHANDLE_ISPLUGGED                3
#define PROPERTYHANDLE_SUSPENDQUICKSTARTVETO    4

// count of ALL properties
#define PROPERTYCOUNT                           4

//_________________________________________________________________________________________________________________
//  non exported definitions
//_________________________________________________________________________________________________________________

//_________________________________________________________________________________________________________________
//  declarations
//_________________________________________________________________________________________________________________

//*****************************************************************************************************************
//  XInterface, XTypeProvider, XServiceInfo
//*****************************************************************************************************************
DEFINE_XINTERFACE_13                    (   Desktop                                                  ,
                                            OWeakObject                                              ,
                                            DIRECT_INTERFACE( css::lang::XTypeProvider              ),
                                            DIRECT_INTERFACE( css::lang::XServiceInfo               ),
                                            DIRECT_INTERFACE( css::frame::XDesktop                  ),
                                            DIRECT_INTERFACE( css::frame::XComponentLoader          ),
                                            DIRECT_INTERFACE( css::frame::XTasksSupplier            ),
                                            DIRECT_INTERFACE( css::frame::XDispatchProvider         ),
                                            DIRECT_INTERFACE( css::frame::XFramesSupplier           ),
                                            DIRECT_INTERFACE( css::frame::XFrame                    ),
                                            DIRECT_INTERFACE( css::lang::XComponent                 ),
                                            DIRECT_INTERFACE( css::frame::XDispatchResultListener   ),
                                            DIRECT_INTERFACE( css::lang::XEventListener             ),
                                            DIRECT_INTERFACE( css::task::XInteractionHandler        ),
                                            DIRECT_INTERFACE( css::beans::XPropertySet              )
                                        )

DEFINE_XTYPEPROVIDER_12                 (   Desktop                                                 ,
                                            css::lang::XTypeProvider                                ,
                                            css::lang::XServiceInfo                                 ,
                                            css::frame::XDesktop                                    ,
                                            css::frame::XComponentLoader                            ,
                                            css::frame::XTasksSupplier                              ,
                                            css::frame::XDispatchProvider                           ,
                                            css::frame::XFramesSupplier                             ,
                                            css::frame::XFrame                                      ,
                                            css::lang::XComponent                                   ,
                                            css::frame::XDispatchResultListener                     ,
                                            css::lang::XEventListener                               ,
                                            css::task::XInteractionHandler
                                        )

DEFINE_XSERVICEINFO_ONEINSTANCESERVICE  (   Desktop                                                 ,
                                            ::cppu::OWeakObject                                     ,
                                            SERVICENAME_DESKTOP                                     ,
                                            IMPLEMENTATIONNAME_DESKTOP
                                        )

DEFINE_INIT_SERVICE                     (   Desktop,
                                            {
                                                /*Attention
                                                    I think we don't need any mutex or lock here ... because we are called by our own static method impl_createInstance()
                                                    to create a new instance of this class by our own supported service factory.
                                                    see macro DEFINE_XSERVICEINFO_MULTISERVICE and "impl_initService()" for further informations!
                                                */

                                                //-------------------------------------------------------------------------------------------------------------
                                                // Initialize a new XFrames-helper-object to handle XIndexAccess and XElementAccess.
                                                // We hold member as reference ... not as pointer too!
                                                // Attention: We share our frame container with this helper. Container is threadsafe himself ... So I think we can do that.
                                                // But look on dispose() for right order of deinitialization.
                                                OFrames* pFramesHelper = new OFrames( m_xFactory, this, &m_aChildTaskContainer );
                                                m_xFramesHelper = css::uno::Reference< css::frame::XFrames >( static_cast< ::cppu::OWeakObject* >(pFramesHelper), css::uno::UNO_QUERY );

                                                //-------------------------------------------------------------------------------------------------------------
                                                // Initialize a new dispatchhelper-object to handle dispatches.
                                                DispatchProvider* pDispatchHelper = new DispatchProvider( m_xFactory, this );
                                                m_xDispatchHelper = css::uno::Reference< css::frame::XDispatchProvider >( static_cast< ::cppu::OWeakObject* >(pDispatchHelper), css::uno::UNO_QUERY );

                                                //-------------------------------------------------------------------------------------------------------------
                                                // I'am the desktop - and use my frame container in a special mode.
                                                // If last child task is removed, I must die!
                                                // My container should terminate me asynchronous by using a timer.
                                                // Enable timer at container.
                                                // (The timer will be initialized with right timeout value automaticly by himself. see class AsyncQuit for further informations!)
                                                m_aChildTaskContainer.enableQuitTimer( this );

                                                // Safe impossible cases
                                                // We can't work without this helper!
                                                LOG_ASSERT2( m_xFramesHelper.is  ()==sal_False, "Desktop::Desktop()", "Frames helper is not valid. XFrames, XIndexAccess and XElementAcces are not supported!\n")
                                                LOG_ASSERT2( m_xDispatchHelper.is()==sal_False, "Desktop::Desktop()", "Dispatch helper is not valid. XDispatch will not work correctly!\n"                      )

                                                // Enable object for real working!
                                                // Otherwise all calls will be rejected ...
                                                m_aTransactionManager.setWorkingMode( E_WORK );
                                            }
                                        )

/*-************************************************************************************************************//**
    @short      standard constructor to create instance by factory
    @descr      This constructor initialize a new instance of this class by valid factory,
                and will be set valid values on his member and baseclasses.

    @attention  a)  Don't use your own reference during an UNO-Service-ctor! There is no guarantee, that you
                    will get over this. (e.g. using of your reference as parameter to initialize some member)
                    Do such things in DEFINE_INIT_SERVICE() method, which is called automaticly after your ctor!!!
                b)  Baseclass OBroadcastHelper is a typedef in namespace cppu!
                    The microsoft compiler has some problems to handle it right BY using namespace explicitly ::cppu::OBroadcastHelper.
                    If we write it without a namespace or expand the typedef to OBrodcastHelperVar<...> -> it will be OK!?
                    I don't know why! (other compiler not tested .. but it works!)

    @seealso    method DEFINE_INIT_SERVICE()

    @param      "xFactory" is the multi service manager, which create this instance.
                The value must be different from NULL!
    @return     -

    @onerror    We throw an ASSERT in debug version or do nothing in relaese version.
*//*-*************************************************************************************************************/
Desktop::Desktop( const css::uno::Reference< css::lang::XMultiServiceFactory >& xFactory )
        //  Init baseclasses first
        //  Attention: Don't change order of initialization!
        //      ThreadHelpBase is a struct with a lock as member. We can't use a lock as direct member!
        //      We must garant right initialization and a valid value of this to initialize other baseclasses!
        :   ThreadHelpBase          ( &Application::GetSolarMutex()                 )
        ,   TransactionBase         (                                               )
        ,   ::cppu::OBroadcastHelperVar< ::cppu::OMultiTypeInterfaceContainerHelper, ::cppu::OMultiTypeInterfaceContainerHelper::keyType >           ( m_aLock.getShareableOslMutex()         )
        ,   ::cppu::OPropertySetHelper  ( *(static_cast< ::cppu::OBroadcastHelper* >(this)) )
        ,   ::cppu::OWeakObject     (                                               )
        // Init member
        ,   m_xFactory              ( xFactory                                      )
        ,   m_aChildTaskContainer   (                                               )
        ,   m_aListenerContainer    ( m_aLock.getShareableOslMutex()                )
        ,   m_eLoadState            ( E_NOTSET                                      )
        ,   m_aInteractionRequest   (                                               )
        ,   m_bSuspendQuickstartVeto( sal_False                                     )
        #ifdef ENABLE_ASSERTIONS
        ,   m_bIsTerminated         ( sal_False                                     )   // see dispose() for further informations!
        #endif
{
    // Safe impossible cases
    // We don't accept all incoming parameter.
    LOG_ASSERT2( implcp_ctor( xFactory ), "Desktop::Desktop()", "Invalid parameter detected!")
}

/*-************************************************************************************************************//**
    @short      standard destructor
    @descr      This one do NOTHING! Use dispose() instaed of this.

    @seealso    method dispose()

    @param      -
    @return     -

    @onerror    -
*//*-*************************************************************************************************************/
Desktop::~Desktop()
{
    LOG_ASSERT2( m_bIsTerminated                       ==sal_False, "Desktop::~Desktop()", "Who forgot to terminate the desktop service?" )
    LOG_ASSERT2( m_aTransactionManager.getWorkingMode()!=E_CLOSE  , "Desktop::~Desktop()", "Who forgot to dispose this service?"          )
}

/*-************************************************************************************************************//**
    @interface  XDesktop
    @short      ask desktop before terminate it
    @descr      The desktop ask his components and if all say "yes" it will destroy this components
                and return "yes" to caller of this method. Otherwhise, desktop will not be destroied!
                But a TerminateListener with a veto - will be the new owner of this service and MUST
                call terminate again, if he stop using of it!

    @seealso    interface XTerminateListener

    @param      -
    @return     sal_True  ,if all components say "yes" for terminate
                sal_False ,otherwise

    @onerror    We return sal_False.
    @threadsafe yes
*//*-*************************************************************************************************************/
sal_Bool SAL_CALL Desktop::terminate() throw( css::uno::RuntimeException )
{
    /* UNSAFE AREA --------------------------------------------------------------------------------------------- */
    // Register transaction and reject wrong calls.
    TransactionGuard aTransaction( m_aTransactionManager, E_HARDEXCEPTIONS );

    /* SAFE AREA ----------------------------------------------------------------------------------------------- */
    ReadGuard aReadLock( m_aLock );
    // Attention, Our timer hold a reference to use ... and sometimes (e.g. for headless office mode)
    // he forget this one insteandly during his own instantiation! So we can die during next call.
    // That's why it's agood idea to hold use self alive.
    css::uno::Reference< css::frame::XDesktop > xThis( static_cast< ::cppu::OWeakObject* >(this), css::uno::UNO_QUERY );
    // Get other neccessary references.
    css::uno::Reference< css::frame::XTerminateListener > xPipeTerminator    = m_xPipeTerminator                          ;
    css::uno::Reference< css::frame::XTerminateListener > xQuickLauncher     = m_xQuickLauncher                           ;
    css::lang::EventObject                                aEvent             ( static_cast< ::cppu::OWeakObject* >(this) );
    sal_Bool                                              bAskQuickStart     = !m_bSuspendQuickstartVeto                  ;
    aReadLock.unlock();
    /* UNSAFE AREA --------------------------------------------------------------------------------------------- */

    // Set default. If a veto occure - break operation and
    // return "not terminated". Otherwise termination was successfully.
    sal_Bool bNormalListenerVeto = sal_False;
    sal_Bool bQuickLaunchVeto    = sal_False;
    sal_Bool bPipeVeto           = sal_False;
    sal_Bool bTaskVeto           = sal_False;

    //-------------------------------------------------------------------------------------------------------------
    // Disable our async quit timer ... we terminate ourself!
    // But if termination fail ... don't forget to enable it again!
    // Member is threadsafe himself!
    m_aChildTaskContainer.disableQuitTimer();

    //-------------------------------------------------------------------------------------------------------------
    // Ask normal terminate listener. They could stop complete terminate AND closing of currently open documents!
    try
    {
        impl_sendQueryTerminationEvent();
    }
    catch( css::frame::TerminationVetoException& )
    {
        bNormalListenerVeto = sal_True;
    }

    //-------------------------------------------------------------------------------------------------------------
    // If no veto comes we should ask our quicklauncher.
    // He stop termination of whole office .. but not closing of open tasks!!!
    // We shouldn't ask quicklauncher if property "SuspendQuickstartVeto" is set to FALSE!!
    if(
        ( bNormalListenerVeto == sal_False  )   &&
        ( bAskQuickStart      == sal_True   )   &&
        ( xQuickLauncher.is() == sal_True   )
      )
    {
        try
        {
            xQuickLauncher->queryTermination( aEvent );
        }
        catch( css::frame::TerminationVetoException& )
        {
            bQuickLaunchVeto = sal_True;
        }
    }

    //-------------------------------------------------------------------------------------------------------------
    // If no veto comes from quick launcher ... we should ask our pipe terminator too.
    // He close pipe if no external requests are pending.
    // Otherwise he throw the veto exception and we don't terminate AND don't close open tasks!
    // Attention: If quick launcher exist - ask him before pipe terminator. Otherwise pipe will be closed
    // quick launcher stop real termination ... but pipe will not reopened! So no further external requests
    // could come in!!!
    if(
        ( bNormalListenerVeto  == sal_False )    &&
        ( bQuickLaunchVeto     == sal_False )    &&
        ( xPipeTerminator.is() == sal_True  )
      )
    {
        try
        {
            xPipeTerminator->queryTermination( aEvent );
        }
        catch( css::frame::TerminationVetoException& )
        {
            bPipeVeto = sal_True;
        }
    }

    //-------------------------------------------------------------------------------------------------------------
    // Close tasks only, if no veto exist ... but if veto comes from our quick launcher ...
    // DO IT! He stop termination - not closing tasks. => It doesn't matter, if bQuickLaunchVeto is true or false.
    // We close tasks for both cases!
    if(
        ( bNormalListenerVeto == sal_False )    &&
        ( bPipeVeto           == sal_False )
      )
    {
        ModifiedDocumentsWindow::Remove();

        // Step over all child tasks and ask they "WOULD YOU DIE?"
        css::uno::Sequence< css::uno::Reference< css::frame::XFrame > > lTasks = m_aChildTaskContainer.getAllElements();
        sal_Int32                                                       nCount = lTasks.getLength()                    ;
        for( sal_Int32 nPosition=0; nPosition<nCount; ++nPosition )
        {
            // Get an element from container and cast it to task.
            css::uno::Reference< css::util::XCloseable > xTask( lTasks[nPosition], css::uno::UNO_QUERY );
            // Ask task for terminating. If anyone say "NO" ...
            // ... we must reset our default return value to "NO" too!
            try
            {
                // Don't deliver ownershipt of this task to any other one! => means call close(sal_False).
                xTask->close(sal_False);
                // Don't remove the task from our child container!
                // A task do it by herself inside close ...
            }
            catch( css::util::CloseVetoException& )
            {
                // Any internal process of this task disagree with our request.
                // Safe this state and break this loop. Following task willn't be asked!
                bTaskVeto = sal_True;
                break;
            }
            catch( css::lang::DisposedException& )
            {
                // Task already closed by another thread or user ...
                // It doesn't matter! Because dead is dead is dead ...!
                // Do nothing and try to close next one.
                // But may it's agood idea to release this task from our container
                m_aChildTaskContainer.remove( lTasks[nPosition] );
            }
        }
    }

    //-------------------------------------------------------------------------------------------------------------
    // All listener has no problem with our termination!
    // Send NotifyTermination event to all and return with true.
    sal_Bool bTerminated =  (
                                ( bNormalListenerVeto == sal_False )    &&
                                ( bQuickLaunchVeto    == sal_False )    &&
                                ( bPipeVeto           == sal_False )    &&
                                ( bTaskVeto           == sal_False )
                            );
    #ifdef ENABLE_ASSERTIONS
        // "Protect" us against dispose before terminate calls!
        // see dispose() for further informations.
        // Follow notify will start shutdown of office and somewhere call dispose() at us ...
        // Set debug variable BEFORE notify!
        /* SAFE AREA --------------------------------------------------------------------------------------- */
        WriteGuard aWriteLock( m_aLock );
        m_bIsTerminated = bTerminated;
        aWriteLock.unlock();
        /* UNSAFE AREA ------------------------------------------------------------------------------------- */
    #endif
    if( bTerminated == sal_True )
    {
        // Send event to normal listener ...
        impl_sendNotifyTerminationEvent();
        // ... but don't forget to send it to our special terminat listener too!
        if( xPipeTerminator.is() == sal_True )
        {
            xPipeTerminator->notifyTermination( aEvent );
        }
        if( xQuickLauncher.is() == sal_True )
        {
            xQuickLauncher->notifyTermination( aEvent );
        }
    }
    // If somewhere break this terminate operation and we must return FALSE ...
    // we must reactivate our quit timer!
    // Otherwise we live for ever.
    else
    {
        m_aChildTaskContainer.enableQuitTimer( xThis );
    }

    // Return result of this question.
    return bTerminated;
}

/*-************************************************************************************************************//**
    @interface  XDesktop
    @short      add/remove a listener for terminate events
    @descr      You can add a listener, if you wish to get an event, if desktop will be terminate.
                Then it's possible to say "NO" by using a TerminateVetoException!

    @attention  a)  We know a special terminate listener - the pipe terminator. He is called as last of all terminate
                    listeners. If no request stands in our office pipe - he has no veto. Otherwise
                    he close the pipe and external requests are rejected.
                b)  Another special listener is our quick launcher. He throw a veto exception, if tray-icon
                    is still active. But he doesn't block closing of tasks! So we must call him after closing of these ones!
                c)  May be we dispose our listener during our own dispose methode ... after closing object for
                    real working. They call us back to remove her interfaces from our listener container.
                    So we should allow that by using E_SOFTEXCEPTIONS and suppress rejection of this calls!

    @seealso    method terminate()

    @param      "xListener" is a reference to the listener. His value must be valid!
    @return     -

    @onerror    We do nothing.
    @threadsafe yes
*//*-*************************************************************************************************************/
void SAL_CALL Desktop::addTerminateListener( const css::uno::Reference< css::frame::XTerminateListener >& xListener ) throw( css::uno::RuntimeException )
{
    /* UNSAFE AREA --------------------------------------------------------------------------------------------- */
    // Safe impossible cases
    // Method not defined for all incoming parameter.
    LOG_ASSERT2( implcp_addTerminateListener( xListener ), "Desktop::addTerminateListener()", "Invalid parameter detected!" )
    // Register transaction and reject wrong calls.
    TransactionGuard aTransaction( m_aTransactionManager, E_HARDEXCEPTIONS );

    sal_Bool                                       bSpecialListener = sal_False                       ;
    css::uno::Reference< css::lang::XServiceInfo > xInfo            ( xListener, css::uno::UNO_QUERY );
    if( xInfo.is() == sal_True )
    {
        ::rtl::OUString sImplementationName = xInfo->getImplementationName();
        /* SAFE AREA ------------------------------------------------------------------------------------------- */
        WriteGuard aWriteLock( m_aLock );
        if( sImplementationName == IMPLEMENTATIONNAME_PIPETERMINATOR )
        {
            m_xPipeTerminator = xListener;
            bSpecialListener  = sal_True ;
        }
        else
        if( sImplementationName == IMPLEMENTATIONNAME_QUICKLAUNCHER )
        {
            m_xQuickLauncher = xListener;
            bSpecialListener = sal_True ;
        }
        aWriteLock.unlock();
        /* UNSAFE AREA ----------------------------------------------------------------------------------------- */
    }

    if( bSpecialListener == sal_False )
    {
        m_aListenerContainer.addInterface( ::getCppuType( ( const css::uno::Reference< css::frame::XTerminateListener >*) NULL ), xListener );
    }
}

//*****************************************************************************************************************
void SAL_CALL Desktop::removeTerminateListener( const css::uno::Reference< css::frame::XTerminateListener >& xListener ) throw( css::uno::RuntimeException )
{
    /* UNSAFE AREA --------------------------------------------------------------------------------------------- */
    // Safe impossible cases
    // Method not defined for all incoming parameter.
    LOG_ASSERT2( implcp_removeTerminateListener( xListener ), "Desktop::removeTerminateListener()", "Invalid parameter detected!" )
    // Register transaction and reject wrong calls.
    TransactionGuard aTransaction( m_aTransactionManager, E_SOFTEXCEPTIONS );

    sal_Bool                                       bSpecialListener = sal_False                       ;
    css::uno::Reference< css::lang::XServiceInfo > xInfo            ( xListener, css::uno::UNO_QUERY );
    if( xInfo.is() == sal_True )
    {
        ::rtl::OUString sImplementationName = xInfo->getImplementationName();
        /* SAFE AREA ------------------------------------------------------------------------------------------- */
        WriteGuard aWriteLock( m_aLock );
        if( sImplementationName == IMPLEMENTATIONNAME_PIPETERMINATOR )
        {
            m_xPipeTerminator = css::uno::Reference< css::frame::XTerminateListener >();
            bSpecialListener  = sal_True;
        }
        else
        if( sImplementationName == IMPLEMENTATIONNAME_QUICKLAUNCHER )
        {
            m_xQuickLauncher = css::uno::Reference< css::frame::XTerminateListener >();
            bSpecialListener = sal_True;
        }
        aWriteLock.unlock();
        /* UNSAFE AREA ----------------------------------------------------------------------------------------- */
    }

    if( bSpecialListener == sal_False )
    {
        m_aListenerContainer.removeInterface( ::getCppuType( ( const css::uno::Reference< css::frame::XTerminateListener >*) NULL ), xListener );
    }
}

/*-************************************************************************************************************//**
    @interface  XDesktop
    @short      get access to create enumerations of all current components
    @descr      You will be the owner of the returned object and must delete it if you don't use it again.

    @seealso    class TasksAccess
    @seealso    class TasksEnumeration

    @param      -
    @return     A reference to an XEnumerationAccess-object.

    @onerror    We return a null-reference.
    @threadsafe yes
*//*-*************************************************************************************************************/
css::uno::Reference< css::container::XEnumerationAccess > SAL_CALL Desktop::getComponents() throw( css::uno::RuntimeException )
{
    /* UNSAFE AREA --------------------------------------------------------------------------------------------- */
    // Register transaction and reject wrong calls.
    TransactionGuard aTransaction( m_aTransactionManager, E_HARDEXCEPTIONS );

    // We use a helper class OComponentAccess to have access on all child components.
    // Create it on demand and return it as a reference.
    OComponentAccess* pAccess = new OComponentAccess( this );
    css::uno::Reference< css::container::XEnumerationAccess > xAccess( static_cast< ::cppu::OWeakObject* >(pAccess), css::uno::UNO_QUERY );
    return xAccess;
}

/*-************************************************************************************************************//**
    @interface  XDesktop
    @short      return the current active component
    @descr      The most current component is the window, model or the controller of the current active frame.

    @seealso    method getCurrentFrame()
    @seealso    method impl_getFrameComponent()

    @param      -
    @return     A reference to the component.

    @onerror    We return a null-reference.
    @threadsafe yes
*//*-*************************************************************************************************************/
css::uno::Reference< css::lang::XComponent > SAL_CALL Desktop::getCurrentComponent() throw( css::uno::RuntimeException )
{
    /* UNSAFE AREA --------------------------------------------------------------------------------------------- */
    // Register transaction and reject wrong calls.
    TransactionGuard aTransaction( m_aTransactionManager, E_HARDEXCEPTIONS );

    // Set return value if method failed.
    css::uno::Reference< css::lang::XComponent > xComponent;

    // Get reference to current frame ...
    // ... get component of this frame ... (It can be the window, the model or the controller.)
    // ... and return the result.
    css::uno::Reference< css::frame::XFrame > xCurrentFrame = getCurrentFrame();
    if( xCurrentFrame.is() == sal_True )
    {
        xComponent = impl_getFrameComponent( xCurrentFrame );
    }
    return xComponent;
}

/*-************************************************************************************************************//**
    @interface  XDesktop
    @short      return the current active frame in hierarchy
    @descr      There can be more then one different active pathes in our frame hierarchy. But only one of them
                could be the most active frame (normal he has the focus).
                Don't mix it with getActiveFrame()! That will return our current active frame, which must be
                a direct child of us and should be a part(!) of an active path.

    @seealso    method getActiveFrame()

    @param      -
    @return     A valid reference, if there is an active frame.
                A null reference , otherwise.

    @onerror    We return a null reference.
    @threadsafe yes
*//*-*************************************************************************************************************/
css::uno::Reference< css::frame::XFrame > SAL_CALL Desktop::getCurrentFrame() throw( css::uno::RuntimeException )
{
    /* UNSAFE AREA --------------------------------------------------------------------------------------------- */
    // Register transaction and reject wrong calls.
    TransactionGuard aTransaction( m_aTransactionManager, E_HARDEXCEPTIONS );

    // Start search with ouer direct active frame (if it exist!).
    // Search on his children for other active frames too.
    // Stop if no one could be found and return last of found ones.
    css::uno::Reference< css::frame::XFramesSupplier > xLast = css::uno::Reference< css::frame::XFramesSupplier >( getActiveFrame(), css::uno::UNO_QUERY );
    if( xLast.is() == sal_True )
    {
        css::uno::Reference< css::frame::XFramesSupplier > xNext = css::uno::Reference< css::frame::XFramesSupplier >( xLast->getActiveFrame(), css::uno::UNO_QUERY );
        while( xNext.is() == sal_True )
        {
            xLast = xNext;
            xNext = css::uno::Reference< css::frame::XFramesSupplier >( xNext->getActiveFrame(), css::uno::UNO_QUERY );
        }
    }
    return css::uno::Reference< css::frame::XFrame >( xLast, css::uno::UNO_QUERY );
}

/*-************************************************************************************************************//**
    @interface  XComponentLoader
    @short      try to load given URL into a task
    @descr      You can give us some informations about the content, which you will load into a frame.
                We search or create this target for you, make a type detection of given URL and try to load it.
                As result of this operation we return the new created component or nothing, if loading failed.

    @seealso    -

    @param      "sURL"              , URL, which represant the content
    @param      "sTargetFrameName"  , name of target frame or special value like "_self", "_blank" ...
    @param      "nSearchFlags"      , optional arguments for frame search, if target isn't a special one
    @param      "lArguments"        , optional arguments for loading
    @return     A valid component reference, if loading was successfully.
                A null reference otherwise.

    @onerror    We return a null reference.
    @threadsafe yes
*//*-*************************************************************************************************************/
css::uno::Reference< css::lang::XComponent > SAL_CALL Desktop::loadComponentFromURL( const ::rtl::OUString&                                 sURL            ,
                                                                                     const ::rtl::OUString&                                 sTargetFrameName,
                                                                                           sal_Int32                                        nSearchFlags    ,
                                                                                     const css::uno::Sequence< css::beans::PropertyValue >& lArguments      ) throw(    css::io::IOException                ,
                                                                                                                                                                        css::lang::IllegalArgumentException ,
                                                                                                                                                                        css::uno::RuntimeException          )
{
    /* UNSAFE AREA --------------------------------------------------------------------------------------------- */
    // Register transaction and reject wrong calls.
    TransactionGuard aTransaction( m_aTransactionManager, E_HARDEXCEPTIONS );

    RTL_LOGFILE_CONTEXT( aLog, "framework (as96863) ::Desktop::loadComponentFromURL" );

    // CHeck incoming parameter and throw an exception for wrong values!
    if(
        ( &sURL                              == NULL ) ||
        ( sURL.getLength()                   <  1    ) ||
        ( sURL.compareToAscii( ".uno"  , 4 ) == 0    ) ||
        ( sURL.compareToAscii( "slot:" , 5 ) == 0    )
      )
    {
        throw css::lang::IllegalArgumentException( DECLARE_ASCII("Null pointer, empty AND not loadable URL's are not allowed!"), static_cast< ::cppu::OWeakObject* >(this), 1 );
    }
    // Attention: An empty target name is equal to "_self"!
    if(
        ( &sTargetFrameName                               == NULL )   ||
        ( sTargetFrameName.getLength()                    <  1    )   ||
        (
            // is it a special target && ( not _blank || _default ) ...
            // These two ones are supported only!
            ( sTargetFrameName.indexOf( (sal_Unicode)'_' ) == 0                     )    &&
            ( sTargetFrameName                             != SPECIALTARGET_BLANK   )    &&
            ( sTargetFrameName                             != SPECIALTARGET_DEFAULT )
        )
      )
    {
        throw css::lang::IllegalArgumentException( DECLARE_ASCII("Unsupported target name found!"), static_cast< ::cppu::OWeakObject* >(this), 2 );
    }
    /* TODO: How can I test the search flags?! */
    // Attention: Arguments are optional!
    if( &lArguments == NULL )
    {
        throw css::lang::IllegalArgumentException( DECLARE_ASCII("Null pointer are not allowed!"), static_cast< ::cppu::OWeakObject* >(this), 4 );
    }

    // Set default return value, if method failed.
    css::uno::Reference< css::lang::XComponent > xComponent;

    // Attention: URL must be parsed full. Otherwise some detections on it will fail!
    // It doesnt matter, if parser isn't available. Because; We try loading of URL then ...
    css::util::URL aURL;
    aURL.Complete = sURL;

    /* SAFE AREA ----------------------------------------------------------------------------------------------- */
    WriteGuard aWriteLock( m_aLock );
    css::uno::Reference< css::util::XURLTransformer > xParser( m_xFactory->createInstance( SERVICENAME_URLTRANSFORMER ), css::uno::UNO_QUERY );
    aWriteLock.unlock();
    /* UNSAFE AREA --------------------------------------------------------------------------------------------- */
    if( xParser.is() == sal_True )
    {
        xParser->parseStrict( aURL );
    }

    css::uno::Reference< css::frame::XDispatch > xDispatcher;
    css::uno::Reference< css::frame::XDispatchProvider > xSysTask;
    sal_Bool bPlugin = impl_checkPlugInState();
    // webtop mode
    if( bPlugin )
    {
        // "_default" isn't allowed for webtop
        // force using of "_blank"
        ::rtl::OUString sTarget = sTargetFrameName;
        if(sTarget==SPECIALTARGET_DEFAULT)
            sTarget=SPECIALTARGET_BLANK;

        // We can't guarantee synchronous functionality inside the webtop environment.
        // We create a system task every time!
        xSysTask = css::uno::Reference< css::frame::XDispatchProvider >( findFrame(sTarget,nSearchFlags), css::uno::UNO_QUERY );
        if(xSysTask.is())
            xDispatcher= xSysTask->queryDispatch(aURL,SPECIALTARGET_SELF,0);
    }
    // FATOffice
    else
        xDispatcher = queryDispatch(aURL,sTargetFrameName,nSearchFlags);

    if( xDispatcher.is() == sal_True )
    {
        // ... dispatch URL at this dispatcher.
        // Set us as listener for status events from this dispatcher.

        // We should set us as interaction handler for possible exceptions during load proccess ...
        // But we shouldn't do that - if anyone already is set!
        // Our interaction handler is called back in method "handle()". We set right condition there
        // to break following loop and throw detected exception from here again!
        css::uno::Sequence< css::beans::PropertyValue > lOwnArguments( lArguments    );
        ArgumentAnalyzer                                aAnalyzer    ( lOwnArguments );
        if( aAnalyzer.existArgument( E_INTERACTIONHANDLER ) == sal_False )
        {
            aAnalyzer.setArgument( E_INTERACTIONHANDLER, static_cast< css::task::XInteractionHandler* >(this) );
        }

        // Reset loader state to default, because we must yield for a valid result! See next WHILE condition.
        // And we must do it before we call dispatch!
        /* SAFE AREA ------------------------------------------------------------------------------------------- */
        aWriteLock.lock();
        m_eLoadState = E_NOTSET;
        aWriteLock.unlock();
        /* UNSAFE AREA ----------------------------------------------------------------------------------------- */

        css::uno::Reference< css::frame::XNotifyingDispatch > xNotifyer( xDispatcher, css::uno::UNO_QUERY );
        if ( xNotifyer.is() )
            xNotifyer->dispatchWithNotification( aURL, lOwnArguments, this );
        else
        {
            // We can't work without any notification!
            // Don't forget to dispose possible new created system task.
            // But do it for "_blank" created ones inside a webtop environment only. Otherwise we can't be shure
            // that variable xSysTask doesn't mean any found task for other target names or flags!!!
            // Case of "blubber" and CREATE flag can be detected here right and will produce ZOMBIE tasks
            // ... but nothing is perfect here ... it's a hack currently and shouldn't occure in current
            // implementation.
            LOG_WARNING("Desktop::loadComponentFromURL()", "Missing interface XNotifyingDispatch. Return NULL!")
            css::uno::Reference< css::util::XCloseable > xClosable( xSysTask, css::uno::UNO_QUERY );
            if(
                    bPlugin &&
                    xClosable.is() &&
                    (
                        sTargetFrameName==SPECIALTARGET_BLANK ||
                        sTargetFrameName==SPECIALTARGET_DEFAULT
                    )
              )
            {
                try
                {
                    xClosable->close(sal_True);
                }
                catch( css::util::CloseVetoException& )
                {
                }
            }
            return xComponent;
        }

        // ... we must wait for asynchron result of this dispatch()-operation!
        // Attention: Don't use lock here ... dispatcher call us back!
        while( m_eLoadState == E_NOTSET )
        {
            Application::Yield();
        }

        // Which reaction was detected ... interaction request or loading state?
        // Test it ...

        // But - first make snapshot of our asynchron status informations by using a lock.
        /* SAFE AREA ------------------------------------------------------------------------------------------- */
        ReadGuard aReadLock( m_aLock );
        ELoadState                                eState                = m_eLoadState;
                                                  m_eLoadState          = E_NOTSET;

        css::uno::Reference< css::frame::XFrame > xLoadTarget           = m_xLastFrame;
                                                  m_xLastFrame          = css::uno::Reference< css::frame::XFrame >(); // Don't hold last frame for ever - or he can't die!

        css::uno::Any                             aRequest              = m_aInteractionRequest;
                                                  m_aInteractionRequest = css::uno::Any();
        aReadLock.unlock();
        /* UNSAFE AREA ----------------------------------------------------------------------------------------- */

        switch( eState )
        {
            //case E_FAILED     :   ... nothing to do here ... we must return our default ... NULL!
            case E_SUCCESSFUL   :   {
                                        // Try to get new current component.
                                        if( xLoadTarget.is() == sal_True )
                                        {
                                            xComponent = impl_getFrameComponent( xLoadTarget );
                                        }
                                    }
                                    break;
            case E_INTERACTION  :   {
                                        // Interaction indicates throwed exception during load proccess.
                                        // Forward io exceptions to user ...
                                        css::ucb::InteractiveIOException           exIOInteractive ;
                                        css::ucb::InteractiveAugmentedIOException  exIOAugmented   ;

                                        if( m_aInteractionRequest >>= exIOInteractive )
                                            throw css::io::IOException( exIOInteractive.Message, static_cast< ::cppu::OWeakObject* >(this) );
                                        else
                                        if( m_aInteractionRequest >>= exIOAugmented )
                                            throw css::io::IOException( exIOAugmented.Message, static_cast< ::cppu::OWeakObject* >(this) );

                                        // ... but unknown exceptions shouldnt be forwarded. Use default return value of NULL to
                                        // tell user failed state of load operation!
                                    }
                                    break;
        }
    }
    // Return result of this operation.
    return xComponent;
}

/*-************************************************************************************************************//**
    @interface  XTasksSupplier
    @short      get access to create enumerations of ouer taskchilds
    @descr      Direct childs of desktop are tasks everytime (could be PlugInFrames too).
                Call these method to could create enumerations of it.

But; Don't forget - you will be the owner of returned object and must release it!
                We use a helper class to implement the access interface. They hold a weakreference to us.
                It can be, that the desktop is dead - but not your tasksaccess-object! Then they will do nothing!
                You can't create enumerations then.

    @attention  Normaly we don't need any lock here. We don't work on internal member!

    @seealso    class TasksAccess

    @param      -
    @return     A reference to an accessobject, which can create enumerations of ouer childtasks.

    @onerror    A null reference is returned.
    @threadsafe yes
*//*-*************************************************************************************************************/
css::uno::Reference< css::container::XEnumerationAccess > SAL_CALL Desktop::getTasks() throw( css::uno::RuntimeException )
{
    LOG_WARNING("Desktop::getTasks()", "Use of obsolete interface XTaskSupplier")
    return NULL;
    /*
    TransactionGuard aTransaction( m_aTransactionManager, E_HARDEXCEPTIONS );

    OTasksAccess* pTasksAccess = new OTasksAccess( this, &m_aChildTaskContainer );
    css::uno::Reference< css::container::XEnumerationAccess > xAccess( static_cast< ::cppu::OWeakObject* >(pTasksAccess), css::uno::UNO_QUERY );
    return xAccess;
    */
}

/*-************************************************************************************************************//**
    @interface  XTasksSupplier
    @short      return current active task of ouer direct childs
    @descr      Desktop childs are tasks only (could be PlugInFrames too)! If we have an active path from desktop
                as top to any frame on bottom, we must have an active direct child. His reference is returned here.

    @attention  a)  Do not confuse it with getCurrentFrame()! The current frame don't must one of ouer direct childs.
                    It can be every frame in subtree and must have the focus (Is the last one of an active path!).
                b)  We don't need any lock here. Our container is threadsafe himself and live, if we live!

    @seealso    method getCurrentFrame()

    @param      -
    @return     A reference to ouer current active taskchild.

    @onerror    A null reference is returned.
    @threadsafe yes
*//*-*************************************************************************************************************/
css::uno::Reference< css::frame::XTask > SAL_CALL Desktop::getActiveTask() throw( css::uno::RuntimeException )
{
    /*
    TransactionGuard aTransaction( m_aTransactionManager, E_HARDEXCEPTIONS );

    return css::uno::Reference< css::frame::XTask >( m_aChildTaskContainer.getActive(), css::uno::UNO_QUERY );
    */
    LOG_WARNING("Desktop::getActiveTask()", "Use of obsolete interface XTaskSupplier")
    return NULL;
}

/*-************************************************************************************************************//**
    @interface  XDispatchProvider
    @short      search a dispatcher for given URL
    @descr      We use a helper implementation (class DispatchProvider) to do so.
                So we don't must implement this algorithm twice!

    @attention  We don't need any lock here. Our helper is threadsafe himself and live, if we live!

    @seealso    class DispatchProvider

    @param      "aURL"              , URL to dispatch
    @param      "sTargetFrameName"  , name of target frame, who should dispatch these URL
    @param      "nSearchFlags"      , flags to regulate the search
    @param      "lQueries"          , list of queryDispatch() calls!
    @return     A reference or list of founded dispatch objects for these URL.

    @onerror    A null reference is returned.
    @threadsafe yes
*//*-*************************************************************************************************************/
css::uno::Reference< css::frame::XDispatch > SAL_CALL Desktop::queryDispatch( const css::util::URL&  aURL             ,
                                                                              const ::rtl::OUString& sTargetFrameName ,
                                                                                    sal_Int32        nSearchFlags     ) throw( css::uno::RuntimeException )
{
    const char UNO_PROTOCOL[] = ".uno:";

    /* UNSAFE AREA --------------------------------------------------------------------------------------------- */
    // Register transaction and reject wrong calls.
    TransactionGuard aTransaction( m_aTransactionManager, E_HARDEXCEPTIONS );

    // Remove uno and cmd protocol part as we want to support both of them. We store only the command part
    // in our hash map. All other protocols are stored with the protocol part.
    String aCommand( aURL.Main );
    if ( aURL.Protocol.equalsIgnoreAsciiCaseAsciiL( UNO_PROTOCOL, sizeof( UNO_PROTOCOL )-1 ))
        aCommand = aURL.Path;

    // Make hash_map lookup if the current URL is in the disabled list
    if ( m_aCommandOptions.Lookup( SvtCommandOptions::CMDOPTION_DISABLED, aCommand ) )
        return css::uno::Reference< css::frame::XDispatch >();
    else
    {
        // We use a helper to support these interface and an interceptor mechanism.
        // Our helper is threadsafe by himself!
        return m_xDispatchHelper->queryDispatch( aURL, sTargetFrameName, nSearchFlags );
    }
}

//*****************************************************************************************************************
css::uno::Sequence< css::uno::Reference< css::frame::XDispatch > > SAL_CALL Desktop::queryDispatches( const css::uno::Sequence< css::frame::DispatchDescriptor >& lQueries ) throw( css::uno::RuntimeException )
{
    /* UNSAFE AREA --------------------------------------------------------------------------------------------- */
    // Register transaction and reject wrong calls.
    TransactionGuard aTransaction( m_aTransactionManager, E_HARDEXCEPTIONS );

    return m_xDispatchHelper->queryDispatches( lQueries );
}

/*-************************************************************************************************************//**
    @interface  XFramesSupplier
    @short      return access to append or remove childs on desktop
    @descr      We don't implement these interface directly. We use a helper class to do this.
                If you wish to add or delete childs to/from the container, call these method to get
                a reference to the helper.

    @attention  Helper is threadsafe himself. So we don't need any lock here.

    @seealso    class OFrames

    @param      -
    @return     A reference to the helper.

    @onerror    A null reference is returned.
    @threadsafe yes
*//*-*************************************************************************************************************/
css::uno::Reference< css::frame::XFrames > SAL_CALL Desktop::getFrames() throw( css::uno::RuntimeException )
{
    /* UNSAFE AREA --------------------------------------------------------------------------------------------- */
    // Register transaction and reject wrong calls.
    TransactionGuard aTransaction( m_aTransactionManager, E_HARDEXCEPTIONS );

    return m_xFramesHelper;
}

/*-************************************************************************************************************//**
    @interface  XFramesSupplier
    @short      set/get the current active child frame
    @descr      It must be a task. Direct childs of desktop are tasks only! No frames are accepted.
                We don't save this information directly in this class. We use ouer container-helper
                to do that.

    @attention  Helper is threadsafe himself. So we don't need any lock here.

    @seealso    class OFrameContainer

    @param      "xFrame", new active frame (must be valid!)
    @return     A reference to ouer current active childtask, if anyone exist.

    @onerror    A null reference is returned.
    @threadsafe yes
*//*-*************************************************************************************************************/
void SAL_CALL Desktop::setActiveFrame( const css::uno::Reference< css::frame::XFrame >& xFrame ) throw( css::uno::RuntimeException )
{
    /* UNSAFE AREA --------------------------------------------------------------------------------------------- */
    // Register transaction and reject wrong calls.
    TransactionGuard aTransaction( m_aTransactionManager, E_HARDEXCEPTIONS );

    // Get old active frame first.
    // If nothing will change - do nothing!
    // Otherwise set new active frame ...
    // and deactivate last frame.
    // It's neccessary for our FrameActionEvent listener on a frame!
    css::uno::Reference< css::frame::XFrame > xLastActiveChild = m_aChildTaskContainer.getActive();
    if( xLastActiveChild != xFrame )
    {
        m_aChildTaskContainer.setActive( xFrame );
        if( xLastActiveChild.is() == sal_True )
        {
            xLastActiveChild->deactivate();
        }
    }
}

//*****************************************************************************************************************
css::uno::Reference< css::frame::XFrame > SAL_CALL Desktop::getActiveFrame() throw( css::uno::RuntimeException )
{
    /* UNSAFE AREA --------------------------------------------------------------------------------------------- */
    // Register transaction and reject wrong calls.
    TransactionGuard aTransaction( m_aTransactionManager, E_HARDEXCEPTIONS );

    return m_aChildTaskContainer.getActive();
}

/*-************************************************************************************************************//**
    @interface  XFrame
    @short      non implemented methods!
    @descr      Some method make no sense for our desktop! He has no window or parent or ...
                So we should implement it empty and warn programmer, if he use it!

    @seealso    -

    @param      -
    @return     -

    @onerror    -
    @threadsafe -
*//*-*************************************************************************************************************/
void SAL_CALL Desktop::initialize( const css::uno::Reference< css::awt::XWindow >& xWindow ) throw( css::uno::RuntimeException )
{
}

//*****************************************************************************************************************
css::uno::Reference< css::awt::XWindow > SAL_CALL Desktop::getContainerWindow() throw( css::uno::RuntimeException )
{
    return css::uno::Reference< css::awt::XWindow >();
}

//*****************************************************************************************************************
void SAL_CALL Desktop::setCreator( const css::uno::Reference< css::frame::XFramesSupplier >& xCreator ) throw( css::uno::RuntimeException )
{
}

//*****************************************************************************************************************
css::uno::Reference< css::frame::XFramesSupplier > SAL_CALL Desktop::getCreator() throw( css::uno::RuntimeException )
{
    return css::uno::Reference< css::frame::XFramesSupplier >();
}

//*****************************************************************************************************************
::rtl::OUString SAL_CALL Desktop::getName() throw( css::uno::RuntimeException )
{
    /* SAFE { */
    ReadGuard aReadLock( m_aLock );
    return m_sName;
    /* } SAFE */
}

//*****************************************************************************************************************
void SAL_CALL Desktop::setName( const ::rtl::OUString& sName ) throw( css::uno::RuntimeException )
{
    /* SAFE { */
    WriteGuard aWriteLock( m_aLock );
    m_sName = sName;
    aWriteLock.unlock();
    /* } SAFE */
}

//*****************************************************************************************************************
sal_Bool SAL_CALL Desktop::isTop() throw( css::uno::RuntimeException )
{
    return sal_True;
}

//*****************************************************************************************************************
void SAL_CALL Desktop::activate() throw( css::uno::RuntimeException )
{
    // Desktop is activae always ... but sometimes our frames try to activate
    // the complete path from bottom to top ... And our desktop is the topest frame :-(
    // So - please don't show any assertions here. Do nothing!
}

//*****************************************************************************************************************
void SAL_CALL Desktop::deactivate() throw( css::uno::RuntimeException )
{
    // Desktop is activae always ... but sometimes our frames try to deactivate
    // the complete path from bottom to top ... And our desktop is the topest frame :-(
    // So - please don't show any assertions here. Do nothing!
}

//*****************************************************************************************************************
sal_Bool SAL_CALL Desktop::isActive() throw( css::uno::RuntimeException )
{
    return sal_True;
}

//*****************************************************************************************************************
sal_Bool SAL_CALL Desktop::setComponent( const css::uno::Reference< css::awt::XWindow >&       xComponentWindow ,
                                         const css::uno::Reference< css::frame::XController >& xController      ) throw( css::uno::RuntimeException )
{
    return sal_False;
}

//*****************************************************************************************************************
css::uno::Reference< css::awt::XWindow > SAL_CALL Desktop::getComponentWindow() throw( css::uno::RuntimeException )
{
    return css::uno::Reference< css::awt::XWindow >();
}

//*****************************************************************************************************************
css::uno::Reference< css::frame::XController > SAL_CALL Desktop::getController() throw( css::uno::RuntimeException )
{
    return css::uno::Reference< css::frame::XController >();
}

//*****************************************************************************************************************
void SAL_CALL Desktop::contextChanged() throw( css::uno::RuntimeException )
{
}

//*****************************************************************************************************************
void SAL_CALL Desktop::addFrameActionListener( const css::uno::Reference< css::frame::XFrameActionListener >& xListener ) throw( css::uno::RuntimeException )
{
}

//*****************************************************************************************************************
//   css::frame::XFrame
//*****************************************************************************************************************
void SAL_CALL Desktop::removeFrameActionListener( const css::uno::Reference< css::frame::XFrameActionListener >& xListener ) throw( css::uno::RuntimeException )
{
}

/*-************************************************************************************************************//**
    @interface  XFrame
    @short      try to find a frame with special parameters
    @descr      This method searches for a frame with the specified name.
                Frames may contain other frames (e.g. a frameset) and may
                be contained in other frames. This hierarchie ist searched by
                this method.
                First some special names are taken into account, i.e. "",
                "_self", "_top", "_parent" etc. The FrameSearchFlags are ignored
                when comparing these names with aTargetFrameName, further steps are
                controlled by the FrameSearchFlags. If allowed, the name of the frame
                itself is compared with the desired one, then ( again if allowed )
                the method findFrame is called for all children of the frame.
                If no Frame with the given name is found until the top frames container,
                a new top Frame is created, if this is allowed by a special
                FrameSearchFlag. The new Frame also gets the desired name.
                We use a helper to get right search direction and react in a right manner.

    @seealso    class TargetFinder

    @param      "sTargetFrameName"  , name of searched frame
    @param      "nSearchFlags"      , flags to regulate search
    @return     A reference to an existing frame in hierarchy, if it exist.

    @onerror    A null reference is returned.
    @threadsafe yes
*//*-*************************************************************************************************************/
css::uno::Reference< css::frame::XFrame > SAL_CALL Desktop::findFrame( const ::rtl::OUString& sTargetFrameName ,
                                                                             sal_Int32        nSearchFlags     ) throw( css::uno::RuntimeException )
{
    css::uno::Reference< css::frame::XFrame > xTarget;

    //-----------------------------------------------------------------------------------------------------
    // 0) Ignore wrong parameter!
    //    We doesn't support search for following special targets.
    //    If we reject this requests - we mustnt check for such names
    //    in following code again and again. If we do not so -wrong
    //    search results can occure!
    //-----------------------------------------------------------------------------------------------------
    if (
        (sTargetFrameName==SPECIALTARGET_DEFAULT  )   ||    // valid for dispatches - not for findFrame()!
        (sTargetFrameName==SPECIALTARGET_MENUBAR  )   ||    // valid for dispatches - not for findFrame()!
        (sTargetFrameName==SPECIALTARGET_HELPAGENT)   ||    // valid for dispatches - not for findFrame()!
        (sTargetFrameName==SPECIALTARGET_PARENT   )   ||    // we have no parent by definition
        (sTargetFrameName==SPECIALTARGET_BEAMER   )         // beamer frames are allowed as child of tasks only -
                                                            // and they exist more then ones. We have no idea which our sub tasks is the right one
       )
    {
        return NULL;
    }

    //-----------------------------------------------------------------------------------------------------
    // I) check for special defined targets first which must be handled exclusive.
    //    force using of "if() else if() ..."
    //-----------------------------------------------------------------------------------------------------

    // get threadsafe some neccessary member which are neccessary for following functionality
    /* SAFE { */
    ReadGuard aReadLock( m_aLock );
    css::uno::Reference< css::lang::XMultiServiceFactory > xFactory = m_xFactory;
    aReadLock.unlock();
    /* } SAFE */

    //-----------------------------------------------------------------------------------------------------
    // I.I) "_blank"
    //  create a new task as child of this desktop instance
    //  Note: Used helper TaskCreator use us automaticly ...
    //-----------------------------------------------------------------------------------------------------
    if ( sTargetFrameName==SPECIALTARGET_BLANK )
    {
        TaskCreator aCreator(xFactory);
        xTarget = aCreator.createTask(::rtl::OUString(),sal_False);
    }

    //-----------------------------------------------------------------------------------------------------
    // I.II) "_top"
    //  We are top by definition
    //-----------------------------------------------------------------------------------------------------
    else
    if ( sTargetFrameName==SPECIALTARGET_TOP )
    {
        xTarget = this;
    }

    //-----------------------------------------------------------------------------------------------------
    // I.III) "_self", ""
    //  This mean this "frame" in every case.
    //-----------------------------------------------------------------------------------------------------
    else
    if (
        ( sTargetFrameName==SPECIALTARGET_SELF ) ||
        ( sTargetFrameName.getLength()<1       )
       )
    {
        xTarget = this;
    }

    else
    {
        //-------------------------------------------------------------------------------------------------
        // II) otherwhise use optional given search flags
        //  force using of combinations of such flags. means no "else" part of use if() statements.
        //  But we ust break further searches if target was already found.
        //  Order of using flags is fix: SELF - CHILDREN - SIBLINGS - PARENT
        //  TASK and CREATE are handled special.
        //  But note: Such flags are not valid for the desktop - especialy SIBLINGS or PARENT.
        //-------------------------------------------------------------------------------------------------

        // get threadsafe some neccessary member which are neccessary for following functionality
        /* SAFE { */
        aReadLock.lock();
        ::rtl::OUString sOwnName = m_sName;
        aReadLock.unlock();
        /* } SAFE */

        //-------------------------------------------------------------------------------------------------
        // II.I) SELF
        //  Check for right name. If it's the searched one return ourself - otherwhise
        //  ignore this flag.
        //-------------------------------------------------------------------------------------------------
        if (
            (nSearchFlags &  css::frame::FrameSearchFlag::SELF)  &&
            (sOwnName     == sTargetFrameName                 )
           )
        {
            xTarget = this;
        }

        //-------------------------------------------------------------------------------------------------
        // II.II) TASKS
        //  This is a special flag. Normaly it regulate search inside tasks and forbid access to parent trees.
        //  But the desktop exists outside such task trees. They are our sub trees. So the desktop implement
        //  a special feature: We use it to start search on our direct childrens only. That means we supress
        //  search on ALL child frames. May that can be usefull to get access on opened document tasks
        //  only without filter out all non realy required sub frames ...
        //  Used helper method on our container doesn't create any frame - its a search only.
        //-------------------------------------------------------------------------------------------------
        if (
            ( ! xTarget.is()                                  ) &&
            (nSearchFlags & css::frame::FrameSearchFlag::TASKS)
           )
        {
            xTarget = m_aChildTaskContainer.searchOnDirectChildrens(sTargetFrameName);
        }

        //-------------------------------------------------------------------------------------------------
        // II.III) CHILDREN
        //  Search on all children for the given target name.
        //  An empty name value can't occure here - because it must be already handled as "_self"
        //  before. Used helper function of container doesn't create any frame.
        //  It makes a deep search only.
        //-------------------------------------------------------------------------------------------------
        if (
            ( ! xTarget.is()                                     ) &&
            (nSearchFlags & css::frame::FrameSearchFlag::CHILDREN)
           )
        {
            xTarget = m_aChildTaskContainer.searchOnAllChildrens(sTargetFrameName);
        }

        //-------------------------------------------------------------------------------------------------
        // II.IV) CREATE
        //  If we haven't found any valid target frame by using normal flags - but user allowed us to create
        //  a new one ... we should do that. Used TaskCreator use us automaticly as parent!
        //-------------------------------------------------------------------------------------------------
        if (
            ( ! xTarget.is()                                   )    &&
            (nSearchFlags & css::frame::FrameSearchFlag::CREATE)
           )
        {
            TaskCreator aCreator(xFactory);
            xTarget = aCreator.createTask(sTargetFrameName,sal_False);
        }
    }

    return xTarget;
}

/*-************************************************************************************************************//**
    @interface  XComponent
    @short      release all reference
    @descr      The owner of this object calles the dispose method if the object
                should be destroyed. All other objects and components, that are registered
                as an EventListener are forced to release their references to this object.
                The reference attributes are disposed and released also.

    @seealso    -

    @param      -
    @return     -

    @onerror    -
    @threadsafe yes
*//*-*************************************************************************************************************/
void SAL_CALL Desktop::dispose() throw( css::uno::RuntimeException )
{
    // Safe impossible cases
    // It's an programming error if dispose is called before terminate!
    LOG_ASSERT2( m_bIsTerminated==sal_False, "Desktop::dispose()", "It's not allowed to dispose the desktop before terminate() is called!" )

    /*ATTENTION
        Make it threadsafe ... but this method is a special one!
        We must close objet for working BEFORE we dispose it realy ...
        After successful closing all interface calls are rejected by our
        transaction manager automaticly.
     */

    /* SAFE AREA ----------------------------------------------------------------------------------------------- */
    // Create an exclusiv access!
    // It's neccessary for follow transaction check ...
    // Another reason: We can recylce these write lock at later time ..
    // and it's superflous to create read- and write- locks in combination.
    WriteGuard aWriteLock( m_aLock );

    // Look for multiple calls of this method!
    // If somewhere call dispose() twice - he will be stopped here realy!!!
    TransactionGuard aTransaction( m_aTransactionManager, E_HARDEXCEPTIONS );

    // Now - we are alone and its the first call of this method ...
    // otherwise call before must throw a DisposedException!
    // Don't forget to release this registered transaction here ...
    // because next "setWorkingMode()" call blocks till all current existing one
    // are finished!
    aTransaction.stop();

    // Disable this instance for further work.
    // This will wait for all current running ones ...
    // and reject all further requests!
    m_aTransactionManager.setWorkingMode( E_BEFORECLOSE );

    // We should hold a reference to ourself ...
    // because our owner dispose us and release our reference ...
    // May be we will die before we could finish this method ...
    // Make snapshot of other neecessary member too.
    css::uno::Reference< css::uno::XInterface > xThis( static_cast< ::cppu::OWeakObject* >(this), css::uno::UNO_QUERY );

    // We don't need this lock any longer ... this method couldn't be called twice ... it was disabled for working!
    aWriteLock.unlock();
    /* UNSAFE AREA --------------------------------------------------------------------------------------------- */

    // We must disable the special quit timer of our frame container.
    // Because it will call terminate at THESE instance if last task will be removed!.
    m_aChildTaskContainer.disableQuitTimer();

    // We must send the dispose message to all listener.
    // Otherwise our child tasks are disposed and try to remove it by himself at our container ...
    css::lang::EventObject aDisposeEvent( xThis         );
    m_aListenerContainer.disposeAndClear( aDisposeEvent );

    // Clear our child task container and forget all task references.
    m_aChildTaskContainer.clear();

    // Dispose our helper too.
    css::uno::Reference< css::lang::XEventListener > xDispatchHelper( m_xDispatchHelper, css::uno::UNO_QUERY );
    css::uno::Reference< css::lang::XEventListener > xFramesHelper  ( m_xFramesHelper  , css::uno::UNO_QUERY );
    if( xDispatchHelper.is() == sal_True )
    {
        xDispatchHelper->disposing( aDisposeEvent );
    }
    if( xFramesHelper.is() == sal_True )
    {
        xFramesHelper->disposing( aDisposeEvent );
    }

    // Release all member references.
    m_xDispatchHelper   = css::uno::Reference< css::frame::XDispatchProvider >();
    m_xFramesHelper     = css::uno::Reference< css::frame::XFrames >();
    m_xLastFrame        = css::uno::Reference< css::frame::XFrame >();
    m_xFactory          = css::uno::Reference< css::lang::XMultiServiceFactory >();
    m_xPipeTerminator   = css::uno::Reference< css::frame::XTerminateListener >();
    m_xQuickLauncher    = css::uno::Reference< css::frame::XTerminateListener >();

    // Disable object for further working.
    m_aTransactionManager.setWorkingMode( E_CLOSE );
}

/*-************************************************************************************************************//**
    @interface  XComponent
    @short      add/remove listener for dispose events
    @descr      Add an event listener to this object, if you whish to get informations
                about our dieing!
                You must releas ethis listener reference during your own disposing() method.

    @attention  Our container is threadsafe himeslf. So we doesn't need any lock here.

    @seealso    -

    @param      "xListener", reference to valid listener. We don't accept invalid values!
    @return     -

    @onerror    -
    @threadsafe yes
*//*-*************************************************************************************************************/
void SAL_CALL Desktop::addEventListener( const css::uno::Reference< css::lang::XEventListener >& xListener ) throw( css::uno::RuntimeException )
{
    /* UNSAFE AREA --------------------------------------------------------------------------------------------- */
    // Safe impossible cases
    // Method not defined for all incoming parameter.
    LOG_ASSERT2( implcp_addEventListener( xListener ), "Desktop::addEventListener()", "Invalid parameter detected!" )
    // Register transaction and reject wrong calls.
    TransactionGuard aTransaction( m_aTransactionManager, E_HARDEXCEPTIONS );

    m_aListenerContainer.addInterface( ::getCppuType( ( const css::uno::Reference< css::lang::XEventListener >*) NULL ), xListener );
}

//*****************************************************************************************************************
void SAL_CALL Desktop::removeEventListener( const css::uno::Reference< css::lang::XEventListener >& xListener ) throw( css::uno::RuntimeException )
{
    /* UNSAFE AREA --------------------------------------------------------------------------------------------- */
    // Safe impossible cases
    // Method not defined for all incoming parameter.
    LOG_ASSERT2( implcp_removeEventListener( xListener ), "Desktop::removeEventListener()", "Invalid parameter detected!" )
    // Register transaction and reject wrong calls.
    TransactionGuard aTransaction( m_aTransactionManager, E_SOFTEXCEPTIONS );

    m_aListenerContainer.removeInterface( ::getCppuType( ( const css::uno::Reference< css::lang::XEventListener >*) NULL ), xListener );
}

/*-************************************************************************************************************//**
    @interface  XDispatchResultListener
    @short      callback for dispatches
    @descr      To support our method "loadComponentFromURL()" we are listener on temp. created dispatcher.
                They call us back in this method "statusChanged()". As source of given state event, they give us a
                reference to the target frame, in which dispatch was loaded! So we can use it to return his component
                to caller! If no target exist ... ??!!

    @seealso    method loadComponentFromURL()

    @param      "aEvent", state event which (hopefully) valid informations
    @return     -

    @onerror    -
    @threadsafe yes
*//*-*************************************************************************************************************/
void SAL_CALL Desktop::dispatchFinished( const css::frame::DispatchResultEvent& aEvent ) throw( css::uno::RuntimeException )
{
    /* UNSAFE AREA --------------------------------------------------------------------------------------------- */
    // Register transaction and reject wrong calls.
    TransactionGuard aTransaction( m_aTransactionManager, E_HARDEXCEPTIONS );

    /* SAFE AREA ------------------------------------------------------------------------------------------- */
    WriteGuard aWriteLock( m_aLock );
    if( m_eLoadState != E_INTERACTION )
    {
        m_xLastFrame = css::uno::Reference< css::frame::XFrame >();
        m_eLoadState = E_FAILED                                   ;
        if( aEvent.State == css::frame::DispatchResultState::SUCCESS )
        {
            css::uno::Reference < css::frame::XFrame > xFrame;
            if ( aEvent.Result >>= m_xLastFrame )
                m_eLoadState = E_SUCCESSFUL;
        }
    }
    /* UNSAFE AREA ----------------------------------------------------------------------------------------- */
}

/*-************************************************************************************************************//**
    @interface  XEventListener
    @short      not implemented!
    @descr      We are a status listener ... and so we must be an event listener too ... But we doesn't need it realy!
                We are a temp. listener only and our lifetime isn't smaller then of our temp. used dispatcher.

    @seealso    method loadComponentFromURL()

    @param      -
    @return     -

    @onerror    -
    @threadsafe -
*//*-*************************************************************************************************************/
void SAL_CALL Desktop::disposing( const css::lang::EventObject& aSource ) throw( css::uno::RuntimeException )
{
    LOG_ERROR( "Desktop::disposing()", "Algorithm error! Normaly desktop is temp. listener ... not all the time. So this method shouldn't be called." )
}

/*-************************************************************************************************************//**
    @interface  XInteractionHandler
    @short      callback for loadComponentFromURL for detected exceptions during load proccess
    @descr      In this case we must cancel loading and throw these detected exception again as result
                of our own called method.

    @attention  a)
                Normal loop in loadComponentFromURL() breaks on setted member m_eLoadState during callback statusChanged().
                But these interaction feature implements second way to do so! So we must look on different callbacks
                for same operation ... and live with it.
                b)
                Search for given continuations too. If any XInteractionAbort exist ... use it to abort further operations
                for currently running operation!

    @seealso    method loadComponentFromURL()
    @seealso    member m_eLoadState

    @param      "xRequest", request for interaction - normal a wrapped target exception from bottom services
    @return     -

    @onerror    -
    @threadsafe yes
*//*-*************************************************************************************************************/
void SAL_CALL Desktop::handle( const css::uno::Reference< css::task::XInteractionRequest >& xRequest ) throw( css::uno::RuntimeException )
{
    /* UNSAFE AREA --------------------------------------------------------------------------------------------- */
    // Register transaction and reject wrong calls.
    TransactionGuard aTransaction( m_aTransactionManager, E_HARDEXCEPTIONS );

    // Don't check incoming request!
    // If somewhere starts interaction without right parameter - he maked something wrong.
    // loadComponentFromURL() waits for thjese event - otherwise it yield for ever!

    // get packed request and work on it first
    // Attention: Don't set it on internal member BEFORE interaction is finished - because
    // "loadComponentFromURL()" yield tills this member is changed. If we do it before
    // interaction finish we can't guarantee right functionality. May be we cancel load process to erliear ...
    css::uno::Any aRequest = xRequest->getRequest();

    // extract continuations from request
    css::uno::Sequence< css::uno::Reference< css::task::XInteractionContinuation > > lContinuations = xRequest->getContinuations();
    css::uno::Reference< css::task::XInteractionAbort >                              xAbort ;
    css::uno::Reference< css::document::XInteractionFilterSelect >                   xSelect;

    sal_Int32 nCount=lContinuations.getLength();
    for( sal_Int32 nStep=0; nStep<nCount; ++nStep )
    {
        if( ! xAbort.is() )
            xAbort  = css::uno::Reference< css::task::XInteractionAbort >( lContinuations[nStep], css::uno::UNO_QUERY );

        if( ! xSelect.is() )
            xSelect = css::uno::Reference< css::document::XInteractionFilterSelect >( lContinuations[nStep], css::uno::UNO_QUERY );
    }

    // differ between abortable interactions (error, unknown filter ...)
    // and other ones (ambigous but not unknown filter ...)
    css::document::AmbigousFilterRequest aAmbigousFilterRequest;
    if( aRequest >>= aAmbigousFilterRequest )
    {
        if( xSelect.is() )
        {
            xSelect->setFilter( aAmbigousFilterRequest.SelectedFilter ); // user selected filter wins!
            xSelect->select();
        }
    }
    else
    {
        if( xAbort.is() )
        {
            xAbort->select();
        }
    }

    /* SAFE AREA ------------------------------------------------------------------------------------------- */
    WriteGuard aWriteLock( m_aLock );
    // Ok now it's time to break yield loop of loadComponentFromURL()!
    m_eLoadState          = E_INTERACTION;
    m_aInteractionRequest = aRequest     ;
    aWriteLock.unlock();
    /* UNSAFE AREA ----------------------------------------------------------------------------------------- */
}

/*-************************************************************************************************************//**
    @short      try to convert a property value
    @descr      This method is called from helperclass "OPropertySetHelper".
                Don't use this directly!
                You must try to convert the value of given propertyhandle and
                return results of this operation. This will be used to ask vetoable
                listener. If no listener has a veto, we will change value realy!
                ( in method setFastPropertyValue_NoBroadcast(...) )

    @attention  Methods of OPropertySethelper are safed by using our shared osl mutex! (see ctor!)
                So we must use different locks to make our implementation threadsafe.

    @seealso    class OPropertySetHelper
    @seealso    method setFastPropertyValue_NoBroadcast()
    @seealso    method impl_tryToChangeProperty()

    @param      "aConvertedValue"   new converted value of property
    @param      "aOldValue"         old value of property
    @param      "nHandle"           handle of property
    @param      "aValue"            new value of property
    @return     sal_True if value will be changed, sal_FALSE otherway

    @onerror    IllegalArgumentException, if you call this with an invalid argument
    @threadsafe yes
*//*-*************************************************************************************************************/
sal_Bool SAL_CALL Desktop::convertFastPropertyValue(       css::uno::Any&   aConvertedValue ,
                                                           css::uno::Any&   aOldValue       ,
                                                           sal_Int32        nHandle         ,
                                                     const css::uno::Any&   aValue          ) throw( css::lang::IllegalArgumentException )
{
    /* UNSAFE AREA --------------------------------------------------------------------------------------------- */
    // Register transaction and reject wrong calls.
    TransactionGuard aTransaction( m_aTransactionManager, E_HARDEXCEPTIONS );

    //  Attention: Method "impl_tryToChangeProperty()" can throw the IllegalArgumentException for us !!!

    //  Initialize state with FALSE !!!
    //  (Handle can be invalid)
    sal_Bool bReturn = sal_False;

    switch( nHandle )
    {
        case PROPERTYHANDLE_ACTIVECOMPONENT     :
        case PROPERTYHANDLE_ACTIVEFRAME         :
        case PROPERTYHANDLE_ISPLUGGED           :   bReturn = sal_False; // These variables are readonly(!) and can't be changed.
                                                    break;
        case PROPERTYHANDLE_SUSPENDQUICKSTARTVETO:  bReturn = impl_tryToChangeProperty( m_bSuspendQuickstartVeto, aValue, aOldValue, aConvertedValue );
                                                    break;
    }

    // Return state of operation.
    return bReturn ;
}

/*-************************************************************************************************************//**
    @short      set value of a transient property
    @descr      This method is calling from helperclass "OPropertySetHelper".
                Don't use this directly!
                Handle and value are valid everyway! You must set the new value only.
                After this, baseclass send messages to all listener automaticly.

    @seealso    class OPropertySetHelper

    @param      "nHandle"   handle of property to change
    @param      "aValue"    new value of property
    @return     -

    @onerror    An exception is thrown.
    @threadsafe yes
*//*-*************************************************************************************************************/
void SAL_CALL Desktop::setFastPropertyValue_NoBroadcast(       sal_Int32        nHandle ,
                                                         const css::uno::Any&   aValue  ) throw( css::uno::Exception )
{
    /* UNSAFE AREA --------------------------------------------------------------------------------------------- */
    // Register transaction and reject wrong calls.
    TransactionGuard aTransaction( m_aTransactionManager, E_HARDEXCEPTIONS );

    switch( nHandle )
    {
        case PROPERTYHANDLE_ACTIVECOMPONENT     :
        case PROPERTYHANDLE_ACTIVEFRAME         :
        case PROPERTYHANDLE_ISPLUGGED           :   LOG_ERROR( "Desktop::setFastPropertyValue_NoBroadcast()", "Set of readonly property not allowed." )
                                                    break;
        case PROPERTYHANDLE_SUSPENDQUICKSTARTVETO:  aValue >>= m_bSuspendQuickstartVeto;
                                                    break;
    }
}

/*-************************************************************************************************************//**
    @short      get value of a transient property
    @descr      This method is calling from helperclass "OPropertySetHelper".
                Don't use this directly!

    @attention  We don't need any mutex or lock here ... We use threadsafe container or methods here only!

    @seealso    class OPropertySetHelper

    @param      "nHandle"   handle of property to change
    @param      "aValue"    current value of property
    @return     -

    @onerror    -
    @threadsafe yes
*//*-*************************************************************************************************************/
void SAL_CALL Desktop::getFastPropertyValue( css::uno::Any& aValue  ,
                                             sal_Int32      nHandle ) const
{
    /* UNSAFE AREA --------------------------------------------------------------------------------------------- */
    // Register transaction and reject wrong calls.
    TransactionGuard aTransaction( m_aTransactionManager, E_HARDEXCEPTIONS );

    switch( nHandle )
    {
        case PROPERTYHANDLE_ACTIVECOMPONENT     :   //aValue <<= getCurrentComponent(); ... not available in const method :-(
                                                    aValue <<= css::uno::Reference< css::lang::XComponent >();
                                                    break;
        case PROPERTYHANDLE_ACTIVEFRAME         :   aValue <<= m_aChildTaskContainer.getActive();
                                                    break;
        case PROPERTYHANDLE_ISPLUGGED           :   aValue <<= impl_checkPlugInState();
                                                    break;
        case PROPERTYHANDLE_SUSPENDQUICKSTARTVETO:  aValue <<= m_bSuspendQuickstartVeto;
                                                    break;
    }
}

/*-************************************************************************************************************//**
    @short      return structure and information about transient properties
    @descr      This method is calling from helperclass "OPropertySetHelper".
                Don't use this directly!

    @attention  You must use global lock (method use static variable) ... and it must be the shareable osl mutex of it.
                Because; our baseclass use this mutex to make his code threadsafe. We use our lock!
                So we could have two different mutex/lock mechanism at the same object.

    @seealso    class OPropertySetHelper

    @param      -
    @return     structure with property-informations

    @onerror    -
    @threadsafe yes
*//*-*************************************************************************************************************/
::cppu::IPropertyArrayHelper& SAL_CALL Desktop::getInfoHelper()
{
    /* UNSAFE AREA --------------------------------------------------------------------------------------------- */
    // Register transaction and reject wrong calls.
    TransactionGuard aTransaction( m_aTransactionManager, E_HARDEXCEPTIONS );

    // Optimize this method !
    // We initialize a static variable only one time. And we don't must use a mutex at every call!
    // For the first call; pInfoHelper is NULL - for the second call pInfoHelper is different from NULL!
    static ::cppu::OPropertyArrayHelper* pInfoHelper = NULL;

    if( pInfoHelper == NULL )
    {
        // Ready for multithreading
        ::osl::MutexGuard aGuard( LockHelper::getGlobalLock().getShareableOslMutex() );
        // Control this pointer again, another instance can be faster then these!
        if( pInfoHelper == NULL )
        {
            // Define static member to give structure of properties to baseclass "OPropertySetHelper".
            // "impl_getStaticPropertyDescriptor" is a non exported and static funtion, who will define a static propertytable.
            // "sal_True" say: Table is sorted by name.
            static ::cppu::OPropertyArrayHelper aInfoHelper( impl_getStaticPropertyDescriptor(), sal_True );
            pInfoHelper = &aInfoHelper;
        }
    }

    return(*pInfoHelper);
}

/*-************************************************************************************************************//**
    @short      return propertysetinfo
    @descr      You can call this method to get information about transient properties
                of this object.

    @attention  You must use global lock (method use static variable) ... and it must be the shareable osl mutex of it.
                Because; our baseclass use this mutex to make his code threadsafe. We use our lock!
                So we could have two different mutex/lock mechanism at the same object.

    @seealso    class OPropertySetHelper
    @seealso    interface XPropertySet
    @seealso    interface XMultiPropertySet

    @param      -
    @return     reference to object with information [XPropertySetInfo]

    @onerror    -
    @threadsafe yes
*//*-*************************************************************************************************************/
css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL Desktop::getPropertySetInfo() throw (::com::sun::star::uno::RuntimeException)
{
    /* UNSAFE AREA --------------------------------------------------------------------------------------------- */
    // Register transaction and reject wrong calls.
    TransactionGuard aTransaction( m_aTransactionManager, E_HARDEXCEPTIONS );

    // Optimize this method !
    // We initialize a static variable only one time. And we don't must use a mutex at every call!
    // For the first call; pInfo is NULL - for the second call pInfo is different from NULL!
    static css::uno::Reference< css::beans::XPropertySetInfo >* pInfo = NULL;

    if( pInfo == NULL )
    {
        // Ready for multithreading
        ::osl::MutexGuard aGuard( LockHelper::getGlobalLock().getShareableOslMutex() );
        // Control this pointer again, another instance can be faster then these!
        if( pInfo == NULL )
        {
            // Create structure of propertysetinfo for baseclass "OPropertySetHelper".
            // (Use method "getInfoHelper()".)
            static css::uno::Reference< css::beans::XPropertySetInfo > xInfo( createPropertySetInfo( getInfoHelper() ) );
            pInfo = &xInfo;
        }
    }

    return (*pInfo);
}

/*-************************************************************************************************************//**
    @short      return current component of current frame
    @descr      The desktop himself has no component. But every frame in subtree.
                If somewhere call getCurrentComponent() at this class, we try to find the right frame and
                then we try to become his component. It can be a VCL-component, the model or the controller
                of founded frame.

    @attention  We don't work on internal member ... so we doesn't need any lock here.

    @seealso    method getCurrentComponent();

    @param      "xFrame", reference to valid frame in hierarchy. Method is not defined for invalid values.
                But we don't check these. Its an IMPL-method and caller must use it right!
    @return     A reference to found component.

    @onerror    A null reference is returned.
    @threadsafe yes
*//*-*************************************************************************************************************/
css::uno::Reference< css::lang::XComponent > Desktop::impl_getFrameComponent( const css::uno::Reference< css::frame::XFrame >& xFrame ) const
{
    /* UNSAFE AREA --------------------------------------------------------------------------------------------- */
    // Register transaction and reject wrong calls.
    TransactionGuard aTransaction( m_aTransactionManager, E_HARDEXCEPTIONS );

    // Set default return value, if method failed.
    css::uno::Reference< css::lang::XComponent > xComponent;
    // Does no controller exists?
    css::uno::Reference< css::frame::XController > xController = xFrame->getController();
    if( xController.is() == sal_False )
    {
        // Controller not exist - use the VCL-component.
        xComponent = css::uno::Reference< css::lang::XComponent >( xFrame->getComponentWindow(), css::uno::UNO_QUERY );
    }
    else
    {
        // Does no model exists?
        css::uno::Reference< css::frame::XModel > xModel( xController->getModel(), css::uno::UNO_QUERY );
        if( xModel.is() == sal_True )
        {
            // Model exist - use the model as component.
            xComponent = css::uno::Reference< css::lang::XComponent >( xModel, css::uno::UNO_QUERY );
        }
        else
        {
            // Model not exist - use the controller as component.
            xComponent = css::uno::Reference< css::lang::XComponent >( xController, css::uno::UNO_QUERY );
        }
    }

    return xComponent;
}

/*-************************************************************************************************************//**
    @short      test, if a property will change his value
    @descr      These methods will test, if a property will change his current value, with given parameter.
                We use a helperclass for properties. These class promote this behaviour.
                We implement a helper function for every property-type!

    @seealso    method convertFastPropertyValue()

    @param      "...Property"       ,   the property with his current value
    @param      "aNewValue"         ,   new value for property
    @param      "aOldValue"         ,   old value of property as Any for convertFastPropertyValue
    @param      "aConvertedValue"   ,   new value of property as Any for convertFastPropertyValue(it can be the old one, if nothing is changed!)
    @return     sal_True  ,if value will be changed
    @return     sal_FALSE ,otherwise.

    @onerror    IllegalArgumentException, if convert failed.
    @threadsafe yes
*//*-*************************************************************************************************************/
sal_Bool Desktop::impl_tryToChangeProperty(         sal_Bool        bProperty       ,
                                            const   css::uno::Any&  aNewValue       ,
                                                    css::uno::Any&  aOldValue       ,
                                                    css::uno::Any&  aConvertedValue ) throw( css::lang::IllegalArgumentException )
{
    /* UNSAFE AREA --------------------------------------------------------------------------------------------- */
    // Register transaction and reject wrong calls.
    TransactionGuard aTransaction( m_aTransactionManager, E_HARDEXCEPTIONS );

    // Set default return value.
    sal_Bool bReturn = sal_False;

    // Clear information of return parameter!
    aOldValue.clear();
    aConvertedValue.clear();

    // Get new value from any.
    // IllegalArgumentException() can be thrown!
    sal_Bool bNewValue;
    ::cppu::convertPropertyValue( bNewValue, aNewValue );

    // If value change ...
    if( bNewValue != bProperty )
    {
        // ... set information of change.
        // Attention:   Use setValue and getCppuBooleanType to set value in any!
        //              It's necessary, if BOOL can be int or char.
        aOldValue.setValue      ( &bProperty, ::getCppuBooleanType() );
        aConvertedValue.setValue( &bNewValue, ::getCppuBooleanType() );
        // Return OK - "value will be change ..."
        bReturn = sal_True;
    }

    return bReturn;
}

/*-************************************************************************************************************//**
    @short      create table with information about properties
    @descr      We use a helper class to support properties. These class need some information about this.
                These method create a new static description table with name, type, r/w-flags and so on ...

    @seealso    class OPropertySetHelper
    @seealso    method getInfoHelper()

    @param      -
    @return     Static table with information about properties.

    @onerror    -
    @threadsafe yes
*//*-*************************************************************************************************************/
const css::uno::Sequence< css::beans::Property > Desktop::impl_getStaticPropertyDescriptor()
{
    // Create a new static property array to initialize sequence!
    // Table of all predefined properties of this class. Its used from OPropertySetHelper-class!
    // Don't forget to change the defines (see begin of this file), if you add, change or delete a property in this list!!!
    // It's necessary for methods of OPropertySetHelper.
    // ATTENTION:
    //      YOU MUST SORT FOLLOW TABLE BY NAME ALPHABETICAL !!!

    static const css::beans::Property pProperties[] =
    {
        css::beans::Property( PROPERTYNAME_ACTIVECOMPONENT      , PROPERTYHANDLE_ACTIVECOMPONENT        , ::getCppuType((const css::uno::Reference< css::lang::XComponent >*)NULL), css::beans::PropertyAttribute::TRANSIENT | css::beans::PropertyAttribute::READONLY ),
        css::beans::Property( PROPERTYNAME_ACTIVEFRAME          , PROPERTYHANDLE_ACTIVEFRAME            , ::getCppuType((const css::uno::Reference< css::lang::XComponent >*)NULL), css::beans::PropertyAttribute::TRANSIENT | css::beans::PropertyAttribute::READONLY ),
        css::beans::Property( PROPERTYNAME_ISPLUGGED            , PROPERTYHANDLE_ISPLUGGED              , ::getBooleanCppuType()                                                  , css::beans::PropertyAttribute::TRANSIENT | css::beans::PropertyAttribute::READONLY ),
        css::beans::Property( PROPERTYNAME_SUSPENDQUICKSTARTVETO, PROPERTYHANDLE_SUSPENDQUICKSTARTVETO  , ::getBooleanCppuType()                                                  , css::beans::PropertyAttribute::TRANSIENT ),
    };
    // Use it to initialize sequence!
    static const css::uno::Sequence< css::beans::Property > lPropertyDescriptor( pProperties, PROPERTYCOUNT );
    // Return static "PropertyDescriptor"
    return lPropertyDescriptor;
}

/*-************************************************************************************************************//**
    @short      work with our terminate listener
    @descr      If somewhere call terminate on this object, we must notify our listener. They could throw a veto exception
                to break it or accept it by doing nothing. These two helper methods send right events to all registered
                listener.

    @attention  We don't need any lock here - our container is threadsafe himself!

    @seealso    method terminate()

    @param      -
    @return     -

    @onerror    -
    @threadsafe yes
*//*-*************************************************************************************************************/
void Desktop::impl_sendQueryTerminationEvent() throw( css::frame::TerminationVetoException )
{
    /* UNSAFE AREA --------------------------------------------------------------------------------------------- */
    // Register transaction and reject wrong calls.
    TransactionGuard aTransaction( m_aTransactionManager, E_HARDEXCEPTIONS );

    // Send QueryTermination event to all listener.
    // Get container for right listener.
    ::cppu::OInterfaceContainerHelper* pContainer = m_aListenerContainer.getContainer( ::getCppuType( ( const css::uno::Reference< css::frame::XTerminateListener >*) NULL ) );
    if( pContainer != NULL )
    {
        // Build QueryTermination event.
        css::lang::EventObject aEvent( static_cast< ::cppu::OWeakObject* >(this) );
        // Get iterator for access to listener.
        ::cppu::OInterfaceIteratorHelper aIterator( *pContainer );
        // Send message to all listener.
        // Somewhere can throw a TerminationVetoException.
        // We don't look for that(!) ... caller of this method will catch these.
        while( aIterator.hasMoreElements() == sal_True )
        {
            try
            {
                ((css::frame::XTerminateListener*)aIterator.next())->queryTermination( aEvent );
            }
            catch( css::uno::RuntimeException& )
            {
                aIterator.remove();
            }
        }
    }
}

//*****************************************************************************************************************
void Desktop::impl_sendNotifyTerminationEvent()
{
    /* UNSAFE AREA --------------------------------------------------------------------------------------------- */
    // Register transaction and reject wrong calls.
    TransactionGuard aTransaction( m_aTransactionManager, E_HARDEXCEPTIONS );

    // Send NotifyTermination event to all listener.
    // Get container for right listener.
    ::cppu::OInterfaceContainerHelper* pContainer = m_aListenerContainer.getContainer( ::getCppuType( ( const css::uno::Reference< css::frame::XTerminateListener >*) NULL ) );
    if( pContainer != NULL )
    {
        // Build QueryTermination event.
        css::lang::EventObject aEvent( static_cast< ::cppu::OWeakObject* >(this) );
        // Get iterator for access to listener.
        ::cppu::OInterfaceIteratorHelper aIterator( *pContainer );
        // Send message to all listener.
        while( aIterator.hasMoreElements() == sal_True )
        {
            try
            {
                ((css::frame::XTerminateListener*)aIterator.next())->notifyTermination( aEvent );
            }
            catch( css::uno::RuntimeException& )
            {
                aIterator.remove();
            }
        }
    }
}

/*-************************************************************************************************************//**
    @short      search for any plugin frame to return current plugin state
    @descr      For property "IsPlugged" we need information about this state.
                We search for any plugin frame in our container (it can be tasks or plugin-frames only!).
                If we found somewhere we return TRUE, FALSE otherwise.

    @attention  We don't need any lock here - our container is threadsafe himself!

    @seealso    property IsPlugged

    @param      -
    @return     sal_True, if a plugin frame exist, sal_False otherwise.

    @onerror    We return sal_False.
    @threadsafe yes
*//*-*************************************************************************************************************/
sal_Bool Desktop::impl_checkPlugInState() const
{
    /* UNSAFE AREA --------------------------------------------------------------------------------------------- */
    // Register transaction and reject wrong calls.
    TransactionGuard aTransaction( m_aTransactionManager, E_HARDEXCEPTIONS );

    // set default return value if search failed or no plugin could be detected.
    sal_Bool bPluginExist = sal_False;

    // We must search at ouer childs. We make a flat search at our direct children only.
    // Break loop, if something was found or all container items was compared.
    css::uno::Sequence< css::uno::Reference< css::frame::XFrame > > lTasks    = m_aChildTaskContainer.getAllElements();
    sal_uInt32                                                      nCount    = lTasks.getLength();
    sal_uInt32                                                      nPosition = 0;
    while(
            ( bPluginExist  ==  sal_False   )   &&
            ( nPosition     <   nCount      )
         )
    {
        css::uno::Reference< css::mozilla::XPluginInstance > xPlugInFrame( lTasks[nPosition], css::uno::UNO_QUERY );
        bPluginExist = xPlugInFrame.is();
        ++nPosition;
    }

    return bPluginExist;
}

//_________________________________________________________________________________________________________________
//  debug methods
//_________________________________________________________________________________________________________________

/*-----------------------------------------------------------------------------------------------------------------
    The follow methods checks the parameter for other functions. If a parameter or his value is non valid,
    we return "sal_True". (otherwise sal_False) This mechanism is used to throw an ASSERT!
-----------------------------------------------------------------------------------------------------------------*/

#ifdef ENABLE_ASSERTIONS

//*****************************************************************************************************************
//  We work with valid servicemanager only.
sal_Bool Desktop::implcp_ctor( const css::uno::Reference< css::lang::XMultiServiceFactory >& xFactory )
{
    return(
            ( &xFactory     ==  NULL        )   ||
            ( xFactory.is() ==  sal_False   )
          );
}

//*****************************************************************************************************************
//  We work with valid listener only.
sal_Bool Desktop::implcp_addTerminateListener( const css::uno::Reference< css::frame::XTerminateListener >& xListener )
{
    return(
            ( &xListener        ==  NULL        )   ||
            ( xListener.is()    ==  sal_False   )
          );
}

//*****************************************************************************************************************
//  We work with valid listener only.
sal_Bool Desktop::implcp_removeTerminateListener( const css::uno::Reference< css::frame::XTerminateListener >& xListener )
{
    return(
            ( &xListener        ==  NULL        )   ||
            ( xListener.is()    ==  sal_False   )
          );
}

//*****************************************************************************************************************
//  The target frame could be ""(!), but flags must be in range of right enum.
sal_Bool Desktop::implcp_findFrame( const ::rtl::OUString&  sTargetFrameName,
                                          sal_Int32         nSearchFlags    )
{
    return(
            ( &sTargetFrameName == NULL )   ||
            (
                (    nSearchFlags != css::frame::FrameSearchFlag::AUTO        ) &&
                ( !( nSearchFlags &  css::frame::FrameSearchFlag::PARENT    ) ) &&
                ( !( nSearchFlags &  css::frame::FrameSearchFlag::SELF      ) ) &&
                ( !( nSearchFlags &  css::frame::FrameSearchFlag::CHILDREN  ) ) &&
                ( !( nSearchFlags &  css::frame::FrameSearchFlag::CREATE    ) ) &&
                ( !( nSearchFlags &  css::frame::FrameSearchFlag::SIBLINGS  ) ) &&
                ( !( nSearchFlags &  css::frame::FrameSearchFlag::TASKS     ) ) &&
                ( !( nSearchFlags &  css::frame::FrameSearchFlag::ALL       ) ) &&
                ( !( nSearchFlags &  css::frame::FrameSearchFlag::GLOBAL    ) )
            )
          );
}

//*****************************************************************************************************************
//  We work with valid listener only.
sal_Bool Desktop::implcp_addEventListener( const css::uno::Reference< css::lang::XEventListener >& xListener )
{
    return(
            ( &xListener        ==  NULL        )   ||
            ( xListener.is()    ==  sal_False   )
          );
}

//*****************************************************************************************************************
//  We work with valid listener only.
sal_Bool Desktop::implcp_removeEventListener( const css::uno::Reference< css::lang::XEventListener >& xListener )
{
    return(
            ( &xListener        ==  NULL        )   ||
            ( xListener.is()    ==  sal_False   )
          );
}

//*****************************************************************************************************************
sal_Bool Desktop::implcp_statusChanged( const css::frame::FeatureStateEvent& aEvent )
{
    return(
            ( &aEvent                              == NULL ) ||
            ( aEvent.FeatureDescriptor.getLength() <  1    )
          );
}

#endif  // #ifdef ENABLE_ASSERTIONS

}   // namespace framework