File: table.c

package info (click to toggle)
abiword 0.7.7-1
  • links: PTS
  • area: main
  • in suites: potato
  • size: 20,604 kB
  • ctags: 18,358
  • sloc: cpp: 88,791; ansic: 66,296; sh: 7,777; makefile: 3,397; xml: 687; perl: 361; awk: 273; sed: 36; csh: 28
file content (799 lines) | stat: -rw-r--r-- 15,279 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
#include <stdlib.h>
#include <stdio.h>
#include "wv.h"
#include "bintree.h"

/*
allow figures within 3 units of each other to
be considered the same
*/
int cellCompLT(void *a,void *b)
    {
    S16 *a2,*b2;

	if (cellCompEQ(a,b))
		return(0);

    a2 = (S16 *)a;
    b2 = (S16 *)b;
    return( *a2 < (*b2)+3);
    }

int cellCompEQ(void *a,void *b)
    {
	int ret;
    S16 *a2,*b2;
    a2 = (S16 *)a;
    b2 = (S16 *)b;
	ret = abs(*a2 - *b2);
	if (ret <= 3)
		ret=1;
	else
		ret=0;
	return(ret);
    }

void wvGetRowTap(wvParseStruct *ps,PAP *dpap,U32 para_intervals,BTE *btePapx,U32 *posPapx)	
	{
	PAPX_FKP para_fkp;
	U32 para_fcFirst, para_fcLim=0xffffffffL;
	PAP apap;
	U32 i;
	S32 j=0;

	wvCopyPAP(&apap,dpap);

	wvInitPAPX_FKP(&para_fkp);

	i=ftell(ps->mainfd);
	wvTrace(("RowTab begin\n"));
	do
		{
		wvReleasePAPX_FKP(&para_fkp);		
		wvGetSimpleParaBounds(wvQuerySupported(&ps->fib,NULL),&para_fkp,&para_fcFirst,&para_fcLim,i, btePapx, posPapx, para_intervals, ps->mainfd);
		wvTrace(("2: para from %x to %x\n",para_fcFirst,para_fcLim));
		wvAssembleSimplePAP(wvQuerySupported(&ps->fib,NULL),&apap, para_fcLim, &para_fkp, &ps->stsh,ps->data);
		i=para_fcLim;
		}
	while (apap.fTtp == 0);

	wvTrace(("fTtp is %d\n",apap.fTtp));

	wvReleasePAPX_FKP(&para_fkp);
	wvCopyTAP(&(dpap->ptap),&apap.ptap);

	for (j=0;j<apap.ptap.itcMac+1;j++)
		wvTrace(("This Row-->%d\n",apap.ptap.rgdxaCenter[j]));
	}

void wvGetFullTableInit(wvParseStruct *ps,U32 para_intervals,BTE *btePapx,U32 *posPapx)	
	{
	PAPX_FKP para_fkp;
	U32 para_fcFirst, para_fcLim=0xffffffffL;
	PAP apap;
	U32 i,j=0;
	TAP *test=NULL;

	if (ps->intable) return;

	wvInitPAPX_FKP(&para_fkp);

	i = ftell(ps->mainfd);
	wvTrace(("TOP\n"));
	do
		{
		wvReleasePAPX_FKP(&para_fkp);		
		wvGetSimpleParaBounds(wvQuerySupported(&ps->fib,NULL),&para_fkp,&para_fcFirst,&para_fcLim,i, btePapx, posPapx, para_intervals, ps->mainfd);
		wvAssembleSimplePAP(wvQuerySupported(&ps->fib,NULL),&apap, para_fcLim, &para_fkp, &ps->stsh,ps->data);
		wvTrace(("para from %x to %x\n",para_fcFirst,para_fcLim));
		i=para_fcLim;

		/* ignore the row end markers */
		if (apap.ptap.itcMac)
			{
			test = (TAP *)realloc(test,sizeof(TAP)*(j+1));
			wvCopyTAP(&(test[j]),&apap.ptap);
			wvTrace(("Row %d\n",j));
			j++;
			}

		}
	while(apap.fInTable);
	wvTrace(("BOTTOM\n"));

	wvReleasePAPX_FKP(&para_fkp);

	wvSetTableInfo(ps,test,j);
	ps->intable=1;
	ps->norows=j;
	wvFree(test);
	}


