summaryrefslogtreecommitdiff
path: root/sw/source/filter/ww8/ww8atr.cxx
blob: bf1a2779646b7c9543062f62c5a019386f15c707 (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
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
3359
3360
3361
3362
3363
3364
3365
3366
3367
3368
3369
3370
3371
3372
3373
3374
3375
3376
3377
3378
3379
3380
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390
3391
3392
3393
3394
3395
3396
3397
3398
3399
3400
3401
3402
3403
3404
3405
3406
3407
3408
3409
3410
3411
3412
3413
3414
3415
3416
3417
3418
3419
3420
3421
3422
3423
3424
3425
3426
3427
3428
3429
3430
3431
3432
3433
3434
3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
3447
3448
3449
3450
3451
3452
3453
3454
3455
3456
3457
3458
3459
3460
3461
3462
3463
3464
3465
3466
3467
3468
3469
3470
3471
3472
3473
3474
3475
3476
3477
3478
3479
3480
3481
3482
3483
3484
3485
3486
3487
3488
3489
3490
3491
3492
3493
3494
3495
3496
3497
3498
3499
3500
3501
3502
3503
3504
3505
3506
3507
3508
3509
3510
3511
3512
3513
3514
3515
3516
3517
3518
3519
3520
3521
3522
3523
3524
3525
3526
3527
3528
3529
3530
3531
3532
3533
3534
3535
3536
3537
3538
3539
3540
3541
3542
3543
3544
3545
3546
3547
3548
3549
3550
3551
3552
3553
3554
3555
3556
3557
3558
3559
3560
3561
3562
3563
3564
3565
3566
3567
3568
3569
3570
3571
3572
3573
3574
3575
3576
3577
3578
3579
3580
3581
3582
3583
3584
3585
3586
3587
3588
3589
3590
3591
3592
3593
3594
3595
3596
3597
3598
3599
3600
3601
3602
3603
3604
3605
3606
3607
3608
3609
3610
3611
3612
3613
3614
3615
3616
3617
3618
3619
3620
3621
3622
3623
/*************************************************************************
 *
 *  $RCSfile: ww8atr.cxx,v $
 *
 *  $Revision: 1.6 $
 *
 *  last change: $Author: jp $ $Date: 2001-01-16 17:18:46 $
 *
 *  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): _______________________________________
 *
 *
 ************************************************************************/

/*
 * Dieses File enthaelt alle Ausgabe-Funktionen des WW8-Writers;
 * fuer alle Nodes, Attribute, Formate und Chars.
 */

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

#pragma hdrstop

#define ITEMID_BOXINFO      SID_ATTR_BORDER_INNER

#ifndef _HINTIDS_HXX
#include <hintids.hxx>
#endif

#ifndef _APP_HXX //autogen
#include <vcl/svapp.hxx>
#endif
#ifndef _SV_SALBTYPE_HXX
#include <vcl/salbtype.hxx>
#endif
#ifndef _ZFORMAT_HXX
#include <svtools/zformat.hxx>
#endif
#ifndef _SFXITEMITER_HXX //autogen
#include <svtools/itemiter.hxx>
#endif
#ifndef _SVX_FONTITEM_HXX
#include <svx/fontitem.hxx>
#endif
#ifndef _SVX_TSTPITEM_HXX //autogen
#include <svx/tstpitem.hxx>
#endif
#ifndef _SVX_ADJITEM_HXX //autogen
#include <svx/adjitem.hxx>
#endif
#ifndef _SVX_SPLTITEM_HXX //autogen
#include <svx/spltitem.hxx>
#endif
#ifndef _SVX_WIDWITEM_HXX //autogen
#include <svx/widwitem.hxx>
#endif
#ifndef _SVX_LSPCITEM_HXX //autogen
#include <svx/lspcitem.hxx>
#endif
#ifndef _SVX_KEEPITEM_HXX //autogen
#include <svx/keepitem.hxx>
#endif
#ifndef _SVX_SHADITEM_HXX //autogen
#include <svx/shaditem.hxx>
#endif
#ifndef _SVX_BRSHITEM_HXX //autogen
#include <svx/brshitem.hxx>
#endif
#ifndef _SVX_POSTITEM_HXX //autogen
#include <svx/postitem.hxx>
#endif
#ifndef _SVX_WGHTITEM_HXX //autogen
#include <svx/wghtitem.hxx>
#endif
#ifndef _SVX_KERNITEM_HXX //autogen
#include <svx/kernitem.hxx>
#endif
#ifndef _SVX_CRSDITEM_HXX //autogen
#include <svx/crsditem.hxx>
#endif
#ifndef _SVX_CMAPITEM_HXX //autogen
#include <svx/cmapitem.hxx>
#endif
#ifndef _SVX_WRLMITEM_HXX //autogen
#include <svx/wrlmitem.hxx>
#endif
#ifndef _SVX_UDLNITEM_HXX //autogen
#include <svx/udlnitem.hxx>
#endif
#ifndef _SVX_LANGITEM_HXX //autogen
#include <svx/langitem.hxx>
#endif
#ifndef _SVX_ESCPITEM_HXX //autogen
#include <svx/escpitem.hxx>
#endif
#ifndef _SVX_FHGTITEM_HXX //autogen
#include <svx/fhgtitem.hxx>
#endif
#ifndef _SVX_COLRITEM_HXX //autogen
#include <svx/colritem.hxx>
#endif
#ifndef _SVX_HYZNITEM_HXX //autogen
#include <svx/hyznitem.hxx>
#endif
#ifndef _SVX_BRKITEM_HXX //autogen
#include <svx/brkitem.hxx>
#endif
#ifndef _SVX_LRSPITEM_HXX //autogen
#include <svx/lrspitem.hxx>
#endif
#ifndef _SVX_ULSPITEM_HXX //autogen
#include <svx/ulspitem.hxx>
#endif
#ifndef _SVX_BOXITEM_HXX //autogen
#include <svx/boxitem.hxx>
#endif
#ifndef _SVX_ITEM_HXX //autogen
#include <svx/cntritem.hxx>
#endif
#ifndef _SVX_SHDDITEM_HXX //autogen
#include <svx/shdditem.hxx>
#endif
#ifndef _SVX_AKRNITEM_HXX //autogen wg. SvxAutoKernItem
#include <svx/akrnitem.hxx>
#endif
#ifndef _SVX_PBINITEM_HXX //autogen wg. SvxPaperBinItem
#include <svx/pbinitem.hxx>
#endif
#ifndef _SVX_EMPHITEM_HXX
#include <svx/emphitem.hxx>
#endif

#ifndef _FMTFLD_HXX //autogen
#include <fmtfld.hxx>
#endif
#ifndef _FCHRFMT_HXX //autogen
#include <fchrfmt.hxx>
#endif
#ifndef _FMTFSIZE_HXX //autogen
#include <fmtfsize.hxx>
#endif
#ifndef _FMTPDSC_HXX //autogen
#include <fmtpdsc.hxx>
#endif
#ifndef _FMTHDFT_HXX //autogen
#include <fmthdft.hxx>
#endif
#ifndef _FMTORNT_HXX //autogen
#include <fmtornt.hxx>
#endif
#ifndef _FMTANCHR_HXX //autogen
#include <fmtanchr.hxx>
#endif
#ifndef _FMTCLDS_HXX //autogen
#include <fmtclds.hxx>
#endif
#ifndef _FMTSRND_HXX //autogen
#include <fmtsrnd.hxx>
#endif
#ifndef _FMTFTN_HXX //autogen
#include <fmtftn.hxx>
#endif
#ifndef _FMTFLCNT_HXX //autogen
#include <fmtflcnt.hxx>
#endif
#ifndef _FRMATR_HXX
#include <frmatr.hxx>
#endif
#ifndef _FMTINFMT_HXX //autogen wg. SwFmtINetFmt
#include <fmtinfmt.hxx>
#endif
#ifndef _TXTFLD_HXX //autogen wg. SwTxtFld
#include <txtfld.hxx>
#endif
#ifndef _TXTFTN_HXX //autogen wg. SwTxtFtn
#include <txtftn.hxx>
#endif
#ifndef _POOLFMT_HXX
#include <poolfmt.hxx>
#endif
#ifndef _DOC_HXX
#include <doc.hxx>          // Doc fuer Fussnoten
#endif
#ifndef _PARATR_HXX
#include <paratr.hxx>
#endif
#ifndef _FLDBAS_HXX
#include <fldbas.hxx>       // fuer SwField ...
#endif
#ifndef _DOCUFLD_HXX
#include <docufld.hxx>       // fuer SwField ...
#endif
#ifndef _FORMAT_HXX
#include <format.hxx>
#endif
#ifndef _PAGEDESC_HXX
#include <pagedesc.hxx>     // fuer SwPageDesc...
#endif
#ifndef _FLDDAT_HXX
#include <flddat.hxx>       // fuer Datum-Felder
#endif
#ifndef _NDTXT_HXX
#include <ndtxt.hxx>        // fuer Numrules
#endif
#ifndef _NDINDEX_HXX
#include <ndindex.hxx>
#endif
#ifndef _FMTHBSH_HXX //autogen
#include <fmthbsh.hxx>
#endif
#ifndef _SWRECT_HXX //autogen
#include <swrect.hxx>
#endif
#ifndef _REFFLD_HXX //autogen wg. SwGetRefField
#include <reffld.hxx>
#endif
#ifndef _FTNINFO_HXX
#include <ftninfo.hxx>
#endif
#ifndef _CHARFMT_HXX
#include <charfmt.hxx>
#endif
#ifndef _SECTION_HXX
#include <section.hxx>
#endif
#ifndef SW_LINEINFO_HXX
#include <lineinfo.hxx>
#endif
#ifndef SW_FMTLINE_HXX
#include <fmtline.hxx>
#endif
#ifndef _TOX_HXX
#include <tox.hxx>
#endif
#ifndef _FMTFTNTX_HXX
#include <fmtftntx.hxx>
#endif

#ifndef _UNOTOOLS_LOCALEDATAWRAPPER_HXX
#include <unotools/localedatawrapper.hxx>
#endif

#ifdef DEBUG
# ifndef _FMTCNTNT_HXX
#  include <fmtcntnt.hxx>
# endif
#endif

#ifndef _WRTWW8_HXX
#include <wrtww8.hxx>
#endif


#define APP_ASC(s)          AppendAscii( RTL_CONSTASCII_STRINGPARAM( s ))
#define ASIGN_ASC(s)        AssignAscii( RTL_CONSTASCII_STRINGPARAM( s ))
#define CREA_ASC(s)         String::CreateFromAscii( RTL_CONSTASCII_STRINGPARAM( s ))

/*
 * um nicht immer wieder nach einem Update festzustellen, das irgendwelche
 * Hint-Ids dazugekommen sind, wird hier definiert, die Groesse der Tabelle
 * definiert und mit der akt. verglichen. Bei unterschieden wird der
 * Compiler schon meckern.
 *
 * diese Section und die dazugeherigen Tabellen muessen in folgenden Files
 * gepflegt werden: rtf\rtfatr.cxx, sw6\sw6atr.cxx, w4w\w4watr.cxx
*/

#if !defined(MSC) && !defined(UNX) && !defined(PPC) && !defined(CSET) && !defined(__MWERKS__) && !defined(WTC)

#define ATTRFNTAB_SIZE 130
#if ATTRFNTAB_SIZE != POOLATTR_END - POOLATTR_BEGIN
#error "Attribut-Tabelle ist ungueltigt. Wurden neue Hint-ID's zugefuegt ??"
#endif

#if 0
#define FORMATTAB_SIZE 6
#if FORMATTAB_SIZE != RES_FMT_END - RES_FMT_BEGIN
#error "Format-Tabelle ist ungueltigt. Wurden neue Hint-ID's zugefuegt ??"
#endif
#endif

#define NODETAB_SIZE 3
#if NODETAB_SIZE != RES_NODE_END - RES_NODE_BEGIN
#error "Node-Tabelle ist ungueltigt. Wurden neue Hint-ID's zugefuegt ??"
#endif

#endif



extern void sw3io_ConvertToOldField( const SwField* pFld, USHORT& rWhich,
                              ULONG& rFmt, ULONG nFFVersion );


//#define WW8_OUT( rWrt, a ) ((SwWW8Writer&)rWrt).pO->Insert( (BYTE*)&a,\
//                   sizeof( a ), ((SwWW8Writer&)rWrt).pO->Count() )

#define WW8_OUT( rWrt, a ) \
    ((SwWW8Writer&)rWrt).OutSprmBytes( (BYTE*)&a, sizeof( a ) )



//------------------------------------------------------------
//  Forward-Declarationen
//------------------------------------------------------------
static Writer& OutWW8_SwFmtBreak( Writer& rWrt, const SfxPoolItem& rHt );
static Writer& OutWW8_SwNumRuleItem( Writer& rWrt, const SfxPoolItem& rHt );

//------------------------------------------------------------
//  Hilfsroutinen fuer Styles
//------------------------------------------------------------

/*
 * Format wie folgt ausgeben:
 *      - gebe die Attribute aus; ohne Parents!
 */

void SwWW8Writer::Out_SfxItemSet( const SfxItemSet& rSet,
                                  BOOL bPapFmt, BOOL bChpFmt )
{
    if( rSet.Count() )
    {
        const SfxPoolItem* pItem;
        FnAttrOut pOut;

        pISet = &rSet;                  // fuer Doppel-Attribute

        // first the NumRule and than the LRSpace, so will W97 understand it
        // and move away the paragraph from the left side
        if( bPapFmt && SFX_ITEM_SET == rSet.GetItemState( RES_PARATR_NUMRULE,
                                                            FALSE, &pItem ))
        {
            pOut = aWW8AttrFnTab[ RES_PARATR_NUMRULE - RES_CHRATR_BEGIN ];
            (*pOut)( *this, *pItem );
            // switch off the numerbering?
            if( !((SwNumRuleItem*)pItem)->GetValue().Len() && SFX_ITEM_SET
                != rSet.GetItemState( RES_LR_SPACE, FALSE ) && SFX_ITEM_SET
                == rSet.GetItemState( RES_LR_SPACE, TRUE, &pItem ) )
            {
                // the set the LR-Space of the parentformat!
                pOut = aWW8AttrFnTab[ RES_LR_SPACE - RES_CHRATR_BEGIN ];
                (*pOut)( *this, *pItem );
            }
        }

        SfxItemIter aIter( rSet );
        pItem = aIter.GetCurItem();

        do {
            register USHORT nWhich = pItem->Which();
            pOut = aWW8AttrFnTab[nWhich - RES_CHRATR_BEGIN];
            if( 0 != pOut && (!bPapFmt || RES_PARATR_NUMRULE != nWhich ))
            {
                BOOL bChp = nWhich >= RES_CHRATR_BEGIN
                            && nWhich < RES_TXTATR_END;
                BOOL bPap = nWhich >= RES_PARATR_BEGIN
                            && nWhich < RES_FRMATR_END;
                if( ( bChpFmt && bChp  ) || ( bPapFmt && bPap ) )
                    (*pOut)( *this, *pItem );
            }
        } while( !aIter.IsAtEnd() && 0 != ( pItem = aIter.NextItem() ) );

        pISet = 0;                      // fuer Doppel-Attribute
    }
}

// Da WW nur Break-After ( Pagebreak und Sectionbreaks ) kennt, im SW aber
// Bagebreaks "vor" und "nach" und Pagedescs nur "vor" existieren, werden
// die Breaks 2* durchgeklimpert, naemlich vor und hinter jeder Zeile.
// Je nach BreakTyp werden sie vor oder nach der Zeile gesetzt.
// Es duerfen nur Funktionen gerufen werden, die nicht in den
// Ausgabebereich pO schreiben, da dieser nur einmal fuer CHP und PAP existiert
// und damit im falschen landen wuerden.
void SwWW8Writer::Out_SfxBreakItems( const SfxItemSet& rSet, const SwNode& rNd )
{
    if( rSet.Count() )
    {
        bBreakBefore = TRUE;

        const SfxPoolItem* pItem;
        if( !bStyDef && !bOutKF && !bOutPageDescs && SFX_ITEM_SET ==
            rSet.GetItemState( RES_PAGEDESC, FALSE, &pItem ) &&
            ((SwFmtPageDesc*)pItem)->GetRegisteredIn() )
        {
            // Die PageDescs werden beim Auftreten von PageDesc-Attributen nur
            // in WW8Writer::pSepx mit der entsprechenden Position eingetragen.
            // Das Aufbauen und die Ausgabe der am PageDesc haengenden Attribute
            // und Kopf/Fusszeilen passiert nach dem Haupttext und seinen Attributen.
            const SwFmtPageDesc& rPgDesc = *(SwFmtPageDesc*)pItem;
            pAktPageDesc = rPgDesc.GetPageDesc();
            if( pAktPageDesc )
            {
                ULONG nFcPos = ReplaceCr( 0x0c ); // Page/Section-Break

                // tatsaechlich wird hier NOCH NICHTS ausgegeben, sondern
                // nur die Merk-Arrays aCps, aSects entsprechend ergaenzt
                if( nFcPos )
                    pSepx->AppendSep( Fc2Cp( nFcPos ), rPgDesc, rNd,
                                      ((SwFmtLineNumber&)rSet.Get(
                                            RES_LINENUMBER )).GetStartValue());
            }
        }
        else if( SFX_ITEM_SET == rSet.GetItemState( RES_BREAK, FALSE, &pItem ) )
            OutWW8_SwFmtBreak( *this, *pItem );

        bBreakBefore = FALSE;
    }
}

void SwWW8Writer::CorrTabStopInSet( SfxItemSet& rSet, USHORT nAbsLeft )
{
    const SfxPoolItem* pItem;
    if( SFX_ITEM_SET == rSet.GetItemState( RES_PARATR_TABSTOP, TRUE, &pItem ))
    {
        // dann muss das fuer die Ausgabe korrigiert werden
        SvxTabStopItem aTStop( *(SvxTabStopItem*)pItem );
        for( USHORT nCnt = 0; nCnt < aTStop.Count(); ++nCnt )
        {
            SvxTabStop& rTab = (SvxTabStop&)aTStop[ nCnt ];
            if( SVX_TAB_ADJUST_DEFAULT != rTab.GetAdjustment() &&
                rTab.GetTabPos() >= nAbsLeft )
                rTab.GetTabPos() -= nAbsLeft;
            else
            {
                aTStop.Remove( nCnt );
                --nCnt;
            }
        }
        rSet.Put( aTStop );
    }
}

BYTE SwWW8Writer::GetNumId( USHORT eNumType )
{
    BYTE nRet = 0;
    switch( eNumType )
    {
    case SVX_NUM_CHARS_UPPER_LETTER:
    case SVX_NUM_CHARS_UPPER_LETTER_N:  nRet = 3;       break;
    case SVX_NUM_CHARS_LOWER_LETTER:
    case SVX_NUM_CHARS_LOWER_LETTER_N:  nRet = 4;       break;
    case SVX_NUM_ROMAN_UPPER:           nRet = 1;       break;
    case SVX_NUM_ROMAN_LOWER:           nRet = 2;       break;

    case SVX_NUM_BITMAP:
    case SVX_NUM_CHAR_SPECIAL:          nRet = 23;      break;

    // nix, macht WW undokumentiert auch so
    case SVX_NUM_NUMBER_NONE:           nRet = 0xff;    break;
    }
    return nRet;
}

void SwWW8Writer::Out_SwFmt( const SwFmt& rFmt, BOOL bPapFmt, BOOL bChpFmt,
                                BOOL bFlyFmt )
{
    BOOL bCallOutSet = TRUE;
    const SwModify* pOldMod = pOutFmtNode;
    pOutFmtNode = &rFmt;

    switch( rFmt.Which() )
    {
    case RES_CONDTXTFMTCOLL:
    case RES_TXTFMTCOLL:
        if( bPapFmt )
        {
            BYTE nLvl = ((const SwTxtFmtColl&)rFmt).GetOutlineLevel();
            if( MAXLEVEL > nLvl )
            {
                // if Write StyleDefinition then write the OutlineRule
                const SwNumFmt& rNFmt = pDoc->GetOutlineNumRule()->Get(nLvl);
                if( bStyDef )
                {
                    if( nLvl >= nWW8MaxListLevel )
                        nLvl = nWW8MaxListLevel-1;

                    if( bWrtWW8 )
                    {
                        // write sprmPIlvl and sprmPIlfo
                        SwWW8Writer::InsUInt16( *pO, 0x260a );
                        pO->Insert( nLvl, pO->Count() );
                        SwWW8Writer::InsUInt16( *pO, 0x460b );
                        SwWW8Writer::InsUInt16( *pO, 1 + GetId(
                                            *pDoc->GetOutlineNumRule() ) );
                    }
                    else
                    {
                        Out_SwNumLvl( nLvl );
                        if( rNFmt.GetAbsLSpace() )
                        {
                            SwNumFmt aNumFmt( rNFmt );
                            const SvxLRSpaceItem& rLR = (SvxLRSpaceItem&)
                                            rFmt.GetAttr( RES_LR_SPACE );
                            aNumFmt.SetAbsLSpace(
                                    aNumFmt.GetAbsLSpace() + rLR.GetLeft() );
                            Out_NumRuleAnld( *pDoc->GetOutlineNumRule(),
                                            aNumFmt, nLvl );
                        }
                        else
                            Out_NumRuleAnld( *pDoc->GetOutlineNumRule(),
                                            rNFmt, nLvl );
                    }
                }

                if( rNFmt.GetAbsLSpace() )
                {
                    SfxItemSet aSet( rFmt.GetAttrSet() );
                    SvxLRSpaceItem aLR( (SvxLRSpaceItem&)aSet.Get( RES_LR_SPACE ) );

                    aLR.SetTxtLeft( aLR.GetTxtLeft() + rNFmt.GetAbsLSpace() );
                    aLR.SetTxtFirstLineOfst( rNFmt.GetFirstLineOffset() );

                    aSet.Put( aLR );
                    SwWW8Writer::CorrTabStopInSet( aSet, rNFmt.GetAbsLSpace() );
                    Out_SfxItemSet( aSet, bPapFmt, bChpFmt );
                    bCallOutSet = FALSE;
                }
            }
        }
        break;

    case RES_CHRFMT:    break;
    case RES_FLYFRMFMT:
        if( bFlyFmt )
        {
            SfxItemSet aSet( pDoc->GetAttrPool(), RES_FRMATR_BEGIN,
                                                RES_FRMATR_END-1 );
            aSet.Set( pFlyFmt->GetAttrSet() );

            // Fly als Zeichen werden bei uns zu Absatz-gebundenen
            // jetzt den Abstand vom Absatz-Rand setzen
            if( pFlyOffset )
            {
                aSet.Put( SwFmtVertOrient( pFlyOffset->Y() ));
                aSet.Put( SwFmtHoriOrient( pFlyOffset->X() ));
            }

            if( SFX_ITEM_SET != aSet.GetItemState( RES_SURROUND ))
                aSet.Put( SwFmtSurround( SURROUND_NONE ) );

            bOutFlyFrmAttrs  = TRUE;
            Out_SfxItemSet( aSet, TRUE, FALSE );
            bOutFlyFrmAttrs = FALSE;

            bCallOutSet = FALSE;
        }
        break;
    default:            ASSERT( !this, "Was wird hier ausgegeben ??? " );
                        break;
    }

    if( bCallOutSet )
        Out_SfxItemSet( rFmt.GetAttrSet(), bPapFmt, bChpFmt );
    pOutFmtNode = pOldMod;
}

BOOL SwWW8Writer::HasRefToObject( USHORT nTyp, const String* pNm,
                                    USHORT nSeqNo )
{
    BOOL bFnd = FALSE;
    const SwTxtNode* pNd;
    SwClientIter aIter( *pDoc->GetSysFldType( RES_GETREFFLD ));
    for( SwFmtFld* pFld = (SwFmtFld*)aIter.First( TYPE( SwFmtFld ));
            pFld && !bFnd; pFld = (SwFmtFld*)aIter.Next() )
        if( pFld->GetTxtFld() && nTyp == pFld->GetFld()->GetSubType() &&
            0 != ( pNd = pFld->GetTxtFld()->GetpTxtNode() ) &&
            pNd->GetNodes().IsDocNodes() )
        {
            const SwGetRefField& rRFld = *(SwGetRefField*)pFld->GetFld();
            switch( nTyp )
            {
            case REF_BOOKMARK:
            case REF_SETREFATTR:    bFnd = *pNm == rRFld.GetSetRefName(); break;
            case REF_FOOTNOTE:
            case REF_ENDNOTE:       bFnd = nSeqNo == rRFld.GetSeqNo(); break;

            case REF_SEQUENCEFLD:   break;      // ???
            case REF_OUTLINE:       break;      // ???
            }
        }

    return bFnd;
}

String SwWW8Writer::GetBookmarkName( USHORT nTyp, const String* pNm,
                                    USHORT nSeqNo )
{
    String sRet;
    switch( nTyp )
    {
    case REF_SETREFATTR:    (sRet.APP_ASC( "Ref_" )) += *pNm; break;
    case REF_SEQUENCEFLD:   break;      // ???
    case REF_BOOKMARK:      sRet = *pNm;    break;
    case REF_OUTLINE:       break;      // ???
    case REF_FOOTNOTE:      (sRet.APP_ASC( "_RefF" ))
                                += String::CreateFromInt32( nSeqNo );
                            break;
    case REF_ENDNOTE:       (sRet.APP_ASC( "_RefE" ))
                                += String::CreateFromInt32( nSeqNo );
                            break;
    }
    return sRet;
}

//-----------------------------------------------------------------------
/*  */
/* File CHRATR.HXX: */

static Writer& OutWW8_SwBoldUSW( Writer& rWrt, BYTE nId, BOOL bVal )
{
    SwWW8Writer& rWrtWW8 = (SwWW8Writer&)rWrt;
    if( rWrtWW8.bWrtWW8 )
        rWrtWW8.InsUInt16( 7 == nId ? 0x2a53 : 0x0835 + nId );
    else if( 7 == nId )
        return rWrt;            // das Attribut gibt es im WW6 nicht
    else
        rWrtWW8.pO->Insert( 85 + nId, rWrtWW8.pO->Count() );
    rWrtWW8.pO->Insert( bVal ? 1 : 0, rWrtWW8.pO->Count() );
    return rWrt;
}

static Writer& OutWW8_SwFont( Writer& rWrt, const SfxPoolItem& rHt )
{
    const SvxFontItem& rAttr = (const SvxFontItem&)rHt;
    SwWW8Writer& rWrtWW8 = (SwWW8Writer&)rWrt;
    USHORT nFontID= rWrtWW8.GetId( rAttr );

    if( rWrtWW8.bWrtWW8 )
    {
        // what about sprmCIdctHint (286F) ??
        rWrtWW8.InsUInt16( 0x4a4f );
        rWrtWW8.InsUInt16( nFontID );
        rWrtWW8.InsUInt16( 0x4a51 );
    }
    else
        rWrtWW8.pO->Insert( 93, rWrtWW8.pO->Count() );
    rWrtWW8.InsUInt16( nFontID );
    return rWrt;
}

static Writer& OutWW8_SwCJKFont( Writer& rWrt, const SfxPoolItem& rHt )
{
    SwWW8Writer& rWrtWW8 = (SwWW8Writer&)rWrt;
    if( rWrtWW8.bWrtWW8 )
    {
        rWrtWW8.InsUInt16( 0x286f );
        rWrtWW8.pO->Insert( 1, rWrtWW8.pO->Count() );
        rWrtWW8.InsUInt16( 0x4a50 );
        rWrtWW8.InsUInt16( rWrtWW8.GetId( (const SvxFontItem&)rHt ) );
    }
    return rWrt;
}

static Writer& OutWW8_SwPosture( Writer& rWrt, const SfxPoolItem& rHt )
{
    return OutWW8_SwBoldUSW( rWrt, 1,
                ITALIC_NONE != ((const SvxPostureItem&)rHt).GetPosture() );
}

static Writer& OutWW8_SwWeight( Writer& rWrt, const SfxPoolItem& rHt )
{
    return OutWW8_SwBoldUSW( rWrt, 0,
                WEIGHT_BOLD == ((const SvxWeightItem&)rHt).GetWeight() );
}

// Shadowed und Contour gibts in WW-UI nicht. JP: ??
static Writer& OutWW8_SwContour( Writer& rWrt, const SfxPoolItem& rHt )
{
    return OutWW8_SwBoldUSW( rWrt, 3,
                            ((const SvxContourItem&)rHt).GetValue() );
}

static Writer& OutWW8_SwShadow( Writer& rWrt, const SfxPoolItem& rHt )
{
    return OutWW8_SwBoldUSW( rWrt, 4,
                            ((const SvxShadowedItem&)rHt).GetValue() );
}

static Writer& OutWW8_SwKerning( Writer& rWrt, const SfxPoolItem& rHt )
{
    const SvxKerningItem& rAttr = (const SvxKerningItem&)rHt;
    SwWW8Writer& rWrtWW8 = (SwWW8Writer&)rWrt;
    if( rWrtWW8.bWrtWW8 )
        rWrtWW8.InsUInt16( 0x8840 );
    else
        rWrtWW8.pO->Insert( 96, rWrtWW8.pO->Count() );
    rWrtWW8.InsUInt16( rAttr.GetValue() );
    return rWrt;
}

static Writer& OutWW8_SvxAutoKern( Writer& rWrt, const SfxPoolItem& rHt )
{
    const SvxAutoKernItem& rAttr = (const SvxAutoKernItem&)rHt;
    SwWW8Writer& rWrtWW8 = (SwWW8Writer&)rWrt;
    if( rWrtWW8.bWrtWW8 )
        rWrtWW8.InsUInt16( 0x484B );
    else
        rWrtWW8.pO->Insert( 107, rWrtWW8.pO->Count() );
    rWrtWW8.pO->Insert( rAttr.GetValue() ? 1 : 0, rWrtWW8.pO->Count() );
    return rWrt;
}


static Writer& OutWW8_SwCrossedOut( Writer& rWrt, const SfxPoolItem& rHt )
{
    FontStrikeout eSt = ((const SvxCrossedOutItem&)rHt).GetStrikeout();
    if( STRIKEOUT_DOUBLE == eSt )
        return OutWW8_SwBoldUSW( rWrt, 7, TRUE );
    if( STRIKEOUT_NONE != eSt )
        return OutWW8_SwBoldUSW( rWrt, 2, TRUE );

    // dann auch beide ausschalten!
    OutWW8_SwBoldUSW( rWrt, 7, FALSE );
    return OutWW8_SwBoldUSW( rWrt, 2, FALSE );
}

static Writer& OutWW8_SwCaseMap( Writer& rWrt, const SfxPoolItem& rHt )
{
    USHORT eSt = ((const SvxCaseMapItem&)rHt).GetValue();
    if( SVX_CASEMAP_KAPITAELCHEN == eSt )
        return OutWW8_SwBoldUSW( rWrt, 5, TRUE );
    if( SVX_CASEMAP_VERSALIEN == eSt )
        return OutWW8_SwBoldUSW( rWrt, 6, TRUE );

    // dann auch beide ausschalten!
    OutWW8_SwBoldUSW( rWrt, 5, FALSE );
    return OutWW8_SwBoldUSW( rWrt, 6, FALSE );
}

static Writer& OutWW8_SwUnderline( Writer& rWrt, const SfxPoolItem& rHt )
{
    const SvxUnderlineItem& rAttr = (const SvxUnderlineItem&)rHt;
    SwWW8Writer& rWrtWW8 = (SwWW8Writer&)rWrt;
    if( rWrtWW8.bWrtWW8 )
        rWrtWW8.InsUInt16( 0x2A3E );
    else
        rWrtWW8.pO->Insert( 94, rWrtWW8.pO->Count() );

    const SfxPoolItem* pItem = ((SwWW8Writer&)rWrt).HasItem(
                                            RES_CHRATR_WORDLINEMODE );
    BOOL bWord = pItem ? ((const SvxWordLineModeItem*)pItem)->GetValue() : FALSE;

        // WW95 - parameters:   0 = none,   1 = single, 2 = by Word,
        //                      3 = double, 4 = dotted, 5 = hidden
        // WW97 - additional parameters:
                            //  6 = thick,   7 = dash,       8 = dot(not used)
                            //  9 = dotdash 10 = dotdotdash, 11 = wave
    BYTE b = 0;
    switch( rAttr.GetUnderline() )
    {
    case UNDERLINE_SINGLE:          b = ( bWord ) ? 2 : 1;          break;
    case UNDERLINE_BOLD:            b = rWrtWW8.bWrtWW8 ?  6 : 1;   break;
    case UNDERLINE_DOUBLE:          b = 3;                          break;
    case UNDERLINE_DOTTED:          b = 4;                          break;
    case UNDERLINE_DASH:            b = rWrtWW8.bWrtWW8 ?  7 : 4;   break;
    case UNDERLINE_DASHDOT:         b = rWrtWW8.bWrtWW8 ?  9 : 4;   break;
    case UNDERLINE_DASHDOTDOT:      b = rWrtWW8.bWrtWW8 ? 10 : 4;   break;
    case UNDERLINE_WAVE:            b = rWrtWW8.bWrtWW8 ? 11 : 3;   break;
    // -------------  new in WW2000  -------------------------------------
    case UNDERLINE_BOLDDOTTED:      b = rWrtWW8.bWrtWW8 ? 20 : 4;   break;
    case UNDERLINE_BOLDDASH:        b = rWrtWW8.bWrtWW8 ? 23 : 4;   break;
    case UNDERLINE_LONGDASH:        b = rWrtWW8.bWrtWW8 ? 39 : 4;   break;
    case UNDERLINE_BOLDLONGDASH:    b = rWrtWW8.bWrtWW8 ? 55 : 4;   break;
    case UNDERLINE_BOLDDASHDOT:     b = rWrtWW8.bWrtWW8 ? 25 : 4;   break;
    case UNDERLINE_BOLDDASHDOTDOT:  b = rWrtWW8.bWrtWW8 ? 26 : 4;   break;
    case UNDERLINE_BOLDWAVE:        b = rWrtWW8.bWrtWW8 ? 27 : 3;   break;
    case UNDERLINE_DOUBLEWAVE:      b = rWrtWW8.bWrtWW8 ? 43 : 3;   break;
    }

    rWrtWW8.pO->Insert( b, rWrtWW8.pO->Count() );
    return rWrt;
}

static Writer& OutWW8_SwLanguage( Writer& rWrt, const SfxPoolItem& rHt )
{
    USHORT nId = 0;
    SwWW8Writer& rWrtWW8 = (SwWW8Writer&)rWrt;
    if( rWrtWW8.bWrtWW8 )
        switch( rHt.Which() )
        {
        case RES_CHRATR_LANGUAGE:       nId = 0x486D; break;
        case RES_CHRATR_CJK_LANGUAGE:   nId = 0x486E; break;
        }
    else
        nId = 97;

    if( nId )
    {
        if( rWrtWW8.bWrtWW8 )
            rWrtWW8.InsUInt16( nId );   // use sprmCRgLid0 rather than sprmCLid
        else
            rWrtWW8.pO->Insert( (BYTE)nId, rWrtWW8.pO->Count() );
        rWrtWW8.InsUInt16( ((const SvxLanguageItem&)rHt).GetLanguage() );
    }
    return rWrt;
}

static Writer& OutWW8_SwEscapement( Writer& rWrt, const SfxPoolItem& rHt )
{
    const SvxEscapementItem& rAttr = (const SvxEscapementItem&)rHt;
    SwWW8Writer& rWrtWW8 = (SwWW8Writer&)rWrt;

    BYTE b = 0xFF;
    short nEsc = rAttr.GetEsc(), nProp = rAttr.GetProp();
    if( !nEsc )
    {
        b = 0;
        nEsc = 0;
        nProp = 100;
    }
    else if( DFLT_ESC_PROP == nProp )
    {
        if( DFLT_ESC_SUB == nEsc || DFLT_ESC_AUTO_SUB == nEsc )
            b = 2;
        else if( DFLT_ESC_SUPER == nEsc || DFLT_ESC_AUTO_SUPER == nEsc )
            b = 1;
    }

    if( 0xFF != b )
    {
        if( rWrtWW8.bWrtWW8 )
            rWrtWW8.InsUInt16( 0x2A48 );
        else
            rWrtWW8.pO->Insert( 104, rWrtWW8.pO->Count() );
        rWrtWW8.pO->Insert( b, rWrtWW8.pO->Count() );
    }

    if( 0 == b || 0xFF == b )
    {
        long nHeight = ((SvxFontHeightItem&)rWrtWW8.GetItem(
                                    RES_CHRATR_FONTSIZE )).GetHeight();
        if( rWrtWW8.bWrtWW8 )
            rWrtWW8.InsUInt16( 0x4845 );
        else
            rWrtWW8.pO->Insert( 101, rWrtWW8.pO->Count() );
        rWrtWW8.InsUInt16( (short)(( nHeight * nEsc + 500 ) / 1000 ));

        if( 100 != nProp || !b )
        {
            if( rWrtWW8.bWrtWW8 )
                rWrtWW8.InsUInt16( 0x4A43 );
            else
                rWrtWW8.pO->Insert( 99, rWrtWW8.pO->Count() );
            rWrtWW8.InsUInt16( ( nHeight * nProp + 500 ) / 1000 );
        }
    }
    return rWrt;
}

static Writer& OutWW8_SwSize( Writer& rWrt, const SfxPoolItem& rHt )
{
    SwWW8Writer& rWrtWW8 = (SwWW8Writer&)rWrt;
    USHORT nId = 0;
    if( rWrtWW8.bWrtWW8 )
        switch ( rHt.Which() )
        {
        case RES_CHRATR_FONTSIZE:
        case RES_CHRATR_CJK_FONTSIZE:   nId = 0x4A43;   break;
        }
    else
        nId = 99;

    if( nId )
    {
        if( rWrtWW8.bWrtWW8 )
            rWrtWW8.InsUInt16( nId );
        else
            rWrtWW8.pO->Insert( (BYTE)nId, rWrtWW8.pO->Count() );

        const SvxFontHeightItem& rAttr = (const SvxFontHeightItem&)rHt;
        rWrtWW8.InsUInt16( (UINT16)(( rAttr.GetHeight() + 5 ) / 10 ) );
    }
    return rWrt;
}

static Writer& OutWW8_EmphasisMark( Writer& rWrt, const SfxPoolItem& rHt )
{
    SwWW8Writer& rWrtWW8 = (SwWW8Writer&)rWrt;
    if( rWrtWW8.bWrtWW8 )
    {
        BYTE nVal;
        switch ( ((const SvxEmphasisMarkItem&)rHt).GetValue() )
        {
        case EMPHASISMARK_NONE:             nVal = 0;   break;
        case EMPHASISMARK_SIDE_DOTS:        nVal = 2;   break;
        case EMPHASISMARK_CIRCLE_ABOVE:     nVal = 3;   break;
        case EMPHASISMARK_DOTS_BELOW:       nVal = 4;   break;
//      case 1:
        default:                            nVal = 1;   break;
        }

        rWrtWW8.InsUInt16( 0x2A34 );
        rWrtWW8.pO->Insert( nVal, rWrtWW8.pO->Count() );
    }
    return rWrt;
}


// TransCol uebersetzt SW-Farben in WW. Heraus kommt die bei WW fuer
// Text- und Hintergrundfarbe benutzte Codierung.
// Gibt es keine direkte Entsprechung, dann wird versucht, eine moeglichst
// aehnliche WW-Farbe zu finden.
// return: 5-Bit-Wert ( 0..16 )
BYTE SwWW8Writer::TransCol( const Color& rCol )
{
    BYTE nCol = 0;      // ->Auto
    switch( rCol.GetColor() )
    {
    case COL_BLACK:         nCol = 1;   break;
    case COL_BLUE:          nCol = 9;   break;
    case COL_GREEN:         nCol = 11;  break;
    case COL_CYAN:          nCol = 10;  break;
    case COL_RED:           nCol = 13;  break;
    case COL_MAGENTA:       nCol = 12;  break;
    case COL_BROWN:         nCol = 14;  break;
    case COL_GRAY:          nCol = 15;  break;
    case COL_LIGHTGRAY:     nCol = 16;  break;
    case COL_LIGHTBLUE:     nCol = 2;   break;
    case COL_LIGHTGREEN:    nCol = 4;   break;
    case COL_LIGHTCYAN:     nCol = 3;   break;
    case COL_LIGHTRED:      nCol = 6;   break;
    case COL_LIGHTMAGENTA:  nCol = 5;   break;
    case COL_YELLOW:        nCol = 7;   break;
    case COL_WHITE:         nCol = 8;   break;

    default:
        if( !pBmpPal )
        {
            pBmpPal = new BitmapPalette( 16 );
            static const ColorData aColArr[ 16 ] = {
                COL_BLACK,      COL_LIGHTBLUE,  COL_LIGHTCYAN,  COL_LIGHTGREEN,
                COL_LIGHTMAGENTA,COL_LIGHTRED,  COL_YELLOW,     COL_WHITE,
                COL_BLUE,       COL_CYAN,       COL_GREEN,      COL_MAGENTA,
                COL_RED,        COL_BROWN,      COL_GRAY,       COL_LIGHTGRAY
            };

            for( int i = 0; i < 16; ++i )
                pBmpPal->operator[]( i ) = Color( aColArr[ i ] );
        }
        nCol = pBmpPal->GetBestIndex( rCol ) + 1;
        break;
    }
    return nCol;
}

// TransBrush uebersetzt SW-Brushes in WW. Heraus kommt WW8_SHD.
// Nicht-Standardfarben des SW werden noch nicht in die
// Misch-Werte ( 0 .. 95% ) vom WW uebersetzt.
// Return: Echte Brush ( nicht transparent )
// auch bei Transparent wird z.B. fuer Tabellen eine transparente Brush
// geliefert
BOOL SwWW8Writer::TransBrush( const Color& rCol, WW8_SHD& rShd )
{
    if( rCol.GetTransparency() )
        rShd = WW8_SHD();               // alles Nullen : transparent
    else
    {
        rShd.SetFore( 8);
        rShd.SetBack( TransCol( rCol ) );
        rShd.SetStyle( bWrtWW8, 0 );
    }
    return !rCol.GetTransparency();
}

static Writer& OutWW8_SwColor( Writer& rWrt, const SfxPoolItem& rHt )
{
    const SvxColorItem& rAttr = (const SvxColorItem&)rHt;
    SwWW8Writer& rWrtWW8 = (SwWW8Writer&)rWrt;
    if( rWrtWW8.bWrtWW8 )
        rWrtWW8.InsUInt16( 0x2A42 );
    else
        rWrtWW8.pO->Insert( 98, rWrtWW8.pO->Count() );

    rWrtWW8.pO->Insert( rWrtWW8.TransCol( ((const SvxColorItem&)rHt).
                                        GetValue() ), rWrtWW8.pO->Count() );
    return rWrt;
}

static Writer& OutWW8_SwFmtCharBackground( Writer& rWrt, const SfxPoolItem& rHt )
{
    SwWW8Writer& rWW8Wrt = (SwWW8Writer&)rWrt;

    if( rWW8Wrt.bWrtWW8 )   // nur WW8 kann ZeichenHintergrund
    {
        const SvxBrushItem& rBack = (const SvxBrushItem&)rHt;
        WW8_SHD aSHD;

        if( rWW8Wrt.TransBrush( rBack.GetColor(), aSHD ) )
        {
            // sprmCShd
            rWW8Wrt.InsUInt16( 0x4866 );
            rWW8Wrt.InsUInt16( aSHD.GetValue() );
        }
    }
    return rWrt;
}

static Writer& OutSwFmtINetFmt( Writer& rWrt, const SfxPoolItem& rHt )
{
    SwWW8Writer& rWrtWW8 = (SwWW8Writer&)rWrt;
    const SwFmtINetFmt& rINet = (SwFmtINetFmt&)rHt;

    if( rINet.GetValue().Len() )
    {
        USHORT nId;
        const String& rStr = rINet.GetINetFmt();
        if( rStr.Len() )
            nId = rINet.GetINetFmtId();
        else
            nId = RES_POOLCHR_INET_NORMAL;

        const SwCharFmt* pFmt = IsPoolUserFmt( nId )
                        ? rWrt.pDoc->FindCharFmtByName( rStr )
                        : rWrt.pDoc->GetCharFmtFromPool( nId );

        if( rWrtWW8.bWrtWW8 )
            rWrtWW8.InsUInt16( 0x4A30 );
        else
            rWrtWW8.pO->Insert( 80, rWrtWW8.pO->Count() );

        rWrtWW8.InsUInt16( rWrtWW8.GetId( *pFmt ) );
    }
    return rWrt;
}


static void InsertSpecialChar( SwWW8Writer& rWrt, BYTE c )
{
    WW8Bytes aItems;
    if( rWrt.pChpIter )
        rWrt.pChpIter->GetItems( aItems );

    if( 0x13 == c )
        rWrt.pChpPlc->AppendFkpEntry( rWrt.Strm().Tell() );
    else
        rWrt.pChpPlc->AppendFkpEntry( rWrt.Strm().Tell(), aItems.Count(),
                                    aItems.GetData() );

    // at end the attributes writes by the Textnode
    if( 0x15 == c )
        aItems.Remove( 0, aItems.Count() );

    rWrt.WriteChar( c );

    // fSpec-Attribut TRUE
    if( rWrt.bWrtWW8 )
        SwWW8Writer::InsUInt16( aItems, 0x855 );
    else
        aItems.Insert( 117, aItems.Count() );
    aItems.Insert( 1, aItems.Count() );

    rWrt.pChpPlc->AppendFkpEntry( rWrt.Strm().Tell(), aItems.Count(),
                                    aItems.GetData() );
}


void SwWW8Writer::OutField( const SwField* pFld, BYTE nFldType,
                            const String& rFldCmd, BYTE nMode )
{
    static BYTE                 aFld13[2] = { 0x13, 0x00 };  // will change
    static BYTE __READONLY_DATA aFld14[2] = { 0x14, 0xff };
    static BYTE __READONLY_DATA aFld15[2] = { 0x15, 0x80 };

    BOOL bUnicode = IsUnicode();
    WW8_WrPlcFld* pFldP;
    switch ( nTxtTyp )
    {
    case TXT_MAINTEXT:  pFldP = pFldMain;       break;
    case TXT_HDFT:      pFldP = pFldHdFt;       break;
    case TXT_FTN:       pFldP = pFldFtn;        break;
    case TXT_EDN:       pFldP = pFldEdn;        break;
    case TXT_TXTBOX:    pFldP = pFldTxtBxs;     break;
    case TXT_HFTXTBOX:  pFldP = pFldHFTxtBxs;   break;

    default:
        ASSERT( !this, "was ist das fuer ein SubDoc-Type?" );
        break;
    }

    if( WRITEFIELD_START & nMode )
    {
        aFld13[1] = nFldType;                           // Typ nachtragen
        pFldP->Append( Fc2Cp( Strm().Tell() ), aFld13 );
        InsertSpecialChar( *this, 0x13 );
    }
    if( WRITEFIELD_CMD_START & nMode )
    {
        if( bUnicode )
            SwWW8Writer::WriteString16( Strm(), rFldCmd, FALSE );
        else
            SwWW8Writer::WriteString8( Strm(), rFldCmd, FALSE,
                                                RTL_TEXTENCODING_MS_1252 );
    }
    if( WRITEFIELD_CMD_END & nMode )
    {
//      Strm() << " \\* FORMATVERBINDEN ";
        pFldP->Append( Fc2Cp( Strm().Tell() ), aFld14 );
        InsertSpecialChar( *this, 0x14 );
    }
    if( WRITEFIELD_END & nMode )
    {
        String sOut;
        if( pFld )
            sOut = pFld->Expand();
        else
            sOut = rFldCmd;
        if( sOut.Len() )
        {
            if( bUnicode )
                SwWW8Writer::WriteString16( Strm(), sOut, FALSE );
            else
                SwWW8Writer::WriteString8( Strm(), sOut, FALSE,
                                                RTL_TEXTENCODING_MS_1252 );
        }
    }
    if( WRITEFIELD_CLOSE & nMode )
    {
        pFldP->Append( Fc2Cp( Strm().Tell() ), aFld15 );
        InsertSpecialChar( *this, 0x15 );
    }
}

void SwWW8Writer::StartCommentOutput(const String& rName)
{
    String aStr( CREA_ASC( " ANGEBEN [" )); ( aStr += rName ).APP_ASC( "] " );
    OutField( 0, 35, aStr, WRITEFIELD_START | WRITEFIELD_CMD_START );
}

void SwWW8Writer::EndCommentOutput(const String& rName)
{
    String aStr( CREA_ASC( " [" )); ( aStr += rName ).APP_ASC(  "] " );
    OutField( 0, 35, aStr, WRITEFIELD_CMD_END | WRITEFIELD_END |
                            WRITEFIELD_CLOSE );
}


USHORT SwWW8Writer::GetId( const SwTOXType& rTOXType )
{
    void* p = (void*)&rTOXType;
    USHORT nRet = aTOXArr.GetPos( p );
    if( USHRT_MAX == nRet )
        aTOXArr.Insert( p, nRet = aTOXArr.Count() );
    return nRet;
}

// return values:  1 - no PageNum,
//                 2 - TabStop before PageNum,
//                 3 - Text before PageNum - rTxt hold the text
//                 4 - no Text and no TabStop before PageNum
int lcl_CheckForm( const SwForm& rForm, BYTE nLvl, String& rText )
{
    int nRet = 4;
    rText.Erase();

    SwFormTokenEnumerator aIter( rForm.CreateTokenEnumerator( nLvl ));
    BOOL bPgNumFnd = FALSE;
    FormTokenType eTType;
    while( TOKEN_END != ( eTType = aIter.GetNextTokenType() ) && !bPgNumFnd )
    {
        switch( eTType )
        {
        case TOKEN_PAGE_NUMS:
            bPgNumFnd = TRUE;
            break;

        case TOKEN_TAB_STOP:
            nRet = 2;
            break;
        case TOKEN_TEXT:
            nRet = 3;
            rText = aIter.GetCurToken().sText.Copy( 0, 5 );
            break;

        case TOKEN_LINK_START:
        case TOKEN_LINK_END:
            break;

        default:
            nRet = 4;
            break;
        }
    }

    if( !bPgNumFnd )
        nRet = 1;

    return nRet;
}


void SwWW8Writer::StartTOX( const SwSection& rSect )
{
    const SwTOXBase* pTOX = rSect.GetTOXBase();
    if( pTOX )
    {
        static sal_Char __READONLY_DATA sContent[] = " VERZEICHNIS \\w \\x ";
        static sal_Char __READONLY_DATA sIndex[] = " INDEX ";
        static sal_Char __READONLY_DATA sEntryEnd[] = "\" ";


        BYTE nCode;
        String aStr;
        switch( pTOX->GetType() )
        {
        case TOX_INDEX:
            {
                nCode = 8;
                aStr.AssignAscii( sIndex );

                if( pTOX->GetTOXForm().IsCommaSeparated() )
                    aStr.APP_ASC( "\\r " );

                if( TOI_ALPHA_DELIMITTER & pTOX->GetOptions() )
                    aStr.APP_ASC( "\\h \"A\" " );

                {
                    String aFillTxt;
                    for( BYTE n = 1; n <= 3; ++n )
                    {
                        String aTxt;
                        int nRet = ::lcl_CheckForm( pTOX->GetTOXForm(),
                                                    n, aTxt );

                        if( 3 == nRet )
                            aFillTxt = aTxt;
                        else if( 4 == nRet )
                            aFillTxt = '\t';
                        else
                            aFillTxt.Erase();
                    }
                    (aStr.APP_ASC( "\\e \"" )) += aFillTxt;
                    aStr.AppendAscii( sEntryEnd );
                }
            }
            break;

//      case TOX_AUTHORITIES:   nCode = 73; aStr = ???; break;

        case TOX_ILLUSTRATIONS:
        case TOX_OBJECTS:
        case TOX_TABLES:
            if( !pTOX->IsFromObjectNames() )
            {
                nCode = 13;
                aStr.AssignAscii( sContent );

                (( aStr.APP_ASC( "\\c \"" )) += pTOX->GetSequenceName()
                                ).AppendAscii( sEntryEnd );
                String aTxt;
                int nRet = ::lcl_CheckForm( pTOX->GetTOXForm(), 1, aTxt );
                if( 1 == nRet )
                    aStr.APP_ASC( "\\n " );
                else if( 3 == nRet || 4 == nRet )
                    (( aStr.APP_ASC( "\\p \"" )) += aTxt ).AppendAscii(sEntryEnd);
            }
            break;

//      case TOX_USER:
//      case TOX_CONTENT:
        default:
            {
                nCode = 13;
                aStr.AssignAscii( sContent );

                String sTOption;
                USHORT n, nTOXLvl = pTOX->GetLevel();
                if( !nTOXLvl )
                    ++nTOXLvl;

                if( TOX_MARK & pTOX->GetCreateType() )
                {
                    aStr.APP_ASC( "\\f " );

                    if( TOX_USER == pTOX->GetType() )
                        (( aStr += '\"' ) +=
                                (sal_Char)( 'A' + GetId( *pTOX->GetTOXType() ))
                                    ).AppendAscii( sEntryEnd );
                }

                if( TOX_OUTLINELEVEL & pTOX->GetCreateType() )
                {
                    // are the chapter template the normal headline 1 to 9 ?
                    // search all outlined collections
                    BYTE nLvl, nMinLvl = MAXLEVEL;
                    const SwTxtFmtColls& rColls = *pDoc->GetTxtFmtColls();
                    const SwTxtFmtColl* pColl;
                    for( n = rColls.Count(); n; )
                        if( MAXLEVEL > (nLvl = ( pColl =
                                    rColls[ --n ] )->GetOutlineLevel() ) &&
                              nMinLvl > nLvl &&
                            ( RES_POOLCOLL_HEADLINE1 > pColl->GetPoolFmtId() ||
                              RES_POOLCOLL_HEADLINE9 < pColl->GetPoolFmtId() ))
                        {
                            nMinLvl = nLvl;
                        }

                    nLvl = nMinLvl < nTOXLvl ? nMinLvl : (BYTE)nTOXLvl;
                    if( nLvl )
                    {
                        USHORT nTmpLvl = nLvl + 1;
                        if( nTmpLvl > nWW8MaxListLevel )
                            nTmpLvl = nWW8MaxListLevel;

                        ((aStr.APP_ASC( "\\o \"1-" )) +=
                            String::CreateFromInt32( nTmpLvl ))
                                    .AppendAscii(sEntryEnd);
                    }

                    if( nLvl != nMinLvl )
                    {
                        // collect this templates into the \t otion
                        for( n = rColls.Count(); n; )
                            if( MAXLEVEL > (nLvl = ( pColl =
                                    rColls[ --n ] )->GetOutlineLevel() ) &&
                                  nMinLvl <= nLvl )
                            {
                                if( sTOption.Len() )
                                    sTOption += ';';
                                (( sTOption += pColl->GetName() ) += ';' )
                                        += String::CreateFromInt32( nLvl + 1 );
                            }
                    }
                }

                if( TOX_TEMPLATE & pTOX->GetCreateType() )
                    for( n = 0; n < nTOXLvl; ++n )
                    {
                        const String& rStyles = pTOX->GetStyleNames( n );
                        if( rStyles.Len() )
                        {
                            xub_StrLen nPos = 0;
                            String sLvl( ';' );
                            sLvl += String::CreateFromInt32( n + 1 );
                            do {
                                String sStyle( rStyles.GetToken( 0,
                                            TOX_STYLE_DELIMITER, nPos ));
                                if( sStyle.Len() )
                                {
                                    if( sTOption.Len() )
                                        sTOption += ';';
                                    ( sTOption += sStyle ) += sLvl;
                                }
                            } while( STRING_NOTFOUND != nPos );
                        }
                    }

                {
                    String aFillTxt;
                    BYTE nNoPgStt = MAXLEVEL, nNoPgEnd = MAXLEVEL;
                    BOOL bFirstFillTxt = TRUE, bOnlyText = TRUE;
                    for( n = 0; n < nTOXLvl; ++n )
                    {
                        String aTxt;
                        int nRet = ::lcl_CheckForm( pTOX->GetTOXForm(),
                                                    n+1, aTxt );
                        if( 1 == nRet )
                        {
                            bOnlyText = FALSE;
                            if( MAXLEVEL == nNoPgStt )
                                nNoPgStt = n+1;
                        }
                        else
                        {
                            if( MAXLEVEL != nNoPgStt &&
                                MAXLEVEL == nNoPgEnd )
                                nNoPgEnd = BYTE(n);

                            bOnlyText = bOnlyText && 3 == nRet;
                            if( 3 == nRet || 4 == nRet )
                            {
                                if( bFirstFillTxt )
                                    aFillTxt = aTxt;
                                else if( aFillTxt != aTxt )
                                    aFillTxt.Erase();
                                bFirstFillTxt = FALSE;
                            }
                        }
                    }
                    if( MAXLEVEL != nNoPgStt )
                    {
                        if( nWW8MaxListLevel < nNoPgEnd )
                            nNoPgEnd = nWW8MaxListLevel;
                        aStr.APP_ASC( "\\n " );
                        (aStr += String::CreateFromInt32( nNoPgStt )) += '-';
                        (aStr += String::CreateFromInt32( nNoPgEnd  )) += ' ';
                    }
                    if( bOnlyText )
                        ((aStr.APP_ASC( "\\p \"" )) += aFillTxt )
                                .AppendAscii(sEntryEnd);
                }

                if( sTOption.Len() )
                    (( aStr.APP_ASC( "\\t \"" )) += sTOption )
                        .AppendAscii(sEntryEnd);
            }
            break;
        }

        if( aStr.Len() )
        {
            bInWriteTOX = TRUE;
            OutField( 0, nCode, aStr, WRITEFIELD_START |
                                WRITEFIELD_CMD_START | WRITEFIELD_CMD_END );
        }
    }
    bStartTOX = FALSE;
}

void SwWW8Writer::EndTOX( const SwSection& rSect )
{
    const SwTOXBase* pTOX = rSect.GetTOXBase();
    if( pTOX )
    {
        BYTE nCode = TOX_INDEX == pTOX->GetType() ? 8 : 13;
        OutField( 0, nCode, aEmptyStr, WRITEFIELD_CLOSE );
    }
    bInWriteTOX = FALSE;
}



// GetDatePara, GetTimePara, GetNumberPara modifizieren die String-Ref
// Es werden die deutschen Format-Spezifier benutzt, da im FIB auch dt. als
// Creator angegeben ist.
BOOL SwWW8Writer::GetNumberFmt( const SwField& rFld, String& rStr )
{
    BOOL bHasFmt = FALSE;
    SvNumberFormatter* pNFmtr = pDoc->GetNumberFormatter();
    UINT32 nFmtIdx = rFld.GetFormat();
    const SvNumberformat* pNumFmt = pNFmtr->GetEntry( nFmtIdx );
    if( pNumFmt )
    {
        USHORT nLng = rFld.GetLanguage();
        LocaleDataWrapper aLocDat( pNFmtr->GetServiceManager(),
            SvNumberFormatter::ConvertLanguageToLocale( nLng ) );
        if( !pKeyMap )
        {
            pKeyMap = new NfKeywordTable;
            NfKeywordTable& rKeyMap = *(NfKeywordTable*)pKeyMap;
//          aKeyMap[ NF_KEY_NONE = 0,
//          aKeyMap[ NF_KEY_E,
//          aKeyMap[ NF_KEY_AMPM,
//          aKeyMap[ NF_KEY_AP,
            rKeyMap[ NF_KEY_MI      ].ASIGN_ASC( "m" );
            rKeyMap[ NF_KEY_MMI     ].ASIGN_ASC( "mm" );
            rKeyMap[ NF_KEY_M       ].ASIGN_ASC( "M" );
            rKeyMap[ NF_KEY_MM      ].ASIGN_ASC( "MM" );
            rKeyMap[ NF_KEY_MMM     ].ASIGN_ASC( "MMM" );
            rKeyMap[ NF_KEY_MMMM    ].ASIGN_ASC( "MMMM" );
            rKeyMap[ NF_KEY_MMMMM   ].ASIGN_ASC( "MMMMM" );
            rKeyMap[ NF_KEY_H       ].ASIGN_ASC( "H" );
            rKeyMap[ NF_KEY_HH      ].ASIGN_ASC( "HH" );
            rKeyMap[ NF_KEY_S       ].ASIGN_ASC( "s" );
            rKeyMap[ NF_KEY_SS      ].ASIGN_ASC( "ss" );
//          aKeyMap[ NF_KEY_Q,
//          aKeyMap[ NF_KEY_QQ,
            rKeyMap[ NF_KEY_D       ].ASIGN_ASC( "t" );
            rKeyMap[ NF_KEY_DD      ].ASIGN_ASC( "tt" );
            rKeyMap[ NF_KEY_DDD     ].ASIGN_ASC( "ttt" );
            rKeyMap[ NF_KEY_DDDD    ].ASIGN_ASC( "tttt" );
            rKeyMap[ NF_KEY_YY      ].ASIGN_ASC( "jj" );
            rKeyMap[ NF_KEY_YYYY    ].ASIGN_ASC( "jjjj" );
            rKeyMap[ NF_KEY_NN      ].ASIGN_ASC( "ttt" );
            rKeyMap[ NF_KEY_NNNN    ].ASIGN_ASC( "tttt" );
//          aKeyMap[ NF_KEY_CCC,
//          aKeyMap[ NF_KEY_GENERAL,
//          aKeyMap[ NF_KEY_NNN,
//          aKeyMap[ NF_KEY_WW,
//          aKeyMap[ NF_KEY_QUARTER,
//          aKeyMap[ NF_KEY_TRUE,
//          aKeyMap[ NF_KEY_FALSE,
//          aKeyMap[ NF_KEY_BOOLEAN,
            rKeyMap[ NF_KEY_AAA     ].ASIGN_ASC( "aaa" );
            rKeyMap[ NF_KEY_AAAA    ].ASIGN_ASC( "aaaa" );
            rKeyMap[ NF_KEY_EC      ].ASIGN_ASC( "e" );
            rKeyMap[ NF_KEY_EEC     ].ASIGN_ASC( "ee" );
            rKeyMap[ NF_KEY_G       ].ASIGN_ASC( "g" );
            rKeyMap[ NF_KEY_GG      ].ASIGN_ASC( "gg" );
            rKeyMap[ NF_KEY_GGG     ].ASIGN_ASC( "ggg" );
        }

        String sFmt( pNumFmt->GetMappedFormatstring(
                        *(NfKeywordTable*)pKeyMap, aLocDat, TRUE ));
        if( sFmt.Len() )
        {
            (( rStr.APP_ASC( "\\@\"" )) += sFmt ).APP_ASC( "\" " );
            bHasFmt = TRUE;
        }
    }
    return bHasFmt;
}

void WW8_GetNumberPara( String& rStr, const SwField& rFld )
{
    switch( rFld.GetFormat() )
    {
    case SVX_NUM_CHARS_UPPER_LETTER:
    case SVX_NUM_CHARS_UPPER_LETTER_N: rStr.APP_ASC( "\\*ALPHABETISCH "); break;
    case SVX_NUM_CHARS_LOWER_LETTER:
    case SVX_NUM_CHARS_LOWER_LETTER_N: rStr.APP_ASC("\\*alphabetisch "); break;
    case SVX_NUM_ROMAN_UPPER:        rStr.APP_ASC("\\*R\xd6MISCH "); break;
    case SVX_NUM_ROMAN_LOWER:        rStr.APP_ASC("\\*r\xf6misch "); break;
    case SVX_NUM_ARABIC:             rStr.APP_ASC("\\*Arabisch "); break;
    }
}

void SwWW8Writer::WritePostItBegin( const SwPostItField& rPostIt,
                                    WW8Bytes* pO )
{
    BYTE aArr[ 3 ];
    BYTE* pArr = aArr;

    // sprmCFSpec TRUE
    if( bWrtWW8 )
        Set_UInt16( pArr, 0x855 );
    else
        Set_UInt8( pArr, 117 );
    Set_UInt8( pArr, 1 );

    pChpPlc->AppendFkpEntry( Strm().Tell() );
    WriteChar( 0x05 );              // Annotation reference

    if( pO )
        pO->Insert( aArr, pArr - aArr, pO->Count() );
    else
        pChpPlc->AppendFkpEntry( Strm().Tell(), pArr - aArr, aArr );
}

static Writer& OutWW8_SwField( Writer& rWrt, const SfxPoolItem& rHt )
{
    SwWW8Writer& rWW8Wrt = (SwWW8Writer&)rWrt;
    const SwFmtFld& rFld = (SwFmtFld&)rHt;
    const SwField* pFld = rFld.GetFld();
    String aStr;        // fuer optionale Parameter
    BOOL bWriteExpand = FALSE;
    USHORT nSubType = pFld->GetSubType();
    BYTE nFldTyp = 0;

    switch( pFld->GetTyp()->Which() )
    {
//  case RES_CHAPTERFLD:
//      break;

    case RES_SETEXPFLD:
        if( GSE_SEQ == nSubType )
        {
            (( aStr.ASIGN_ASC( " SEQ \"" )) += pFld->GetTyp()->GetName() )
                    .APP_ASC( "\" " );
            ::WW8_GetNumberPara( aStr, *pFld );
            rWW8Wrt.OutField( pFld, 12, aStr );
        }
        else
            bWriteExpand = TRUE;
        break;

    case RES_PAGENUMBERFLD:
        aStr.ASIGN_ASC( " SEITE " );
        ::WW8_GetNumberPara( aStr, *pFld );
        rWW8Wrt.OutField( pFld, 33, aStr );
        break;

    case RES_FILENAMEFLD:
        rWW8Wrt.OutField( pFld, 29, CREA_ASC( "DATEINAME" ));
        break;

    case RES_DBNAMEFLD:
        aStr.ASIGN_ASC( "DATENBANK " );         // ok ??
        aStr += rWrt.pDoc->GetDBName();
        rWW8Wrt.OutField( pFld, 78, aStr );
        break;

    case RES_AUTHORFLD:
        rWW8Wrt.OutField( pFld, (AF_SHORTCUT & nSubType ? 61 : 60),
                            CREA_ASC( "AUTOR" ));
        break;

    case RES_TEMPLNAMEFLD:
        rWW8Wrt.OutField( pFld, 30, CREA_ASC("DOKVORLAGE" ));
        break;

    case RES_DOCINFOFLD:    // Last printed, last edited,...
        if( DI_SUB_FIXED & nSubType )
            bWriteExpand = TRUE;
        else
        {
            static sal_Char __READONLY_DATA sFld15[] = "TITLE";
            static sal_Char __READONLY_DATA sFld16[] = "THEMA";
            static sal_Char __READONLY_DATA sFld17[] = "AUTOR ";
            static sal_Char __READONLY_DATA sFld18[] = "STICHW\xd6RTER";
            static sal_Char __READONLY_DATA sFld19[] = "KOMMENTAR";
            static sal_Char __READONLY_DATA sFld20[] = "GESPEICHERTVON";
            static sal_Char __READONLY_DATA sFld21[] = "ERSTELLDAT ";
            static sal_Char __READONLY_DATA sFld22[] = "SPEICHERDAT ";
            static sal_Char __READONLY_DATA sFld23[] = "DRUCKDAT ";
            static sal_Char __READONLY_DATA sFld24[] = "\xdc" "BERARBEITUNGSNUMMER";

            static const sal_Char* __READONLY_DATA aFldArr[] = {
                    sFld15, sFld16, sFld17, sFld18, sFld19,
                    sFld20, sFld21, sFld22, sFld23, sFld24
            };

            switch( 0xff & nSubType )
            {
            case DI_TITEL:      nFldTyp = 15;   break;
            case DI_THEMA:      nFldTyp = 16;   break;
            case DI_KEYS:       nFldTyp = 18;   break;
            case DI_COMMENT:    nFldTyp = 19;   break;
            case DI_DOCNO:      nFldTyp = 24;   break;

            case DI_CREATE:
                if( DI_SUB_AUTHOR == (nSubType & ~DI_SUB_AUTHOR ))
                    nFldTyp = 17;
                else if( rWW8Wrt.GetNumberFmt( *pFld, aStr ))
                    nFldTyp = 21;
                break;

            case DI_CHANGE:
                if( DI_SUB_AUTHOR == (nSubType & ~DI_SUB_AUTHOR ))
                    nFldTyp = 20;
                break;

            case DI_PRINT:
                if( DI_SUB_AUTHOR != (nSubType & ~DI_SUB_AUTHOR ) &&
                    rWW8Wrt.GetNumberFmt( *pFld, aStr ))
                    nFldTyp = 23;
                break;
            case DI_EDIT:
                if( DI_SUB_AUTHOR != (nSubType & ~DI_SUB_AUTHOR ) &&
                    rWW8Wrt.GetNumberFmt( *pFld, aStr ))
                    nFldTyp = 22;
                break;
            }

            if( nFldTyp )
            {
                aStr.InsertAscii( aFldArr[ nFldTyp - 15 ], 0 );
                rWW8Wrt.OutField( pFld, nFldTyp, aStr );
            }
            else
                bWriteExpand = TRUE;
        }
        break;

    case RES_DATETIMEFLD:
        if( FIXEDFLD & nSubType || !rWW8Wrt.GetNumberFmt( *pFld, aStr ) )
            bWriteExpand = TRUE;
        else
        {
            const sal_Char* pAddStr;
            BYTE nTyp;
            if( DATEFLD & nSubType )
            {
                pAddStr = " AKTUALDAT ";
                nTyp = 31;
            }
            else
            {
                pAddStr = " ZEIT ";
                nTyp = 32;
            }
            aStr.InsertAscii( pAddStr, 0 );
            rWW8Wrt.OutField( pFld, nTyp, aStr );
        }
        break;

    case RES_DOCSTATFLD:
        {
            switch( nSubType )
            {
            case DS_PAGE:   aStr.ASIGN_ASC(" ANZSEITEN ");      nFldTyp = 26; break;
            case DS_WORD:   aStr.ASIGN_ASC(" ANZW\xd6RTER ");   nFldTyp = 27; break;
            case DS_CHAR:   aStr.ASIGN_ASC(" ANZZEICHEN ");     nFldTyp = 28; break;
            }

            if( nFldTyp )
            {
                ::WW8_GetNumberPara( aStr, *pFld );
                rWW8Wrt.OutField( pFld, nFldTyp, aStr );
            }
            else
                bWriteExpand = TRUE;
        }
        break;
    case RES_EXTUSERFLD:
        {
            switch( 0xFF & nSubType  )
            {
            case EU_FIRSTNAME:
            case EU_NAME:
                nFldTyp = 60;
                aStr.ASIGN_ASC("BENUTZERNAME");
                break;

            case EU_SHORTCUT:
                nFldTyp = 61;
                aStr.ASIGN_ASC("BENUTZERINITIALEN");
                break;

            case EU_STREET:
            case EU_COUNTRY:
            case EU_ZIP:
            case EU_CITY:
                nFldTyp = 62;
                aStr.ASIGN_ASC("BENUTZERADR");
                break;
            }
            if( nFldTyp )
                rWW8Wrt.OutField( pFld, nFldTyp, aStr );
            else
                bWriteExpand = TRUE;
        }
        break;

    case RES_POSTITFLD:
        {
            const SwPostItField& rPFld = *(SwPostItField*)pFld;
            rWW8Wrt.pAtn->Append( rWW8Wrt.Fc2Cp( rWrt.Strm().Tell() ), rPFld );
            rWW8Wrt.WritePostItBegin( rPFld, rWW8Wrt.pO );
        }
        break;

    case RES_INPUTFLD:
        ((aStr.ASIGN_ASC("EINGEBEN \"" )) += pFld->GetPar2() )+= '\"';
        rWW8Wrt.OutField( pFld, 39, aStr );
        break;

    case RES_GETREFFLD:
        {
            aStr.ASIGN_ASC(" REF ");
            const SwGetRefField& rRFld = *(SwGetRefField*)pFld;
            switch( nSubType )
            {
            case REF_SETREFATTR:
            case REF_BOOKMARK:
                aStr += rWW8Wrt.GetBookmarkName( nSubType,
                                                &rRFld.GetSetRefName(), 0 );
                nFldTyp = 3;
                break;

            case REF_FOOTNOTE:
            case REF_ENDNOTE:
                aStr += rWW8Wrt.GetBookmarkName( nSubType, 0,
                                                rRFld.GetSeqNo() );
                nFldTyp = REF_ENDNOTE == nSubType ? 72 : 5;
                switch( pFld->GetFormat() )
                {
                case REF_PAGE_PGDESC:
                case REF_PAGE:
                case REF_UPDOWN:
                    break;
                default:
                    aStr.InsertAscii( "FUSSENDNOTE", 1 );
                    break;
                }
                break;

//          case REF_SEQUENCEFLD:   // ???
//          case REF_OUTLINE:       // 10
            // page reference - 37
            // DDE reference  - 45
            // DDE automatic reference - 46
            }

            if( nFldTyp )
            {
                switch( pFld->GetFormat() )
                {
                case REF_PAGE_PGDESC:
                case REF_PAGE:
                    aStr.InsertAscii( "SEITEN", 1 );
                    nFldTyp = 37;
                    break;

                case REF_UPDOWN:
                    aStr.APP_ASC( " \\p" );
                    nFldTyp = 3;
                    break;

                case REF_CHAPTER:
                case REF_ONLYNUMBER:
                case REF_ONLYCAPTION:
                case REF_ONLYSEQNO:
                    break;
                // default:
                // case REF_CONTENT:
                }

                aStr.APP_ASC( " \\h " );        // insert hyperlink
                rWW8Wrt.OutField( pFld, nFldTyp, aStr );

            }
            else
                bWriteExpand = TRUE;
        }
        break;

    default:
        bWriteExpand = TRUE;
        break;
    }

    if( bWriteExpand )
    {
        if( rWW8Wrt.IsUnicode() )
            SwWW8Writer::WriteString16( rWrt.Strm(), pFld->Expand(), FALSE );
        else
            SwWW8Writer::WriteString8(  rWrt.Strm(), pFld->Expand(), FALSE,
                                                    RTL_TEXTENCODING_MS_1252 );
    }

    return rWrt;
}

static Writer& OutWW8_SwFlyCntnt( Writer& rWrt, const SfxPoolItem& rHt )
{
    SwWW8Writer& rWrtWW8 = (SwWW8Writer&)rWrt;
    if( rWrtWW8.pOutFmtNode && rWrtWW8.pOutFmtNode->ISA( SwCntntNode ))
    {
        SwTxtNode* pTxtNd = (SwTxtNode*)rWrtWW8.pOutFmtNode;

        Point aLayPos;
        aLayPos = pTxtNd->FindLayoutRect( FALSE, &aLayPos ).Pos();

        rWrtWW8.OutWW8FlyFrm( *((SwFmtFlyCnt&)rHt).GetFrmFmt(), aLayPos );
    }
    return rWrt;
}

// TOXMarks fehlen noch

// Detaillierte Einstellungen zur Trennung erlaubt WW nur dokumentenweise.
// Man koennte folgende Mimik einbauen: Die Werte des Style "Standard" werden,
// falls vorhanden, in die Document Properties ( DOP ) gesetzt.
// ---
// ACK.  Dieser Vorschlag passt exakt zu unserer Implementierung des Import,
// daher setze ich das gleich mal um. (KHZ, 07/15/2000)
static Writer& OutWW8_SvxHyphenZone( Writer& rWrt, const SfxPoolItem& rHt )
{
// sprmPFNoAutoHyph
    const SvxHyphenZoneItem& rAttr = (const SvxHyphenZoneItem&)rHt;
    SwWW8Writer& rWrtWW8 = (SwWW8Writer&)rWrt;
    if( rWrtWW8.bWrtWW8 )
        rWrtWW8.InsUInt16( 0x242A );
    else
        rWrtWW8.pO->Insert( 44, rWrtWW8.pO->Count() );

    rWrtWW8.pO->Insert( rAttr.IsHyphen() ? 0 : 1, rWrtWW8.pO->Count() );
    return rWrt;
}

static Writer& OutWW8_SfxBoolItem( Writer& rWrt, const SfxPoolItem& rHt )
{
    USHORT nId = 0;
    SwWW8Writer& rWrtWW8 = (SwWW8Writer&)rWrt;
    if( rWrtWW8.bWrtWW8 )
        switch ( rHt.Which() )
        {
        case RES_PARATR_SCRIPTSPACE:            nId = 0x2437;   break;
        case RES_PARATR_HANGINGPUNCTUATION:     nId = 0x2435;   break;
        case RES_PARATR_FORBIDDEN_RULES:        nId = 0x2433;   break;
        }

    if( nId )
    {
        if( rWrtWW8.bWrtWW8 )
            rWrtWW8.InsUInt16( nId );
        else
            rWrtWW8.pO->Insert( (BYTE)nId, rWrtWW8.pO->Count() );

        rWrtWW8.pO->Insert( ((SfxBoolItem&)rHt).GetValue() ? 1 : 0,
                            rWrtWW8.pO->Count() );
    }
    return rWrt;
}

// NoHyphen: ich habe keine Entsprechung in der SW-UI und WW-UI gefunden

static Writer& OutWW8_SwHardBlank( Writer& rWrt, const SfxPoolItem& rHt )
{
    ((SwWW8Writer&)rWrt).WriteChar( ((SwFmtHardBlank&)rHt).GetChar() );
    return rWrt;
}

// RefMark, NoLineBreakHere  fehlen noch

void SwWW8Writer::WriteFtnBegin( const SwFmtFtn& rFtn, WW8Bytes* pOutArr )
{
    WW8Bytes aAttrArr;
    BOOL bAutoNum = !rFtn.GetNumStr().Len();    // Auto-Nummer
    if( bAutoNum )
    {
        if( bWrtWW8 )
        {
            static BYTE __READONLY_DATA aSpec[] = {
                0x03, 0x6a, 0, 0, 0, 0,         // sprmCObjLocation (wahrscheinlich unnoetig)
                0x55, 0x08, 1                   // sprmCFSpec
            };

            aAttrArr.Insert( aSpec, sizeof( aSpec ), aAttrArr.Count() );
        }
        else
        {
            static BYTE __READONLY_DATA aSpec[] = {
                117, 1,                         // sprmCFSpec
                68, 4, 0, 0, 0, 0               // sprmCObjLocation (wahrscheinlich unnoetig)
            };
            aAttrArr.Insert( aSpec, sizeof( aSpec ), aAttrArr.Count() );
        }
    }

        // sprmCIstd
    const SwEndNoteInfo* pInfo;
    if( rFtn.IsEndNote() )
        pInfo = &pDoc->GetEndNoteInfo();
    else
        pInfo = &pDoc->GetFtnInfo();
    const SwCharFmt* pCFmt = pOutArr
                                ? pInfo->GetAnchorCharFmt( *pDoc )
                                : pInfo->GetCharFmt( *pDoc );
    if( bWrtWW8 )
        SwWW8Writer::InsUInt16( aAttrArr, 0x4a30 );
    else
        aAttrArr.Insert( 80, aAttrArr.Count() );
    SwWW8Writer::InsUInt16( aAttrArr, GetId( *pCFmt ) );

                                                // fSpec-Attribut TRUE
                            // Fuer Auto-Nummer muss ein Spezial-Zeichen
                            // in den Text und darum ein fSpec-Attribut
    pChpPlc->AppendFkpEntry( Strm().Tell() );
    if( bAutoNum )
        WriteChar( 0x02 );              // Auto-Nummer-Zeichen
    else
        // User-Nummerierung
        OutSwString( rFtn.GetNumStr(), 0, rFtn.GetNumStr().Len(),
                        IsUnicode(), RTL_TEXTENCODING_MS_1252 );

    if( pOutArr )
    {
        // insert at start of array, so the "hard" attribute overrule the
        // attributes of the character template
        pOutArr->Insert( &aAttrArr, 0 );
    }
    else
    {
        WW8Bytes aOutArr;

        // insert at start of array, so the "hard" attribute overrule the
        // attributes of the character template
        aOutArr.Insert( &aAttrArr, 0 );

        // write for the ftn number in the content, the font of the anchor
        const SwTxtFtn* pTxtFtn = rFtn.GetTxtFtn();
        if( pTxtFtn )
        {
            WW8Bytes* pOld = pO;
            pO = &aOutArr;
            SfxItemSet aSet( pDoc->GetAttrPool(), RES_CHRATR_FONT,
                                                    RES_CHRATR_FONT );

            pCFmt = pInfo->GetCharFmt( *pDoc );
            aSet.Set( pCFmt->GetAttrSet() );

            pTxtFtn->GetTxtNode().GetAttr( aSet, *pTxtFtn->GetStart(),
                                            (*pTxtFtn->GetStart()) + 1 );
            ::OutWW8_SwFont( *this, aSet.Get( RES_CHRATR_FONT ));
            pO = pOld;
        }
        pChpPlc->AppendFkpEntry( Strm().Tell(), aOutArr.Count(),
                                                aOutArr.GetData() );
    }
}

static BOOL lcl_IsAtTxtEnd( const SwFmtFtn& rFtn )
{
    BOOL bRet = TRUE;
    if( rFtn.GetTxtFtn() )
    {
        USHORT nWh = rFtn.IsEndNote() ? RES_END_AT_TXTEND
                                      : RES_FTN_AT_TXTEND;
        const SwSectionNode* pSectNd = rFtn.GetTxtFtn()->GetTxtNode().
                                                        FindSectionNode();
        while( pSectNd && FTNEND_ATPGORDOCEND ==
                ((const SwFmtFtnAtTxtEnd&)pSectNd->GetSection().GetFmt()->
                GetAttr( nWh, TRUE )).GetValue() )
            pSectNd = pSectNd->FindStartNode()->FindSectionNode();

        if( !pSectNd )
            bRet = FALSE;   // the is ftn/end collected at Page- or Doc-End
    }
    return bRet;
}


static Writer& OutWW8_SwFtn( Writer& rWrt, const SfxPoolItem& rHt )
{
    const SwFmtFtn& rFtn = (const SwFmtFtn&)rHt;
    SwWW8Writer& rWW8Wrt = (SwWW8Writer&)rWrt;

    USHORT nTyp;
    WW8_WrPlcFtnEdn* pFtnEnd;
    if( rFtn.IsEndNote() )
    {
        pFtnEnd = rWW8Wrt.pEdn;
        nTyp = REF_ENDNOTE;
        if( rWW8Wrt.bEndAtTxtEnd )
            rWW8Wrt.bEndAtTxtEnd = lcl_IsAtTxtEnd( rFtn );
    }
    else
    {
        pFtnEnd = rWW8Wrt.pFtn;
        nTyp = REF_FOOTNOTE;
        if( rWW8Wrt.bFtnAtTxtEnd )
            rWW8Wrt.bFtnAtTxtEnd = lcl_IsAtTxtEnd( rFtn );
    }

    // if any reference to this footnote/endnote then insert an internal
    // Bookmark.
    String sBkmkNm;
    if( rWW8Wrt.HasRefToObject( nTyp, 0, rFtn.GetTxtFtn()->GetSeqRefNo() ))
    {
        sBkmkNm = rWW8Wrt.GetBookmarkName( nTyp, 0,
                                    rFtn.GetTxtFtn()->GetSeqRefNo() );
        rWW8Wrt.AppendBookmark( sBkmkNm );
    }


    pFtnEnd->Append( rWW8Wrt.Fc2Cp( rWrt.Strm().Tell() ), rFtn );
    rWW8Wrt.WriteFtnBegin( rFtn, rWW8Wrt.pO );

    if( sBkmkNm.Len() )
        rWW8Wrt.AppendBookmark( sBkmkNm );

    return rWrt;
}



static Writer& OutWW8_SwTxtCharFmt( Writer& rWrt, const SfxPoolItem& rHt )
{
    const SwFmtCharFmt& rAttr = (const SwFmtCharFmt&)rHt;
    if( rAttr.GetCharFmt() )
    {
        SwWW8Writer& rWrtWW8 = (SwWW8Writer&)rWrt;
        if( rWrtWW8.bWrtWW8 )
            rWrtWW8.InsUInt16( 0x4A30 );
        else
            rWrtWW8.pO->Insert( 80, rWrtWW8.pO->Count() );

        rWrtWW8.InsUInt16( rWrtWW8.GetId( *rAttr.GetCharFmt() ) );
    }
    return rWrt;
}


static Writer& OutWW8_SwNumRuleItem( Writer& rWrt, const SfxPoolItem& rHt )
{
    SwWW8Writer& rWW8Wrt = (SwWW8Writer&)rWrt;
    const SwNumRuleItem& rNumRule = (const SwNumRuleItem&)rHt;

    const SwTxtNode* pTxtNd = 0;
    USHORT nNumId;
    BYTE nLvl = 0;
    if( rNumRule.GetValue().Len() )
    {
        const SwNumRule* pRule = rWrt.pDoc->FindNumRulePtr(
                                        rNumRule.GetValue() );
        if( pRule && USHRT_MAX != ( nNumId = rWW8Wrt.GetId( *pRule )) )
        {
            ++nNumId;
            if( rWW8Wrt.pOutFmtNode )
            {
                if( rWW8Wrt.pOutFmtNode->ISA( SwCntntNode ))
                {
                    pTxtNd = (SwTxtNode*)rWW8Wrt.pOutFmtNode;
                    const SwNodeNum* pNum = pTxtNd->GetNum();

                    if( pNum && NO_NUM > pNum->GetLevel() )
                        nLvl = GetRealLevel( pNum->GetLevel() );
                }
                else if( rWW8Wrt.pOutFmtNode->ISA( SwTxtFmtColl ))
                {
                    const SwTxtFmtColl* pC = (SwTxtFmtColl*)rWW8Wrt.pOutFmtNode;
                    if( pC && MAXLEVEL > pC->GetOutlineLevel() )
                        nLvl = pC->GetOutlineLevel();
                }
            }
        }
        else
            nNumId = USHRT_MAX;
    }
    else
        nNumId = 0;

    if( USHRT_MAX != nNumId )
    {
        if( nLvl >= nWW8MaxListLevel )
            nLvl = nWW8MaxListLevel-1;
        if( rWW8Wrt.bWrtWW8 )
        {
            // write sprmPIlvl and sprmPIlfo
            SwWW8Writer::InsUInt16( *rWW8Wrt.pO, 0x260a );
            rWW8Wrt.pO->Insert( nLvl, rWW8Wrt.pO->Count() );
            SwWW8Writer::InsUInt16( *rWW8Wrt.pO, 0x460b );
            SwWW8Writer::InsUInt16( *rWW8Wrt.pO, nNumId );
        }
        else if( pTxtNd && rWW8Wrt.Out_SwNum( pTxtNd ) )                // NumRules
            rWW8Wrt.pSepx->SetNum( pTxtNd );
    }
    return rWrt;
}

/* File FRMATR.HXX */

static Writer& OutWW8_SwFrmSize( Writer& rWrt, const SfxPoolItem& rHt )
{
    SwWW8Writer& rWW8Wrt = (SwWW8Writer&)rWrt;
    const SwFmtFrmSize& rSz = (const SwFmtFrmSize&)rHt;

    if( rWW8Wrt.bOutFlyFrmAttrs )                   // Flys
    {
        if( rWW8Wrt.bOutGrf )
            return rWrt;                // Fly um Grafik -> Auto-Groesse

//???? was ist bei Prozentangaben ???
        if( rSz.GetWidth() )
        {
            //"sprmPDxaWidth"
            if( rWW8Wrt.bWrtWW8 )
                rWW8Wrt.InsUInt16( 0x841A );
            else
                rWW8Wrt.pO->Insert( 28, rWW8Wrt.pO->Count() );
            rWW8Wrt.InsUInt16( (USHORT)rSz.GetWidth() );
        }

        if( rSz.GetHeight() )
        {
            // sprmPWHeightAbs
            if( rWW8Wrt.bWrtWW8 )
                rWW8Wrt.InsUInt16( 0x442B );
            else
                rWW8Wrt.pO->Insert( 45, rWW8Wrt.pO->Count() );

            USHORT nH = 0;
            switch( rSz.GetSizeType() )
            {
            case ATT_VAR_SIZE: break;
            case ATT_FIX_SIZE: nH = (USHORT)rSz.GetHeight() & 0x7fff; break;
            default:           nH = (USHORT)rSz.GetHeight() | 0x8000; break;
            }
            rWW8Wrt.InsUInt16( nH );
        }
    }
    else if( rWW8Wrt.bOutPageDescs )            // PageDesc : Breite + Hoehe
    {
        if( rWW8Wrt.pAktPageDesc->GetLandscape() )
        {
            /*sprmSBOrientation*/
            if( rWW8Wrt.bWrtWW8 )
                rWW8Wrt.InsUInt16( 0x301d );
            else
                rWW8Wrt.pO->Insert( 162, rWW8Wrt.pO->Count() );
            rWW8Wrt.pO->Insert( 2, rWW8Wrt.pO->Count() );
        }

        /*sprmSXaPage*/
        if( rWW8Wrt.bWrtWW8 )
            rWW8Wrt.InsUInt16( 0xB01F );
        else
            rWW8Wrt.pO->Insert( 164, rWW8Wrt.pO->Count() );
        rWW8Wrt.InsUInt16( (USHORT)rSz.GetWidth() );

        /*sprmSYaPage*/
        if( rWW8Wrt.bWrtWW8 )
            rWW8Wrt.InsUInt16( 0xB020 );
        else
            rWW8Wrt.pO->Insert( 165, rWW8Wrt.pO->Count() );
        rWW8Wrt.InsUInt16( (USHORT)rSz.GetHeight() );
    }
    return rWrt;
}

// FillOrder fehlt noch

// ReplaceCr() wird fuer Pagebreaks und Pagedescs gebraucht. Es wird ein
// bereits geschriebenes CR durch ein Break-Zeichen ersetzt. Replace muss
// direkt nach Schreiben des CR gerufen werden.
// Rueckgabe: FilePos des ersetzten CRs + 1 oder 0 fuer nicht ersetzt

ULONG SwWW8Writer::ReplaceCr( BYTE nChar )
{
    // Bug #49917#
    ASSERT( nChar, "gegen 0 ersetzt bringt WW97/95 zum Absturz" );

    ULONG nRetPos = 0, nPos = Strm().Tell();
    Strm().SeekRel( IsUnicode() ? -2 : -1 );
    BYTE nC1;
    Strm().Read( &nC1, 1 );
    if( nC1 == 0x0d )               // CR ?
    {
        Strm().SeekRel( -1 );       // CR hinter Zeile
        Strm().Write( &nChar, 1 );  // durch nChar ersetzen
        nRetPos = nPos;
    }
    Strm().Seek( nPos );

    if( 0x7 == nC1 )            // at end of TableRow ?
    {
        // then write as normal char
        WriteChar( nChar );
        nRetPos = Strm().Tell();
    }
#ifdef PRODUCT
    else
    {
        ASSERT( nRetPos || nPos == (ULONG)pFib->fcMin,
                "WW8_ReplaceCr an falscher FilePos gerufen" );
    }
#endif
    return nRetPos;
}

// Breaks schreiben nichts in das Ausgabe-Feld rWrt.pO,
// sondern nur in den Text-Stream ( Bedingung dafuer, dass sie von Out_Break...
// gerufen werden duerfen )
static Writer& OutWW8_SwFmtBreak( Writer& rWrt, const SfxPoolItem& rHt )
{
/*UMSTELLEN*/
    SwWW8Writer& rWW8Wrt = (SwWW8Writer&)rWrt;
    const SvxFmtBreakItem &rBreak = (const SvxFmtBreakItem&)rHt;

    if( rWW8Wrt.bStyDef )
    {
        switch( rBreak.GetBreak() )
        {
//JP 21.06.99: column breaks does never change to pagebreaks
//      case SVX_BREAK_COLUMN_BEFORE:
//      case SVX_BREAK_COLUMN_BOTH:

        case SVX_BREAK_PAGE_BEFORE:
        case SVX_BREAK_PAGE_BOTH:
            // sprmPPageBreakBefore/sprmPFPageBreakBefore
            if( rWW8Wrt.bWrtWW8 )
                rWW8Wrt.InsUInt16( 0x2407 );
            else
                rWW8Wrt.pO->Insert( 9, rWW8Wrt.pO->Count() );
            rWW8Wrt.pO->Insert( rBreak.GetValue() ? 1 : 0, rWW8Wrt.pO->Count() );
            break;
        }
    }
    else if( !rWW8Wrt.pFlyFmt )
    {
        BYTE nC = 0;
        BOOL bBefore = FALSE;

        switch( rBreak.GetBreak() )
        {
        case SVX_BREAK_NONE:                                // Ausgeschaltet
            if( !rWW8Wrt.bBreakBefore )
            {
                // sprmPPageBreakBefore/sprmPFPageBreakBefore
                if( rWW8Wrt.bWrtWW8 )
                    rWW8Wrt.InsUInt16( 0x2407 );
                else
                    rWW8Wrt.pO->Insert( 9, rWW8Wrt.pO->Count() );
                rWW8Wrt.pO->Insert( (BYTE)0, rWW8Wrt.pO->Count() );
            }
            return rWrt;

        case SVX_BREAK_COLUMN_BEFORE:                       // ColumnBreak
            bBefore = TRUE;
                // no break;
        case SVX_BREAK_COLUMN_AFTER:
        case SVX_BREAK_COLUMN_BOTH:
            nC = 0xe;
            break;

        case SVX_BREAK_PAGE_BEFORE:                         // PageBreak
            bBefore = TRUE;
            // no break;
        case SVX_BREAK_PAGE_AFTER:
        case SVX_BREAK_PAGE_BOTH:
            nC = 0xc;
            break;
        }

        if( (bBefore == rWW8Wrt.bBreakBefore ) && nC )  // #49917#
            rWW8Wrt.ReplaceCr( nC );
    }
    return rWrt;
}

static Writer& OutWW8_SvxPaperBin( Writer& rWrt, const SfxPoolItem& rHt )
{
    SwWW8Writer& rWrtWW8 = (SwWW8Writer&)rWrt;
    const SvxPaperBinItem& rItem = (const SvxPaperBinItem&)rHt;

    if( rWrtWW8.bOutPageDescs )
    {
        USHORT nVal;
        switch( rItem.GetValue() )
        {
        case 0: nVal = 15;  break;      // Automatically select
        case 1: nVal = 1;   break;      // Upper paper tray
        case 2: nVal = 4;   break;      // Manual paper feed
        default: nVal = 0;  break;
        }

        if( nVal )
        {
            // sprmSDmBinFirst  0x5007  word
            // sprmSDmBinOther  0x5008  word
            BYTE nOff = rWrtWW8.bOutFirstPage ? 0 : 1;
            if( rWrtWW8.bWrtWW8 )
                rWrtWW8.InsUInt16( 0x5007 + nOff );
            else
                rWrtWW8.pO->Insert( 140 + nOff, rWrtWW8.pO->Count() );
            rWrtWW8.InsUInt16( nVal );
        }
    }
    return rWrt;
}

static Writer& OutWW8_SwFmtLRSpace( Writer& rWrt, const SfxPoolItem& rHt )
{
    SwWW8Writer& rWW8Wrt = (SwWW8Writer&)rWrt;
    const SvxLRSpaceItem & rLR = (const SvxLRSpaceItem&) rHt;


    // Flys fehlen noch ( siehe RTF )

    if( rWW8Wrt.bOutFlyFrmAttrs )                   // Flys
    {
        // sprmPDxaFromText10
        if( rWW8Wrt.bWrtWW8 )
            rWW8Wrt.InsUInt16( 0x4622 );
        else
            rWW8Wrt.pO->Insert( 49, rWW8Wrt.pO->Count() );
        // Mittelwert nehmen, da WW nur 1 Wert kennt
        rWW8Wrt.InsUInt16( (USHORT) ( ( rLR.GetLeft() + rLR.GetRight() ) / 2 ) );
    }
    else if( rWW8Wrt.bOutPageDescs )                // PageDescs
    {
        USHORT nLDist, nRDist;
        const SfxPoolItem* pItem = ((SwWW8Writer&)rWrt).HasItem( RES_BOX );
        if( pItem )
        {
            nRDist = ((SvxBoxItem*)pItem)->CalcLineSpace( BOX_LINE_LEFT );
            nLDist = ((SvxBoxItem*)pItem)->CalcLineSpace( BOX_LINE_RIGHT );
        }
        else
            nLDist = nRDist = 0;
        nLDist += (USHORT)rLR.GetLeft();
        nRDist += (USHORT)rLR.GetRight();

        // sprmSDxaLeft
        if( rWW8Wrt.bWrtWW8 )
            rWW8Wrt.InsUInt16( 0xB021 );
        else
            rWW8Wrt.pO->Insert( 166, rWW8Wrt.pO->Count() );
        rWW8Wrt.InsUInt16( nLDist );
        // sprmSDxaRight
        if( rWW8Wrt.bWrtWW8 )
            rWW8Wrt.InsUInt16( 0xB022 );
        else
            rWW8Wrt.pO->Insert( 167, rWW8Wrt.pO->Count() );
        rWW8Wrt.InsUInt16( nRDist );
    }
    else
    {                                          // normale Absaetze
        // sprmPDxaLeft
        if( rWW8Wrt.bWrtWW8 )
            rWW8Wrt.InsUInt16( 0x840F );
        else
            rWW8Wrt.pO->Insert( 17, rWW8Wrt.pO->Count() );
        rWW8Wrt.InsUInt16( (USHORT)rLR.GetTxtLeft() );
        // sprmPDxaRight
        if( rWW8Wrt.bWrtWW8 )
            rWW8Wrt.InsUInt16( 0x840E );
        else
            rWW8Wrt.pO->Insert( 16, rWW8Wrt.pO->Count() );
        rWW8Wrt.InsUInt16( (USHORT)rLR.GetRight() );
        // sprmPDxaLeft1
        if( rWW8Wrt.bWrtWW8 )
            rWW8Wrt.InsUInt16( 0x8411 );
        else
            rWW8Wrt.pO->Insert( 19, rWW8Wrt.pO->Count() );
        rWW8Wrt.InsUInt16( rLR.GetTxtFirstLineOfst() );
    }
    return rWrt;
}

static USHORT lcl_CalcHdFtDist( const SwFrmFmt& rFmt, BOOL bLower )
{
    long nDist = 0;
    SwRect aRect( rFmt.FindLayoutRect( FALSE ));
    if( aRect.Height() )
        nDist += aRect.Height();
    else
    {
        const SwFmtFrmSize& rSz = rFmt.GetFrmSize();
        if( ATT_VAR_SIZE != rSz.GetSizeType() )
            nDist += rSz.GetHeight();
        else
        {
            nDist += 274;       // defaulten fuer 12pt Schrift
            const SvxULSpaceItem& rUL = rFmt.GetULSpace();
            nDist += ( bLower ? rUL.GetLower() : rUL.GetUpper() );
        }
    }
    return (USHORT)nDist;
}

static Writer& OutWW8_SwFmtULSpace( Writer& rWrt, const SfxPoolItem& rHt )
{
    SwWW8Writer& rWW8Wrt = (SwWW8Writer&)rWrt;
    const SvxULSpaceItem & rUL = (const SvxULSpaceItem&) rHt;

    // Flys fehlen noch ( siehe RTF )

    if( rWW8Wrt.bOutFlyFrmAttrs )                   // Flys
    {
        // sprmPDyaFromText
        if( rWW8Wrt.bWrtWW8 )
            rWW8Wrt.InsUInt16( 0x842E );
        else
            rWW8Wrt.pO->Insert( 48, rWW8Wrt.pO->Count() );
        // Mittelwert nehmen, da WW nur 1 Wert kennt
        rWW8Wrt.InsUInt16( (USHORT) ( ( rUL.GetUpper() + rUL.GetLower() ) / 2 ) );
    }
    else if( rWW8Wrt.bOutPageDescs )            // Page-UL
    {
        USHORT nUDist, nLDist;
        const SfxPoolItem* pItem = rWW8Wrt.HasItem( RES_BOX );
        if( pItem )
        {
            nUDist = ((SvxBoxItem*)pItem)->CalcLineSpace( BOX_LINE_TOP );
            nLDist = ((SvxBoxItem*)pItem)->CalcLineSpace( BOX_LINE_BOTTOM );
        }
        else
            nUDist = nLDist = 0;
        nUDist += rUL.GetUpper();
        nLDist += rUL.GetLower();

        // Kopf-/Fusszeilen beachten:
        if( 0 != ( pItem = rWW8Wrt.HasItem( RES_HEADER )) &&
            ((SwFmtHeader*)pItem)->IsActive() )
        {
            // dann aufjedenfall schon mal den Abstand der Kopfzeile zum
            // SeitenAnfang ausgeben
            // sprmSDyaHdrTop
            if( rWW8Wrt.bWrtWW8 )
                rWW8Wrt.InsUInt16( 0xB017 );
            else
                rWW8Wrt.pO->Insert( 156, rWW8Wrt.pO->Count() );
            rWW8Wrt.InsUInt16( nUDist );
            nUDist += ::lcl_CalcHdFtDist( *((SwFmtHeader*)pItem)->
                                            GetHeaderFmt(), TRUE );
        }
        // sprmSDyaTop
        if( rWW8Wrt.bWrtWW8 )
            rWW8Wrt.InsUInt16( 0x9023 );
        else
            rWW8Wrt.pO->Insert( 168, rWW8Wrt.pO->Count() );
        rWW8Wrt.InsUInt16( nUDist );


        if( 0 != ( pItem = rWW8Wrt.HasItem( RES_FOOTER )) &&
            ((SwFmtFooter*)pItem)->IsActive() )
        {
            // dann aufjedenfall schon mal den Abstand der Fusszeile zum
            // SeitenEnde ausgeben
            // sprmSDyaHdrBottom
            if( rWW8Wrt.bWrtWW8 )
                rWW8Wrt.InsUInt16( 0xB018 );
            else
                rWW8Wrt.pO->Insert( 157, rWW8Wrt.pO->Count() );
            rWW8Wrt.InsUInt16( nLDist );
            nLDist += ::lcl_CalcHdFtDist( *((SwFmtFooter*)pItem)->
                                            GetFooterFmt(), FALSE );
        }
        // sprmSDyaBottom
        if( rWW8Wrt.bWrtWW8 )
            rWW8Wrt.InsUInt16( 0x9024 );
        else
            rWW8Wrt.pO->Insert( 169, rWW8Wrt.pO->Count() );
        rWW8Wrt.InsUInt16( nLDist );
    }
    else
    {
        // sprmPDyaBefore
        if( rWW8Wrt.bWrtWW8 )
            rWW8Wrt.InsUInt16( 0xA413 );
        else
            rWW8Wrt.pO->Insert( 21, rWW8Wrt.pO->Count() );
        rWW8Wrt.InsUInt16( rUL.GetUpper() );
        // sprmPDyaAfter
        if( rWW8Wrt.bWrtWW8 )
            rWW8Wrt.InsUInt16( 0xA414 );
        else
            rWW8Wrt.pO->Insert( 22, rWW8Wrt.pO->Count() );
        rWW8Wrt.InsUInt16( rUL.GetLower() );
    }
    return rWrt;
}

// Print, Opaque, Protect fehlen noch

static Writer& OutWW8_SwFmtSurround( Writer& rWrt, const SfxPoolItem& rHt )
{
    SwWW8Writer& rWW8Wrt = (SwWW8Writer&)rWrt;
    if( rWW8Wrt.bOutFlyFrmAttrs )
    {
        if( rWW8Wrt.bWrtWW8 )
            rWW8Wrt.InsUInt16( 0x2423 );
        else
            rWW8Wrt.pO->Insert( 37, rWW8Wrt.pO->Count() );

        rWW8Wrt.pO->Insert( (SURROUND_NONE !=
                        ((const SwFmtSurround&) rHt).GetSurround() )
                    ? 2 : 1, rWW8Wrt.pO->Count() );
    }
    return rWrt;
}

Writer& OutWW8_SwFmtVertOrient( Writer& rWrt, const SfxPoolItem& rHt )
{
    const SwFmtVertOrient& rFlyVert = (const SwFmtVertOrient&) rHt;
    SwWW8Writer& rWW8Wrt = (SwWW8Writer&)rWrt;

//!!!! Ankertyp und entsprechende Umrechnung fehlt noch

    if( rWW8Wrt.bOutFlyFrmAttrs )
    {
        const SwFmtVertOrient& rFlyVert = (const SwFmtVertOrient&) rHt;

        short nPos;
        switch( rFlyVert.GetVertOrient() )
        {
        case VERT_NONE:         nPos = (short)rFlyVert.GetPos(); break;
        case VERT_CENTER:
        case VERT_LINE_CENTER:  nPos = -8; break;
        case VERT_BOTTOM:
        case VERT_LINE_BOTTOM:  nPos = -12; break;
        case VERT_TOP:
        case VERT_LINE_TOP:
        default:                nPos = -4; break;
        }

        // sprmPDyaAbs
        if( rWW8Wrt.bWrtWW8 )
            rWW8Wrt.InsUInt16( 0x8419 );
        else
            rWW8Wrt.pO->Insert( 27, rWW8Wrt.pO->Count() );
        rWW8Wrt.InsUInt16( nPos );
    }
    return rWrt;
}


Writer& OutWW8_SwFmtHoriOrient( Writer& rWrt, const SfxPoolItem& rHt )
{
    SwWW8Writer& rWW8Wrt = (SwWW8Writer&)rWrt;
    if( !rWW8Wrt.pFlyFmt )
    {
        ASSERT( rWW8Wrt.pFlyFmt, "HoriOrient ohne pFlyFmt !!" );
        return rWrt;
    }

//!!!! Ankertyp und entsprechende Umrechnung fehlt noch
    if( rWW8Wrt.bOutFlyFrmAttrs )
    {
        const SwFmtHoriOrient& rFlyHori = (const SwFmtHoriOrient&) rHt;

        short nPos;
        switch( rFlyHori.GetHoriOrient() )
        {
        case HORI_NONE:    {
                                nPos = (short)rFlyHori.GetPos();
                                if( !nPos )
                                    nPos = 1;   // WW: 0 ist reserviert
#if 0
// ist nicht noetig, da Bindung an Absatz als hor. Bindung an die
// Spalte exportiert wird, da so das Verhalten bei Mehrspaltigkeit
// am AEhnlichsten ist.
                                RndStdIds eAn = rWW8Wrt.pFlyFmt->GetAttrSet().
                                                GetAnchor().GetAnchorId();
                                if( eAn == FLY_AT_CNTNT || eAn == FLY_IN_CNTNT )
                                    nPos += GetPageL( rWW8Wrt );
#endif
                           }
                           break;

        case HORI_LEFT:    nPos = rFlyHori.IsPosToggle() ? -12 : 0;
                           break;
        case HORI_RIGHT:   nPos = rFlyHori.IsPosToggle() ? -16 : -8;
                           break;
        case HORI_CENTER:
        case HORI_FULL:                         // FULL nur fuer Tabellen
        default:           nPos = -4; break;
        }

        // sprmPDxaAbs
        if( rWW8Wrt.bWrtWW8 )
            rWW8Wrt.InsUInt16( 0x8418 );
        else
            rWW8Wrt.pO->Insert( 26, rWW8Wrt.pO->Count() );
        rWW8Wrt.InsUInt16( nPos );
    }
    return rWrt;
}

static Writer& OutWW8_SwFmtAnchor( Writer& rWrt, const SfxPoolItem& rHt )
{
    SwWW8Writer& rWW8Wrt = (SwWW8Writer&)rWrt;
    ASSERT( rWW8Wrt.pFlyFmt, "Anker ohne pFlyFmt !!" );

    if( rWW8Wrt.bOutFlyFrmAttrs )
    {
        const SwFmtAnchor& rAnchor = (const SwFmtAnchor&) rHt;
        BYTE nP = 0;
        switch( rAnchor.GetAnchorId() )
        {
        case FLY_PAGE:      nP |= ( 1 << 4 )        // Vert: Page
                                  | ( 2 << 6 );     // Horz: Page
                            break;
        // Im Fall eine Flys als Zeichen: Absatz-gebunden setzen!!!
        case FLY_AT_FLY:
        case FLY_AUTO_CNTNT:
        case FLY_AT_CNTNT:
        case FLY_IN_CNTNT:  nP |= ( 2 << 4 )        // Vert: Text
                                  | ( 0 << 6 );     // Horz: Column
                            break;
        }

        // sprmPPc
        if( rWW8Wrt.bWrtWW8 )
            rWW8Wrt.InsUInt16( 0x261B );
        else
            rWW8Wrt.pO->Insert( 29, rWW8Wrt.pO->Count() );
        rWW8Wrt.pO->Insert( nP, rWW8Wrt.pO->Count() );
    }
    return rWrt;
}

static Writer& OutWW8_SwFmtBackground( Writer& rWrt, const SfxPoolItem& rHt )
{
    SwWW8Writer& rWW8Wrt = (SwWW8Writer&)rWrt;

    if( !rWW8Wrt.bOutPageDescs )    // WW kann keinen Hintergrund
    {                               // in Section
        const SvxBrushItem& rBack = (const SvxBrushItem&)rHt;
        WW8_SHD aSHD;

        if( rWW8Wrt.TransBrush( rBack.GetColor(), aSHD ) )
        {
            // sprmPShd
            if( rWW8Wrt.bWrtWW8 )
                rWW8Wrt.InsUInt16( 0x442D );
            else
                rWW8Wrt.pO->Insert( 47, rWW8Wrt.pO->Count() );
            rWW8Wrt.InsUInt16( aSHD.GetValue() );
        }
    }
    return rWrt;
}


// TranslateBorderLine() liefert eine UINT32 zurueck, der noch in einen
// SVBT32 uebersetzt werden muss.
// bei Export als WW6 sind nur die unteren 16 Bit von Interesse
// bShadow darf bei Tabellenzellen *nicht* gesetzt sein !
UINT32 SwWW8Writer::TranslateBorderLine( const SvxBorderLine& rLine,
                                        USHORT nDist, BOOL bShadow )
{
    UINT32 nBrd = 0;
    UINT16 nWidth = rLine.GetInWidth() + rLine.GetOutWidth(), brcType = 0;
    UINT32 nColCode = 0;
    if( nWidth )                                // Linie ?
    {
        // BRC.brcType
        BOOL bDouble = 0 != rLine.GetInWidth() && 0 != rLine.GetOutWidth();
        BOOL bThick = !bDouble && !bWrtWW8 && nWidth > 75;
        if( bDouble )
            brcType = 3;
        else if( bThick )
            brcType = 2;
        else
            brcType = 1;

        // BRC.dxpLineWidth
        if( bThick )
            nWidth /= 2;

        if( bWrtWW8 )
        {
            // Angabe in 8tel Punkten, also durch 2.5, da 1 Punkt = 20 Twips
            nWidth = (( nWidth * 8 ) + 10 ) / 20;
            if( 0xff < nWidth )
                nWidth = 0xff;
        }
        else
        {
            // Angabe in 0.75 pt
            nWidth = ( nWidth + 7 ) / 15;
            if( nWidth > 5 )
                nWidth = 5;
        }

        if( 0 == nWidth )                       // ganz duenne Linie
            nWidth = 1;                         //       nicht weglassen

        // BRC.ico
        nColCode = TransCol( rLine.GetColor() );
    }

    // BRC.dxpSpace
    long nLDist = nDist;
    nLDist /= 20;               // Masseinheit : pt
    if( nLDist > 0x1f )
        nLDist = 0x1f;

    if( bWrtWW8 )
    {
        nBrd = nWidth + ( brcType << 8 );
        nBrd |= nColCode << 16;
        nBrd |= nLDist << 24;

        // fShadow, keine weiteren Einstellungen im WW moeglich
        if( bShadow )
            nBrd |= (0x2000L << 16);
    }
    else
    {
        nBrd = nWidth + ( brcType << 3 );
        nBrd |= (nColCode & 0x1f) << 6;
        nBrd |= nLDist << 11;
        // fShadow, keine weiteren Einstellungen im WW moeglich
        if( bShadow )
            nBrd |= 0x20;
    }

    return nBrd;
}

// MakeBorderLine() bekommt einen WW8Bytes* uebergeben, um die Funktion
// auch fuer die Tabellen-Umrandungen zu benutzen.
// Wenn nSprmNo == 0, dann wird der Opcode nicht ausgegeben.
// bShadow darf bei Tabellenzellen *nicht* gesetzt sein !
void SwWW8Writer::Out_BorderLine( WW8Bytes& rO, const SvxBorderLine* pLine,
                                  USHORT nDist, USHORT nOffset,
                                  BOOL bShadow )
{
    ASSERT( (0 <= nOffset && nOffset <= 3) || USHRT_MAX == nOffset ||
            ((0x702b - 0x6424) <= nOffset && nOffset <= (0x702e - 0x6424)),
                "SprmOffset ausserhalb des Bereichs" );


    UINT32 nBrdCd = pLine ? TranslateBorderLine( *pLine, nDist, bShadow )
                          : 0;
    if( bWrtWW8 )
    {
// WW97-SprmIds
// 0x6424, sprmPBrcTop      pap.brcTop;BRC;long; !!!!
// 0x6425, sprmPBrcLeft
// 0x6426, sprmPBrcBottom
// 0x6427, sprmPBrcRight
        if( USHRT_MAX != nOffset )                      // mit OpCode-Ausgabe ?
            SwWW8Writer::InsUInt16( rO, 0x6424 + nOffset );

        SwWW8Writer::InsUInt32( rO, nBrdCd );
    }
    else
    {
// WW95-SprmIds
//     38, sprmPBrcTop      - pap.brcTop BRC short !!!
//     39, sprmPBrcLeft
//     40, sprmPBrcBottom
//     41, sprmPBrcRight
        if( USHRT_MAX != nOffset )                      // mit OpCode-Ausgabe ?
            rO.Insert( (BYTE)( 38 + nOffset ), rO.Count() );
        SwWW8Writer::InsUInt16( rO, (UINT16)nBrdCd );
    }
}

// OutWW8_SwFmtBox1() ist fuer alle Boxen ausser in Tabellen.
// es wird pO des WW8Writers genommen
void SwWW8Writer::Out_SwFmtBox( const SvxBoxItem& rBox, BOOL bShadow )
{
    USHORT nOffset = 0;
    if( bOutPageDescs )
    {
        if( !bWrtWW8 )
            return ;            // WW95 kennt keine Seitenumrandung

// WW97-SprmIds
// 0x702b, sprmSBrcTop      pap.brcTop;BRC;long; !!!!
// 0x702c, sprmSBrcLeft
// 0x702d, sprmSBrcBottom
// 0x702e, sprmSBrcRight
        nOffset = (0x702b - 0x6424);
    }

    static USHORT __READONLY_DATA aBorders[] = {
            BOX_LINE_TOP, BOX_LINE_LEFT, BOX_LINE_BOTTOM, BOX_LINE_RIGHT };
    const USHORT* pBrd = aBorders;
    for( int i = 0; i < 4; ++i, ++pBrd )
    {
        const SvxBorderLine* pLn = rBox.GetLine( *pBrd );
        Out_BorderLine( *pO, pLn, rBox.GetDistance( *pBrd ), nOffset+i,
                            bShadow );
    }
}

// OutWW8_SwFmtBox2() ist fuer TC-Strukturen in Tabellen. Der Sprm-Opcode
// wird nicht geschrieben, da es in der TC-Structur ohne Opcode gepackt ist.
// dxpSpace wird immer 0, da WW das in Tabellen so verlangt
// ( Tabellenumrandungen fransen sonst aus )
// Ein WW8Bytes-Ptr wird als Ausgabe-Parameter uebergeben

void SwWW8Writer::Out_SwFmtTableBox( WW8Bytes& rO, const SvxBoxItem& rBox )
{
    // moeglich und vielleicht besser waere 0xffff
    static USHORT __READONLY_DATA aBorders[] = {
            BOX_LINE_TOP, BOX_LINE_LEFT, BOX_LINE_BOTTOM, BOX_LINE_RIGHT };
    const USHORT* pBrd = aBorders;
    for( int i = 0; i < 4; ++i, ++pBrd )
    {
        const SvxBorderLine* pLn = rBox.GetLine( *pBrd );
        Out_BorderLine( rO, pLn, 0, USHRT_MAX, FALSE );
    }
}

static Writer& OutWW8_SwFmtBox( Writer& rWrt, const SfxPoolItem& rHt )
{
                                // Fly um Grafik-> keine Umrandung hier, da
                                // der GrafikHeader bereits die Umrandung hat
    SwWW8Writer& rWW8Wrt = ((SwWW8Writer&)rWrt);
    if( !rWW8Wrt.bOutGrf )
    {
        BOOL bShadow = FALSE;
        const SfxPoolItem* pItem = ((SwWW8Writer&)rWrt).HasItem( RES_SHADOW );
        if( pItem )
        {
            const SvxShadowItem* p = (const SvxShadowItem*)pItem;
            bShadow = ( p->GetLocation() != SVX_SHADOW_NONE )
                      && ( p->GetWidth() != 0 );
        }

        rWW8Wrt.Out_SwFmtBox( (SvxBoxItem&)rHt, bShadow );
    }
    return rWrt;
}


static Writer& OutWW8_SwFmtCol( Writer& rWrt, const SfxPoolItem& rHt )
{
    const SwFmtCol& rCol = (const SwFmtCol&)rHt;
    const SwColumns& rColumns = rCol.GetColumns();
    SwWW8Writer& rWW8Wrt = ((SwWW8Writer&)rWrt);

    USHORT nCols = rColumns.Count();
    if( 1 < nCols
        && !rWW8Wrt.bOutFlyFrmAttrs )       // mehrspaltige Rahmen kann WW nicht
    {
        // dann besorge mal die Seitenbreite ohne Raender !!
        SwTwips nPageSize;
        const SwFrmFmt* pFmt = rWW8Wrt.pAktPageDesc
                                ? &rWW8Wrt.pAktPageDesc->GetMaster()
                                : &rWW8Wrt.pDoc->GetPageDesc(0).GetMaster();

        SwRect aRect( pFmt->FindLayoutRect( TRUE ));
        if( 0 == ( nPageSize = aRect.Width() ))
        {
            const SvxLRSpaceItem& rLR = pFmt->GetLRSpace();
            nPageSize = pFmt->GetFrmSize().GetWidth() -
                            rLR.GetLeft() - rLR.GetRight();
        }

        // CColumns
        if( rWW8Wrt.bWrtWW8 )
            rWW8Wrt.InsUInt16( 0x500b );
        else
            rWW8Wrt.pO->Insert( 144, rWW8Wrt.pO->Count() );
        rWW8Wrt.InsUInt16( nCols - 1 );

        // DxaColumns
        if( rWW8Wrt.bWrtWW8 )
            rWW8Wrt.InsUInt16( 0x900c );
        else
            rWW8Wrt.pO->Insert( 145, rWW8Wrt.pO->Count() );
        rWW8Wrt.InsUInt16( rCol.GetGutterWidth( TRUE ) );

        // LBetween
        if( rWW8Wrt.bWrtWW8 )
            rWW8Wrt.InsUInt16( 0x3019 );
        else
            rWW8Wrt.pO->Insert( 158, rWW8Wrt.pO->Count() );
        rWW8Wrt.pO->Insert( COLADJ_NONE == rCol.GetLineAdj() ? 0 : 1,
                            rWW8Wrt.pO->Count() );

        // Nachsehen, ob alle Spalten gleich sind
        BOOL bEven = TRUE;
        USHORT n;
        USHORT nColWidth = rCol.CalcPrtColWidth( 0, (USHORT)nPageSize );
        for( n = 1; n < nCols; n++ )
        {
            short nDiff = nColWidth - rCol.CalcPrtColWidth( n, (USHORT)nPageSize );
            if( nDiff > 10 || nDiff < -10 )      // Toleranz: 10 tw
            {
                bEven = FALSE;
                break;
            }
        }
        if( bEven )
        {
            USHORT nSpace = rColumns[0]->GetRight() + rColumns[1]->GetLeft();
            for( n = 2; n < nCols; n++ )
            {
                short nDiff = nSpace - ( rColumns[n - 1]->GetRight()
                                         + rColumns[n]->GetLeft() );
                if( nDiff > 10 || nDiff < -10 )
                { // Toleranz: 10 tw
                    bEven = FALSE;
                    break;
                }
            }
        }

        // FEvenlySpaced
        if( rWW8Wrt.bWrtWW8 )
            rWW8Wrt.InsUInt16( 0x3005 );
        else
            rWW8Wrt.pO->Insert( 138, rWW8Wrt.pO->Count() );
        rWW8Wrt.pO->Insert( bEven ? 1 : 0, rWW8Wrt.pO->Count() );

        if( !bEven )
        {
            for( USHORT n = 0; n < nCols; ++n )
            {
                //sprmSDxaColWidth
                if( rWW8Wrt.bWrtWW8 )
                    rWW8Wrt.InsUInt16( 0xF203 );
                else
                    rWW8Wrt.pO->Insert( 136, rWW8Wrt.pO->Count() );
                rWW8Wrt.pO->Insert( (BYTE)n, rWW8Wrt.pO->Count() );
                rWW8Wrt.InsUInt16( rCol.CalcPrtColWidth( n, (USHORT)nPageSize ) );

                if( n+1 != nCols )
                {
                    //sprmSDxaColSpacing
                    if( rWW8Wrt.bWrtWW8 )
                        rWW8Wrt.InsUInt16( 0xF204 );
                    else
                        rWW8Wrt.pO->Insert( 137, rWW8Wrt.pO->Count() );
                    rWW8Wrt.pO->Insert( (BYTE)n, rWW8Wrt.pO->Count() );
                    rWW8Wrt.InsUInt16( rColumns[ n ]->GetRight() +
                                       rColumns[ n + 1 ]->GetLeft() );
                }
            }
        }
    }
    return rWrt;
}

// "Absaetze zusammenhalten"
static Writer& OutWW8_SvxFmtKeep( Writer& rWrt, const SfxPoolItem& rHt )
{
// sprmFKeepFollow
    const SvxFmtKeepItem& rAttr = (const SvxFmtKeepItem&)rHt;
    SwWW8Writer& rWrtWW8 = (SwWW8Writer&)rWrt;
    if( rWrtWW8.bWrtWW8 )
        rWrtWW8.InsUInt16( 0x2406 );
    else
        rWrtWW8.pO->Insert( 8, rWrtWW8.pO->Count() );

    rWrtWW8.pO->Insert( rAttr.GetValue() ? 1 : 0, rWrtWW8.pO->Count() );
    return rWrt;
}


// exclude a paragraph from Line Numbering
static Writer& OutWW8_SwFmtLineNumber( Writer& rWrt, const SfxPoolItem& rHt )
{
// sprmPFNoLineNumb
    const SwFmtLineNumber& rAttr = (const SwFmtLineNumber&)rHt;

    SwWW8Writer& rWrtWW8 = (SwWW8Writer&)rWrt;
    if( rWrtWW8.bWrtWW8 )
        rWrtWW8.InsUInt16( 0x240C );
    else
        rWrtWW8.pO->Insert( 14, rWrtWW8.pO->Count() );

    rWrtWW8.pO->Insert( rAttr.IsCount() ? 0 : 1, rWrtWW8.pO->Count() );

    return rWrt;
}


/* File PARATR.HXX  */

static Writer& OutWW8_SvxLineSpacing( Writer& rWrt, const SfxPoolItem& rHt )
{
// sprmPDyaLine
    const SvxLineSpacingItem& rAttr = (const SvxLineSpacingItem&)rHt;
    SwWW8Writer& rWrtWW8 = (SwWW8Writer&)rWrt;
    if( rWrtWW8.bWrtWW8 )
        rWrtWW8.InsUInt16( 0x6412 );
    else
        rWrtWW8.pO->Insert( 20, rWrtWW8.pO->Count() );

    short nSpace = 240, nMulti = 0;

    switch( rAttr.GetLineSpaceRule() )
    {
    case SVX_LINE_SPACE_AUTO:
    case SVX_LINE_SPACE_FIX:
    case SVX_LINE_SPACE_MIN:
        {
            switch( rAttr.GetInterLineSpaceRule() )
            {
            case SVX_INTER_LINE_SPACE_FIX:      // unser Durchschuss
                // gibt es aber nicht in WW - also wie kommt man an
                // die MaxLineHeight heran?
                nSpace = (short)rAttr.GetInterLineSpace();
                break;

            case SVX_INTER_LINE_SPACE_PROP:
                nSpace = (short)(( 240L * rAttr.GetPropLineSpace() ) / 100L );
                nMulti = 1;
                break;

            default:                    // z.B. Minimum oder FIX?
                if( SVX_LINE_SPACE_FIX == rAttr.GetLineSpaceRule() )
                    nSpace = -(short)rAttr.GetLineHeight();
                else
                    nSpace = (short)rAttr.GetLineHeight();
                break;
            }
        }
        break;
    }

    rWrtWW8.InsUInt16( nSpace );
    rWrtWW8.InsUInt16( nMulti );
    return rWrt;
}


static Writer& OutWW8_SvxAdjust( Writer& rWrt, const SfxPoolItem& rHt )
{
// sprmPJc
    const SvxAdjustItem& rAttr = (const SvxAdjustItem&)rHt;
    BYTE nAdj = 255;
    switch( rAttr.GetAdjust() )
    {
    case SVX_ADJUST_LEFT:       nAdj = 0;   break;
    case SVX_ADJUST_RIGHT:      nAdj = 2;   break;
    case SVX_ADJUST_BLOCKLINE:
    case SVX_ADJUST_BLOCK:      nAdj = 3;   break;
    case SVX_ADJUST_CENTER:     nAdj = 1;   break;
    default:                    return rWrt;    // kein gueltiges Attribut
    }

    if( 255 != nAdj )               // gueltiges Attribut?
    {
        SwWW8Writer& rWrtWW8 = (SwWW8Writer&)rWrt;
        if( rWrtWW8.bWrtWW8 )
            rWrtWW8.InsUInt16( 0x2403 );
        else
            rWrtWW8.pO->Insert( 5, rWrtWW8.pO->Count() );
        rWrtWW8.pO->Insert( nAdj, rWrtWW8.pO->Count() );
    }
    return rWrt;
}

// "Absaetze trennen"
static Writer& OutWW8_SvxFmtSplit( Writer& rWrt, const SfxPoolItem& rHt )
{
// sprmPFKeep
    const SvxFmtSplitItem& rAttr = (const SvxFmtSplitItem&)rHt;
    SwWW8Writer& rWrtWW8 = (SwWW8Writer&)rWrt;
    if( rWrtWW8.bWrtWW8 )
        rWrtWW8.InsUInt16( 0x2405 );
    else
        rWrtWW8.pO->Insert( 7, rWrtWW8.pO->Count() );
    rWrtWW8.pO->Insert( rAttr.GetValue() ? 0 : 1, rWrtWW8.pO->Count() );
    return rWrt;
}

//  Es wird nur das Item "SvxWidowItem" und nicht die Orphans uebersetzt,
//  da es fuer beides im WW nur ein Attribut "Absatzkontrolle" gibt und
//  im SW wahrscheinlich vom Anwender immer Beide oder keiner gesetzt werden.
static Writer& OutWW8_SvxWidows( Writer& rWrt, const SfxPoolItem& rHt )
{
// sprmPFWidowControl
    const SvxWidowsItem& rAttr = (const SvxWidowsItem&)rHt;
    SwWW8Writer& rWrtWW8 = (SwWW8Writer&)rWrt;
    if( rWrtWW8.bWrtWW8 )
        rWrtWW8.InsUInt16( 0x2431 );
    else
        rWrtWW8.pO->Insert( 51, rWrtWW8.pO->Count() );
    rWrtWW8.pO->Insert( rAttr.GetValue() ? 1 : 0, rWrtWW8.pO->Count() );
    return rWrt;
}


class SwWW8WrTabu
{
    BYTE* pDel;                 // DelArray
    BYTE* pAddPos;              // AddPos-Array
    BYTE* pAddTyp;              // AddTyp-Array
    USHORT nAdd;                // so viele Tabs kommen hinzu
    USHORT nDel;                // so viele Tabs fallen weg
    USHORT nLeftParaMgn;        // fuer anderes Wertesystem SW/WW
public:
    SwWW8WrTabu( USHORT nDelMax, USHORT nAddMax, USHORT nLeftPara );
    ~SwWW8WrTabu();

    void Add( const SvxTabStop & rTS );
    void Del( const SvxTabStop & rTS );
    void PutAll( SwWW8Writer& rWW8Wrt );
};

SwWW8WrTabu::SwWW8WrTabu( USHORT nDelMax, USHORT nAddMax, USHORT nLeftPara )
    : nAdd( 0 ), nDel( 0 ), nLeftParaMgn( nLeftPara )
{
    pDel = ( nDelMax ) ? new BYTE[ nDelMax * 2 ] : 0;
    pAddPos = new BYTE[ nAddMax * 2 ];
    pAddTyp = new BYTE[ nAddMax ];
}

SwWW8WrTabu::~SwWW8WrTabu()
{
    delete[] pAddTyp;
    delete[] pAddPos;
    delete[] pDel;
}

// Add( const SvxTabStop & rTS ) fuegt einen Tab in die WW-Struktur ein
void SwWW8WrTabu::Add( const SvxTabStop & rTS )
{
    // Tab-Position eintragen
    ShortToSVBT16( (USHORT)rTS.GetTabPos() + nLeftParaMgn,
                   pAddPos + ( nAdd * 2 ) );

    // Tab-Typ eintragen
    BYTE nPara = 0;
    switch( rTS.GetAdjustment() )
    {
    case SVX_TAB_ADJUST_RIGHT:      nPara = 2;  break;
    case SVX_TAB_ADJUST_CENTER:     nPara = 1;  break;
    case SVX_TAB_ADJUST_DECIMAL:
            nPara = ',' == rTS.GetDecimal() ? 3 : 1;
            break;
    }

    switch( rTS.GetFill() )
    {
    case '.':   nPara |= 1 << 3; break;     // dotted leader
    case '_':   nPara |= 3 << 3; break;     // Single line leader
    case '-':   nPara |= 2 << 3; break;     // hyphenated leader
    case '=':   nPara |= 4 << 3; break;     // heavy line leader
    }

    ByteToSVBT8( nPara, pAddTyp + nAdd );
    ++nAdd;
}

// Del( const SvxTabStop & rTS ) fuegt einen zu loeschenden Tab
// in die WW-Struktur ein
void SwWW8WrTabu::Del( const SvxTabStop & rTS )
{
                                        // Tab-Position eintragen
    ShortToSVBT16( (USHORT)rTS.GetTabPos() + nLeftParaMgn,
                   pDel + ( nDel * 2 ) );
    ++nDel;
}

//  PutAll( SwWW8Writer& rWW8Wrt ) schreibt das Attribut nach rWrt.pO
void SwWW8WrTabu::PutAll( SwWW8Writer& rWrt )
{
    if( nAdd > 255 )
    {
        ASSERT( !this, "+ mehr als 255 Tabs dazu ?????" );
        nAdd = 255;
    }
    if( nDel > 255 )
    {
        ASSERT( !this, "+ mehr als 255 Tabs weg ?????" );
        nDel = 255;
    }

    USHORT nSiz = 2 * nDel + 3 * nAdd + 2;
    if( nSiz > 255 )
        nSiz = 255;

    if( rWrt.bWrtWW8 )
        rWrt.InsUInt16( 0xC60D );
    else
        rWrt.pO->Insert( 15, rWrt.pO->Count() );
    rWrt.pO->Insert( (BYTE)nSiz, rWrt.pO->Count() );    // cch eintragen

    // DelArr schreiben
    rWrt.pO->Insert( (BYTE)nDel, rWrt.pO->Count() );    // nDel eintragen
    rWrt.OutSprmBytes( pDel, nDel * 2 );
    // InsArr schreiben
    rWrt.pO->Insert( (BYTE)nAdd, rWrt.pO->Count() );    // nAdd schreiben
    rWrt.OutSprmBytes( pAddPos, 2 * nAdd );         // AddPosArray
    rWrt.OutSprmBytes( pAddTyp, nAdd );             // AddTypArray
}


static void OutWW8_SwTabStopAdd( Writer& rWrt, const SvxTabStopItem& rTStops,
                                 USHORT nLParaMgn  )
{
    SwWW8WrTabu aTab( 0, rTStops.Count(), nLParaMgn );

    for( USHORT n = 0; n < rTStops.Count(); n++ )
    {
        const SvxTabStop& rTS = rTStops[ n ];
        if( SVX_TAB_ADJUST_DEFAULT != rTS.GetAdjustment() ) // Def-Tabs ignorieren
            aTab.Add( rTS );
    }
    aTab.PutAll( (SwWW8Writer&)rWrt );
}

static void OutWW8_SwTabStopDelAdd( Writer& rWrt, const SvxTabStopItem& rTOld,
                                const SvxTabStopItem& rTNew, USHORT nLParaMgn )
{
    SwWW8WrTabu aTab( rTOld.Count(), rTNew.Count(), nLParaMgn );

    USHORT nO = 0;      // rTOld Index
    USHORT nN = 0;      // rTNew Index

    do {
        const SvxTabStop* pTO;
        long nOP;
        if( nO < rTOld.Count() )                    // alt noch nicht am Ende ?
        {
            pTO = &rTOld[ nO ];
            nOP = pTO->GetTabPos();
            if( SVX_TAB_ADJUST_DEFAULT == pTO->GetAdjustment() )
            {
                nO++;                                // Default-Tab ignorieren
                continue;
            }
        }
        else
        {
            pTO = 0;
            nOP = LONG_MAX;
        }

        const SvxTabStop* pTN;
        long nNP;
        if( nN < rTNew.Count() )                    // neu noch nicht am Ende
        {
            pTN = &rTNew[ nN ];
            nNP = pTN->GetTabPos();
            if( SVX_TAB_ADJUST_DEFAULT == pTN->GetAdjustment() )
            {
                nN++;                               // Default-Tab ignorieren
                continue;
            }
        }
        else
        {
            pTN = 0;
            nNP = LONG_MAX;
        }

        if( nOP == LONG_MAX && nNP == LONG_MAX )
            break;                                  // alles fertig

        if( nOP < nNP )                             // naechster Tab ist alt
        {
            aTab.Del( *pTO );                       // muss geloescht werden
            nO++;
        }
        else if( nNP < nOP )                        // naechster Tab ist neu
        {
            aTab.Add( *pTN );                       // muss eigefuegt werden
            nN++;
        }
        else if ( pTO->IsEqual( *pTN ) )            // Tabs sind gleich
        {
            nO++;                                   // nichts zu tun
            nN++;
        }
        else                                        // Tabs selbe Pos, diff Typ
        {
            aTab.Del( *pTO );                       // alten loeschen
            aTab.Add( *pTN );                       // neuen einfuegen
            nO++;
            nN++;
        }
    } while( 1 );

    aTab.PutAll( (SwWW8Writer&)rWrt );
}

static Writer& OutWW8_SwTabStop( Writer& rWrt, const SfxPoolItem& rHt )
{
    SwWW8Writer& rWW8Wrt = (SwWW8Writer&)rWrt;
    const SvxTabStopItem & rTStops = (const SvxTabStopItem&)rHt;
    const SfxPoolItem* pLR = rWW8Wrt.HasItem( RES_LR_SPACE );
    USHORT nOffset = pLR ? ((const SvxLRSpaceItem*)pLR)->GetTxtLeft() : 0;

    const SfxPoolItem* pItem = 0;

    if( rWW8Wrt.bStyDef             // StyleDef -> "einfach" eintragen
        || !rWW8Wrt.pStyAttr        // keine Style-Attrs -> dito
        || ( SFX_ITEM_SET != rWW8Wrt.pStyAttr->GetItemState(
            RES_PARATR_TABSTOP, TRUE, &pItem  ) ) ) // kein Tab-Attr in Styles -> dito
    {
        OutWW8_SwTabStopAdd( rWW8Wrt, rTStops, nOffset );
    }
    else if ( pItem )       // Harte Attribute: Differenzen zum Style eintragen
    {
        OutWW8_SwTabStopDelAdd( rWW8Wrt, *(const SvxTabStopItem*)pItem,
                                rTStops, nOffset );
    }
    return rWrt;
}

//-----------------------------------------------------------------------

/*
 * lege hier die Tabellen fuer die WW-Funktions-Pointer auf
 * die Ausgabe-Funktionen an.
 * Es sind lokale Strukturen, die nur innerhalb
 * bekannt sein muessen.
 */

SwAttrFnTab aWW8AttrFnTab = {
/* RES_CHRATR_CASEMAP   */          OutWW8_SwCaseMap,
/* RES_CHRATR_CHARSETCOLOR */       0,
/* RES_CHRATR_COLOR */              OutWW8_SwColor,
/* RES_CHRATR_CONTOUR   */          OutWW8_SwContour,
/* RES_CHRATR_CROSSEDOUT    */      OutWW8_SwCrossedOut,
/* RES_CHRATR_ESCAPEMENT    */      OutWW8_SwEscapement,
/* RES_CHRATR_FONT  */              OutWW8_SwFont,
/* RES_CHRATR_FONTSIZE  */          OutWW8_SwSize,
/* RES_CHRATR_KERNING   */          OutWW8_SwKerning,
/* RES_CHRATR_LANGUAGE  */          OutWW8_SwLanguage,
/* RES_CHRATR_POSTURE   */          OutWW8_SwPosture,
/* RES_CHRATR_PROPORTIONALFONTSIZE*/0,
/* RES_CHRATR_SHADOWED  */          OutWW8_SwShadow,
/* RES_CHRATR_UNDERLINE */          OutWW8_SwUnderline,
/* RES_CHRATR_WEIGHT    */          OutWW8_SwWeight,
/* RES_CHRATR_WORDLINEMODE   */     0,   // Wird bei Underline mitbehandelt
/* RES_CHRATR_AUTOKERN   */         OutWW8_SvxAutoKern,
/* RES_CHRATR_BLINK */              0, // neu: blinkender Text
/* RES_CHRATR_NOHYPHEN  */          0, // Neu: nicht trennen
/* RES_CHRATR_NOLINEBREAK */        0, // Neu: nicht umbrechen
/* RES_CHRATR_BACKGROUND */         OutWW8_SwFmtCharBackground,
/* RES_CHRATR_CJK_FONT */           OutWW8_SwCJKFont,
/* RES_CHRATR_CJK_FONTSIZE */       OutWW8_SwSize,
/* RES_CHRATR_CJK_LANGUAGE */       OutWW8_SwLanguage,
/* RES_CHRATR_CJK_POSTURE */        OutWW8_SwPosture,
/* RES_CHRATR_CJK_WEIGHT */         OutWW8_SwWeight,
/* RES_CHRATR_CTL_FONT */           0,
/* RES_CHRATR_CTL_FONTSIZE */       0,
/* RES_CHRATR_CTL_LANGUAGE */       0,
/* RES_CHRATR_CTL_POSTURE */        0,
/* RES_CHRATR_CTL_WEIGHT */         0,
/* RES_CHRATR_WRITING_DIRECTION */  0,
/* RES_CHRATR_EMPHASIS_MARK*/       OutWW8_EmphasisMark,
/* RES_CHRATR_DUMMY3 */             0,
/* RES_CHRATR_DUMMY4 */             0,
/* RES_CHRATR_DUMMY5 */             0,
/* RES_CHRATR_DUMMY1 */             0, // Dummy:

/* RES_TXTATR_INETFMT */            OutSwFmtINetFmt,
/* RES_TXTATR_DUMMY */              0,
/* RES_TXTATR_REFMARK */            0,      // handel by SwAttrIter
/* RES_TXTATR_TOXMARK   */          0,      // handel by SwAttrIter
/* RES_TXTATR_CHARFMT   */          OutWW8_SwTxtCharFmt,
/* RES_TXTATR_TWO_LINES */          0,
/* RES_TXTATR_CJK_RUBY */           0,
/* RES_TXTATR_UNKNOWN_CONTAINER */  0,
/* RES_TXTATR_DUMMY5 */             0,
/* RES_TXTATR_DUMMY6 */             0,

/* RES_TXTATR_FIELD */              OutWW8_SwField,
/* RES_TXTATR_FLYCNT    */          OutWW8_SwFlyCntnt,
/* RES_TXTATR_FTN       */          OutWW8_SwFtn,
/* RES_TXTATR_SOFTHYPH */           0,  // old attr. - coded now by character
/* RES_TXTATR_HARDBLANK */          OutWW8_SwHardBlank,
/* RES_TXTATR_DUMMY1 */             0, // Dummy:
/* RES_TXTATR_DUMMY2 */             0, // Dummy:

/* RES_PARATR_LINESPACING   */      OutWW8_SvxLineSpacing,
/* RES_PARATR_ADJUST    */          OutWW8_SvxAdjust,
/* RES_PARATR_SPLIT */              OutWW8_SvxFmtSplit,
/* RES_PARATR_ORPHANS   */          0, // OutW4W_SwOrphans, // kann WW nicht unabhaengig von Widows
/* RES_PARATR_WIDOWS    */          OutWW8_SvxWidows,
/* RES_PARATR_TABSTOP   */          OutWW8_SwTabStop,
/* RES_PARATR_HYPHENZONE*/          OutWW8_SvxHyphenZone,
/* RES_PARATR_DROP */               0,
/* RES_PARATR_REGISTER */           0, // neu:  Registerhaltigkeit
/* RES_PARATR_NUMRULE */            OutWW8_SwNumRuleItem,
/* RES_PARATR_SCRIPTSPACE */        OutWW8_SfxBoolItem, // Dummy:
/* RES_PARATR_HANGINGPUNCTUATION */ OutWW8_SfxBoolItem, // Dummy:
/* RES_PARATR_DUMMY1 */             OutWW8_SfxBoolItem, // Dummy:
/* RES_PARATR_DUMMY2 */             0, // Dummy:
/* RES_PARATR_DUMMY3 */             0, // Dummy:
/* RES_PARATR_DUMMY4 */             0, // Dummy:
/* RES_PARATR_DUMMY5 */             0, // Dummy:
/* RES_PARATR_DUMMY6 */             0, // Dummy:
/* RES_PARATR_DUMMY7 */             0, // Dummy:
/* RES_PARATR_DUMMY8 */             0, // Dummy:

/* RES_FILL_ORDER   */              0, // OutW4W_SwFillOrder,
/* RES_FRM_SIZE */                  OutWW8_SwFrmSize,
/* RES_PAPER_BIN   */               OutWW8_SvxPaperBin,
/* RES_LR_SPACE */                  OutWW8_SwFmtLRSpace,
/* RES_UL_SPACE */                  OutWW8_SwFmtULSpace,
/* RES_PAGEDESC */                  0,  // wird bei OutBreaks beachtet
/* RES_BREAK */                     OutWW8_SwFmtBreak,
/* RES_CNTNT */                     0, /* 0, // OutW4W_??? */
/* RES_HEADER */                    0,  // wird bei der PageDesc ausgabe beachtet
/* RES_FOOTER */                    0,  // wird bei der PageDesc ausgabe beachtet
/* RES_PRINT */                     0, // OutW4W_SwFmtPrint,
/* RES_OPAQUE */                    0, // OutW4W_SwFmtOpaque, // kann WW nicht
/* RES_PROTECT */                   0, // OutW4W_SwFmtProtect,
/* RES_SURROUND */                  OutWW8_SwFmtSurround,
/* RES_VERT_ORIENT */               OutWW8_SwFmtVertOrient,
/* RES_HORI_ORIENT */               OutWW8_SwFmtHoriOrient,
/* RES_ANCHOR */                    OutWW8_SwFmtAnchor,
/* RES_BACKGROUND */                OutWW8_SwFmtBackground,
/* RES_BOX  */                      OutWW8_SwFmtBox,
/* RES_SHADOW */                    0, // Wird bei SwFmtBox mitbehandelt
/* RES_FRMMACRO */                  0, /* 0, // OutW4W_??? */
/* RES_COL */                       OutWW8_SwFmtCol,
/* RES_KEEP */                      OutWW8_SvxFmtKeep,
/* RES_URL */                       0, // URL
/* RES_EDIT_IN_READONLY */          0,
/* RES_LAYOUT_SPLIT */              0,
/* RES_CHAIN */                     0,
/* RES_FRMATR_DUMMY2 */             0, // Dummy:
/* RES_LINENUMBER */                OutWW8_SwFmtLineNumber, // Line Numbering
/* RES_FRMATR_DUMMY4 */             0, // Dummy:
/* RES_FRMATR_DUMMY5 */             0, // Dummy:
/* RES_FRMATR_DUMMY6 */             0, // Dummy:
/* RES_FRMATR_DUMMY7 */             0, // Dummy:
/* RES_FRMATR_DUMMY8 */             0, // Dummy:
/* RES_FRMATR_DUMMY9 */             0, // Dummy:


/* RES_GRFATR_MIRRORGRF */          0, // OutW4W_SwMirrorGrf,
/* RES_GRFATR_CROPGRF   */          0, // OutW4W_SwCropGrf
/* RES_GRFATR_ROTATION */           0,
/* RES_GRFATR_LUMINANCE */          0,
/* RES_GRFATR_CONTRAST */           0,
/* RES_GRFATR_CHANNELR */           0,
/* RES_GRFATR_CHANNELG */           0,
/* RES_GRFATR_CHANNELB */           0,
/* RES_GRFATR_GAMMA */              0,
/* RES_GRFATR_INVERT */             0,
/* RES_GRFATR_TRANSPARENCY */       0,
/* RES_GRFATR_DRWAMODE */           0,
/* RES_GRFATR_DUMMY1 */             0,
/* RES_GRFATR_DUMMY2 */             0,
/* RES_GRFATR_DUMMY3 */             0,
/* RES_GRFATR_DUMMY4 */             0,
/* RES_GRFATR_DUMMY5 */             0,

/* RES_BOXATR_FORMAT */             0,
/* RES_BOXATR_FORMULA */            0,
/* RES_BOXATR_VALUE */              0,

/* RES_UNKNOWNATR_CONTAINER */      0
};


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

      $Log: not supported by cvs2svn $
      Revision 1.5  2000/12/01 11:22:52  jp
      Task #81077#: im-/export of CJK documents

      Revision 1.4  2000/11/24 19:47:04  er
      #80660# GetNumberFmt: new date keys

      Revision 1.3  2000/11/20 09:38:45  jp
      new para attributes - expand para range

      Revision 1.2  2000/11/04 21:49:59  er
      GetMappedFormatstring with LocaleDataWrapper instead of International

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

      Revision 1.51  2000/09/18 16:04:58  willem.vandorp
      OpenOffice header added.

      Revision 1.50  2000/08/21 10:14:14  khz
      Export Line Numbering (restart on new section)

      Revision 1.49  2000/08/04 10:56:44  jp
      Soft-/HardHyphens & HardBlanks changed from attribute to unicode character

      Revision 1.48  2000/07/31 19:24:54  jp
      new attributes for CJK/CTL and graphic

      Revision 1.47  2000/07/25 14:46:38  khz
      #76811# save AutoHyphenation flag in Document Properties

      Revision 1.46  2000/07/06 11:05:03  khz
      Export *result* of field nonexisting in WW as either Unicode or 8bit text

      Revision 1.45  2000/06/19 09:30:59  khz
      Export the new WW2000 _underlining_ features

      Revision 1.44  2000/06/09 16:30:26  jp
      Write correct edit-/create-/print-/change - datetime fields

      Revision 1.43  2000/05/12 16:14:18  jp
      Changes for Unicode

      Revision 1.42  2000/04/18 12:58:03  khz
      Task #75183# to set char language use sprmCRgLid0 rather than sprmCLid

      Revision 1.41  2000/03/03 15:20:01  os
      StarView remainders removed

      Revision 1.40  2000/02/21 13:05:36  jp
      #70473# changes for unicode

      Revision 1.39  2000/02/11 14:40:03  hr
      #70473# changes for unicode ( patched by automated patchtool )

      Revision 1.38  1999/12/20 17:41:37  jp
      Bug #70749#: Date/Time-Numberformats in german format from the formatter

      Revision 1.37  1999/12/15 17:06:22  jp
      Bug #70913#: write Ftn-/EndNoteInfo - at end of section or page/doc

      Revision 1.36  1999/12/08 13:53:01  jp
      Task #70258#: textattr for XMLAttrContainer

      Revision 1.35  1999/11/29 09:09:49  jp
      InsertSpecialChar: ask for ChpIter

      Revision 1.34  1999/11/25 21:22:33  jp
      Bug #70131#: OutFields: append the charattributes of the node to the sprms

      Revision 1.33  1999/11/24 13:14:25  jp
      remove GetTimePara/GetDatePara, ReplaceCr: insert char at row end

      Revision 1.32  1999/11/22 18:26:04  jp
      export of TOX and TOX entries

      Revision 1.31  1999/11/12 16:07:12  jp
      write foot-/endnote attributes with correct charfmts

      Revision 1.30  1999/11/12 13:23:25  jp
      Escapement: write AUTO-Escapment correct

      Revision 1.29  1999/11/10 16:09:54  jp
      Bug #67922#: write header/footer for w95

      Revision 1.28  1999/10/29 17:45:57  jp
      export of 'complex'(vert. merged) tables

      Revision 1.26  1999/10/14 21:06:13  jp
      Bug #68617#,#68705# and other little things

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