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
|
/*************************************************************************
*
* $RCSfile: frame.cxx,v $
*
* $Revision: 1.15 $
*
* last change: $Author: mba $ $Date: 2001-02-15 08:49:10 $
*
* 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_SERVICES_FRAME_HXX_
#include <services/frame.hxx>
#endif
#ifndef __FRAMEWORK_HELPER_ODISPATCHPROVIDER_HXX_
#include <helper/odispatchprovider.hxx>
#endif
#ifndef __FRAMEWORK_HELPER_OINTERCEPTIONHELPER_HXX_
#include <helper/ointerceptionhelper.hxx>
#endif
#ifndef __FRAMEWORK_HELPER_OFRAMES_HXX_
#include <helper/oframes.hxx>
#endif
#ifndef __FRAMEWORK_HELPER_OSTATUSINDICATORFACTORY_HXX_
#include <helper/ostatusindicatorfactory.hxx>
#endif
#ifndef __FRAMEWORK_CLASSES_TARGETFINDER_HXX_
#include <classes/targetfinder.hxx>
#endif
//_________________________________________________________________________________________________________________
// interface includes
//_________________________________________________________________________________________________________________
#ifndef _COM_SUN_STAR_AWT_XDEVICE_HPP_
#include <com/sun/star/awt/XDevice.hpp>
#endif
#ifndef _COM_SUN_STAR_AWT_XTOPWINDOW_HPP_
#include <com/sun/star/awt/XTopWindow.hpp>
#endif
#ifndef _COM_SUN_STAR_FRAME_XTASK_HPP_
#include <com/sun/star/frame/XTask.hpp>
#endif
#ifndef _COM_SUN_STAR_FRAME_XDESKTOP_HPP_
#include <com/sun/star/frame/XDesktop.hpp>
#endif
#ifndef _COM_SUN_STAR_AWT_POSSIZE_HPP_
#include <com/sun/star/awt/PosSize.hpp>
#endif
#ifndef _COM_SUN_STAR_FRAME_FRAMESEARCHFLAG_HPP_
#include <com/sun/star/frame/FrameSearchFlag.hpp>
#endif
#ifndef _COM_SUN_STAR_AWT_XWINDOWPEER_HPP_
#include <com/sun/star/awt/XWindowPeer.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 _RTL_USTRBUF_HXX_
#include <rtl/ustrbuf.hxx>
#endif
#ifndef _SV_WINDOW_HXX
#include <vcl/window.hxx>
#endif
#ifndef _SV_SVAPP_HXX
#include <vcl/svapp.hxx>
#endif
#ifndef _TOOLKIT_HELPER_VCLUNOHELPER_HXX_
#include <toolkit/unohlp.hxx>
#endif
#ifndef _TOOLKIT_AWT_VCLXWINDOW_HXX_
#include <toolkit/awt/vclxwindow.hxx>
#endif
#ifdef DEBUG
#ifndef _RTL_STRBUF_HXX_
#include <rtl/strbuf.hxx>
#endif
#endif
//_________________________________________________________________________________________________________________
// namespace
//_________________________________________________________________________________________________________________
namespace framework{
using namespace ::com::sun::star ;
using namespace ::com::sun::star::beans ;
using namespace ::com::sun::star::container ;
using namespace ::com::sun::star::frame ;
using namespace ::com::sun::star::lang ;
using namespace ::com::sun::star::task ;
using namespace ::com::sun::star::uno ;
using namespace ::com::sun::star::util ;
using namespace ::cppu ;
using namespace ::osl ;
using namespace ::rtl ;
//_________________________________________________________________________________________________________________
// non exported const
//_________________________________________________________________________________________________________________
#define DEFAULT_EACTIVESTATE INACTIVE
#define DEFAULT_BRECURSIVESEARCHPROTECTION sal_False
#define DEFAULT_BISFRAMETOP sal_True
#define DEFAULT_BALREADYDISPOSED sal_False
#define DEFAULT_BCONNECTED sal_True
#define DEFAULT_SNAME OUString()
//_________________________________________________________________________________________________________________
// non exported definitions
//_________________________________________________________________________________________________________________
//_________________________________________________________________________________________________________________
// declarations
//_________________________________________________________________________________________________________________
//*****************************************************************************************************************
// constructor
//*****************************************************************************************************************
Frame::Frame( const Reference< XMultiServiceFactory >& xFactory )
// Init baseclasses first
// Attention:
// Don't change order of initialization!
// OMutexMember is a struct with a mutex as member. We can't use a mutex as member, while
// we must garant right initialization and a valid value of this! First initialize
// baseclasses and then members. And we need the mutex for other baseclasses !!!
: OMutexMember ( )
, OWeakObject ( )
// Init member
, m_xFactory ( xFactory )
, m_aListenerContainer ( m_aMutex )
, m_aChildFrameContainer ( )
// Init flags
, m_eActiveState ( DEFAULT_EACTIVESTATE )
, m_bRecursiveSearchProtection( DEFAULT_BRECURSIVESEARCHPROTECTION)
, m_bIsFrameTop ( DEFAULT_BISFRAMETOP )
, m_bAlreadyDisposed ( DEFAULT_BALREADYDISPOSED )
, m_bConnected ( DEFAULT_BCONNECTED )
, m_sName ( DEFAULT_SNAME )
{
// We cant create the dispatchhelper and frameshelper, because they hold wekreferences to us!
// But with a HACK (++refcount) its "OK" :-(
++m_refCount ;
// Initialize a new dispatchhelper-object to handle dispatches for SELF private and fast!
// We use these helper as slave for our interceptor helper ...
// (Attention: These helper hold a weakreference to us!)
#if SUPD>614
ODispatchProvider* pDispatchHelper = new ODispatchProvider( m_xFactory, this );
#else
ODispatchProvider* pDispatchHelper = new ODispatchProvider( m_xFactory, this, m_aMutex );
#endif
// Initialize a new interception helper object to handle dispatches and interceptor mechanism PRIVATE!
// These helper don't need any reference to use ...
OInterceptionHelper* pInterceptionHelper = new OInterceptionHelper( Reference< XFrame >( this ), Reference< XDispatchProvider >( static_cast< OWeakObject* >( pDispatchHelper ), UNO_QUERY ) );
m_xDispatchHelper = Reference< XDispatchProvider >( static_cast< OWeakObject* >(pInterceptionHelper), UNO_QUERY );
// Initialize a new frameshelper-object to handle indexaccess and elementaccess!
// Attention: OFrames need the this-pointer for initializing. You must use "this" directly.
// If you define an extra variable to do that (like: Reference< XFrame > xTHIS( ... )) and
// forget to clear this reference BEFORE "--m_refCount" (!), your refcount will be less then 0
// and the new Desktop-instance will be destroyed instantly!!!...
OFrames* pFramesHelper = new OFrames( m_xFactory, m_aMutex, this, &m_aChildFrameContainer );
m_xFramesHelper = Reference< XFrames >( static_cast< OWeakObject* >(pFramesHelper), UNO_QUERY );
// Safe impossible cases
// We can't work without these helpers!
LOG_ASSERT( !(m_xDispatchHelper.is()==sal_False), "Frame::Frame()\nDispatchHelper is not valid. XDispatchProvider, XDispatch, XDispatchProviderInterception are not supported!\n" )
LOG_ASSERT( !(m_xFramesHelper.is ()==sal_False), "Frame::Frame()\nFramesHelper is not valid. XFrames, XIndexAccess and XElementAcces are not supported!\n" )
// Don't forget these - or we live for ever!
--m_refCount ;
}
//*****************************************************************************************************************
// destructor
//*****************************************************************************************************************
Frame::~Frame()
{
}
//*****************************************************************************************************************
// XInterface, XTypeProvider, XServiceInfo
//*****************************************************************************************************************
DEFINE_XINTERFACE_13 ( Frame ,
OWeakObject ,
DIRECT_INTERFACE(XTypeProvider ),
DIRECT_INTERFACE(XServiceInfo ),
DIRECT_INTERFACE(XFramesSupplier ),
DIRECT_INTERFACE(XFrame ),
DIRECT_INTERFACE(XComponent ),
DIRECT_INTERFACE(XStatusIndicatorFactory ),
DIRECT_INTERFACE(XDispatchProvider ),
DIRECT_INTERFACE(XDispatchProviderInterception ),
DIRECT_INTERFACE(XBrowseHistoryRegistry ),
DIRECT_INTERFACE(awt::XWindowListener ),
DIRECT_INTERFACE(awt::XTopWindowListener ),
DIRECT_INTERFACE(awt::XFocusListener ),
DERIVED_INTERFACE(XEventListener, awt::XWindowListener )
)
DEFINE_XTYPEPROVIDER_13 ( Frame ,
XTypeProvider ,
XServiceInfo ,
XFramesSupplier ,
XFrame ,
XComponent ,
XStatusIndicatorFactory ,
XDispatchProvider ,
XDispatchProviderInterception ,
XBrowseHistoryRegistry ,
awt::XWindowListener ,
awt::XTopWindowListener ,
awt::XFocusListener ,
XEventListener
)
DEFINE_XSERVICEINFO_MULTISERVICE ( Frame ,
SERVICENAME_FRAME ,
IMPLEMENTATIONNAME_FRAME
)
//*****************************************************************************************************************
// XFramesSupplier
//*****************************************************************************************************************
Reference< XFrames > SAL_CALL Frame::getFrames() throw( RuntimeException )
{
// Return access to all child frames to caller.
// Ouer childframe container is implemented in helper class OFrames and used as a member m_xFramesHelper!
return m_xFramesHelper;
}
//*****************************************************************************************************************
// XFramesSupplier
//*****************************************************************************************************************
Reference< XFrame > SAL_CALL Frame::getActiveFrame() throw( RuntimeException )
{
// Ready for multithreading
LOCK_MUTEX( aGuard, m_aMutex, "Frame::getActiveFrame()" )
// Return current active frame.
// This information is avaliable on the container.
return m_aChildFrameContainer.getActive();
}
//*****************************************************************************************************************
// XFramesSupplier
//*****************************************************************************************************************
void SAL_CALL Frame::setActiveFrame( const Reference< XFrame >& xFrame ) throw( RuntimeException )
{
// Ready for multithreading
LOCK_MUTEX( aGuard, m_aMutex, "Frame::setActiveFrame()" )
// Safe impossible cases
// This method is not defined for all incoming parameters.
// I accept valid frames only. No tasks or desktops!
// (But a NULL-reference stop down search in tree and is allowed!)
LOG_ASSERT( impldbg_checkParameter_setActiveFrame( xFrame ), "Frame::setActiveFrame()\nInvalid parameter detected.\n" )
// We don't safe the current active frame directly in this class! We set the information at container.
// This is neccessar to control, if the active frame is a direct child of us!
Reference< XFrame > xActiveChild = m_aChildFrameContainer.getActive();
// Don't work, if "new" active frame is'nt different from current one!
if ( xActiveChild != xFrame )
{
// Set the new active child frame.
m_aChildFrameContainer.setActive( xFrame );
if( isActive() && xActiveChild.is() )
xActiveChild->deactivate();
}
if ( xFrame.is() )
{
if( m_eActiveState == FOCUS )
{
m_eActiveState = ACTIVE;
impl_sendFrameActionEvent( FrameAction_FRAME_UI_DEACTIVATING );
}
if ( m_eActiveState == ACTIVE && !xFrame->isActive() )
xFrame->activate();
}
else if ( m_eActiveState == ACTIVE )
{
// If this frame is active and has no active subframe anymore it is UI active too
m_eActiveState = FOCUS;
impl_sendFrameActionEvent( FrameAction_FRAME_UI_ACTIVATED );
}
}
//*****************************************************************************************************************
// XStatusIndicatorFactory
//*****************************************************************************************************************
Reference< XStatusIndicator > SAL_CALL Frame::createStatusIndicator() throw( RuntimeException )
{
// Ready for multithreading
LOCK_MUTEX( aGuard, m_aMutex, "Frame::createStatusIndicator()" )
// Forward operation to our helper.
return m_xIndicatorFactoryHelper->createStatusIndicator();
}
//*****************************************************************************************************************
// XDispatchProvider
//*****************************************************************************************************************
Reference< XDispatch > SAL_CALL Frame::queryDispatch( const URL& aURL ,
const OUString& sTargetFrameName,
sal_Int32 nSearchFlags ) throw( RuntimeException )
{
// We use a helper to support these interface and an interceptor mechanism.
// These helper implementation use his own mutex and check incoming parameter for us!
return m_xDispatchHelper->queryDispatch( aURL, sTargetFrameName, nSearchFlags );
}
//*****************************************************************************************************************
// XDispatchProvider
//*****************************************************************************************************************
Sequence< Reference< XDispatch > > SAL_CALL Frame::queryDispatches( const Sequence< DispatchDescriptor >& seqDescriptor ) throw( RuntimeException )
{
// We use a helper to support these interface and an interceptor mechanism.
// These helper implementation use his own mutex and check incoming parameter for us!
return m_xDispatchHelper->queryDispatches( seqDescriptor );
}
//*****************************************************************************************************************
// XDispatchProviderInterception
//*****************************************************************************************************************
void SAL_CALL Frame::registerDispatchProviderInterceptor( const Reference< XDispatchProviderInterceptor >& xInterceptor ) throw( RuntimeException )
{
// We use a helper to support these interface and an interceptor mechanism.
// These helper implementation use his own mutex and check incoming parameter for us!
Reference< XDispatchProviderInterception > xHelper( m_xDispatchHelper, UNO_QUERY );
xHelper->registerDispatchProviderInterceptor( xInterceptor );
}
//*****************************************************************************************************************
// XDispatchProviderInterception
//*****************************************************************************************************************
void SAL_CALL Frame::releaseDispatchProviderInterceptor( const Reference< XDispatchProviderInterceptor >& xInterceptor ) throw( RuntimeException )
{
// We use a helper to support these interface and an interceptor mechanism.
// These helper implementation use his own mutex and check incoming parameter for us!
Reference< XDispatchProviderInterception > xHelper( m_xDispatchHelper, UNO_QUERY );
xHelper->releaseDispatchProviderInterceptor( xInterceptor );
}
//*****************************************************************************************************************
// XBrowseHistoryRegistry
//*****************************************************************************************************************
void SAL_CALL Frame::updateViewData( const Any& aValue ) throw( RuntimeException )
{
LOG_ASSERT( sal_False, "Frame::updateViewData()\nNot implemented yet!\n" )
}
//*****************************************************************************************************************
// XBrowseHistoryRegistry
//*****************************************************************************************************************
void SAL_CALL Frame::createNewEntry( const OUString& sURL ,
const Sequence< PropertyValue >& seqArguments,
const OUString& sTitle ) throw( RuntimeException )
{
LOG_ASSERT( sal_False, "Frame::createNewEntry()\nNot implemented yet!\n" )
}
//*****************************************************************************************************************
// awt::XWindowListener
//*****************************************************************************************************************
void SAL_CALL Frame::windowResized( const awt::WindowEvent& aEvent ) throw( RuntimeException )
{
// Ready for multithreading
LOCK_MUTEX( aGuard, m_aMutex, "Frame::windowResized()" )
// Safe impossible cases
LOG_ASSERT( impldbg_checkParameter_windowResized( aEvent ), "Frame::windowResized()\nInvalid parameter detected.\n" )
// If we have a current component window - we must resize it!
impl_resizeComponentWindow();
}
//*****************************************************************************************************************
// awt::XWindowListener
//*****************************************************************************************************************
void SAL_CALL Frame::windowMoved( const awt::WindowEvent& aEvent ) throw( RuntimeException )
{
}
//*****************************************************************************************************************
// awt::XWindowListener
//*****************************************************************************************************************
void SAL_CALL Frame::windowShown( const EventObject& aEvent ) throw( RuntimeException )
{
}
//*****************************************************************************************************************
// awt::XWindowListener
//*****************************************************************************************************************
void SAL_CALL Frame::windowHidden( const EventObject& aEvent ) throw( RuntimeException )
{
}
//*****************************************************************************************************************
// XTopWindowListener
//*****************************************************************************************************************
void SAL_CALL Frame::windowOpened( const EventObject& aEvent ) throw( RuntimeException )
{
}
//*****************************************************************************************************************
// XTopWindowListener
//*****************************************************************************************************************
void SAL_CALL Frame::windowClosing( const EventObject& aEvent ) throw( RuntimeException )
{
}
//*****************************************************************************************************************
// XTopWindowListener
//*****************************************************************************************************************
void SAL_CALL Frame::windowClosed( const EventObject& aEvent ) throw( RuntimeException )
{
}
//*****************************************************************************************************************
// XTopWindowListener
//*****************************************************************************************************************
void SAL_CALL Frame::windowMinimized( const EventObject& aEvent ) throw( RuntimeException )
{
}
//*****************************************************************************************************************
// XTopWindowListener
//*****************************************************************************************************************
void SAL_CALL Frame::windowNormalized( const EventObject& aEvent ) throw( RuntimeException )
{
}
//*****************************************************************************************************************
// XTopWindowListener
//*****************************************************************************************************************
void SAL_CALL Frame::windowActivated( const EventObject& aEvent ) throw( RuntimeException )
{
// Activate the new active path from here to top.
if ( m_eActiveState == INACTIVE )
{
LOCK_MUTEX( aGuard, m_aMutex, "Frame::windowActivated()" )
// Safe impossible cases
LOG_ASSERT( impldbg_checkParameter_windowActivated( aEvent ), "Frame::windowActivated()\nInvalid parameter detected.\n" )
setActiveFrame( Reference< XFrame >() );
activate();
}
}
//*****************************************************************************************************************
// XTopWindowListener
//*****************************************************************************************************************
void SAL_CALL Frame::windowDeactivated( const EventObject& aEvent ) throw( RuntimeException )
{
if( m_eActiveState != INACTIVE )
{
LOCK_MUTEX( aGuard, m_aMutex, "Frame::windowDeactivated()" )
// Safe impossible cases
LOG_ASSERT( impldbg_checkParameter_windowDeactivated( aEvent ), "Frame::windowDeactivated()\nInvalid parameter detected.\n" )
// Deactivation is always done implicitely by activation of another frame.
// Only if no activation is done, deactivations have to be processed if the activated window
// is a parent window of the last active Window!
Reference< awt::XWindowPeer > xOwnWindow ( m_xContainerWindow, UNO_QUERY );
Window* pFocusWindow= Application::GetFocusWindow();
if (
( xOwnWindow.is() == sal_True ) &&
( pFocusWindow != NULL ) &&
( m_xParent.is() == sal_True ) &&
( (Reference< XDesktop >( m_xParent, UNO_QUERY )).is() == sal_False )
)
{
Reference< awt::XWindow > xParentWindow = m_xParent->getContainerWindow() ;
Window* pOwnWindow = VCLUnoHelper::GetWindow( xOwnWindow ) ;
Window* pParentWindow = VCLUnoHelper::GetWindow( xParentWindow ) ;
if( pParentWindow->IsChild( pFocusWindow ) )
{
m_xParent->setActiveFrame( Reference< XFrame >() );
}
}
}
}
//*****************************************************************************************************************
// XFrame
//*****************************************************************************************************************
void SAL_CALL Frame::initialize( const Reference< awt::XWindow >& xWindow ) throw( RuntimeException )
{
// Ready for multithreading
LOCK_MUTEX( aGuard, m_aMutex, "Frame::initialize()" )
// Safe impossible cases
LOG_ASSERT( impldbg_checkParameter_initialize( xWindow ), "Frame::initialize()\nInvalid parameter detected.\n" )
LOG_ASSERT( !(m_xContainerWindow.is() == sal_True ) , "Frame::initialize()\nMethod already called! Don't do it again.\n")
// Protection against more then one calls ...
if ( m_xContainerWindow.is() == sal_False )
{
// ... and set the new window.
impl_setContainerWindow( xWindow );
// Now we can use our indicator factory helper to support XStatusIndicatorFactory interface.
// We have a valid parent window for it!
// Initialize helper.
OStatusIndicatorFactory* pIndicatorFactoryHelper = new OStatusIndicatorFactory( m_xFactory, m_xContainerWindow );
m_xIndicatorFactoryHelper = Reference< XStatusIndicatorFactory >( static_cast< OWeakObject* >( pIndicatorFactoryHelper ), UNO_QUERY );
}
}
//*****************************************************************************************************************
// XFrame
//*****************************************************************************************************************
Reference< awt::XWindow > SAL_CALL Frame::getContainerWindow() throw( RuntimeException )
{
// Ready for multithreading
LOCK_MUTEX( aGuard, m_aMutex, "Frame::getContainerWindow()" )
// Return reference to my own window - if it exist!
return m_xContainerWindow;
}
//*****************************************************************************************************************
// XFrame
//*****************************************************************************************************************
void SAL_CALL Frame::setCreator( const Reference< XFramesSupplier >& xCreator ) throw( RuntimeException )
{
// Ready for multithreading
LOCK_MUTEX( aGuard, m_aMutex, "Frame::setCreator()" )
// Safe impossible cases
LOG_ASSERT( impldbg_checkParameter_setCreator( xCreator ), "Frame::setCreator()\nInvalid parameter detected.\n" )
// Safe new reference to different parent.
m_xParent = xCreator;
// Set/reset "is top" flag, if ouer new parent a frame, task or a desktop.
m_bIsFrameTop = impl_willFrameTop( m_xParent );
}
//*****************************************************************************************************************
// XFrame
//*****************************************************************************************************************
Reference< XFramesSupplier > SAL_CALL Frame::getCreator() throw( RuntimeException )
{
// Ready for multithreading
LOCK_MUTEX( aGuard, m_aMutex, "Frame::getCreator()" )
// Return reference to my creator - It's my parent too.
return m_xParent;
}
//*****************************************************************************************************************
// XFrame
//*****************************************************************************************************************
OUString SAL_CALL Frame::getName() throw( RuntimeException )
{
// Ready for multithreading
LOCK_MUTEX( aGuard, m_aMutex, "Frame::getName()" )
// Return name of this frame.
return m_sName;
}
//*****************************************************************************************************************
// XFrame
//*****************************************************************************************************************
void SAL_CALL Frame::setName( const OUString& sName ) throw( RuntimeException )
{
// Ready for multithreading
LOCK_MUTEX( aGuard, m_aMutex, "Frame::setName()" )
// Safe impossible cases
LOG_ASSERT( impldbg_checkParameter_setName( sName ), "Frame::setName()\nInvalid parameter detected.\n" )
// Take the new one.
m_sName = sName;
}
//*****************************************************************************************************************
// XFrame
//*****************************************************************************************************************
Reference< XFrame > SAL_CALL Frame::findFrame( const OUString& sTargetFrameName ,
sal_Int32 nSearchFlags ) throw( RuntimeException )
{
// Ready for multithreading
LOCK_MUTEX( aGuard, m_aMutex, "Frame::findFrame()" )
// Safe impossible cases
LOG_ASSERT( impldbg_checkParameter_findFrame( sTargetFrameName, nSearchFlags ), "Frame::findFrame()\nInvalid parameter detected.\n" )
// Set default return value if method failed.
Reference< XFrame > xSearchedFrame;
// Protection against recursion while searching in parent frames!
// See switch-statement eSIBLINGS, eALL for further informations.
if ( m_bRecursiveSearchProtection == sal_False )
{
// Use helper to classify search direction.
IMPL_ETargetClass eDirection = TargetFinder::classify( this ,
sTargetFrameName ,
nSearchFlags );
// Use returned recommendation to search right frame!
switch( eDirection )
{
case eSELF : {
xSearchedFrame = this;
}
break;
case ePARENT : {
xSearchedFrame = Reference< XFrame >( m_xParent, UNO_QUERY );
}
break;
case eUP : {
xSearchedFrame = m_xParent->findFrame( sTargetFrameName, nSearchFlags );
}
break;
case eDOWN : {
xSearchedFrame = TargetFinder::helpDownSearch( m_xFramesHelper, sTargetFrameName );
}
break;
case eSIBLINGS : {
m_bRecursiveSearchProtection = sal_True;
xSearchedFrame = m_xParent->findFrame( sTargetFrameName, FrameSearchFlag::CHILDREN );
m_bRecursiveSearchProtection = sal_False;
}
break;
case eALL : {
m_bRecursiveSearchProtection = sal_True;
xSearchedFrame = TargetFinder::helpDownSearch( m_xFramesHelper, sTargetFrameName );
if( xSearchedFrame.is() == sal_False )
{
xSearchedFrame = m_xParent->findFrame( sTargetFrameName, nSearchFlags );
}
m_bRecursiveSearchProtection = sal_False;
}
break;
}
}
// Return result of operation.
return xSearchedFrame;
}
/*TODO
If new implementation of findFrame/queryDispatch works correctly we can delete these old code!
//*****************************************************************************************************************
// XFrame
//*****************************************************************************************************************
Reference< XFrame > SAL_CALL Frame::findFrame( const OUString& sTargetFrameName ,
sal_Int32 nSearchFlags ) throw( RuntimeException )
{
// Ready for multithreading
LOCK_MUTEX( aGuard, m_aMutex, "Frame::findFrame()" )
// Safe impossible cases
LOG_ASSERT( impldbg_checkParameter_findFrame( sTargetFrameName, nSearchFlags ), "Frame::findFrame()\nInvalid parameter detected.\n" )
// Log some special informations about search. (Active in debug version only, if special mode is set!)
LOG_PARAMETER_FINDFRAME( "Frame", m_sName, sTargetFrameName, nSearchFlags )
// Set default return Value, if method failed
Reference< XFrame > xReturn = Reference< XFrame >();
// Protection against recursion while searching in parent frames!
// See search for PARENT for further informations.
if ( m_bRecursiveSearchProtection == sal_False )
{
//*************************************************************************************************************
// 1) Search for "_self" or ""!. We handle this as self too!
//*************************************************************************************************************
if (
( sTargetFrameName == FRAMETYPE_SELF ) ||
( sTargetFrameName.getLength() < 1 )
)
{
LOG_TARGETINGSTEP( "Frame", m_sName, "react to \"_self\" or \"\"" )
xReturn = Reference< XFrame >( static_cast< OWeakObject* >( this ), UNO_QUERY );
}
else
//*************************************************************************************************************
// 2) If "_top" searched and we have no parent set us for return himself.
//*************************************************************************************************************
if( sTargetFrameName == FRAMETYPE_TOP )
{
LOG_TARGETINGSTEP( "Frame", m_sName, "react to \"_top\"" )
if( m_xParent.is() == sal_False )
{
// If no parent well known we are the top frame!
LOG_TARGETINGSTEP( "Frame", m_sName, "no parent exist!" )
xReturn = Reference< XFrame >( static_cast< OWeakObject* >( this ), UNO_QUERY );
}
else
{
// If parent well kwnown we must forward searching to it.
LOG_TARGETINGSTEP( "Frame", m_sName, "parent exist!" )
xReturn = m_xParent->findFrame( FRAMETYPE_TOP, 0 );
}
}
else
//*************************************************************************************************************
// 3) If "_parent" searched and we have any one, set it for return.
//*************************************************************************************************************
if( sTargetFrameName == FRAMETYPE_PARENT )
{
LOG_TARGETINGSTEP( "Frame", m_sName, "react to \"_parent\"" )
if( m_xParent.is() == sal_True )
{
// If parent well kwnown we must return it as result.
LOG_TARGETINGSTEP( "Frame", m_sName, "parent exist!" )
xReturn = Reference< XFrame >( m_xParent, UNO_QUERY );
}
else
{
// Else we can't return anything and our default is used!
LOG_TARGETINGSTEP( "Frame", m_sName, "no parent exist!" )
}
}
else
//*************************************************************************************************************
// 4) Forward "_blank" to desktop. He can create new task only!
// (Look for existing parent!)
//*************************************************************************************************************
if( sTargetFrameName == FRAMETYPE_BLANK )
{
LOG_TARGETINGSTEP( "Frame", m_sName, "react to \"_blank\"" )
if( m_xParent.is() == sal_True )
{
LOG_TARGETINGSTEP( "Frame", m_sName, "forward \"_blank\" to parent" )
xReturn = m_xParent->findFrame( FRAMETYPE_BLANK, 0 );
}
else
{
// Else we cant create this new frame!
LOG_TARGETINGSTEP( "Frame", m_sName, "can create new frame for \"_blank\"" )
}
}
else
//*************************************************************************************************************
// ATTENTION!
// We have searched for special targets only ... but now we must search for any named frames and use search
// flags to do that!
//*************************************************************************************************************
{
//*********************************************************************************************************
// At first we must filter all other special target names!
// You can disable this statement if all these cases are handled before ...
//*********************************************************************************************************
// if (
// ( sTargetFrameName != FRAMETYPE_SELF ) &&
// ( sTargetFrameName != FRAMETYPE_PARENT) &&
// ( sTargetFrameName != FRAMETYPE_TOP ) &&
// ( sTargetFrameName != FRAMETYPE_BLANK ) &&
// ( sTargetFrameName.getLength() > 0 )
// )
{
//*****************************************************************************************************
// 5) If SELF searched and given name is the right one, we can return us as result.
//*****************************************************************************************************
if (
( nSearchFlags & FrameSearchFlag::SELF ) &&
( sTargetFrameName == m_sName )
)
{
LOG_TARGETINGSTEP( "Frame", m_sName, "react to SELF" )
xReturn = Reference< XFrame >( static_cast< OWeakObject* >( this ), UNO_QUERY );
}
//*****************************************************************************************************
// 6) If SELF searched and given name is the right one, we can return us as result.
//*****************************************************************************************************
if (
( xReturn.is() == sal_False ) &&
( nSearchFlags & FrameSearchFlag::PARENT ) &&
( m_xParent.is() == sal_True )
)
{
// We must protect us against searching from top to bottom!
m_bRecursiveSearchProtection = sal_True ;
LOG_TARGETINGSTEP( "Frame", m_sName, "forward PARENT to parent" )
xReturn = m_xParent->findFrame( sTargetFrameName, nSearchFlags );
m_bRecursiveSearchProtection = sal_False ;
}
//*************************************************************************************************************
// 7) Search for CHILDREN.
//*************************************************************************************************************
if (
( xReturn.is() == sal_False ) &&
( nSearchFlags & FrameSearchFlag::CHILDREN ) &&
( m_aChildFrameContainer.hasElements() == sal_True )
)
{
LOG_TARGETINGSTEP( "Frame", m_sName, "react to CHILDREN" )
// Search at own container of childframes if allowed.
// Lock the container. Nobody should append or remove elements during next time.
// But don't forget to unlock it again!
m_aChildFrameContainer.lock();
// First search only for direct subframes.
// Break loop, if something was found or all container items was compared.
sal_uInt32 nCount = m_aChildFrameContainer.getCount();
sal_uInt32 nPosition = 0;
while (
( xReturn.is() == sal_False ) &&
( nPosition < nCount )
)
{
xReturn = m_aChildFrameContainer[nPosition]->findFrame( sTargetFrameName, FrameSearchFlag::SELF );
++nPosition;
}
// If no direct subframe was found, search now subframes of subframes.
nPosition = 0;
while (
( xReturn.is() == sal_False ) &&
( nPosition < nCount )
)
{
xReturn = m_aChildFrameContainer[nPosition]->findFrame( sTargetFrameName, FrameSearchFlag::CHILDREN );
++nPosition;
}
// Don't forget to unlock the container!
m_aChildFrameContainer.unlock();
}
//*************************************************************************************************************
// 8) Search for SIBLINGS.
// Attention:
// Continue search on brothers ( subframes of parent ) but don't let them search their brothers too ...
// If FrameSearchFlag_CHILDREN is set, the children of the brothers will be searched also, otherwise not.
//*************************************************************************************************************
if (
( xReturn.is() == sal_False ) &&
( nSearchFlags & FrameSearchFlag::SIBLINGS ) &&
( m_xParent.is() == sal_True )
)
{
LOG_TARGETINGSTEP( "Frame", m_sName, "react to SIBLINGS" )
// Get all siblings from ouer parent and collect some informations about result set.
// Count of siblings, access to list ...
Reference< XFrames > xFrames = m_xParent->getFrames();
Sequence< Reference< XFrame > > seqFrames = xFrames->queryFrames( FrameSearchFlag::CHILDREN );
Reference< XFrame >* pArray = seqFrames.getArray();
sal_uInt16 nCount = (sal_uInt16)seqFrames.getLength();
Reference< XFrame > xThis ( (OWeakObject*)this, UNO_QUERY );
Reference< XFrame > xSearchFrame;
// Search siblings "pure" - no search on brothers of brothers - no search at children of siblings!
// Break loop, if something was found or all items was threated.
sal_uInt16 nPosition = 0;
while (
( xReturn.is() == sal_False ) &&
( nPosition < nCount )
)
{
// Exclude THIS frame! We are a child of ouer parent and exist in result list of "queryFrames()" too.
if ( pArray[nPosition] != xThis )
{
xReturn = pArray[nPosition]->findFrame( sTargetFrameName, FrameSearchFlag::SELF );
}
++nPosition;
}
// If no sibling match ouer search, try it again with children of ouer siblings.
nPosition = 0;
while (
( xReturn.is() == sal_False ) &&
( nPosition < nCount )
)
{
// Exclude THIS frame again.
if ( pArray[nPosition] != xThis )
{
xReturn = pArray[nPosition]->findFrame( sTargetFrameName, FrameSearchFlag::CHILDREN );
}
++nPosition;
}
}
//*************************************************************************************************************
// 9) Search for TASKS.
// Attention:
// The Task-implementation control these flag too! But if search started from the bottom of the tree, we must
// forward it to ouer parents. They can be tasks only!
//*************************************************************************************************************
if (
( xReturn.is() == sal_False ) &&
( nSearchFlags & FrameSearchFlag::TASKS ) &&
( m_xParent.is() == sal_True )
)
{
// We must protect us against recursive calls from top to bottom.
m_bRecursiveSearchProtection = sal_True ;
LOG_TARGETINGSTEP( "Frame", m_sName, "forward TASKS to parent" )
xReturn = m_xParent->findFrame( sTargetFrameName, nSearchFlags );
m_bRecursiveSearchProtection = sal_False;
}
//*************************************************************************************************************
// 10) If CREATE is set we must forward call to desktop. He is the only one, who can do that.
//*************************************************************************************************************
// Praeprozessor Bug!
// Wenn nach CREATE ein Space steht wird versucht es durch das Define CREATE aus tools/rtti.hxx zu ersetzen
// was fehlschlaegt und die naechsten 3 Klammern ")){" unterschlaegt!
// Dann meckert der Compiler das natuerlich an ...
if((xReturn.is()==sal_False)&&(nSearchFlags&FrameSearchFlag::CREATE)&&(m_xParent.is()==sal_True))
{
LOG_TARGETINGSTEP( "Frame", m_sName, "forward CREATE to parent" )
xReturn = m_xParent->findFrame( sTargetFrameName, FrameSearchFlag::CREATE );
}
}
}
}
// Log some special informations about search. (Active in debug version only, if special mode is set!)
LOG_RESULT_FINDFRAME( "Frame", m_sName, xReturn )
// Return with result of operation.
return xReturn;
}
*/
//*****************************************************************************************************************
// XFrame
//*****************************************************************************************************************
sal_Bool SAL_CALL Frame::isTop() throw( RuntimeException )
{
// Ready for multithreading
LOCK_MUTEX( aGuard, m_aMutex, "Frame::isTop()" )
// Return state of this instance.
// This information is set in setCreator()!
// We are top, if ouer parent is a task or the desktop.
return m_bIsFrameTop;
}
//*****************************************************************************************************************
// XFrame
//*****************************************************************************************************************
void SAL_CALL Frame::activate() throw( RuntimeException )
{
// Ready for multithreading
LOCK_MUTEX( aGuard, m_aMutex, "Frame::activate()" )
// Get the current active child frame.
Reference< XFrame > xActiveChild = m_aChildFrameContainer.getActive();
//_____________________________________________________________________________________________________________
// 1)
// If I'am not active before ...
if ( m_eActiveState == INACTIVE )
{
// ... do it then.
m_eActiveState = ACTIVE;
// Deactivate sibling path and forward activation to parent ... if any parent exist!
if ( m_xParent.is() == sal_True )
{
// Everytime set THIS frame as active child of parent and activate it.
// We MUST have a valid path from bottom to top as active path!
// But we must deactivate the old active sibling path first.
// Attention: Deactivation of an active path, deactivate the whole path ... from bottom to top!
// But we wish to deactivate founded sibling-tree only.
// [ see deactivate() / step 4) for further informations! ]
m_xParent->setActiveFrame( this );
// Then we can activate from here to top.
// Attention: We are ACTIVE now. And the parent will call activate() at us!
// But we do nothing then! We are already activated.
m_xParent->activate();
}
// Its neccessary to send event NOW - not before.
// Activation goes from bottom to top!
// Thats the reason to activate parent first and send event now.
impl_sendFrameActionEvent( FrameAction_FRAME_ACTIVATED );
}
//_____________________________________________________________________________________________________________
// 2)
// Else;
// I was active before or current activated and there is a path from here to bottom, who CAN be active.
// But ouer direct child of path is not active yet.
// (It can be, if activation occur in the middle of a current path!)
// In these case we activate path to bottom to set focus on right frame!
if (
( m_eActiveState == ACTIVE ) &&
( xActiveChild.is() == sal_True ) &&
( xActiveChild->isActive() == sal_False )
)
{
xActiveChild->activate();
}
//_____________________________________________________________________________________________________________
// 3)
// I was active before or current activated. But if i have no active child => i will become the focus!
if (
( m_eActiveState == ACTIVE ) &&
( xActiveChild.is() == sal_False )
)
{
// Set FOCUS-state and send event to all listener.
// if( m_xComponentWindow.is() == sal_True )
// {
// m_xComponentWindow->setFocus();
// }
m_eActiveState = FOCUS;
impl_sendFrameActionEvent( FrameAction_FRAME_UI_ACTIVATED );
}
}
//*****************************************************************************************************************
// XFrame
//*****************************************************************************************************************
void SAL_CALL Frame::deactivate() throw( RuntimeException )
{
// Ready for multithreading
LOCK_MUTEX( aGuard, m_aMutex, "Frame::deactivate()" )
// Work only, if there something to do!
if ( m_eActiveState != INACTIVE )
{
//_____________________________________________________________________________________________________________
// 1)
// Deactivate all active childs.
Reference< XFrame > xActiveChild = m_aChildFrameContainer.getActive();
if (( xActiveChild.is() == sal_True ) && ( xActiveChild->isActive() == sal_True ))
{
xActiveChild->deactivate();
}
//_____________________________________________________________________________________________________________
// 2)
// If i have the focus - i will lost it now.
if ( m_eActiveState == FOCUS )
{
// Set new state INACTIVE(!) and send message to all listener.
// Don't set ACTIVE as new state. This frame is deactivated for next time - due to activate().
m_eActiveState = ACTIVE;
impl_sendFrameActionEvent( FrameAction_FRAME_UI_DEACTIVATING );
}
//_____________________________________________________________________________________________________________
// 3)
// If i'am active - i will be deactivated now.
if ( m_eActiveState == ACTIVE )
{
// Set new state and send message to all listener.
m_eActiveState = INACTIVE;
impl_sendFrameActionEvent( FrameAction_FRAME_DEACTIVATING );
}
//_____________________________________________________________________________________________________________
// 4)
// If there is a path from here to my parent ...
// ... I'am on the top or in the middle of deactivated subtree and action was started here.
// I must deactivate all frames from here to top, which are members of current path.
// Stop, if THESE frame not the active frame of ouer parent!
Reference< XFrame > xTHIS( (OWeakObject*)this, UNO_QUERY );
if (
( m_xParent.is() == sal_True ) &&
( m_xParent->getActiveFrame() == xTHIS )
)
{
// We MUST break the path - otherwise we will get the focus - not ouer parent! ...
// Attention: Ouer parent don't call us again - WE ARE NOT ACTIVE YET!
// [ see step 3 and condition "if ( m_eActiveState!=INACTIVE ) ..." in this method! ]
m_xParent->deactivate();
}
}
}
//*****************************************************************************************************************
// XFrame
//*****************************************************************************************************************
sal_Bool SAL_CALL Frame::isActive() throw( RuntimeException )
{
// Ready for multithreading
LOCK_MUTEX( aGuard, m_aMutex, "Frame::isActive()" )
// Set default return value to NO.
sal_Bool bReturn = sal_False;
// If i'am a member of the current active path ... reset return value to YES.
if (
( m_eActiveState == ACTIVE ) ||
( m_eActiveState == FOCUS )
)
{
bReturn = sal_True;
}
// Return result of this operation.
return bReturn;
}
//*****************************************************************************************************************
// XFrame
//*****************************************************************************************************************
sal_Bool SAL_CALL Frame::setComponent( const Reference< awt::XWindow >& xComponentWindow ,
const Reference< XController >& xController ) throw( RuntimeException )
{
/* HACK for sfx2! */
if ( xController.is() && !xComponentWindow.is() )
return sal_False;
/* HACK for sfx2! */
// mutex should be locked as short as possible, because otherwise deadlocks in multithreaded environments
// are guaranteed, because (de)registering listeners or disposing a VCL componente always tries to get
// the solar mutex; if this mutex is hold in another thread, this thread would be blocked if it tried to
// access this frame ( f.e. when a focus lost event should be processed )
LOCK_MUTEX( aGuard, m_aMutex, "Frame::setComponent()" )
LOG_ASSERT( impldbg_checkParameter_setComponent( xComponentWindow, xController ), "Frame::setComponent()\nInvalid parameter detected.\n" )
// always release controller before releasing window, because controller may want to access its window
sal_Bool bNewController = ( m_xController != xController );
sal_Bool bNewWindow = ( m_xComponentWindow != xComponentWindow );
sal_Bool bHasController = m_xController.is();
sal_Bool bHasWindow = m_xComponentWindow.is();
UNLOCK_MUTEX( aGuard, "Frame::setComponent()" )
// Release current component, if there is any
if ( bHasController || bHasWindow )
{
// Send FrameAction event to all listeners
impl_sendFrameActionEvent( FrameAction_COMPONENT_DETACHING );
}
if( bNewController == sal_True )
{
impl_setController( Reference< XController >() );
}
if( bNewWindow == sal_True )
{
impl_setComponentWindow( xComponentWindow );
}
if( bNewController == sal_True )
{
impl_setController( xController );
}
// Send FrameActionEvent to all listeners
if (
( xController.is() == sal_True ) ||
( xComponentWindow.is() == sal_True )
)
{
if ( m_bConnected == sal_True )
{
impl_sendFrameActionEvent( FrameAction_COMPONENT_REATTACHED );
}
else
{
impl_sendFrameActionEvent( FrameAction_COMPONENT_ATTACHED );
}
}
m_bConnected = sal_True;
// A new component doesn't know anything about current active/focus states
if (
( m_eActiveState == FOCUS ) &&
( m_xComponentWindow.is() == sal_True )
)
{
m_xComponentWindow->setFocus();
}
return sal_True;
}
//*****************************************************************************************************************
// XFrame
//*****************************************************************************************************************
Reference< awt::XWindow > SAL_CALL Frame::getComponentWindow() throw( RuntimeException )
{
// Ready for multithreading
LOCK_MUTEX( aGuard, m_aMutex, "Frame::getComponentWindow()" )
return m_xComponentWindow;
}
//*****************************************************************************************************************
// XFrame
//*****************************************************************************************************************
Reference< XController > SAL_CALL Frame::getController() throw( RuntimeException )
{
// Ready for multithreading
LOCK_MUTEX( aGuard, m_aMutex, "Frame::getController()" )
// Return current controller.
return m_xController;
}
//*****************************************************************************************************************
// XFrame
//*****************************************************************************************************************
void SAL_CALL Frame::contextChanged() throw( RuntimeException )
{
// Ready for multithreading
LOCK_MUTEX( aGuard, m_aMutex, "Frame::contextChanged()" )
// Send event to all istener for frame actions.
impl_sendFrameActionEvent( FrameAction_CONTEXT_CHANGED );
}
//*****************************************************************************************************************
// XFrame
//*****************************************************************************************************************
void SAL_CALL Frame::addFrameActionListener( const Reference< XFrameActionListener >& xListener ) throw( RuntimeException )
{
// Ready for multithreading
LOCK_MUTEX( aGuard, m_aMutex, "Frame::addFrameActionListener()" )
// Safe impossible cases
LOG_ASSERT( impldbg_checkParameter_addFrameActionListener( xListener ), "Frame::addFrameActionListener()\nInvalid parameter detected.\n" )
// Add listener to container
m_aListenerContainer.addInterface( ::getCppuType( ( const Reference< XFrameActionListener >* ) NULL ), xListener );
}
//*****************************************************************************************************************
// XFrame
//*****************************************************************************************************************
void SAL_CALL Frame::removeFrameActionListener( const Reference< XFrameActionListener >& xListener ) throw( RuntimeException )
{
// Ready for multithreading
LOCK_MUTEX( aGuard, m_aMutex, "Frame::removeFrameActionListener()" )
// Safe impossible cases
LOG_ASSERT( impldbg_checkParameter_removeFrameActionListener( xListener ), "Frame::removeFrameActionListener()\nInvalid parameter detected.\n" )
// Rmove listener from container
m_aListenerContainer.removeInterface( ::getCppuType( ( const Reference< XFrameActionListener >* ) NULL ), xListener );
}
//*****************************************************************************************************************
// XComponent
//*****************************************************************************************************************
void SAL_CALL Frame::dispose() throw( RuntimeException )
{
Reference < XFrame > xThis( this );
// mutex should be locked as short as possible, because otherwise deadlocks in multithreaded environments
// are guaranteed, because (de)registering listeners or disposing a VCL componente always tries to get
// the solar mutex; if this mutex is hold in another thread, this thread would be blocked if it tried to
// access this frame ( f.e. when a focus lost event should be processed )
LOCK_MUTEX( aGuard, m_aMutex, "Frame::dispose()" )
// Protection against recursive disposing!
if ( m_bAlreadyDisposed == sal_False )
{
// Set flag against recursive or following calls.
m_bAlreadyDisposed = sal_True ;
UNLOCK_MUTEX( aGuard, "Frame::dispose()" )
// Send message to all DISPOSE-listener.
impl_sendDisposeEvent();
// Delete current component and controller.
setComponent( Reference< awt::XWindow >(), Reference< XController >() );
EventObject aEvent;
aEvent.Source = xThis;
m_aListenerContainer.disposeAndClear( aEvent );
LOCK_MUTEX( anotherGuard, m_aMutex, "Frame::dispose()" )
// Force parent container to forget this frame.
// ( It's contained in m_xParent and so no XEventListener for m_xParent! )
if ( m_xParent.is() == sal_True )
{
m_xParent->getFrames()->remove( xThis );
m_xParent = Reference< XFramesSupplier >();
}
// Release current indicator factory helper.
m_xIndicatorFactoryHelper = Reference< XStatusIndicatorFactory >();
// If we have our own window ... release it!
if ( m_xContainerWindow.is() == sal_True )
{
impl_setContainerWindow( Reference< awt::XWindow >() );
}
// Forget global servicemanager
m_xFactory = Reference< XMultiServiceFactory >();
// Free memory for container and other helper.
m_aChildFrameContainer.clear();
m_xFramesHelper = Reference< XFrames >();
m_xDispatchHelper = Reference< XDispatchProvider >();
// Reset flags and other members ...
m_eActiveState = DEFAULT_EACTIVESTATE ;
m_bRecursiveSearchProtection = DEFAULT_BRECURSIVESEARCHPROTECTION;
m_bIsFrameTop = DEFAULT_BISFRAMETOP ;
m_bConnected = DEFAULT_BCONNECTED ;
m_sName = DEFAULT_SNAME ;
}
}
//*****************************************************************************************************************
// XComponent
//*****************************************************************************************************************
void SAL_CALL Frame::addEventListener( const Reference< XEventListener >& xListener ) throw( RuntimeException )
{
// Ready for multithreading
LOCK_MUTEX( aGuard, m_aMutex, "Frame::addEventListener()" )
// Safe impossible cases
LOG_ASSERT( impldbg_checkParameter_addEventListener( xListener ), "Frame::addEventListener()\nInvalid parameter detected.\n" )
// Add listener to container.
m_aListenerContainer.addInterface( ::getCppuType( ( const Reference< XEventListener >* ) NULL ), xListener );
}
//*****************************************************************************************************************
// XComponent
//*****************************************************************************************************************
void SAL_CALL Frame::removeEventListener( const Reference< XEventListener >& xListener ) throw( RuntimeException )
{
// Ready for multithreading
LOCK_MUTEX( aGuard, m_aMutex, "Frame::removeEventListener()" )
// Safe impossible cases
LOG_ASSERT( impldbg_checkParameter_removeEventListener( xListener ), "Frame::removeEventListener()\nInvalid parameter detected.\n" )
// Add listener to container.
m_aListenerContainer.removeInterface( ::getCppuType( ( const Reference< XEventListener >* ) NULL ), xListener );
}
//*****************************************************************************************************************
// XEventListener
//*****************************************************************************************************************
void SAL_CALL Frame::disposing( const EventObject& aEvent ) throw( RuntimeException )
{
// Ready for multithreading
LOCK_MUTEX( aGuard, m_aMutex, "Frame::disposing()" )
// Safe impossible cases
LOG_ASSERT( impldbg_checkParameter_disposing( aEvent ), "Frame::disposing()\nInvalid parameter detected.\n" )
// This instance is forced to release references to the specified interfaces by event-source.
if ( aEvent.Source == m_xContainerWindow )
{
impl_setContainerWindow( Reference< awt::XWindow >() );
}
}
//*****************************************************************************************************************
// XFocusListener
//*****************************************************************************************************************
void SAL_CALL Frame::focusGained( const awt::FocusEvent& aEvent ) throw( RuntimeException )
{
// Ready for multithreading
LOCK_MUTEX( aGuard, m_aMutex, "Frame::focusGained()" )
// Safe impossible cases
LOG_ASSERT( impldbg_checkParameter_focusGained( aEvent ), "Frame::focusGained()\nInvalid parameter detected.\n" )
/*
// We must safe this new state, send event to listener ...
m_eActiveState = FOCUS;
impl_sendFrameActionEvent( FrameAction_FRAME_UI_ACTIVATED );
// ... and forward our new focus to our component window!
if( m_xComponentWindow.is() == sal_True )
{
m_xComponentWindow->setFocus();
}
*/
if( m_xComponentWindow.is() == sal_True )
{
m_xComponentWindow->setFocus();
}
}
//*****************************************************************************************************************
// XFocusListener
//*****************************************************************************************************************
void SAL_CALL Frame::focusLost( const awt::FocusEvent& aEvent ) throw( RuntimeException )
{
// Ready for multithreading
LOCK_MUTEX( aGuard, m_aMutex, "Frame::focusLost()" )
// Safe impossible cases
LOG_ASSERT( impldbg_checkParameter_focusLost( aEvent ), "Frame::focusLost()\nInvalid parameter detected.\n" )
/*
// We must send UI_DEACTIVATING to our listener and forget our current FOCUS state!
m_eActiveState = ACTIVE;
impl_sendFrameActionEvent( FrameAction_FRAME_UI_DEACTIVATING );
*/
}
//*****************************************************************************************************************
// private method
//*****************************************************************************************************************
void Frame::impl_setContainerWindow( const Reference< awt::XWindow >& xWindow )
{
// mutex should be locked as short as possible, because otherwise deadlocks in multithreaded environments
// are guaranteed, because (de)registering listeners or disposing a VCL componente always tries to get
// the solar mutex; if this mutex is hold in another thread, this thread would be blocked if it tried to
// access this frame ( f.e. when a focus lost event should be processed )
LOCK_MUTEX( aGuard, m_aMutex, "Frame::impl_setContainerWindow()" )
// Remember old window; dispose later to avoid flickering.
Reference< awt::XWindow > xOld = m_xContainerWindow;
// Save new window reference
m_xContainerWindow = xWindow;
UNLOCK_MUTEX( aGuard, "Frame::impl_setContainerWindow()" )
// Remove this instance from old WindowListener container.
if ( xOld.is() == sal_True )
{
xOld->removeWindowListener( this );
xOld->removeFocusListener( this );
}
// Register this instance as new listener.
if ( xWindow.is() == sal_True )
{
xWindow->addWindowListener( this );
xWindow->addFocusListener( this );
// if possible register as TopWindowListener
Reference< awt::XTopWindow > xTopWindow( xWindow, UNO_QUERY );
if ( xTopWindow.is() == sal_True )
xTopWindow->addTopWindowListener( this );
}
// Dispose old window now
if ( xOld.is() == sal_True )
{
// All VclComponents are XComponents; so call dispose before discarding
// a Reference< XVclComponent >, because this frame is the owner of the window
xOld->setVisible( sal_False );
xOld->dispose();
}
}
//*****************************************************************************************************************
// private method
//*****************************************************************************************************************
void Frame::impl_setComponentWindow( const Reference< awt::XWindow >& xWindow )
{
LOCK_MUTEX( aGuard, m_aMutex, "Frame::impl_setComponentWindow()" )
// Work only, if window will changing.
if ( xWindow != m_xComponentWindow )
{
// Remember old component; dispose later to avoid flickering.
Reference< awt::XWindow > xOld = m_xComponentWindow;
// Take the new one.
m_xComponentWindow = xWindow;
UNLOCK_MUTEX( aGuard, "Frame::impl_setComponentWindow()" )
// Set correct size before showing the window.
impl_resizeComponentWindow();
// Destroy old window.
if ( xOld.is() == sal_True )
{
// All VclComponents are XComponents; so call dispose before discarding
// a Reference< XVclComponent >, because this frame is the owner of the Component.
xOld->dispose();
}
}
}
//*****************************************************************************************************************
// private method
//*****************************************************************************************************************
void Frame::impl_setController( const Reference< XController >& xController )
{
LOCK_MUTEX( aGuard, m_aMutex, "Frame::impl_setController()" )
// Safe old value for disposing AFTER set of new controller!
Reference< XController > xOld = m_xController;
// Take the new one.
m_xController = xController;
UNLOCK_MUTEX( aGuard, "Frame::impl_setController()" )
// Dispose old instance.
if ( xOld.is() == sal_True )
{
xOld->dispose();
}
}
//*****************************************************************************************************************
// private method
//*****************************************************************************************************************
void Frame::impl_sendFrameActionEvent( const FrameAction& aAction )
{
// Log informations about order of events to file!
// (only activated in debug version!)
LOG_FRAMEACTIONEVENT( "Frame", m_sName, aAction )
// Send FrameAction event to all listener.
// Get container for right listener.
OInterfaceContainerHelper* pContainer = m_aListenerContainer.getContainer( ::getCppuType( ( const Reference< XFrameActionListener >*) NULL ) );
if ( pContainer != NULL )
{
// Build action event.
FrameActionEvent aFrameActionEvent( (OWeakObject*)this, this, aAction );
// Get iterator for access to listener.
OInterfaceIteratorHelper aIterator( *pContainer );
// Send message to all listener.
while ( aIterator.hasMoreElements() == sal_True )
{
((XFrameActionListener *)aIterator.next())->frameAction( aFrameActionEvent );
}
}
}
//*****************************************************************************************************************
// private method
//*****************************************************************************************************************
void Frame::impl_sendDisposeEvent()
{
// Log informations about order of events to file!
// (only activated in debug version!)
LOG_DISPOSEEVENT( "Frame", m_sName )
// Send event to all listener.
// Get container for right listener.
OInterfaceContainerHelper* pContainer = m_aListenerContainer.getContainer( ::getCppuType( ( const Reference< XEventListener >*) NULL ) );
if ( pContainer != NULL )
{
// Build event.
EventObject aEvent( (OWeakObject*)this );
// Get iterator for access to listener.
OInterfaceIteratorHelper aIterator( *pContainer );
// Send message to all listener.
while ( aIterator.hasMoreElements() == sal_True )
{
((XEventListener*)aIterator.next())->disposing( aEvent );
}
}
}
//*****************************************************************************************************************
// private method
//*****************************************************************************************************************
sal_Bool Frame::impl_willFrameTop( const REFERENCE< XFRAMESSUPPLIER >& xParent )
{
// Set default return value.
sal_Bool bWillFrameTop = sal_False;
// This frame is a topframe, if ouer parent is a task, the desktop or no parent exist!
// Cast parent to right interfaces ...
Reference< XTask > xIsTask ( xParent, UNO_QUERY );
Reference< XDesktop > xIsDesktop ( xParent, UNO_QUERY );
// ... and control it.
if (
( xIsTask.is() == sal_True ) ||
( xIsDesktop.is() == sal_True ) ||
( m_xParent.is() == sal_False )
)
{
bWillFrameTop = sal_True;
}
// Return result of this operation.
return bWillFrameTop;
}
//*****************************************************************************************************************
// private method
//*****************************************************************************************************************
void Frame::impl_resizeComponentWindow()
{
// Work only if container window is set!
if (
( m_xContainerWindow.is() == sal_True ) &&
( m_xComponentWindow.is() == sal_True )
)
{
// Get reference to his device.
Reference< awt::XDevice > xDevice( m_xContainerWindow, UNO_QUERY );
// Convert relativ size to output size.
awt::Rectangle aRectangle = m_xContainerWindow->getPosSize();
awt::DeviceInfo aInfo = xDevice->getInfo();
awt::Size aSize ( aRectangle.Width - aInfo.LeftInset - aInfo.RightInset ,
aRectangle.Height - aInfo.TopInset - aInfo.BottomInset );
// Resize ouer component window.
m_xComponentWindow->setPosSize( 0, 0, aSize.Width, aSize.Height, awt::PosSize::SIZE );
}
}
//_________________________________________________________________________________________________________________
// debug methods
//_________________________________________________________________________________________________________________
/*-----------------------------------------------------------------------------------------------------------------
The follow methods checks the parameter for other functions. If a parameter or his value is non valid,
we return "sal_False". (else sal_True) This mechanism is used to throw an ASSERT!
ATTENTION
If you miss a test for one of this parameters, contact the autor or add it himself !(?)
But ... look for right testing! See using of this methods!
-----------------------------------------------------------------------------------------------------------------*/
#ifdef ENABLE_ASSERTIONS
//*****************************************************************************************************************
// append() accept valid references and pure frames only! No tasks or desktops.
sal_Bool Frame::impldbg_checkParameter_append( const Reference< XFrame >& xFrame )
{
// Set default return value.
sal_Bool bOK = sal_True;
// Check parameter.
if (
( &xFrame == NULL ) ||
( xFrame.is() == sal_False ) ||
( (Reference< XTask >( xFrame, UNO_QUERY )).is() == sal_True ) ||
( (Reference< XDesktop >( xFrame, UNO_QUERY )).is() == sal_True )
)
{
bOK = sal_False ;
}
// Return result of check.
return bOK ;
}
//*****************************************************************************************************************
// queryFrames() accept valid searchflags only. If a new one will exist, we know it, if this check failed!
sal_Bool Frame::impldbg_checkParameter_queryFrames( sal_Int32 nSearchFlags )
{
// Set default return value.
sal_Bool bOK = sal_True;
// Check parameter.
if (
( nSearchFlags != FrameSearchFlag::AUTO ) &&
( !( nSearchFlags & FrameSearchFlag::PARENT ) ) &&
( !( nSearchFlags & FrameSearchFlag::SELF ) ) &&
( !( nSearchFlags & FrameSearchFlag::CHILDREN ) ) &&
( !( nSearchFlags & FrameSearchFlag::CREATE ) ) &&
( !( nSearchFlags & FrameSearchFlag::SIBLINGS ) ) &&
( !( nSearchFlags & FrameSearchFlag::TASKS ) ) &&
( !( nSearchFlags & FrameSearchFlag::ALL ) ) &&
( !( nSearchFlags & FrameSearchFlag::GLOBAL ) )
)
{
bOK = sal_False ;
}
// Return result of check.
return bOK ;
}
//*****************************************************************************************************************
// remove() accept valid references and pure frames only! No tasks or desktops.
sal_Bool Frame::impldbg_checkParameter_remove( const Reference< XFrame >& xFrame )
{
// Set default return value.
sal_Bool bOK = sal_True;
// Check parameter.
if (
( &xFrame == NULL ) ||
( xFrame.is() == sal_False ) ||
( (Reference< XTask >( xFrame, UNO_QUERY )).is() == sal_True ) ||
( (Reference< XDesktop >( xFrame, UNO_QUERY )).is() == sal_True )
)
{
bOK = sal_False ;
}
// Return result of check.
return bOK ;
}
//*****************************************************************************************************************
// Its allowed to reset the active frame membervariable with a NULL-Reference but not with a NULL-pointer!
// And we accept frames only! No tasks and desktops!
sal_Bool Frame::impldbg_checkParameter_setActiveFrame( const Reference< XFrame >& xFrame )
{
// Set default return value.
sal_Bool bOK = sal_True;
// Check parameter.
if ( &xFrame == NULL )
{
bOK = sal_False ;
}
else
if (
( (Reference< XTask >( xFrame, UNO_QUERY )).is() == sal_True ) ||
( (Reference< XDesktop >( xFrame, UNO_QUERY )).is() == sal_True )
)
{
bOK = sal_False ;
}
// Return result of check.
return bOK ;
}
//*****************************************************************************************************************
sal_Bool Frame::impldbg_checkParameter_updateViewData( const Any& aValue )
{
// Set default return value.
sal_Bool bOK = sal_True;
// Check parameter.
if (
( &aValue == NULL ) ||
( aValue.hasValue() == sal_False )
//ASMUSS Wenn der Typ noch bekannt ist, dann auch den abfragen!
)
{
bOK = sal_False ;
}
// Return result of check.
return bOK ;
}
//*****************************************************************************************************************
sal_Bool Frame::impldbg_checkParameter_createNewEntry( const OUString& sURL ,
const Sequence< PropertyValue >& seqArguments,
const OUString& sTitle )
{
// Set default return value.
sal_Bool bOK = sal_True;
// Check parameter.
if (
( &sURL == NULL ) ||
( sURL.getLength() < 1 ) ||
( &seqArguments == NULL ) ||
( seqArguments.getLength() < 1 ) ||
( &sTitle == NULL ) ||
( sTitle.getLength() < 1 )
)
{
bOK = sal_False ;
}
// Return result of check.
return bOK ;
}
//*****************************************************************************************************************
sal_Bool Frame::impldbg_checkParameter_windowResized( const awt::WindowEvent& aEvent )
{
// Set default return value.
sal_Bool bOK = sal_True;
// Check parameter.
if (
( &aEvent == NULL )
)
{
bOK = sal_False ;
}
// Return result of check.
return bOK ;
}
//*****************************************************************************************************************
sal_Bool Frame::impldbg_checkParameter_windowActivated( const EventObject& aEvent )
{
// Set default return value.
sal_Bool bOK = sal_True;
// Check parameter.
if (
( &aEvent == NULL )
)
{
bOK = sal_False ;
}
// Return result of check.
return bOK ;
}
//*****************************************************************************************************************
sal_Bool Frame::impldbg_checkParameter_windowDeactivated( const EventObject& aEvent )
{
// Set default return value.
sal_Bool bOK = sal_True;
// Check parameter.
if (
( &aEvent == NULL )
)
{
bOK = sal_False ;
}
// Return result of check.
return bOK ;
}
//*****************************************************************************************************************
sal_Bool Frame::impldbg_checkParameter_initialize( const Reference< awt::XWindow >& xWindow )
{
// Set default return value.
sal_Bool bOK = sal_True;
// Check parameter.
if (
( &xWindow == NULL ) ||
( xWindow.is() == sal_False )
)
{
bOK = sal_False ;
}
// Return result of check.
return bOK ;
}
//*****************************************************************************************************************
sal_Bool Frame::impldbg_checkParameter_setCreator( const Reference< XFramesSupplier >& xCreator )
{
// Set default return value.
sal_Bool bOK = sal_True;
// Check parameter.
if (
( &xCreator == NULL ) ||
( xCreator.is() == sal_False )
)
{
bOK = sal_False ;
}
// Return result of check.
return bOK ;
}
//*****************************************************************************************************************
// An empty name is not fine but allowed ... !
sal_Bool Frame::impldbg_checkParameter_setName( const OUString& sName )
{
// Set default return value.
sal_Bool bOK = sal_True;
// Check parameter.
if (
( &sName == NULL )
)
{
bOK = sal_False ;
}
// Return result of check.
return bOK ;
}
//*****************************************************************************************************************
sal_Bool Frame::impldbg_checkParameter_findFrame( const OUString& sTargetFrameName ,
sal_Int32 nSearchFlags )
{
// Set default return value.
sal_Bool bOK = sal_True;
// Check parameter.
if (
( &sTargetFrameName == NULL ) ||
// sTargetFrameName can be ""!
(
( nSearchFlags != FrameSearchFlag::AUTO ) &&
( !( nSearchFlags & FrameSearchFlag::PARENT ) ) &&
( !( nSearchFlags & FrameSearchFlag::SELF ) ) &&
( !( nSearchFlags & FrameSearchFlag::CHILDREN ) ) &&
( !( nSearchFlags & FrameSearchFlag::CREATE ) ) &&
( !( nSearchFlags & FrameSearchFlag::SIBLINGS ) ) &&
( !( nSearchFlags & FrameSearchFlag::TASKS ) ) &&
( !( nSearchFlags & FrameSearchFlag::ALL ) ) &&
( !( nSearchFlags & FrameSearchFlag::GLOBAL ) )
)
)
{
bOK = sal_False ;
}
// Return result of check.
return bOK ;
}
//*****************************************************************************************************************
sal_Bool Frame::impldbg_checkParameter_setComponent( const Reference< awt::XWindow >& xComponentWindow ,
const Reference< XController >& xController )
{
// Set default return value.
sal_Bool bOK = sal_True;
// Check parameter.
if (
( &xComponentWindow == NULL ) ||
( &xController == NULL )
)
{
bOK = sal_False ;
}
// Return result of check.
return bOK ;
}
//*****************************************************************************************************************
sal_Bool Frame::impldbg_checkParameter_addFrameActionListener( const Reference< XFrameActionListener >& xListener )
{
// Set default return value.
sal_Bool bOK = sal_True;
// Check parameter.
if (
( &xListener == NULL ) ||
( xListener.is() == sal_False )
)
{
bOK = sal_False ;
}
// Return result of check.
return bOK ;
}
//*****************************************************************************************************************
sal_Bool Frame::impldbg_checkParameter_removeFrameActionListener( const Reference< XFrameActionListener >& xListener )
{
// Set default return value.
sal_Bool bOK = sal_True;
// Check parameter.
if (
( &xListener == NULL ) ||
( xListener.is() == sal_False )
)
{
bOK = sal_False ;
}
// Return result of check.
return bOK ;
}
//*****************************************************************************************************************
sal_Bool Frame::impldbg_checkParameter_addEventListener( const Reference< XEventListener >& xListener )
{
// Set default return value.
sal_Bool bOK = sal_True;
// Check parameter.
if (
( &xListener == NULL ) ||
( xListener.is() == sal_False )
)
{
bOK = sal_False ;
}
// Return result of check.
return bOK ;
}
//*****************************************************************************************************************
sal_Bool Frame::impldbg_checkParameter_removeEventListener( const Reference< XEventListener >& xListener )
{
// Set default return value.
sal_Bool bOK = sal_True;
// Check parameter.
if (
( &xListener == NULL ) ||
( xListener.is() == sal_False )
)
{
bOK = sal_False ;
}
// Return result of check.
return bOK ;
}
//*****************************************************************************************************************
sal_Bool Frame::impldbg_checkParameter_disposing( const EventObject& aEvent )
{
// Set default return value.
sal_Bool bOK = sal_True;
// Check parameter.
if (
( &aEvent == NULL ) ||
( aEvent.Source.is() == sal_False )
)
{
bOK = sal_False ;
}
// Return result of check.
return bOK ;
}
//*****************************************************************************************************************
sal_Bool Frame::impldbg_checkParameter_focusGained( const awt::FocusEvent& aEvent )
{
// Set default return value.
sal_Bool bOK = sal_True;
// Check parameter.
if (
( &aEvent == NULL )
)
{
bOK = sal_False ;
}
// Return result of check.
return bOK ;
}
//*****************************************************************************************************************
sal_Bool Frame::impldbg_checkParameter_focusLost( const awt::FocusEvent& aEvent )
{
// Set default return value.
sal_Bool bOK = sal_True;
// Check parameter.
if (
( &aEvent == NULL )
)
{
bOK = sal_False ;
}
// Return result of check.
return bOK ;
}
#endif // #ifdef ENABLE_ASSERTIONS
/*-----------------------------------------------------------------------------------------------------------------
Follow method is used to print out the content of current container.
Use this to get information about the tree.
-----------------------------------------------------------------------------------------------------------------*/
#ifdef ENABLE_SERVICEDEBUG // Is defined in debug version only.
//*****************************************************************************************************************
OUString Frame::impldbg_getTreeNames( sal_Int16 nLevel )
{
// Create an "empty stream" with enough place for ouer own container informations.
OUStringBuffer sOutPut(1024);
// Add my own information to stream.
// Format of output : "<Level*TAB>[<level>:<name>:<extra informations>]\n"
// Add "<Level*TAB>"
for ( sal_Int8 nTabCount=1; nTabCount<=nLevel; ++nTabCount )
{
sOutPut.appendAscii( "\t" );
}
// Add "[<level>:<name>:"
sOutPut.append( (sal_Unicode)'[' );
sOutPut.append( (sal_Int32)nLevel );
sOutPut.append( (sal_Unicode)':' );
sOutPut.append( (sal_Unicode)'"' );
sOutPut.append( m_sName );
sOutPut.append( (sal_Unicode)'"' );
sOutPut.append( (sal_Unicode)':' );
// Add "<extra informations>"
switch( m_eActiveState )
{
case ACTIVE : sOutPut.appendAscii( "ACTIVE");
break;
case FOCUS : sOutPut.appendAscii( "FOCUS" );
break;
}
Reference< XFrame > xActiveChild = m_aChildFrameContainer.getActive();
Reference< XFrame > xTHISFrame ( (OWeakObject*)this, UNO_QUERY );
Reference< XFrame > xActiveParentChild;
if ( m_xParent.is() == sal_True )
{
xActiveParentChild = m_xParent->getActiveFrame();
}
// If "active path" from my parent to one of my childs not broken => I'am in the middle of an active path.
if ( xActiveChild.is() == sal_True && xActiveParentChild == xTHISFrame )
{
sOutPut.appendAscii( ":MIDDLEPATH" );
}
// If "active path" exist to one of my childs only => I'am on the top of an active path.
if ( xActiveChild.is() == sal_True && xActiveParentChild != xTHISFrame )
{
sOutPut.appendAscii( ":STARTPATH" );
}
// If "active path" exist from my parent to me, but not to one of my childs => I'am at the end of an active path.
if ( xActiveChild.is() == sal_False && xActiveParentChild == xTHISFrame )
{
sOutPut.appendAscii( ":ENDPATH" );
}
// Else; There is no active path in the near of this node.
// Add "]\n"
sOutPut.append( (sal_Unicode)']' );
sOutPut.appendAscii( "\n" );
// Step over all elements in current container and collect names.
// We must lock the container, to have exclusiv access to elements!
m_aChildFrameContainer.lock();
sal_uInt32 nCount = m_aChildFrameContainer.getCount();
for ( sal_uInt32 nPosition=0; nPosition<nCount; ++nPosition )
{
// Step during tree deep first - from the left site to the right one.
// Print subtree of this child to stream!
Reference< XFrame > xItem = m_aChildFrameContainer[nPosition];
Reference< XSPECIALDEBUGINTERFACE > xDebug( xItem, UNO_QUERY );
sOutPut.append( xDebug->dumpVariable( DUMPVARIABLE_TREEINFO, nLevel+1 ) );
}
// Don't forget to unlock the container!
m_aChildFrameContainer.unlock();
// Now we have anough informations about tree.
// Return it to caller.
return sOutPut.makeStringAndClear();
}
#endif // #ifdef ENABLE_SERVICEDEBUG
} // namespace framework
|