File: sprm.c

package info (click to toggle)
wv 1.0.2-0.1
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 6,428 kB
  • ctags: 6,733
  • sloc: ansic: 59,221; sh: 9,998; xml: 1,677; makefile: 36
file content (3145 lines) | stat: -rw-r--r-- 93,866 bytes parent folder | download
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
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <string.h>
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "wv.h"

/*
void wvToggle(int ret,CHP *in,STSH *stsh,U8 toggle,type)

When the parameter of the sprm is set to 0 or 1, then
the CHP property is set to the parameter value.

*/

/*
When the parameter of the sprm is 128, then the CHP property is set to the
value that is stored for the property in the style sheet. CHP When the
parameter of the sprm is 129, the CHP property is set to the negation of the
value that is stored for the property in the style sheet CHP.
sprmCFBold through sprmCFVanish are stored only in grpprls linked to piece table
entries.


*/

/*
an argument might be made that instead of in being returned or negated that
it should be the looked up in the original chp through the istd that should
be used, in which case this should be a macro that does the right thing.
but im uncertain as to which is the correct one to do, ideas on a postcard
to... etc etc

This argument which i left as a comment to the original function has been
bourne out in practice, so i converted this to a macro and did a lookup
on the original unmodified chp in the stylesheet to check against

Interestingly enough, even though the spec says that these are only used
in piece table grpprls this is untrue, examples/doc-that-needs-utf8.doc
has them in the stylesheet definition portion, which is a serious problem
as the style that must be checked is not generated before this modifier
comes along, a real nuisance.
*/

#define wvTOGGLE(ret,in,stsh,toggle,type) \
	{ \
	CHP ctemp; \
	if ((toggle == 0) || (toggle == 1))  \
		ret = toggle; \
	else \
		{ \
		\
		wvInitCHPFromIstd(&ctemp,in->istd,stsh); \
	\
		if (toggle == 128) \
			ret = ctemp.type; \
		else if (toggle == 129) \
			ret = !ctemp.type; \
		else \
			wvWarning("Strangle sprm toggle value, ignoring\n"); \
		} \
	}


/*
 spra value operand size
 0          1 byte (operand affects 1 bit)
 1          1 byte
 2          2 bytes
 3          4 bytes
 4          2 bytes
 5          2 bytes
 6          variable length -- following byte is size of operand
 7          3 bytes
*/
int
wvSprmLen (int spra)
{
    switch (spra)
      {
      case 0:
      case 1:
	  return (1);
      case 2:
      case 4:
      case 5:
	  return (2);
      case 7:
	  return (3);
      case 3:
	  return (4);
      case 6:
	  return (-1);
	  /*variable length -- following byte is size of operand */
      default:
	  wvError (("Incorrect spra value %d\n", spra));
      }
    return (-2);
}

void
wvInitSprm (Sprm * aSprm)
{
    aSprm->ispmd = 0;
    aSprm->fSpec = 0;
    aSprm->sgc = 0;
    aSprm->spra = 0;
}

void
wvGetSprmFromU16 (Sprm * aSprm, U16 sprm)
{
#ifdef PURIFY
    wvInitSprm (aSprm);
#endif
    aSprm->ispmd = sprm & 0x01ff;
    aSprm->fSpec = (sprm & 0x0200) >> 9;
    aSprm->sgc = (sprm & 0x1c00) >> 10;
    aSprm->spra = (sprm & 0xe000) >> 13;
}

#undef EXAMINE_SPRM
U8
wvEatSprm (U16 sprm, U8 * pointer, U16 * pos)
{
    int len;
    Sprm aSprm;
#ifdef EXAMINE_SPRM
	U8 temp[256];
	U16 p;
	U8  *pi;
	int i;
#endif
    wvTrace (("Eating sprm %x\n", sprm));
    wvGetSprmFromU16 (&aSprm, sprm);
    if (sprm == sprmPChgTabs)
      {
	  wvTrace (("sprmPChgTabs\n"));
	  len = wvApplysprmPChgTabs (NULL, pointer, pos);
	  len++;
	  return (len);
      }
    else if ((sprm == sprmTDefTable) || (sprm == sprmTDefTable10))
      {
	  wvTrace (("sprmTDefTable\\sprmTDefTable10\n"));
	  len = bread_16ubit (pointer, pos);
	  len--;
      }
	else
      {
	  len = wvSprmLen (aSprm.spra);
#ifdef EXAMINE_SPRM
	  i = 0;
	  p = *pos;
	  pi = pointer;
#endif
	  wvTrace (("wvSprmLen len is %d\n", len));
	  if (len < 0)
	    {
		len = bread_8ubit (pointer, pos);
		/* bread increased pos, but in order to keep len and pos in
		   sync later on, we have to decreased it again */
		(*pos)--;
#ifdef EXAMINE_SPRM
		pi++;
		while(i < sizeof(temp) && i < len)
		{
			temp[i] = bread_8ubit(pi, &p);
			pi++;
			i++;
		}
#endif
		len++;
	    }
#ifdef EXAMINE_SPRM
	  else
	  {
		while(i < sizeof(temp) && i < len)
		{
			temp[i] = bread_8ubit(pi, &p);
			pi++;
			i++;
		}
	  }
#endif
      }
    (*pos) += len;
    return (len);
}
#undef EXAMINE_SPRM