/*
-------------------------
|          |            |
-------------------------
|   | | |    |     |    |
-------------------------
|                       |
-------------------------
|     |         |       |
-------------------------

==>

|   | | |  | |  |  |    |

As in this example we create a list of cell begin
positions which is a superset of all begin
positions in all rows, once we have this list we
restart at the top of the table and figure out
how many spans each cell has to achieve to match
back up to its original boundaries.

We will have to match boundaries that are with in
3 units of eachother to be the same boundary as
that occurs frequently in word tables, (gagh!)
*/
void wvSetTableInfo(wvParseStruct *ps,TAP *ptap,int no)
	{
	BintreeInfo tree;
	Node *testn,*testp;
	int i,j,k;

	if (ps->vmerges) 
		{
		wvTrace(("vmerges is not NULL\n"));
		for(i=0;i<ps->norows;i++)
			wvFree(ps->vmerges[i]);
		wvFree(ps->vmerges);
		ps->vmerges=NULL;
		}

	if (no == 0)
		{
		wvWarning("Broken tables, continuing and hoping for the best\n");
		ps->nocellbounds = 0;
		return;
		}

	InitBintree(&tree,cellCompLT,cellCompEQ);

	wvTrace(("we still ok, no is %d\n",no));

	for (i=0;i<no;i++)
		{
		for (j=0;j<ptap[i].itcMac+1;j++)
			{
			wvTrace(("%d\n",ptap[i].rgdxaCenter[j]));
			InsertNode(&tree,(void *) &(ptap[i].rgdxaCenter[j]) );
			}
		}
	wvTrace(("end of in\n"));

	testn = NextNode(&tree,NULL);

	ps->nocellbounds = tree.no_in_tree;
	wvFree(ps->cellbounds);
	if (tree.no_in_tree)
		ps->cellbounds=(S16 *)malloc(sizeof(S16) * tree.no_in_tree);
	else
		ps->cellbounds=NULL;

	i=0;
	wvTrace(("No in tree is %d\n",tree.no_in_tree));
    while (testn != NULL)
        {
		ps->cellbounds[i++] = *((S16 *)testn->Data);
		wvTrace(("cellbound are %d\n",ps->cellbounds[i-1]));
        testp = NextNode(&tree,testn);
        DeleteNode(&tree,testn);
        testn = testp;
        }
	wvTrace(("No in tree according to i is %d\n",i));

	wvTrace(("end of out\n"));

	ps->vmerges = (S16 **)malloc(sizeof(S16 *) * no);
	wvTrace(("no of rows is %d",no));
	for(i=0;i<no;i++)
		{
		ps->vmerges[i] = (S16 *)malloc(sizeof(S16) * ptap[i].itcMac);
		wvTrace(("no of cells is %d",ptap[i].itcMac));
		for (j=0;j<ptap[i].itcMac;j++)
			ps->vmerges[i][j]=1;
		}

	for (i=no-1;i>0;i--)
		{
		for (j=0;j<ptap[i].itcMac;j++)
			{
			wvTrace(("Vertical merge is %d\n",ptap[i].rgtc[j].fVertMerge));
			if (ptap[i].rgtc[j].fVertMerge)
				{
				wvTrace(("Vertical merge found, row %d, cell %d\n",i,j));
				/* 
				find a cell above me with the same boundaries
					if it is also merged increment it, and set myself to 0
					else leave me alone
				*/
				for(k=0;k<ptap[i-1].itcMac;k++)	/* the row above */
					{
					wvTrace(("cell begins are %d %d\n",ptap[i-1].rgdxaCenter[k],ptap[i].rgdxaCenter[j]));
					wvTrace(("cell ends are %d %d\n",ptap[i-1].rgdxaCenter[k+1],ptap[i].rgdxaCenter[j+1]));
				
					if ( (cellCompEQ((void *)&(ptap[i-1].rgdxaCenter[k]) ,(void *)&(ptap[i].rgdxaCenter[j])))
						&&
						(cellCompEQ((void *)&(ptap[i-1].rgdxaCenter[k+1]) ,(void *)&(ptap[i].rgdxaCenter[j+1]))) )
						{
						wvTrace(("found a cell above me, yippee\n"));
						if (ptap[i-1].rgtc[k].fVertMerge)
							{
							ps->vmerges[i-1][k]+=ps->vmerges[i][j];
							ps->vmerges[i][j]=0;
							}
						}

					}
				}
			}
		}


	for(i=0;i<no;i++)
		for (j=0;j<ptap[i].itcMac;j++)
			wvTrace(("rowspan numbers are %d\n",ps->vmerges[i][j]));
	}





