U32 wvGetBlip (Blip * blip, wvStream * fd, wvStream * delay) { U32 i, count, count2; MSOFBH amsofbh; long pos = 0; count = wvGetFBSE (&blip->fbse, fd); wvTrace (("count is %d\n", count)); if (blip->fbse.cbName == 0) blip->name = NULL; else blip->name = (U16 *) wvMalloc (sizeof (U16) * blip->fbse.cbName); for (i = 0; i < blip->fbse.cbName; i++) blip->name[i] = read_16ubit (fd); count += blip->fbse.cbName * 2; wvTrace (("count is %d\n", count)); wvTrace (("offset %x\n", blip->fbse.foDelay)); if (delay) { pos = wvStream_tell (delay); if(blip->fbse.foDelay!=-1) wvStream_goto (delay, blip->fbse.foDelay); wvTrace (("offset %x\n", blip->fbse.foDelay)); fd = delay; } count2 = wvGetMSOFBH (&amsofbh, fd); wvTrace (("count is %d\n", count2)); wvTrace ( ("HERE is %x %x (%d)\n", wvStream_tell (fd), amsofbh.fbt, amsofbh.fbt - msofbtBlipFirst)); wvTrace (("type is %x\n", amsofbh.fbt)); switch (amsofbh.fbt - msofbtBlipFirst) { case msoblipWMF: case msoblipEMF: case msoblipPICT: count2 += wvGetMetafile (&blip->blip.metafile, &amsofbh, fd); break; case msoblipJPEG: case msoblipPNG: case msoblipDIB: count2 += wvGetBitmap (&blip->blip.bitmap, &amsofbh, fd); break; } wvTrace (("count is %d\n", count2)); blip->type = amsofbh.fbt - msofbtBlipFirst; if (delay) { wvStream_goto (delay, pos); return (count); } return (count + count2); }
int wv0x01(Blip *blip, wvStream *fd, U32 len) { MSOFBH amsofbh; FSPContainer item; U32 count = 0; /* char test[3];*/ int ret = 0; if (fd == NULL) return 0; /*[email protected] fix hack as outdated look picf*/ /* temp hack to test older included bmps in word 6 and 7, should be wrapped in a modern escher strucure before getting to here, and then handled as normal */ /*test[2] = '\0'; test[0] = read_8ubit (fd); test[1] = read_8ubit (fd); wvStream_rewind (fd); if (!(strcmp (test, "BM"))) { blip->blip.bitmap.m_pvBits = fd; blip->type = msoblipDIB; return (1); } */ while (count < len) { wvTrace(("count is %x,len is %x\n", count, len)); count += wvGetMSOFBH(&amsofbh, fd); wvTrace(("type is %x\n ", amsofbh.fbt)); switch (amsofbh.fbt) { case msofbtSpContainer: wvTrace(("Container at %x\n", wvStream_tell(fd))); count += wvGetFSPContainer(&item, &amsofbh, fd); wvReleaseFSPContainer(&item); break; case msofbtBSE: wvTrace(("Blip at %x\n", wvStream_tell(fd))); count += wvGetBlip(blip, fd, NULL); ret = 1; break; default: wvError(("Not a shape container\n")); return 0; break; } } return ret; }
U32 wvStream_size (wvStream * in) { U32 size; long offset = wvStream_tell(in); wvStream_offset_from_end(in,0); size = wvStream_tell(in); wvStream_goto(in,offset); return size; }
void wvGetEscher(escherstruct *item, U32 offset, U32 len, wvStream *fd, wvStream *delay) { U32 count = 0; MSOFBH amsofbh; wvStream_goto(fd, offset); wvTrace(("offset %x, len %d\n", offset, len)); wvInitEscher(item); while (count < len) { count += wvGetMSOFBH(&amsofbh, fd); wvTrace( ("count is %x,len is %x, next len is %x\n", count, len, amsofbh.cbLength)); wvTrace(("type is %x\n ", amsofbh.fbt)); switch (amsofbh.fbt) { case msofbtDggContainer: count += wvGetDggContainer(&item->dggcontainer, &amsofbh, fd, delay); break; case msofbtDgContainer: count += wvGetDgContainer(&item->dgcontainer, &amsofbh, fd); break; default: wvError(("Not a container, panic (%x)\n", amsofbh.fbt)); return; break; } } wvTrace(("offset %x, len %d (pos %x)\n", offset, len, wvStream_tell(fd))); }
U32 wvGetBstoreContainer(BstoreContainer *item, MSOFBH *msofbh, wvStream *fd, wvStream *delay) { MSOFBH amsofbh; U32 count = 0; while (count < msofbh->cbLength) { count += wvGetMSOFBH(&amsofbh, fd); wvTrace(("type is %x\n ", amsofbh.fbt)); switch (amsofbh.fbt) { case msofbtBSE: wvTrace(("Blip at %x\n", wvStream_tell(fd))); item->no_fbse++; item->blip = (Blip *)realloc(item->blip, sizeof(Blip) * item->no_fbse); count += wvGetBlip((&item->blip[item->no_fbse - 1]), fd, delay); wvTrace( ("type is %d (number is %d\n", item->blip[item->no_fbse - 1].type, item->no_fbse)); break; default: count += wvEatmsofbt(&amsofbh, fd); wvError(("Eating type 0x%x\n", amsofbh.fbt)); break; } } return count; }
bool check_password(char *password) { int offset = wvStream_tell(ps.tablefd); wvSetPassword(password, &ps); bool r = false; switch (version) { case WORD6: case WORD7: r = wvDecrypt95(&ps) == 0; break; case WORD8: r = wvDecrypt97(&ps) == 0; break; } gsf_input_seek(ps.tablefd->stream.gsf_stream, offset, G_SEEK_SET); return r; }
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; wvVersion ver = wvQuerySupported (&ps->fib, NULL); if (ps->intable) return; wvInitPAPX_FKP (¶_fkp); i = wvStream_tell (ps->mainfd); wvTrace (("TOP\n")); do { wvReleasePAPX_FKP (¶_fkp); wvGetSimpleParaBounds (ver, ¶_fkp, ¶_fcFirst, ¶_fcLim, i, btePapx, posPapx, para_intervals, ps->mainfd); wvAssembleSimplePAP (ver, &apap, para_fcLim, ¶_fkp, ps); wvTrace (("para from %x to %x\n", para_fcFirst, para_fcLim)); i = para_fcLim; /* ignore the row end markers */ /*if (apap.ptap.itcMac)*/ /* we ascertain the number of rows by counting the end of row markers. NB: a row marker can have a 0 itcMac*/ if (apap.fTtp) { 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 (¶_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; wvVersion ver = wvQuerySupported (&ps->fib, NULL); wvCopyPAP (&apap, dpap); wvInitPAPX_FKP (¶_fkp); i = wvStream_tell (ps->mainfd); do { wvReleasePAPX_FKP (¶_fkp); wvTrace ( ("3: cp and fc are %x(%d) %x\n", i, i, wvConvertCPToFC (i, &ps->clx))); piece = wvGetComplexParaBounds (ver, ¶_fkp, ¶_fcFirst, ¶_fcLim, i, &ps->clx, btePapx, posPapx, para_intervals, piece, ps->mainfd); if (piece == 0xffffffffL) break; wvAssembleSimplePAP (ver, &apap, para_fcLim, ¶_fkp, ps); wvAssembleComplexPAP (ver, &apap, piece, ps); 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 (¶_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 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; wvVersion ver = wvQuerySupported (&ps->fib, NULL); wvCopyPAP (&apap, dpap); wvInitPAPX_FKP (¶_fkp); i = wvStream_tell (ps->mainfd); wvTrace (("RowTab begin\n")); do { wvReleasePAPX_FKP (¶_fkp); wvGetSimpleParaBounds (ver, ¶_fkp, ¶_fcFirst, ¶_fcLim, i, btePapx, posPapx, para_intervals, ps->mainfd); wvTrace (("2: para from %x to %x\n", para_fcFirst, para_fcLim)); wvAssembleSimplePAP (ver, &apap, para_fcLim, ¶_fkp, ps); i = para_fcLim; } while ((apap.fTtp == 0) && apap.fInTable); /* placing '&& apap.fInTable' here fixes #11433. I can't find any regressions */ wvTrace (("fTtp is %d\n", apap.fTtp)); wvReleasePAPX_FKP (¶_fkp); wvCopyTAP (&(dpap->ptap), &apap.ptap); for (j = 0; j < apap.ptap.itcMac + 1; j++) wvTrace (("This Row-->%d\n", apap.ptap.rgdxaCenter[j])); }
U32 wvGetBitmap(BitmapBlip *abm, MSOFBH *amsofbh, wvStream *fd) { U32 i, count; char extra = 0; wvStream *stm = NULL; wvTrace(("starting bitmap at %x\n", wvStream_tell(fd))); for (i = 0; i < 16; i++) abm->m_rgbUid[i] = read_8ubit(fd); count = 16; abm->m_rgbUidPrimary[0] = 0; switch (amsofbh->fbt - msofbtBlipFirst) { case msoblipPNG: wvTrace(("msoblipPNG\n")); /* sprintf(buffer,"%s-wv-%d.png",aimage,no++); */ if (amsofbh->inst ^ msobiPNG) extra = 1; break; case msoblipJPEG: wvTrace(("msoblipJPEG\n")); /* sprintf(buffer,"%s-wv-%d.jpg",aimage,no++); */ if (amsofbh->inst ^ msobiJFIF) extra = 1; break; case msoblipDIB: wvTrace(("msoblipDIB\n")); /* sprintf(buffer,"%s-wv-%d.dib",aimage,no++); */ if (amsofbh->inst ^ msobiDIB) extra = 1; break; } if (extra) { for (i = 0; i < 16; i++) abm->m_rgbUidPrimary[i] = read_8ubit(fd); count += 16; } abm->m_bTag = read_8ubit(fd); abm->m_pvBits = NULL; count++; stm = wvStream_TMP_create(amsofbh->cbLength); if (!stm) { abm->m_pvBits = NULL; return 0; } for (i = count; i < amsofbh->cbLength; i++) write_8ubit(stm, read_8ubit(fd)); wvStream_rewind(stm); abm->m_pvBits = stm; count += i; return count; }
static int specCharProc (wvParseStruct * ps, U16 eachchar, CHP * achp) { Blip blip; wvStream *fil; long pos; FSPA *fspa; PICF picf; FDOA *fdoa; switch (eachchar) { case 19: /* field begin */ ps->fieldstate++; ps->fieldmiddle = 0; return 0; case 20: /* field separator */ if (achp->fOle2) { wvTrace (("Field has an embedded OLE2 object\n")); } ps->fieldmiddle = 1; return 0; case 21: /* field end */ ps->fieldstate--; ps->fieldmiddle = 0; return 0; default: break; } /* TODO: properly handle fields */ if (ps->fieldstate) { if (eachchar == 0x13 || eachchar == 0x14) return 0; } /* image handling */ switch (eachchar) { case 0x01: if (achp->fOle2) { wvTrace (("embedded OLE2 component. currently unsupported")); return 0; } pos = wvStream_tell (ps->data); wvStream_goto (ps->data, achp->fcPic_fcObj_lTagObj); wvGetPICF (wvQuerySupported (&ps->fib, NULL), &picf, ps->data); fil = picf.rgb; if (wv0x01 (&blip, fil, picf.lcb - picf.cbHeader)) { handleImage (&blip, picf.dxaGoal, picf.dyaGoal); } else { wvTrace (("Dom: strange no graphic data 1\n")); } wvStream_goto (ps->data, pos); return 0; break; case 0x08: if (wvQuerySupported (&ps->fib, NULL) == WORD8) { if (ps->nooffspa > 0) { fspa = wvGetFSPAFromCP (ps->currentcp, ps->fspa, ps->fspapos, ps->nooffspa); if (!fspa) { wvError ( ("No fspa! Panic and Insanity Abounds!\n")); return 0; } if (wv0x08 (&blip, fspa->spid, ps)) { handleImage (&blip, fspa->xaRight - fspa->xaLeft, fspa->yaBottom - fspa->yaTop); } else { wvTrace (("Dom: strange no graphic data 2\n")); return 0; } } else { wvTrace (("nooffspa was <=0 -- ignoring")); } } else { wvError ( ("pre Word8 0x08 graphic -- unsupported at the moment")); fdoa = wvGetFDOAFromCP (ps->currentcp, NULL, ps->fdoapos, ps->nooffdoa); } } return 0; }
/* return value: 1 == success 0 == failure */ int wvGetPICF (wvVersion ver, PICF * apicf, wvStream * fd) { U8 temp; U32 i; U8 *buf,*p; size_t size; long pos = wvStream_tell (fd); apicf->lcb = read_32ubit (fd); apicf->cbHeader = read_16ubit (fd); wvTrace (("size of pic is %x (%d)\n", apicf->cbHeader, apicf->cbHeader)); apicf->mfp_mm = (S16) read_16ubit (fd); wvTrace (("mm type is %d\n", apicf->mfp_mm)); apicf->mfp_xExt = (S16) read_16ubit (fd); apicf->mfp_yExt = (S16) read_16ubit (fd); apicf->mfp_hMF = (S16) read_16ubit (fd); if (apicf->mfp_mm == 99) wvGetBITMAP (&(apicf->obj.bitmap), fd); else wvGetrc (&(apicf->obj.arc), fd); apicf->dxaGoal = (S16) read_16ubit (fd); apicf->dyaGoal = (S16) read_16ubit (fd); apicf->mx = read_16ubit (fd); apicf->my = read_16ubit (fd); apicf->dxaCropLeft = (S16) read_16ubit (fd); apicf->dyaCropTop = (S16) read_16ubit (fd); apicf->dxaCropRight = (S16) read_16ubit (fd); apicf->dyaCropBottom = (S16) read_16ubit (fd); temp = read_8ubit (fd); apicf->brcl = temp & 0x0F; apicf->fFrameEmpty = (temp & 0x10) >> 4; apicf->fBitmap = (temp & 0x20) >> 5; wvTrace (("bitmap is %d\n", apicf->fBitmap)); apicf->fDrawHatch = (temp & 0x40) >> 6; apicf->fError = (temp & 0x80) >> 7; apicf->bpp = read_8ubit (fd); wvGetBRC (ver, &(apicf->brcTop), fd); wvGetBRC (ver, &(apicf->brcLeft), fd); wvGetBRC (ver, &(apicf->brcBottom), fd); wvGetBRC (ver, &(apicf->brcRight), fd); apicf->dxaOrigin = (S16) read_16ubit (fd); apicf->dyaOrigin = (S16) read_16ubit (fd); if (ver == WORD8) apicf->cProps = (S16) read_16ubit (fd); else apicf->cProps = 0; pos = wvStream_tell (fd) - pos; for (i = pos; i < apicf->cbHeader; i++) read_8ubit (fd); wvTrace (("pos is finally %x\n", wvStream_tell (fd))); wvTrace (("len of data is %d\n", apicf->lcb - apicf->cbHeader)); wvTrace ( ("ends at %x\n", wvStream_tell (fd) + apicf->lcb - apicf->cbHeader)); i = 0; if (apicf->mfp_mm < 90){ MSOFBH bse_pic_amsofbh; size_t lHeaderSize; size_t lWordStructsSize; U8 *pHeader; U8 *pWordStructs; U32 len; U32 j; U8 bmp_header[40]; U32 header_len; U32 colors_used; U16 bpp; pWordStructs = pHeader = 0; wvTrace (("test\n")); len = apicf->lcb - apicf->cbHeader; /*[email protected] store*/ pos = wvStream_tell (fd); i = wvEatOldGraphicHeader (fd, len); if(i!=-1)/*Found BMP */ { wvTrace (("len is %d, header len guess is %d\n", len, i)); if (i + 2 >= len) { wvTrace (("all read ok methinks\n")); apicf->rgb = NULL; return 1; } len -= i; pos = wvStream_tell (fd); for(j=0;j< sizeof(bmp_header);j++) bmp_header[j] = read_8ubit (fd); bpp = bmp_header[14] + (bmp_header[15] << 8); if ( bpp < 9) { colors_used = bmp_header[32] + (bmp_header[33] << 8) + (bmp_header[34] << 16) + (bmp_header[35] << 24); } else { colors_used = 0; } wvStream_goto(fd,pos); header_len = 14 + 40 + 4 * colors_used; /*Get Blip Header Size*/ lHeaderSize = PutWord8BitmapHeader(apicf, 0, len + i-14, header_len); pHeader = malloc(lHeaderSize); /*Write Blip Header*/ PutWord8BitmapHeader(apicf, pHeader, len, header_len); /*Set Type of FBSE Header*/ bse_pic_amsofbh.ver = 0; bse_pic_amsofbh.inst = msobiDIB; bse_pic_amsofbh.fbt = msofbtBlipFirst + msoblipDIB;/*msoblipJPEG msoblipPNG*/ bse_pic_amsofbh.cbLength = lHeaderSize+len; }else{/*must be WMF*/ /*Get Blip Header Size*/ lHeaderSize = PutWord8MetafileHeader(apicf, 0); pHeader = malloc(lHeaderSize); /*Write Blip Header*/ PutWord8MetafileHeader(apicf, pHeader); /*Set Type of FBSE Header*/ bse_pic_amsofbh.ver = 0; bse_pic_amsofbh.inst = msobiWMF; bse_pic_amsofbh.fbt = msofbtBlipFirst + msoblipWMF; bse_pic_amsofbh.cbLength = lHeaderSize+len; i = 0; wvStream_goto(fd,pos); } lWordStructsSize = PutWord8Structs(&bse_pic_amsofbh, 0,0); pWordStructs = malloc(lWordStructsSize); PutWord8Structs(&bse_pic_amsofbh, pWordStructs, lWordStructsSize); size = lHeaderSize + lWordStructsSize + apicf->lcb - apicf->cbHeader; p = buf = malloc(size); if(!p) { free(pWordStructs); free(pHeader); return 0; } memcpy(p, pWordStructs, lWordStructsSize); p+= lWordStructsSize; memcpy(p, pHeader, lHeaderSize); p+=lHeaderSize; free(pWordStructs); free(pHeader); } else{ size = apicf->lcb - apicf->cbHeader; p = buf = malloc(size); } #if 0 for (; i < apicf->lcb - apicf->cbHeader; i++) *p++ = read_8ubit (fd); #endif U32 length = apicf->lcb - apicf->cbHeader - i; if (fd->kind == GSF_STREAM) { gsf_input_read (GSF_INPUT (fd->stream.gsf_stream), length, p); p += length; } else if (fd->kind == FILE_STREAM) { fread(p, sizeof(guint8), length, fd->stream.file_stream); p += length; } else { memorystream_read(fd->stream.memory_stream, p, length); p += length; } /* f = fopen("test.dat","wb"); fwrite(buf, 1,size, f); fclose(f); */ wvStream_memory_create(&apicf->rgb, (char*)buf, size); return 1; }
U32 wvEatOldGraphicHeader (wvStream * fd, U32 len) { U32 X, entry, count = 0, test; U16 pad; test = read_32ubit (fd); /*0x00090001 */ if (test != 0x00090001L){ wvError (("Old Graphic\n")); return -1; } count += 4; test = read_16ubit (fd); /*0x0300 */ if (test != 0x0300){ wvError (("Old Graphic\n")); return -1; } count += 2; read_32ubit (fd); /*changes */ count += 4; test = read_16ubit (fd); /*0x0000 */ if (test != 0x00000000L){ wvError (("Old Graphic\n")); return -1; } count += 2; X = read_32ubit (fd); /*changes, lets call this X */ wvError (("X is %x\n", X)); count += 4; test = read_16ubit (fd); /*0x0000 */ if (test != 0x00000000L){ wvError (("Old Graphic\n")); return -1; } count += 2; /* while ( entry != X) */ do { entry = read_32ubit (fd); count += 4; wvTrace ( ("Entry is %x, %x, count is %d\n", entry, wvStream_tell (fd), count)); switch (entry) { case 3: read_16ubit (fd); count += 2; wvTrace ( ("suspect that we are finished, count %d, len %d\n", count, len)); break; default: { U32 lene2 = entry - 2; U32 i; wvTrace ( ("lene2 is %d, predict end of %x\n", len, wvStream_tell (fd) + (entry - 2) * 2)); /* RIES ([email protected]) prolly a dirty patch because I check count everytime it's incremnented against lene2. This seems twork very well I tried it on around 15.000 word documents and it seems to work! */ for (i = 0; i < lene2; i++) { if ( (count + 1) >= len) return (count); test = read_16ubit (fd); if ((i == 0) && ((test == 0x0f43) || (test == 0x0b41))) { wvTrace ( ("Found a Bitmap, Will strip header and return with bitmap data\n")); count += 2; if ( (count + 1) >= len) return (count); pad = test; test = read_32ubit (fd); /*0x00cc0020 */ if (test != 0x00cc0020) wvTrace (("Old Graphic\n")); count += 4; if ( (count + 1) >= len) return (count); if (pad == 0x0f43) { test = read_16ubit (fd); /*0x0000 */ if (test != 0x0000) wvTrace (("Old Graphic\n")); count += 2; if ( (count + 1) >= len) return (count); } read_16ubit (fd); /*width */ count += 2; if ( (count + 1) >= len) return (count); read_16ubit (fd); /*height */ count += 2; if ( (count + 1) >= len) return (count); test = read_32ubit (fd); /*0x00000000L */ if (test != 0x00000000L) wvTrace (("Old Graphic\n")); count += 4; if ( (count + 1) >= len) return (count); read_16ubit (fd); /*width */ count += 2; if ( (count + 1) >= len) return (count); read_16ubit (fd); /*height */ count += 2; if ( (count + 1) >= len) return (count); test = read_32ubit (fd); /*0x00000000L */ if (test != 0x00000000L) wvTrace (("Old Graphic\n")); count += 4; return (count); } count += 2; if ( (count + 1) >= len) return (count); } } break; } } while (count + 1 < len); wvTrace (("Entry is %x %x, %d\n", entry, wvStream_tell (fd), count)); return (count); }
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; wvVersion ver = wvQuerySupported (&ps->fib, 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 (¶_fkp); i = wvStream_tell (ps->mainfd); wvTrace (("TOP\n")); do { wvTrace (("cycle again\n")); wvReleasePAPX_FKP (¶_fkp); wvTrace ( ("2: cp and fc are %x(%d) %x\n", i, i, wvConvertCPToFC (i, &ps->clx))); piece = wvGetComplexParaBounds (ver, ¶_fkp, ¶_fcFirst, ¶_fcLim, i, &ps->clx, btePapx, posPapx, para_intervals, piece, ps->mainfd); if (piece == 0xffffffffL) break; wvAssembleSimplePAP (ver, &apap, para_fcLim, ¶_fkp, ps); wvTrace (("para from %x to %x\n", para_fcFirst, para_fcLim)); wvAssembleComplexPAP (ver, &apap, piece, ps); wvTrace (("para from %x to %x\n", para_fcFirst, para_fcLim)); i = para_fcLim; /* ignore the row end markers */ /* if ((apap.ptap.itcMac) (apap.fTtp))*/ /* we ascertain the number of rows by counting the end of row markers. NB: a row marker can have a 0 itcMac*/ if (apap.fTtp) { 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 (¶_fkp); wvSetTableInfo (ps, test, j); ps->intable = 1; ps->norows = j; wvFree (test); }
/* 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; int ichartype; 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; wvVersion ver = wvQuerySupported (&ps->fib, NULL); long pos = wvStream_tell (ps->mainfd); wvInitPAPX_FKP (¶_fkp); para_fcFirst = wvConvertCPToFC (ps->currentcp, &ps->clx); for (piececount = piece; piececount < ps->clx.nopcd; piececount++) { ichartype = wvGetPieceBoundsFC (&beginfc, &endfc, &ps->clx, piececount); if(ichartype==-1) break; chartype = (U8) ichartype; wvStream_goto (ps->mainfd, beginfc); 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 (¶_fkp); wvTrace ( ("cp and fc are %x(%d) %x\n", i, i, wvConvertCPToFC (i, &ps->clx))); cpiece = wvGetComplexParaBounds (ver, ¶_fkp, ¶_fcFirst, ¶_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 (ver, &apap, para_fcLim, ¶_fkp, ps); wvAssembleComplexPAP (ver, &apap, cpiece, ps); wvTrace ( ("table ttp are %d %d\n", apap.fInTable, apap.fTtp)); } } } wvStream_goto (ps->mainfd, pos); }