Sprm
wvApplySprmFromBucket (wvVersion ver, U16 sprm, PAP * apap, CHP * achp,
		       SEP * asep, STSH * stsh, U8 * pointer, U16 * pos,
		       wvStream * data)
{
    BRC10 tempBRC10;
    U16 temp16;
    U8 temp8;
    PAP temppap;
    CHP tempchp;
    SEP tempsep;
    U8 toggle;
    Sprm RetSprm;

    /*bullet proofing */
    if (apap == NULL)
      {
	  wvInitPAP (&temppap);
	  apap = &temppap;
      }
    if (achp == NULL)
      {
	  wvInitCHP (&tempchp);
	  achp = &tempchp;
      }
    if (asep == NULL)
      {
#ifdef PURIFY
	  wvInitSEP (&tempsep);
#endif
	  asep = &tempsep;
      }
#ifdef SPRMTEST
    wvError (("sprm is %x\n", sprm));
#endif

    switch (sprm)
      {
	  /*Beginning of PAP */
      case sprmPIstd:
	  apap->istd = bread_16ubit (pointer, pos);
	  break;
      case sprmPIstdPermute:
	  wvApplysprmPIstdPermute (apap, pointer, pos);
	  break;
      case sprmPIncLvl:
	  wvApplysprmPIncLvl (apap, pointer, pos);
	  break;
      case sprmPJc:
	  apap->jc = bread_8ubit (pointer, pos);
	  wvTrace (("jc is now %d\n", apap->jc));
	  break;
      case sprmPFSideBySide:
	  apap->fSideBySide = bread_8ubit (pointer, pos);
	  break;
      case sprmPFKeep:
	  apap->fKeep = bread_8ubit (pointer, pos);
	  break;
      case sprmPFKeepFollow:
	  apap->fKeepFollow = bread_8ubit (pointer, pos);
	  break;
      case sprmPFPageBreakBefore:
	  apap->fPageBreakBefore = bread_8ubit (pointer, pos);
	  break;
      case sprmPBrcl:
	  apap->brcl = bread_8ubit (pointer, pos);
	  break;
      case sprmPBrcp:
	  apap->brcp = bread_8ubit (pointer, pos);
	  break;
      case sprmPIlvl:
	  apap->ilvl = bread_8ubit (pointer, pos);
	  break;
      case sprmPIlfo:
	  apap->ilfo = (S16) bread_16ubit (pointer, pos);
	  wvTrace (("ilfo is %d\n", apap->ilfo));
	  break;
      case sprmPFNoLineNumb:
	  apap->fNoLnn = bread_8ubit (pointer, pos);
	  break;
      case sprmPChgTabsPapx:
	  wvApplysprmPChgTabsPapx (apap, pointer, pos);
	  break;
      case sprmPDxaRight:
	  apap->dxaRight = (S16) bread_16ubit (pointer, pos);
	  break;
      case sprmPDxaLeft:
	  apap->dxaLeft = (S16) bread_16ubit (pointer, pos);
	  break;
      case sprmPNest:
	  /*
	     sprmPNest (opcode 0x4610) causes its operand, a two-byte dxa value to be
	     added to pap.dxaLeft. If the result of the addition is less than 0, 0 is
	     stored into pap.dxaLeft.
	   */
	  temp16 = (S16) bread_16ubit (pointer, pos);
	  apap->dxaLeft += temp16;
	  if (apap->dxaLeft < 0)
	      apap->dxaLeft = 0;
	  break;
      case sprmPDxaLeft1:
	  apap->dxaLeft1 = (S16) bread_16ubit (pointer, pos);
	  break;
      case sprmPDyaLine:
	  wvGetLSPDFromBucket (&apap->lspd, pointer);
	  (*pos) += 4;
	  break;
      case sprmPDyaBefore:
	  apap->dyaBefore = bread_16ubit (pointer, pos);
	  break;
      case sprmPDyaAfter:
	  apap->dyaAfter = bread_16ubit (pointer, pos);
	  break;
      case sprmPChgTabs:
	  wvApplysprmPChgTabs (apap, pointer, pos);
	  break;
      case sprmPFInTable:
	  apap->fInTable = bread_8ubit (pointer, pos);
	  break;
      case sprmPFTtp:
	  apap->fTtp = bread_8ubit (pointer, pos);
	  break;
      case sprmPDxaAbs:
	  apap->dxaAbs = (S16) bread_16ubit (pointer, pos);
	  break;
      case sprmPDyaAbs:
	  apap->dyaAbs = (S16) bread_16ubit (pointer, pos);
	  break;
      case sprmPDxaWidth:
	  apap->dxaWidth = (S16) bread_16ubit (pointer, pos);
	  break;
      case sprmPPc:
	  wvApplysprmPPc (apap, pointer, pos);
	  break;
      case sprmPBrcTop10:
	  wvGetBRC10FromBucket (&tempBRC10, pointer);
	  (*pos) += 2;
	  wvConvertBRC10ToBRC (&apap->brcTop, &tempBRC10);
	  break;
      case sprmPBrcLeft10:
	  wvGetBRC10FromBucket (&tempBRC10, pointer);
	  (*pos) += 2;
	  wvConvertBRC10ToBRC (&apap->brcLeft, &tempBRC10);
	  break;
      case sprmPBrcBottom10:
	  wvGetBRC10FromBucket (&tempBRC10, pointer);
	  (*pos) += 2;
	  wvConvertBRC10ToBRC (&apap->brcBottom, &tempBRC10);
	  break;
      case sprmPBrcRight10:
	  wvGetBRC10FromBucket (&tempBRC10, pointer);
	  (*pos) += 2;
	  wvConvertBRC10ToBRC (&apap->brcRight, &tempBRC10);
	  break;
      case sprmPBrcBetween10:
	  wvGetBRC10FromBucket (&tempBRC10, pointer);
	  (*pos) += 2;
	  wvConvertBRC10ToBRC (&apap->brcBetween, &tempBRC10);
	  break;
      case sprmPBrcBar10:
	  wvGetBRC10FromBucket (&tempBRC10, pointer);
	  (*pos) += 2;
	  wvConvertBRC10ToBRC (&apap->brcBar, &tempBRC10);
	  break;
      case sprmPDxaFromText10:
	  apap->dxaFromText = (S16) bread_16ubit (pointer, pos);
	  break;
      case sprmPWr:
	  apap->wr = bread_8ubit (pointer, pos);
	  break;
      case sprmPBrcTop:
	  (*pos) += wvGetBRCFromBucket (ver, &apap->brcTop, pointer);
	  break;
      case sprmPBrcLeft:
	  (*pos) += wvGetBRCFromBucket (ver, &apap->brcLeft, pointer);
	  break;
      case sprmPBrcBottom:
	  (*pos) += wvGetBRCFromBucket (ver, &apap->brcBottom, pointer);
	  break;
      case sprmPBrcRight:
	  (*pos) += wvGetBRCFromBucket (ver, &apap->brcRight, pointer);
	  break;
      case sprmPBrcBetween:
	  (*pos) += wvGetBRCFromBucket (ver, &apap->brcBetween, pointer);
	  break;
      case sprmPBrcBar:
	  (*pos) += wvGetBRCFromBucket (ver, &apap->brcBar, pointer);
	  break;
      case sprmPFNoAutoHyph:
	  apap->fNoAutoHyph = bread_8ubit (pointer, pos);
	  break;
      case sprmPWHeightAbs:
	  /* ???? apap->wHeightAbs */
	  (*pos) += 2;
	  break;
      case sprmPDcs:
	  wvGetDCSFromBucket (&apap->dcs, pointer);
	  (*pos) += 2;
	  break;
      case sprmPShd:
	  wvGetSHDFromBucket (&apap->shd, pointer);
	  (*pos) += 2;
	  break;
      case sprmPDyaFromText:
	  apap->dyaFromText = (S16) bread_16ubit (pointer, pos);
	  break;
      case sprmPDxaFromText:
	  apap->dxaFromText = (S16) bread_16ubit (pointer, pos);
	  break;
      case sprmPFLocked:
	  apap->fLocked = bread_8ubit (pointer, pos);
	  break;
      case sprmPFWidowControl:
	  apap->fWidowControl = bread_8ubit (pointer, pos);
	  break;
      case sprmPFKinsoku:
	  apap->fKinsoku = bread_8ubit (pointer, pos);
	  break;
      case sprmPFWordWrap:
	  apap->fWordWrap = bread_8ubit (pointer, pos);
	  break;
      case sprmPFOverflowPunct:
	  apap->fOverflowPunct = bread_8ubit (pointer, pos);
	  break;
      case sprmPFTopLinePunct:
	  apap->fTopLinePunct = bread_8ubit (pointer, pos);
	  break;
      case sprmPFAutoSpaceDE:
	  apap->fAutoSpaceDE = bread_8ubit (pointer, pos);
	  break;
      case sprmPFAutoSpaceDN:
	  /* ???? apap->fAutoSpaceDN */
	  (*pos)++;
	  break;
      case sprmPWAlignFont:
	  apap->wAlignFont = (S16) bread_16ubit (pointer, pos);
	  break;
      case sprmPFrameTextFlow:
	  wvApplysprmPFrameTextFlow (apap, pointer, pos);
	  break;
      case sprmPISnapBaseLine:
	  /*obsolete: not applicable in Word97 and later versions */
	  (*pos)++;
	  break;
      case sprmPNLvlAnm:
	  /*obsolete: not applicable in Word97 and later version */
	  apap->nLvlAnm = bread_8ubit (pointer, pos);
	  wvTrace (("%d\n", apap->nLvlAnm));
	  break;
      case sprmPAnld:
	  wvApplysprmPAnld (ver, apap, pointer, pos);
	  break;
      case sprmPPropRMark:
	  wvApplysprmPPropRMark (apap, pointer, pos);
	  break;
      case sprmPOutLvl:
	  /*has no effect if pap.istd is < 1 or is > 9 */
	  temp8 = bread_8ubit (pointer, pos);
	  if ((apap->istd >= 1) && (apap->istd <= 9))
	      apap->lvl = temp8;
	  break;
      case sprmPFBiDi:
	apap->fBidi = bread_8ubit (pointer, pos);
	break;
      case sprmPFNumRMIns:
	  apap->fNumRMIns = bread_8ubit (pointer, pos);
	  break;
      case sprmPCrLf:
	  /* ???? */
	  (*pos)++;
	  break;
      case sprmPNumRM:
	  wvApplysprmPNumRM (apap, pointer, pos);
	  break;
      case sprmPHugePapx2:
      case sprmPHugePapx:
	  wvApplysprmPHugePapx (apap, pointer, pos, data, stsh);
	  break;
      case sprmPFUsePgsuSettings:
	  apap->fUsePgsuSettings = bread_8ubit (pointer, pos);
	  break;
      case sprmPFAdjustRight:
	  apap->fAdjustRight = bread_8ubit (pointer, pos);
	  break;
	  /*End of PAP */


	  /*Begin of CHP */
      case sprmCFRMarkDel:
	  achp->fRMarkDel = bread_8ubit (pointer, pos);
	  break;
      case sprmCFRMark:
	  achp->fRMark = bread_8ubit (pointer, pos);
	  break;
      case sprmCFFldVanish:
	  achp->fFldVanish = bread_8ubit (pointer, pos);
	  break;
      case sprmCPicLocation:
	  if (ver != WORD8)
	    {
		wvTrace (("byte is %x\n", bread_8ubit (pointer, pos)));
		pointer++;
	    }
	  /*
	     This sprm moves the 4-byte operand of the sprm into the
	     chp.fcPic field. It simultaneously sets chp.fSpec to 1.
	   */
	  achp->fcPic_fcObj_lTagObj = bread_32ubit (pointer, pos);
	  wvTrace (("Len is %x\n", achp->fcPic_fcObj_lTagObj));
	  achp->fSpec = 1;
	  break;
      case sprmCIbstRMark:
	  achp->ibstRMark = (S16) bread_16ubit (pointer, pos);
	  break;
      case sprmCDttmRMark:
	  wvGetDTTMFromBucket (&achp->dttmRMark, pointer);
	  (*pos) += 4;
	  break;
      case sprmCFData:
	  achp->fData = bread_8ubit (pointer, pos);
	  break;
      case sprmCIdslRMark:
	  achp->idslRMReason = (S16) bread_16ubit (pointer, pos);
	  break;
      case sprmCChs:
	  wvApplysprmCChs (achp, pointer, pos);
	  break;
      case sprmCSymbol:
	  wvApplysprmCSymbol (ver, achp, pointer, pos);
	  break;
      case sprmCFOle2:
	  achp->fOle2 = bread_8ubit (pointer, pos);
	  break;
      case sprmCHighlight:
	  /* ico (fHighlight is set to 1 iff ico is not 0) */
	  achp->icoHighlight = bread_8ubit (pointer, pos);
	  if (achp->icoHighlight)
	      achp->fHighlight = 1;	/*? */

	  /*another possibility is... */
	  /* if (achp->ico) achp->fHighlight = 1; */
	  /*
	     or is it something else, who knows the entire documentation on
	     the topic consist of the if and only if (iff) line, or maybe
	     iff is a type for if, who knows eh ?
	   */
	  break;
      case sprmCObjLocation:
	  achp->fcPic_fcObj_lTagObj = (S32) bread_32ubit (pointer, pos);
	  break;
      case sprmCIstd:
	  achp->istd = bread_16ubit (pointer, pos);
	  break;
      case sprmCIstdPermute:
	  wvApplysprmCIstdPermute (achp, pointer, pos);	/*unfinished */
	  break;
      case sprmCDefault:
	  wvApplysprmCDefault (achp, pointer, pos);
	  break;
      case sprmCPlain:
	  wvApplysprmCPlain (achp, stsh);
	  break;
      case sprmCFBold:
	  toggle = bread_8ubit (pointer, pos);
	  wvTrace (("toggle here is %d, istd is %d\n", toggle, achp->istd));
	  wvTOGGLE (achp->fBold, achp, stsh, toggle, fBold) break;
      case sprmCFItalic:
	  toggle = bread_8ubit (pointer, pos);
	  wvTrace (("Italic is %d, sprm val is %d\n", achp->fItalic, toggle));
	  wvTOGGLE (achp->fItalic, achp, stsh, toggle, fItalic)
	      wvTrace (("Italic is now %d\n", achp->fItalic));
	  break;
      case sprmCFStrike:
	  toggle = bread_8ubit (pointer, pos);
	  wvTOGGLE (achp->fStrike, achp, stsh, toggle, fStrike) break;
      case sprmCFOutline:
	  toggle = bread_8ubit (pointer, pos);
	  wvTOGGLE (achp->fOutline, achp, stsh, toggle, fOutline) break;
      case sprmCFShadow:
	  toggle = bread_8ubit (pointer, pos);
	  wvTOGGLE (achp->fShadow, achp, stsh, toggle, fShadow) break;
      case sprmCFSmallCaps:
	  toggle = bread_8ubit (pointer, pos);
	  wvTOGGLE (achp->fSmallCaps, achp, stsh, toggle, fSmallCaps) break;
      case sprmCFCaps:
	  toggle = bread_8ubit (pointer, pos);
	  wvTOGGLE (achp->fCaps, achp, stsh, toggle, fCaps) break;
      case sprmCFVanish:
	  wvTrace (("vanish modified\n"));
	  toggle = bread_8ubit (pointer, pos);
	  wvTOGGLE (achp->fVanish, achp, stsh, toggle, fVanish) break;
      case sprmCFtcDefault:
	  toggle = bread_8ubit (pointer, pos);
	  wvTOGGLE (achp->fBold, achp, stsh, toggle, fBold) break;
      case sprmCKul:
	  achp->kul = bread_8ubit (pointer, pos);
	  break;
      case sprmCSizePos:
	  wvApplysprmCSizePos (achp, pointer, pos);
	  break;
      case sprmCDxaSpace:
	  achp->dxaSpace = (S16) bread_16ubit (pointer, pos);
	  break;
      case sprmCIco:
	  achp->ico = bread_8ubit (pointer, pos);
	  break;
      case sprmCHps:
	  /*incorrect marked as being a byte in docs ? */
	  achp->hps = bread_16ubit (pointer, pos);
	  break;
      case sprmCHpsInc:
	  wvApplysprmCHpsInc (achp, pointer, pos);
	  break;
      case sprmCHpsPos:
	  /*incorrect marked as being a byte in docs ? */
	  achp->hpsPos = bread_16ubit (pointer, pos);
	  break;
      case sprmCHpsPosAdj:
	  wvApplysprmCHpsPosAdj (achp, pointer, pos);
	  break;
      case sprmCMajority:
	  wvApplysprmCMajority (achp, stsh, pointer, pos);
	  break;
      case sprmCIss:
	  achp->iss = bread_8ubit (pointer, pos);
	  break;
      case sprmCHpsNew50:
	  bread_8ubit (pointer, pos);
	  achp->hps = bread_16ubit (pointer, pos);
	  break;
      case sprmCHpsInc1:
	  wvApplysprmCHpsInc1 (achp, pointer, pos);
	  break;
      case sprmCHpsKern:
	  /*the spec would you have you believe that this is a U8 */
	  achp->hpsKern = bread_16ubit (pointer, pos);
	  break;
      case sprmCMajority50:
	  wvApplysprmCMajority50 (achp, stsh, pointer, pos);
	  break;
      case sprmCHpsMul:
	  /*percentage to grow hps ?? */
	  achp->hps = achp->hps * bread_16ubit (pointer, pos) / 100;
	  break;
      case sprmCYsri:
	  /* ???? achp->ysri */
	  bread_8ubit (pointer, pos);
	  break;
      case sprmCRgFtc0:
	  achp->ftcAscii = bread_16ubit (pointer, pos);
	  break;
      case sprmCRgFtc1:
	  achp->ftcFE = bread_16ubit (pointer, pos);
	  break;
      case sprmCRgFtc2:
	  achp->ftcOther = bread_16ubit (pointer, pos);
	  break;
      case sprmCFDStrike:
	  achp->fDStrike = bread_8ubit (pointer, pos);
	  break;
      case sprmCFImprint:
	  achp->fImprint = bread_8ubit (pointer, pos);
	  break;
      case sprmCFSpec:
	  achp->fSpec = bread_8ubit (pointer, pos);
	  break;
      case sprmCFObj:
	  achp->fObj = bread_8ubit (pointer, pos);
	  break;
      case sprmCPropRMark:
	  wvApplysprmCPropRMark (achp, pointer, pos);
	  break;
      case sprmCFEmboss:
	  achp->fEmboss = bread_8ubit (pointer, pos);
	  break;
      case sprmCSfxText:
	  achp->sfxtText = bread_8ubit (pointer, pos);
	  break;
      case sprmCDispFldRMark:
	  wvApplysprmCDispFldRMark (achp, pointer, pos);
	  break;
      case sprmCIbstRMarkDel:
	  achp->ibstRMarkDel = (S16) bread_16ubit (pointer, pos);
	  break;
      case sprmCDttmRMarkDel:
	  wvGetDTTMFromBucket (&achp->dttmRMarkDel, pointer);
	  (*pos) += 4;
	  break;
      case sprmCBrc:
	  (*pos) += wvGetBRCFromBucket (ver, &achp->brc, pointer);
	  break;
      case sprmCShd:
	  wvGetSHDFromBucket (&achp->shd, pointer);
	  (*pos) += 2;
      case sprmCIdslRMarkDel:
	  /* achp->idslRMReasonDel ???? */
	  (S16) bread_16ubit (pointer, pos);
	  break;
      case sprmCFUsePgsuSettings:
	  achp->fUsePgsuSettings = bread_8ubit (pointer, pos);
	  break;
      case sprmCRgLid0:
	  achp->lidDefault = bread_16ubit (pointer, pos);
	  break;
      case sprmCRgLid1:
	  achp->lidFE = bread_16ubit (pointer, pos);
	  break;
      case sprmCIdctHint:
	  achp->idctHint = bread_8ubit (pointer, pos);
	  break;
      case sprmCFFtcAsciSymb:	/* not fully mentioned in spec */
	  achp->fFtcAsciSym = bread_8ubit (pointer, pos);
	  break;
      case sprmCCpg:		/* not fully mentioned in spec */
	  achp->cpg = bread_16ubit (pointer, pos);
	  break;
      case sprmCLid:		/*
				   only used internally, never stored ( word 97 )
				   but exists in earlier versions so...
				 */
	  achp->lid = bread_16ubit (pointer, pos);
	  achp->lidDefault = achp->lid;
	  achp->lidFE = achp->lid;
	  wvTrace (("lid is %x\n", achp->lidDefault));
	  break;

	  /* BiDi */

      case sprmCFBiDi:		/* is this run BiDi */
	  achp->fBidi = bread_8ubit (pointer, pos);
	  break;

      case sprmCFDiacColor: /* ???? */
	bread_16ubit (pointer, pos);
	break;

      case sprmCFBoldBi:	
	achp->fBoldBidi = bread_8ubit (pointer, pos);
	break;

      case sprmCFItalicBi:
	achp->fItalicBidi = bread_8ubit (pointer, pos);
	break;

      case sprmCFtcBi:
	achp->ftcBidi = bread_16ubit (pointer, pos);
	break;

      case sprmCLidBi:
	achp->lidBidi = bread_16ubit (pointer, pos);
	break;

      case sprmCIcoBi:
	achp->icoBidi = bread_8ubit (pointer, pos);
	break;

      case sprmCHpsBi:
	achp->hpsBidi = bread_16ubit (pointer, pos);
	break;
	  /* End of CHP */


	  /* Begin of SEP */
      case sprmScnsPgn:
	  asep->cnsPgn = bread_8ubit (pointer, pos);
	  break;
      case sprmSiHeadingPgn:
	  asep->iHeadingPgn = bread_8ubit (pointer, pos);
	  break;
      case sprmSOlstAnm:
	  wvApplysprmSOlstAnm (ver, asep, pointer, pos);
	  break;
      case sprmSDxaColWidth:
      case sprmSDxaColSpacing:
	  /* well then no one has docs for these two , they're 3 long
	     but affects (i guess by name) a 89 long array so who
	     knows
	   */
	  bread_8ubit (pointer, pos);
	  bread_8ubit (pointer, pos);
	  bread_8ubit (pointer, pos);
	  break;
      case sprmSFEvenlySpaced:
	  asep->fEvenlySpaced = bread_8ubit (pointer, pos);
	  break;
      case sprmSFProtected:
	  asep->fUnlocked = bread_8ubit (pointer, pos);
	  break;
      case sprmSDmBinFirst:
	  asep->dmBinFirst = bread_16ubit (pointer, pos);
	  break;
      case sprmSDmBinOther:
	  asep->dmBinFirst = bread_16ubit (pointer, pos);
	  break;
      case sprmSBkc:
	  asep->bkc = bread_8ubit (pointer, pos);
	  break;
      case sprmSFTitlePage:
	  asep->fTitlePage = bread_8ubit (pointer, pos);
	  break;
      case sprmSCcolumns:
	  asep->ccolM1 = bread_16ubit (pointer, pos);
	  break;
      case sprmSDxaColumns:
	  asep->dxaColumns = (S16) bread_16ubit (pointer, pos);
	  break;
      case sprmSFAutoPgn:
	  asep->fAutoPgn = bread_8ubit (pointer, pos);
	  break;
      case sprmSNfcPgn:
	  asep->nfcPgn = bread_8ubit (pointer, pos);
	  break;
      case sprmSDyaPgn:
	  asep->dyaPgn = (S16) bread_16ubit (pointer, pos);
	  break;
      case sprmSDxaPgn:
	  asep->dxaPgn = (S16) bread_16ubit (pointer, pos);
	  break;
      case sprmSFPgnRestart:
	  asep->fPgnRestart = bread_8ubit (pointer, pos);
	  break;
      case sprmSFEndnote:
	  asep->fEndNote = bread_8ubit (pointer, pos);
	  break;
      case sprmSLnc:
	  asep->lnc = bread_8ubit (pointer, pos);
	  break;
      case sprmSGprfIhdt:
	  asep->grpfIhdt = bread_8ubit (pointer, pos);
	  break;
      case sprmSNLnnMod:
	  asep->nLnnMod = bread_16ubit (pointer, pos);
	  break;
      case sprmSDxaLnn:
	  asep->dxaLnn = (S16) bread_16ubit (pointer, pos);
	  break;
      case sprmSDyaHdrTop:
	  asep->dyaHdrTop = bread_16ubit (pointer, pos);
	  break;
      case sprmSDyaHdrBottom:
	  asep->dyaHdrBottom = bread_16ubit (pointer, pos);
	  break;
      case sprmSLBetween:
	  asep->fLBetween = bread_8ubit (pointer, pos);
	  break;
      case sprmSVjc:
	  asep->fLBetween = bread_8ubit (pointer, pos);
	  break;
      case sprmSLnnMin:
	  asep->lnnMin = (S16) bread_16ubit (pointer, pos);
	  break;
      case sprmSPgnStart:
	  asep->pgnStart = bread_16ubit (pointer, pos);
	  break;
      case sprmSBOrientation:
	  asep->dmOrientPage = bread_8ubit (pointer, pos);
	  break;
      case sprmSBCustomize:
	  /*noone knows what this is */
	  bread_8ubit (pointer, pos);
	  break;
      case sprmSXaPage:
	  asep->xaPage = bread_16ubit (pointer, pos);
	  break;
      case sprmSYaPage:
	  asep->yaPage = bread_16ubit (pointer, pos);
	  break;
      case sprmSDxaLeft:
	  asep->dxaLeft = bread_16ubit (pointer, pos);
	  break;
      case sprmSDxaRight:
	  asep->dxaRight = bread_16ubit (pointer, pos);
	  break;
      case sprmSDyaTop:
	  asep->dyaTop = (S16) bread_16ubit (pointer, pos);
	  break;
      case sprmSDyaBottom:
	  asep->dyaBottom = (S16) bread_16ubit (pointer, pos);
	  break;
      case sprmSDzaGutter:
	  asep->dzaGutter = bread_16ubit (pointer, pos);
	  break;
      case sprmSDmPaperReq:
	  asep->dmPaperReq = bread_16ubit (pointer, pos);
	  break;
      case sprmSPropRMark:
	  wvApplysprmSPropRMark (asep, pointer, pos);
	  break;
      case sprmSFBiDi:
	  asep->fBidi = bread_8ubit (pointer, pos);
	  break;
      case sprmSFFacingCol: /* ?????? , what the hell are these two */
      case sprmSFRTLGutter:
	  bread_8ubit (pointer, pos);
	  break;
      case sprmSBrcTop:
	  (*pos) += wvGetBRCFromBucket (ver, &asep->brcTop, pointer);
	  break;
      case sprmSBrcLeft:
	  (*pos) += wvGetBRCFromBucket (ver, &asep->brcLeft, pointer);
	  break;
      case sprmSBrcBottom:
	  (*pos) += wvGetBRCFromBucket (ver, &asep->brcBottom, pointer);
	  break;
      case sprmSBrcRight:
	  (*pos) += wvGetBRCFromBucket (ver, &asep->brcRight, pointer);
	  break;
      case sprmSPgbProp:
	  asep->pgbProp = (S16) bread_16ubit (pointer, pos);
	  break;
      case sprmSDxtCharSpace:
	  asep->dxtCharSpace = (S32) bread_32ubit (pointer, pos);
	  break;
      case sprmSDyaLinePitch:
	  /* incorrectly documented; is only word size */
	  asep->dyaLinePitch = (S32) bread_16ubit (pointer, pos);
	  break;
      case sprmSClm:
	  /* who knows */
	  bread_16ubit (pointer, pos);
	  break;
      case sprmSTextFlow:
	  asep->wTextFlow = (S16) bread_16ubit (pointer, pos);
	  break;
	  /* End of SEP */

	  /* Begin of TAP */
      case sprmTJc:
	  apap->ptap.jc = (S16) bread_16ubit (pointer, pos);
	  break;
      case sprmTFCantSplit:
	  apap->ptap.fCantSplit = bread_8ubit (pointer, pos);
	  break;
      case sprmTTableHeader:
	  apap->ptap.fTableHeader = bread_8ubit (pointer, pos);
	  break;
      case sprmTDyaRowHeight:	/* check len */
	  asep->dyaLinePitch = (S16) bread_16ubit (pointer, pos);
	  break;
      case sprmTDiagLine:	/* ????? */
	  wvError (("huh, show me this document\n"));
	  break;
      case sprmTHTMLProps:	/* ???? */
	  apap->ptap.lwHTMLProps = (S32) bread_32ubit (pointer, pos);
	  break;
      case sprmTDxaLeft:
	  wvApplysprmTDxaLeft (&apap->ptap, pointer, pos);
	  break;
      case sprmTDxaGapHalf:
	  wvApplysprmTDxaGapHalf (&apap->ptap, pointer, pos);
	  break;
      case sprmTTableBorders:
	  wvApplysprmTTableBorders (ver, &apap->ptap, pointer, pos);
	  break;
      case sprmTDefTable10:
	  wvApplysprmTDefTable10 (&apap->ptap, pointer, pos);
	  break;
      case sprmTDefTable:
	  wvApplysprmTDefTable (&apap->ptap, pointer, pos);
	  break;
      case sprmTDefTableShd:
	  /*
	     wvApplysprmTDefTableShd follows the written spec, but
	     it isnt't working out for me, maybe its my own fault,
	     anyhow Im trying wv2 out temporarily
	   */
	  wv2ApplysprmTDefTableShd (&apap->ptap, pointer, pos);
	  /*
	     wvApplysprmTDefTableShd(&apap->ptap,pointer,pos);
	   */
	  break;
      case sprmTTlp:
	  wvGetTLPFromBucket (&(apap->ptap.tlp), pointer);
	  (*pos) += cbTLP;
	  break;
      case sprmTSetBrc:
	  wvApplysprmTSetBrc (ver, &apap->ptap, pointer, pos);
	  break;
      case sprmTInsert:
	  wvApplysprmTInsert (&apap->ptap, pointer, pos);
	  break;
      case sprmTDelete:
	  wvApplysprmTDelete (&apap->ptap, pointer, pos);
	  break;
      case sprmTDxaCol:
	  wvApplysprmTDxaCol (&apap->ptap, pointer, pos);
	  break;
      case sprmTMerge:
	  wvApplysprmTMerge (&apap->ptap, pointer, pos);
	  break;
      case sprmTSplit:
	  wvApplysprmTSplit (&apap->ptap, pointer, pos);
	  break;
      case sprmTSetBrc10:
	  wvApplysprmTSetBrc10 (&apap->ptap, pointer, pos);
	  break;
      case sprmTSetShd:
	  wvApplysprmTSetShd (&apap->ptap, pointer, pos);
	  break;
      case sprmTSetShdOdd:
	  wvApplysprmTSetShdOdd (&apap->ptap, pointer, pos);
	  break;
      case sprmTTextFlow:
	  wvError (("huh, show me this document\n"));
	  wvApplysprmTTextFlow (&apap->ptap, pointer, pos);
	  break;
      case sprmTVertMerge:
	  wvApplysprmTVertMerge (&apap->ptap, pointer, pos);
	  break;
      case sprmTFBiDi:		/* ????? */
	  bread_16ubit (pointer, pos);
	  break;
      case sprmTUNKNOWN1:
	  /* read wv.h and word 6 sprm 204
	     further down in this file to understand this
	   */
	  bread_8ubit (pointer, pos);
	  bread_16ubit (pointer, pos);
	  break;
      case sprmTVertAlign:
	  wvApplysprmTVertAlign (&apap->ptap, pointer, pos);
	  break;

	  /* end of TAP */

	  /*
	     case sprmPicBrcl
	   */

      case sprmPRuler:		/* ???? */
      case sprmCIdCharType:	/* obsolete */
      case sprmCKcd:		/* ???? */
      case sprmCCharScale:	/* ???? */
      case sprmNoop:		/* no operand */
	  break;
      default:
	  wvEatSprm (sprm, pointer, pos);
	  break;
      }

    wvGetSprmFromU16 (&RetSprm, sprm);
    return (RetSprm);
}