/*	table backgrounds */
/*
 0  1  2  3		first row 	
 4  5  6  7		even row 	
 8  9 10 11		odd row 	
12 13 14 15 	last row 	

 F  E  O  L 
 i  v  d  a
 r  e  d  s
 s  n     t
 t     C 
    C  o  C
 C  o  l  o
 o  l  u  l
 l  u  m  u
 u  m  n  m
 m  n     n
 n
*/
	
static int cellbgcolors[40][4][4] = {

	/*0*/
	{
	{8, 8, 8, 8},
	{8, 8, 8, 8},
	{8, 8, 8, 8},
	{8, 8, 8, 8}
	},
	
	/*1*/
	{
	{8, 8, 8, 8},
	{8, 8, 8, 8},
	{8, 8, 8, 8},
	{8, 8, 8, 8}
	},

	/*2*/
	{
	{8, 8, 8, 8},
	{8, 8, 8, 8},
	{8, 8, 8, 8},
	{8, 8, 8, 8}
	},

	/*3*/
	{
	{1, 1, 1, 1},
	{8, 8, 8, 8},
	{8, 8, 8, 8},
	{8, 8, 8, 8}
	},

	/*4*/
	{
	{8, 8, 8, 8},
	{8, 8, 8, 8},
	{8, 8, 8, 8},
	{8, 8, 8, 8}
	},

	/*5*/
	{
	{12, 12, 12, 12},
	{16, 8, 8, 8},
	{16, 8, 8, 8},
	{16, 8, 8, 8}
	},

	/*6*/
	{
	{9, 9, 9, 9},
	{16, 16, 16, 16},
	{16, 16, 16, 16},
	{8, 8, 8, 8}
	},

	/*7*/
	{
	{2, 2, 2, 2},
	{8, 8, 8, 8},
	{8, 8, 8, 8},
	{15, 15, 15, 15}
	},

	/*8*/
	{
	{1, 1, 1, 1},
	{9, 11, 11, 11},
	{9, 11, 11, 11},
	{9, 11, 11, 11}
	},

	/*9*/
	{
	{6, 6, 6, 6},
	{7, 7, 7, 16},
	{7, 7, 7, 16},
	{7, 7, 7, 16}
	},
	
	/*10*/
	{
	{1, 11, 11, 11},
	{11, 3, 3, 3},
	{11, 3, 3, 3},
	{11, 3, 3, 3}
	},

	/*11*/
	{
	{16, 16, 7, 16},
	{16, 16, 7, 16},
	{16, 16, 7, 16},
	{16, 16, 7, 16}
	},

	/*12*/
	{
	{9, 9, 9, 9},
	{16, 16, 4, 16},
	{16, 16, 4, 16},
	{16, 16, 4, 16}
	},

	/*13*/
	{
	{9, 9, 9, 9},
	{15, 15, 16, 15},
	{15, 15, 16, 15},
	{15, 15, 16, 15}
	},

	/*14*/
	{
	{1, 1, 1, 1},
	{3, 3, 16, 3},
	{3, 3, 16, 3},
	{3, 3, 16, 3}
	},

	/*15*/
	{
	{15, 15, 8, 15},
	{15, 15, 8, 15},
	{15, 15, 8, 15},
	{15, 15, 8, 15}
	},

	/*16*/
	{
	{8, 8, 8, 8},
	{8, 8, 8, 8},
	{8, 8, 8, 8},
	{8, 8, 8, 8}
	},
	
	/*17*/
	{
	{8, 8, 8, 8},
	{8, 8, 8, 8},
	{8, 8, 8, 8},
	{8, 8, 8, 8}
	},

	/*18*/
	{
	{7, 7, 7, 7},
	{8, 8, 8, 8},
	{8, 8, 8, 8},
	{8, 8, 8, 8}
	},

	/*19*/
	{
	{7, 7, 7, 7},
	{8, 8, 8, 8},
	{8, 8, 8, 8},
	{7, 7, 7, 7}
	},

	/*20*/
	{
	{8, 8, 8, 8},
	{8, 8, 8, 8},
	{8, 8, 8, 8},
	{8, 8, 8, 8}
	},

	/*21*/
	{
	{8, 8, 8, 8},
	{8, 8, 8, 8},
	{8, 8, 8, 8},
	{8, 8, 8, 8}
	},

	/*22*/
	{
	{8, 8, 8, 8},
	{8, 8, 8, 8},
	{8, 8, 8, 8},
	{8, 8, 8, 8}
	},

	/*23*/
	{
	{9, 9, 9, 9},
	{8, 8, 8, 8},
	{8, 8, 8, 8},
	{8, 8, 8, 8}
	},

	/*24*/
	{
	{16, 16, 16, 16},
	{8, 8, 8, 8},
	{16, 16, 16, 16},
	{8, 8, 8, 8}
	},

	/*25*/
	{
	{11, 11, 11, 11},
	{8, 8, 8, 8},
	{4, 4, 4, 4},
	{8, 8, 8, 8}
	},

	/*26*/
	{
	{8, 8, 8, 8},
	{8, 8, 8, 8},
	{8, 8, 8, 8},
	{8, 8, 8, 8}
	},

	/*27*/
	{
	{15, 15, 15, 15},
	{8, 8, 8, 8},
	{8, 8, 8, 8},
	{8, 8, 8, 8}
	},

	/*28*/
	{
	{8, 8, 8, 8},
	{8, 8, 8, 8},
	{8, 8, 8, 8},
	{8, 8, 8, 8}
	},

	/*29*/
	{
	{15, 15, 15, 15},
	{15, 15, 15, 15},
	{16, 16, 16, 16},
	{15, 15, 15, 15}
	},

	/*30*/
	{
	{16, 16, 16, 16},
	{7, 7, 7, 7},
	{16, 16, 16, 16},
	{8, 8, 8, 8}
	},

	/*31*/
	{
	{7, 7, 7, 7},
	{6, 6, 6, 6},
	{14, 14, 14, 14},
	{6, 6, 6, 6}
	},

	/*32*/
	{
	{15, 15, 15, 15},
	{15, 15, 15, 15},
	{15, 15, 15, 15},
	{15, 15, 15, 15}
	},

	/*33*/
	{
	{15, 15, 15, 15},
	{15, 15, 15, 15},
	{15, 15, 15, 15},
	{15, 15, 15, 15}
	},

	/*34*/
	{
	{15, 15, 16, 15},
	{15, 15, 16, 15},
	{15, 15, 16, 15},
	{15, 15, 16, 15}
	},

	/*35*/
	{
	{15, 15, 15, 15},
	{15, 15, 15, 15},
	{16, 16, 16, 16},
	{15, 15, 15, 15}
	},

	/*36*/
	{
	{8, 8, 8, 8},
	{8, 8, 8, 8},
	{8, 8, 8, 8},
	{8, 8, 8, 8}
	},

	/*37*/
	{
	{1, 1, 1, 1},
	{8, 8, 8, 8},
	{8, 8, 8, 8},
	{8, 8, 8, 8}
	},

	/*38*/
	{
	{8, 8, 8, 8},
	{8, 8, 8, 8},
	{10, 10, 10, 10},
	{5, 5, 5, 5}
	},

	/*39*/
	{
	{8, 8, 8, 8},
	{4, 8, 8, 10},
	{4, 8, 8, 10},
	{4, 8, 8, 10}
	}
	
	};
		

