summaryrefslogtreecommitdiff
path: root/sw/source/ui/utlui/content.cxx
blob: cefd46dd4daa610d711aa172fb9377bd3cedd210 (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
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
/*************************************************************************
 *
 *  $RCSfile: content.cxx,v $
 *
 *  $Revision: 1.3 $
 *
 *  last change: $Author: os $ $Date: 2000-11-03 11:32:31 $
 *
 *  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): _______________________________________
 *
 *
 ************************************************************************/

#ifdef PRECOMPILED
#include "ui_pch.hxx"
#endif

#pragma hdrstop

#ifndef _SVSTDARR_HXX
#define _SVSTDARR_STRINGSDTOR
#include <svtools/svstdarr.hxx>
#endif
#ifndef _DRAG_HXX //autogen
#include <vcl/drag.hxx>
#endif
#ifndef _URLBMK_HXX //autogen
#include <svtools/urlbmk.hxx>
#endif
#ifndef _URLOBJ_HXX //autogen
#include <tools/urlobj.hxx>
#endif
#ifndef _SFXDOCFILE_HXX //autogen
#include <sfx2/docfile.hxx>
#endif
#ifndef _SFXDISPATCH_HXX //autogen
#include <sfx2/dispatch.hxx>
#endif
#ifndef _CLIP_HXX //autogen
#include <vcl/clip.hxx>
#endif
#ifndef _HELP_HXX //autogen
#include <vcl/help.hxx>
#endif
#ifndef _SOT_FORMATS_HXX //autogen
#include <sot/formats.hxx>
#endif
#ifndef _SV_SOUND_HXX //autogen
#include <vcl/sound.hxx>
#endif

#ifndef _UIITEMS_HXX
#include <uiitems.hxx>
#endif
#ifndef _FMTINFMT_HXX //autogen
#include <fmtinfmt.hxx>
#endif
#ifndef _TXTINET_HXX //autogen
#include <txtinet.hxx>
#endif
#ifndef _FMTFLD_HXX //autogen
#include <fmtfld.hxx>
#endif
#ifndef _SWMODULE_HXX
#include <swmodule.hxx>
#endif
#ifndef _WRTSH_HXX
#include <wrtsh.hxx>
#endif
#ifndef _VIEW_HXX
#include <view.hxx>
#endif
#ifndef _ERRHDL_HXX
#include <errhdl.hxx>
#endif
#ifndef _DOCSH_HXX
#include <docsh.hxx>
#endif
#ifndef _CONTENT_HXX
#include <content.hxx>
#endif
#ifndef _FRMFMT_HXX
#include <frmfmt.hxx>
#endif
#ifndef _FLDBAS_HXX
#include <fldbas.hxx>
#endif
#ifndef _TXTATR_HXX
#include <txtatr.hxx>
#endif
#ifndef _BOOKMRK_HXX
#include <bookmrk.hxx>
#endif
#ifndef _SECTION_HXX
#include <section.hxx>
#endif
#ifndef _NUMRULE_HXX
#include <numrule.hxx>
#endif
#ifndef _TOX_HXX
#include <tox.hxx>
#endif
#define NAVIPI_CXX
#ifndef _NAVIPI_HXX
#include <navipi.hxx>
#endif
#ifndef _NAVICONT_HXX
#include <navicont.hxx>
#endif
#ifndef _NAVICFG_HXX
#include <navicfg.hxx>
#endif
#ifndef _SWCONT_HXX
#include <swcont.hxx>
#endif
#ifndef _EDTWIN_HXX
#include <edtwin.hxx>
#endif
#ifndef _DOC_HXX
#include <doc.hxx>
#endif
#ifndef _UNOTOOLS_HXX
#include <unotools.hxx>
#endif
#ifndef _HINTS_HXX
#include <hints.hxx>
#endif

#ifndef _CMDID_H
#include <cmdid.h>
#endif
#ifndef _HELPID_H
#include <helpid.h>
#endif
#ifndef _NAVIPI_HRC
#include <navipi.hrc>
#endif
#ifndef _UTLUI_HRC
#include <utlui.hrc>
#endif
#ifndef _MISC_HRC
#include <misc.hrc>
#endif
#ifndef _COMCORE_HRC
#include <comcore.hrc>
#endif
#ifndef _COM_SUN_STAR_TEXT_XTEXTSECTIONSSUPPLIER_HPP_
#include <com/sun/star/text/XTextSectionsSupplier.hpp>
#endif
#ifndef _COM_SUN_STAR_TEXT_XTEXTGRAPHICOBJECTSSUPPLIER_HPP_
#include <com/sun/star/text/XTextGraphicObjectsSupplier.hpp>
#endif
#ifndef _COM_SUN_STAR_TEXT_XTEXTTABLESSUPPLIER_HPP_
#include <com/sun/star/text/XTextTablesSupplier.hpp>
#endif
#ifndef _COM_SUN_STAR_TEXT_XDOCUMENTINDEXESSUPPLIER_HPP_
#include <com/sun/star/text/XDocumentIndexesSupplier.hpp>
#endif
#ifndef _COM_SUN_STAR_TEXT_XBOOKMARKSSUPPLIER_HPP_
#include <com/sun/star/text/XBookmarksSupplier.hpp>
#endif
#ifndef _COM_SUN_STAR_TEXT_XTEXTEMBEDDEDOBJECTSSUPPLIER_HPP_
#include <com/sun/star/text/XTextEmbeddedObjectsSupplier.hpp>
#endif
#ifndef _COM_SUN_STAR_TEXT_XTEXTFRAMESSUPPLIER_HPP_
#include <com/sun/star/text/XTextFramesSupplier.hpp>
#endif


#define CTYPE_CNT   0
#define CTYPE_CTT   1

using namespace ::com::sun::star;

#define CP2S(cChar) UniString::CreateFromAscii(cChar)
#define C2S(cChar)  UniString::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM(cChar))

#define NAVI_BOOKMARK_DELIM     (sal_Unicode)1


/***************************************************************************

***************************************************************************/

typedef SwContent* SwContentPtr;
SV_DECL_PTRARR_SORT_DEL( SwContentArr, SwContentPtr, 0,4)
SV_IMPL_OP_PTRARR_SORT(SwContentArr, SwContentPtr)

sal_Bool SwContentTree::bIsInDrag = sal_False;


/***************************************************************************
    Beschreibung: Hilfsmethoden
***************************************************************************/


sal_Bool lcl_IsContent(SvLBoxEntry* pEntry)
{
    return ((SwTypeNumber*)pEntry->GetUserData())->GetTypeId() == CTYPE_CNT;
}


sal_Bool lcl_IsContentType(SvLBoxEntry* pEntry)
{
    return ((SwTypeNumber*)pEntry->GetUserData())->GetTypeId() == CTYPE_CTT;
}


sal_Bool lcl_FindShell(SwWrtShell* pShell)
{
    sal_Bool bFound = sal_False;
    SwView *pView = SwModule::GetFirstView();
    while (pView)
    {
        if(pShell == &pView->GetWrtShell())
        {
            bFound = sal_True;
            break;
        }
        pView = SwModule::GetNextView(pView);
    }
    return bFound;
}

/***************************************************************************
    Beschreibung: Inhalt, enthaelt Namen und Verweis auf den Inhalstyp
***************************************************************************/


SwContent::SwContent(const SwContentType* pCnt, const String& rName, long nYPos) :
    pParent(pCnt),
    sContentName(rName),
    SwTypeNumber(CTYPE_CNT),
    nYPosition(nYPos),
    bInvisible(sal_False)
{
}


sal_uInt8   SwTypeNumber::GetTypeId()
{
    return nTypeId;
}

SwTypeNumber::~SwTypeNumber()
{
}

sal_Bool SwContent::IsProtect() const
{
    return sal_False;
}

sal_Bool SwPostItContent::IsProtect() const
{
    return pFld->IsProtect();
}

sal_Bool SwURLFieldContent::IsProtect() const
{
    return pINetAttr->IsProtect();
}

SwGraphicContent::~SwGraphicContent()
{
}
SwTOXBaseContent::~SwTOXBaseContent()
{
}

/***************************************************************************
    Beschreibung:   Inhaltstyp, kennt seine Inhalte und die WrtShell
***************************************************************************/


SwContentType::SwContentType(SwWrtShell* pShell, sal_uInt16 nType, sal_uInt8 nLevel) :
    SwTypeNumber(CTYPE_CTT),
    pWrtShell(pShell),
    nContentType(nType),
    nOutlineLevel(nLevel),
    bDataValid(sal_False),
    bMemberFilled(sal_False),
    sContentTypeName(SW_RES(STR_CONTENT_TYPE_FIRST + nType)),
    sSingleContentTypeName(SW_RES(STR_CONTENT_TYPE_SINGLE_FIRST + nType)),
    pMember(0),
    bEdit(sal_False),
    bDelete(sal_True),
    nMemberCount(0)
{
    Init();
}

/***************************************************************************
    Beschreibung:   Initialisierung
***************************************************************************/


void SwContentType::Init(sal_Bool* pbInvalidateWindow)
{
    // wenn sich der MemberCount aendert ...
    sal_uInt16 nOldMemberCount = nMemberCount;
    nMemberCount = 0;
    switch(nContentType)
    {
        case CONTENT_TYPE_OUTLINE   :
        {
            sTypeToken = CP2S(pMarkToOutline);
            sal_uInt16 nOutlineCount = nMemberCount = pWrtShell->GetOutlineCnt();
            if(nOutlineLevel < MAXLEVEL)
            {
                for(sal_uInt16 j = 0; j < nOutlineCount; j++)
                {
                    if(pWrtShell->GetOutlineLevel(j) > nOutlineLevel )
                        nMemberCount --;
                }
            }
            bDelete = sal_False;
        }
        break;

        case CONTENT_TYPE_TABLE     :
            sTypeToken = CP2S(pMarkToTable);
            nMemberCount = pWrtShell->GetTblFrmFmtCount(sal_True);
            bEdit = sal_True;
        break;

        case CONTENT_TYPE_FRAME     :
        case CONTENT_TYPE_GRAPHIC   :
        case CONTENT_TYPE_OLE       :
        {
            FlyCntType eType = FLYCNTTYPE_FRM;
            sTypeToken = CP2S(pMarkToFrame);
            if(nContentType == CONTENT_TYPE_OLE)
            {
                eType = FLYCNTTYPE_OLE;
                sTypeToken = CP2S(pMarkToOLE);
            }
            else if(nContentType == CONTENT_TYPE_GRAPHIC)
            {
                eType = FLYCNTTYPE_GRF;
                sTypeToken = CP2S(pMarkToGraphic);
            }
            nMemberCount = pWrtShell->GetFlyCount(eType);
            bEdit = sal_True;
        }
        break;
        case CONTENT_TYPE_BOOKMARK  :
        {
            sal_uInt16 nCount = nMemberCount = pWrtShell->GetBookmarkCnt(sal_True);
            sTypeToken = aEmptyStr;
            bEdit = sal_True;
        }
        break;
        case CONTENT_TYPE_REGION :
        {
            SwContentArr*   pOldMember = 0;
            sal_uInt16 nOldRegionCount = 0;
            sal_Bool bInvalidate = sal_False;
            if(!pMember)
                pMember = new SwContentArr;
            else if(pMember->Count())
            {
                pOldMember = pMember;
                nOldRegionCount = pOldMember->Count();
                pMember = new SwContentArr;
            }
            const Point aNullPt;
            nMemberCount = pWrtShell->GetSectionFmtCount();
            for(sal_uInt16 i = 0; i < nMemberCount; i++)
            {
                const SwSectionFmt* pFmt;
                SectionType eTmpType;
                if( (pFmt = &pWrtShell->GetSectionFmt(i))->IsInNodesArr() &&
                (eTmpType = pFmt->GetSection()->GetType()) != TOX_CONTENT_SECTION
                && TOX_HEADER_SECTION != eTmpType )
                {
                    const String& rSectionName = pFmt->GetSection()->GetName();
                    sal_uInt16 nLevel = 0;
                    SwSectionFmt* pParentFmt = pFmt->GetParent();
                    while(pParentFmt)
                    {
                        nLevel++;
                        pParentFmt = pParentFmt->GetParent();
                    }

                    SwContent* pCnt = new SwRegionContent(this, rSectionName,
                            nLevel,
                            pFmt->FindLayoutRect( sal_False, &aNullPt ).Top());

                    SwPtrMsgPoolItem aAskItem( RES_CONTENT_VISIBLE, 0 );
                    if( !pFmt->GetInfo( aAskItem ) &&
                        !aAskItem.pObject )     // not visible
                        pCnt->SetInvisible();
                    pMember->Insert(pCnt);//, pMember->Count());

                    sal_uInt16 nPos = pMember->Count() - 1;
                    if(nOldRegionCount > nPos &&
                        (pOldMember->GetObject(nPos))->IsInvisible()
                                != pCnt->IsInvisible())
                            bInvalidate = sal_True;
                }
            }
            nMemberCount = pMember->Count();
            sTypeToken = CP2S(pMarkToRegion);
            bEdit = sal_True;
            bDelete = sal_False;
            if(pOldMember)
            {
                pOldMember->DeleteAndDestroy(0, pOldMember->Count());
                delete pOldMember;
                if(pbInvalidateWindow && bInvalidate)
                    *pbInvalidateWindow = sal_True;
            }
        }
        break;
        case CONTENT_TYPE_INDEX:
        {
            nMemberCount = pWrtShell->GetTOXCount();
            bEdit = sal_True;
            bDelete = sal_False;
        }
        break;
        case CONTENT_TYPE_REFERENCE:
        {
            nMemberCount = pWrtShell->GetRefMarks( 0 );
            bDelete = sal_False;
        }
        break;
        case CONTENT_TYPE_URLFIELD:
        {
            nMemberCount = 0;
            if(!pMember)
                pMember = new SwContentArr;
            else if(pMember->Count())
                pMember->DeleteAndDestroy(0, pMember->Count());

            SwGetINetAttrs aArr;
            nMemberCount = pWrtShell->GetINetAttrs( aArr );
            for( sal_uInt16 n = 0; n < nMemberCount; ++n )
            {
                SwGetINetAttr* p = aArr[ n ];
                SwURLFieldContent* pCnt = new SwURLFieldContent(
                                    this,
                                    p->sText,
                                    INetURLObject::decode(
                                        p->rINetAttr.GetINetFmt().GetValue(),
                                        INET_HEX_ESCAPE,
                                           INetURLObject::DECODE_UNAMBIGUOUS,
                                        RTL_TEXTENCODING_UTF8 ),
                                    &p->rINetAttr,
                                    n );
                pMember->Insert( pCnt );//, n );
            }
            bEdit = sal_True;
            nOldMemberCount = nMemberCount;
            bDelete = sal_False;
        }
        break;
        case CONTENT_TYPE_POSTIT:
        {
            nMemberCount = 0;
            if(!pMember)
                pMember = new SwContentArr;
            else if(pMember->Count())
                pMember->DeleteAndDestroy(0, pMember->Count());
            SwFieldType* pType = pWrtShell->GetFldType(
                                    RES_POSTITFLD, aEmptyStr);
            SwClientIter aIter( *pType );
            SwClient * pFirst = aIter.GoStart();
            while(pFirst)
            {
                if(((SwFmtFld*)pFirst)->GetTxtFld() &&
                        ((SwFmtFld*)pFirst)->IsFldInDoc())
                {
                    SwField* pField = (SwField*)((SwFmtFld*)pFirst)
                                                                    ->GetFld();

                    String sEntry = pField->GetPar2();
                    RemoveNewline(sEntry);
                    SwPostItContent* pCnt = new SwPostItContent(
                                        this,
                                        sEntry, // hier steht der Text
                                        (const SwFmtFld*)pFirst,
                                        nMemberCount);
                    pMember->Insert(pCnt);//, nMemberCount);
                    nMemberCount++;
                }
                pFirst = aIter++;
            }
            sTypeToken = aEmptyStr;
            bEdit = sal_True;
            nOldMemberCount = nMemberCount;
        }
        break;
        case CONTENT_TYPE_DRAWOBJECT:
            sTypeToken = aEmptyStr;
        break;
    }
    // ... dann koennen die Daten auch nicht mehr gueltig sein
    // abgesehen von denen, die schon korrigiert wurden, dann ist
    // nOldMemberCount doch nicht so old
    if( nOldMemberCount != nMemberCount )
        bDataValid = sal_False;
}

/***************************************************************************
    Beschreibung:
***************************************************************************/


SwContentType::~SwContentType()
{
    delete pMember;
}

/***************************************************************************
    Beschreibung:    Inhalt liefern, dazu gfs. die Liste fuellen
***************************************************************************/


const SwContent* SwContentType::GetMember(sal_uInt16 nIndex)
{
    if(!bDataValid || !pMember)
    {
        FillMemberList();
    }
    if(nIndex < pMember->Count())
        return pMember->GetObject(nIndex);
    else
        return 0;

}


/***************************************************************************
    Beschreibung:
***************************************************************************/


void    SwContentType::Invalidate()
{
    bDataValid = sal_False;
}

/***************************************************************************
    Beschreibung: Liste der Inhalte fuellen
***************************************************************************/


void    SwContentType::FillMemberList(sal_Bool* pbLevelOrVisibiblityChanged)
{
    SwContentArr*   pOldMember = 0;
    int nOldMemberCount = -1;
    SwPtrMsgPoolItem aAskItem( RES_CONTENT_VISIBLE, 0 );
    if(pMember && pbLevelOrVisibiblityChanged)
    {
        pOldMember = pMember;
        nOldMemberCount = pOldMember->Count();
        pMember = new SwContentArr;
        *pbLevelOrVisibiblityChanged = sal_False;
    }
    else if(!pMember)
        pMember = new SwContentArr;
    else if(pMember->Count())
        pMember->DeleteAndDestroy(0, pMember->Count());
    switch(nContentType)
    {
        case CONTENT_TYPE_OUTLINE   :
        {
            sal_uInt16 nOutlineCount = nMemberCount = pWrtShell->GetOutlineCnt();

            sal_uInt16 nPos = 0;
            for (sal_uInt16 i = 0; i < nOutlineCount; ++i)
            {
                const sal_Int8 nLevel = (sal_Int8)pWrtShell->GetOutlineLevel(i);
                if(nLevel >= nOutlineLevel )
                    nMemberCount--;
                else
                {
                    String aEntry(pWrtShell->GetOutlineText(i));
                    aEntry.EraseLeadingChars();
                    SwNavigationPI::CleanEntry( aEntry );
                    SwOutlineContent* pCnt = new SwOutlineContent(this, aEntry, i, nLevel,
                                                        pWrtShell->IsOutlineMovable( i ), nPos );
                    pMember->Insert(pCnt);//, nPos);
                    // bei gleicher Anzahl und vorhandenem pOldMember wird die
                    // alte mit der neuen OutlinePos verglichen
                    // cast fuer Win16
                    if(nOldMemberCount > (int)nPos &&
                        ((SwOutlineContent*)pOldMember->GetObject(nPos))->GetOutlineLevel() != nLevel)
                        *pbLevelOrVisibiblityChanged = sal_True;

                    nPos++;
                }
            }

        }
        break;

        case CONTENT_TYPE_TABLE     :
        {
            DBG_ASSERT(nMemberCount ==
                    pWrtShell->GetTblFrmFmtCount(sal_True),
                    "MemberCount differiert")
            Point aNullPt;
            nMemberCount =  pWrtShell->GetTblFrmFmtCount(sal_True);
            for(sal_uInt16 i = 0; i < nMemberCount; i++)
            {
                const SwFrmFmt& rTblFmt = pWrtShell->GetTblFrmFmt(i, sal_True);
                String sTblName( rTblFmt.GetName() );

                SwContent* pCnt = new SwContent(this, sTblName,
                        rTblFmt.FindLayoutRect(sal_False, &aNullPt).Top() );
                if( !rTblFmt.GetInfo( aAskItem ) &&
                    !aAskItem.pObject )     // not visible
                    pCnt->SetInvisible();

                pMember->Insert(pCnt);//, i);

                if(nOldMemberCount > (int)i &&
                    (pOldMember->GetObject(i))->IsInvisible() != pCnt->IsInvisible())
                        *pbLevelOrVisibiblityChanged = sal_True;
            }
        }
        break;
        case CONTENT_TYPE_OLE       :
        case CONTENT_TYPE_FRAME     :
        case CONTENT_TYPE_GRAPHIC   :
        {
            FlyCntType eType = FLYCNTTYPE_FRM;
            if(nContentType == CONTENT_TYPE_OLE)
                eType = FLYCNTTYPE_OLE;
            else if(nContentType == CONTENT_TYPE_GRAPHIC)
                eType = FLYCNTTYPE_GRF;
            DBG_ASSERT(nMemberCount ==  pWrtShell->GetFlyCount(eType),
                    "MemberCount differiert");
            Point aNullPt;
            nMemberCount = pWrtShell->GetFlyCount(eType);
            for(sal_uInt16 i = 0; i < nMemberCount; i++)
            {
                const SwFrmFmt* pFrmFmt = pWrtShell->GetFlyNum(i,eType);
                String sFrmName = pFrmFmt->GetName();

                SwContent* pCnt;
                if(CONTENT_TYPE_GRAPHIC == nContentType)
                {
                    String sLink;
                    pWrtShell->GetGrfNms( &sLink, 0, (SwFlyFrmFmt*) pFrmFmt);
                    pCnt = new SwGraphicContent(this, sFrmName,
                                INetURLObject::decode( sLink, INET_HEX_ESCAPE,
                                           INetURLObject::DECODE_UNAMBIGUOUS,
                                        RTL_TEXTENCODING_UTF8 ),
                                pFrmFmt->FindLayoutRect(sal_False, &aNullPt).Top());
                }
                else
                {
                    pCnt = new SwContent(this, sFrmName,
                            pFrmFmt->FindLayoutRect(sal_False, &aNullPt).Top() );
                }
                if( !pFrmFmt->GetInfo( aAskItem ) &&
                    !aAskItem.pObject )     // not visible
                    pCnt->SetInvisible();
                pMember->Insert(pCnt);//, i);
                if(nOldMemberCount > (int)i &&
                    (pOldMember->GetObject(i))->IsInvisible() != pCnt->IsInvisible())
                        *pbLevelOrVisibiblityChanged = sal_True;
            }
        }
        break;
        case CONTENT_TYPE_BOOKMARK  :
        {
            nMemberCount = pWrtShell->GetBookmarkCnt(sal_True);
            for(sal_uInt16 i = 0; i < nMemberCount; i++)
            {
                SwBookmark& rBkmk = pWrtShell->GetBookmark( i, sal_True );
                    const String& rBkmName = rBkmk.GetName();
                    //nYPos von 0 -> ::com::sun::star::text::Bookmarks werden nach Alphabet sortiert
                    SwContent* pCnt = new SwContent(this, rBkmName, 0);
                    pMember->Insert(pCnt);//, pMember->Count());
            }
        }
        break;
        case CONTENT_TYPE_REGION    :
        {
            const Point aNullPt;
            nMemberCount = pWrtShell->GetSectionFmtCount();
            for(sal_uInt16 i = 0; i < nMemberCount; i++)
            {
                const SwSectionFmt* pFmt;
                SectionType eTmpType;
                if( (pFmt = &pWrtShell->GetSectionFmt(i))->IsInNodesArr() &&
                (eTmpType = pFmt->GetSection()->GetType()) != TOX_CONTENT_SECTION
                && TOX_HEADER_SECTION != eTmpType )
                {
                    String sSectionName = pFmt->GetSection()->GetName();

                    sal_uInt16 nLevel = 0;
                    SwSectionFmt* pParentFmt = pFmt->GetParent();
                    while(pParentFmt)
                    {
                        nLevel++;
                        pParentFmt = pParentFmt->GetParent();
                    }

                    SwContent* pCnt = new SwRegionContent(this, sSectionName,
                            nLevel,
                            pFmt->FindLayoutRect( sal_False, &aNullPt ).Top());
                    if( !pFmt->GetInfo( aAskItem ) &&
                        !aAskItem.pObject )     // not visible
                        pCnt->SetInvisible();
                    pMember->Insert(pCnt);//, pMember->Count());

                    sal_uInt16 nPos = pMember->Count() - 1;
                    if(nOldMemberCount > nPos &&
                        (pOldMember->GetObject(nPos))->IsInvisible()
                                != pCnt->IsInvisible())
                            *pbLevelOrVisibiblityChanged = sal_True;
                }
            }
            nMemberCount = pMember->Count();
        }
        break;
        case CONTENT_TYPE_REFERENCE:
        {
            SvStringsDtor aRefMarks;
            nMemberCount = pWrtShell->GetRefMarks( &aRefMarks );

            for(sal_uInt16 i=0; i<nMemberCount; i++)
            {
                //Referenzen nach Alphabet sortiert
                SwContent* pCnt = new SwContent(
                            this, *aRefMarks.GetObject(i), 0);
                pMember->Insert(pCnt);//, i);
            }
        }
        break;
        case CONTENT_TYPE_URLFIELD:
        {
            SwGetINetAttrs aArr;
            nMemberCount = pWrtShell->GetINetAttrs( aArr );
            for( sal_uInt16 n = 0; n < nMemberCount; ++n )
            {
                SwGetINetAttr* p = aArr[ n ];
                SwURLFieldContent* pCnt = new SwURLFieldContent(
                                    this,
                                    p->sText,
                                    INetURLObject::decode(
                                        p->rINetAttr.GetINetFmt().GetValue(),
                                        INET_HEX_ESCAPE,
                                           INetURLObject::DECODE_UNAMBIGUOUS,
                                        RTL_TEXTENCODING_UTF8 ),
                                    &p->rINetAttr,
                                    n );
                pMember->Insert( pCnt );//, n );
            }
        }
        break;
        case CONTENT_TYPE_INDEX:
        {

            sal_uInt16 nCount = nMemberCount = pWrtShell->GetTOXCount();
            for ( sal_uInt16 nTox = 0; nTox < nCount; nTox++ )
            {
                const SwTOXBase* pBase = pWrtShell->GetTOX( nTox );
                String sTOXNm( pBase->GetTOXName() );

                SwContent* pCnt = new SwTOXBaseContent(
                        this, sTOXNm, nTox, *pBase);

                if( !pBase->GetInfo( aAskItem ) &&
                    !aAskItem.pObject )     // not visible
                    pCnt->SetInvisible();

                pMember->Insert( pCnt );//, nTox );
                sal_uInt16 nPos = pMember->Count() - 1;
                if(nOldMemberCount > nPos &&
                    (pOldMember->GetObject(nPos))->IsInvisible()
                            != pCnt->IsInvisible())
                        *pbLevelOrVisibiblityChanged = sal_True;
            }
        }
        break;
        case CONTENT_TYPE_POSTIT:
        {
            nMemberCount = 0;
            if(!pMember)
                pMember = new SwContentArr;
            else if(pMember->Count())
                pMember->DeleteAndDestroy(0, pMember->Count());
            SwFieldType* pType = pWrtShell->GetFldType(
                                    RES_POSTITFLD, aEmptyStr);
            SwClientIter aIter( *pType );
            SwClient * pFirst = aIter.GoStart();
            while(pFirst)
            {
                if(((SwFmtFld*)pFirst)->GetTxtFld() &&
                        ((SwFmtFld*)pFirst)->IsFldInDoc())
                {
                    SwField* pField = (SwField*)((SwFmtFld*)pFirst)
                                                                    ->GetFld();
                    String sEntry = pField->GetPar2();
                    RemoveNewline(sEntry);
                    SwPostItContent* pCnt = new SwPostItContent(
                                        this,
                                        sEntry, // hier steht der Text
                                        (const SwFmtFld*)pFirst,
                                        nMemberCount);
                    pMember->Insert(pCnt);//, nMemberCount);
                    nMemberCount++;
                }
                pFirst = aIter++;
            }
        }
        break;
        case CONTENT_TYPE_DRAWOBJECT:
        break;
    }
    bDataValid = sal_True;
    if(pOldMember)
        pOldMember->DeleteAndDestroy(0, pOldMember->Count());

}

/***************************************************************************
    Beschreibung: TreeListBox fuer Inhaltsanzeige
***************************************************************************/


SwContentTree::SwContentTree(Window* pParent, const ResId& rResId) :
        SvTreeListBox( pParent, rResId ),
        pHiddenShell(0),
        pActiveShell(0),
        pConfig(SW_MOD()->GetNavigationConfig()),
        sSpace(C2S("                    ")),
        sRemoveIdx(SW_RES(ST_REMOVE_INDEX)),
        sUpdateIdx(SW_RES(ST_UPDATE)),
        sRename(SW_RES(ST_RENAME)),
        sReadonlyIdx(SW_RES(ST_READONLY_IDX)),
        sUnprotTbl(SW_RES(ST_REMOVE_TBL_PROTECTION)),
        sInvisible(SW_RES(ST_INVISIBLE)),
        nActiveBlock(0),
        nHiddenBlock(0),
        nOutlineLevel(MAXLEVEL),
        nRootType(USHRT_MAX),
        nLastSelType(USHRT_MAX),
        bIsActive(sal_True),
        bIsConstant(sal_False),
        bIsHidden(sal_False),
        bIsInternalDrag(sal_False),
        bDocChgdInDragging(sal_False),
        bIsRoot(sal_False),
        bIsIdleClear(sal_False),
        bIsLastReadOnly(sal_False),
        bIsOutlineMoveable(sal_True),
        bViewHasChanged(sal_False),
        bIsImageListInitialized(sal_False)
{
    SetHelpId(HID_NAVIGATOR_TREELIST);

    Bitmap aRootClosed      (SW_RES(BMP_ROOT_CLOSED));
    Bitmap aRootOpened      (SW_RES(BMP_ROOT_OPENED));
    SetNodeBitmaps( aRootClosed, aRootOpened );
    SetDoubleClickHdl(LINK(this, SwContentTree, ContentDoubleClickHdl));
    SetDragDropMode(SV_DRAGDROP_APP_COPY);
    for(sal_uInt16 i=0; i < CONTENT_TYPE_MAX; i++)
    {
        aActiveContentArr[i]    = 0;
        aHiddenContentArr[i]    = 0;
    }
    for( i = 0; i < CONTEXT_COUNT; i++  )
    {
        aContextStrings[i] = SW_RESSTR(i+ST_CONTEXT_FIRST);
    }
    nActiveBlock = pConfig->GetActiveBlock();
    aUpdTimer.SetTimeoutHdl(LINK(this, SwContentTree, TimerUpdate));
    aUpdTimer.SetTimeout(1000);
    Clear();
}

/***************************************************************************
    Beschreibung:
***************************************************************************/


SwContentTree::~SwContentTree()
{
    Clear(); // vorher gfs. Inhaltstypen loeschen
    bIsInDrag = sal_False;
}

/***************************************************************************
    Beschreibung:   Drop wird im Navigator ausgefuehrt
***************************************************************************/


sal_Bool     SwContentTree::Drop( const DropEvent& rEvt)
{
    if(bIsRoot)
    {
        return SvTreeListBox::Drop(rEvt);
    }
    else
        return bIsInDrag ? sal_False : GetParentWindow()->Drop(rEvt);
}

/***************************************************************************
    Beschreibung:   QueryDrop wird im Navigator ausgefuehrt
***************************************************************************/


sal_Bool     SwContentTree::QueryDrop( DropEvent& rEvt)
{
    if(bIsRoot)
    {
        return bIsOutlineMoveable && SvTreeListBox::QueryDrop(rEvt);
    }
    else
        return bIsInDrag ? sal_False : GetParentWindow()->QueryDrop(rEvt);
}

/***************************************************************************
    Beschreibung:   Handler fuer Dragging und ContextMenu
***************************************************************************/


void  SwContentTree::Command( const CommandEvent& rCEvt )
{
    sal_Bool bParent = sal_False;
    switch( rCEvt.GetCommand() )
    {
        case COMMAND_STARTDRAG:
        {
            if(!bIsRoot || nRootType != CONTENT_TYPE_OUTLINE)
            {
                ReleaseMouse();
                StartExecuteDrag();
            }
            else
                bParent = sal_True;
        }
        break;
        case COMMAND_CONTEXTMENU:
        {
            PopupMenu aPop;
            PopupMenu aSubPop1;
            PopupMenu aSubPop2;
            PopupMenu aSubPop3;
            PopupMenu aSubPop4; // Bearbeiten

            for(sal_uInt16 i = 1; i <= MAXLEVEL; i++ )
            {
                aSubPop1.InsertItem( i + 100, String::CreateFromInt32(i));
            }
            aSubPop1.CheckItem(100 + nOutlineLevel);
            for(i=0; i < 3; i++ )
            {
                aSubPop2.InsertItem( i + 201, aContextStrings[
                        ST_HYPERLINK - ST_CONTEXT_FIRST + i]);
            }
            aSubPop2.CheckItem( 201 +
                            GetParentWindow()->GetRegionDropMode());
            //Liste der offenen Dateien einfuegen
            sal_uInt16 nId = 301;
            const SwView* pActiveView = ::GetActiveView();
            SwView *pView = SwModule::GetFirstView();
            while (pView)
            {
                String sInsert = pView->GetDocShell()->GetTitle();
                if(pView == pActiveView)
                {
                    sInsert += '(';
                    sInsert += aContextStrings[ ST_ACTIVE - ST_CONTEXT_FIRST];
                    sInsert += ')';
                }
                aSubPop3.InsertItem(nId, sInsert);
                if(bIsConstant && pActiveShell == &pView->GetWrtShell())
                    aSubPop3.CheckItem(nId);
                pView = SwModule::GetNextView(pView);
                nId++;
            }
            aSubPop3.InsertItem(nId++, aContextStrings[ST_ACTIVE_VIEW - ST_CONTEXT_FIRST]);
            if(pHiddenShell)
            {
                String sHiddenEntry = pHiddenShell->GetView().GetDocShell()->GetTitle();
                sHiddenEntry += C2S(" ( ");
                sHiddenEntry += aContextStrings[ ST_HIDDEN - ST_CONTEXT_FIRST];
                sHiddenEntry += C2S(" )");
                aSubPop3.InsertItem(nId, sHiddenEntry);
            }

            if(bIsActive)
                aSubPop3.CheckItem( --nId );
            else if(bIsHidden)
                aSubPop3.CheckItem( nId );

            aPop.InsertItem( 1, aContextStrings[
                                        ST_OUTLINE_LEVEL - ST_CONTEXT_FIRST]);
            aPop.InsertItem(2, aContextStrings[ST_DRAGMODE - ST_CONTEXT_FIRST]);
            aPop.InsertItem(3, aContextStrings[ST_DISPLAY - ST_CONTEXT_FIRST]);
            Link aSelLk = LINK(this, SwContentTree, PopupHdl );
            //jetzt noch bearbeiten
            SvLBoxEntry* pEntry;
            //Bearbeiten nur, wenn die angezeigten Inhalte aus der aktiven View kommen
            if((bIsActive || pActiveShell == pActiveView->GetWrtShellPtr())
                    && 0 != (pEntry = FirstSelected()) && lcl_IsContent(pEntry))
            {
                const SwContentType* pContType = ((SwContent*)pEntry->GetUserData())->GetParent();
                const sal_uInt16 nContentType = pContType->GetType();
                sal_Bool bReadonly = pActiveShell->GetView().GetDocShell()->IsReadOnly();
                sal_Bool bEditable = pContType->IsEditable();
                sal_Bool bDeletable = pContType->IsDeletable();
                sal_Bool bRenamable = bEditable && !bReadonly &&
                    (CONTENT_TYPE_TABLE == nContentType ||
                        CONTENT_TYPE_FRAME == nContentType ||
                        CONTENT_TYPE_GRAPHIC == nContentType ||
                        CONTENT_TYPE_OLE == nContentType ||
                        CONTENT_TYPE_BOOKMARK == nContentType ||
                        CONTENT_TYPE_REGION == nContentType||
                        CONTENT_TYPE_INDEX == nContentType);

                if(!bReadonly && (bEditable || bDeletable))
                {
                    sal_Bool bSubPop4 = sal_False;
                    if(CONTENT_TYPE_INDEX == nContentType)
                    {
                        bSubPop4 = sal_True;
                        aSubPop4.InsertItem(401, sRemoveIdx);
                        aSubPop4.InsertItem(402, sUpdateIdx);
                        aSubPop4.InsertItem(403, aContextStrings[ST_EDIT_ENTRY - ST_CONTEXT_FIRST]);
                        aSubPop4.InsertItem(405, sReadonlyIdx);

                        const SwTOXBase* pBase = ((SwTOXBaseContent*)pEntry->GetUserData())->GetTOXBase();
                        aSubPop4.CheckItem( 405, pActiveShell->IsTOXBaseReadonly(*pBase));
                        aSubPop4.InsertItem(501, aContextStrings[ST_DELETE_ENTRY - ST_CONTEXT_FIRST]);
                    }
                    else if(CONTENT_TYPE_TABLE == nContentType && !bReadonly)
                    {
                        bSubPop4 = sal_True;
                        aSubPop4.InsertItem(403, aContextStrings[ST_EDIT_ENTRY - ST_CONTEXT_FIRST]);
                        aSubPop4.InsertItem(404, sUnprotTbl);
                        sal_Bool bFull = sal_False;
                        String sTblName = ((SwContent*)pEntry->GetUserData())->GetName();
                        sal_Bool bProt =pActiveShell->HasTblAnyProtection( &sTblName, &bFull );
                        aSubPop4.EnableItem(403, !bFull );
                        aSubPop4.EnableItem(404, bProt );
                        aSubPop4.InsertItem(501, aContextStrings[ST_DELETE_ENTRY - ST_CONTEXT_FIRST]);
                    }
                    else if(!((SwContent*)pEntry->GetUserData())->IsProtect())
                    {
                        if(bEditable && bDeletable)
                        {
                            aSubPop4.InsertItem(403, aContextStrings[ST_EDIT_ENTRY - ST_CONTEXT_FIRST]);
                            aSubPop4.InsertItem(501, aContextStrings[ST_DELETE_ENTRY - ST_CONTEXT_FIRST]);
                            bSubPop4 = sal_True;
                        }
                        else if(bEditable)
                            aPop.InsertItem(403, aContextStrings[ST_EDIT_ENTRY - ST_CONTEXT_FIRST]);
                        else if(bDeletable)
                            aPop.InsertItem(501, aContextStrings[ST_DELETE_ENTRY - ST_CONTEXT_FIRST]);
                    }
                    //Rename object
                    if(bRenamable)
                    {
                        if(bSubPop4)
                            aSubPop4.InsertItem(502, sRename);
                        else
                            aPop.InsertItem(502, sRename);
                    }

                    if(bSubPop4)
                    {
                        aPop.InsertItem(4, pContType->GetSingleName());
                        aPop.SetPopupMenu(4, &aSubPop4);
                        aSubPop4.SetSelectHdl(aSelLk);
                    }
                }
            }


            aPop.SetPopupMenu( 1, &aSubPop1 );
            aPop.SetPopupMenu( 2, &aSubPop2 );
            aPop.SetPopupMenu( 3, &aSubPop3 );
            aPop.SetSelectHdl(aSelLk);
            aSubPop1.SetSelectHdl(aSelLk);
            aSubPop2.SetSelectHdl(aSelLk);
            aSubPop3.SetSelectHdl(aSelLk);

            aPop.Execute( this, rCEvt.GetMousePosPixel() );
        }
        break;
        default: bParent = sal_True;
    }
    if(bParent)
        SvTreeListBox::Command(rCEvt);
}

/***************************************************************************
    Beschreibung:   Einrueckung fuer outlines (und sections)
***************************************************************************/


long    SwContentTree::GetTabPos( SvLBoxEntry* pEntry, SvLBoxTab* pTab)
{
    sal_uInt16 nLevel = 0;
    if(lcl_IsContent(pEntry))
    {
        nLevel++;
        SwContent* pCnt = (SwContent *) pEntry->GetUserData();
        const SwContentType*    pParent;
        if(pCnt &&  0 != (pParent = pCnt->GetParent()))
        {
            if(pParent->GetType() == CONTENT_TYPE_OUTLINE)
                nLevel += ((SwOutlineContent*)pCnt)->GetOutlineLevel();
            else if(pParent->GetType() == CONTENT_TYPE_REGION)
                nLevel += ((SwRegionContent*)pCnt)->GetRegionLevel();
        }
    }
    sal_uInt16 nBasis = bIsRoot ? 0 : 5;
    return nLevel * 10 + nBasis + pTab->GetPos();  //empirisch ermittelt
}

/***************************************************************************
    Beschreibung:   Inhalte werden erst auf Anforderung in die Box eingefuegt
***************************************************************************/


void  SwContentTree::RequestingChilds( SvLBoxEntry* pParent )
{
    // ist es ein Inhaltstyp?
    if(lcl_IsContentType(pParent))
    {
        if(!pParent->HasChilds())
        {
            DBG_ASSERT(pParent->GetUserData(), "keine UserData?")
            SwContentType* pCntType = (SwContentType*)pParent->GetUserData();

            sal_uInt16 nCount = pCntType->GetMemberCount();
            for(sal_uInt16 i = 0; i < nCount; i++)
            {
                const SwContent* pCnt = pCntType->GetMember(i);
                if(pCnt)
                {
                    String sEntry = pCnt->GetName();
                    if(!sEntry.Len())
                        sEntry = sSpace;
                    SvLBoxEntry* pChild = InsertEntry(sEntry, pParent,
                            sal_False, LIST_APPEND, (void*)pCnt);
                }

            }
        }
    }
}
/***************************************************************************
    Beschreibung:   Expand - Zustand fuer Inhaltstypen merken
***************************************************************************/


sal_Bool  SwContentTree::Expand( SvLBoxEntry* pParent )
{
    if(!bIsRoot)
    {
        if(lcl_IsContentType(pParent))
        {
            SwContentType* pCntType = (SwContentType*)pParent->GetUserData();
            sal_uInt16 nOr = 1 << pCntType->GetType(); //linear -> Bitposition
            if(bIsActive || bIsConstant)
            {
                nActiveBlock |= nOr;
                pConfig->SetActiveBlock(nActiveBlock);
            }
            else
                nHiddenBlock |= nOr;
        }
    }
    return SvTreeListBox::Expand(pParent);
}
/***************************************************************************
    Beschreibung:   Collapse - Zustand fuer Inhaltstypen merken
***************************************************************************/


sal_Bool  SwContentTree::Collapse( SvLBoxEntry* pParent )
{
    sal_Bool bRet;
    if(!bIsRoot)
    {
        if(lcl_IsContentType(pParent))
        {
            SwContentType* pCntType = (SwContentType*)pParent->GetUserData();
            sal_uInt16 nAnd = 1 << pCntType->GetType();
            nAnd = ~nAnd;
            if(bIsActive || bIsConstant)
            {
                nActiveBlock &= nAnd;
                pConfig->SetActiveBlock(nActiveBlock);
            }
            else
                nHiddenBlock &= nAnd;
        }
            bRet = SvTreeListBox::Collapse(pParent);
    }
    else
        bRet = sal_False;
    return bRet;
}


/***************************************************************************
    Beschreibung:   Auch auf Doppelclick wird zunaechst nur aufgeklappt
***************************************************************************/


IMPL_LINK( SwContentTree, ContentDoubleClickHdl, SwContentTree *, EMPTYARG )
{
    SvLBoxEntry* pEntry = GetCurEntry();
    // ist es ein Inhaltstyp?
    DBG_ASSERT(pEntry, "kein aktueller Eintrag!")
    if(pEntry)
    {
        if(lcl_IsContentType(pEntry))
            RequestingChilds(pEntry);
        else if(bIsActive || bIsConstant)
        {
            if(bIsConstant)
            {
                pActiveShell->GetView().GetViewFrame()->GetWindow().ToTop();
            }
            //Inhaltstyp anspringen:
            SwContent* pCnt = (SwContent*)pEntry->GetUserData();
            DBG_ASSERT( pCnt, "keine UserData")
            GotoContent(pCnt);
            if(pCnt->GetParent()->GetType() == CONTENT_TYPE_FRAME)
                pActiveShell->EnterStdMode();
        }
    }
    return 0;
}

/***************************************************************************
    Beschreibung:   Anzeigen der Datei
***************************************************************************/


void SwContentTree::Display( sal_Bool bActive )
{
    if(!bIsImageListInitialized)
    {
        aEntryImages = ImageList(SW_RES(IMG_NAVI_ENTRYBMP));
        bIsImageListInitialized = sal_True;
    }
    // erst den selektierten Eintrag auslesen, um ihn spaeter evtl. wieder
    // zu selektieren -> die UserDaten sind hier nicht mehr gueltig!
    SvLBoxEntry* pOldSelEntry = FirstSelected();
    String sEntryName;  // Name des Eintrags
    sal_uInt16 nEntryRelPos = 0; // rel. Pos zu seinem Parent
    if(pOldSelEntry)
    {
        sEntryName = GetEntryText(pOldSelEntry);
        if(GetParent(pOldSelEntry))
        {
            nEntryRelPos = (sal_uInt16)(GetModel()->GetAbsPos(pOldSelEntry) - GetModel()->GetAbsPos(GetParent(pOldSelEntry)));
        }
    }
    Clear();
    SetUpdateMode( sal_False );
    if(bActive && !bIsConstant && !bIsActive)
        bIsActive = bActive;
    bIsHidden = !bActive;
    SwWrtShell* pShell = GetWrtShell();
    sal_Bool bReadOnly = pShell ? pShell->GetView().GetDocShell()->IsReadOnly() : sal_True;
    if(bReadOnly != bIsLastReadOnly)
    {
        bIsLastReadOnly = bReadOnly;
        sal_Bool bDisable =  pShell == 0 || bReadOnly;
        SwNavigationPI* pNavi = GetParentWindow();
        pNavi->aContentToolBox.EnableItem(FN_ITEM_UP , !bDisable);
        pNavi->aContentToolBox.EnableItem(FN_ITEM_DOWN, !bDisable);
        pNavi->aContentToolBox.EnableItem(FN_ITEM_LEFT, !bDisable);
        pNavi->aContentToolBox.EnableItem(FN_ITEM_RIGHT, !bDisable);
        pNavi->aContentToolBox.EnableItem(FN_SELECT_SET_AUTO_BOOKMARK, !bDisable);
    }
    if(pShell)
    {
        SvLBoxEntry* pSelEntry = 0;
        if(nRootType == USHRT_MAX)
        {
            for(sal_uInt16 nCntType = CONTENT_TYPE_OUTLINE;
                        nCntType <= CONTENT_TYPE_POSTIT; nCntType++ )
            {
                SwContentType** ppContentT = bActive ?
                                &aActiveContentArr[nCntType] :
                                    &aHiddenContentArr[nCntType];
                if(!*ppContentT)
                    (*ppContentT) = new SwContentType(pShell, nCntType, nOutlineLevel );


                String sEntry = (*ppContentT)->GetName();
                SvLBoxEntry* pEntry;
                const Image& rImage = aEntryImages.GetImage(SID_SW_START + nCntType);
                sal_Bool bChOnDemand = 0 != (*ppContentT)->GetMemberCount();
                pEntry = InsertEntry(sEntry, rImage, rImage,
                                0, bChOnDemand, LIST_APPEND, (*ppContentT));
                if(nCntType == nLastSelType)
                    pSelEntry = pEntry;
                sal_uInt16 nExpandOptions = bIsActive || bIsConstant ?
                                            nActiveBlock :
                                                nHiddenBlock;
                if(nExpandOptions & (1 << nCntType))
                {
                    Expand(pEntry);
                    if(nEntryRelPos && nCntType == nLastSelType)
                    {
                        // jetzt vielleicht noch ein Child selektieren
                        SvLBoxEntry* pChild = pEntry;
                        SvLBoxEntry* pTemp = 0;
                        sal_uInt16 nPos = 1;
                        while(0 != (pChild = Next(pChild)))
                        {
                            // der alte Text wird leicht bevorzugt
                            if(sEntryName == GetEntryText(pChild) ||
                                nPos == nEntryRelPos )
                            {
                                pSelEntry = pChild;
                                break;
                            }
                            pTemp = pChild;
                            nPos++;
                        }
                        if(!pSelEntry || lcl_IsContentType(pSelEntry))
                            pSelEntry = pTemp;
                    }

                }
            }
            if(pSelEntry)
            {
                MakeVisible(pSelEntry);
                Select(pSelEntry);
            }
        }
        else
        {
            SwContentType** ppRootContentT = bActive ?
                                &aActiveContentArr[nRootType] :
                                    &aHiddenContentArr[nRootType];
            if(!(*ppRootContentT))
                (*ppRootContentT) = new SwContentType(pShell, nRootType, nOutlineLevel );
            const Image& rImage = aEntryImages.GetImage(20000 + nRootType);
            SvLBoxEntry* pParent = InsertEntry(
                    (*ppRootContentT)->GetName(), rImage, rImage,
                        0, sal_False, LIST_APPEND, *ppRootContentT);
            SvLBoxEntry* pEntry;
            for(sal_uInt16 i = 0; i < (*ppRootContentT)->GetMemberCount(); i++ )
            {
                const SwContent* pCnt = (*ppRootContentT)->GetMember(i);
                if(pCnt)
                {
                    String sEntry = pCnt->GetName();
                    if(!sEntry.Len())
                        sEntry = sSpace;
                    pEntry = InsertEntry( sEntry, pParent,
                                sal_False, LIST_APPEND, (void*)pCnt);
                }
            }
            Expand(pParent);
            if( nRootType == CONTENT_TYPE_OUTLINE && bIsActive )
            {
                //feststellen, wo der Cursor steht
                const sal_uInt16 nActPos = pShell->GetOutlinePos(MAXLEVEL);
                SvLBoxEntry* pEntry = First();

                while( 0 != (pEntry = Next(pEntry)) )
                {
                    if(((SwOutlineContent*)pEntry->GetUserData())->GetPos() == nActPos)
                    {
                        MakeVisible(pEntry);
                        Select(pEntry);
                    }
                }

            }
            else
            {
                // jetzt vielleicht noch ein Child selektieren
                SvLBoxEntry* pChild = pParent;
                SvLBoxEntry* pTemp = 0;
                sal_uInt16 nPos = 1;
                while(0 != (pChild = Next(pChild)))
                {
                    // der alte Text wird leicht bevorzugt
                    if(sEntryName == GetEntryText(pChild) ||
                        nPos == nEntryRelPos )
                    {
                        pSelEntry = pChild;
                        break;
                    }
                    pTemp = pChild;
                    nPos++;
                }
                if(!pSelEntry)
                    pSelEntry = pTemp;
                if(pSelEntry)
                {
                    MakeVisible(pSelEntry);
                    Select(pSelEntry);
                }
            }
        }
    }
    SetUpdateMode( sal_True );

}

/***************************************************************************
    Beschreibung:   Im Clear muessen auch die ContentTypes geloescht werden
***************************************************************************/


void SwContentTree::Clear()
{
    SetUpdateMode(sal_False);
    SvTreeListBox::Clear();
    SetUpdateMode(sal_True);
}

/***************************************************************************
    Beschreibung:   Inhalt eintueten und abschicken
***************************************************************************/


void SwContentTree::StartExecuteDrag()
{
    DragServer::Clear();
    nDragMode = DRAG_MOVEABLE|DRAG_COPYABLE|DRAG_LINKABLE;
    if(!FillDragServer(nDragMode))
        return;

    Application::PostUserEvent( STATIC_LINK( this, SwContentTree, ExecDragHdl ) );

}

/***************************************************************************
    Beschreibung:
***************************************************************************/


sal_Bool SwContentTree::FillDragServer(sal_uInt16& nDragMode)
{
    SwWrtShell* pWrtShell = GetWrtShell();
    DBG_ASSERT(pWrtShell, "keine Shell!")
    SvLBoxEntry* pEntry = GetCurEntry();
    if(!pEntry || lcl_IsContentType(pEntry) || !pWrtShell)
        return sal_False;
    String sEntry;
    SwContent* pCnt = ((SwContent*)pEntry->GetUserData());

    sal_uInt16 nActType = pCnt->GetParent()->GetType();
    String sUrl;
    sal_Bool bOutline = sal_False;
    String sOutlineText;
    switch( nActType )
    {
        case CONTENT_TYPE_OUTLINE:
        {
            sal_uInt16 nPos = ((SwOutlineContent*)pCnt)->GetPos();
            DBG_ASSERT(nPos < pWrtShell->GetOutlineCnt(),
            "outlinecnt veraendert")
            const SwNumRule* pOutlRule = pWrtShell->GetOutlineNumRule();
            const SwNodeNum* pNum = pWrtShell->GetOutlineNum(nPos);
            if( pNum && pOutlRule && MAXLEVEL >= pNum->GetLevel())
                for(sal_Int8 nLevel = 0; nLevel <= pNum->GetLevel(); nLevel++)
                {
                    sal_uInt16 nVal = pNum->GetLevelVal()[nLevel];
                    nVal ++;
                    nVal -= pOutlRule->Get(nLevel).GetStartValue();
                    sEntry += String::CreateFromInt32( nVal );
                    sEntry += '.';
                }
            sEntry += pWrtShell->GetOutlineText(nPos, sal_False);
            sOutlineText = pWrtShell->GetOutlineText(nPos, sal_True);
            bIsOutlineMoveable = ((SwOutlineContent*)pCnt)->IsMoveable();
            bOutline = sal_True;
        }
        break;
        case CONTENT_TYPE_POSTIT:
        case CONTENT_TYPE_INDEX:
        case CONTENT_TYPE_REFERENCE :
            // koennen weder als URL noch als Bereich eingefuegt werden
        break;
        case CONTENT_TYPE_URLFIELD:
            sUrl = ((SwURLFieldContent*)pCnt)->GetURL();
        // kein break;
        case CONTENT_TYPE_OLE:
        case CONTENT_TYPE_GRAPHIC:
            if(GetParentWindow()->GetRegionDropMode() != REGION_MODE_NONE)
                break;
            else
                nDragMode &= ~(DRAG_LINKABLE|DRAG_MOVEABLE);
        default:
            sEntry = GetEntryText(pEntry);
    }

    sal_Bool bRet = sal_False;
    if(sEntry.Len())
    {
        const SwDocShell* pDocShell = pWrtShell->GetView().GetDocShell();
        if(!sUrl.Len())
        {
            if(pDocShell->HasName())
            {
                SfxMedium* pMedium = pDocShell->GetMedium();
                sUrl = pMedium->GetURLObject().GetURLNoMark();
                // nur, wenn primaer ein Link eingefuegt werden soll
                bRet = sal_True;
            }
            else if(    nActType == CONTENT_TYPE_REGION ||
                        nActType == CONTENT_TYPE_BOOKMARK )
            {
                // fuer Bereich und Textmarken ist ein Link auch ohne
                // Dateiname ins eigene Dokument erlaubt
                bRet = sal_True;
            }
            else if(bIsConstant &&
                    ( !::GetActiveView() ||
                        pActiveShell != ::GetActiveView()->GetWrtShellPtr()))
            {
                // Urls von inaktiven Views ohne Dateinamen koennen auch nicht
                // gedraggt werden
                bRet = sal_False;
            }
            else
            {
                bRet = GetParentWindow()->GetRegionDropMode() == REGION_MODE_NONE;
                nDragMode = DRAG_MOVEABLE;
            }

            const String& rToken = pCnt->GetParent()->GetTypeToken();
            sUrl += '#';
            sUrl += sEntry;
            if(rToken.Len())
            {
                sUrl += cMarkSeperator;
                sUrl += rToken;
            }
        }
        else
            bRet = sal_True;
        if(bRet)
        {
            DragServer::NewItem();
            //fuer Outlines muss in die Description der Ueberschrifttext mit der echten Nummer
            if(bOutline)
                sEntry = sOutlineText;
            {
                NaviContentBookmark aBmk( sUrl, sEntry,
                                    GetParentWindow()->GetRegionDropMode(),
                                    pDocShell);
                aBmk.CopyDragServer();
            }

            // fuer fremde DocShells muss eine INetBookmark
            // dazugeliefert werden
            if(pDocShell->HasName())
            {
                INetBookmark aBmk( sUrl, sEntry );
                aBmk.CopyDragServer();
            }
        }
    }
    return bRet;
}
/***************************************************************************
    Beschreibung:   Umschalten der Anzeige auf Root
***************************************************************************/


sal_Bool SwContentTree::ToggleToRoot()
{
    if(!bIsRoot)
    {
        SvLBoxEntry* pEntry = GetCurEntry();
        const SwContentType* pCntType;
        if(pEntry)
        {
            if(lcl_IsContentType(pEntry))
                pCntType = (SwContentType*)pEntry->GetUserData();
            else
                pCntType = ((SwContent*)pEntry->GetUserData())->GetParent();
            nRootType = pCntType->GetType();
            bIsRoot = sal_True;
            Display(bIsActive || bIsConstant);
        }
    }
    else
    {
        nRootType = USHRT_MAX;
        bIsRoot = sal_False;
        FindActiveTypeAndRemoveUserData();
        Display(bIsActive || bIsConstant);
    }
    pConfig->SetRootType( nRootType );
    GetParentWindow()->aContentToolBox.CheckItem(FN_SHOW_ROOT, bIsRoot);
    return bIsRoot;
}

/***************************************************************************
    Beschreibung:   Angezeigten Inhalt auf Gueltigkeit pruefen
***************************************************************************/


sal_Bool SwContentTree::HasContentChanged()
{
/*
    -Parallel durch das lokale Array und die Treelistbox laufen.
    -Sind die Eintraege nicht expandiert, werden sie nur im Array verworfen
    und der Contenttype wird als UserData neu gesetzt.
    - ist der Root-Modus aktiv, wird nur dieser aktualisiert,
    fuer die nicht angezeigten Inhaltstypen gilt:
        die Memberliste wird geloescht und der Membercount aktualisiert
    Wenn Inhalte ueberprueft werden, werden gleichzeitig die vorhanden
    Memberlisten aufgefuellt. Sobald ein Unterschied auftritt wird nur noch
    gefuellt und nicht mehr ueberprueft. Abschliessend wird die Box neu gefuellt.

*/

    sal_Bool bRepaint = sal_False;
    sal_Bool bInvalidate = sal_False;

    if(!bIsActive && ! bIsConstant)
    {
        for(sal_uInt16 i=0; i < CONTENT_TYPE_MAX; i++)
        {
            if(aActiveContentArr[i])
                aActiveContentArr[i]->Invalidate();
        }
    }
    else if(bIsRoot)
    {
        sal_Bool bOutline = sal_False;
        SvLBoxEntry* pEntry = First();
        if(!pEntry)
            bRepaint = sal_True;
        else
        {
            sal_uInt16 nType = ((SwContentType*)pEntry->GetUserData())->GetType();
            bOutline = nRootType == CONTENT_TYPE_OUTLINE;
            SwContentType* pArrType = aActiveContentArr[nType];
            if(!pArrType)
                bRepaint = sal_True;
            else
            {
                sal_uInt16 nSelLevel = USHRT_MAX;

                SvLBoxEntry* pFirstSel;
                if(bOutline &&
                        0 != ( pFirstSel = FirstSelected()) &&
                            lcl_IsContent(pFirstSel))
                {
                    nSelLevel = ((SwOutlineContent*)pFirstSel->GetUserData())->GetOutlineLevel();
                    SwWrtShell* pSh = GetWrtShell();
                    sal_uInt16 nOutlinePos = pSh->GetOutlinePos(MAXLEVEL);
                    bRepaint |= nOutlinePos != USHRT_MAX && pSh->GetOutlineLevel(nOutlinePos) != nSelLevel;
                }

                pArrType->Init(&bInvalidate);
                pArrType->FillMemberList();
                pEntry->SetUserData((void*)pArrType);
                if(!bRepaint)
                {
                    if(GetChildCount(pEntry) != pArrType->GetMemberCount())
                            bRepaint = sal_True;
                    else
                    {
                        sal_uInt16 nChildCount = (sal_uInt16)GetChildCount(pEntry);
                        for(sal_uInt16 j = 0; j < nChildCount; j++)
                        {
                            pEntry = Next(pEntry);
                            const SwContent* pCnt = pArrType->GetMember(j);
                            pEntry->SetUserData((void*)pCnt);
                            String sEntryText = GetEntryText(pEntry);
                            if( sEntryText != pCnt->GetName() &&
                                !(sEntryText == sSpace && !pCnt->GetName().Len()))
                                bRepaint = sal_True;
                        }
                    }
                }
            }
        }
        if( !bRepaint && bOutline )
        {
            //feststellen, wo der Cursor steht
            const sal_uInt16 nActPos = GetWrtShell()->GetOutlinePos(MAXLEVEL);
            SvLBoxEntry* pEntry = First();

            while( 0 != (pEntry = Next(pEntry)) )
            {
                if(((SwOutlineContent*)pEntry->GetUserData())->GetPos() == nActPos)
                {
                    if(FirstSelected() != pEntry)
                    {
                        Select(pEntry);
                        MakeVisible(pEntry);
                    }
                }
            }

        }

    }
    else
    {
        SvLBoxEntry* pEntry = First();
        while ( pEntry )
        {
            sal_Bool bNext = sal_True; // mindestens ein Next muss sein
            SwContentType* pTreeType = (SwContentType*)pEntry->GetUserData();
            sal_uInt16 nType = pTreeType->GetType();
            sal_uInt16 nTreeCount = pTreeType->GetMemberCount();
            SwContentType* pArrType = aActiveContentArr[nType];
            if(!pArrType)
                bRepaint = sal_True;
            else
            {
                pArrType->Init(&bInvalidate);
                pEntry->SetUserData((void*)pArrType);
                if(IsExpanded(pEntry))
                {
                    sal_Bool bLevelOrVisibiblityChanged = sal_False;
                    // bLevelOrVisibiblityChanged is set if outlines have changed their level
                    // or if the visibility of objects (frames, sections, tables) has changed
                    // i.e. in header/footer
                    pArrType->FillMemberList(&bLevelOrVisibiblityChanged);
                    if(bLevelOrVisibiblityChanged)
                        bInvalidate = sal_True;
                    sal_uInt16 nChildCount = (sal_uInt16)GetChildCount(pEntry);
                    if(bLevelOrVisibiblityChanged)
                        bInvalidate = sal_True;

                    if(nChildCount != pArrType->GetMemberCount())
                        bRepaint = sal_True;
                    else
                    {
                        for(sal_uInt16 j = 0; j < nChildCount; j++)
                        {
                            pEntry = Next(pEntry);
                            bNext = sal_False;
                            const SwContent* pCnt = pArrType->GetMember(j);
                            pEntry->SetUserData((void*)pCnt);
                            String sEntryText = GetEntryText(pEntry);
                            if( sEntryText != pCnt->GetName() &&
                                !(sEntryText == sSpace && !pCnt->GetName().Len()))
                                bRepaint = sal_True;
                        }
                    }

                }
                else if(pEntry->HasChilds())
                {
                    //war der Eintrag einmal aufgeklappt, dann muessen auch
                    // die unsichtbaren Eintraege geprueft werden.
                    // zumindest muessen die Userdaten aktualisiert werden
                    sal_Bool bLevelOrVisibiblityChanged = sal_False;
                    // bLevelOrVisibiblityChanged is set if outlines have changed their level
                    // or if the visibility of objects (frames, sections, tables) has changed
                    // i.e. in header/footer
                    pArrType->FillMemberList(&bLevelOrVisibiblityChanged);
                    sal_Bool bRemoveChildren = sal_False;
                    sal_uInt16 nChildCount = (sal_uInt16)GetChildCount(pEntry);
                    if( nChildCount != pArrType->GetMemberCount() )
                    {
                        bRemoveChildren = sal_True;
                    }
                    else
                    {
                        SvLBoxEntry* pChild = FirstChild(pEntry);
                        for(sal_uInt16 j = 0; j < nChildCount; j++)
                        {
                            const SwContent* pCnt = pArrType->GetMember(j);
                            pChild->SetUserData((void*)pCnt);
                            String sEntryText = GetEntryText(pChild);
                            if( sEntryText != pCnt->GetName() &&
                                !(sEntryText == sSpace && !pCnt->GetName().Len()))
                                bRemoveChildren = sal_True;
                            pChild = Next(pChild);
                        }
                    }
                    if(bRemoveChildren)
                    {
                        SvLBoxEntry* pChild = FirstChild(pEntry);
                        SvLBoxEntry* pRemove = pChild;
                        for(sal_uInt16 j = 0; j < nChildCount; j++)
                        {
                            pChild = Next(pRemove);
                            GetModel()->Remove(pRemove);
                            pRemove = pChild;
                        }
                    }
                    if(!nChildCount)
                    {
                        pEntry->EnableChildsOnDemand(sal_False);
                        InvalidateEntry(pEntry);
                    }

                }
                else if((nTreeCount != 0)
                            != (pArrType->GetMemberCount()!=0))
                {
                    bRepaint = sal_True;
                }
            }
            //hier muss noch der naechste Root-Entry gefunden werden
            while( pEntry && (bNext || GetParent(pEntry ) ))
            {
                pEntry = Next(pEntry);
                bNext = sal_False;
            }
        }
    }
    if(!bRepaint && bInvalidate)
        Invalidate();
    return bRepaint;
}

/***************************************************************************
    Beschreibung:   Bevor alle Daten geloescht werden, soll noch der letzte
 *                  aktive Eintrag festgestellt werden. Dann werden die
 *                  UserData geloescht
***************************************************************************/
void SwContentTree::FindActiveTypeAndRemoveUserData()
{
    SvLBoxEntry* pEntry = FirstSelected();
    if(pEntry)
    {
        // wird Clear ueber TimerUpdate gerufen, kann nur fuer die Root
        // die Gueltigkeit der UserData garantiert werden
        SvLBoxEntry* pParent;
        while(0 != (pParent = GetParent(pEntry)))
            pEntry = pParent;
        if(pEntry->GetUserData() && lcl_IsContentType(pEntry))
            nLastSelType = ((SwContentType*)pEntry->GetUserData())->GetType();
    }
//  else
//      nLastSelType = USHRT_MAX;
    pEntry = First();
    while(pEntry)
    {
        pEntry->SetUserData(0);
        pEntry = Next(pEntry);
    }
}

/***************************************************************************
    Beschreibung:   Nachdem ein File auf den Navigator gedroppt wurde,
                    wird die neue Shell gesetzt
***************************************************************************/


void SwContentTree::SetHiddenShell(SwWrtShell* pSh)
{
    pHiddenShell = pSh;
    bIsHidden = sal_True;
    bIsActive = bIsConstant = sal_False;
    FindActiveTypeAndRemoveUserData();
    for(sal_uInt16 i=0; i < CONTENT_TYPE_MAX; i++)
    {
        DELETEZ(aHiddenContentArr[i]);
    }
    Display(bIsActive);

    GetParentWindow()->UpdateListBox();
}
/***************************************************************************
    Beschreibung:   Dokumentwechsel - neue Shell setzen
***************************************************************************/


void SwContentTree::SetActiveShell(SwWrtShell* pSh)
{
    if(bIsInternalDrag)
        bDocChgdInDragging = sal_True;
    sal_Bool bClear = pActiveShell != pSh;
    if(bIsActive && bClear)
    {
        pActiveShell = pSh;
        FindActiveTypeAndRemoveUserData();
        Clear();
    }
    else if(bIsConstant)
    {
        if(!lcl_FindShell(pActiveShell))
        {
            pActiveShell = pSh;
            bIsActive = sal_True;
            bIsConstant = sal_False;
            bClear = sal_True;
        }
    }
    // nur wenn es die aktive View ist, wird das Array geloescht und
    // die Anzeige neu gefuellt
    if(bIsActive && bClear)
    {
        FindActiveTypeAndRemoveUserData();
        for(sal_uInt16 i=0; i < CONTENT_TYPE_MAX; i++)
        {
            DELETEZ(aActiveContentArr[i]);
        }
        Display(sal_True);
    }
}

/***************************************************************************
    Beschreibung:   Eine offene View als aktiv festlegen
***************************************************************************/


void SwContentTree::SetConstantShell(SwWrtShell* pSh)
{
    pActiveShell = pSh;
    bIsActive       = sal_False;
    bIsConstant     = sal_True;
    FindActiveTypeAndRemoveUserData();
    for(sal_uInt16 i=0; i < CONTENT_TYPE_MAX; i++)
    {
        DELETEZ(aActiveContentArr[i]);
    }
    Display(sal_True);
}
/***************************************************************************
    Beschreibung:   Kommandos des Navigators ausfuehren
***************************************************************************/


void SwContentTree::ExecCommand(sal_uInt16 nCmd, sal_Bool bModifier)
{
    sal_Bool nMove = sal_False;
    switch( nCmd )
    {
        case FN_ITEM_DOWN:
        case FN_ITEM_UP:   nMove = sal_True;
        case FN_ITEM_LEFT:
        case FN_ITEM_RIGHT:
        if( !GetWrtShell()->GetView().GetDocShell()->IsReadOnly() &&
                (bIsActive ||
                    (bIsConstant && pActiveShell == ::GetActiveView()->GetWrtShellPtr())))
        {
            SwWrtShell* pShell = GetWrtShell();
            sal_Int8 nActOutlineLevel = nOutlineLevel;
            sal_uInt16 nActPos = pShell->GetOutlinePos(nActOutlineLevel);
            SvLBoxEntry* pFirstEntry = FirstSelected();
            if (pFirstEntry && lcl_IsContent(pFirstEntry))
            {
                if(bIsRoot && nRootType == CONTENT_TYPE_OUTLINE ||
                    ((SwContent*)pFirstEntry->GetUserData())->GetParent()->GetType()
                                                ==  CONTENT_TYPE_OUTLINE)
                    nActPos = ((SwOutlineContent*)pFirstEntry->GetUserData())->GetPos();
            }
            if ( nActPos < USHRT_MAX &&
                    ( !nMove || pShell->IsOutlineMovable( nActPos )) )
            {
                pShell->StartAllAction();
                pShell->GotoOutline( nActPos); // Falls Textselektion != BoxSelektion
                pShell->Push();
                pShell->MakeOutlineSel( nActPos, nActPos,
                                    bModifier);
                if( nMove )
                {
                    short nDir = nCmd == FN_ITEM_UP ? -1 : 1;
                    if( !bModifier && (nDir == -1 && nActPos > 0 ||
                        nDir == 1 && nActPos < GetEntryCount() - 2 ) )
                    {
                        pShell->MoveOutlinePara( nDir );
                        //Cursor wieder an die aktuelle Position setzen
                        pShell->GotoOutline( nActPos + nDir);
                    }
                    else if(bModifier)
                    {
                        sal_uInt16 nActEndPos = nActPos;
                        SvLBoxEntry* pEntry = pFirstEntry;
                        sal_uInt16 nActLevel = ((SwOutlineContent*)
                                pFirstEntry->GetUserData())->GetOutlineLevel();
                        pEntry = Next(pEntry);
                        while( pEntry && CONTENT_TYPE_OUTLINE ==
                            ((SwTypeNumber*)pEntry->GetUserData())->GetTypeId() )
                        {
                            if(nActLevel >= ((SwOutlineContent*)
                                pEntry->GetUserData())->GetOutlineLevel())
                                break;
                            pEntry = Next(pEntry);
                            nActEndPos++;
                        }
                        sal_uInt16 nDest;
                        if(nDir == 1)
                        {
                            //Wenn der letzte Eintrag bewegt werden soll
                            //ist Schluss
                            if(pEntry && CONTENT_TYPE_OUTLINE ==
                                ((SwTypeNumber*)pEntry->GetUserData())->GetTypeId())
                            {
                                // pEntry zeigt jetzt auf den
                                // dem letzten sel. Eintrag folgenden E.
                                nDest = nActEndPos;
                                nDest++;
                                //hier muss der uebernaechste Eintrag
                                //gefunden werden. Die Selektion muss davor eingefuegt
                                //werden
                                while(pEntry )
                                {
                                    pEntry = Next(pEntry);
                                    // nDest++ darf nur ausgefuehrt werden,
                                    // wenn pEntry != 0
                                    if(pEntry && nDest++ &&
                                    ( nActLevel >= ((SwOutlineContent*)pEntry->GetUserData())->GetOutlineLevel()||
                                     CONTENT_TYPE_OUTLINE != ((SwTypeNumber*)pEntry->GetUserData())->GetTypeId()))
                                    {
                                        nDest--;
                                        break;
                                    }
                                }
                                nDir = nDest - nActEndPos;
                                //wenn kein Eintrag gefunden wurde, der der Bedingung
                                //fuer das zuvor Einfuegen entspricht, muss etwas weniger
                                //geschoben werden
                            }
                            else
                                nDir = 0;
                        }
                        else
                        {
                            nDest = nActPos;
                            pEntry = pFirstEntry;
                            while(pEntry && nDest )
                            {
                                nDest--;
                                pEntry = Prev(pEntry);
                                if(pEntry &&
                                    (nActLevel >= ((SwOutlineContent*)pEntry->GetUserData())->GetOutlineLevel()||
                                    CONTENT_TYPE_OUTLINE !=
                                ((SwTypeNumber*)pEntry->GetUserData())->GetTypeId()))
                                {
                                    break;
                                }
                            }
                            nDir = nDest - nActPos;
                        }
                        if(nDir)
                        {
                            pShell->MoveOutlinePara( nDir );
                            //Cursor wieder an die aktuelle Position setzen
                            pShell->GotoOutline( nActPos + nDir);
                        }
                    }
                }
                else
                {
                    if( pShell->IsProtectedOutlinePara() )
                        Sound::Beep(); //konnte nicht umgestuft werden
                    else
                        pShell->OutlineUpDown( nCmd == FN_ITEM_LEFT ? -1 : 1 );
                }

                pShell->ClearMark();
                pShell->Pop(sal_False); //Cursor steht jetzt wieder an der akt. Ueberschrift
                pShell->EndAllAction();
                if(aActiveContentArr[CONTENT_TYPE_OUTLINE])
                    aActiveContentArr[CONTENT_TYPE_OUTLINE]->Invalidate();
                Display(sal_True);
                if(!bIsRoot)
                {
                    const sal_uInt16 nActPos = pShell->GetOutlinePos(MAXLEVEL);
                    SvLBoxEntry* pEntry = First();

                    while( 0 != (pEntry = Next(pEntry)) && lcl_IsContent(pEntry))
                    {
                        if(((SwOutlineContent*)pEntry->GetUserData())->GetPos() == nActPos)
                        {
                            Select(pEntry);
                            MakeVisible(pEntry);
                        }
                    }
                }
            }
            else
                Sound::Beep(); //konnte nicht verschoben werden
        }
    }
}
/***************************************************************************
    Beschreibung:
***************************************************************************/


void    SwContentTree::Show()
{
    aUpdTimer.Start();
    SvTreeListBox::Show();
}

/***************************************************************************
    Beschreibung:   zusammengefaltet wird nicht geidlet
***************************************************************************/


void    SwContentTree::Hide()
{
    aUpdTimer.Stop();
    SvTreeListBox::Hide();
}

/***************************************************************************
    Beschreibung:   Kein Idle mit Focus oder waehrend des Dragging
***************************************************************************/


IMPL_LINK( SwContentTree, TimerUpdate, Timer*, EMPTYARG)
{
    // kein Update waehrend D&D
    // Viewabfrage, da der Navigator zu spaet abgeraeumt wird
    SwView* pView = ::GetActiveView();
    if( (!HasFocus() || bViewHasChanged) &&
         !bIsInDrag && !bIsInternalDrag && pView &&
         pView->GetWrtShellPtr() && !pView->GetWrtShellPtr()->ActionPend() )
    {
        bViewHasChanged = sal_False;
        bIsIdleClear = sal_False;
        SwWrtShell* pActShell = pView->GetWrtShellPtr();
        if( bIsConstant && !lcl_FindShell( pActiveShell ) )
        {
            SetActiveShell(pActShell);
            GetParentWindow()->UpdateListBox();
        }

        if(bIsActive && pActShell != GetWrtShell())
            SetActiveShell(pActShell);
        else if( (bIsActive || (bIsConstant && pActShell == GetWrtShell())) &&
                    HasContentChanged())
        {
            FindActiveTypeAndRemoveUserData();
            Display(sal_True);
        }
    }
    else if(!pView && bIsActive && !bIsIdleClear)
    {
        if(pActiveShell)
            SetActiveShell(0);
        Clear();
        bIsIdleClear = sal_True;
    }
    return 0;
}

/***************************************************************************
    Beschreibung:
***************************************************************************/


DragDropMode  SwContentTree::NotifyBeginDrag( SvLBoxEntry* pEntry )
{
    DragDropMode eMode = (DragDropMode)0;
    if(bIsActive && nRootType == CONTENT_TYPE_OUTLINE &&
        GetModel()->GetAbsPos( pEntry ) > 0
        && !GetWrtShell()->GetView().GetDocShell()->IsReadOnly())
        eMode =  GetDragDropMode();
    else if(!bIsActive && GetWrtShell()->GetView().GetDocShell()->HasName())
        eMode = SV_DRAGDROP_APP_COPY;

    sal_uInt16 nDrgMode;
    FillDragServer(nDrgMode);
    bDocChgdInDragging = sal_False;
    return eMode;
}


/***************************************************************************
    Beschreibung :  Nach dem Drag wird der aktuelle Absatz m i t
                    Childs verschoben
***************************************************************************/


sal_Bool  SwContentTree::NotifyMoving( SvLBoxEntry*  pTarget,
        SvLBoxEntry*  pEntry, SvLBoxEntry*& , sal_uInt32& )
{
    if(!bDocChgdInDragging)
    {
        sal_uInt16 nTargetPos = 0;
        sal_uInt16 nSourcePos = (( SwOutlineContent* )pEntry->GetUserData())->GetPos();
        if(!lcl_IsContent(pTarget))
            nTargetPos = USHRT_MAX;
        else
            nTargetPos = (( SwOutlineContent* )pTarget->GetUserData())->GetPos();
        if( MAXLEVEL > nOutlineLevel && // werden nicht alle Ebenen angezeigt
                        nTargetPos != USHRT_MAX)
        {
            SvLBoxEntry* pNext = Next(pTarget);
            if(pNext)
                nTargetPos = (( SwOutlineContent* )pNext->GetUserData())->GetPos() -1;
            else
                nTargetPos = GetWrtShell()->GetOutlineCnt() - 1;

        }

        DBG_ASSERT( pEntry &&
            lcl_IsContent(pEntry),"Source == 0 oder Source hat keinen Content" )
        GetParentWindow()->MoveOutline( nSourcePos,
                                    nTargetPos,
                                    sal_True);

        aActiveContentArr[CONTENT_TYPE_OUTLINE]->Invalidate();
        Display(sal_True);
    }
    //TreeListBox wird aus dem Dokument neu geladen
    return sal_False;
}
/***************************************************************************
    Beschreibung :  Nach dem Drag wird der aktuelle Absatz o h n e
                    Childs verschoben
***************************************************************************/


sal_Bool  SwContentTree::NotifyCopying( SvLBoxEntry*  pTarget,
        SvLBoxEntry*  pEntry, SvLBoxEntry*& , sal_uInt32& )
{
    if(!bDocChgdInDragging)
    {
        sal_uInt16 nTargetPos = 0;
        sal_uInt16 nSourcePos = (( SwOutlineContent* )pEntry->GetUserData())->GetPos();
        if(!lcl_IsContent(pTarget))
            nTargetPos = USHRT_MAX;
        else
            nTargetPos = (( SwOutlineContent* )pTarget->GetUserData())->GetPos();

        if( MAXLEVEL > nOutlineLevel && // werden nicht alle Ebenen angezeigt
                        nTargetPos != USHRT_MAX)
        {
            SvLBoxEntry* pNext = Next(pTarget);
            if(pNext)
                nTargetPos = (( SwOutlineContent* )pNext->GetUserData())->GetPos() - 1;
            else
                nTargetPos = GetWrtShell()->GetOutlineCnt() - 1;

        }


        DBG_ASSERT( pEntry &&
            lcl_IsContent(pEntry),"Source == 0 oder Source hat keinen Content" )
        GetParentWindow()->MoveOutline( nSourcePos, nTargetPos, sal_False);

        //TreeListBox wird aus dem Dokument neu geladen
        aActiveContentArr[CONTENT_TYPE_OUTLINE]->Invalidate();
        Display(sal_True);
    }
    return sal_False;
}
/***************************************************************************
    Beschreibung:   Kein Drop vor den ersten Eintrag - es ist ein SwContentType
***************************************************************************/


sal_Bool  SwContentTree::NotifyQueryDrop( SvLBoxEntry* pEntry)
{
    return pEntry != 0;
}

/***************************************************************************
    Beschreibung:
***************************************************************************/


void  SwContentTree::BeginDrag( const Point& rPt)
{
    bIsInternalDrag = sal_True;
    SvTreeListBox::BeginDrag(rPt);
}
/***************************************************************************
    Beschreibung:
***************************************************************************/


void  SwContentTree::EndDrag()
{
    bIsInternalDrag = sal_False;
    SvTreeListBox::EndDrag();
}
/***************************************************************************
    Beschreibung:   Wird ein Ctrl+DoubleClick in einen freien Bereich ausgefuehrt,
 *                  dann soll die Basisfunktion des Controls gerufen werden
***************************************************************************/
void  SwContentTree::MouseButtonDown( const MouseEvent& rMEvt )
{
    Point aPos( rMEvt.GetPosPixel());
    SvLBoxEntry* pEntry = GetEntry( aPos, sal_True );
    if( !pEntry && rMEvt.IsLeft() && rMEvt.IsMod1() && (rMEvt.GetClicks() % 2) == 0)
        Control::MouseButtonDown( rMEvt );
    else
        SvTreeListBox::MouseButtonDown( rMEvt );
}

/***************************************************************************
    Beschreibung:   sofort aktualisieren
***************************************************************************/


void  SwContentTree::GetFocus()
{
    SwView* pActView = ::GetActiveView();
    if(pActView)
    {
        SwWrtShell* pActShell = pActView->GetWrtShellPtr();
        if(bIsConstant && !lcl_FindShell(pActiveShell))
        {
            SetActiveShell(pActShell);
        }

        if(bIsActive && pActShell != GetWrtShell())
            SetActiveShell(pActShell);
        else if( (bIsActive || (bIsConstant && pActShell == GetWrtShell())) &&
                    HasContentChanged())
        {
            Display(sal_True);
        }
    }
    else if(bIsActive)
        Clear();
    SvTreeListBox::GetFocus();
}

/***************************************************************************
    Beschreibung:
***************************************************************************/


void  SwContentTree::KeyInput(const KeyEvent& rEvent)
{
    const KeyCode aCode = rEvent.GetKeyCode();
    if(aCode.GetCode() == KEY_RETURN)
    {
        SvLBoxEntry* pEntry = FirstSelected();
        if ( pEntry )
        {
            switch(aCode.GetModifier())
            {
                case KEY_MOD2:
                    // Boxen umschalten
                    GetParentWindow()->ToggleTree();
                break;
                case KEY_MOD1:
                    // RootModus umschalten
                    ToggleToRoot();
                break;
                case 0:
                    if(lcl_IsContentType(pEntry))
                    {
                        IsExpanded(pEntry) ?
                            Collapse(pEntry) :
                                Expand(pEntry);
                    }
                    else
                        ContentDoubleClickHdl(0);
                break;
            }
        }
    }
    else if(aCode.GetCode() == KEY_DELETE && 0 == aCode.GetModifier())
    {
        SvLBoxEntry* pEntry = FirstSelected();
        if(pEntry &&
            lcl_IsContent(pEntry) &&
                ((SwContent*)pEntry->GetUserData())->GetParent()->IsDeletable() &&
                    !pActiveShell->GetView().GetDocShell()->IsReadOnly())
        {
            EditEntry(pEntry, EDIT_MODE_DELETE);
            GrabFocus();
        }
    }
    else
        SvTreeListBox::KeyInput(rEvent);

}

/***************************************************************************
    Beschreibung:
***************************************************************************/


void  SwContentTree::RequestHelp( const HelpEvent& rHEvt )
{
    if( rHEvt.GetMode() & HELPMODE_QUICK )
    {
        Point aPos( ScreenToOutputPixel( rHEvt.GetMousePosPixel() ));
        SvLBoxEntry* pEntry = GetEntry( aPos );
        if( pEntry )
        {
            sal_uInt16 nType;
            sal_Bool bBalloon = sal_False;
            sal_Bool bContent = sal_False;
            void* pUserData = pEntry->GetUserData();
            if(lcl_IsContentType(pEntry))
                nType = ((SwContentType*)pUserData)->GetType();
            else
            {
                nType = ((SwContent*)pUserData)->GetParent()->GetType();
                bContent = sal_True;
            }
            String sEntry;
            sal_Bool bRet = sal_False;
            if(bContent)
            {
                switch( nType )
                {
                    case CONTENT_TYPE_URLFIELD:
                        sEntry = ((SwURLFieldContent*)pUserData)->GetURL();
                        bRet = sal_True;
                    break;

                    case CONTENT_TYPE_POSTIT:
                        sEntry = ((SwPostItContent*)pUserData)->GetName();
                        bRet = sal_True;
                        if(Help::IsBalloonHelpEnabled())
                            bBalloon = sal_True;
                    break;
                    case CONTENT_TYPE_OUTLINE:
                        sEntry = ((SwOutlineContent*)pUserData)->GetName();
                        bRet = sal_True;
                    break;
                    case CONTENT_TYPE_GRAPHIC:
                        sEntry = ((SwGraphicContent*)pUserData)->GetLink();
#ifdef DEBUG
                        sEntry += ' ';
                        sEntry += String::CreateFromInt32(
                                    ((SwGraphicContent*)pUserData)->GetYPos());
#endif
                        bRet = sal_True;
                    break;
#ifdef DEBUG
                    case CONTENT_TYPE_TABLE:
                    case CONTENT_TYPE_FRAME:
                        sEntry = String::CreateFromInt32(
                                        ((SwContent*)pUserData)->GetYPos() );
                        bRet = sal_True;
                    break;
#endif
                }
                if(((SwContent*)pUserData)->IsInvisible())
                {
                    if(sEntry.Len())
                        sEntry += C2S(", ");
                    sEntry += sInvisible;
                    bRet = sal_True;
                }
            }
            else
            {
                sal_uInt16 nMemberCount = ((SwContentType*)pUserData)->GetMemberCount();
                sEntry = String::CreateFromInt32(nMemberCount);
                sEntry += ' ';
                sEntry += nMemberCount == 1
                            ? ((SwContentType*)pUserData)->GetSingleName()
                            : ((SwContentType*)pUserData)->GetName();
                bRet = sal_True;
            }
            if(bRet)
            {
                SvLBoxTab* pTab;
                SvLBoxItem* pItem = GetItem( pEntry, aPos.X(), &pTab );
                if( pItem && SV_ITEM_ID_LBOXSTRING == pItem->IsA())
                {
                    aPos = GetEntryPos( pEntry );

                    aPos.X() = GetTabPos( pEntry, pTab );
                    Size aSize( pItem->GetSize( this, pEntry ) );

                    if((aPos.X() + aSize.Width()) > GetSizePixel().Width())
                        aSize.Width() = GetSizePixel().Width() - aPos.X();

                    aPos = OutputToScreenPixel(aPos);
                    Rectangle aItemRect( aPos, aSize );
                    if(bBalloon)
                    {
                        aPos.X() += aSize.Width();
                        Help::ShowBalloon( this, aPos, aItemRect, sEntry );
                    }
                    else
                        Help::ShowQuickHelp( this, aItemRect, sEntry,
                            QUICKHELP_LEFT|QUICKHELP_VCENTER );
                }
            }
            else
                Help::ShowQuickHelp( this, Rectangle(), aEmptyStr, 0 );
        }
    }
}

/***************************************************************************
    Beschreibung:
***************************************************************************/


IMPL_LINK(SwContentTree, PopupHdl, Menu*, pMenu)
{
    sal_uInt16 nId = pMenu->GetCurItemId();
    SvLBoxEntry* pFirst = FirstSelected();
    switch( nId )
    {
        //Outlinelevel
        case 101:
        case 102:
        case 103:
        case 104:
        case 105:
        case 106:
        case 107:
        case 108:
        case 109:
        case 110:
            nId -= 100;
            if(nOutlineLevel != nId )
                SetOutlineLevel((sal_Int8)nId);
        break;
        case 201:
        case 202:
        case 203:
            GetParentWindow()->SetRegionDropMode(nId - 201);
        break;
        case 401:
        case 402:
            EditEntry(pFirst, nId == 401 ? EDIT_MODE_RMV_IDX : EDIT_MODE_UPD_IDX);
        break;
        // Eintrag bearbeiten
        case 403:
            EditEntry(pFirst);
        break;
        case 404:
            EditEntry(pFirst, EDIT_UNPROTECT_TABLE);
        break;
        case 405 :
        {
            const SwTOXBase* pBase = ((SwTOXBaseContent*)pFirst->GetUserData())
                                                                ->GetTOXBase();
            pActiveShell->SetTOXBaseReadonly(*pBase, !pMenu->IsItemChecked(nId));
        }
        break;
        case 4:
        break;
        case 501:
            EditEntry(pFirst, EDIT_MODE_DELETE);
        break;
        case 502 :
            EditEntry(pFirst, EDIT_MODE_RENAME);
        break;
        //Anzeige
        default: // nId > 300
        if(nId > 300 && nId < 400)
        {
            nId -= 300;
            SwView *pView = SwModule::GetFirstView();
            while (pView)
            {
                nId --;
                if(nId == 0)
                {
                    SetConstantShell(&pView->GetWrtShell());
                    break;
                }
                pView = SwModule::GetNextView(pView);
            }
            if(nId)
            {
                bViewHasChanged = bIsActive = nId==1;
                bIsConstant = sal_False;
                Display(nId == 1);
            }
        }
    }
    GetParentWindow()->UpdateListBox();
    return sal_True;
}

/***************************************************************************
    Beschreibung:
***************************************************************************/


void SwContentTree::SetOutlineLevel(sal_uInt8 nSet)
{
    nOutlineLevel = nSet;
    pConfig->SetOutlineLevel( nOutlineLevel );
    SwContentType** ppContentT = bIsActive ?
                    &aActiveContentArr[CONTENT_TYPE_OUTLINE] :
                        &aHiddenContentArr[CONTENT_TYPE_OUTLINE];
    if(*ppContentT)
    {
        (*ppContentT)->SetOutlineLevel(nOutlineLevel);
        (*ppContentT)->Init();
    }
    Display(bIsActive);
}

/***************************************************************************
    Beschreibung:   Moduswechsel: gedropptes Doc anzeigen
***************************************************************************/


void SwContentTree::ShowHiddenShell()
{
    if(pHiddenShell)
    {
        bIsConstant = sal_False;
        bIsActive = sal_False;
        Display(sal_False);
    }
}

/***************************************************************************
    Beschreibung:   Moduswechsel: aktive Sicht anzeigen
***************************************************************************/


void SwContentTree::ShowActualView()
{
    bIsActive = sal_True;
    bIsConstant = sal_False;
    Display(sal_True);
    GetParentWindow()->UpdateListBox();
}

/*-----------------20.11.96 13.34-------------------
    Beschreibung: Hier sollen die Buttons zum Verschieben von
                  Outlines en-/disabled werden
--------------------------------------------------*/

sal_Bool  SwContentTree::Select( SvLBoxEntry* pEntry, sal_Bool bSelect )
{
    if(!pEntry)
        return sal_False;
    sal_Bool bEnable = sal_False;
    SvLBoxEntry* pParentEntry = GetParent(pEntry);
    if(!bIsLastReadOnly && (!IsVisible() ||
        (bIsRoot && nRootType == CONTENT_TYPE_OUTLINE && pParentEntry ||
            lcl_IsContent(pEntry) && ((SwContentType*)pParentEntry->GetUserData())->GetType() == CONTENT_TYPE_OUTLINE)))
        bEnable = sal_True;
    SwNavigationPI* pNavi = GetParentWindow();
    pNavi->aContentToolBox.EnableItem(FN_ITEM_UP ,  bEnable);
    pNavi->aContentToolBox.EnableItem(FN_ITEM_DOWN, bEnable);
    pNavi->aContentToolBox.EnableItem(FN_ITEM_LEFT, bEnable);
    pNavi->aContentToolBox.EnableItem(FN_ITEM_RIGHT,bEnable);

    return SvTreeListBox::Select(pEntry, bSelect);
}

/*-----------------27.11.96 12.56-------------------

--------------------------------------------------*/

void SwContentTree::SetRootType(sal_uInt16 nType)
{
    nRootType = nType;
    bIsRoot = sal_True;
    pConfig->SetRootType( nRootType );
}

/*-----------------10.01.97 12.19-------------------

--------------------------------------------------*/

void SwContentType::RemoveNewline(String& rEntry)
{
    sal_Unicode* pStr = rEntry.GetBufferAccess();
    for(xub_StrLen i = rEntry.Len(); i; --i, ++pStr )
    {
        if( *pStr == 10 || *pStr == 13 )
            *pStr = 0x20;
    }
}

/*-----------------14.01.97 16.38-------------------

--------------------------------------------------*/

void SwContentTree::EditEntry(SvLBoxEntry* pEntry, sal_uInt8 nMode)
{
    SwContent* pCnt = (SwContent*)pEntry->GetUserData();
    GotoContent(pCnt);
    sal_uInt16 nType = pCnt->GetParent()->GetType();
    sal_uInt16 nSlot = 0;

    uno::Reference< container::XNameAccess >  xNameAccess, xSecond, xThird;
    switch(nType)
    {
        case CONTENT_TYPE_TABLE     :
            if(nMode == EDIT_UNPROTECT_TABLE)
            {
                pActiveShell->GetView().GetDocShell()->
                        GetDoc()->UnProtectCells( pCnt->GetName());
            }
            else if(nMode == EDIT_MODE_DELETE)
            {
                pActiveShell->StartAction();
                pActiveShell->StartUndo();
                pActiveShell->GetView().GetViewFrame()->GetDispatcher()->Execute(FN_TABLE_SELECT_ALL);
                pActiveShell->DeleteRow();
                pActiveShell->EndUndo();
                pActiveShell->EndAction();
            }
            else if(nMode == EDIT_MODE_RENAME)
            {
                uno::Reference< frame::XModel >  xModel = pActiveShell->GetView().GetDocShell()->GetBaseModel();
                uno::Reference< text::XTextTablesSupplier >  xTables(xModel, uno::UNO_QUERY);
                xNameAccess = xTables->getTextTables();
            }
            else
                nSlot = FN_FORMAT_TABLE_DLG;
        break;

        case CONTENT_TYPE_GRAPHIC   :
            if(nMode == EDIT_MODE_DELETE)
            {
                pActiveShell->DelRight();
            }
            else if(nMode == EDIT_MODE_RENAME)
            {
                uno::Reference< frame::XModel >  xModel = pActiveShell->GetView().GetDocShell()->GetBaseModel();
                uno::Reference< text::XTextGraphicObjectsSupplier >  xGraphics(xModel, uno::UNO_QUERY);
                xNameAccess = xGraphics->getGraphicObjects();
                uno::Reference< text::XTextFramesSupplier >  xFrms(xModel, uno::UNO_QUERY);
                xSecond = xFrms->getTextFrames();
                uno::Reference< text::XTextEmbeddedObjectsSupplier >  xObjs(xModel, uno::UNO_QUERY);
                xThird = xObjs->getEmbeddedObjects();
            }
            else
                nSlot = FN_FORMAT_GRAFIC_DLG;
        break;

        case CONTENT_TYPE_FRAME     :
        case CONTENT_TYPE_OLE       :
            if(nMode == EDIT_MODE_DELETE)
            {
                pActiveShell->DelRight();
            }
            else if(nMode == EDIT_MODE_RENAME)
            {
                uno::Reference< frame::XModel >  xModel = pActiveShell->GetView().GetDocShell()->GetBaseModel();
                uno::Reference< text::XTextFramesSupplier >  xFrms(xModel, uno::UNO_QUERY);
                uno::Reference< text::XTextEmbeddedObjectsSupplier >  xObjs(xModel, uno::UNO_QUERY);
                if(CONTENT_TYPE_FRAME == nType)
                {
                    xNameAccess = xFrms->getTextFrames();
                    xSecond = xObjs->getEmbeddedObjects();
                }
                else
                {
                    xNameAccess = xObjs->getEmbeddedObjects();
                    xSecond = xFrms->getTextFrames();
                }
                uno::Reference< text::XTextGraphicObjectsSupplier >  xGraphics(xModel, uno::UNO_QUERY);
                xThird = xGraphics->getGraphicObjects();
            }
            else
                nSlot = FN_FORMAT_FRAME_DLG;
        break;
        case CONTENT_TYPE_BOOKMARK  :
            if(nMode == EDIT_MODE_DELETE)
            {
                pActiveShell->DelBookmark( pCnt->GetName() );
            }
            else if(nMode == EDIT_MODE_RENAME)
            {
                uno::Reference< frame::XModel >  xModel = pActiveShell->GetView().GetDocShell()->GetBaseModel();
                uno::Reference< text::XBookmarksSupplier >  xBkms(xModel, uno::UNO_QUERY);
                xNameAccess = xBkms->getBookmarks();
            }
            else
                nSlot = FN_INSERT_BOOKMARK;
        break;

        case CONTENT_TYPE_REGION    :
            if(nMode == EDIT_MODE_RENAME)
            {
                uno::Reference< frame::XModel >  xModel = pActiveShell->GetView().GetDocShell()->GetBaseModel();
                uno::Reference< text::XTextSectionsSupplier >  xSects(xModel, uno::UNO_QUERY);
                xNameAccess = xSects->getTextSections();
            }
            else
                nSlot = FN_EDIT_REGION;
        break;

        case CONTENT_TYPE_URLFIELD:
            nSlot = FN_EDIT_HYPERLINK;
        break;
        case CONTENT_TYPE_REFERENCE:
            nSlot = FN_EDIT_FIELD;
        break;

        case CONTENT_TYPE_POSTIT:
            if(nMode == EDIT_MODE_DELETE)
            {
                pActiveShell->DelRight();
            }
            else
                nSlot = FN_POSTIT;
        break;
        case CONTENT_TYPE_INDEX:
        {
            const SwTOXBase* pBase = ((SwTOXBaseContent*)pCnt)->GetTOXBase();
            switch(nMode)
            {
                case EDIT_MODE_EDIT:
                    if(pBase)
                    {
                        SwPtrItem aPtrItem( FN_INSERT_MULTI_TOX, (void*)pBase);
                        pActiveShell->GetView().GetViewFrame()->
                            GetDispatcher()->Execute(FN_INSERT_MULTI_TOX,
                                            SFX_CALLMODE_ASYNCHRON, &aPtrItem, 0);

                    }
                break;
                case EDIT_MODE_UPD_IDX:
                    nSlot = FN_UPDATE_CUR_TOX;
                break;
                case EDIT_MODE_RMV_IDX:
                case EDIT_MODE_DELETE:
                {
                    if( pBase )
                        pActiveShell->DeleteTOX(*pBase, EDIT_MODE_DELETE == nMode);
                }
                break;
                case EDIT_MODE_RENAME:
                {
                    uno::Reference< frame::XModel >  xModel = pActiveShell->GetView().GetDocShell()->GetBaseModel();
                    uno::Reference< text::XDocumentIndexesSupplier >  xIndexes(xModel, uno::UNO_QUERY);
                    xNameAccess = uno::Reference< container::XNameAccess >(xIndexes, uno::UNO_QUERY);
                }
                break;
            }
        }
        break;

    }
    if(nSlot)
        pActiveShell->GetView().GetViewFrame()->
                    GetDispatcher()->Execute(nSlot, SFX_CALLMODE_ASYNCHRON);
    else if(xNameAccess.is())
    {
        uno::Any aObj = xNameAccess->getByName(pCnt->GetName());
        uno::Reference< uno::XInterface >  xTmp = *(uno::Reference< uno::XInterface > *)aObj.getValue();
        uno::Reference< container::XNamed >  xNamed(xTmp, uno::UNO_QUERY);
        SwRenameXNamedDlg aDlg(this, xNamed, xNameAccess);
        if(xSecond.is())
            aDlg.SetAlternativeAccess( xSecond, xThird);

        String sForbiddenChars;
        if(CONTENT_TYPE_BOOKMARK == nType)
        {
            sForbiddenChars = C2S("/\\@:*?\";,.# ");
        }
        else if(CONTENT_TYPE_TABLE == nType)
        {
            sForbiddenChars = C2S(" .<>");
        }
        aDlg.SetForbiddenChars(sForbiddenChars);
        aDlg.Execute();
    }
}

/*-----------------14.01.97 16.53-------------------

--------------------------------------------------*/

void SwContentTree::GotoContent(SwContent* pCnt)
{
    pActiveShell->EnterStdMode();

    sal_Bool bSel = sal_False;
    sal_uInt16 nJumpType = pCnt->GetParent()->GetType();
    switch(nJumpType)
    {
        case CONTENT_TYPE_OUTLINE   :
        {
            pActiveShell->GotoOutline(((SwOutlineContent*)pCnt)->GetPos());
        }
        break;
        case CONTENT_TYPE_TABLE     :
        {
            pActiveShell->GotoTable(pCnt->GetName());
        }
        break;
        case CONTENT_TYPE_FRAME     :
        case CONTENT_TYPE_GRAPHIC   :
        case CONTENT_TYPE_OLE       :
        {
            if(pActiveShell->GotoFly(pCnt->GetName()))
                bSel = sal_True;
        }
        break;
        case CONTENT_TYPE_BOOKMARK  :
        {
            pActiveShell->GotoBookmark(pCnt->GetName());
        }
        break;
        case CONTENT_TYPE_REGION    :
        {
            pActiveShell->GotoRegion(pCnt->GetName());
        }
        break;
        case CONTENT_TYPE_URLFIELD:
        {
            if(pActiveShell->GotoINetAttr(
                            *((SwURLFieldContent*)pCnt)->GetINetAttr() ))
            {
                pActiveShell->Right(sal_True, 1, sal_False);
                pActiveShell->SwCrsrShell::SelectTxtAttr( RES_TXTATR_INETFMT, sal_True );
            }

        }
        break;
        case CONTENT_TYPE_REFERENCE:
        {
            pActiveShell->GotoRefMark(pCnt->GetName());
        }
        break;
        case CONTENT_TYPE_INDEX:
        {
            if (!pActiveShell->GotoNextTOXBase(&pCnt->GetName()))
                pActiveShell->GotoPrevTOXBase(&pCnt->GetName());
        }
        break;
        case CONTENT_TYPE_POSTIT:
            pActiveShell->GotoFld(*((SwPostItContent*)pCnt)->GetPostIt());
        break;
        case CONTENT_TYPE_DRAWOBJECT:
            DBG_ERROR("unsupported format")
        break;
    }
    if(bSel)
    {
        pActiveShell->HideCrsr();
        pActiveShell->EnterSelFrmMode();
    }
    SwView& rView = pActiveShell->GetView();
    rView.StopShellTimer();
    rView.GetEditWin().GrabFocus();
}
/*-----------------06.02.97 19.14-------------------
    Jetzt nochtdie passende ::com::sun::star::text::Bookmark
--------------------------------------------------*/

NaviContentBookmark::NaviContentBookmark()
        :   nDefDrag( REGION_MODE_NONE ), nDocSh(0)
{
}

/*-----------------06.02.97 20.12-------------------

--------------------------------------------------*/

NaviContentBookmark::NaviContentBookmark( const String &rUrl,
                    const String& rDesc,
                    sal_uInt16 nDragType,
                    const SwDocShell* pDocSh ) :
    aUrl( rUrl ),
    aDescr(rDesc),
    nDefDrag( nDragType ),
    nDocSh((long)pDocSh)
{
}

/*-----------------06.02.97 19.17-------------------

--------------------------------------------------*/


sal_Bool    NaviContentBookmark::DragServerHasFormat( sal_uInt16 nItem,
                                                    const SwDocShell* pDocSh )
{
    sal_Bool bRet = sal_False;
    if(DragServer::HasFormat( nItem, SOT_FORMATSTR_ID_SONLK ))
    {
        long nDocSh = (long) pDocSh;
        NaviContentBookmark aTemp;
        aTemp.PasteDragServer(nItem);
        // steht vor dem # ein Dateiname?
        sal_uInt16 nFound = aTemp.GetURL().Search('#');
        // entweder die Quelle hatte einen Namen oder Quelle und Ziel sind gleich
        if(nFound != STRING_NOTFOUND &&
            (nFound > 0  ||
                nDocSh == aTemp.GetDocShell() ))
                bRet = sal_True;
    }
    return bRet;
}

/*-----------------06.02.97 19.17-------------------

--------------------------------------------------*/

sal_Bool NaviContentBookmark::CopyDragServer() const
{
     String aString( aUrl );
     aString += NAVI_BOOKMARK_DELIM;
     aString += aDescr;
     aString += NAVI_BOOKMARK_DELIM;
     aString += String::CreateFromInt32( nDefDrag );
     aString += NAVI_BOOKMARK_DELIM;
     aString += String::CreateFromInt32( nDocSh );

     return DragServer::CopyData( aString.GetBuffer(), (aString.Len() + 1) *2,
                                  SOT_FORMATSTR_ID_SONLK );
}
/*-----------------06.02.97 19.16-------------------

--------------------------------------------------*/

sal_Bool NaviContentBookmark::PasteDragServer( sal_uInt16 nItem )
{
    sal_Bool bRet = sal_False;
    if( DragServer::HasFormat( nItem, SOT_FORMATSTR_ID_SONLK ) )
    {
        sal_uInt32 nLen = DragServer::GetDataLen( nItem, SOT_FORMATSTR_ID_SONLK );
        String aString;
        DragServer::PasteData( nItem, aString.AllocBuffer(
                            nLen / 2 ), nLen, SOT_FORMATSTR_ID_SONLK );

        xub_StrLen nStrFndPos = 0;
        aUrl        = aString.GetToken(0, NAVI_BOOKMARK_DELIM, nStrFndPos );
        aDescr      = aString.GetToken(0, NAVI_BOOKMARK_DELIM, nStrFndPos );
        nDefDrag    = aString.GetToken(0, NAVI_BOOKMARK_DELIM,
                                        nStrFndPos ).ToInt32();
        nDocSh      = aString.GetToken(0, NAVI_BOOKMARK_DELIM,
                                        nStrFndPos ).ToInt32();
        bRet = sal_True;
    }
    return bRet;
}

/*-----------------06.02.97 20.43-------------------

--------------------------------------------------*/

sal_Bool NaviContentBookmark::Paste( SotDataObject& rObj, sal_uInt32 nFormat )
{
    sal_Bool bRet = sal_False;

    SvData aData( nFormat, MEDIUM_ALL );
    if( rObj.GetData( &aData ) )
    {
        void *pData;
        aData.GetData( &pData, TRANSFER_REFERENCE );

        if( nFormat == SOT_FORMATSTR_ID_SONLK )
        {
            String aString((sal_Unicode*)pData);
            xub_StrLen nStrFndPos = 0;
            aUrl        = aString.GetToken(0, NAVI_BOOKMARK_DELIM, nStrFndPos );
            aDescr      = aString.GetToken(0, NAVI_BOOKMARK_DELIM, nStrFndPos );
            nDefDrag    = aString.GetToken(0, NAVI_BOOKMARK_DELIM,
                                            nStrFndPos ).ToInt32();
            nDocSh      = aString.GetToken(0, NAVI_BOOKMARK_DELIM,
                                            nStrFndPos ).ToInt32();
            bRet = sal_True;
        }
    }
    return bRet;

}

/*-----------------07.02.97 08.23-------------------

--------------------------------------------------*/

sal_uInt32  NaviContentBookmark::HasFormat( SotDataObject& rObj )
{
    return rObj.GetTypeList().Get( SOT_FORMATSTR_ID_SONLK )
                ? SOT_FORMATSTR_ID_SONLK : 0;
}

/*-----------------20.02.97 15.37-------------------

--------------------------------------------------*/
IMPL_STATIC_LINK(SwContentTree, ExecDragHdl, SwContentTree*, EMPTYARG)
{
    SwContentTree::SetInDrag(sal_True);
    DropAction eDropAction = pThis->ExecuteDrag(Pointer(POINTER_MOVEDATA), Pointer(POINTER_COPYDATA), POINTER_LINKDATA, pThis->nDragMode );
    SwContentTree::SetInDrag(sal_False);
    return 0;
}
/* -----------------------------09.12.99 13:50--------------------------------

 ---------------------------------------------------------------------------*/
class SwContentLBoxString : public SvLBoxString
{
public:
    SwContentLBoxString( SvLBoxEntry* pEntry, sal_uInt16 nFlags,
        const String& rStr ) : SvLBoxString(pEntry,nFlags,rStr) {}

    virtual void Paint( const Point& rPos, SvLBox& rDev, sal_uInt16 nFlags,
        SvLBoxEntry* pEntry);
};

/* -----------------------------09.12.99 13:49--------------------------------

 ---------------------------------------------------------------------------*/
void SwContentTree::InitEntry(SvLBoxEntry* pEntry,
        const XubString& rStr ,const Image& rImg1,const Image& rImg2)
{
    sal_uInt16 nColToHilite = 1; //0==Bitmap;1=="Spalte1";2=="Spalte2"
    SvTreeListBox::InitEntry( pEntry, rStr, rImg1, rImg2 );
    SvLBoxString* pCol = (SvLBoxString*)pEntry->GetItem( nColToHilite );
    SwContentLBoxString* pStr = new SwContentLBoxString( pEntry, 0, pCol->GetText() );
    pEntry->ReplaceItem( pStr, nColToHilite );
}
/* -----------------------------09.12.99 13:49--------------------------------

 ---------------------------------------------------------------------------*/
void SwContentLBoxString::Paint( const Point& rPos, SvLBox& rDev, sal_uInt16 nFlags,
    SvLBoxEntry* pEntry )
{
    if(lcl_IsContent(pEntry) &&
            ((SwContent *)pEntry->GetUserData())->IsInvisible())
    {
        //* pCont = (SwContent*)pEntry->GetUserData();
        Font aOldFont( rDev.GetFont());
        Font aFont(aOldFont);
        Color aCol( COL_LIGHTGRAY );
        aFont.SetColor( aCol );
        rDev.SetFont( aFont );
        rDev.DrawText( rPos, GetText() );
        rDev.SetFont( aOldFont );
    }
    else
        SvLBoxString::Paint( rPos, rDev, nFlags, pEntry);
}

/*------------------------------------------------------------------------

    $Log: not supported by cvs2svn $
    Revision 1.2  2000/10/20 13:42:18  jp
    use correct INetURL-Decode enum

    Revision 1.1.1.1  2000/09/18 17:14:50  hr
    initial import

    Revision 1.161  2000/09/18 16:06:17  willem.vandorp
    OpenOffice header added.

    Revision 1.160  2000/09/08 15:11:58  os
    use configuration service

    Revision 1.159  2000/09/07 15:59:34  os
    change: SFX_DISPATCHER/SFX_BINDINGS removed

    Revision 1.158  2000/08/17 13:46:34  jp
    UI with decode URL; integer -> string bugs fixed

    Revision 1.157  2000/07/20 13:17:38  jp
    change old txtatr-character to the two new characters

    Revision 1.156  2000/07/03 08:54:55  jp
    must changes for VCL

    Revision 1.155  2000/06/30 10:25:49  os
    #63367# keep selected position in root mode, too

    Revision 1.154  2000/06/06 09:11:51  os
    76056# CreateFromInt32

    Revision 1.153  2000/05/23 19:54:16  jp
    Bugfixes for Unicode

    Revision 1.152  2000/04/26 15:03:20  os
    GetName() returns const String&

    Revision 1.151  2000/04/18 15:14:08  os
    UNICODE

    Revision 1.150  2000/03/23 07:51:10  os
    UNO III

    Revision 1.149  2000/03/03 15:17:05  os
    StarView remainders removed

    Revision 1.148  2000/02/22 16:56:35  jp
    Bug #73303#: new IsProtectedOutlinePara

    Revision 1.147  2000/02/11 15:00:33  hr
    #70473# changes for unicode ( patched by automated patchtool )

    Revision 1.146  2000/02/01 12:41:04  os
    #72443# visibility of section must be checked in SwContentType::Init

------------------------------------------------------------------------*/