void
wvApplysprmPIstdPermute (PAP * apap, U8 * pointer, U16 * pos)
{
    U8 cch;
    U8 fLongg;
    U8 fSpare;
    U16 istdFirst;
    U16 istdLast;
    U16 *rgistd;
    U16 i;

    cch = dread_8ubit (NULL, &pointer);
    (*pos)++;
    fLongg = dread_8ubit (NULL, &pointer);
    (*pos)++;
    fSpare = dread_8ubit (NULL, &pointer);
    (*pos)++;
    istdFirst = dread_16ubit (NULL, &pointer);
    (*pos) += 2;
    istdLast = dread_16ubit (NULL, &pointer);
    (*pos) += 2;

    if ( cch > 6)
      {
	  rgistd = (U16 *) wvMalloc (sizeof (U16) * ((cch - 6) / 2));
	  if (rgistd == NULL)
	    {
		wvError (
			 ("Could not allocate %d\n",
			  sizeof (U16) * ((cch - 6) / 2)));
		return;
	    }
	  for (i = 0; i < (cch - 6) / 2; i++)
	    {
		rgistd[i] = dread_16ubit (NULL, &pointer);
		(*pos) += 2;
	    }
      }
    else
	rgistd = NULL;
    /*
       First check if pap.istd is greater than the istdFirst recorded in the sprm
       and less than or equal to the istdLast recorded in the sprm If not, the sprm
       has no effect. If it is, pap.istd is set to rgistd[pap.istd - istdFirst]
     */

    if ((apap->istd > istdFirst) && (apap->istd <= istdLast))
      {
	  wvTrace (("%d %d %d\n", apap->istd, istdFirst, istdLast));
	  apap->istd = rgistd[apap->istd - istdFirst];
      }
    wvFree (rgistd);
}

void
wvApplysprmPIncLvl (PAP * apap, U8 * pointer, U16 * pos)
{
    U8 temp8;
    S8 tempS8;
    temp8 = bread_8ubit (pointer, pos);
    /*
       If pap.stc is < 1 or > 9, sprmPIncLvl has no effect. Otherwise, if the value
       stored in the byte has its highest order bit off, the value is a positive
       difference which should be added to pap.istd and pap.lvl and then pap.stc
       should be set to min(pap.istd, 9). If the byte value has its highest order
       bit on, the value is a negative difference which should be sign extended to
       a word and then subtracted from pap.istd and pap.lvl. Then pap.stc should be
       set to max(1, pap.istd).

       Now... hang on a sec coz

       Note that the storage and behavior of styles has changed radically since
       Word 2 for Windows, beginning with nFib 63. Some of the differences are:
       <chomp>
       * The style code is called an istd, rather than an stc.

       So, for the purposes of this filter, we ignore the stc component of the
       instructions

     */

    if ((apap->istd < 1) || (apap->istd > 9))
	return;

    if ((temp8 & 0x80) >> 7 == 0)
      {
	  apap->istd += temp8;
	  apap->lvl += temp8;
	  /*
	     apap->stc = min(apap->istd, 9);
	   */
      }
    else
      {
	  tempS8 = (S8) temp8;
	  apap->istd += tempS8;
	  apap->lvl += tempS8;
	  /*
	     apap->stc = max(1, apap->istd);
	   */
      }
}

void
wvApplysprmPChgTabsPapx (PAP * apap, U8 * pointer, U16 * pos)
{
    S16 temp_rgdxaTab[itbdMax];
    TBD temp_rgtbd[itbdMax];
    int i, j, k = 0, oldpos;
    U8 cch, itbdDelMax;
    S16 *rgdxaDel;
    U8 itbdAddMax;
    S16 *rgdxaAdd;
    int add = 0;
    TBD *rgtbdAdd;

    oldpos = *pos;
    cch = dread_8ubit (NULL, &pointer);
    (*pos)++;
    itbdDelMax = dread_8ubit (NULL, &pointer);
    (*pos)++;
    if (itbdDelMax != 0)
      {
	  rgdxaDel = (S16 *) wvMalloc (sizeof (U16) * itbdDelMax);
	  for (i = 0; i < itbdDelMax; i++)
	    {
		rgdxaDel[i] = (S16) dread_16ubit (NULL, &pointer);
		(*pos) += 2;
	    }
      }
    else
	rgdxaDel = NULL;
    itbdAddMax = dread_8ubit (NULL, &pointer);
    wvTrace (("itbdAddMax is %d\n", itbdAddMax));
    (*pos)++;
    if (itbdAddMax != 0)
      {
	  rgdxaAdd = (S16 *) wvMalloc (sizeof (U16) * itbdAddMax);
	  for (i = 0; i < itbdAddMax; i++)
	    {
		rgdxaAdd[i] = (S16) dread_16ubit (NULL, &pointer);
		wvTrace (("stops are %d\n", rgdxaAdd[i]));
		(*pos) += 2;
	    }
	  rgtbdAdd = (TBD *) wvMalloc (itbdAddMax * sizeof (TBD));
	  for (i = 0; i < itbdAddMax; i++)
	    {
		wvGetTBDFromBucket (&rgtbdAdd[i], pointer);
		(*pos)++;
	    }
      }
    else
      {
	  rgdxaAdd = NULL;
	  rgtbdAdd = NULL;
      }

#ifdef DEBUG
    if (*pos - oldpos != cch + 1)
	wvTrace (("Offset Problem in wvApplysprmPChgTabsPapx\n"));
#endif

    /*
       When sprmPChgTabsPapx is interpreted, the rgdxaDel of the sprm is applied
       first to the pap that is being transformed. This is done by deleting from
       the pap the rgdxaTab entry and rgtbd entry of any tab whose rgdxaTab value
       is equal to one of the rgdxaDel values in the sprm. It is guaranteed that
       the entries in pap.rgdxaTab and the sprm's rgdxaDel and rgdxaAdd are
       recorded in ascending dxa order.

       Then the rgdxaAdd and rgtbdAdd entries are merged into the pap's rgdxaTab
       and rgtbd arrays so that the resulting pap rgdxaTab is sorted in ascending
       order with no duplicates.
     */
    for (j = 0; j < apap->itbdMac && k < itbdMax; j++)
      {
	  add = 1;
	  for (i = 0; i < itbdDelMax; i++)
	    {
		if (rgdxaDel[i] == apap->rgdxaTab[j])
		  {
		      add = 0;
		      break;
		  }
	    }
	  if (add)
	    {
		temp_rgdxaTab[k] = apap->rgdxaTab[j];
		wvCopyTBD (&temp_rgtbd[k++], &apap->rgtbd[j]);
	    }
      }
    /*temp_rgdxaTab now contains all the tab stops to be retained after the delete */
    apap->itbdMac = k;
    k = 0;
    j = 0;
    i = 0;
    while ((j < apap->itbdMac) || (i < itbdAddMax))
      {
#if 0
	  wvTrace (("i %d j apap->itbdMac %d %d\n", i, j, apap->itbdMac));
	  wvTrace (("temp_rgdxaTab[j] %d\n", temp_rgdxaTab[j]));
	  wvTrace (("rgdxaAdd[i] %d\n", rgdxaAdd[i]));
#endif
	  if ((j < apap->itbdMac)
	      && (i >= itbdAddMax || temp_rgdxaTab[j] < rgdxaAdd[i]))
	    {
		/* if we have one from the retained group that should be added */
		apap->rgdxaTab[k] = temp_rgdxaTab[j];
		wvCopyTBD (&apap->rgtbd[k++], &temp_rgtbd[j++]);
	    }
	  else if ((j < apap->itbdMac) && (temp_rgdxaTab[j] == rgdxaAdd[i]))
	    {
		/* if we have one from the retained group that should be added
		   which is the same as one from the new group */
		apap->rgdxaTab[k] = rgdxaAdd[i];
		wvCopyTBD (&apap->rgtbd[k++], &rgtbdAdd[i++]);
		j++;
	    }
	  else			/*if (i < itbdAddMax) */
	    {
		/* if we have one from the new group to be added */
		apap->rgdxaTab[k] = rgdxaAdd[i];
		wvCopyTBD (&apap->rgtbd[k++], &rgtbdAdd[i++]);
	    }
      }
    wvTrace (("k is %d\n", k));

    apap->itbdMac = k;

    for (i = 0; i < apap->itbdMac; i++)
      {
	  wvTrace (
		   ("tab %d rgdxa %d %x\n", i, apap->rgdxaTab[i],
		    apap->rgdxaTab[i]));
      }

    wvFree (rgtbdAdd);
    wvFree (rgdxaAdd);
    wvFree (rgdxaDel);
}