/* 
determine where we should be in the grid, 
if we do not want the special end cases, and we are
one of them, then shift into a new location in
the grid, and output the color sitting there
*/

int wvCellBgColor(int whichrow,int whichcell,int nocells,int norows,TLP *tlp)
	{
	if (whichrow == norows-1)
		whichrow=3;
	else if (whichrow > 0)
		{
		if (isodd(whichrow)) 
			whichrow=2;
		else
			whichrow=1;
		}

	if (whichcell == nocells-1)
		whichcell=3;
	else if (whichcell > 0)
		{
		if (isodd(whichcell)) 
			whichcell=2;
		else
			whichcell=1;
		}

	wvTrace(("the cell index and bgcolor is %d %d %d,%d (last cell and row are %d %d)\n",tlp->itl,whichrow,whichcell,cellbgcolors[tlp->itl][whichrow][whichcell],nocells,norows));
	if (tlp->itl >= 40)
		{
		wvWarning("Table Look %d requested, but theres only %d in the list\n",tlp->itl+1,40);
		return(8);
		}
	return(cellbgcolors[tlp->itl][whichrow][whichcell]);
	}

/*
get the end cp of the piece

i as a cp
wvGetComplexParaBounds as fc's
go to the end as a cp
*/
void TheTest(wvParseStruct *ps,U32 piece,BTE *btePapx,U32 *posPapx,U32 para_intervals)	
	{
	U32 piececount;
	U8 chartype;
	U32 begincp,endcp;
	U32 beginfc,endfc;
	U32 i,j,k=0;
	U32 para_fcFirst,para_fcLim;
	PAPX_FKP para_fkp;
	PAP apap;
	int cpiece=0;

	long pos = ftell(ps->mainfd);
	wvInitPAPX_FKP(&para_fkp);

	para_fcFirst = wvConvertCPToFC(ps->currentcp,&ps->clx);

	for (piececount=piece;piececount<ps->clx.nopcd;piececount++)
		{
		chartype = wvGetPieceBoundsFC(&beginfc,&endfc,&ps->clx,piececount);
		fseek(ps->mainfd,beginfc,SEEK_SET);
		wvGetPieceBoundsCP(&begincp,&endcp,&ps->clx,piececount);
		if (k==0)
			{
			wvTrace(("cp distance is %d, cp is %d\n",ps->currentcp-begincp,ps->currentcp));
			wvTrace(("no of pieces is %d, this one is %d\n",ps->clx.nopcd,piece));
			k++;
			begincp = ps->currentcp;
			beginfc = wvConvertCPToFC(ps->currentcp,&ps->clx);
			}
		wvTrace(("begin and end are %d %d (%x %x)\n",begincp,endcp,beginfc,endfc));
		para_fcLim=0xffffffffL;
		for (i=begincp,j=beginfc;(i<endcp && i<ps->fib.ccpText);i++,j += wvIncFC(chartype))
			{
			if ((para_fcLim == 0xffffffffL) || (para_fcLim == j))
            	{
                wvReleasePAPX_FKP(&para_fkp);
                wvTrace(("cp and fc are %x(%d) %x\n",i,i,wvConvertCPToFC(i, &ps->clx)));
                cpiece = wvGetComplexParaBounds(wvQuerySupported(&ps->fib,NULL),&para_fkp,&para_fcFirst,&para_fcLim,wvConvertCPToFC(i, &ps->clx),
					&ps->clx, btePapx, posPapx, para_intervals,piececount,ps->mainfd);
                wvTrace(("para begin and end is %x %x, pieceend is %x\n",para_fcFirst,para_fcLim,wvConvertCPToFC(endcp,&ps->clx)));
                } 
			 if (j == para_fcFirst)
                {
                wvAssembleSimplePAP(wvQuerySupported(&ps->fib,NULL),&apap,para_fcLim,&para_fkp,&ps->stsh,ps->data);
                wvAssembleComplexPAP(wvQuerySupported(&ps->fib,NULL),&apap,cpiece,&ps->stsh,&ps->clx,ps->data);
				wvTrace(("table ttp are %d %d\n",apap.fInTable,apap.fTtp));
				}
			}
		}

	fseek(ps->mainfd,pos,SEEK_SET);
	}

