summaryrefslogtreecommitdiff
path: root/sw/source/filter/ww8/ww8par2.cxx
blob: b17099d6b6938113b79f65993bf9ce5ca128776f (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
3624
3625
3626
3627
3628
3629
3630
3631
3632
3633
3634
3635
3636
3637
3638
3639
3640
3641
3642
3643
3644
3645
3646
3647
3648
3649
3650
3651
3652
3653
3654
3655
3656
3657
3658
3659
3660
3661
3662
3663
3664
3665
3666
3667
3668
3669
3670
3671
3672
3673
3674
3675
3676
3677
3678
3679
3680
3681
3682
3683
3684
3685
3686
3687
3688
3689
3690
3691
3692
3693
3694
3695
3696
3697
3698
3699
3700
3701
3702
3703
3704
3705
3706
3707
3708
3709
3710
3711
3712
3713
3714
3715
3716
3717
3718
3719
3720
3721
3722
3723
3724
3725
3726
3727
3728
3729
3730
3731
3732
3733
3734
3735
3736
3737
3738
3739
3740
3741
3742
3743
3744
3745
3746
3747
3748
3749
3750
3751
3752
3753
3754
3755
3756
3757
3758
3759
3760
3761
3762
3763
3764
3765
3766
3767
3768
3769
3770
3771
3772
3773
3774
3775
3776
3777
3778
3779
3780
3781
3782
3783
3784
3785
3786
3787
3788
3789
3790
3791
3792
3793
3794
3795
3796
3797
3798
3799
3800
3801
3802
3803
3804
3805
3806
3807
3808
3809
3810
3811
3812
3813
3814
3815
3816
3817
3818
3819
3820
3821
3822
3823
3824
3825
3826
3827
3828
3829
3830
3831
3832
3833
3834
3835
3836
3837
3838
3839
3840
3841
3842
3843
3844
3845
3846
3847
3848
3849
3850
3851
3852
3853
3854
3855
3856
3857
3858
3859
3860
3861
3862
3863
3864
3865
3866
3867
3868
3869
3870
3871
3872
3873
/*************************************************************************
 *
 *  $RCSfile: ww8par2.cxx,v $
 *
 *  $Revision: 1.78 $
 *
 *  last change: $Author: cmc $ $Date: 2002-12-10 12:41:17 $
 *
 *  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): _______________________________________
 *
 *
 ************************************************************************/

/* vi:set tabstop=4 shiftwidth=4 expandtab: */
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil -*- */

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

#pragma hdrstop

#ifndef _SOLAR_H
#include <tools/solar.h>
#endif

#ifndef _SV_FONTTYPE_HXX
#include <vcl/fonttype.hxx>
#endif
#ifndef _SV_FONT_HXX
#include <vcl/font.hxx>
#endif

#ifndef _SFXDOCINF_HXX //autogen
#include <sfx2/docinf.hxx>
#endif

#define ITEMID_BOXINFO      SID_ATTR_BORDER_INNER
#ifndef _HINTIDS_HXX
#include <hintids.hxx>
#endif

#ifndef _SVX_COLRITEM_HXX
#include <svx/colritem.hxx>
#endif
#ifndef _SVX_ORPHITEM_HXX //autogen
#include <svx/orphitem.hxx>
#endif
#ifndef _SVX_WIDWITEM_HXX //autogen
#include <svx/widwitem.hxx>
#endif
#ifndef _SVX_BRSHITEM_HXX //autogen
#include <svx/brshitem.hxx>
#endif
#ifndef _SVX_BOXITEM_HXX //autogen
#include <svx/boxitem.hxx>
#endif
#ifndef _SVX_LRSPITEM_HXX //autogen
#include <svx/lrspitem.hxx>
#endif
#ifndef _SVX_FHGTITEM_HXX //autogen
#include <svx/fhgtitem.hxx>
#endif
#ifndef _SVX_FHGTITEM_HXX //autogen
#include <svx/fhgtitem.hxx>
#endif
#ifndef _SVX_HYZNITEM_HXX //autogen
#include <svx/hyznitem.hxx>
#endif
#ifndef _SVX_FRMDIRITEM_HXX
#include <svx/frmdiritem.hxx>
#endif

#ifndef _PAM_HXX
#include <pam.hxx>              // fuer SwPam
#endif
#ifndef _DOC_HXX
#include <doc.hxx>
#endif
#ifndef _DOCARY_HXX
#include <docary.hxx>
#endif
#ifndef _NDTXT_HXX
#include <ndtxt.hxx>            // class SwTxtNode
#endif
#ifndef _PARATR_HXX
#include <paratr.hxx>           // SwNumRuleItem
#endif
#ifndef _POOLFMT_HXX
#include <poolfmt.hxx>          // RES_POOLCOLL_STANDARD
#endif
#ifndef _SWTABLE_HXX
#include <swtable.hxx>          // class SwTableLines, ...
#endif
#ifndef _TBLSEL_HXX
#include <tblsel.hxx>           // class _SwSelBox
#endif
#ifndef _MDIEXP_HXX
#include <mdiexp.hxx>
#endif
#ifndef _FMTPDSC_HXX
#include <fmtpdsc.hxx>
#endif
#ifndef _TXTFTN_HXX //autogen
#include <txtftn.hxx>
#endif
#ifndef _FRMFMT_HXX
#include <frmfmt.hxx>
#endif
#ifndef _FTNIDX_HXX
#include <ftnidx.hxx>
#endif
#ifndef _FMTFTN_HXX //autogen
#include <fmtftn.hxx>
#endif
#ifndef _CHARFMT_HXX
#include <charfmt.hxx>
#endif
#ifndef _SWSTYLENAMEMAPPER_HXX
#include <SwStyleNameMapper.hxx>
#endif

#ifndef _FLTSHELL_HXX
#include <fltshell.hxx>         // fuer den Attribut Stack
#endif
#ifndef _FMTANCHR_HXX //autogen
#include <fmtanchr.hxx>
#endif

#ifndef _WW8STRUC_HXX
#include "ww8struc.hxx"         // struct TC
#endif
#ifndef _WW8PAR_HXX
#include "ww8par.hxx"
#endif
#ifndef _WW8PAR2_HXX
#include "ww8par2.hxx"
#endif

#define MAX_COL 64  // WW6-Beschreibung: 32, WW6-UI: 31 & WW8-UI: 63!

class WW8SelBoxInfo: public SwSelBoxes_SAR
{
private:
    WW8SelBoxInfo(const WW8SelBoxInfo&);
    WW8SelBoxInfo& operator=(const WW8SelBoxInfo&);
public:
    short nGroupXStart;
    short nGroupWidth;

    WW8SelBoxInfo(short nXCenter, short nWidth)
        : nGroupXStart( nXCenter ), nGroupWidth( nWidth )
    {}
};

typedef WW8SelBoxInfo* WW8SelBoxInfoPtr;

SV_DECL_PTRARR_DEL(WW8MergeGroups, WW8SelBoxInfoPtr, 16,16)
SV_IMPL_PTRARR(WW8MergeGroups, WW8SelBoxInfoPtr)

struct WW8TabBandDesc
{
    WW8TabBandDesc* pNextBand;
    short nGapHalf;
    short mnDefaultLeft;
    short mnDefaultTop;
    short mnDefaultRight;
    short mnDefaultBottom;
    bool mbHasSpacing;
    short nLineHeight;
    short nRows;
    short nCenter[MAX_COL + 1]; // X-Rand aller Zellen dieses Bandes
    short nWidth[MAX_COL + 1];  // Laenge aller Zellen dieses Bandes
    short nWwCols;      // BYTE wuerde reichen, alignment -> short
    short nSwCols;      // SW: so viele Spalten fuer den Writer
    bool bLEmptyCol;    // SW: Links eine leere Zusatz-Spalte
    bool bREmptyCol;    // SW: dito rechts
    WW8_TCell* pTCs;
    BYTE nOverrideSpacing[MAX_COL + 1];
    short nOverrideValues[MAX_COL + 1][4];
    WW8_SHD* pSHDs;
    sal_uInt32* pNewSHDs;
    WW8_BRC aDefBrcs[6];


    // nur fuer WW6-7: diese Zelle hat WW-Flag bMerged (horizontal) gesetzt
    //bool bWWMergedVer6[MAX_COL];


    bool bExist[MAX_COL];           // Existiert diese Zelle ?
    UINT8 nTransCell[MAX_COL + 2];  // UEbersetzung WW-Index -> SW-Index

    WW8TabBandDesc() {  memset( this, 0, sizeof( *this ) ); };
    WW8TabBandDesc( WW8TabBandDesc& rBand );    // tief kopieren
    ~WW8TabBandDesc() { delete[] pTCs; delete[] pSHDs; delete[] pNewSHDs;};
    static void setcelldefaults(WW8_TCell *pCells, short nCells);
    void ReadDef(bool bVer67, const BYTE* pS);
    void ProcessSprmTSetBRC(bool bVer67, const BYTE* pParamsTSetBRC);
    void ProcessSprmTDxaCol(const BYTE* pParamsTDxaCol);
    void ProcessSprmTDelete(const BYTE* pParamsTDelete);
    void ProcessSprmTInsert(const BYTE* pParamsTInsert);
    void ProcessSpacing(const BYTE* pParamsTInsert);
    void ProcessSpecificSpacing(const BYTE* pParamsTInsert);
    void ReadShd(const BYTE* pS );
    void ReadNewShd(const BYTE* pS, bool bVer67);

    enum wwDIR {wwTOP = 0, wwLEFT = 1, wwBOTTOM = 2, wwRIGHT = 3};
};

class WW8TabDesc
{
    ::std::vector<String> aNumRuleNames;

    SwWW8ImplReader* pIo;

    WW8TabBandDesc* pFirstBand;
    WW8TabBandDesc* pActBand;

    SwPosition* pTmpPos;

    SwTableNode* pTblNd;            // Tabellen-Node
    const SwTableLines* pTabLines;  // Zeilen-Array davon
    SwTableLine* pTabLine;          // akt. Zeile
    SwTableBoxes* pTabBoxes;        // Boxen-Array in akt. Zeile
    SwTableBox* pTabBox;            // akt. Zelle

    WW8MergeGroups* pMergeGroups;   // Listen aller zu verknuepfenden Zellen

    WW8_TCell* pAktWWCell;

    short nRows;
    short nDefaultSwCols;
    short nBands;
    short nMinLeft;
    short nConvertedLeft;
    short nMaxRight;
    short nSwWidth;

    bool bOk;
    bool bHeader;
    bool bClaimLineFmt;
    SwHoriOrient eOri;
    bool bIsBiDi;
                                // 2. allgemeine Verwaltungsinfo
    short nAktRow;
    short nAktBandRow;          // SW: in dieser Zeile des akt. Bandes bin ich
                                // 3. Verwaltungsinfo fuer Writer
    short nAktCol;


    // 4. Methoden

    USHORT GetLogicalWWCol() const;
    void SetTabBorders( SwTableBox* pBox, short nIdx );
    void SetTabShades( SwTableBox* pBox, short nWwIdx );
    void SetTabVertAlign( SwTableBox* pBox, short nWwIdx );
    void CalcDefaults();
    bool SetPamInCell(short nWwCol, bool bPam);
    void InsertCells( short nIns );
    void AdjustNewBand();

    // durchsucht pMergeGroups, meldet Index der ersten, passenden Gruppe bzw.
    // -1 Details siehe bei der Implementierung
    bool FindMergeGroup(short nX1, short nWidth, bool bExact, short& nMGrIdx);

    // einzelne Box ggfs. in eine Merge-Gruppe aufnehmen
    // (die Merge-Gruppen werden dann spaeter auf einen Schlag abgearbeitet)
    SwTableBox* UpdateTableMergeGroup(WW8_TCell& rCell,
        WW8SelBoxInfo* pActGroup, SwTableBox* pActBox, USHORT nCol  );
    //No copying
    WW8TabDesc(const WW8TabDesc&);
    WW8TabDesc &operator=(const WW8TabDesc&);
public:
    const SwTable* pTable;          // Tabelle
    SwPosition* pParentPos;
    SwFlyFrmFmt* pFlyFmt;
    SfxItemSet aItemSet;
    bool IsValidCell(short nCol) const;

    WW8TabDesc( SwWW8ImplReader* pIoClass, WW8_CP nStartCp );
    bool Ok() const { return bOk; }
    void CreateSwTable();
    void UseSwTable();
    void SetSizePosition(SwFrmFmt* pFrmFmt);
    void TableCellEnd();
    void FinishSwTable();
    void MergeCells();
    short GetMinLeft() const { return nConvertedLeft; }
    ~WW8TabDesc();
    SwPosition *GetPos() { return pTmpPos; }

    const WW8_TCell* GetAktWWCell() const { return pAktWWCell; }
    const short GetAktCol() const { return nAktCol; }
    SwTableBox* GetTableBox() { return pTabBox; }
    // find name of numrule valid for current WW-COL
    const String& GetNumRuleName() const;
    void SetNumRuleName( const String& rName );
};

long SwWW8ImplReader::Read_Ftn(WW8PLCFManResult* pRes)
{
    bool bFtEdOk = false;

    if( nIniFlags & WW8FL_NO_FTN )
        return 0;

    /*
    #84095#
    Ignoring Footnote outside of the normal Text. People will put footnotes
    into field results and field commands.
    */
    if (bIgnoreText ||
        pPaM->GetPoint()->nNode < rDoc.GetNodes().GetEndOfExtras().GetIndex())
    {
        return 0;
    }

    USHORT nType;
    bool bAutoNum = true;
    if( eEDN == pRes->nSprmId )
    {
        nType = MAN_EDN;
        if( pPlcxMan->GetEdn() )
            bAutoNum = 0 != *(short*)pPlcxMan->GetEdn()->GetData();
    }
    else
    {
        nType = MAN_FTN;
        if( pPlcxMan->GetFtn() )
            bAutoNum = 0 != *(short*)pPlcxMan->GetFtn()->GetData();
    }

    WW8PLCFxSaveAll aSave;
    pPlcxMan->SaveAllPLCFx( aSave );
    WW8PLCFMan* pOldPlcxMan = pPlcxMan;

    SwFmtFtn aFtn( eEDN == pRes->nSprmId ) ;            // erzeuge Fussnote
    //rDoc.Insert( *pPaM, aFtn );

    SwTxtNode* pTxt = pPaM->GetNode()->GetTxtNode();
    xub_StrLen nPos = pPaM->GetPoint()->nContent.GetIndex();

    SwTxtAttr* pFN = pTxt->Insert(aFtn, nPos, nPos);

    SwPosition aTmpPos( *pPaM->GetPoint() );    // merke alte Cursorposition

    ASSERT(pFN, "Probleme beim Anlegen des Fussnoten-Textes");
    if( pFN )
    {
        const SwNodeIndex* pSttIdx = ((SwTxtFtn*)pFN)->GetStartNode();
        ASSERT(pSttIdx, "Probleme beim Anlegen des Fussnoten-Textes");

        ((SwTxtFtn*)pFN)->SetSeqNo( rDoc.GetFtnIdxs().Count() );

        bool bOld = bFtnEdn;
        bFtnEdn = true;

        // read content of Ft-/End-Note
        Read_HdFtFtnText( pSttIdx, pRes->nCp2OrIdx, pRes->nMemLen, nType );
        bFtEdOk = true;
        bFtnEdn = bOld;

        // falls keine automatische Numerierung eingestellt ist, so hole
        // das 1. Zeichen aus der Fuss-/End-Note und setze das als Zeichen
        if( !bAutoNum )
        {
            SwNodeIndex& rNIdx = pPaM->GetPoint()->nNode;
            rNIdx = pSttIdx->GetIndex() + 1;
            SwTxtNode* pTNd = rNIdx.GetNode().GetTxtNode();
            if( pTNd )
            {
                String sNo( pTNd->GetTxt().GetChar( 0 ));
                ((SwTxtFtn*)pFN)->SetNumber( 0, &sNo );
                pPaM->GetPoint()->nContent.Assign( pTNd, 0 );
                pPaM->SetMark();
                pPaM->GetMark()->nContent++;
                rDoc.Delete( *pPaM );
                pPaM->DeleteMark();
            }
        }
    }
    *pPaM->GetPoint() = aTmpPos;                // restore Cursor

    pPlcxMan = pOldPlcxMan;             // Attributverwaltung restoren
    pPlcxMan->RestoreAllPLCFx( aSave );

    if( bSymbol )
    {
        pCtrlStck->SetAttr( *pPaM->GetPoint(), RES_CHRATR_FONT );
        bSymbol = false;
    }

    // insert Section to get this Ft-/End-Note at the end of the section,
    // when there is no open section at the moment
       if( bFtEdOk && pLastPgDeskIdx && !pAfterSection)
    {
        const SwNodeIndex aOrgLastPgDeskIdx( *pLastPgDeskIdx );

        (*pLastPgDeskIdx)++;
        SwPosition aSectStart(*pLastPgDeskIdx);
        aSectStart.nContent.Assign(pLastPgDeskIdx->GetNode().GetCntntNode(), 0);

        SwPosition *pTemp = pPaM->GetPoint();
        if (pTableDesc)
            pTemp = pTableDesc->GetPos();

        SwPaM aSectPaM(aSectStart, *pTemp);
        InsertSectionWithWithoutCols( aSectPaM, 0 );

        if (pTableDesc)
            (*pAfterSection)--;
        pPaM->Move( fnMoveBackward );
        DELETEZ( pLastPgDeskIdx );
        // set attributes to correct position
        pCtrlStck->MoveAttrsToNextNode( aOrgLastPgDeskIdx );
    }

    return 1;       // das Fussnotenzeichen ueberlesen!
}

bool SwWW8ImplReader::SearchRowEnd(WW8PLCFx_Cp_FKP* pPap, WW8_CP &rStartCp,
    int nLevel) const
{
    WW8PLCFxDesc aRes;
    aRes.pMemPos = 0;
    aRes.nEndPos = rStartCp;

    while
    (
        (
         (bVer67 && !pWwFib->fComplex) ||
         (pPap->GetPCDIdx() < pPap->GetPCDIMax())
        ) &&
        pPap->HasFkp()
    )
    {
        if (pPap->Where() != LONG_MAX)
        {
            const BYTE* pB = pPap->HasSprm(TabRowSprm(nLevel));
            if (pB && *pB == 1)
            {
                const BYTE *pLevel = 0;
                if ((pLevel = pPap->HasSprm(0x6649)))
                {
                    if (nLevel + 1 == *pLevel)
                        return true;
                }
                else
                {
                    ASSERT(!nLevel || pLevel, "sublevel without level sprm");
                    return true;    // RowEnd found
                }
            }
        }

        aRes.nStartPos = aRes.nEndPos;
        aRes.pMemPos = 0;
        //Seek to our next block of properties
        if (!(pPap->SeekPos(aRes.nStartPos)))
        {
            aRes.nEndPos = LONG_MAX;
            pPap->SetDirty(true);
        }
        pPap->GetSprms(&aRes);
        pPap->SetDirty(false);
        //Update our aRes to get the new starting point of the next properties
        rStartCp = aRes.nEndPos;
    }

    return false;
}

// TestApo() ist die aus ProcessSpecial() herausgeloeste Apo-Abfrage.
// sie wird auch beim Aufbau der Tabellen-Struktur (ww8par6.cxx)
// verwendet.
// Die Parameter rbStartApo, rbStopApo und rpNowStyleApo sind reine
// Rueckgabeparameter
const BYTE* SwWW8ImplReader::TestApo(bool& rbStartApo, bool& rbStopApo,
    WW8FlyPara* &rpNowStyleApo, int nCellLevel, bool bTableRowEnd,
    WW8_TablePos *pTabPos)
{
    const BYTE* pSprm37;
    const BYTE* pSprm29;
    // Frame in Style Definition (word appears to ignore them if inside an
    // text autoshape, e.g. #94418#)
    rpNowStyleApo = 0;
    if (!bTxbxFlySection)
        rpNowStyleApo = pCollA[nAktColl].pWWFly;

    rbStartApo = rbStopApo  = false;

    /*
    ##1140##
    If I have a table and apply a style to one of its frames that should cause
    a paragraph that its applied to it to only exist as a seperate floating
    frame, then the behavour depends on which cell that it has been applied
    to. If its the first cell of a row then the whole table row jumps into the
    new frame, if its not then then the paragraph attributes are applied
    "except" for the floating frame stuff. i.e. its ignored. So if theres a
    table, and we're not in the first cell then we ignore the fact that the
    paragraph style wants to be in a different frame.

    This sort of mindbending inconsistency is surely why frames are deprecated
    in word 97 onwards and hidden away from the user


    #i1532#
    If we are already a table in a frame then we must grab the para properties
    to see if we are still in that frame.
    */

    if (nInTable && InLocalApo() && rpNowStyleApo && (!(pTableDesc &&
        pTableDesc->GetAktCol())))
    {
        pSprm37       = 0;
        pSprm29       = 0;
        rpNowStyleApo = 0;
    }
    else
    {
        pSprm37 = pPlcxMan->HasParaSprm( bVer67 ? 37 : 0x2423 );
        pSprm29 = pPlcxMan->HasParaSprm( bVer67 ? 29 : 0x261B );
    }

    // Is there some frame data here
    bool bNowApo = rpNowStyleApo || pSprm29 || pSprm37 || pTabPos;

    bool bTestAllowed = !bTxbxFlySection && !bTableRowEnd;
    if (bTestAllowed)
    {
        if (nCellLevel == nInTable)
        {
            bTestAllowed =
                (!(nInTable && pTableDesc && pTableDesc->GetAktCol()));
        }
    }

    if (!bTestAllowed)
        return pSprm29;

    rbStartApo = bNowApo && !InEqualApo(nCellLevel); // APO-start
    rbStopApo = InEqualOrHigherApo(nCellLevel) && !bNowApo;  // APO-end

    //If it happens that we are in a table, then if its not the first cell
    //then any attributes that might otherwise cause the contents to jump
    //into another frame don't matter, a table row sticks together as one
    //unit no matter what else happens. So if we are not in a table at
    //all, or if we are in the first cell then test that the last frame
    //data is the same as the current one
    if (bNowApo && !bTableRowEnd && nCellLevel == nInTable && InLocalApo())
    {
        // two bordering eachother
        if (!TestSameApo(pSprm29, rpNowStyleApo, pTabPos))
            rbStopApo = rbStartApo = true;
    }

    return pSprm29;
}

//---------------------------------------------------------------------
//   Hilfroutinen fuer Kapitelnummerierung und Aufzaehlung / Gliederung
//---------------------------------------------------------------------

static void SetBaseAnlv( SwNumFmt* pNum, WW8_ANLV* pAV )
{
    static SvxExtNumType eNumA[8] = { SVX_NUM_ARABIC, SVX_NUM_ROMAN_UPPER, SVX_NUM_ROMAN_LOWER,
        SVX_NUM_CHARS_UPPER_LETTER_N, SVX_NUM_CHARS_LOWER_LETTER_N, SVX_NUM_ARABIC,
        SVX_NUM_ARABIC, SVX_NUM_ARABIC };

    static SvxAdjust eAdjA[4] = { SVX_ADJUST_LEFT,
        SVX_ADJUST_RIGHT, SVX_ADJUST_LEFT, SVX_ADJUST_LEFT };
//          eigentlich folgende 2, aber Writer-UI bietet es nicht an
//      SVX_ADJUST_CENTER, SVX_ADJUST_BLOCKLINE };

    pNum->SetNumberingType(( SVBT8ToByte( pAV->nfc ) < 8 ) ?
                    eNumA[SVBT8ToByte( pAV->nfc ) ] : SVX_NUM_NUMBER_NONE);
//  pNum->bInclUpperLevel = pAV->fPrev;
    pNum->SetIncludeUpperLevels( ( SVBT8ToByte( pAV->aBits1 ) & 0x4 ) >> 2 );
    pNum->SetStart( SVBT16ToShort( pAV->iStartAt ) );
//  pNum->eNumAdjust = eAdjA[pAV->jc];
    pNum->SetNumAdjust( eAdjA[SVBT8ToByte( pAV->aBits1 ) & 0x3] );

    pNum->SetCharTextDistance( SVBT16ToShort( pAV->dxaSpace ) );
    INT16 nIndent = Abs((INT16)SVBT16ToShort( pAV->dxaIndent ));
    if( SVBT8ToByte( pAV->aBits1 ) & 0x08 ){    // fHang
        pNum->SetFirstLineOffset( -nIndent );
        pNum->SetLSpace( nIndent );
        pNum->SetAbsLSpace( nIndent );
    }else{
        pNum->SetCharTextDistance( nIndent );       // Breite der Nummer fehlt
    }
    if( SVBT8ToByte( pAV->nfc ) == 5 || SVBT8ToByte( pAV->nfc ) == 7 )
    {
        String sP( pNum->GetSuffix() );
        sP.Insert( '.', 0 );
        pNum->SetSuffix( sP );  // Ordinalzahlen
    }
}

void SwWW8ImplReader::SetAnlvStrings(SwNumFmt* pNum, WW8_ANLV* pAV,
    const BYTE* pTxt, bool bOutline)
{
    bool bInsert = false;                       // Default
    CharSet eCharSet = eStructCharSet;

    const WW8_FFN* pF = pFonts->GetFont(SVBT16ToShort(pAV->ftc)); // FontInfo
    bool bListSymbol = pF && ( pF->chs == 2 );      // Symbol/WingDings/...

    String sTxt;
    if (bVer67)
    {
        sTxt = String( (sal_Char*)pTxt,  SVBT8ToByte( pAV->cbTextBefore )
                                 + SVBT8ToByte( pAV->cbTextAfter  ), eCharSet );
    }
    else
    {
        for(xub_StrLen i = SVBT8ToByte(pAV->cbTextBefore);
            i < SVBT8ToByte(pAV->cbTextAfter); ++i, pTxt += 2)
        {
            sTxt.Append(SVBT16ToShort(*(SVBT16*)pTxt));
        }
    }

    if( bOutline )
    {                             // Gliederung
        if( !pNum->GetIncludeUpperLevels()          // es sind  <= 1 Nummern anzuzeigen
            || pNum->GetNumberingType() == SVX_NUM_NUMBER_NONE ){   // oder dieser Level hat keine
                                                // eigenen Ziffern
            bInsert = true;                     // -> dann uebernehme Zeichen

            // replace by simple Bullet ?
            if( bListSymbol )
                //JP 14.08.96: cBulletChar benutzen, damit auf dem MAC
                //              richtig gemappt wird
                sTxt.Fill(  SVBT8ToByte( pAV->cbTextBefore )
                          + SVBT8ToByte( pAV->cbTextAfter  ), cBulletChar );
            }
    }
    else
    {                                       // Nummerierung / Aufzaehlung
        bInsert = true;
//      if( SVBT16ToShort( pAV->ftc ) == 1
//          || SVBT16ToShort( pAV->ftc ) == 3 ){    // Symbol / WingDings
        if( bListSymbol )
        {
            FontFamily eFamily;
            String aName;
            FontPitch ePitch;

            if( GetFontParams( SVBT16ToShort( pAV->ftc ), eFamily, aName,
                                ePitch, eCharSet ) ){
//              USHORT nSiz = ( SVBT16ToShort( pAV->hps ) ) ?
//                          SVBT16ToShort( pAV->hps ) : 24; // Groesse in 1/2 Pt
//                      darf nach JP nicht gesetzt werden, da immer die Size
//                      genommen wird, die am ZeilenAnfang benutzt wird
                Font aFont;
                aFont.SetName( aName );
                aFont.SetFamily( eFamily );
//              aFont.SetPitch( ePitch );       // darf nach JP nicht
                aFont.SetCharSet( eCharSet );
                pNum->SetNumberingType(SVX_NUM_CHAR_SPECIAL);
//              if( pAV->ico )      // geht in UI und SWG-Writer/Reader nicht
//                  aFont.SetColor( Color( GetCol( pAV->ico ) ) );
                pNum->SetBulletFont( &aFont );

                // take only the very first character
                if( pAV->cbTextBefore || pAV->cbTextAfter)
                    pNum->SetBulletChar( sTxt.GetChar( 0 ) );
                else
                    pNum->SetBulletChar( 0x2190 );
            }
        }
    }
    if( bInsert )
    {
        if( pAV->cbTextBefore )
        {
            String sP( sTxt.Copy( 0, SVBT8ToByte( pAV->cbTextBefore ) ) );
            pNum->SetPrefix( sP );
        }
        if( SVBT8ToByte( pAV->cbTextAfter ) )
        {
            String sP( pNum->GetSuffix() );
            sP.Insert( sTxt.Copy( SVBT8ToByte( pAV->cbTextBefore ),
                                  SVBT8ToByte( pAV->cbTextAfter  ) ) );
            pNum->SetSuffix( sP );
        }
// Die Zeichen vor und hinter mehreren Ziffern koennen leider nicht uebernommen
// werden, da sie der Writer ganz anders behandelt und das Ergebnis i.A.
// schlechter als ohne waere.
    }
}

// SetAnld bekommt einen WW-ANLD-Descriptor und einen Level und modifiziert
// die durch pNumR anggebeben NumRules. Wird benutzt fuer alles ausser
// Gliederung im Text
void SwWW8ImplReader::SetAnld(SwNumRule* pNumR, WW8_ANLD* pAD, BYTE nSwLevel,
    bool bOutLine)
{
    SwNumFmt aNF;
    if( pAD )
    {                                   // Es gibt einen Anld-Sprm
        bAktAND_fNumberAcross = 0 != SVBT8ToByte( pAD->fNumberAcross );
        WW8_ANLV* pAV = &pAD->eAnlv;
        SetBaseAnlv( &aNF, pAV );       // Setze Basis-Format
        SetAnlvStrings( &aNF, pAV, pAD->rgchAnld, bOutLine );// und Rest
    }
    pNumR->Set( nSwLevel, aNF );
}



//-------------------------------------------------------
//          Kapitelnummerierung und Kapitelbullets
//-------------------------------------------------------
// Kapitelnummerierung findet in Styledefinionen statt. Sprm 13 gibt den Level
// an, Sprm 12 den Inhalt

SwNumRule* SwWW8ImplReader::GetStyRule()
{
    if( pStyles->pStyRule )         // Bullet-Style bereits vorhanden
        return pStyles->pStyRule;

    const String aBaseName(CREATE_CONST_ASC( "WW8StyleNum" ));
    const String aName( rDoc.GetUniqueNumRuleName( &aBaseName, false) );

    USHORT nRul = rDoc.MakeNumRule( aName );
    pStyles->pStyRule = rDoc.GetNumRuleTbl()[nRul];
    // Auto == false-> Nummerierungsvorlage
    pStyles->pStyRule->SetAutoRule(false);

    return pStyles->pStyRule;
}

// Sprm 13
void SwWW8ImplReader::Read_ANLevelNo( USHORT, const BYTE* pData, short nLen )
{
    nSwNumLevel = 0xff; // Default: ungueltig

    if( nLen <= 0 )
        return;

    // StyleDef ?
    if( pAktColl )
    {
        // nur fuer SwTxtFmtColl, nicht CharFmt
        // WW: 0 = no Numbering
        if (pCollA[nAktColl].bColl && *pData)
        {
            // Bereich WW:1..9 -> SW:0..8 keine Aufzaehlung / Nummerierung

            if (*pData <= MAXLEVEL && *pData <= 9)
            {
                nSwNumLevel = *pData - 1;
                if (!bNoAttrImport)
                    ((SwTxtFmtColl*)pAktColl)->SetOutlineLevel( nSwNumLevel );
                    // Bei WW-NoNumbering koennte auch NO_NUMBERING gesetzt
                    // werden. ( Bei normaler Nummerierung muss NO_NUM gesetzt
                    // werden: NO_NUM : Nummerierungs-Pause,
                    // NO_NUMBERING : ueberhaupt keine Nummerierung )

            }
            else if( *pData == 10 || *pData == 11 )
            {
                // Typ merken, der Rest geschieht bei Sprm 12
                pStyles->nWwNumLevel = *pData;
            }
        }
    }
    else
    {
        //Not StyleDef
        if (!bAnl && !(nIniFlags & WW8FL_NO_NUMRULE))
            StartAnl(pData);        // Anfang der Gliederung / Aufzaehlung
        NextAnlLine(pData);
    }
}

void SwWW8ImplReader::Read_ANLevelDesc( USHORT, const BYTE* pData, short nLen ) // Sprm 12
{
    if( !pAktColl || nLen <= 0                  // nur bei Styledef
        || !pCollA[nAktColl].bColl              // CharFmt -> ignorieren
        || ( nIniFlags & WW8FL_NO_OUTLINE ) ){
        nSwNumLevel = 0xff;
        return;
    }
    if( nSwNumLevel <= MAXLEVEL         // Bereich WW:1..9 -> SW:0..8
        && nSwNumLevel <= 9 ){      // keine Aufzaehlung / Nummerierung

                                        // Falls bereits direkt oder durch
                                        // Vererbung NumruleItems gesetzt sind,
                                        // dann jetzt ausschalten #56163
        pAktColl->SetAttr( SwNumRuleItem() );

        String aName(CREATE_CONST_ASC( "Outline" ));
        SwNumRule aNR( rDoc.GetUniqueNumRuleName(&aName), OUTLINE_RULE );
        aNR = *rDoc.GetOutlineNumRule();

        SetAnld(&aNR, (WW8_ANLD*)pData, nSwNumLevel, true);

            // fehlende Level muessen nicht aufgefuellt werden

        rDoc.SetOutlineNumRule( aNR );
    }else if( pStyles->nWwNumLevel == 10 || pStyles->nWwNumLevel == 11 ){
        SwNumRule* pNR = GetStyRule();
        SetAnld(pNR, (WW8_ANLD*)pData, 0, false);
        pAktColl->SetAttr( SwNumRuleItem( pNR->GetName() ) );
        pCollA[nAktColl].bHasStyNumRule = true;
    }
}

//-----------------------------------------
//      Nummerierung / Aufzaehlung
//-----------------------------------------

// SetNumOlst() traegt die Numrules fuer diese Zeile ins SwNumFmt ein
// ( nur fuer Gliederungen im Text; Aufzaehlungen / Nummerierungen laufen
// ueber ANLDs )
// dabei wird die Info aus dem OLST geholt und nicht aus dem ANLD ( s.u. )
void SwWW8ImplReader::SetNumOlst( SwNumRule* pNumR, WW8_OLST* pO, BYTE nSwLevel )
{
    SwNumFmt aNF;
    WW8_ANLV* pAV = &pO->rganlv[nSwLevel];
    SetBaseAnlv( &aNF, pAV );               // Setze Basis-Format
                                            // ... und nun die Strings
    int i, nTxtOfs = 0;
    register WW8_ANLV* pAV1;                 // suche String-Positionen
    for( i = 0, pAV1 = pO->rganlv; i < nSwLevel; i++, pAV1++ ){
        nTxtOfs += SVBT8ToByte( pAV1->cbTextBefore )
                    + SVBT8ToByte( pAV1->cbTextAfter );
    }

    if (!bVer67)
        nTxtOfs *= 2;
    SetAnlvStrings( &aNF, pAV, pO->rgch + nTxtOfs, true); // und rein
    pNumR->Set( nSwLevel, aNF );
}




// der OLST kommt am Anfang jeder Section, die Gliederungen enthaelt. Die ANLDs,
// die an jeder Gliederungszeile haengen, enthalten nur Stuss, also werden die
// OLSTs waehrend der Section gemerkt, damit die Informationen beim Auftreten
// von Gliederungsabsaetzen zugreifbar ist.
void SwWW8ImplReader::Read_OLST( USHORT, const BYTE* pData, short nLen )
{
    if( nIniFlags & WW8FL_NO_NUMRULE )
        return;
    if( nLen <= 0 ){
        DELETEZ( pNumOlst );
        return;
    }
    if( pNumOlst )
        delete pNumOlst;                    // nur sicherheitshalber
    pNumOlst = new WW8_OLST;
    if( nLen < sizeof( WW8_OLST ) )         // auffuellen, falls zu kurz
        memset( pNumOlst, 0, sizeof( *pNumOlst ) );
    *pNumOlst = *(WW8_OLST*)pData;
}

WW8LvlType GetNumType(BYTE nWwLevelNo)
{
    WW8LvlType nRet = WW8_None;
    if( nWwLevelNo == 12 )
       nRet = WW8_Pause;
    else if( nWwLevelNo == 10 )
       nRet = WW8_Numbering;
    else if( nWwLevelNo == 11 )
       nRet = WW8_Sequence;
    else if( nWwLevelNo > 0 && nWwLevelNo <= 9 )
       nRet = WW8_Outline;
    return nRet;
}

// StartAnl wird am Anfang eines Zeilenbereichs gerufen,
//  der Gliederung / Nummerierung / Aufzaehlung enthaelt
#define MAX_ANLV_NUM 12
void SwWW8ImplReader::StartAnl( const BYTE* pSprm13 )
{
    bAktAND_fNumberAcross = false;

    BYTE nT = GetNumType( *pSprm13 );
    if( nT == WW8_Pause || nT == WW8_None )
        return;

    nWwNumType = nT;

    // check for COL numbering:
    const BYTE* pS12 = 0;// sprmAnld
    String sNumRule;
    if( pTableDesc )
    {
        sNumRule = pTableDesc->GetNumRuleName();
        if( sNumRule.Len() )
        {
            pNumRule = rDoc.FindNumRulePtr( sNumRule );
            if( !pNumRule )
                sNumRule.Erase();
            else
            {
                // this is ROW numbering ?
                pS12 = pPlcxMan->HasParaSprm(bVer67 ? 12 : 0xC63E); // sprmAnld
                if (pS12 && 0 != SVBT8ToByte(((WW8_ANLD*)pS12)->fNumberAcross))
                    sNumRule.Erase();
            }
        }
    }

    if (!sNumRule.Len() && pCollA[nAktColl].bHasStyNumRule)
    {
        sNumRule = pCollA[nAktColl].pFmt->GetNumRule().GetValue();
        pNumRule = rDoc.FindNumRulePtr(sNumRule);
        if (!pNumRule)
            sNumRule.Erase();
    }

    if (!sNumRule.Len())
    {
        if (!pNumRule)
            pNumRule = rDoc.GetNumRuleTbl()[rDoc.MakeNumRule(sNumRule)];
        if( pTableDesc )
        {
            if (!pS12)
                pS12 = pPlcxMan->HasParaSprm(bVer67 ? 12 : 0xC63E); // sprmAnld
            if (!pS12 || !SVBT8ToByte( ((WW8_ANLD*)pS12)->fNumberAcross))
                pTableDesc->SetNumRuleName( pNumRule->GetName() );
        }
    }

    bAnl = true;

    // NumRules ueber Stack setzen
    pCtrlStck->NewAttr(*pPaM->GetPoint(),
            SfxStringItem(RES_FLTR_NUMRULE, pNumRule->GetName()));
}


// NextAnlLine() wird fuer jede Zeile einer
// Gliederung / Nummerierung / Aufzaehlung einmal gerufen
void SwWW8ImplReader::NextAnlLine(const BYTE* pSprm13)
{
    if (!bAnl)
        return;

    // pNd->UpdateNum ohne Regelwerk gibt GPF spaetestens beim Speichern als
    // sdw3

    // WW:10 = Nummerierung -> SW:0 & WW:11 = Auffzaehlung -> SW:0
    if (*pSprm13 == 10 || *pSprm13 == 11)
    {
        nSwNumLevel = 0;
        if (!pNumRule->GetNumFmt(nSwNumLevel))
        {
            // noch nicht definiert
            // sprmAnld o. 0
            const BYTE* pS12 = pPlcxMan->HasParaSprm(bVer67 ? 12 : 0xC63E);
            SetAnld(pNumRule, (WW8_ANLD*)pS12, nSwNumLevel, false);
        }
    }
    else if (*pSprm13 <= MAXLEVEL)          // Bereich WW:1..9 -> SW:0..8
    {
        nSwNumLevel = *pSprm13 - 1;             // Gliederung
        // noch nicht definiert
        if (!pNumRule->GetNumFmt(nSwNumLevel))
        {
            if (pNumOlst)                       // es gab ein OLST
                SetNumOlst(pNumRule, pNumOlst , nSwNumLevel);
            else                                // kein Olst, nimm Anld
            {
                // sprmAnld
                const BYTE* pS12 = pPlcxMan->HasParaSprm(bVer67 ? 12 : 0xC63E);
                SetAnld(pNumRule, (WW8_ANLD*)pS12, nSwNumLevel, false);
            }
        }
    }
    else
        nSwNumLevel = 0xff;                 // keine Nummer

    BYTE nLevel = (nSwNumLevel < MAXLEVEL) ? nSwNumLevel : NO_NUM;
    SwNodeNum aNum(nLevel);
    SwTxtNode* pNd = pPaM->GetNode()->GetTxtNode();
    pNd->UpdateNum(aNum);
}

// StopAnl() wird am Ende des Zeilenbereiches gerufen
void SwWW8ImplReader::StopAnl(bool bGoBack)
{
    if( bGoBack )
    {
        SwPosition aTmpPos( *pPaM->GetPoint() );    // eine Zeile zu spaet
        // gehe zurueck
        pPaM->Move( fnMoveBackward, fnGoCntnt );
        pCtrlStck->SetAttr( *pPaM->GetPoint(), RES_FLTR_NUMRULE ); // Setze NumRules in Stack
        // restore Pam
        *pPaM->GetPoint() = aTmpPos;
    }
    else
        pCtrlStck->SetAttr( *pPaM->GetPoint(), RES_FLTR_NUMRULE ); // Setze NumRules in Stack

    nSwNumLevel = 0xff;
    nWwNumType = WW8_None;
    bAnl = false;
}

WW8TabBandDesc::WW8TabBandDesc( WW8TabBandDesc& rBand )
{
    *this = rBand;
    if( rBand.pTCs )
    {
        pTCs = new WW8_TCell[nWwCols];
        memcpy( pTCs, rBand.pTCs, nWwCols * sizeof( WW8_TCell ) );
    }
    if( rBand.pSHDs )
    {
        pSHDs = new WW8_SHD[nWwCols];
        memcpy( pSHDs, rBand.pSHDs, nWwCols * sizeof( WW8_SHD ) );
    }
    if( rBand.pNewSHDs )
    {
        pNewSHDs = new sal_uInt32[nWwCols];
        memcpy(pNewSHDs, rBand.pNewSHDs, nWwCols * sizeof(sal_uInt32));
    }
    memcpy(aDefBrcs, rBand.aDefBrcs, sizeof(aDefBrcs));
}

// ReadDef liest die Zellenpositionen und ggfs die Umrandungen eines Bandes ein
void WW8TabBandDesc::ReadDef(bool bVer67, const BYTE* pS)
{
    if (!bVer67)
        pS++;

    short nLen = (INT16)SVBT16ToShort( pS - 2 ); // nicht schoen
    BYTE nCols = *pS;                       // Anzahl der Zellen
    short nOldCols = nWwCols;

    if( nCols > MAX_COL )
        return;

    nWwCols = nCols;

    const BYTE* pT = &pS[1];
    nLen --;
    int i;
    for(i=0; i<=nCols; i++, pT+=2 )
        nCenter[i] = (INT16)SVBT16ToShort( pT );    // X-Raender
    nLen -= 2 * ( nCols + 1 );
    if( nCols != nOldCols ) // andere Spaltenzahl
    {
        delete[] pTCs, pTCs = 0;
        delete[] pSHDs, pSHDs = 0;
        delete[] pNewSHDs, pNewSHDs = 0;
    }

    short nFileCols = nLen / ( bVer67 ? 10 : 20 );  // wirklich abgespeichert

    if (!pTCs && nCols)
    {
        // lege leere TCs an
        pTCs = new WW8_TCell[nCols];
        setcelldefaults(pTCs,nCols);
    }

    if( nFileCols )
    {
        // lies TCs ein

        /*
            Achtung: ab Ver8 ist ein reserve-ushort je TC eingefuegt und auch
                     der Border-Code ist doppelt so gross, daher ist hier
                             kein simples kopieren moeglich,
                             d.h.: pTCs[i] = *pTc;  geht leider nicht.
            ---
            Vorteil: Arbeitstruktur ist jetzt viel bequemer zu handhaben!
        */
        WW8_TCell* pAktTC  = pTCs;
        if( bVer67 )
        {
            WW8_TCellVer6* pTc = (WW8_TCellVer6*)pT;
            for(i=0; i<nFileCols; i++, ++pAktTC,++pTc)
            {
                if( i < nFileCols )
                {               // TC aus File ?
                    BYTE aBits1 = SVBT8ToByte( pTc->aBits1Ver6 );
                    pAktTC->bFirstMerged    = ( ( aBits1 & 0x01 ) != 0 );
                    pAktTC->bMerged     = ( ( aBits1 & 0x02 ) != 0 );
                    memcpy( pAktTC->rgbrc[ WW8_TOP      ].aBits1,
                                    pTc->rgbrcVer6[ WW8_TOP     ].aBits1, sizeof( SVBT16 ) );
                    memcpy( pAktTC->rgbrc[ WW8_LEFT     ].aBits1,
                                    pTc->rgbrcVer6[ WW8_LEFT    ].aBits1, sizeof( SVBT16 ) );
                    memcpy( pAktTC->rgbrc[ WW8_BOT      ].aBits1,
                                    pTc->rgbrcVer6[ WW8_BOT     ].aBits1, sizeof( SVBT16 ) );
                    memcpy( pAktTC->rgbrc[ WW8_RIGHT    ].aBits1,
                                    pTc->rgbrcVer6[ WW8_RIGHT   ].aBits1, sizeof( SVBT16 ) );
                    if(    ( pAktTC->bMerged )
                            && ( i > 0             ) )
                    {
                        // Cell gemerged -> merken
                        //bWWMergedVer6[i] = true;
                        memcpy( pTCs[i-1].rgbrc[ WW8_RIGHT ].aBits1,
                                pTc->rgbrcVer6[  WW8_RIGHT ].aBits1, sizeof( SVBT16 ) );
                            // right Border in vorige Zelle uebernehmen
                            // Hier darf bExist nicht auf false gesetzt werden, da WW
                            // in den Textboxen diese Zellen nicht mitzaehlt....
                    }
                }
            }
        }
        else
        {
            WW8_TCellVer8* pTc = (WW8_TCellVer8*)pT;
            for(int i=0; i<nFileCols; i++, ++pAktTC, ++pTc )
            {
                UINT16 aBits1 = SVBT16ToShort( pTc->aBits1Ver8 );
                pAktTC->bFirstMerged    = ( ( aBits1 & 0x0001 ) != 0 );
                pAktTC->bMerged         = ( ( aBits1 & 0x0002 ) != 0 );
                pAktTC->bVertical       = ( ( aBits1 & 0x0004 ) != 0 );
                pAktTC->bBackward       = ( ( aBits1 & 0x0008 ) != 0 );
                pAktTC->bRotateFont     = ( ( aBits1 & 0x0010 ) != 0 );
                pAktTC->bVertMerge      = ( ( aBits1 & 0x0020 ) != 0 );
                pAktTC->bVertRestart    = ( ( aBits1 & 0x0040 ) != 0 );
                pAktTC->nVertAlign      = ( ( aBits1 & 0x0180 ) >> 7 );
                // am Rande: im aBits1 verstecken sich noch 7 Reserve-Bits,
                //           anschliessend folgen noch 16 weitere Reserve-Bits

                // In Version 8 koennen wir alle Bordercodes auf einmal kopieren!
                memcpy( pAktTC->rgbrc, pTc->rgbrcVer8, 4 * sizeof( WW8_BRC ) );
            }
        }
    }
}

void WW8TabBandDesc::ProcessSprmTSetBRC(bool bVer67, const BYTE* pParamsTSetBRC)
{
    if( pParamsTSetBRC && pTCs ) // set one or more cell border(s)
    {
        BYTE nitcFirst= pParamsTSetBRC[0];// first col to be changed
        BYTE nitcLim  = pParamsTSetBRC[1];// (last col to be changed)+1
        BYTE nFlag    = *(pParamsTSetBRC+2);

        bool bChangeRight  = (nFlag & 0x08) ? true : false;
        bool bChangeBottom = (nFlag & 0x04) ? true : false;
        bool bChangeLeft   = (nFlag & 0x02) ? true : false;
        bool bChangeTop    = (nFlag & 0x01) ? true : false;

        WW8_TCell* pAktTC  = pTCs + nitcFirst;
        if( bVer67 )
        {
            WW8_BRCVer6* pBRC = (WW8_BRCVer6*)(pParamsTSetBRC+3);

            for( int i = nitcFirst; i < nitcLim; i++, ++pAktTC )
            {
                if( bChangeTop )
                    memcpy( pAktTC->rgbrc[ WW8_TOP  ].aBits1,
                            pBRC->aBits1,
                            sizeof( SVBT16 ) );
                if( bChangeLeft )
                    memcpy( pAktTC->rgbrc[ WW8_LEFT ].aBits1,
                            pBRC->aBits1,
                            sizeof( SVBT16 ) );
                if( bChangeBottom )
                    memcpy( pAktTC->rgbrc[ WW8_BOT  ].aBits1,
                            pBRC->aBits1,
                            sizeof( SVBT16 ) );
                if( bChangeRight )
                    memcpy( pAktTC->rgbrc[ WW8_RIGHT].aBits1,
                            pBRC->aBits1,
                            sizeof( SVBT16 ) );
            }
        }
        else
        {
            WW8_BRC* pBRC = (WW8_BRC*)(pParamsTSetBRC+3);

            for( int i = nitcFirst; i < nitcLim; i++, ++pAktTC )
            {
                if( bChangeTop )
                    memcpy( pAktTC->rgbrc[ WW8_TOP  ].aBits1,
                            pBRC->aBits1,
                            sizeof( WW8_BRC ) );
                if( bChangeLeft )
                    memcpy( pAktTC->rgbrc[ WW8_LEFT ].aBits1,
                            pBRC->aBits1,
                            sizeof( WW8_BRC ) );
                if( bChangeBottom )
                    memcpy( pAktTC->rgbrc[ WW8_BOT  ].aBits1,
                            pBRC->aBits1,
                            sizeof( WW8_BRC ) );
                if( bChangeRight )
                    memcpy( pAktTC->rgbrc[ WW8_RIGHT].aBits1,
                            pBRC->aBits1,
                            sizeof( WW8_BRC ) );
            }



        }
    }
}


void WW8TabBandDesc::ProcessSprmTDxaCol(const BYTE* pParamsTDxaCol)
{
    // sprmTDxaCol (opcode 0x7623) changes the width of cells
    // whose index is within a certain range to be a certain value.

    if( nWwCols && pParamsTDxaCol ) // set one or more cell length(s)
    {
        BYTE nitcFirst= pParamsTDxaCol[0]; // first col to be changed
        BYTE nitcLim  = pParamsTDxaCol[1]; // (last col to be changed)+1
        short nDxaCol = (INT16)SVBT16ToShort( pParamsTDxaCol + 2 );
        short nOrgWidth;
        short nDelta;

        for( int i = nitcFirst; (i < nitcLim) && (i < nWwCols); i++ )
        {
            nOrgWidth  = nCenter[i+1] - nCenter[i];
            nDelta     = nDxaCol - nOrgWidth;
            for( int j = i+1; j <= nWwCols; j++ )
            {
                nCenter[j] += nDelta;
            }
        }
    }
}

void WW8TabBandDesc::ProcessSprmTInsert(const BYTE* pParamsTInsert)
{
    if( nWwCols && pParamsTInsert )        // set one or more cell length(s)
    {
        BYTE nitcInsert = pParamsTInsert[0]; // position at which to insert
        BYTE nctc  = pParamsTInsert[1];      // number of cells
        USHORT ndxaCol = SVBT16ToShort( pParamsTInsert+2 );

        short nNewWwCols;
        if (nitcInsert > nWwCols)
            nNewWwCols = nitcInsert+nctc;
        else
            nNewWwCols = nWwCols+nctc;

        WW8_TCell *pTC2s = new WW8_TCell[nNewWwCols];
        setcelldefaults(pTC2s, nNewWwCols);

        if (pTCs)
        {
            memcpy( pTC2s, pTCs, nWwCols * sizeof( WW8_TCell ) );
            delete[] pTCs;
        }
        pTCs = pTC2s;

        //If we have to move some cells
        if (nitcInsert <= nWwCols)
        {
            // adjust the left x-position of the dummy at the very end
            nCenter[nWwCols + nctc] = nCenter[nWwCols]+nctc*ndxaCol;
            for( int i = nWwCols-1; i >= nitcInsert; i--)
            {
                // adjust the left x-position
                nCenter[i + nctc] = nCenter[i]+nctc*ndxaCol;

                // adjust the cell's borders
                pTCs[i + nctc] = pTCs[i];
            }
        }

        //if itcMac is larger than full size, fill in missing ones first
        for( int i = nWwCols; i > nitcInsert+nWwCols; i--)
            nCenter[i] = i ? (nCenter[i - 1]+ndxaCol) : 0;

        //now add in our new cells
        for( int j = 0;j < nctc; j++)
            nCenter[j + nitcInsert] = (j + nitcInsert) ? (nCenter[j + nitcInsert -1]+ndxaCol) : 0;

        nWwCols = nNewWwCols;
    }
}

void WW8TabBandDesc::ProcessSpacing(const BYTE* pParams)
{
    BYTE nLen = pParams ? *(pParams - 1) : 0;
    ASSERT(nLen == 6, "Unexpected spacing len");
    if (nLen != 6)
        return;
    mbHasSpacing=true;
    BYTE nWhichCell = *pParams++;
    ASSERT(nWhichCell == 0, "Expected cell to be 0!");
    *pParams++; //unknown byte

    BYTE nSideBits = *pParams++;
    ASSERT(nSideBits < 0x10, "Unexpected value for nSideBits");
    *pParams++; //unknown byte
    USHORT nValue =  SVBT16ToShort( pParams );
    for (int i = wwTOP; i <= wwRIGHT; i++)
    {
        switch (nSideBits & (1 << i))
        {
            case 1 << wwTOP:
                mnDefaultTop = nValue;
                break;
            case 1 << wwLEFT:
                mnDefaultLeft = nValue;
                break;
            case 1 << wwBOTTOM:
                mnDefaultBottom = nValue;
                break;
            case 1 << wwRIGHT:
                mnDefaultRight = nValue;
                break;
            case 0:
                break;
            default:
                ASSERT(!this, "Impossible");
                break;
        }
    }
}

void WW8TabBandDesc::ProcessSpecificSpacing(const BYTE* pParams)
{
    BYTE nLen = pParams ? *(pParams - 1) : 0;
    ASSERT(nLen == 6, "Unexpected spacing len");
    if (nLen != 6)
        return;
    BYTE nWhichCell = *pParams++;
    ASSERT(nWhichCell < nWwCols, "Cell out of range in spacings");
    if (nWhichCell >= nWwCols)
        return;

    *pParams++; //unknown byte
    BYTE nSideBits = *pParams++;
    ASSERT(nSideBits < 0x10, "Unexpected value for nSideBits");
    nOverrideSpacing[nWhichCell] |= nSideBits;

    ASSERT(nOverrideSpacing[nWhichCell] < 0x10,
        "Unexpected value for nSideBits");
    BYTE nUnknown2 = *pParams++;
    ASSERT(nUnknown2 == 0x3, "Unexpected value for spacing2");
    USHORT nValue =  SVBT16ToShort( pParams );

    for (int i=0; i < 4; i++)
    {
        if (nSideBits & (1 << i))
            nOverrideValues[nWhichCell][i] = nValue;
    }
}

void WW8TabBandDesc::ProcessSprmTDelete(const BYTE* pParamsTDelete)
{
    if( nWwCols && pParamsTDelete )        // set one or more cell length(s)
    {
        BYTE nitcFirst= pParamsTDelete[0]; // first col to be deleted
        BYTE nitcLim  = pParamsTDelete[1]; // (last col to be deleted)+1

        BYTE nShlCnt  = nWwCols - nitcLim; // count of cells to be shifted


        WW8_TCell* pAktTC  = pTCs + nitcFirst;
        int i = 0;
        for( ; i < nShlCnt; i++, ++pAktTC )
        {
            // adjust the left x-position
            nCenter[nitcFirst + i] = nCenter[nitcLim + i];

            // adjust the cell's borders
            *pAktTC = pTCs[ nitcLim + i];
        }
        // adjust the left x-position of the dummy at the very end
        nCenter[nitcFirst + i] = nCenter[nitcLim + i];

        nWwCols -= (nitcLim - nitcFirst);
    }
}

// ReadShd liest ggfs die Hintergrundfarben einer Zeile ein.
// Es muss vorher ReadDef aufgerufen worden sein
void WW8TabBandDesc::ReadShd(const BYTE* pS )
{
    BYTE nLen = pS ? *(pS - 1) : 0;
    if( !nLen )
        return;

    if( !pSHDs )
    {
        pSHDs = new WW8_SHD[nWwCols];
        memset( pSHDs, 0, nWwCols * sizeof( WW8_SHD ) );
    }

    short nAnz = nLen >> 1;
    if (nAnz > nWwCols)
        nAnz = nWwCols;

    SVBT16* pShd;
    int i;
    for(i=0, pShd = (SVBT16*)pS; i<nAnz; i++, pShd++ )
        pSHDs[i].SetWWValue( *pShd );
}

void WW8TabBandDesc::ReadNewShd(const BYTE* pS, bool bVer67)
{
    BYTE nLen = pS ? *(pS - 1) : 0;
    if (!nLen)
        return;

    if (!pNewSHDs)
        pNewSHDs = new sal_uInt32[nWwCols];

    short nAnz = nLen / 10; //10 bytes each
    if (nAnz > nWwCols)
        nAnz = nWwCols;

    int i=0;
    while (i < nAnz)
        pNewSHDs[i++] = SwWW8ImplReader::ExtractColour(pS, bVer67);

    while (i < nWwCols)
        pNewSHDs[i++] = COL_AUTO;
}

void WW8TabBandDesc::setcelldefaults(WW8_TCell *pCells, short nCols)
{
    memset( pCells, 0, nCols * sizeof( WW8_TCell ) );
#if 0
    //Theres the possibility that it should be something like this
    for (int i=0;i<nCols;++i)
    {
        ShortToSVBT16(0xFFFF,pCells[i].rgbrc[0].aBits1);
        ShortToSVBT16(0xFFFF,pCells[i].rgbrc[0].aBits2);

        ShortToSVBT16(0xFFFF,pCells[i].rgbrc[1].aBits1);
        ShortToSVBT16(0xFFFF,pCells[i].rgbrc[1].aBits2);

        ShortToSVBT16(0xFFFF,pCells[i].rgbrc[2].aBits1);
        ShortToSVBT16(0xFFFF,pCells[i].rgbrc[2].aBits2);

        ShortToSVBT16(0xFFFF,pCells[i].rgbrc[3].aBits1);
        ShortToSVBT16(0xFFFF,pCells[i].rgbrc[3].aBits2);
    }
#endif
}

const BYTE *HasTabCellSprm(WW8PLCFx_Cp_FKP* pPap, bool bVer67)
{
    const BYTE *pParams;
    if (bVer67)
        pParams = pPap->HasSprm(24);
    else
    {
        if (!(pParams = pPap->HasSprm(0x244B)))
            pParams = pPap->HasSprm(0x2416);
    }
    return pParams;
}

WW8TabDesc::WW8TabDesc(SwWW8ImplReader* pIoClass, WW8_CP nStartCp)
    : pIo(pIoClass), pFirstBand(0), pActBand(0), pTmpPos(0), pTblNd(0),
    pTabLines(0), pTabLine(0), pTabBoxes(0), pTabBox(0), pMergeGroups(0),
    pAktWWCell(0), nRows(0), nDefaultSwCols(0), nBands(0), nMinLeft(0),
    nConvertedLeft(0), nMaxRight(0), nSwWidth(0), bOk(true), bHeader(false),
    bClaimLineFmt(false), eOri(HORI_NONE), bIsBiDi(false), nAktRow(0),
    nAktBandRow(0), nAktCol(0), pTable(0), pParentPos(0), pFlyFmt(0),
    aItemSet(pIo->rDoc.GetAttrPool(),RES_FRMATR_BEGIN,RES_FRMATR_END-1)
{
    pIo->bAktAND_fNumberAcross = false;

    static const SwHoriOrient aOriArr[] =
    {
        HORI_LEFT, HORI_CENTER, HORI_RIGHT, HORI_CENTER
    };

    bool bVer67   = pIo->bVer67;
    bool bComplex = pIo->pWwFib->fComplex;
    WW8_TablePos aTabPos;

    WW8PLCFxSave1 aSave;
    pIo->pPlcxMan->GetPap()->Save( aSave );

    WW8PLCFx_Cp_FKP* pPap = pIo->pPlcxMan->GetPapPLCF();

    eOri = HORI_LEFT;

       WW8TabBandDesc* pNewBand = new WW8TabBandDesc;

    wwSprmParser aSprmParser(pIo->GetFib().nVersion);

    // process pPap until end of table found
    do
    {
        short nTabeDxaNew      = SHRT_MAX;
        bool bTabRowJustRead   = false;
        const BYTE* pShadeSprm = 0;
        const BYTE* pNewShadeSprm = 0;
        WW8_TablePos *pTabPos  = 0;

        // Suche Ende einer TabZeile
        if(!(pIo->SearchRowEnd(pPap, nStartCp, pIo->nInTable)))
        {
            bOk = false;
            break;
        }

        // Get the SPRM chains:
        // first from PAP and then from PCD (of the Piece Table)
        WW8PLCFxDesc aDesc;
        pPap->GetSprms( &aDesc );
        WW8SprmIter aSprmIter(aDesc.pMemPos, aDesc.nSprmsLen, aSprmParser);

        const BYTE* pParams = aSprmIter.GetAktParams();
        for( int nLoop = 0; nLoop < 2; ++nLoop )
        {
            while ( aSprmIter.GetSprms() &&
                (0 != (pParams = aSprmIter.GetAktParams())) )
            {
                switch( aSprmIter.GetAktId() )
                {
                case 187:
                case 0xD605:
                    // sprmTTableBorders
                    if( bVer67 )
                    {
                        for( int i = 0; i < 6; ++i )
                        {
                            pNewBand->aDefBrcs[i].aBits1[0] = pParams[   2*i ];
                            pNewBand->aDefBrcs[i].aBits1[1] = pParams[ 1+2*i ];
                        }
                    }
                    else // aDefBrcs = *(BRC(*)[6])pS;
                        memcpy( pNewBand->aDefBrcs, pParams, 24 );
                    break;
                case 186:
                case 0x3404:
                    if( nRows == 0 )  // only 1. Line is Header
                    {
                        // sprmTTableHeader
                        bHeader = true;
                    }
                    break;
                case 182:
                case 0x5400:
                    if( nRows == 0 )
                    {
                        // sprmTJc  -  Justification Code
                        eOri = aOriArr[ *pParams & 0x3 ];
                    }
                    break;
                case 0x560B:
                    bIsBiDi = SVBT16ToShort(pParams) ? true : false;
                    break;
                case 184:
                case 0x9602:
                    {
                        // sprmTDxaGapHalf
                        pNewBand->nGapHalf = (INT16)SVBT16ToShort( pParams );
                    }
                    break;
                case 189:
                case 0x9407:
                    {
                        // sprmTDyaRowHeight
                        pNewBand->nLineHeight = (INT16)SVBT16ToShort( pParams );
                        bClaimLineFmt = true;
                    }
                    break;
                case 190:
                case 0xD608:
                    {
                        // DefineTabRow
                        pNewBand->ReadDef( bVer67, pParams );
                        bTabRowJustRead = true;
                    }
                    break;
                case 191:
                case 0xD609:
                    // TableShades
                    pShadeSprm = pParams;
                    break;
                case 0xD612:
                    pNewShadeSprm = pParams;
                    break;
                //
                // * * * * Bug #69885#: the following codes were added * * * *
                //                      (khz, 1.Feb.2000)
                case 183:
                case 0x9601:
                    {
                        // sprmTDxaLeft
                        //
                        // our Writer cannot shift single table lines
                        // horizontally so we have to find the smallest
                        // parameter (meaning the left-most position) and then
                        // shift the whole table to that margin (see below)
                        short nDxaNew = (INT16)SVBT16ToShort( pParams );
                        if( nDxaNew < nTabeDxaNew )
                            nTabeDxaNew = nDxaNew;
                    }
                    break;
                case 193:
                case 0xD620:
                    {
                        // sprmTSetBrc
                        pNewBand->ProcessSprmTSetBRC( bVer67, pParams );
                    }
                    break;
                case 196:
                case 0x7623:
                    {
                        // sprmTDxaCol
                        pNewBand->ProcessSprmTDxaCol(pParams);
                    }
                    break;
                case 194:
                case 0x7621:
                    {
                        // sprmTInsert
                        pNewBand->ProcessSprmTInsert(pParams);
                    }
                    break;
                case 195:
                case 0x5622:
                    {
                        // sprmTDelete
                        pNewBand->ProcessSprmTDelete(pParams);
                    }
                    break;
                case 0xD634:
                    pNewBand->ProcessSpacing(pParams);
                    break;
                case 0xD632:
                    pNewBand->ProcessSpecificSpacing(pParams);
                    break;
                }
                aSprmIter++;
            }

            if( !nLoop )
            {
                pPap->GetPCDSprms(  aDesc );
                aSprmIter.SetSprms( aDesc.pMemPos, aDesc.nSprmsLen );
            }
        }

        // #55171: WW-Tabellen koennen Fly-Wechsel beinhalten daher hier
        // Tabellen abbrechen und neu beginnen noch steht *pPap noch vor
        // TabRowEnd, daher kann TestApo() mit letztem Parameter false und
        // damit wirksam gerufen werden.

        if (bTabRowJustRead)
        {
            if (pShadeSprm)
                pNewBand->ReadShd(pShadeSprm);
            if (pNewShadeSprm)
                pNewBand->ReadNewShd(pNewShadeSprm, bVer67);
        }

        if( nTabeDxaNew < SHRT_MAX )
        {
            short* pCenter  = pNewBand->nCenter;
            for( int i = 0; i < pNewBand->nWwCols; i++, ++pCenter )
                *pCenter += nTabeDxaNew; // Shift left x-position
        }

        if (!pActBand)
            pActBand = pFirstBand = pNewBand;
        else
        {
            pActBand->pNextBand = pNewBand;
            pActBand = pNewBand;
        }
        nBands++;

        pNewBand = new WW8TabBandDesc;

        nRows++;
        pActBand->nRows++;

        //Seek our pap to its next block of properties
        WW8PLCFxDesc aRes;
        aRes.pMemPos = 0;
        aRes.nStartPos = nStartCp;

        if (!(pPap->SeekPos(aRes.nStartPos)))
        {
            aRes.nEndPos = LONG_MAX;
            pPap->SetDirty(true);
        }
        pPap->GetSprms(&aRes);
        pPap->SetDirty(false);

        //Are we at the end of available properties
        if (
            (pPap->Where() == LONG_MAX) ||
            (
             (!bVer67 || bComplex) && (pPap->GetPCDIdx() >= pPap->GetPCDIMax())
            )
           )
        {
            bOk = false;
            break;
        }

        //Are we still in a table cell
        pParams = HasTabCellSprm(pPap, pIo->bVer67);
        const BYTE *pLevel = pPap->HasSprm(0x6649);
        // InTable
        if (!pParams || (1 != *pParams) ||
            (pLevel && (*pLevel <= pIo->nInTable)))
        {
            break;
        }

        //Get the end of row new table positioning data
        WW8_CP nMyStartCp=nStartCp;
        if (pIo->SearchRowEnd(pPap, nMyStartCp, pIo->nInTable))
            if (SwWW8ImplReader::ParseTabPos(&aTabPos, pPap))
                pTabPos = &aTabPos;

        //Move back to this cell
        aRes.pMemPos = 0;
        aRes.nStartPos = nStartCp;

        if (!(pPap->SeekPos(aRes.nStartPos)))
        {
            aRes.nEndPos = LONG_MAX;
            pPap->SetDirty(true);
        }
        pPap->GetSprms(&aRes);
        pPap->SetDirty(false);

        //Does this row match up with the last row closely enough to be
        //considered part of the same table
        bool bStartApo, bStopApo;
        WW8FlyPara *rpNowStyleApo=0;
        pIo->TestApo(bStartApo, bStopApo, rpNowStyleApo, pIo->nInTable, false,
            pTabPos);

        /*
        ##513##, #79474# If this is not sufficent, then we should look at
        sprmPD{y|x}aAbs as our indicator that the following set of rows is not
        part of this table, but instead is an absolutely positioned table
        outside of this one
        */
        if (bStartApo || bStopApo)
            break;

        nStartCp = aRes.nEndPos;
    }
    while( 1 );

    if( bOk )
    {
        if( pActBand->nRows > 1 )
        {
            // Letztes Band hat mehr als 1 Zeile
            delete pNewBand;
            pNewBand = new WW8TabBandDesc( *pActBand ); // neues machen
            pActBand->nRows--;      // wegen Sonderbehandlung Raender-Defaults
            pNewBand->nRows = 1;
            pActBand->pNextBand = pNewBand; // am Ende einschleifen
            nBands++;
            pNewBand = 0;                   // nicht loeschen
        }
        CalcDefaults();
    }
    delete pNewBand;

    pIo->pPlcxMan->GetPap()->Restore( aSave );
}

WW8TabDesc::~WW8TabDesc()
{
    WW8TabBandDesc* pR = pFirstBand;
    while(pR)
    {
        WW8TabBandDesc* pR2 = pR->pNextBand;
        delete pR;
        pR = pR2;
    }

    delete pParentPos;
    delete pMergeGroups;
}

void WW8TabDesc::CalcDefaults()
{
    short nMinCols = SHRT_MAX;
    register WW8TabBandDesc* pR;

    nMinLeft = SHRT_MAX;
    nMaxRight = SHRT_MIN;

    /*
    #101175#
    If we are an honestly inline centered table, then the normal rules of
    engagement for left and right margins do not apply. The multiple rows are
    centered regardless of the actual placement of rows, so we cannot have
    mismatched rows as is possible in other configurations.

    e.g. change the example bugdoc in word from text wrapping of none (inline)
    to around (in frame (bApo)) and the table splits into two very disjoint
    rows as the beginning point of each row are very different
    */
    if ((!pIo->InLocalApo()) && (eOri == HORI_CENTER))
    {
        for (pR = pFirstBand; pR; pR = pR->pNextBand)
            for( short i = pR->nWwCols; i >= 0; --i)
                pR->nCenter[i] -=  pR->nCenter[0];
    }

    // 1. Durchlauf: aeusserste L- und R-Grenzen finden
    for( pR = pFirstBand; pR; pR = pR->pNextBand )
    {
        if( pR->nCenter[0] < nMinLeft )
            nMinLeft = pR->nCenter[0];

        for( short i = 0; i < pR->nWwCols; i++ )
        {
           /*
            #74387# If the margins are so large as to make the displayable
            area inside them smaller than the minimum allowed then adjust the
            width to fit. But only do it if the two cells are not the exact
            same value, if they are then the cell does not really exist and will
            be blended together into the same cell through the use of the
            nTrans(late) array.
            */
            if (
                (pR->nCenter[i+1] - pR->nCenter[i]) &&
                ((pR->nCenter[i+1] - pR->nCenter[i] - pR->nGapHalf*2) < MINLAY)
               )
            {
                pR->nCenter[i+1] = pR->nCenter[i]+MINLAY+pR->nGapHalf * 2;
            }
        }

        if( pR->nCenter[pR->nWwCols] > nMaxRight )
            nMaxRight = pR->nCenter[pR->nWwCols];
    }
    nSwWidth = nMaxRight - nMinLeft;

    // 2. Durchlauf: Zahl der Writer-Spalten feststellen Die Zahl der Writer
    // Spalten kann um bis zu 2 hoeher sein als im WW, da der SW im Gegensatz
    // zu WW keine ausgefransten linken und rechten Raender kann und diese
    // durch leere Boxen aufgefuellt werden.  Durch nichtexistente Zellen
    // koennen auch Zellen wegfallen

        // 3. Durchlauf: Wo noetig die Umrandungen durch die Defaults ersetzen
    nConvertedLeft = nMinLeft;

    short nLeftMaxThickness = 0, nRightMaxThickness=0;
    for( pR = pFirstBand ; pR; pR = pR->pNextBand )
    {
        if( !pR->pTCs )
        {
            pR->pTCs = new WW8_TCell[ pR->nWwCols ];
            memset( pR->pTCs, 0, pR->nWwCols * sizeof( WW8_TCell ) );
        }
        for(int k = 0; k < pR->nWwCols; k++ )
        {
            register WW8_TCell* pT = &pR->pTCs[k];
            int i, j;
            for( i = 0; i < 4; i ++ )
            {
                if (pT->rgbrc[i].IsZeroed(pIo->bVer67))
                {
                    // if shadow is set, its invalid
                    j = i;
                    switch( i )
                    {
                    case 0:
                        // Aussen oben  / Innen waagerecht
                        j = (pR == pFirstBand) ? 0 : 4;
                        break;
                    case 1:
                        // Aussen links / Innen senkrecht
                        j = k ? 5 : 1;
                        break;
                    case 2:
                        // Aussen unten / Innen waagerecht
                        j = pR->pNextBand ? 4 : 2;
                        break;
                    case 3:
                        // Aussen rechts/ Innen senkrecht
                        j = (k == pR->nWwCols - 1) ? 3 : 5;
                        break;
                    }
                    // mangel mit Defaults ueber
                    pT->rgbrc[i] = pR->aDefBrcs[j];
                }
            }
        }
        /*
        Similiar to graphics and other elements word does not totally
        factor the width of the border into its calculations of size, we
        do so we must adjust out widths and other dimensions to fit.  It
        appears that what occurs is that the last cell's right margin if
        the margin width that is not calculated into winwords table
        dimensions, so in that case increase the table to include the
        extra width of the right margin.
        */
        if ( pIo->bVer67 ?
         !(SVBT16ToShort(pR->pTCs[pR->nWwCols-1].rgbrc[3].aBits1) & 0x20)
       : !(SVBT16ToShort(pR->pTCs[pR->nWwCols-1].rgbrc[3].aBits2) & 0x2000))
        {
            short nThickness = pR->pTCs[pR->nWwCols-1].rgbrc[3].
                DetermineBorderProperties(pIo->bVer67);
            pR->nCenter[pR->nWwCols] += nThickness;
            if (nThickness > nRightMaxThickness)
                nRightMaxThickness = nThickness;
        }

        /*
        The left space of the table is in nMinLeft, but again this
        does not consider the margin thickness to its left in the
        placement value, so get the thickness of the left border,
        half is placed to the left of the nominal left side, and
        half to the right.
        */
        if ( pIo->bVer67 ?
              !(SVBT16ToShort(pR->pTCs[0].rgbrc[1].aBits1) & 0x20)
            : !(SVBT16ToShort(pR->pTCs[0].rgbrc[1].aBits2) & 0x2000))
        {
            short nThickness = pR->pTCs[0].rgbrc[1].
                DetermineBorderProperties(pIo->bVer67);
            if (nThickness > nLeftMaxThickness)
                nLeftMaxThickness = nThickness;
        }
    }
    nSwWidth += nRightMaxThickness;
    nMaxRight += nRightMaxThickness;
    nConvertedLeft = nMinLeft-(nLeftMaxThickness/2);

    for( pR = pFirstBand; pR; pR = pR->pNextBand )
    {
        pR->nSwCols = pR->nWwCols;
        pR->bLEmptyCol = pR->nCenter[0] - nMinLeft >= MINLAY;
        pR->bREmptyCol = nMaxRight - pR->nCenter[pR->nWwCols] >= MINLAY;

        short nAddCols = pR->bLEmptyCol + pR->bREmptyCol;
        USHORT i;
        USHORT j = ( pR->bLEmptyCol ) ? 1 : 0;
        for( i = 0; i < pR->nWwCols; i++ )
        {
            pR->nTransCell[i] = (INT8)j;
            if ( pR->nCenter[i] < pR->nCenter[i+1] )
            {
                pR->bExist[i] = true;
                j++;
            }
            else
            {
                pR->bExist[i] = false;
                nAddCols--;
            }
        }

        ASSERT(i,"no columns in row ?");

        /*
        #96345#
        If the last cell was "false" then there is no valid cell following it,
        so the default mapping forward wont't work. So map it (and
        contigious invalid cells backwards to the last valid cell instead.
        */
        if (i && pR->bExist[i-1] == false)
        {
            USHORT k=i-1;
            while (k && pR->bExist[k] == false)
                k--;
            for (USHORT n=k+1;n<i;n++)
                pR->nTransCell[n] = pR->nTransCell[k];
        }

        pR->nTransCell[i++] = (INT8)(j++);  // Wird u.a. wegen bREmptyCol um
        pR->nTransCell[i] = (INT8)j;        // max. 2 ueberindiziert

        pR->nSwCols += nAddCols;
        if( pR->nSwCols < nMinCols )
            nMinCols = pR->nSwCols;
    }

    if (nMinLeft && (HORI_LEFT == eOri))
        eOri = HORI_LEFT_AND_WIDTH; //  absolutely positioned

    nDefaultSwCols = nMinCols;  // da Zellen einfuegen billiger ist als Mergen
    if( nDefaultSwCols == 0 )
        bOk = false;
    pActBand = pFirstBand;
    nAktBandRow = 0;
    ASSERT( pActBand, "pActBand ist 0" );
}

void WW8TabDesc::SetSizePosition(SwFrmFmt* pFrmFmt)
{
    SwFrmFmt* pApply=pFrmFmt;
    if (!pApply )
        pApply = pTable->GetFrmFmt();
    ASSERT(pApply,"No frame");
    pApply->SetAttr(aItemSet);
    if (pFrmFmt)
    {
        SwFmtFrmSize aSize = pFrmFmt->GetFrmSize();
        aSize.SetSizeType(ATT_MIN_SIZE);
        aSize.SetHeight(MINLAY);
        pFrmFmt->SetAttr(aSize);
        pTable->GetFrmFmt()->SetAttr(SwFmtHoriOrient(0,HORI_FULL));
    }
}

void WW8TabDesc::CreateSwTable()
{
    ::SetProgressState( pIo->nProgress, pIo->rDoc.GetDocShell() );   // Update

    // if there is already some content on the Node append new node to ensure
    // that this content remains ABOVE the table
    SwPosition* pPoint = pIo->pPaM->GetPoint();
    bool bInsNode = pPoint->nContent.GetIndex() ? true : false;
    bool bSetMinHeight = false;

    /*
     #i8062#
     Set fly anchor to its anchor pos, so that if a table starts immediately
     at this position a new node will be inserted before inserting the table.
    */
    if (!bInsNode && pIo->pFmtOfJustInsertedApo)
    {
        const SwPosition* pAPos =
            pIo->pFmtOfJustInsertedApo->GetAnchor().GetCntntAnchor();
        if (pAPos && &pAPos->nNode.GetNode() == &pPoint->nNode.GetNode())
        {
            bInsNode = true;
            bSetMinHeight = true;

            SwFmtSurround aSur(pIo->pFmtOfJustInsertedApo->GetSurround());
            aSur.SetAnchorOnly(true);
            pIo->pFmtOfJustInsertedApo->SetAttr(aSur);
        }
    }

    if (!bInsNode && pIo->pNode_FLY_AT_CNTNT == &pPoint->nNode.GetNode())
    {
        bInsNode = true;
        bSetMinHeight = true;
    }

    if (bSetMinHeight == true)
    {
        // minimize Fontsize to minimize height growth of the header/footer
        // set font size to 1 point to minimize y-growth of Hd/Ft
        SvxFontHeightItem aSz(20);
        pIo->NewAttr( aSz );
        pIo->pCtrlStck->SetAttr(*pPoint, RES_CHRATR_FONTSIZE);
    }

    if (bInsNode)
        pIo->AppendTxtNode(*pPoint);

    pTmpPos = new SwPosition( *pIo->pPaM->GetPoint() );

    // Die Tabelle ist beim Einfuegen noch recht klein: Zahl der Spalten ist
    // die kleinste Spaltenanzahl des Originals, da Spalten einfuegen
    // schneller geht als Loeschen Zahl der Zeilen ist die Zahl der Baender,
    // da sich die (identischen) Zeilen eines Bandes prima duplizieren lassen
    pTable = pIo->rDoc.InsertTable( *pTmpPos, nBands, nDefaultSwCols, eOri );

    // Abfrage, ob im Node, in dem die Tabelle eingefuegt werden soll, bereits
    // ein Pagedesc steht. Dann wuerde der PageDesc in die naechste Zeile
    // hinter der Tabelle rutschen, wo er nichts zu suchen hat.  -> loeschen
    // und spaeter an das Tabellenformat setzen
    if (SwTxtNode* pNd = pIo->rDoc.GetNodes()[pTmpPos->nNode]->GetTxtNode())
    {
        if (const SfxItemSet* pSet = pNd->GetpSwAttrSet())
        {
            SfxPoolItem *pSetAttr = 0;
            const SfxPoolItem* pItem;
            if (SFX_ITEM_SET == pSet->GetItemState(RES_PAGEDESC, false, &pItem))
            {
                pSetAttr = new SwFmtPageDesc( *(SwFmtPageDesc*)pItem );
                pNd->ResetAttr( RES_PAGEDESC );
                pSet = pNd->GetpSwAttrSet();
            }
            if (pSet &&
                SFX_ITEM_SET == pSet->GetItemState(RES_BREAK, false, &pItem))
            {
                delete pSetAttr;
                pSetAttr = new SvxFmtBreakItem( *(SvxFmtBreakItem*)pItem );
                pNd->ResetAttr( RES_BREAK );
            }

            // evtl den PageDesc/Break jetzt an der Tabelle setzen
            if (pSetAttr)
            {
                aItemSet.Put(*pSetAttr);
                delete pSetAttr;
            }
        }
    }

    // Gesamtbreite der Tabelle
    if( nMaxRight - nMinLeft > MINLAY * nDefaultSwCols )
    {
        pTable->GetFrmFmt()->SetAttr(SwFmtFrmSize(ATT_FIX_SIZE, nSwWidth));
        aItemSet.Put(SwFmtFrmSize(ATT_FIX_SIZE, nSwWidth));
    }

    SvxFrameDirectionItem aDirection(
        bIsBiDi ? FRMDIR_HORI_RIGHT_TOP : FRMDIR_HORI_LEFT_TOP );
    aItemSet.Put(aDirection);

    if (HORI_LEFT_AND_WIDTH == eOri)
    {
        if (!pIo->nInTable && pIo->InLocalApo() && pIo->pSFlyPara->pFlyFmt &&
            GetMinLeft())
        {
            //If we are inside a frame and we have a border, the frames
            //placement does not consider the tables border, which word
            //displays outside the frame, so adjust here.
            SwFmtHoriOrient aHori(pIo->pSFlyPara->pFlyFmt->GetHoriOrient());
            SwHoriOrient eHori = aHori.GetHoriOrient();
            if ((eHori == HORI_NONE) || (eHori == HORI_LEFT) ||
                (eHori == HORI_LEFT_AND_WIDTH))
            {
                aHori.SetPos(aHori.GetPos()+GetMinLeft());
                aHori.SetHoriOrient(HORI_NONE);
                pIo->pSFlyPara->pFlyFmt->SetAttr(aHori);
            }
        }
        else
        {
            //If bApo is set, then this table is being placed in a floating
            //frame, and the frame matches the left and right *lines* of the
            //table, so the space to the left of the table isn't to be used
            //inside the frame, in word the dialog involved greys out the
            //ability to set the margin.
            SvxLRSpaceItem aL;
            aL.SetLeft( GetMinLeft() );
            aItemSet.Put(aL);
        }
    }
}

void WW8TabDesc::UseSwTable()
{
    // globale Varis initialisieren
    pTabLines = &pTable->GetTabLines();
    nAktRow = nAktCol = nAktBandRow = 0;

    pTblNd  = (SwTableNode*)(*pTabLines)[0]->GetTabBoxes()[0]->
        GetSttNd()->FindTableNode();
    ASSERT( pTblNd, "wo ist mein TabellenNode" );
    pTblNd->GetTable().SetHeadlineRepeat( bHeader );

    // ggfs. Zusatz-Zellen einfuegen u.dgl.
    AdjustNewBand();

    WW8DupProperties aDup(pIo->rDoc,pIo->pCtrlStck);
    pIo->pCtrlStck->SetAttr(*pIo->pPaM->GetPoint(), 0, false);

    // jetzt den PaM korrekt setzen und ggfs. erste Mergegruppe vorbereiten...
    SetPamInCell(nAktCol, true);
    aDup.Insert(*pIo->pPaM->GetPoint());

    pIo->bWasTabRowEnd = false;
}

void WW8TabDesc::MergeCells()
{
    short nRow;

    for (pActBand=pFirstBand, nRow=0; pActBand; pActBand=pActBand->pNextBand)
    {
        //
        // ggfs. aktuelle Box in entsprechende Merge-Gruppe eintragen
        //
        if( pActBand->pTCs )
        {
            for( short j = 0; j < pActBand->nRows; j++, nRow++ )
                for( short i = 0; i < pActBand->nWwCols; i++ )
                {
                    SwTableBox* pTargetBox;
                    WW8SelBoxInfoPtr pActMGroup = 0;
                    //
                    // ggfs. eine neue Merge-Gruppe beginnen
                    //
                    ASSERT(nRow < pTabLines->Count(),
                        "Too few lines, table ended early");
                    if (nRow >= pTabLines->Count())
                        return;
                    pTabLine = (*pTabLines)[ nRow ];
                    pTabBoxes = &pTabLine->GetTabBoxes();

                    USHORT nCol = pActBand->nTransCell[ i ];
                    ASSERT(nCol < pTabBoxes->Count(),
                        "Too few columns, table ended early");
                    if (nCol >= pTabBoxes->Count())
                        return;
                    pTabBox = (*pTabBoxes)[nCol];
                    WW8_TCell& rCell = pActBand->pTCs[ i ];
                    // ist dies die obere, linke-Zelle einer Merge-Gruppe ?

                    bool bMerge = false;
                    if ( rCell.bVertRestart && !rCell.bMerged )
                        bMerge = true;
                    else if (rCell.bFirstMerged && pActBand->bExist[i])
                    {
                        //#91211# Some tests to avoid merging cells
                        //which previously were declared invalid because
                        //of sharing the exact same dimensions as their
                        //previous cell

                        //If theres anything underneath/above we're ok.
                        if (rCell.bVertMerge || rCell.bVertRestart)
                            bMerge = true;
                        else
                        {
                        //If its a hori merge only, and the only things in
                        //it are invalid cells then its already taken care
                        //of, so don't merge.
                            for (USHORT i2 = i+1; i2 < pActBand->nWwCols; i2++ )
                                if (pActBand->pTCs[ i2 ].bMerged &&
                                    !pActBand->pTCs[ i2 ].bFirstMerged  )
                                {
                                    if (pActBand->bExist[i2])
                                    {
                                        bMerge = true;
                                        break;
                                    }
                                }
                                else
                                    break;
                        }
                    }

                    if (bMerge)
                    {
                        short nX1    = pActBand->nCenter[ i ];
                        short nWidth = pActBand->nWidth[ i ];

                        // 0. falls noetig das Array fuer die Merge-Gruppen
                        // anlegen
                        if( !pMergeGroups )
                            pMergeGroups = new WW8MergeGroups;
                        else
                        {
                            // 1. ggfs. alte Mergegruppe(n) schliessen, die
                            // den von unserer neuen Gruppe betroffenen
                            // X-Bereich ueberdecken
                            short nMGrIdx;
                            while(FindMergeGroup( nX1, nWidth, false, nMGrIdx))
                                (*pMergeGroups)[ nMGrIdx ]->nGroupXStart = -999;
                        }

                        // 2. aktuelle Merge-Gruppe anlegen
                        pActMGroup = new WW8SelBoxInfo( nX1, nWidth );

                        // 3. und in Gruppen-Array eintragen
                        pMergeGroups->Insert(pActMGroup, pMergeGroups->Count());

                        // 4. Target-Box anlegen und als 0. in Merge-Group
                        // setzen
                        pIo->rDoc.GetNodes().InsBoxen(pTblNd, pTabLine,
                            (SwTableBoxFmt*)pTabBox->GetFrmFmt(),
                            (SwTxtFmtColl*)pIo->rDoc.GetDfltTxtFmtColl(), 0,
                            nCol );

                        pTargetBox = (*pTabBoxes)[ nCol ];

                        // eingefuegte Box wieder aus der Row entfernen
                        // (wird vom Merge() dann endgueltig richtig eingebaut)
                        pTabBoxes->Remove( nCol );

                        // und ab damit in die Merge-Group
                        pActMGroup->Insert( pTargetBox, pActMGroup->Count() );
                        //
                        // 5. Target-Box formatieren
                        //
                        pTargetBox->SetUpper( 0 );

                        // eigenes Frame-Format fuer diese Box anlegen
                        SwFrmFmt* pNewFrmFmt = pTargetBox->ClaimFrmFmt();

                        // Border der O-L-Box der Gruppe wird Border der
                        // Targetbox
                        pNewFrmFmt->SetAttr( pTabBox->GetFrmFmt()->GetBox() );
                        // Gesamtbreite ermitteln und zuweisen
                        short nSizCell = pActBand->nWidth[ i ];
                        for (USHORT i2 = i+1; i2 < pActBand->nWwCols; i2++ )
                            if (pActBand->pTCs[ i2 ].bMerged &&
                                !pActBand->pTCs[ i2 ].bFirstMerged  )
                            {
                                nSizCell += pActBand->nWidth[ i2 ];
                            }
                            else
                                break;
                        pActMGroup->nGroupWidth = nSizCell;
                        pNewFrmFmt->SetAttr( SwFmtFrmSize( ATT_VAR_SIZE,
                            pActMGroup->nGroupWidth ));
                    }

                    // ggfs. akt. Box zu einer Merge-Gruppe hinzufuegen (dies
                    // kann eine soeben angelegte, oder eine andere Gruppe
                    // sein)
                    UpdateTableMergeGroup( rCell, pActMGroup, pTabBox, i );
                }
        }
    }
}

void WW8TabDesc::FinishSwTable()
{
    WW8DupProperties aDup(pIo->rDoc,pIo->pCtrlStck);
    pIo->pCtrlStck->SetAttr( *pIo->pPaM->GetPoint(), 0, false);

    *pIo->pPaM->GetPoint() = *pTmpPos;
    delete pTmpPos, pTmpPos = 0;

    aDup.Insert(*pIo->pPaM->GetPoint());

    pIo->bWasTabRowEnd = false;
    if( pIo->rDoc.GetRootFrm() )
    {
        // exitiert schon ein Layout, dann muss an dieser Tabelle die
        // BoxFrames neu erzeugt werden.
        pTblNd->DelFrms();
        pTblNd->MakeFrms( &pIo->pPaM->GetPoint()->nNode );
    }

    MergeCells();

    // falls noetig, zu mergende Zellen gruppenweise zusammenfassen
    if( pMergeGroups )
    {
        // bearbeite alle Merge-Gruppen nacheinander
        SwTableBox*    pTargetBox;
        WW8SelBoxInfo* pActMGroup;
        USHORT         nActBoxCount;
        for( USHORT iGr = 0; iGr < pMergeGroups->Count(); iGr++ )
        {
            pActMGroup   = (*pMergeGroups)[ iGr ];
            // Anzahl der zu mergenden Boxen PLUS Eins (fuer die TargetBox)
            nActBoxCount = pActMGroup->Count();

            if( ( 1 < nActBoxCount ) && pActMGroup && (*pActMGroup)[ 0 ] )
            {
                // beachten: der 0. Eintrag ist die ebenso wie
                // die obere, linke Box formatierte Target-Box !!!
                pTargetBox = (*pActMGroup)[ 0 ];
                //
                // Target-Box verschoenern: unteren Rand der letzten Box nehmen
                //
                SwFrmFmt* pTargetFrmFmt = pTargetBox->GetFrmFmt();
                SvxBoxItem aBoxItem( pTargetFrmFmt->GetBox() );
                aBoxItem.SetLine( (*pActMGroup)[ nActBoxCount-1 ]->
                    GetFrmFmt()->GetBox().GetBottom(), BOX_LINE_BOTTOM );
                pTargetFrmFmt->SetAttr( aBoxItem );

                // oeffne Merge-Array mit passender Groesse
                SwSelBoxes aBoxes( nActBoxCount-1 );

                // alle Boxen dieser Gruppe in aBoxes versammeln
                aBoxes.Insert( pActMGroup->GetData()+1, nActBoxCount-1 );

                // Sicherheitspruefung: Gruppe mit nur EINER Box fuehrt beim
                // Mergen zum Programmabsturz, deshalb diesen unsinnigen Fall
                // abfangen!
                USHORT nMergeTest;
                if( 2 == nActBoxCount )
                {
                    // nur 1 Zelle in der Merge-Gruppe: wahrscheinlich Word-Bug
                    nMergeTest = TBLMERGE_TOOCOMPLEX;
                }
                else
                {   //
                    // Vorsicht: erstmal austesten,
                    // ob sich die aBoxes ueberhaupt mergen lassen wuerden...
                    //

                    // siehe   /SW/INC/TBLSEL.HXX
                    nMergeTest = CheckMergeSel( aBoxes );
                    BYTE  nTry = 1;
                    //
                    // Falls das Merge so nicht machbar ist,
                    // pruefen, ob es ginge, wenn wir die letzte Box
                    // oder die beiden letzten Boxen
                    // oder gar die drei letzten Boxen
                    // aus der Merge-Gruppe rausnehmen wuerden
                    while(     ( TBLMERGE_TOOCOMPLEX == nMergeTest )
                                    && ( 4 > nTry                          )
                                    && ( 3 < nActBoxCount /* wichtig ! */  ) )
                    {
                        nTry++;
                        nActBoxCount--;
                        // letzte Box aus der Gruppe rausnehmen
                        aBoxes.Remove( nActBoxCount-1 );
                        // und nachsehen, ob Merge nun moeglich waere
                        nMergeTest = CheckMergeSel( aBoxes );
                    }
                }
                //
                // Genug geprueft - wir schreiten zur Tat...
                //
                switch( nMergeTest )
                {
                case TBLMERGE_OK:
                    {
                    //
                    // You succeed at last...
                    //
                    SwTxtNode* pTxtNd;
                    SwPosition aInsPos( *pTargetBox->GetSttNd() );
                    SwNodeIndex& rInsPosNd = aInsPos.nNode;
                    SwPaM aPam( aInsPos );

                    //Move content of cells being merged to new cell
                    for (USHORT n=1;n<pActMGroup->Count();n++)
                    {
                        SwPaM aPamTest( pIo->rDoc.GetNodes() );
                        //If theres nothing in the cell (after the first) ignore it
                        if ((n > 1) && (IsEmptyBox( *(*pActMGroup)[n], aPamTest)))
                            continue;
                        aPam.GetPoint()->nNode.Assign( *(*pActMGroup)[n]->
                            GetSttNd()->EndOfSectionNode(), -1 );

                        SwCntntNode* pCNd = aPam.GetCntntNode();
                        USHORT nL = pCNd ? pCNd->Len() : 0;
                        aPam.GetPoint()->nContent.Assign( pCNd, nL );

                        SwNodeIndex aSttNdIdx(*(*pActMGroup)[n]->GetSttNd(),1);

                        pIo->AppendTxtNode( *aPam.GetPoint() );
                        SwNodeRange aRg( aSttNdIdx, aPam.GetPoint()->nNode );
                        rInsPosNd++;

                        pIo->rDoc.Move( aRg, rInsPosNd );
                        rInsPosNd.Assign( pIo->rDoc.GetNodes(),
                            rInsPosNd.GetNode().EndOfSectionIndex() - 2 );
                        pTxtNd = rInsPosNd.GetNode().GetTxtNode();
                        if( pTxtNd )
                            aInsPos.nContent.Assign(
                                    pTxtNd, pTxtNd->GetTxt().Len() );
                    }

                    SwNodeIndex aIdx( *pTargetBox->GetSttNd()->
                        EndOfSectionNode(), -1 );
                    pIo->rDoc.GetNodes().Delete( aIdx, 1 );

                    aPam.GetPoint()->nNode = *pTargetBox->GetSttNd();
                    aPam.GetPoint()->nContent.Assign( 0, 0 );

                    ((SwTable*)pTable)->Merge( &pIo->rDoc, aBoxes, pTargetBox );

                    }
                    break;
                case TBLMERGE_NOSELECTION:
                    /*NOP*/     // war wohl nix?
                    break;
                case TBLMERGE_TOOCOMPLEX:
                    // Pech: Trotz aller Probiererei geht das Merge immer noch
                    // nicht!
                    //
                    // Beachten: die Daten der Gruppe schlummern bereits in
                    // der Target-Box. Da kein Merge moeglich ist, setzen wir
                    // die Target-Box in die Tabelle an die Stelle der oberen
                    // linken Box.
                    {
                        const SwTableBox* pBox  = (*pActMGroup)[ 1 ];
                        SwTableLine*      pLine = (SwTableLine*)pBox->GetUpper();

                        USHORT nPos = pLine->GetTabBoxes().GetPos( pBox );

                        ASSERT( USHRT_MAX != nPos, "GetPos fehlgeschlagen");

                        SwStartNode* pSttNd = (SwStartNode*)pBox->GetSttNd();

                        ASSERT( pSttNd, "Box ohne Start-Node ?!");

                        pTargetBox->ChgFrmFmt(
                            (SwTableBoxFmt*)pBox->GetFrmFmt() );
                        pTargetBox->SetUpper(  pLine );

                        // erst die Box loeschen!!
                        pLine->GetTabBoxes().DeleteAndDestroy( nPos );
                        // dann die pTargetBox einfuegen
                        pLine->GetTabBoxes().C40_INSERT( SwTableBox,
                            pTargetBox, nPos );
                        // dann die Nodes loeschen!!
                        pIo->rDoc.DeleteSection( pSttNd );
                    }
                    break;
                default:            // was wollen wir denn hier ???
                    ASSERT(!this,"CheckMergeSel() with undefined return value");
                    break;
                }
            }
        }
        DELETEZ( pMergeGroups );
    }
    // nun noch ggfs. die doppelten Innenraender korrigieren (Bug #53525#)
    if( pTable )
        ((SwTable*)pTable)->GCBorderLines();    // Garbage Collect
}


// durchsucht pMergeGroups, meldet Index der ersten, passenden Gruppe bzw. -1
//
// Parameter: nXcenter  = Mittenposition der anfragenden Box
//            nWidth    = Breite der anfragenden Box
//            bExact    = Flag, ob Box in dieser Gruppe passen muss,
//                          oder diese nur zu tangieren braucht
//
bool WW8TabDesc::FindMergeGroup(short nX1, short nWidth, bool bExact,
    short& nMGrIdx)
{
    nMGrIdx = -1;
    if( pMergeGroups )
    {
        // noch als gueltig angesehener Bereich in der Naehe der Grenzen
        const short nToleranz = 4;
        // die aktuell untersuchte Gruppe
        WW8SelBoxInfoPtr pActGroup;
        // Boxgrenzen
        short nX2 = nX1 + nWidth;
        // ungefaehre Gruppengrenzen
        short nGrX1;
        short nGrX2;

        for( USHORT iGr = 0; iGr < pMergeGroups->Count(); iGr++ )
        {
            // die aktuell untersuchte Gruppe
            pActGroup = (*pMergeGroups)[ iGr ];
            if( -999 < pActGroup->nGroupXStart  )
            {
                // ungefaehre Gruppengrenzen mit Toleranz nach *aussen* hin
                nGrX1 = pActGroup->nGroupXStart - nToleranz;
                nGrX2 = pActGroup->nGroupXStart
                             +pActGroup->nGroupWidth  + nToleranz;
                //
                // Falls Box reinpasst, melde auf jeden Fall den Erfolg
                //
                if( ( nX1 > nGrX1 ) && ( nX2 < nGrX2 ) )
                {
                    nMGrIdx = iGr;  break;
                }
                //
                // hat die Box Bereiche mit der Gruppe gemeinsam?
                //
                if( !bExact )
                {
                    // melde Erfolg, wenn nX1 *oder* nX2 innerhalb der Gruppe liegen
                    if(    (     ( nX1 > nGrX1 )
                                        && ( nX1 < nGrX2 - 2*nToleranz ) )
                            || (     ( nX2 > nGrX1 + 2*nToleranz )
                                        && ( nX2 < nGrX2 ) )
                            // oder nX1 und nX2 die Gruppe umfassen
                            || (     ( nX1 <=nGrX1 )
                                        && ( nX2 >=nGrX2 ) ) )
                    {
                        nMGrIdx = iGr;  break;
                    }
                }
            }
        }
    }
    return ( -1 < nMGrIdx );
}


bool WW8TabDesc::IsValidCell(short nCol) const
{
    return pActBand->bExist[nCol] && (USHORT)nAktRow < pTabLines->Count();
}


bool WW8TabDesc::SetPamInCell(short nWwCol, bool bPam)
{
    ASSERT( pActBand, "pActBand ist 0" );

    USHORT nCol = pActBand->nTransCell[nWwCol];

    if ((USHORT)nAktRow >= pTabLines->Count())
    {
        ASSERT(!this, "Actual row bigger than expected." );
        return false;
    }

    pTabLine = (*pTabLines)[nAktRow];
    pTabBoxes = &pTabLine->GetTabBoxes();

    if ( nCol >= pTabBoxes->Count() )
        return false;
    pTabBox = (*pTabBoxes)[nCol];
    if( !pTabBox->GetSttNd() )
    {
        ASSERT(pTabBox->GetSttNd(), "Probleme beim Aufbau der Tabelle");
        return false;
    }
    if( bPam )
    {
        pAktWWCell = &pActBand->pTCs[ nWwCol ];
        //We need to set the pPaM on the first cell, invalid
        //or not so that we can collect paragraph proproties over
        //all the cells, but in that case on the valid cell we do not
        //want to reset the fmt properties
        if (pIo->pPaM->GetPoint()->nNode != pTabBox->GetSttIdx() + 1)
        {
            pIo->pPaM->GetPoint()->nNode = pTabBox->GetSttIdx() + 1;
            pIo->pPaM->GetPoint()->nContent.Assign( pIo->pPaM->GetCntntNode(), 0 );
            // Zur Sicherheit schon jetzt setzen, da bei den Zellen, die
            // zum Randausgleich eingefuegt werden, sonst der Style
            // nicht gesetzt wird.
            pIo->rDoc.SetTxtFmtColl( *pIo->pPaM, (SwTxtFmtColl*)pIo->pDfltTxtFmtColl );
            // uebrigens: da diese Zellen unsichtbare Hilfskonstruktionen sind,
            //            und nur dazu dienen, zerfranste Aussehen der WW-Tabelle
            //            nachzuahmen, braucht NICHT SetTxtFmtCollAndListLevel()
            //            verwendet zu werden.
        }
    }
    return true;
}

void WW8TabDesc::InsertCells( short nIns )
{
    pTabLine = (*pTabLines)[nAktRow];
    pTabBoxes = &pTabLine->GetTabBoxes();
    pTabBox = (*pTabBoxes)[0];

    pIo->rDoc.GetNodes().InsBoxen( pTblNd, pTabLine, (SwTableBoxFmt*)pTabBox->GetFrmFmt(),
                            (SwTxtFmtColl*)pIo->pDfltTxtFmtColl, 0, pTabBoxes->Count(), nIns );
    // mit dem Dritten Parameter wird das FrmFmt der Boxen angegeben.
    // hier kann man auch noch optimieren, um FrmFmts zu sparen
}

void WW8TabDesc::SetTabBorders(SwTableBox* pBox, short nWwIdx)
{
    if( nWwIdx < 0 || nWwIdx >= pActBand->nWwCols )
        return;                 // kuenstlich erzeugte Zellen -> Kein Rand


    SvxBoxItem aFmtBox;
    if (pActBand->pTCs)     // neither Cell Border nor Default Border defined ?
    {
        WW8_TCell* pT = &pActBand->pTCs[nWwIdx];
        if (pIo->IsBorder(pT->rgbrc))
            pIo->SetBorder(aFmtBox, pT->rgbrc);
    }

    if (pActBand->nOverrideSpacing[nWwIdx] & (1 << WW8TabBandDesc::wwTOP))
    {
        aFmtBox.SetDistance(
            pActBand->nOverrideValues[nWwIdx][WW8TabBandDesc::wwTOP],
            BOX_LINE_TOP);
    }
    else
        aFmtBox.SetDistance(pActBand->mnDefaultTop, BOX_LINE_TOP);
    if (pActBand->nOverrideSpacing[nWwIdx] & (1 << WW8TabBandDesc::wwBOTTOM))
    {
        aFmtBox.SetDistance(
            pActBand->nOverrideValues[nWwIdx][WW8TabBandDesc::wwBOTTOM],
            BOX_LINE_BOTTOM);
    }
    else
        aFmtBox.SetDistance(pActBand->mnDefaultBottom,BOX_LINE_BOTTOM);

    // nGapHalf bedeutet bei WW ein *horizontaler* Abstand zwischen
    // Tabellenzelle und -Inhalt
    short nLeftDist =
        pActBand->mbHasSpacing ? pActBand->mnDefaultLeft : pActBand->nGapHalf;
    short nRightDist =
        pActBand->mbHasSpacing ? pActBand->mnDefaultRight : pActBand->nGapHalf;
    if (pActBand->nOverrideSpacing[nWwIdx] & (1 << WW8TabBandDesc::wwLEFT))
    {
        aFmtBox.SetDistance(
            pActBand->nOverrideValues[nWwIdx][WW8TabBandDesc::wwLEFT],
            BOX_LINE_LEFT);
    }
    else
        aFmtBox.SetDistance(nLeftDist, BOX_LINE_LEFT);
    if (pActBand->nOverrideSpacing[nWwIdx] & (1 << WW8TabBandDesc::wwRIGHT))
    {
        aFmtBox.SetDistance(
            pActBand->nOverrideValues[nWwIdx][WW8TabBandDesc::wwRIGHT],
            BOX_LINE_RIGHT);
    }
    else
        aFmtBox.SetDistance(nRightDist,BOX_LINE_RIGHT);

    pBox->GetFrmFmt()->SetAttr(aFmtBox);
}

void WW8TabDesc::SetTabShades( SwTableBox* pBox, short nWwIdx )
{
    if( nWwIdx < 0 || nWwIdx >= pActBand->nWwCols )
        return;                 // kuenstlich erzeugte Zellen -> Keine Farbe

    bool bFound=false;
    if (pActBand->pNewSHDs && pActBand->pNewSHDs[nWwIdx] != COL_AUTO)
    {
        Color aColor(pActBand->pNewSHDs[nWwIdx]);
        pBox->GetFrmFmt()->SetAttr(SvxBrushItem(aColor));
        bFound = true;
    }

    //If there was no new shades, or no new shade setting
    if (pActBand->pSHDs && !bFound)
    {
        WW8_SHD& rSHD = pActBand->pSHDs[nWwIdx];
        if (!rSHD.GetValue())       // auto
            return;

        SwWW8Shade aSh( pIo->bVer67, rSHD );
        pBox->GetFrmFmt()->SetAttr(SvxBrushItem(aSh.aColor));
    }
}

void WW8TabDesc::SetTabVertAlign( SwTableBox* pBox, short nWwIdx )
{
    if( nWwIdx < 0 || nWwIdx >= pActBand->nWwCols )
        return;

    SwVertOrient eVertOri=VERT_TOP;

    if( pActBand->pTCs )
    {
        WW8_TCell* pT = &pActBand->pTCs[nWwIdx];
        switch (pT->nVertAlign)
        {
            case 0:
            default:
                eVertOri = VERT_TOP;
                break;
            case 1:
                eVertOri = VERT_CENTER;
                break;
            case 2:
                eVertOri = VERT_BOTTOM;
                break;
        }
    }

    pBox->GetFrmFmt()->SetAttr( SwFmtVertOrient(0,eVertOri) );
}

void WW8TabDesc::AdjustNewBand()
{
    if( pActBand->nSwCols > nDefaultSwCols )        // Zellen splitten
        InsertCells( pActBand->nSwCols - nDefaultSwCols );

    SetPamInCell( 0, false);
    ASSERT( pTabBoxes && pTabBoxes->Count() == (USHORT)pActBand->nSwCols,
        "Falsche Spaltenzahl in Tabelle" )

    if( bClaimLineFmt )
    {
        pTabLine->ClaimFrmFmt();            // noetig wg. Zeilenhoehe
        SwFmtFrmSize aF( ATT_MIN_SIZE, 0, 0 );  // default

        if( pActBand->nLineHeight == 0 )    // 0 = Auto
            aF.SetSizeType( ATT_VAR_SIZE );
        else
        {
            if( pActBand->nLineHeight < 0 ) // Pos = min, Neg = exakt
            {
                aF.SetSizeType( ATT_FIX_SIZE );
                pActBand->nLineHeight = -pActBand->nLineHeight;
            }
            if( pActBand->nLineHeight < MINLAY ) // nicht erlaubte Zeilenhoehe
                pActBand->nLineHeight = MINLAY;

            aF.SetHeight( pActBand->nLineHeight );// Min- / Exakt-Hoehe setzen
        }
        pTabLine->GetFrmFmt()->SetAttr( aF );
    }

    short i;    // SW-Index
    short j;    // WW-Index
    short nW;   // Breite
    SwFmtFrmSize aFS( ATT_FIX_SIZE );
    j = pActBand->bLEmptyCol ? -1 : 0;

    for( i = 0; i < pActBand->nSwCols; i++ )
    {
        // setze Zellenbreite
        if( j < 0 )
            nW = pActBand->nCenter[0] - nMinLeft;
        else
        {
            //Set j to first non invalid cell
            while ((j < pActBand->nWwCols) && (!pActBand->bExist[j]))
                j++;

            if( j < pActBand->nWwCols )
                nW = pActBand->nCenter[j+1] - pActBand->nCenter[j];
            else
                nW = nMaxRight - pActBand->nCenter[j];
            pActBand->nWidth[ j ] = nW;
        }

        register SwTableBox* pBox = (*pTabBoxes)[i];
        // liesse sich durch intelligentes Umhaengen der FrmFmts noch weiter
        // verringern
        pBox->ClaimFrmFmt();

        SetTabBorders(pBox, j);
        SetTabVertAlign(pBox, j);
        if( pActBand->pSHDs || pActBand->pNewSHDs)
            SetTabShades(pBox, j);
        j++;

        aFS.SetWidth( nW );
        pBox->GetFrmFmt()->SetAttr( aFS );

        // ueberspringe nicht existente Zellen
        while( ( j < pActBand->nWwCols ) && !pActBand->bExist[j] )
        {
            pActBand->nWidth[j] = pActBand->nCenter[j+1] - pActBand->nCenter[j];
            j++;
        }
    }
}

void WW8TabDesc::TableCellEnd()
{
    ::SetProgressState( pIo->nProgress, pIo->rDoc.GetDocShell() );   // Update

    // neue Zeile
    if( pIo->bWasTabRowEnd )
    {
        // bWasTabRowEnd will be deactivated in
        // SwWW8ImplReader::ProcessSpecial()

        USHORT iCol = GetLogicalWWCol();
        if (iCol < aNumRuleNames.size())
        {
            aNumRuleNames.erase(aNumRuleNames.begin() + iCol,
                aNumRuleNames.end());
        }

        nAktCol = 0;
        nAktRow++;
        nAktBandRow++;
        ASSERT( pActBand , "pActBand ist 0" );
        if( pActBand )
        {
            if( nAktRow >= nRows )  // am Tabellenende gibt's nichts sinnvolles
                return;                 // mehr zu tun

            bool bNewBand = nAktBandRow >= pActBand->nRows;
            if( bNewBand )
            {                       // neues Band noetig ?
                pActBand = pActBand->pNextBand; //
                nAktBandRow = 0;
                ASSERT( pActBand, "pActBand ist 0" );
                AdjustNewBand();
            }
            else
            {
                SwTableBox* pBox = (*pTabBoxes)[0];
                SwSelBoxes aBoxes;
                pIo->rDoc.InsertRow( pTable->SelLineFromBox( pBox, aBoxes ) );
            }
        }
    }
    else
    {                       // neue Spalte ( Zelle )
        nAktCol++;
    }
    SetPamInCell(nAktCol, true);

    // finish Annotated Level Numbering ?
    if( pIo->bAnl && !pIo->bAktAND_fNumberAcross )
        pIo->StopAnl( IsValidCell( nAktCol ) );//false);//!bRowEnded ); //
}

// ggfs. die Box in fuer diese Col offene Merge-Gruppe eintragen
SwTableBox* WW8TabDesc::UpdateTableMergeGroup(  WW8_TCell&     rCell,
                                                WW8SelBoxInfo* pActGroup,
                                                SwTableBox*    pActBox,
                                                USHORT         nCol )
{
    // Rueckgabewert defaulten
    SwTableBox* pResult = 0;

    // pruefen, ob die Box zu mergen ist
    if( pActBand->bExist[ nCol ] &&
        (rCell.bFirstMerged
        || rCell.bMerged
        || rCell.bVertMerge
        || rCell.bVertRestart) )
    {
        // passende Merge-Gruppe ermitteln
        WW8SelBoxInfo* pTheMergeGroup = 0;
        if( pActGroup )
            // Gruppe uebernehmen
            pTheMergeGroup = pActGroup;
        else
        {
            // Gruppe finden
            short nMGrIdx;
            if( FindMergeGroup( pActBand->nCenter[ nCol ],
                                pActBand->nWidth[  nCol ], true, nMGrIdx ) )
                pTheMergeGroup = (*pMergeGroups)[ nMGrIdx ];
        }
        if( pTheMergeGroup )
        {
            // aktuelle Box der Merge-Gruppe hinzufuegen
            pTheMergeGroup->Insert( pActBox, pTheMergeGroup->Count() );

            // Target-Box zurueckmelden
            pResult = (*pTheMergeGroup)[ 0 ];
        }
    }
    return pResult;
}


USHORT WW8TabDesc::GetLogicalWWCol() const // returns number of col as INDICATED within WW6 UI status line -1
{
    USHORT nCol = 0;
    if( pActBand && pActBand->pTCs)
    {
        for( USHORT iCol = 1; iCol <= nAktCol; ++iCol )
        {
            if( !pActBand->pTCs[ iCol-1 ].bMerged )
                ++nCol;
        }
    }
    return nCol;
}

// find name of numrule valid for current WW-COL
const String& WW8TabDesc::GetNumRuleName() const
{
    USHORT nCol = GetLogicalWWCol();
    if (nCol < aNumRuleNames.size())
        return aNumRuleNames[nCol];
    else
        return aEmptyStr;
}

void WW8TabDesc::SetNumRuleName( const String& rName )
{
    USHORT nCol = GetLogicalWWCol();
    for (USHORT nSize = aNumRuleNames.size(); nSize <= nCol; ++nSize)
        aNumRuleNames.push_back(aEmptyStr);
    aNumRuleNames[nCol] = rName;
}

bool SwWW8ImplReader::StartTable(WW8_CP nStartCp)
{
    // keine rekursiven Tabellen Nicht bei EinfuegenDatei in Tabelle oder
    // Fussnote
    if (bReadNoTbl)
        return false;

    if (pTableDesc)
        aTableStack.push(pTableDesc);

    pTableDesc = new WW8TabDesc( this, nStartCp );

    if( pTableDesc->Ok() )
    {
        int nNewInTable = nInTable + 1;
        if (InEqualApo(nNewInTable))
        {
            ASSERT(pSFlyPara->pFlyFmt,
                "how could we be in a local apo and have no apo");
        }

        if (!aTableStack.empty() && !InEqualApo(nNewInTable))
        {
            pTableDesc->pParentPos = new SwPosition(*pPaM->GetPoint());
            SfxItemSet aItemSet(rDoc.GetAttrPool(),
                RES_FRMATR_BEGIN, RES_FRMATR_END-1);
            SwFmtAnchor aAnchor(FLY_IN_CNTNT);
            aAnchor.SetAnchor(pTableDesc->pParentPos);
            aItemSet.Put(aAnchor);
            pTableDesc->pFlyFmt = rDoc.MakeFlySection(FLY_IN_CNTNT,
                pTableDesc->pParentPos, &aItemSet);
            ASSERT(pTableDesc->pFlyFmt->GetAnchor().GetAnchorId()
                == FLY_IN_CNTNT, "Not the anchor type requested!");
            MoveInsideFly(pTableDesc->pFlyFmt);
        }
        pTableDesc->CreateSwTable();
        if (pTableDesc->pFlyFmt)
        {
            SwFmtHoriOrient aHori = pTableDesc->pTable->GetFrmFmt()->
                GetHoriOrient();
            pTableDesc->SetSizePosition(pTableDesc->pFlyFmt);
            pTableDesc->pFlyFmt->SetAttr(SwFmtSurround(SURROUND_NONE));
            pTableDesc->pFlyFmt->SetAttr(aHori);
        }
        else if (InEqualApo(nNewInTable) && pSFlyPara->pFlyFmt)
        {
            pTableDesc->SetSizePosition(pSFlyPara->pFlyFmt);
            const SfxPoolItem *pItem;
            if (SFX_ITEM_SET ==
                pTableDesc->aItemSet.GetItemState(RES_FRM_SIZE, true, &pItem))
            {
                const SwFmtFrmSize *pSize = (const SwFmtFrmSize *)pItem;
                pSFlyPara->BoxUpWidth(pSize->GetWidth());
            }
        }
        else if (!InEqualApo(nNewInTable))
            pTableDesc->SetSizePosition(0);
        pTableDesc->UseSwTable();
    }
    else
        PopTableDesc();

    return 0 != pTableDesc;
}

void SwWW8ImplReader::TabCellEnd()
{
    if (nInTable && pTableDesc)
        pTableDesc->TableCellEnd();
}

void SwWW8ImplReader::Read_TabRowEnd( USHORT, const BYTE* pData, short nLen )   // Sprm25
{
    if( ( nLen > 0 ) && ( *pData == 1 ) )
        bWasTabRowEnd = true;
}

void SwWW8ImplReader::PopTableDesc()
{
    if (pTableDesc && pTableDesc->pFlyFmt)
        MoveOutsideFly(pTableDesc->pFlyFmt,*pTableDesc->pParentPos);

    delete pTableDesc;
    if (aTableStack.empty())
        pTableDesc = 0;
    else
    {
       pTableDesc = aTableStack.top();
       aTableStack.pop();
    }
}

void SwWW8ImplReader::StopTable()
{
    pTableDesc->FinishSwTable();
    PopTableDesc();
}

// GetTableLeft() wird fuer absatzgebundene Grafikobjekte in Tabellen
// gebraucht.
// WW nimmt bei eingerueckten Tabellen den Absatzrand, der ohne Tabelle
// gueltig waere, als Basis; SW benutzt den linken Tabellenrand.
short SwWW8ImplReader::GetTableLeft()
{
    return (pTableDesc) ? pTableDesc->GetMinLeft() : 0;
}

bool SwWW8ImplReader::IsInvalidOrToBeMergedTabCell() const
{
    if( !pTableDesc )
        return false;

    const WW8_TCell* pCell = pTableDesc->GetAktWWCell();

    return     !pTableDesc->IsValidCell( pTableDesc->GetAktCol() )
            || (    pCell
                 && (    !pCell->bFirstMerged
                      && (    pCell->bMerged
                           || (    pCell->bVertMerge
                                && !pCell->bVertRestart
                              )
                         )
                    )
                );
}

const USHORT SwWW8ImplReader::StyleUsingLFO( USHORT nLFOIndex ) const
{
    USHORT nRes = USHRT_MAX;
    if( pCollA )
    {
        for(USHORT nI = 0; nI < pStyles->GetCount(); nI++ )
            if(    pCollA[ nI ].bValid
                && (nLFOIndex == pCollA[ nI ].nLFOIndex) )
                nRes = nI;
    }
    return nRes;
}

const SwFmt* SwWW8ImplReader::GetStyleWithOrgWWName( String& rName ) const
{
    SwFmt* pRet = 0;
    if( pCollA )
    {
        for(USHORT nI = 0; nI < pStyles->GetCount(); nI++ )
            if(    pCollA[ nI ].bValid
                && (rName.Equals( pCollA[ nI ].GetOrgWWName())) )
            {
                pRet = pCollA[ nI ].pFmt;
                break;
            }
    }
    return pRet;
}

//-----------------------------------------
//          class WW8RStyle
//-----------------------------------------

const BYTE* WW8RStyle::HasParaSprm( USHORT nId ) const
{
    if( !pParaSprms || !nSprmsLen )
        return 0;

    const BYTE* pSprms = pParaSprms;
    USHORT i, x;

    for( i=0; i < nSprmsLen; )
    {
        USHORT nAktId = maSprmParser.GetSprmId(pSprms);
        // Sprm found ?
        if( nAktId == nId )
            return pSprms + maSprmParser.DistanceToData(nId);

        x = maSprmParser.GetSprmSize(nAktId, pSprms);
        i += x;
        pSprms += x;
    }
    return 0;                               // Sprm not found
}

void WW8RStyle::ImportSprms(long nPosFc, short nLen, bool bPap)
{
    if( pStStrm->IsEof() )
        return;

    BYTE *pSprms0 = new BYTE[nLen];
    if( bPap )
    {
        pParaSprms = pSprms0;   // fuer HasParaSprms()
        nSprmsLen = nLen;
    }
    BYTE* pSprms1 = pSprms0;
    pStStrm->Seek( nPosFc );
    pStStrm->Read( pSprms0, nLen );

    while ( nLen > 0 )
    {
        USHORT nL1 = pIo->ImportSprm(pSprms1);
        nLen -= nL1;
        pSprms1 += nL1;
    }

    delete[] pSprms0;
    pParaSprms = 0;
    nSprmsLen = 0;
}

static inline short WW8SkipOdd(SvStream* pSt )
{
    if ( pSt->Tell() & 0x1 )
    {
        UINT8 c;
        pSt->Read( &c, 1 );
        return 1;
    }
    return 0;
}

static inline short WW8SkipEven(SvStream* pSt )
{
    if (!(pSt->Tell() & 0x1))
    {
        UINT8 c;
        pSt->Read( &c, 1 );
        return 1;
    }
    return 0;
}

short WW8RStyle::ImportUPX(short nLen, bool bPAP, bool bOdd)
{
    INT16 cbUPX;

    if( 0 < nLen ) // Empty ?
    {
        if (bOdd)
            nLen -= WW8SkipEven( pStStrm );
        else
            nLen -= WW8SkipOdd( pStStrm );

        *pStStrm >> cbUPX;

        nLen-=2;

        if ( cbUPX > nLen )
            cbUPX = nLen;       // !cbUPX auf nLen verkleinert!

        if( (1 < cbUPX) || ( (0 < cbUPX) && !bPAP ) )
        {
            if( bPAP )
            {
                UINT16 id;
                *pStStrm >> id;

                cbUPX-=  2;
                nLen-=  2;
            }

            if( 0 < cbUPX )
            {
                ULONG nPos = pStStrm->Tell();   // falls etwas falsch interpretiert
                                                // wird, gehts danach wieder richtig
                ImportSprms( nPos, cbUPX, bPAP );

                if ( pStStrm->Tell() != nPos + cbUPX )
                    pStStrm->Seek( nPos+cbUPX );

                nLen -= cbUPX;
            }
        }
    }
    return nLen;
}

void WW8RStyle::ImportGrupx(short nLen, bool bPara, bool bOdd)
{
    if( nLen <= 0 )
        return;
    if (bOdd)
        nLen -= WW8SkipEven( pStStrm );
    else
        nLen -= WW8SkipOdd( pStStrm );

    if( bPara ) // Grupx.Papx
        nLen = ImportUPX(nLen, true, bOdd);
    ImportUPX(nLen, false, bOdd);                   // Grupx.Chpx
}

WW8RStyle::WW8RStyle(WW8Fib& rFib, SwWW8ImplReader* pI)
    : WW8Style(*pI->pTableStream, rFib), maSprmParser(rFib.nVersion),
    pIo(pI), pStStrm(pI->pTableStream), pStyRule(0), nWwNumLevel(0)
{
    pIo->pCollA = new SwWW8StyInf[ cstd ]; // Style-UEbersetzung WW->SW
    pIo->nColls = cstd;
}

void WW8RStyle::Set1StyleDefaults()
{
    if (!bCJKFontChanged)   // Style no CJK Font? set the default
        pIo->SetNewFontAttr(ftcStandardChpCJKStsh, true, RES_CHRATR_CJK_FONT);

    if (!bCTLFontChanged)   // Style no CTL Font? set the default
        pIo->SetNewFontAttr(ftcStandardChpCTLStsh, true, RES_CHRATR_CTL_FONT);

    //#88976# western 2nd to make western charset conversion the default
    if (!bFontChanged)      // Style has no Font? set the default,
        pIo->SetNewFontAttr(ftcStandardChpStsh, true, RES_CHRATR_FONT);

    if( !pIo->bNoAttrImport )
    {
        // Style has no text color set, winword default is auto
        if ( !bTxtColChanged )
            pIo->pAktColl->SetAttr(SvxColorItem(Color(COL_AUTO)));

        // Style has no FontSize ? WinWord Default is 10pt for western and asian
        if( !bFSizeChanged )
        {
            SvxFontHeightItem aAttr(200);
            pIo->pAktColl->SetAttr(aAttr);
            aAttr.SetWhich(RES_CHRATR_CJK_FONTSIZE);
            pIo->pAktColl->SetAttr(aAttr);
        }

        // Style has no FontSize ? WinWord Default is 10pt for western and asian
        if( !bFCTLSizeChanged )
        {
            SvxFontHeightItem aAttr(200);
            aAttr.SetWhich(RES_CHRATR_CTL_FONTSIZE);
            pIo->pAktColl->SetAttr(aAttr);
        }

        if( pIo->pWDop->fWidowControl && !bWidowsChanged )  // Widows ?
        {
            pIo->pAktColl->SetAttr( SvxWidowsItem( 2 ) );
            pIo->pAktColl->SetAttr( SvxOrphansItem( 2 ) );
        }
    }
}

//-----------------------------------------
//      Zeichenvorlagen
//-----------------------------------------
SwCharFmt* WW8RStyle::SearchCharFmt( const String& rName )
{
    USHORT n;
                            // Suche zuerst in den Doc-Styles
    for( n = pIo->rDoc.GetCharFmts()->Count(); n > 0; )
        if( (*pIo->rDoc.GetCharFmts())[ --n ]->GetName().Equals( rName ) )
            return (*pIo->rDoc.GetCharFmts())[ n ];

                    // Collection noch nicht gefunden, vielleicht im Pool ?
    n = SwStyleNameMapper::GetPoolIdFromUIName( rName , GET_POOLID_CHRFMT );
    if ( n != USHRT_MAX )       // gefunden oder Standard
        return pIo->rDoc.GetCharFmtFromPool( n );

    return 0;
}

SwCharFmt* WW8RStyle::MakeNewCharFmt( WW8_STD* pStd, const String& rName )
{
    String aName( rName );
    SwCharFmt* pFmt = 0;

    // eingebauter Style, den wir nicht kennen ? oder Namen gibts schon ?
    if (pStd->sti != WW8_STD::STI_USER || SearchCharFmt(aName))
    {
        if (!aName.EqualsAscii("WW-", 0, 3))    // noch kein "WW-"
            aName.InsertAscii("WW-", 0);        // dann aender ihn

        if (SearchCharFmt(aName))               // Namen gibt's immer noch ?
        {
            for (USHORT n = 1; n < 1000; ++n)
            {
                String aName1( aName );
                aName1 += String::CreateFromInt32( n );
                if ((pFmt = SearchCharFmt(aName1)) == 0)
                {
                    aName = aName1;
                    break;   // unbenutzten Namen gefunden
                }
            }
        }
    }

    if (!pFmt)   // unbenutzter Collection-Name gefunden, erzeuge neue Coll
        pFmt = pIo->rDoc.MakeCharFmt(aName, pIo->rDoc.GetDfltCharFmt());

    return pFmt;
}

SwCharFmt* WW8RStyle::MakeOrGetCharFmt(bool * pbStyExist, WW8_STD* pStd,
    const String& rName )
{
#define RES_NO RES_POOLCHR_END

    static USHORT __READONLY_DATA aArr1[]={
        RES_POOLCHR_FOOTNOTE, 0, RES_POOLCHR_LINENUM,
        RES_POOLCHR_PAGENO, RES_POOLCHR_ENDNOTE };

    static USHORT __READONLY_DATA aArr2[]={
        RES_POOLCHR_INET_NORMAL, RES_POOLCHR_INET_VISIT,
        RES_POOLCHR_HTML_STRONG, RES_POOLCHR_HTML_EMPHASIS };

    // Einfuegen: immer neue Styles generieren || nicht abgeschaltet
    if ( pIo->mbNewDoc && !(pIo->nIniFlags & WW8FL_NO_DEFSTYLES) )
    {
        SwCharFmt* pFmt = 0;

        // Default-Style bekannt ?
        short nIdx = pStd->sti - 38;
        if(    nIdx >= 0 && nIdx < 5
            && aArr1[nIdx]!=0 )
            pFmt = pIo->rDoc.GetCharFmtFromPool( aArr1[ nIdx ] );
        else
        {
            nIdx = pStd->sti - 85;
            if(    nIdx >= 0
                && nIdx <  4 )
                pFmt = pIo->rDoc.GetCharFmtFromPool( aArr2[ nIdx ] );
        }
        if( pFmt )
        {
            *pbStyExist = true;
            return pFmt;
        }
    }
    *pbStyExist = false;
    String aName( rName );
    xub_StrLen nPos = aName.Search( ',' );
    if( STRING_NOTFOUND != nPos )   // mehrere Namen mit Komma getrennt
        aName.Erase( nPos );        // gibts im SW nicht
    return MakeNewCharFmt( pStd, aName );   // nicht gefunden
}

//-----------------------------------------
//      Absatzvorlagen
//-----------------------------------------

SwTxtFmtColl* WW8RStyle::SearchFmtColl( const String& rName )
{
                            // Suche zuerst in den Doc-Styles
    SwTxtFmtColl* pColl = pIo->rDoc.FindTxtFmtCollByName( rName );
    if( !pColl )
    {
                    // Collection noch nicht gefunden, vielleicht im Pool ?
        USHORT n = SwStyleNameMapper::GetPoolIdFromUIName( rName , GET_POOLID_TXTCOLL );
        if ( n != USHRT_MAX )       // gefunden oder Standard
            pColl = pIo->rDoc.GetTxtCollFromPoolSimple(n, false);
    }
    return pColl;
}

SwTxtFmtColl* WW8RStyle::MakeNewFmtColl( WW8_STD* pStd, const String& rName )
{
    String aName( rName );
    SwTxtFmtColl* pColl = 0;

    // eingebauter Style, den wir nicht kennen
    // oder Namen gibts schon ?
    if (pStd->sti != WW8_STD::STI_USER || SearchFmtColl(aName))
    {
        if (!aName.EqualsIgnoreCaseAscii("WW-", 0, 3))  // noch kein "WW-"
            aName.InsertAscii("WW-" , 0);   // dann AEnder ihn

        // Namen gibt's immer noch ?
        if (SearchFmtColl(aName))
        {
            for (USHORT n = 1; n < 1000; ++n)
            {
                // dann bastel neuen
                String aName1(aName);
                aName += String::CreateFromInt32(n);
                if ((pColl = SearchFmtColl(aName1)) == 0)
                {
                    aName = aName1;
                    // unbenutzten Namen gefunden
                    break;
                }
            }
        }
    }

    if (!pColl)   // unbenutzter Collection-Name gefunden, erzeuge neue Coll
    {
        pColl = pIo->rDoc.MakeTxtFmtColl(aName,
            const_cast<SwTxtFmtColl *>(pIo->rDoc.GetDfltTxtFmtColl()));
    }

    return pColl;
}

SwTxtFmtColl* WW8RStyle::MakeOrGetFmtColl(bool * pbStyExist, WW8_STD* pStd,
    const String& rName)
{
#define RES_NONE RES_POOLCOLL_DOC_END

    static const RES_POOL_COLLFMT_TYPE aArr[]={
        RES_POOLCOLL_STANDARD, RES_POOLCOLL_HEADLINE1, RES_POOLCOLL_HEADLINE2,                                  // Ueberschrift 2
        RES_POOLCOLL_HEADLINE3, RES_POOLCOLL_HEADLINE4, RES_POOLCOLL_HEADLINE5,
        RES_POOLCOLL_HEADLINE6, RES_POOLCOLL_HEADLINE7, RES_POOLCOLL_HEADLINE8,
        RES_POOLCOLL_HEADLINE9,

        RES_POOLCOLL_TOX_IDX1, RES_POOLCOLL_TOX_IDX2, RES_POOLCOLL_TOX_IDX3,
        RES_NONE, RES_NONE, RES_NONE, RES_NONE, RES_NONE, RES_NONE,
        RES_POOLCOLL_TOX_CNTNT1,

        RES_POOLCOLL_TOX_CNTNT2, RES_POOLCOLL_TOX_CNTNT3, RES_POOLCOLL_TOX_CNTNT4,
        RES_POOLCOLL_TOX_CNTNT5, RES_POOLCOLL_TOX_CNTNT6, RES_POOLCOLL_TOX_CNTNT7,
        RES_POOLCOLL_TOX_CNTNT8, RES_POOLCOLL_TOX_CNTNT9,
        RES_NONE, RES_POOLCOLL_FOOTNOTE,

        RES_NONE, RES_POOLCOLL_HEADER, RES_POOLCOLL_FOOTER, RES_POOLCOLL_TOX_IDXH,
        RES_NONE, RES_NONE, RES_POOLCOLL_JAKETADRESS, RES_POOLCOLL_SENDADRESS,
        RES_NONE, RES_NONE,

        RES_NONE, RES_NONE, RES_NONE, RES_POOLCOLL_ENDNOTE, RES_NONE, RES_NONE, RES_NONE,
        RES_POOLCOLL_LISTS_BEGIN, RES_NONE, RES_NONE,

        RES_NONE, RES_NONE, RES_NONE, RES_NONE, RES_NONE,
        RES_NONE, RES_NONE, RES_NONE, RES_NONE, RES_NONE,

        RES_NONE,RES_NONE, RES_POOLCOLL_DOC_TITEL, RES_NONE, RES_POOLCOLL_SIGNATURE, RES_NONE,
        RES_POOLCOLL_TEXT, RES_POOLCOLL_TEXT_MOVE, RES_NONE, RES_NONE,

        RES_NONE, RES_NONE, RES_NONE, RES_NONE, RES_POOLCOLL_DOC_SUBTITEL };


    ASSERT( ( sizeof( aArr ) / sizeof( RES_POOL_COLLFMT_TYPE ) == 75 ),
            "Style-UEbersetzungstabelle hat falsche Groesse" );

    if( pStd->sti < sizeof( aArr ) / sizeof( RES_POOL_COLLFMT_TYPE )
        && aArr[pStd->sti]!=RES_NONE    // Default-Style bekannt
        && !( pIo->nIniFlags & WW8FL_NO_DEFSTYLES ) ) // nicht abgeschaltet
    {
        SwTxtFmtColl* pCol =
            pIo->rDoc.GetTxtCollFromPoolSimple(aArr[pStd->sti], false);
        if(pCol)
        {
            *pbStyExist = true;
            return pCol;
        }
    }
    String aName( rName );
    xub_StrLen nPos = aName.Search( ',' );
    if( STRING_NOTFOUND != nPos )   // mehrere Namen mit Komma getrennt
        aName.Erase( nPos );        // gibts im SW nicht
    SwTxtFmtColl* pCol = SearchFmtColl( aName );
    if( pCol )
    {
        *pbStyExist = true;
        return pCol;
    }
    *pbStyExist = false;
    return MakeNewFmtColl( pStd, aName );   // nicht gefunden
}

void WW8RStyle::Import1Style( USHORT nNr )
{
    SwWW8StyInf* pSI = &pIo->pCollA[nNr];

    if( pSI->bImported || !pSI->bValid )
        return;

    pSI->bImported = true;                      // jetzt schon Flag setzen
                                                // verhindert endlose Rekursion
                                                //
    // gueltig und nicht NIL und noch nicht Importiert

    if( pSI->nBase < cstd && !pIo->pCollA[pSI->nBase].bImported )
        Import1Style( pSI->nBase );

    pStStrm->Seek( pSI->nFilePos );

    short nSkip, cbStd;
    String sName;

    WW8_STD* pStd = Read1Style( nSkip, &sName, &cbStd );// lies Style

    if (pStd)
        pSI->SetOrgWWIdent( sName, pStd->sti );

    // either no Name or unused Slot or unknown Style

    if ( !pStd || (0 == sName.Len()) || ((1 != pStd->sgc) && (2 != pStd->sgc)) )
    {
        pStStrm->SeekRel( nSkip );
        return;
    }
                                                // echter Para- oder Char-Style
    SwFmt* pColl;
    bool bStyExist;
    if (pStd->sgc == 1)             // Para-Style
        pColl = MakeOrGetFmtColl( &bStyExist, pStd, sName );
    else                                // Char-Style
        pColl = MakeOrGetCharFmt( &bStyExist, pStd, sName );

    bool bImport = !bStyExist || pIo->mbNewDoc; // Inhalte Importieren ?
    bool bOldNoImp = pIo->bNoAttrImport;
    pSI->bImportSkipped = !bImport;

    if( !bImport )
        pIo->bNoAttrImport = true;
    else
    {
        if (bStyExist)
            pColl->ResetAllAttr();
        pColl->SetAuto(false);          // nach Empfehlung JP
    }                                   // macht die UI aber anders
    pIo->pAktColl = pColl;
    pSI->pFmt = pColl;                  // UEbersetzung WW->SW merken
    pSI->bImportSkipped = !bImport;

    // Setze Based on
    USHORT j = pSI->nBase;
    if (j != nNr && j < cstd )
    {
        SwWW8StyInf* pj = &pIo->pCollA[j];
        if (pSI->pFmt && pj->pFmt && pSI->bColl == pj->bColl)
        {
            pSI->pFmt->SetDerivedFrom( pj->pFmt );  // ok, Based on eintragen
            pSI->eFontSrcCharSet = pj->eFontSrcCharSet; // CharSet als Default
            pSI->nLeftParaMgn = pj->nLeftParaMgn;
            pSI->nTxtFirstLineOfst = pj->nTxtFirstLineOfst;
            pSI->n81Flags = pj->n81Flags;
            pSI->n81BiDiFlags = pj->n81BiDiFlags;

            if (pj->pWWFly)
                pSI->pWWFly = new WW8FlyPara(pIo->bVer67, pj->pWWFly);
        }
    }
    else if( pIo->mbNewDoc && bStyExist )
    {
        if( pStd->sgc == 1 )
            pSI->pFmt->SetDerivedFrom( pIo->pStandardFmtColl );
        else
            pSI->pFmt->SetDerivedFrom( pIo->rDoc.GetDfltCharFmt() );
    }

    pSI->nFollow = pStd->istdNext;              // Follow merken

    long nPos = pStStrm->Tell();        // falls etwas falsch interpretiert
                                    // wird, gehts danach wieder richtig

    pStyRule = 0;                   // falls noetig, neu anlegen
    bTxtColChanged = bFontChanged = bCJKFontChanged = bCTLFontChanged =
        bFSizeChanged = bFCTLSizeChanged = bWidowsChanged = false;
    pIo->SetNAktColl( nNr );
    pIo->bStyNormal = nNr == 0;

    if( pStd && ( pStd->sgc == 1 || pStd->sgc == 2 ) )
    {
        //Variable parts of the STD start at even byte offsets, but "inside
        //the STD", which I take to meaning even in relation to the starting
        //position of the STD, which matches findings in #89439#, generally it
        //doesn't matter as the STSHI starts off nearly always on an even
        //offset

        //Import of the Style Contents
        ImportGrupx( nSkip, pStd->sgc == 1, pSI->nFilePos & 1);
                        // Alle moeglichen Attribut-Flags zuruecksetzen,
                        // da es in Styles keine Attr-Enden gibt
        pIo->bHasBorder = pIo->bShdTxtCol = pIo->bCharShdTxtCol
        = pIo->bSpec = pIo->bObj = pIo->bSymbol = false;
        pIo->nCharFmt = -1;
    }


    // If Style basiert auf Nichts oder Basis ignoriert
    if( pStd && (pSI->nBase >= cstd || pIo->pCollA[pSI->nBase].bImportSkipped)
        && pStd->sgc == 1 )
    {
        //! Char-Styles funktionieren aus
        // unerfindlichen Gruenden nicht
        // -> dann evtl. harte WW-Defaults
        // reinsetzen
        Set1StyleDefaults();
    }

    pStyRule = 0;                   // zur Sicherheit
    pIo->bStyNormal = false;
    pIo->SetNAktColl( 0 );
    pIo->bNoAttrImport = bOldNoImp;
    // rasch nochmal die Listen-Merk-Felder zuruecksetzen,
    // fuer den Fall dass sie beim einlesen des Styles verwendet wurden
    pIo->nLFOPosition = USHRT_MAX;
    pIo->nListLevel = WW8ListManager::nMaxLevel;

    pStStrm->Seek( nPos+nSkip );

    DELETEZ( pStd );
}

void WW8RStyle::RecursiveReg(USHORT nNr)
{
    SwWW8StyInf* pSI = &pIo->pCollA[nNr];
    if (pSI)
    {
        if( pSI->bImported || !pSI->bValid )
            return;

        pSI->bImported = true;

        if( pSI->nBase < cstd && !pIo->pCollA[pSI->nBase].bImported )
            RecursiveReg(pSI->nBase);

        pIo->RegisterNumFmtOnStyle(nNr);
        pIo->NeedAdjustStyleTabStops(pIo->pCollA[nNr].nLeftParaMgn,
            pIo->pCollA[nNr].nTxtFirstLineOfst,pSI);
    }
}

/*
 After all styles are imported then we can recursively apply numbering
 styles to them, and change their tab stop settings if they turned out
 to have special first line indentation.
*/
void WW8RStyle::PostProcessStyles()
{
    USHORT i;
    /*
     Clear all imported flags so that we can recursively apply numbering
     formats and use it to mark handled ones
    */
    for(i=0; i < cstd; i++)
    {
        SwWW8StyInf* pSI = &pIo->pCollA[ i ];
        pSI->bImported = false;
    }

    /*
     Register the num formats and tabstop changes on the styles recursively.
    */

    /*
     In the same loop apply the tabstop changes required because we need to
     change their location if theres a special indentation for the first line,
     By avoiding making use of each styles margins during reading of their
     tabstops we don't get problems with doubly adjusting tabstops that
     are inheritied.
    */
    for(i=0; i < cstd; i++)
        if( pIo->pCollA[i].bValid )
            RecursiveReg( i );
}


void WW8RStyle::ScanStyles()        // untersucht Style-Abhaengigkeiten
{                               // und ermittelt die Filepos fuer jeden Style
/*
    WW8_FC nStyleStart = rFib.fcStshf;
    pStStrm->Seek( nStyleStart );
    */
    USHORT i;
    for( i=0; i<cstd; i++ ){
        short nSkip;
        SwWW8StyInf* pSI = &pIo->pCollA[i];

        pSI->nFilePos = pStStrm->Tell();        // merke FilePos
        WW8_STD* pStd = Read1Style( nSkip, 0, 0 );  // read STD
        pSI->bValid   = ( 0 != pStd );
        if( pSI->bValid
            && !(pStd->sgc == 2 && ( pIo->nIniFlags & WW8FL_NO_ZSTYLES ) ) ){
            pSI->nBase = pStd->istdBase;        // merke Basis
            pSI->bColl = ( pStd->sgc == 1 );    // Para-Style
            pSI->bValid = true;
        }
        else
            memset( &pSI , 0, sizeof( &pSI ) );

        delete pStd;
        pStStrm->SeekRel( nSkip );              // ueberlese Namen und Sprms
    }
}

void WW8RStyle::Import()
{
    pIo->pDfltTxtFmtColl  = pIo->rDoc.GetDfltTxtFmtColl();
    pIo->pStandardFmtColl =
        pIo->rDoc.GetTxtCollFromPoolSimple(RES_POOLCOLL_STANDARD, false);

    if( pIo->nIniFlags & WW8FL_NO_STYLES )
        return;

    ScanStyles();                       // Scanne Based On

    USHORT i;
    for( i=0; i<cstd; i++ ) // Styles importieren
        if( pIo->pCollA[i].bValid )
            Import1Style( i );

    for( i=0; i<cstd; i++ )
    {   // Follow einstellen
        SwWW8StyInf* pi = &pIo->pCollA[i];
        USHORT j = pi->nFollow;
        if( j < cstd )
        {
            SwWW8StyInf* pj = &pIo->pCollA[j];
            if ( j != i                             // sinnvoller Index ?
                 && pi->pFmt                        // Format ok ?
                 && pj->pFmt                        // Derived-Format ok ?
                 && pi->bColl                       // geht nur bei Absatz-Vorlagen (WW)
                 && pj->bColl ){                    // beides gleicher Typ ?
                    ( (SwTxtFmtColl*)pi->pFmt )->SetNextTxtFmtColl(
                     *(SwTxtFmtColl*)pj->pFmt );    // ok, eintragen
            }
        }
    }
// Die Sonderbehandlung zur Setzen der
// Default-Zeichenvorlage "Absatz-Standardschriftart" ( Style-ID 65 ) fehlt
// Sie ist aber defaultmaessig leer ( WW6 dt und US ) und von der
// WW-UI nicht zu veraendern, so dass das nicht stoert.
// Der Mechanismus waere folgender:
//  if( bNew ) rDoc.SetDefault( pDefCharFmt->GetAttrSet() );
//
    // fuer z.B. Tabellen wird ein immer gueltiger Std-Style gebraucht

    if( pIo->pCollA[0].pFmt && pIo->pCollA[0].bColl && pIo->pCollA[0].bValid )
        pIo->pDfltTxtFmtColl = (SwTxtFmtColl*)pIo->pCollA[0].pFmt;
    else
        pIo->pDfltTxtFmtColl = pIo->rDoc.GetDfltTxtFmtColl();


    // set Hyphenation flag on BASIC para-style
    if (pIo->mbNewDoc && pIo->pStandardFmtColl)
    {
        if (pIo->pWDop->fAutoHyphen
            && SFX_ITEM_SET != pIo->pStandardFmtColl->GetItemState(
                                            RES_PARATR_HYPHENZONE, false) )
        {
            SvxHyphenZoneItem aAttr(true);
            aAttr.GetMinLead()    = 2;
            aAttr.GetMinTrail()   = 2;
            aAttr.GetMaxHyphens() = 0;

            pIo->pStandardFmtColl->SetAttr( aAttr );
        }

        /*
        Word defaults to ltr not from environment like writer. Regardless of
        the page/sections rtl setting the standard style lack of rtl still
        means ltr
        */
        if (SFX_ITEM_SET != pIo->pStandardFmtColl->GetItemState(RES_FRAMEDIR,
            false))
        {
           pIo->pStandardFmtColl->SetAttr(
                SvxFrameDirectionItem(FRMDIR_HORI_LEFT_TOP));
        }
    }

    // wir sind jetzt nicht mehr beim Style einlesen:
    pIo->pAktColl = 0;
}


//-----------------------------------------
//      Document Info
//-----------------------------------------

// ReadDocInfo() liegt hier und nicht nicht in wwpar.cxx::LoadDoc1(),
// da hier das noetige sfxcore.hxx bereits includet ist.

void SwWW8ImplReader::ReadDocInfo()
{
    if( pStg )
    {
        SfxDocumentInfo* pNeu;
        if( rDoc.GetpInfo() )                           // soo ein Umstand......
            pNeu = new SfxDocumentInfo( *rDoc.GetpInfo() );
        else
            pNeu = new SfxDocumentInfo();

        pNeu->LoadPropertySet( pStg );  // DocInfo laden
        rDoc.SetInfo( *pNeu );
        delete pNeu;
    }
}