int
wvApplysprmPChgTabs (PAP * apap, U8 * pointer, U16 * pos)
{
    S16 temp_rgdxaTab[itbdMax];
    TBD temp_rgtbd[itbdMax];
    U8 cch;
    U8 itbdDelMax;
    S16 *rgdxaDel;
    S16 *rgdxaClose;
    U8 itbdAddMax;
    S16 *rgdxaAdd;
    TBD *rgtbdAdd;
    int add = 0;
    U8 i, j, k = 0;

    wvTrace (("entering wvApplysprmPChgTabs\n"));
    /*
       itbdDelMax and itbdAddMax are defined to be equal to 50. This means that the
       largest possible instance of sprmPChgTabs is 354. When the length of the
       sprm is greater than or equal to 255, the cch field will be set equal to
       255. When cch == 255, the actual length of the sprm can be calculated as
       follows: length = 2 + itbdDelMax * 4 + itbdAddMax * 3.
     */

    cch = dread_8ubit (NULL, &pointer);
    wvTrace (("cch is %d\n", cch));
    (*pos)++;
    itbdDelMax = dread_8ubit (NULL, &pointer);
    (*pos)++;

    wvTrace (("itbdDelMax is %d\n", itbdDelMax));
    if (itbdDelMax != 0)
      {
	  rgdxaDel = (S16 *) wvMalloc (sizeof (S16) * itbdDelMax);
	  rgdxaClose = (S16 *) wvMalloc (sizeof (S16) * itbdDelMax);
	  for (i = 0; i < itbdDelMax; i++)
	    {
		rgdxaDel[i] = (S16) dread_16ubit (NULL, &pointer);
		(*pos) += 2;
	    }
	  for (i = 0; i < itbdDelMax; i++)
	    {
		rgdxaClose[i] = dread_16ubit (NULL, &pointer);
		(*pos) += 2;
	    }
      }
    else
      {
	  rgdxaDel = NULL;
	  rgdxaClose = NULL;
      }
    itbdAddMax = dread_8ubit (NULL, &pointer);
    wvTrace (("itbdAddMax is %d\n", itbdAddMax));
    (*pos)++;
    if (itbdAddMax != 0)
      {
	  rgdxaAdd = (S16 *) wvMalloc (sizeof (S16) * itbdAddMax);
	  rgtbdAdd = (TBD *) wvMalloc (itbdAddMax * sizeof (TBD));
	  for (i = 0; i < itbdAddMax; i++)
	    {
		rgdxaAdd[i] = (S16) dread_16ubit (NULL, &pointer);
		wvTrace (("rgdxaAdd %d is %x\n", i, rgdxaAdd[i]));
		(*pos) += 2;
	    }
	  for (i = 0; i < itbdAddMax; i++)
	    {
		wvGetTBDFromBucket (&rgtbdAdd[i], pointer);
		(*pos)++;
	    }
      }
    else
      {
	  rgdxaAdd = NULL;
	  rgtbdAdd = NULL;
      }

    if (cch == 225)
	cch = 2 + itbdDelMax * 4 + itbdAddMax * 3;

    /*
       When sprmPChgTabs is interpreted, the rgdxaDel of the sprm is applied first
       to the pap that is being transformed. This is done by deleting from the pap
       the rgdxaTab entry and rgtbd entry of any tab whose rgdxaTab value is within
       the interval [rgdxaDel[i] - rgdxaClose[i], rgdxaDel[i] + rgdxaClose[i]] It
       is guaranteed that the entries in pap.rgdxaTab and the sprm's rgdxaDel and
       rgdxaAdd are recorded in ascending dxa order.

       Then the rgdxaAdd and rgtbdAdd entries are merged into the pap's rgdxaTab
       and rgtbd arrays so that the resulting pap rgdxaTab is sorted in ascending
       order with no duplicates.
     */
    if (apap == NULL)
      {
	  wvFree (rgdxaDel);
	  wvFree (rgtbdAdd);
	  wvFree (rgdxaAdd);
	  wvFree (rgdxaClose);
	  return (cch);
      }

    wvTrace (("here %d\n", apap->itbdMac));
    for (j = 0; j < apap->itbdMac && k < itbdMax; j++)
      {
	  add = 1;
	  for (i = 0; i < itbdDelMax; i++)
	    {
		wvTrace (
			 ("examing %x against %x\n", apap->rgdxaTab[j],
			  rgdxaDel[i]));
		if ((apap->rgdxaTab[j] >= rgdxaDel[i] - rgdxaClose[i])
		    && (apap->rgdxaTab[j] <= rgdxaDel[i] + rgdxaClose[i]))
		  {
		      wvTrace (("deleting\n"));
		      add = 0;
		      break;
		  }
	    }
	  if (add)
	    {
		temp_rgdxaTab[k] = apap->rgdxaTab[j];
		wvCopyTBD (&temp_rgtbd[k++], &apap->rgtbd[j]);
	    }
      }
    apap->itbdMac = k;
    wvTrace (("here %d\n", apap->itbdMac));

    k = 0;
    j = 0;
    i = 0;
    while ((j < apap->itbdMac) || (i < itbdAddMax))
      {
	  if ((j < apap->itbdMac)
	      && (i >= itbdAddMax || temp_rgdxaTab[j] < rgdxaAdd[i]))
	    {
		wvTrace (("adding from nondeleted tab stops\n"));
		apap->rgdxaTab[k] = temp_rgdxaTab[j];
		wvCopyTBD (&apap->rgtbd[k++], &temp_rgtbd[j++]);
	    }
	  else if ((j < apap->itbdMac) && (temp_rgdxaTab[j] == rgdxaAdd[i]))
	    {
		wvTrace (("adding from new tab stops\n"));
		apap->rgdxaTab[k] = rgdxaAdd[i];
		wvCopyTBD (&apap->rgtbd[k++], &rgtbdAdd[i++]);
		j++;
	    }
	  else			/*if (i < itbdAddMax) */
	    {
		wvTrace (("adding from new tab stops\n"));
		apap->rgdxaTab[k] = rgdxaAdd[i];
		wvCopyTBD (&apap->rgtbd[k++], &rgtbdAdd[i++]);
	    }
      }

    apap->itbdMac = k;
    wvTrace (("here %d\n", apap->itbdMac));

    for (i = 0; i < apap->itbdMac; i++)
      {
	  wvTrace (
		   ("tab %d rgdxa %d %x\n", i, apap->rgdxaTab[i],
		    apap->rgdxaTab[i]));
      }

    wvFree (rgdxaDel);
    wvFree (rgtbdAdd);
    wvFree (rgdxaAdd);
    wvFree (rgdxaClose);
    wvTrace (("Exiting Successfully\n"));

    return (cch);
}

void
wvApplysprmPPc (PAP * apap, U8 * pointer, U16 * pos)
{
    U8 temp8;
    struct _temp {
	U32 reserved:4;
	U32 pcVert:2;
	U32 pcHorz:2;
    } temp;


    temp8 = bread_8ubit (pointer, pos);
#ifdef PURIFY
    temp.pcVert = 0;
    temp.pcHorz = 0;
#endif
    temp.pcVert = (temp8 & 0x0C) >> 4;
    temp.pcHorz = (temp8 & 0x03) >> 6;

    /*
       sprmPPc is interpreted by moving pcVert to pap.pcVert if pcVert != 3 and by
       moving pcHorz to pap.pcHorz if pcHorz != 3.
     */

    if (temp.pcVert != 3)
	apap->pcVert = temp.pcVert;
    if (temp.pcHorz != 3)
	apap->pcHorz = temp.pcHorz;
}

void
wvApplysprmPFrameTextFlow (PAP * apap, U8 * pointer, U16 * pos)
{
    U16 temp16 = bread_16ubit (pointer, pos);

    apap->fVertical = temp16 & 0x0001;
    apap->fBackward = (temp16 & 0x0002) >> 1;
    apap->fRotateFont = (temp16 & 0x0004) >> 2;
}

void
wvApplysprmPAnld (wvVersion ver, PAP * apap, U8 * pointer, U16 * pos)
{
    dread_8ubit (NULL, &pointer);
    (*pos)++;
    wvGetANLD_FromBucket (ver, &apap->anld, pointer);
    if (ver == WORD8)
	(*pos) += cbANLD;
    else
	(*pos) += cb6ANLD;
}

void
wvApplysprmPPropRMark (PAP * apap, U8 * pointer, U16 * pos)
{
    dread_8ubit (NULL, &pointer);
    /*
       sprmPPropRMark is interpreted by moving the first parameter
       byte to pap.fPropRMark, the next two bytes to pap.ibstPropRMark, and the
       remaining four bytes to pap.dttmPropRMark.
     */
    apap->fPropRMark = dread_8ubit (NULL, &pointer);
    (*pos)++;
    apap->ibstPropRMark = dread_16ubit (NULL, &pointer);
    (*pos) += 2;
    wvGetDTTMFromBucket (&apap->dttmPropRMark, pointer);
    (*pos) += 4;
}

void
wvApplysprmPNumRM (PAP * apap, U8 * pointer, U16 * pos)
{
    dread_8ubit (NULL, &pointer);
    (*pos)++;
    wvGetNUMRMFromBucket (&apap->numrm, pointer);
    (*pos) += cbNUMRM;
}

void
wvApplysprmPHugePapx (PAP * apap, U8 * pointer, U16 * pos, wvStream * data,
		      STSH * stsh)
{
    U32 offset;
    U16 len, i, sprm;
    U8 *grpprl, *pointer2;
    /*
       sprmPHugePapx is stored in PAPX FKPs in place of the grpprl of a PAPX which
       would otherwise be too big to fit in an FKP (as of this writing, 488 bytes
       is the size of the largest PAPX which can fit in an FKP). The parameter fc
       gives the location of the grpprl in the data stream. The first word at that
       fc counts the number of bytes in the grpprl (not including the byte count
       itself). A sprmPHugePapx should therefore only be found in a PAPX FKP and
       should be the only sprm in that PAPX's grpprl.
     */
    offset = dread_32ubit (NULL, &pointer);
    (*pos) += 4;
    wvTrace (("Offset is %x in data stream\n", offset));
    if (!(data))
      {
	  wvError (("No data stream!!\n"));
	  return;
      }
    if (0 > wvStream_goto (data, offset))
      {
	  wvError (("Couldn't seek data stream!!\n"));
	  apap->fTtp++;
	  return;
      }
    len = read_16ubit (data);
    if (!len)
      {
	  wvWarning ("sprmPHugePapx len is 0, seems unlikely\n");
	  return;
      }

    grpprl = (U8 *) wvMalloc (len);

    for (i = 0; i < len; i++)
	grpprl[i] = read_8ubit (data);

    i = 0;
    while (i < len - 2)
      {
	  sprm = bread_16ubit (grpprl + i, &i);
#ifdef SPRMTEST
	  wvError (("sprm is %x\n", sprm));
#endif
	  pointer2 = grpprl + i;
	  if (i < len)
	      wvApplySprmFromBucket (WORD8, sprm, apap, NULL, NULL, stsh,
				     pointer2, &i, data);
      }
    wvFree (grpprl);
}

void
wvApplysprmCChs (CHP * achp, U8 * pointer, U16 * pos)
{
    /*
       When this sprm is interpreted, the first byte of the operand is moved to
       chp.fChsDiff and the remaining word is moved to chp.chse.
     */
    achp->fChsDiff = dread_8ubit (NULL, &pointer);
    (*pos)++;
    /*achp->chse ???? */
    /* the doc says to set this, but it doesnt exist anywhere else in the docs */
    dread_16ubit (NULL, &pointer);
    (*pos) += 2;
}

void
wvApplysprmCSymbol (wvVersion ver, CHP * achp, U8 * pointer, U16 * pos)
{
    if (ver == WORD8)
      {
	  /*
	     Word 8
	     This sprm's operand is 4 bytes. The first 2 hold the font code; the last 2
	     hold a character specifier. When this sprm is interpreted, the font code is
	     moved to chp.ftcSym and the character specifier is moved to chp.xchSym and
	     chp.fSpec is set to 1.
	   */
	  achp->ftcSym = dread_16ubit (NULL, &pointer);
	  (*pos) += 2;
	  achp->xchSym = dread_16ubit (NULL, &pointer);
	  (*pos) += 2;
	  wvTrace (("%d %d\n", achp->ftcSym, achp->xchSym));
      }
    else
      {
	  /*
	     Word 6 and 7
	     The length byte recorded at offset 1 in this
	     sprm will always be 3. When this sprm is interpreted the two byte
	     font code recorded at offset 2 is moved to chp.ftcSym, the single
	     byte character specifier recorded at offset 4 is moved to chp.chSym
	     and chp.fSpec is set to 1.
	   */
	  dread_8ubit (NULL, &pointer);
	  (*pos)++;
	  achp->ftcSym = dread_16ubit (NULL, &pointer);
	  (*pos) += 2;
	  achp->xchSym = dread_8ubit (NULL, &pointer);
	  achp->xchSym += 61440;	/* promote this char into a unicode char to
					   be consistent with what word 8 does */
	  (*pos)++;
      }
    achp->fSpec = 1;
}