void wvGetComplexFullTableInit(wvParseStruct *ps,U32 para_intervals,BTE *btePapx,U32 *posPapx,U32 piece)	
	{
	PAPX_FKP para_fkp;
	U32 para_fcFirst, para_fcLim=0xffffffffL;
	PAP apap;
	U32 i,j=0,k=0;
	S32 l;
	TAP *test=NULL;

	if (ps->intable) return;

#if 0
	/* some testing code */
	wvTrace(("before test\n"));
	TheTest(ps,piece,btePapx,posPapx,para_intervals);
	wvTrace(("after test\n"));
#endif

	wvInitPAPX_FKP(&para_fkp);

	i = ftell(ps->mainfd);
	wvTrace(("TOP\n"));
	do
		{
		wvTrace(("cycle again\n"));
		wvReleasePAPX_FKP(&para_fkp);		

		wvTrace(("2: cp and fc are %x(%d) %x\n",i,i,wvConvertCPToFC(i, &ps->clx)));
		piece = wvGetComplexParaBounds(wvQuerySupported(&ps->fib,NULL),&para_fkp,&para_fcFirst,&para_fcLim,
			i,&ps->clx, btePapx, posPapx, para_intervals,piece,ps->mainfd);


		if (piece == 0xffffffffL) break;
		wvAssembleSimplePAP(wvQuerySupported(&ps->fib,NULL),&apap, para_fcLim, &para_fkp, &ps->stsh,ps->data);
		wvTrace(("para from %x to %x\n",para_fcFirst,para_fcLim));
		wvAssembleComplexPAP(wvQuerySupported(&ps->fib,NULL),&apap,piece,&ps->stsh,&ps->clx,ps->data);
		
		wvTrace(("para from %x to %x\n",para_fcFirst,para_fcLim));
		i=para_fcLim;

		/* ignore the row end markers */
		if (apap.ptap.itcMac)
			{
			test = (TAP *)realloc(test,sizeof(TAP)*(j+1));
			wvCopyTAP(&(test[j]),&apap.ptap);
			for (l=0;l<apap.ptap.itcMac+1;l++)
				wvTrace(("In This Row-->%d\n",apap.ptap.rgdxaCenter[l]));
			j++;
			}
		if (apap.fTtp)
			k++;
		}
	while(apap.fInTable);
	wvTrace(("BOTTOM\n"));
#ifdef DEBUG
	if (piece == 0xffffffffL)
		wvTrace(("broken on line %d\n",j));
#endif
	wvTrace(("no of lines is %d %d\n",j,k));

	wvReleasePAPX_FKP(&para_fkp);

	wvSetTableInfo(ps,test,j);
	ps->intable=1;
	ps->norows=j;
	wvFree(test);
	}