void
wvApplysprmCIstdPermute (CHP * achp, U8 * pointer, U16 * pos)
{
    U8 cch;
    U8 fLongg;
    U8 fSpare;
    U16 istdFirst;
    U16 istdLast;
    U16 *rgistd;
    U16 i;

    cch = dread_8ubit (NULL, &pointer);
    (*pos)++;
    fLongg = dread_8ubit (NULL, &pointer);
    (*pos)++;
    fSpare = dread_8ubit (NULL, &pointer);
    (*pos)++;
    istdFirst = dread_16ubit (NULL, &pointer);
    (*pos) += 2;
    istdLast = dread_16ubit (NULL, &pointer);
    (*pos) += 2;
    if ((cch - 6) / 2 != 0)
      {
	  rgistd = (U16 *) wvMalloc (sizeof (U16) * ((cch - 6) / 2));
	  for (i = 0; i < (cch - 6) / 2; i++)
	    {
		rgistd[i] = dread_16ubit (NULL, &pointer);
		(*pos) += 2;
	    }
      }
    else
	rgistd = NULL;
    /*
       first check if chp.istd is greater than the
       istdFirst recorded in the sprm and less than or equal to the istdLast
       recorded in the sprm If not, the sprm has no effect. If it is, chp.istd is
       set to rgstd[chp.istd - istdFirst] and any chpx stored in that rgstd entry
       is applied to the chp.

       Note that it is possible that an istd may be recorded in the rgistd that
       refers to a paragraph style. This will no harmful consequences since the
       istd for a paragraph style should never be recorded in chp.istd.
     */

    if ((achp->istd > istdFirst) && (achp->istd <= istdLast))
      {
	  achp->istd = rgistd[achp->istd - istdFirst];
	  /*
	     if really a chp style
	     wvAddCHPXFromUPEBucket(achp,&(stsh->std[achp->istd].grupe[0].chpx),stsh);
	     else
	     complain;
	   */
      }
    wvFree (rgistd);
}

void
wvApplysprmCDefault (CHP * achp, U8 * pointer, U16 * pos)
{
    /*
       sprmCDefault (opcode 0x2A32) clears the fBold, fItalic, fOutline, fStrike,
       fShadow, fSmallCaps, fCaps, fVanish, kul and ico fields of the chp to 0. It
       was first defined for Word 3.01 and had to be backward compatible with Word
       3.00 so it is a variable length sprm whose count of bytes is 0. It consists
       of the sprmCDefault opcode followed by a byte of 0.
     */
    dread_8ubit (NULL, &pointer);
    (*pos)++;
    achp->fBold = 0;
    achp->fItalic = 0;
    achp->fOutline = 0;
    achp->fStrike = 0;
    achp->fShadow = 0;
    achp->fSmallCaps = 0;
    achp->fCaps = 0;
    achp->fVanish = 0;
    achp->kul = 0;
    achp->ico = 0;
}

void
wvApplysprmCPlain (CHP * achp, STSH * stsh)
{
    U8 fSpec;
    /*
       the style sheet CHP is copied over the original CHP preserving the
       fSpec setting from the original CHP.
     */
    fSpec = achp->fSpec;
    wvInitCHPFromIstd (achp, achp->istd, stsh);
    achp->fSpec = fSpec;
}


U8
wvToggle (U8 in, U8 toggle)
{
    /*
       When the parameter of the sprm is set to 0 or 1, then
       the CHP property is set to the parameter value.
     */
    if ((toggle == 0) || (toggle == 1))
	return (toggle);
    /*
       When the parameter of the sprm is 128, then the CHP property is set to the
       value that is stored for the property in the style sheet. CHP When the
       parameter of the sprm is 129, the CHP property is set to the negation of the
       value that is stored for the property in the style sheet CHP.
     */

    /*
       an argument might be made that instead of in being returned or negated that
       it should be the looked up in the original chp through the istd that should
       be used, in which case this should be a macro that does the right thing.
       but im uncertain as to which is the correct one to do, ideas on a postcard
       to... etc etc
     */
    if (toggle == 128)
	return (in);
    else if (toggle == 129)
	return (!in);
    wvWarning ("Strangle sprm toggle value, ignoring\n");
    return (in);
}

void
wvApplysprmCSizePos (CHP * achp, U8 * pointer, U16 * pos)
{
    U8 prevhpsPos;
    U16 temp8;
    struct _temp {
	U32 hpsSize:8;
	U32 cInc:7;
	U32 fAdjust:1;
	U32 hpsPos:8;
    } temp;
    temp.hpsSize = dread_8ubit (NULL, &pointer);
    (*pos)++;
    temp8 = dread_8ubit (NULL, &pointer);
    (*pos)++;
    temp.cInc = (temp8 & 0x7f) >> 8;
    temp.fAdjust = (temp8 & 0x80) >> 7;
    temp.hpsPos = dread_8ubit (NULL, &pointer);
    (*pos)++;

    /*
       if hpsSize != 0 then chp.hps is set to hpsSize.

       If cInc is != 0, the cInc is interpreted as a 7 bit twos complement
       number and the procedure described below for interpreting sprmCHpsInc is
       followed to increase or decrease the chp.hps by the specified number of
       levels.

       If hpsPos is != 128, then chp.hpsPos is set equal to hpsPos.

       If fAdjust is on , hpsPos != 128 and hpsPos != 0 and the previous value of
       chp.hpsPos == 0, then chp.hps is reduced by one level following the method
       described for sprmCHpsInc.

       If fAdjust is on, hpsPos == 0 and the previous value of chp.hpsPos != 0,
       then the chp.hps value is increased by one level using the method described
       below for sprmCHpsInc.
     */

    if (temp.hpsSize != 0)
	achp->hps = temp.hpsSize;

    if (temp.cInc != 0)
      {
      }

    prevhpsPos = achp->hpsPos;

    if (temp.hpsPos != 128)
	achp->hpsPos = temp.hpsPos;
#if 0
    /*else ? who knows ? */
    if ((temp.fAdjust) && (temp.hpsPos != 128) && (temp.hpsPos != 0)
	&& (achp->hpsPos == 0))
	/*reduce level */ ;
    if ((temp.fAdjust) && (temp.hpsPos == 0) && (achp->hpsPos != 0))
	/*increase level */ ;
#endif

    /*
       This depends on an implementation of sprmCHpsInc, read wvApplysprmCHpsInc for
       some comments on the whole matter
     */

    wvError (
	     ("This document has an unsupported sprm (sprmCSizePos), please mail "));
    wvError (
	     ("Caolan.McNamara@ul.ie with this document, as i haven't been able to "));
    wvError (("get any examples of it so as to figure out how to handle it\n"));

}

void
wvApplysprmCHpsInc (CHP * achp, U8 * pointer, U16 * pos)
{
    U8 param;
    /*
       sprmCHpsInc(opcode 0x2A44) is a three-byte sprm consisting of the sprm
       opcode and a one-byte parameter.

       Word keeps an ordered array of the font sizes that are defined for the fonts
       recorded in the system file with each font size transformed into an hps.

       The parameter is a one-byte twos complement number. Word uses this number
       to calculate an index in the font size array to determine the new hps for a
       run. When Word interprets this sprm and the parameter is positive, it searches
       the array of font sizes to find the index of the smallest entry in the font
       size table that is greater than the current chp.hps.It then adds the
       parameter minus 1 to the index and maxes this with the index of the last array
       entry. It uses the result as an index into the font size array and assigns that
       entry of the array to chp.hps.

       When the parameter is negative, Word searches the array of font sizes to
       find the index of the entry that is less than or equal to the current
       chp.hps. It then adds the negative parameter to the index and does a min of
       the result with 0. The result of the min function is used as an index into
       the font size array and that entry of the array is assigned to chp.hps.
       sprmCHpsInc is stored only in grpprls linked to piece table entries.
     */

    wvError (
	     ("This document has an unsupported sprm (sprmCHpsInc), please mail"));
    wvError (
	     ("Caolan.McNamara@ul.ie with this document, as i haven't been able to "));
    wvError (("get any examples of it so as to figure out how to handle it\n"));

    param = dread_8ubit (NULL, &pointer);

    /*
       Now for christ sake !!, how on earth would i have an "ordered array of the
       font sizes that are defined for the fonts recorded in the system file", that
       sounds to me that i would have to have access to the fonts on the actual
       machine that word was last run on !, it sounds to me that this sprm might only
       be used during the editing of a file, so im going to have to ignore it because
       it complete goobledegook to me
     */

}

void
wvApplysprmCHpsPosAdj (CHP * achp, U8 * pointer, U16 * pos)
{
    U8 param;
    /*
       sprmCHpsPosAdj (opcode 0x2A46) causes the hps of a run to be reduced the
       first time text is superscripted or subscripted and causes the hps of a run
       to be increased when superscripting/subscripting is removed from a run.

       The one byte parameter of this sprm is the new hpsPos value that is to be
       stored in chp.hpsPos.

       If the new hpsPos is not equal 0 (meaning that the text is to be super/
       subscripted), Word first examines the current value of chp.hpsPos
       to see if it is equal to 0.

       If so, Word uses the algorithm described for sprmCHpsInc to decrease chp.hps
       by one level.

       If the new hpsPos == 0 (meaning the text is not super/subscripted),
       Word examines the current chp.hpsPos to see if it is not equal to 0. If it is
       not (which means text is being restored to normal position), Word uses the
       sprmCHpsInc algorithm to increase chp.hps by one level.

       After chp.hps is adjusted, the parameter value is stored in chp.hpsPos.
     */

    wvError (
	     ("This document has an partially unsupported sprm (sprmCHpsPosAdj), please mail "));
    wvError (
	     ("Caolan.McNamara@ul.ie with this document, as i haven't been able to "));
    wvError (("get any examples of it so as to figure out how to handle it\n"));

    param = dread_8ubit (NULL, &pointer);
    (*pos)++;

    /*
       please see wvApplysprmCHpsInc for why this is unfinished
     */

#if 0
    if ((param != 0) && (achp->hpsPos == 0))
	/*decrease chp.hps */ ;
    else if ((param == 0) && (achp->hpsPos != 0))
	/*increase chp.hps */ ;
#endif

    achp->hpsPos = param;


}

void
wvApplysprmCMajority (CHP * achp, STSH * stsh, U8 * pointer, U16 * pos)
{
    U16 i;
    CHP base;
    CHP orig;
    UPXF upxf;
    /*
       Bytes 0 and 1 of
       sprmCMajority contains the opcode, byte 2 contains the length of the
       following list of character sprms. . Word begins interpretation of this sprm
       by applying the stored character sprm list to a standard chp. That chp has
       chp.istd = istdNormalChar. chp.hps=20, chp.lid=0x0400 and chp.ftc = 4. Word
       then compares fBold, fItalic, fStrike, fOutline, fShadow, fSmallCaps, fCaps,
       ftc, hps, hpsPos, kul, qpsSpace and ico in the original CHP with the values
       recorded for these fields in the generated CHP.. If a field in the original
       CHP has the same value as the field stored in the generated CHP, then that
       field is reset to the value stored in the style's CHP. If the two copies
       differ, then the original CHP value is left unchanged.
     */
    wvTrace (
	     ("This document has a sprm (sprmCMajority), that ive never seen in practice please mail "));
    wvTrace (
	     ("Caolan.McNamara@ul.ie with this document, as i haven't been able to "));
    wvTrace (
	     ("get any examples of it so as to figure out if its handled correctly\n"));

    wvInitCHP (&base);
    base.ftc = 4;

    /*generate a UPE and run wvAddCHPXFromBucket */

    upxf.cbUPX = dread_8ubit (NULL, &pointer);
    (*pos)++;
    upxf.upx.chpx.grpprl = (U8 *) wvMalloc (upxf.cbUPX);

    for (i = 0; i < upxf.cbUPX; i++)
      {
	  upxf.upx.chpx.grpprl[i] = dread_8ubit (NULL, &pointer);
	  (*pos)++;
      }

    wvTrace (("achp istd is %d\n", achp->istd));

    wvAddCHPXFromBucket (&base, &upxf, stsh);

    wvTrace (("achp istd is %d\n", achp->istd));

    wvTrace (("my underline started as %d\n", achp->kul));

    wvInitCHPFromIstd (&orig, achp->istd, stsh);

    /* this might be a little wrong, review after doing dedicated CHP's */
    if (achp->fBold == base.fBold)
	achp->fBold = orig.fBold;
    if (achp->fItalic == base.fItalic)
	achp->fItalic = orig.fItalic;
    if (achp->fStrike == base.fStrike)
	achp->fStrike = orig.fStrike;
    if (achp->fOutline == base.fOutline)
	achp->fOutline = orig.fOutline;
    if (achp->fShadow == base.fShadow)
	achp->fShadow = orig.fShadow;
    if (achp->fSmallCaps == base.fSmallCaps)
	achp->fSmallCaps = orig.fSmallCaps;
    if (achp->fCaps == base.fCaps)
	achp->fCaps = orig.fCaps;
    if (achp->ftc == base.ftc)
	achp->ftc = orig.ftc;
    if (achp->hps == base.hps)
	achp->hps = orig.hps;
    if (achp->hpsPos == base.hpsPos)
	achp->hpsPos = orig.hpsPos;
    if (achp->kul == base.kul)
	achp->kul = orig.kul;
    /* ????
       if (achp->qpsSpace == base.qpsSpace)
       achp->qpsSpace = orig.qpsSpace;
     */
    if (achp->ico == base.ico)
	achp->ico = orig.ico;

    /*
       these ones are mentioned in a different part of the spec, that
       doesnt have as much weight as the above, but i'm going to add them
       anyway
     */
    if (achp->fVanish == base.fVanish)
	achp->fVanish = orig.fVanish;
    wvTrace (("%d\n", base.dxaSpace));
    wvTrace (("%d\n", achp->dxaSpace));
    if (achp->dxaSpace == base.dxaSpace)
	achp->dxaSpace = orig.dxaSpace;
    if (achp->lidDefault == base.lidDefault)
	achp->lidDefault = orig.lidDefault;
    if (achp->lidFE == base.lidFE)
	achp->lidFE = orig.lidFE;
    wvFree (upxf.upx.chpx.grpprl);


    wvTrace (("my underline ended as %d\n", achp->kul));
}

void
wvApplysprmCHpsInc1 (CHP * achp, U8 * pointer, U16 * pos)
{
    /*
       This sprm is interpreted by adding the two byte increment
       stored as the opcode of the sprm to chp.hps. If this result is less than 8,
       the chp.hps is set to 8. If the result is greater than 32766, the chp.hps is
       set to 32766.
     */
    dread_8ubit (NULL, &pointer);
    (*pos)++;
    achp->hps += dread_16ubit (NULL, &pointer);
    (*pos) += 2;
    if (achp->hps < 8)
	achp->hps = 8;
    else if (achp->hps > 32766)
	achp->hps = 32766;
}


void
wvApplysprmCMajority50 (CHP * achp, STSH * stsh, U8 * pointer, U16 * pos)
{
    U16 i;
    CHP base;
    CHP orig;
    UPXF upxf;
    /*
       Bytes 0 and 1 of
       sprmCMajority contains the opcode, byte 2 contains the length of the
       following list of character sprms. . Word begins interpretation of this sprm
       by applying the stored character sprm list to a standard chp. That chp has
       chp.istd = istdNormalChar. chp.hps=20, chp.lid=0x0400 and chp.ftc = 4. Word
       then compares fBold, fItalic, fStrike, fOutline, fShadow, fSmallCaps, fCaps,
       ftc, hps, hpsPos, kul, qpsSpace and ico in the original CHP with the values
       recorded for these fields in the generated CHP.. If a field in the original
       CHP has the same value as the field stored in the generated CHP, then that
       field is reset to the value stored in the style's CHP. If the two copies
       differ, then the original CHP value is left unchanged.
     */
    wvTrace (
	     ("This document has a sprm (sprmCMajority50), that ive never seen in practice please mail "));
    wvTrace (
	     ("Caolan.McNamara@ul.ie with this document, as i haven't been able to "));
    wvTrace (
	     ("get any examples of it so as to figure out if its handled correctly\n"));

    wvInitCHP (&base);
    base.ftc = 4;

    /*generate a UPE and run wvAddCHPXFromBucket */

    upxf.cbUPX = dread_8ubit (NULL, &pointer);
    (*pos)++;
    upxf.upx.chpx.grpprl = (U8 *) wvMalloc (upxf.cbUPX);

    for (i = 0; i < upxf.cbUPX; i++)
      {
	  upxf.upx.chpx.grpprl[i] = dread_8ubit (NULL, &pointer);
	  (*pos)++;
      }

    wvAddCHPXFromBucket (&base, &upxf, stsh);

    wvInitCHPFromIstd (&orig, achp->istd, stsh);

    /* this might be a little wrong, review after doing dedicated CHP's */
    wvTrace (("istd is %d\n", achp->istd));
    if (achp->fBold == base.fBold)
	achp->fBold = orig.fBold;
    if (achp->fItalic == base.fItalic)
	achp->fItalic = orig.fItalic;
    if (achp->fStrike == base.fStrike)
	achp->fStrike = orig.fStrike;
    if (achp->fSmallCaps == base.fSmallCaps)
	achp->fSmallCaps = orig.fSmallCaps;
    if (achp->fCaps == base.fCaps)
	achp->fCaps = orig.fCaps;
    if (achp->ftc == base.ftc)
	achp->ftc = orig.ftc;
    if (achp->hps == base.hps)
	achp->hps = orig.hps;
    if (achp->hpsPos == base.hpsPos)
	achp->hpsPos = orig.hpsPos;
    if (achp->kul == base.kul)
	achp->kul = orig.kul;
    if (achp->ico == base.ico)
	achp->ico = orig.ico;
    if (achp->fVanish == base.fVanish)
	achp->fVanish = orig.fVanish;
    if (achp->dxaSpace == base.dxaSpace)
	achp->dxaSpace = orig.dxaSpace;

    wvFree (upxf.upx.chpx.grpprl); /* this seemed to be missing... */
}

void
wvApplysprmCPropRMark (CHP * achp, U8 * pointer, U16 * pos)
{
    dread_8ubit (NULL, &pointer);	/*len */
    (*pos)++;
    achp->fPropRMark = dread_8ubit (NULL, &pointer);
    (*pos)++;
    achp->ibstPropRMark = (S16) dread_16ubit (NULL, &pointer);
    (*pos) += 2;
    wvGetDTTMFromBucket (&achp->dttmPropRMark, pointer);
    (*pos) += 4;
}

void
wvApplysprmCDispFldRMark (CHP * achp, U8 * pointer, U16 * pos)
{
    /*
       is interpreted by moving the first
       parameter byte to chp.fDispFldRMark, the next two bytes to
       chp.ibstDispFldRMark, the next four bytes to chp.dttmDispFldRMark,
       and the remaining 32 bytes to chp.xstDispFldRMark.
     */

    int i;
    dread_8ubit (NULL, &pointer);	/*len */
    (*pos)++;
    achp->fDispFldRMark = dread_8ubit (NULL, &pointer);
    (*pos)++;
    achp->ibstDispFldRMark = (S16) dread_16ubit (NULL, &pointer);
    (*pos) += 2;
    wvGetDTTMFromBucket (&achp->dttmDispFldRMark, pointer);
    (*pos) += 4;
    pointer += 4;
    for (i = 0; i < 16; i++)
      {
	  achp->xstDispFldRMark[i] = dread_16ubit (NULL, &pointer);
	  (*pos) += 2;
      }
}


void
wvApplysprmSOlstAnm (wvVersion ver, SEP * asep, U8 * pointer, U16 * pos)
{
    U8 len = dread_8ubit (NULL, &pointer);
    wvGetOLSTFromBucket (ver, &asep->olstAnm, pointer);
    if (len != cbOLST)
	wvError (("OLST len is different from expected\n"));
    (*pos) += len;
}

void
wvApplysprmSPropRMark (SEP * asep, U8 * pointer, U16 * pos)
{
    dread_8ubit (NULL, &pointer);
    (*pos)++;
    /*
       sprmPPropRMark is interpreted by moving the first parameter
       byte to pap.fPropRMark, the next two bytes to pap.ibstPropRMark, and the
       remaining four bytes to pap.dttmPropRMark.
     */
    asep->fPropRMark = dread_8ubit (NULL, &pointer);
    (*pos)++;
    asep->ibstPropRMark = dread_16ubit (NULL, &pointer);
    (*pos) += 2;
    wvGetDTTMFromBucket (&asep->dttmPropRMark, pointer);
    (*pos) += 4;
}


/*
sprmTDxaLeft (opcode 0x9601) is called to adjust the x position within a
column which marks the left boundary of text within the first cell of a
table row. This sprm causes a whole table row to be shifted left or right
within its column leaving the horizontal width and vertical height of cells
in the row unchanged. Bytes 0-1 of the sprm contains the opcode, and the new
dxa position, call it dxaNew, is stored as an integer in bytes 2 and 3. Word
interprets this sprm by adding dxaNew - (rgdxaCenter[0] + tap.dxaGapHalf) to
every entry of tap.rgdxaCenter whose index is less than tap.itcMac.
sprmTDxaLeft is stored only in grpprls linked to piece table entries.
*/
void
wvApplysprmTDxaLeft (TAP * aTap, U8 * pointer, U16 * pos)
{
    S16 dxaNew = (S16) dread_16ubit (NULL, &pointer);
    int i;
    (*pos) += 2;
    dxaNew = dxaNew - (aTap->rgdxaCenter[0] + aTap->dxaGapHalf);
    for (i = 0; i < aTap->itcMac; i++)
	aTap->rgdxaCenter[i] += dxaNew;
}

/*
sprmTDxaGapHalf (opcode 0x9602) adjusts the white space that is maintained
between columns by changing tap.dxaGapHalf. Because we want the left
boundary of text within the leftmost cell to be at the same location after
the sprm is applied, Word also adjusts tap.rgdxCenter[0] by the amount that
tap.dxaGapHalf changes. Bytes 0-1 of the sprm contains the opcode, and the
new dxaGapHalf, call it dxaGapHalfNew, is stored in bytes 2 and 3. When the
sprm is interpreted, the change between the old and new dxaGapHalf values,
tap.dxaGapHalf - dxaGapHalfNew, is added to tap.rgdxaCenter[0] and then
dxaGapHalfNew is moved to tap.dxaGapHalf. sprmTDxaGapHalf is stored in PAPXs
and also in grpprls linked to piece table entries.

*/
void
wvApplysprmTDxaGapHalf (TAP * aTap, U8 * pointer, U16 * pos)
{
    S16 dxaGapHalfNew = (S16) dread_16ubit (NULL, &pointer);
    (*pos) += 2;
    aTap->rgdxaCenter[0] += aTap->dxaGapHalf - dxaGapHalfNew;
    aTap->dxaGapHalf = dxaGapHalfNew;
}

/*
sprmTTableBorders (opcode 0xD605) sets the tap.rgbrcTable. The sprm is
interpreted by moving the 24 bytes of the sprm's operand to tap.rgbrcTable.
*/
void
wvApplysprmTTableBorders (wvVersion ver, TAP * aTap, U8 * pointer, U16 * pos)
{
    int i, d;
    if (ver == WORD8)
      {
	  dread_8ubit (NULL, &pointer);
	  (*pos)++;
      }
    for (i = 0; i < 6; i++)
      {
	  d = wvGetBRCFromBucket (ver, &(aTap->rgbrcTable[i]), pointer);
	  pointer += d;
	  (*pos) += d;
      }
}

/*
sprmTDefTable (opcode 0xD608) defines the boundaries of table cells
(tap.rgdxaCenter) and the properties of each cell in a table (tap.rgtc).
Bytes 0 and 1 of the sprm contain its opcode. Bytes 2 and 3 store a two-byte
length of the following parameter. Byte 4 contains the number of cells that
are to be defined by the sprm, call it itcMac. When the sprm is interpreted,
itcMac is moved to tap.itcMac. itcMac cannot be larger than 32. In bytes 5
through 5+2*(itcMac + 1) -1 , is stored an array of integer dxa values
sorted in ascending order which will be moved to tap.rgdxaCenter. In bytes
5+ 2*(itcMac + 1) through byte 5+2*(itcMac + 1) + 10*itcMac - 1 is stored an
array of TC entries corresponding to the stored tap.rgdxaCenter. This array
is moved to tap.rgtc. sprmTDefTable is only stored in PAPXs.
*/
void
wvApplysprmTDefTable (TAP * aTap, U8 * pointer, U16 * pos)
{
    U16 len;
    int i, t, oldpos;
    wvVersion type;
    len = dread_16ubit (NULL, &pointer);
    (*pos) += 2;
    wvTrace (("wvApplysprmTDefTable\n"));
    aTap->itcMac = dread_8ubit (NULL, &pointer);
    (*pos)++;
    oldpos = (*pos) - 2;
    wvTrace (("oldpos is %x\n", oldpos));
    wvTrace (("C: there are %d cells\n", aTap->itcMac));
    for (i = 0; i < aTap->itcMac + 1; i++)
      {
	  aTap->rgdxaCenter[i] = (S16) dread_16ubit (NULL, &pointer);
	  wvTrace (("C: cell boun is %d\n", aTap->rgdxaCenter[i]));
	  (*pos) += 2;
      }

    wvTrace (
	     ("HERE-->pos is now %d, the len was %d, there is %d left\n",
	      *pos, len, len - (*pos - oldpos)));

    if ((len - (*pos - oldpos)) < (cb6TC * aTap->itcMac))
      {
	  pointer += len - (*pos - oldpos);
	  (*pos) += len - (*pos - oldpos);
	  return;
      }

    if ((len - (*pos - oldpos)) < (cbTC * aTap->itcMac))
	type = WORD6;
    else
	type = WORD8;

    wvTrace (("type is %d\n", type));

    wvTrace (("left over is %d\n", len - (*pos - oldpos)));

    for (i = 0; i < aTap->itcMac; i++)
      {
	  t = wvGetTCFromBucket (type, &(aTap->rgtc[i]), pointer);
	  wvTrace (("DefTable merge is %d\n", aTap->rgtc[i].fVertMerge));
	  /* for christ sake !!, word 8 stores word 6 sized TC's in this sprm ! */
	  (*pos) += t;
	  pointer += t;
	  wvTrace (("t is %d, under is %x\n", t, *pointer));
      }

    wvTrace (("left over is %d\n", len - (*pos - oldpos)));

    while (len - (*pos - oldpos))
      {
	  wvTrace (("Eating byte %x\n", dread_8ubit (NULL, &pointer)));
	  (*pos)++;
      }
    wvTrace (
	     ("oldpos is %x, pos is %x, diff is %d\n", oldpos, *pos,
	      *pos - oldpos - 2));
}

/*
sprmTDefTable10 (opcode0xD606) is an obsolete version of sprmTDefTable
(opcode 0xD608) that was used in WinWord 1.x. Its contents are identical to
those in sprmTDefTable, except that the TC structures contain the obsolete
structures BRC10s.
*/

void
wvApplysprmTDefTable10 (TAP * aTap, U8 * pointer, U16 * pos)
{
    U16 len;
    int i, t;
    len = dread_16ubit (NULL, &pointer);
    (*pos) += 2;
    aTap->itcMac = dread_8ubit (NULL, &pointer);
    (*pos)++;
    for (i = 0; i < aTap->itcMac + 1; i++)
      {
	  aTap->rgdxaCenter[i] = (S16) dread_16ubit (NULL, &pointer);
	  (*pos) += 2;
      }
    for (i = 0; i < aTap->itcMac; i++)
      {
	  t = wvGetTCFromBucket (WORD6, &(aTap->rgtc[i]), pointer);
	  (*pos) += t;
	  pointer += t;
      }
}

void
wv2ApplysprmTDefTableShd (TAP * aTap, U8 * pointer, U16 * pos)
{
    U8 len;
    U16 itcMac;
    int i;

    len = dread_8ubit (NULL, &pointer);
    (*pos)++;
    itcMac = len / cbSHD;
    wvTrace (
	     ("len in 2sprmTDefTableShd is %d, no of cells is %d\n", len,
	      itcMac));

    for (i = 0; i < itcMac; i++)
      {
	  wvGetSHDFromBucket (&(aTap->rgshd[i]), pointer);
	  pointer += cbSHD;
	  (*pos) += cbSHD;
      }
}


/*
sprmTDefTableShd (opcode 0xD609) is similar to sprmTDefTable, and
compliments it by defining the shading of each cell in a table (tap.rgshd).
Bytes 0 and 1 of the sprm contain its opcode. Bytes 2 and 3 store a two-byte
length of the following parameter. Byte 4 contains the number of cells that
are to be defined by the sprm, call it itcMac. itcMac cannot be larger than
32. In bytes 5 through 5+2*(itcMac + 1) -1 , is stored an array of SHDs.
This array is moved to tap.rgshd. sprmTDefTable is only stored in PAPXs.
*/
void
wvApplysprmTDefTableShd (TAP * aTap, U8 * pointer, U16 * pos)
{
    U16 len;
    U16 itcMac;
    int i, oldpos;

    len = dread_16ubit (NULL, &pointer);
    (*pos) += 2;
    if (len >= 0x4000)
      {
	  len = len & 0x00ff;
	  wvError (
		   ("bad len in sprmTDefTableShd, munging to %d instead\n",
		    len));
      }
    wvTrace (("wvApplysprmTDefTableShd, len %d\n", len));
    itcMac = dread_8ubit (NULL, &pointer);
    (*pos)++;
    oldpos = (*pos) - 2;
    wvTrace (("oldpos is %x\n", oldpos));
    wvTrace (("C: there are %d cells\n", itcMac));
    if (itcMac > 32)
	wvError (("Broken word doc, recovering from stupidity\n"));
    else
      {
	  if ((len - (*pos - oldpos)) < (cbSHD * aTap->itcMac))
	    {
		wvError (("Broken sprmDefTableShd, recovering from problem\n"));
		pointer += len - (*pos - oldpos);
		(*pos) += len - (*pos - oldpos);
		return;
	    }

	  for (i = 0; i < itcMac; i++)
	    {
		wvGetSHDFromBucket (&(aTap->rgshd[i]), pointer);
		pointer += cbSHD;
		(*pos) += cbSHD;
	    }
      }

    while (len - (*pos - oldpos))
      {
	  wvTrace (("Eating byte %x\n", dread_8ubit (NULL, &pointer)));
	  (*pos)++;
      }
    wvTrace (
	     ("oldpos is %x, pos is %x, diff is %d\n", oldpos, *pos,
	      *pos - oldpos - 2));
}