void wvGetComplexRowTap(wvParseStruct *ps,PAP *dpap,U32 para_intervals,BTE *btePapx,U32 *posPapx,U32 piece)	
	{
	PAPX_FKP para_fkp;
	U32 para_fcFirst, para_fcLim=0xffffffffL;
	PAP apap;
	U32 i;
	S32 j=0;

	wvCopyPAP(&apap,dpap);

	wvInitPAPX_FKP(&para_fkp);

	i=ftell(ps->mainfd);

	do
		{
		wvReleasePAPX_FKP(&para_fkp);		
		
		wvTrace(("3: cp and fc are %x(%d) %x\n",i,i,wvConvertCPToFC(i, &ps->clx)));
		piece = wvGetComplexParaBounds(wvQuerySupported(&ps->fib,NULL),&para_fkp,&para_fcFirst,&para_fcLim,i,&ps->clx, btePapx, posPapx, para_intervals,piece,ps->mainfd);
		if (piece == 0xffffffffL) break;
		wvAssembleSimplePAP(wvQuerySupported(&ps->fib,NULL),&apap, para_fcLim, &para_fkp, &ps->stsh,ps->data);
        wvAssembleComplexPAP(wvQuerySupported(&ps->fib,NULL),&apap,piece,&ps->stsh,&ps->clx,ps->data);
		wvTrace(("para from %x to %x, table is %d\n",para_fcFirst,para_fcLim,apap.fInTable));
		i=para_fcLim;
		}
	while(apap.fTtp == 0);

	wvReleasePAPX_FKP(&para_fkp);
	wvCopyTAP(&(dpap->ptap),&apap.ptap);

	for (j=0;j<apap.ptap.itcMac+1;j++)
		wvTrace(("This Row-->%d\n",apap.ptap.rgdxaCenter[j]));
	}