/*
Word 8

sprmTSetBrc (opcode 0xD620) allows the border definitions(BRCs) within TCs
to be set to new values. It has the following format:

 b10 b16 field          type  size bitfield comments

 0   0   sprm           short               opcode 0xD620

 2   2   count          byte                number of bytes for operand

 3   3   itcFirst       byte                the index of the first cell
                                            that is to have its borders
                                            changed.

 4   4   itcLim         byte                index of the cell that follows
                                            the last cell to have its
                                            borders changed

 5   5                  short :4   F0       reserved

         fChangeRight   short :1   08       =1 when tap.rgtc[].brcRight is
                                            to be changed

         fChangeBottom  short :1   04       =1 when tap.rgtc[].brcBottom
                                            is to be changed

         fChangeLeft    short :1   02       =1 when tap.rgtc[].brcLeft is
                                            to be changed

         fChangeTop     short :1   01       =1 when tap.rgtc[].brcTop is
                                            to be changed

 6   6   brc            BRC                 new BRC value to be stored in
                                            TCs.

*/
/* Pre Word 8 *
0    0    	sprm byte opcode 193
1    1    	itcFirst  byte
2    2    	itcLim    byte
3    3         int  :4 F0   reserved
			fChangeRight int  :1   08
			fChangeBottom int  :1   04
			fChangeLeft int  :1   02
			fChangeTop int  :1   01
	4    4  brc  BRC
*/
void
wvApplysprmTSetBrc (wvVersion ver, TAP * aTap, U8 * pointer, U16 * pos)
{
    U8 itcFirst, itcLim, len, temp8;
    BRC abrc;
    int i;
    if (ver == WORD8)
      {
	  len = dread_8ubit (NULL, &pointer);
	  (*pos)++;
	  wvTrace (("the len is %d", len));
      }
    itcFirst = dread_8ubit (NULL, &pointer);
    itcLim = dread_8ubit (NULL, &pointer);
    temp8 = dread_8ubit (NULL, &pointer);
    (*pos) += 3;
    (*pos) += wvGetBRCFromBucket (ver, &abrc, pointer);

    for (i = itcFirst; i < itcLim; i++)
      {
	  if (temp8 & 0x08)
	      wvCopyBRC (&aTap->rgtc[i].brcRight, &abrc);
	  if (temp8 & 0x04)
	      wvCopyBRC (&aTap->rgtc[i].brcBottom, &abrc);
	  if (temp8 & 0x02)
	      wvCopyBRC (&aTap->rgtc[i].brcLeft, &abrc);
	  if (temp8 & 0x01)
	      wvCopyBRC (&aTap->rgtc[i].brcTop, &abrc);
      }
}

/*
sprmTInsert (opcode 0x7621) inserts new cell definitions in an existing
table's cell structure.

Bytes 0 and 1 of the sprm contain the opcode.

Byte 2 is the index within tap.rgdxaCenter and tap.rgtc at which the new dxaCenter
and tc values will be inserted. Call this index itcInsert.

Byte 3 contains a count of the cell definitions to be added to the tap, call it ctc.

Bytes 4 and 5 contain the width of the cells that will be added, call it dxaCol.

If there are already cells defined at the index where cells are to be inserted,
tap.rgdxaCenter entries at or above this index must be moved to the entry
ctc higher and must be adjusted by adding ctc*dxaCol to the value stored.

The contents of tap.rgtc at or above the index must be moved 10*ctc bytes
higher in tap.rgtc.

If itcInsert is greater than the original tap.itcMac, itcInsert - tap.ctc columns
beginning with index tap.itcMac must be added of width dxaCol
(loop from itcMac to itcMac+itcInsert-tap.ctc adding dxaCol to the rgdxaCenter
value of the previous entry and storing sum as dxaCenter of new entry),
whose TC entries are cleared to zeros.

Beginning with index itcInsert, ctc columns of width dxaCol must be added by
constructing new tap.rgdxaCenter and tap.rgtc entries with the newly defined
rgtc entries cleared to zeros.

Finally, the number of cells that were added to the tap is added to tap.itcMac.

sprmTInsert is stored only in grpprls linked to piece table entries.
*/

void
wvApplysprmTInsert (TAP * aTap, U8 * pointer, U16 * pos)
{
    U8 itcInsert = dread_8ubit (NULL, &pointer);
    U8 ctc = dread_8ubit (NULL, &pointer);
    S16 dxaCol = (S16) dread_16ubit (NULL, &pointer);
    int i;
    (*pos) += 4;

    if (itcInsert <= aTap->itcMac + 1)
      {
	  for (i = aTap->itcMac + 1; i >= itcInsert; i--)
	    {
		aTap->rgdxaCenter[i + ctc] =
		    aTap->rgdxaCenter[i] + ctc * dxaCol;
		aTap->rgtc[i + ctc] = aTap->rgtc[i];
	    }
      }

    if (itcInsert > aTap->itcMac)
      {
	  for (i = aTap->itcMac; i < aTap->itcMac + itcInsert - ctc; i++)
	    {
		aTap->rgdxaCenter[i] = aTap->rgdxaCenter[i - 1] + dxaCol;
		wvInitTC (&(aTap->rgtc[i]));
	    }
      }

    for (i = itcInsert; i < ctc + itcInsert; i++)
      {
	  aTap->rgdxaCenter[i] = aTap->rgdxaCenter[i - 1] + dxaCol;
	  wvInitTC (&(aTap->rgtc[i]));
      }

    aTap->itcMac += ctc;
}


/*
sprmTDelete (opcode 0x5622) deletes cell definitions from an existing
table's cell structure. Bytes 0 and 1of the sprm contain the opcode. Byte 2
contains the index of the first cell to delete, call it itcFirst. Byte 3
contains the index of the cell that follows the last cell to be deleted,
call it itcLim. sprmTDelete causes any rgdxaCenter and rgtc entries whose
index is greater than or equal to itcLim to be moved to the entry that is
itcLim - itcFirst lower, and causes tap.itcMac to be decreased by the number
of cells deleted. sprmTDelete is stored only in grpprls linked to piece
table entries.
*/
void
wvApplysprmTDelete (TAP * aTap, U8 * pointer, U16 * pos)
{
    U8 itcFirst = dread_8ubit (NULL, &pointer);
    U8 itcLim = dread_8ubit (NULL, &pointer);
    int i;
    (*pos) += 2;

    for (i = itcLim; i < aTap->itcMac + 1; i++)
      {
	  aTap->rgdxaCenter[i - (itcLim - itcFirst)] = aTap->rgdxaCenter[i];
	  wvCopyTC (&(aTap->rgtc[i - (itcLim - itcFirst)]), &(aTap->rgtc[i]));
      }
}

/*
sprmTDxaCol (opcode 0x7623) changes the width of cells whose index is within
a certain range to be a certain value. Bytes 0 and 1of the sprm contain the
opcode. Byte 2 contains the index of the first cell whose width is to be
changed, call it itcFirst. Byte 3 contains the index of the cell that
follows the last cell whose width is to be changed, call it itcLim. Bytes 4
and 5 contain the new width of the cell, call it dxaCol.

This sprm causes the itcLim - itcFirst entries of tap.rgdxaCenter to be
adjusted so that tap.rgdxaCenter[i+1] = tap.rgdxaCenter[i] + dxaCol. Any
tap.rgdxaCenter entries that exist beyond itcLim are adjusted to take into
account the amount added to or removed from the previous columns.
*/
void
wvApplysprmTDxaCol (TAP * aTap, U8 * pointer, U16 * pos)
{
    U8 itcFirst = dread_8ubit (NULL, &pointer);
    U8 itcLim = dread_8ubit (NULL, &pointer);
    S16 dxaCol = (S16) dread_16ubit (NULL, &pointer);
    S16 diff = 0;
    int i;
    (*pos) += 4;
    for (i = itcFirst; i < itcLim; i++)
      {
	  diff += aTap->rgdxaCenter[i + 1] - (aTap->rgdxaCenter[i] + dxaCol);
	  aTap->rgdxaCenter[i + 1] = aTap->rgdxaCenter[i] + dxaCol;
      }
    for (i = itcLim; i < aTap->itcMac + 1; i++);
    aTap->rgdxaCenter[i + 1] += diff;
}

/*
sprmTMerge (opcode 0x5624) merges the display areas of cells within a
specified range. Bytes 0 and 1 of the sprm contain the opcode. Byte 2
contains the index of the first cell that is to be merged, call it itcFirst.
Byte 3 contains the index of the cell that follows the last cell to be
merged, call it itcLim.

This sprm causes tap.rgtc[itcFirst].fFirstMerged to
be set to 1. Cells in the range whose index is greater than itcFirst and
less than itcLim have tap.rgtc[].fMerged set to 1. sprmTMerge is stored only
in grpprls linked to piece table entries.

*/
void
wvApplysprmTMerge (TAP * aTap, U8 * pointer, U16 * pos)
{
    U8 itcFirst = dread_8ubit (NULL, &pointer);
    U8 itcLim = dread_8ubit (NULL, &pointer);
    int i;
    (*pos) += 2;

    aTap->rgtc[itcFirst].fFirstMerged = 1;
    for (i = itcFirst + 1; i < itcLim; i++)
	aTap->rgtc[i].fMerged = 1;
}

/*
sprmTSplit (opcode 0x5625) splits the display areas of merged cells into
their originally assigned display areas. Bytes 0 and 1 of the sprm contain
the opcode. Byte 2 contains the index of the first cell that is to be split,
call it itcFirst. Byte 3 contains the index of the cell that follows the
last cell to be split, call it itcLim.

This sprm clears
tap.rgtc[].fFirstMerged and tap.rgtc[].fMerged for all rgtc entries >=
itcFirst and < itcLim. sprmTSplit is stored only in grpprls linked to piece
table entries.
*/
void
wvApplysprmTSplit (TAP * aTap, U8 * pointer, U16 * pos)
{
    U8 itcFirst = dread_8ubit (NULL, &pointer);
    U8 itcLim = dread_8ubit (NULL, &pointer);
    int i;
    (*pos) += 2;

    for (i = itcFirst; i < itcLim; i++)
      {
	  aTap->rgtc[i].fMerged = 0;
	  aTap->rgtc[itcFirst].fFirstMerged = 0;
      }
}

/*
This is guess based upon SetBrc
*/
void
wvApplysprmTSetBrc10 (TAP * aTap, U8 * pointer, U16 * pos)
{
    U8 itcFirst, itcLim, len, temp8;
    BRC10 abrc;
    int i;
    len = dread_8ubit (NULL, &pointer);
    itcFirst = dread_8ubit (NULL, &pointer);
    itcLim = dread_8ubit (NULL, &pointer);
    temp8 = dread_8ubit (NULL, &pointer);
    (*pos) += 3;
    (*pos) += wvGetBRC10FromBucket (&abrc, pointer);

    for (i = itcFirst; i < itcLim; i++)
      {
	  if (temp8 & 0x08)
	      wvConvertBRC10ToBRC (&aTap->rgtc[i].brcRight, &abrc);
	  if (temp8 & 0x04)
	      wvConvertBRC10ToBRC (&aTap->rgtc[i].brcBottom, &abrc);
	  if (temp8 & 0x02)
	      wvConvertBRC10ToBRC (&aTap->rgtc[i].brcLeft, &abrc);
	  if (temp8 & 0x01)
	      wvConvertBRC10ToBRC (&aTap->rgtc[i].brcTop, &abrc);
      }
}

/*
sprmTSetShd (opcode 0x7627) allows the shading definitions(SHDs) within a
tap to be set to new values. Bytes 0 and 1 of the sprm contain the opcode.
Byte 2 contains the index of the first cell whose shading is to be changed,
call it itcFirst. Byte 3 contains the index of the cell that follows the
last cell whose shading is to be changed, call it itcLim. Bytes 4 and 5
contain the SHD structure, call it shd. This sprm causes the itcLim -
itcFirst entries of tap.rgshd to be set to shd. sprmTSetShd is stored only
in grpprls linked to piece table entries.
*/
void
wvApplysprmTSetShd (TAP * aTap, U8 * pointer, U16 * pos)
{
    U8 itcFirst = dread_8ubit (NULL, &pointer);
    U8 itcLim = dread_8ubit (NULL, &pointer);
    int i;
    SHD shd;
    (*pos) += 2;

    wvGetSHDFromBucket (&shd, pointer);
    (*pos) += cbSHD;

    for (i = itcFirst; i < itcLim; i++)
	wvCopySHD (&aTap->rgshd[i], &shd);
}

/*
sprmTSetShdOdd (opcode 0x7628) is identical to sprmTSetShd, but it only
changes the rgshd for odd indices between itcFirst and. sprmTSetShdOdd is
stored only in grpprls linked to piece table entries.
*/
void
wvApplysprmTSetShdOdd (TAP * aTap, U8 * pointer, U16 * pos)
{
    U8 itcFirst = dread_8ubit (NULL, &pointer);
    U8 itcLim = dread_8ubit (NULL, &pointer);
    int i;
    SHD shd;
    (*pos) += 2;

    wvGetSHDFromBucket (&shd, pointer);
    (*pos) += cbSHD;

    for (i = itcFirst; i < itcLim; i++)
      {
	  if ((i / 2) != (i + 1) / 2)
	      wvCopySHD (&aTap->rgshd[i], &shd);
      }
}

/* guess */
void
wvApplysprmTTextFlow (TAP * aTap, U8 * pointer, U16 * pos)
{
    U8 val = dread_8ubit (NULL, &pointer);
    int i;
    (*pos)++;

    for (i = 0; i < aTap->itcMac; i++)
      {
	  /* just a complete guess who knows */
	  aTap->rgtc[i].fVertical = val & 0x0001;
	  aTap->rgtc[i].fBackward = (val & 0x0002) >> 1;
	  aTap->rgtc[i].fRotateFont = (val & 0x0004) >> 2;
      }
}

/*
sprmTVertMerge (opcode 0xD62B) changes the vertical cell merge properties
for a cell in the tap.rgtc[]. Bytes 0 and 1 of the sprm contain the opcode.
Byte 2 contains the index of the cell whose vertical cell merge properties
are to be changed. Byte 3 codes the new vertical cell merge properties for
the cell, a 0 clears both fVertMerge and fVertRestart, a 1 sets fVertMerge
and clears fVertRestart, and a 3 sets both flags. sprmTVertMerge is stored
only in grpprls linked to piece table entries.
*/
void
wvApplysprmTVertMerge (TAP * aTap, U8 * pointer, U16 * pos)
{
    U8 index, props, count;
    wvTrace (("doing Vertical merge\n"));

    count = dread_8ubit (NULL, &pointer);
    wvTrace (("count is %d\n", count));	/* check against word 8 please */
    index = dread_8ubit (NULL, &pointer);
    props = dread_8ubit (NULL, &pointer);
    (*pos) += 3;

    switch (props)
      {
      case 0:
	  aTap->rgtc[index].fVertMerge = 0;
	  aTap->rgtc[index].fVertRestart = 0;
	  break;
      case 1:
	  aTap->rgtc[index].fVertMerge = 1;
	  aTap->rgtc[index].fVertRestart = 0;
	  break;
      case 3:
	  aTap->rgtc[index].fVertMerge = 1;
	  aTap->rgtc[index].fVertRestart = 1;
	  break;
      }
}

/*
sprmTVertAlign (opcode 0xD62C) changes the vertical alignment property in
the tap.rgtc[]. Bytes 0 and 1 of the sprm contain the opcode. Byte 2
contains the index of the first cell whose shading is to be changed, call it
itcFirst. Byte 3 contains the index of the cell that follows the last cell
whose shading is to be changed, call it itcLim. This sprm causes the
vertAlign properties of the itcLim - itcFirst entries of tap.rgtc[] to be
set to the new vertical alignment property contained in Byte 4.
sprmTVertAlign is stored only in grpprls linked to piece table entries.
*/
void
wvApplysprmTVertAlign (TAP * aTap, U8 * pointer, U16 * pos)
{
    U8 itcFirst = dread_8ubit (NULL, &pointer);
    U8 itcLim = dread_8ubit (NULL, &pointer);
    U8 props = dread_8ubit (NULL, &pointer);
    int i;
    (*pos) += 3;

    for (i = itcFirst; i < itcLim; i++)
	aTap->rgtc[i].vertAlign = props;
}

SprmName rgsprmPrm[0x80] =
    { sprmNoop, sprmNoop, sprmNoop, sprmNoop, sprmPIncLvl, sprmPJc,
    sprmPFSideBySide, sprmPFKeep, sprmPFKeepFollow, sprmPFPageBreakBefore,
    sprmPBrcl, sprmPBrcp, sprmPIlvl, sprmNoop, sprmPFNoLineNumb, sprmNoop,
    sprmNoop, sprmNoop, sprmNoop, sprmNoop, sprmNoop, sprmNoop, sprmNoop,
    sprmNoop, sprmPFInTable, sprmPFTtp, sprmNoop, sprmNoop, sprmNoop, sprmPPc,
    sprmNoop, sprmNoop, sprmNoop, sprmNoop, sprmNoop, sprmNoop, sprmNoop,
    sprmPWr, sprmNoop, sprmNoop, sprmNoop, sprmNoop, sprmNoop, sprmNoop,
    sprmPFNoAutoHyph, sprmNoop, sprmNoop, sprmNoop, sprmNoop, sprmNoop,
    sprmPFLocked, sprmPFWidowControl, sprmNoop, sprmPFKinsoku, sprmPFWordWrap,
    sprmPFOverflowPunct, sprmPFTopLinePunct, sprmPFAutoSpaceDE,
    sprmPFAutoSpaceDN, sprmNoop, sprmNoop, sprmPISnapBaseLine, sprmNoop,
    sprmNoop, sprmNoop, sprmCFStrikeRM, sprmCFRMark, sprmCFFldVanish,
    sprmNoop,
    sprmNoop, sprmNoop, sprmCFData, sprmNoop, sprmNoop, sprmNoop, sprmCFOle2,
    sprmNoop, sprmCHighlight, sprmCFEmboss, sprmCSfxText, sprmNoop, sprmNoop,
    sprmNoop, sprmCPlain, sprmNoop, sprmCFBold, sprmCFItalic, sprmCFStrike,
    sprmCFOutline, sprmCFShadow, sprmCFSmallCaps, sprmCFCaps, sprmCFVanish,
    sprmNoop, sprmCKul, sprmNoop, sprmNoop, sprmNoop, sprmCIco, sprmNoop,
    sprmCHpsInc, sprmNoop, sprmCHpsPosAdj, sprmNoop, sprmCIss, sprmNoop,
    sprmNoop, sprmNoop, sprmNoop, sprmNoop, sprmNoop, sprmNoop, sprmNoop,
    sprmNoop, sprmNoop, sprmCFDStrike, sprmCFImprint, sprmCFSpec, sprmCFObj,
    sprmPicBrcl, sprmPOutLvl, sprmNoop, sprmNoop, sprmNoop, sprmNoop,
    sprmNoop,
    sprmPPnbrRMarkNot
};

SprmName
wvGetrgsprmPrm (U16 in)
{
    if (in > 0x80)
      {
	  wvError (("Impossible rgsprmPrm value\n"));
	  return (sprmNoop);
      }
    return (rgsprmPrm[in]);
}


SprmName rgsprmWord6[256] = {
    sprmNoop /*          0 */ ,
    sprmNoop /*                  1 */ ,
    sprmPIstd /*         2 */ ,
    sprmPIstdPermute /*  3 */ ,
    sprmPIncLvl /*       4 */ ,
    sprmPJc /*           5 */ ,
    sprmPFSideBySide /*  6 */ ,
    sprmPFKeep /*        7 */ ,
    sprmPFKeepFollow /*  8 */ ,
    sprmPFPageBreakBefore /*  9 */ ,	/* added F */
    sprmPBrcl /*         10 */ ,
    sprmPBrcp /*         11 */ ,
    sprmPAnld /*         12 */ ,
    sprmPNLvlAnm /*      13 */ ,
    sprmPFNoLineNumb /*  14 */ ,
    sprmPChgTabsPapx /*  15 */ ,
    sprmPDxaRight /*     16 */ ,
    sprmPDxaLeft /*      17 */ ,
    sprmPNest /*         18 */ ,
    sprmPDxaLeft1 /*     19 */ ,
    sprmPDyaLine /*      20 */ ,
    sprmPDyaBefore /*    21 */ ,
    sprmPDyaAfter /*     22 */ ,
    sprmPChgTabs /*      23 */ ,
    sprmPFInTable /*     24 */ ,
    sprmPFTtp /*         25 */ ,	/* added F */
    sprmPDxaAbs /*       26 */ ,
    sprmPDyaAbs /*       27 */ ,
    sprmPDxaWidth /*     28 */ ,
    sprmPPc /*           29 */ ,
    sprmPBrcTop10 /*     30 */ ,
    sprmPBrcLeft10 /*    31 */ ,
    sprmPBrcBottom10 /*  32 */ ,
    sprmPBrcRight10 /*   33 */ ,
    sprmPBrcBetween10 /* 34 */ ,
    sprmPBrcBar10 /*     35 */ ,
    sprmPDxaFromText10 /*   36 */ ,	/* new name */
    sprmPWr /*           37 */ ,
    sprmPBrcTop /*       38 */ ,
    sprmPBrcLeft /*      39 */ ,
    sprmPBrcBottom /*    40 */ ,
    sprmPBrcRight /*     41 */ ,
    sprmPBrcBetween /*   42 */ ,
    sprmPBrcBar /*       43 */ ,
    sprmPFNoAutoHyph /*  44 */ ,
    sprmPWHeightAbs /*   45 */ ,
    sprmPDcs /*          46 */ ,
    sprmPShd /*          47 */ ,
    sprmPDyaFromText /*  48 */ ,
    sprmPDxaFromText /*  49 */ ,
    sprmPFLocked /*      50 */ ,
    sprmPFWidowControl /*  51 */ ,
    sprmNoop /*          52 */ ,
    sprmNoop /*          53 */ ,
    sprmNoop /*          54 */ ,
    sprmNoop /*          55 */ ,
    sprmNoop /*          56 */ ,
    sprmPUNKNOWN2 /*     57 */ ,
    sprmPUNKNOWN3 /*     58 */ ,
    sprmPUNKNOWN4 /*     59 */ ,
    sprmNoop /*          60 */ ,
    sprmNoop /*          61 */ ,
    sprmNoop /*          62 */ ,
    sprmNoop /*          63 */ ,
    sprmNoop /*          64 */ ,
    sprmCFStrikeRM /*    65 */ ,
    sprmCFRMark /*       66 */ ,
    sprmCFFldVanish /*   67 */ ,
    sprmCPicLocation /*  68 */ ,
    sprmCIbstRMark /*    69 */ ,
    sprmCDttmRMark /*    70 */ ,
    sprmCFData /*        71 */ ,
    sprmCIdslRMark /*     72 */ ,	/* new name */
    sprmCChs /*         73 */ ,	/* new name */
    sprmCSymbol /*       74 */ ,
    sprmCFOle2 /*        75 */ ,
    sprmNoop /*          76 */ ,
    sprmNoop /*          77 */ ,
    sprmNoop /*          78 */ ,
    sprmNoop /*          79 */ ,
    sprmCIstd /*         80 */ ,
    sprmCIstdPermute /*  81 */ ,
    sprmCDefault /*      82 */ ,
    sprmCPlain /*        83 */ ,
    sprmNoop /*          84 */ ,
    sprmCFBold /*        85 */ ,
    sprmCFItalic /*      86 */ ,
    sprmCFStrike /*      87 */ ,
    sprmCFOutline /*     88 */ ,
    sprmCFShadow /*      89 */ ,
    sprmCFSmallCaps /*   90 */ ,
    sprmCFCaps /*        91 */ ,
    sprmCFVanish /*      92 */ ,
    sprmCFtc /*          93 */ ,
    sprmCKul /*          94 */ ,
    sprmCSizePos /*      95 */ ,
    sprmCDxaSpace /*     96 */ ,
    sprmCLid /*          97 */ ,
    sprmCIco /*          98 */ ,
    sprmCHps /*          99 */ ,
    sprmCHpsInc /*       100 */ ,
    sprmCHpsPos /*       101 */ ,
    sprmCHpsPosAdj /*    102 */ ,
    sprmCMajority /*     103 */ ,
    sprmCIss /*          104 */ ,
    sprmCHpsNew50 /*     105 */ ,
    sprmCHpsInc1 /*      106 */ ,
    sprmCHpsKern /*      107 */ ,
    sprmCMajority50 /*   108 */ ,
    sprmCHpsMul /*       109 */ ,
    sprmCYsri /*             110 */ ,	/* new name */
    sprmCUNKNOWN5 /*     111 */ ,
    sprmCUNKNOWN6 /*     112 */ ,
    sprmCUNKNOWN7 /*     113 */ ,
    sprmNoop /*          114 */ ,
    sprmNoop /*          115 */ ,
    sprmNoop /*          116 */ ,
    sprmCFSpec /*        117 */ ,
    sprmCFObj /*         118 */ ,
    sprmPicBrcl /*       119 */ ,
    sprmPicScale /*      120 */ ,
    sprmPicBrcTop /*     121 */ ,
    sprmPicBrcLeft /*    122 */ ,
    sprmPicBrcBottom /*  123 */ ,
    sprmPicBrcRight /*   124 */ ,
    sprmNoop /*          125 */ ,
    sprmNoop /*          126 */ ,
    sprmNoop /*          127 */ ,
    sprmNoop /*          128 */ ,
    sprmNoop /*          129 */ ,
    sprmNoop /*          130 */ ,
    sprmScnsPgn /*           131 */ ,	/* new name */
    sprmSiHeadingPgn /*  132 */ ,
    sprmSOlstAnm /*      133 */ ,
    sprmNoop /*          134 */ ,
    sprmNoop /*          135 */ ,
    sprmSDxaColWidth /*  136 */ ,
    sprmSDxaColWidth /*  137 */ ,	/* new name */
    sprmSFEvenlySpaced /*138 */ ,
    sprmSFProtected /*   139 */ ,
    sprmSDmBinFirst /*   140 */ ,
    sprmSDmBinOther /*   141 */ ,
    sprmSBkc /*          142 */ ,
    sprmSFTitlePage /*   143 */ ,
    sprmSCcolumns /*     144 */ ,
    sprmSDxaColumns /*   145 */ ,
    sprmSFAutoPgn /*     146 */ ,
    sprmSNfcPgn /*       147 */ ,
    sprmSDyaPgn /*       148 */ ,
    sprmSDxaPgn /*       149 */ ,
    sprmSFPgnRestart /*  150 */ ,
    sprmSFEndnote /*     151 */ ,
    sprmSLnc /*          152 */ ,
    sprmSGprfIhdt /*     153 */ ,
    sprmSNLnnMod /*      154 */ ,
    sprmSDxaLnn /*       155 */ ,
    sprmSDyaHdrTop /*    156 */ ,
    sprmSDyaHdrBottom /* 157 */ ,
    sprmNoop /*          158 */ ,
    sprmSVjc /*          159 */ ,
    sprmSLnnMin /*       160 */ ,
    sprmSPgnStart /*     161 */ ,
    sprmSBOrientation /* 162 */ ,
    sprmSBCustomize /*   163 */ ,
    sprmSXaPage /*       164 */ ,
    sprmSYaPage /*       165 */ ,
    sprmSDxaLeft /*      166 */ ,
    sprmSDxaRight /*     167 */ ,
    sprmSDyaTop /*       168 */ ,
    sprmSDyaBottom /*    169 */ ,
    sprmSDzaGutter /*    170 */ ,
    sprmSDmPaperReq /*   171 */ ,
    sprmNoop /*          172 */ ,
    sprmNoop /*          173 */ ,
    sprmNoop /*          174 */ ,
    sprmNoop /*          175 */ ,
    sprmNoop /*          176 */ ,
    sprmNoop /*          177 */ ,
    sprmNoop /*          178 */ ,
    sprmNoop /*          179 */ ,
    sprmNoop /*          180 */ ,
    sprmNoop /*          181 */ ,
    sprmTJc /*           182 */ ,
    sprmTDxaLeft /*      183 */ ,
    sprmTDxaGapHalf /*   184 */ ,
    sprmTFCantSplit /*   185 */ ,
    sprmTTableHeader /*  186 */ ,
    sprmTTableBorders /* 187 */ ,
    sprmTDefTable10 /*   188 */ ,
    sprmTDyaRowHeight /* 189 */ ,
    sprmTDefTable /*     190 */ ,
    sprmTDefTableShd /*  191 */ ,
    sprmTTlp /*          192 */ ,
    sprmTSetBrc /*       193 */ ,
    sprmTInsert /*       194 */ ,
    sprmTDelete /*       195 */ ,
    sprmTDxaCol /*       196 */ ,
    sprmTMerge /*        197 */ ,
    sprmTSplit /*        198 */ ,
    sprmTSetBrc10 /*     199 */ ,
    sprmTSetShd /*       200 */ ,
    sprmNoop /*          201 */ ,
    sprmNoop /*          202 */ ,
    sprmNoop /*          203 */ ,

    sprmTUNKNOWN1 /*    204 */ ,
    /*guess I know that this should be either
     * a) 3 bytes long,
     * b) complex with a len of 2,
     * its certainly a table related sprm, my guess is sprmTVertMerge
     * as that fits its profile, but it isn't working in practice.
     * */
#if 0
    sprmNoop /*          205 */ ,
    sprmNoop /*          206 */ ,
    sprmNoop /*          207 */ ,
    sprmMax			/*           208 */
#endif
};

SprmName
wvGetrgsprmWord6 (U8 in)
{
    return (rgsprmWord6[in]);
}