static U32 wvStream_close_stream (wvStream * in) { if ( !in ) return 0; if (in->kind == GSF_STREAM) { g_object_unref (G_OBJECT(in->stream.gsf_stream)); in->stream.gsf_stream = NULL; wvFree (in); return 0; } else if (in->kind == FILE_STREAM) { U32 ret; ret = (U32) fclose (in->stream.file_stream); wvFree (in); return (ret); } else if (in->kind == MEMORY_STREAM) { wvFree (in->stream.memory_stream->mem); wvFree (in->stream.memory_stream); wvFree (in); return 0; } else abort(); }
void wvReleaseSpgrContainer(SpgrContainer *item) { U32 i; for (i = 0; i < item->no_spcontainer; i++) wvReleaseFSPContainer(&(item->spcontainer[i])); wvFree(item->spcontainer); for (i = 0; i < item->no_spgrcontainer; i++) wvReleaseSpgrContainer(&(item->spgrcontainer[i])); wvFree(item->spgrcontainer); }
void internal_wvReleasePAPX_FKP (PAPX_FKP * fkp) { int i; wvFree (fkp->rgfc); fkp->rgfc = NULL; wvFree (fkp->rgbx); fkp->rgbx = NULL; for (i = 0; i < fkp->crun; i++) wvReleasePAPX (&(fkp->grppapx[i])); fkp->crun = 0; wvFree (fkp->grppapx); fkp->grppapx = NULL; }
void wvFreeXst(Xst **xst) { Xst *freegroup; if ((xst == NULL) || (*xst == NULL)) return; while (*xst != NULL) { freegroup = *xst; *xst = (*xst)->next; if (freegroup->u16string != NULL) wvFree(freegroup->u16string); wvFree(freegroup); } }
void internal_wvReleaseCHPX_FKP (CHPX_FKP * fkp) { int i; wvTrace (("chpx fkp b freeed\n")); wvFree (fkp->rgfc); fkp->rgfc = NULL; wvFree (fkp->rgb); fkp->rgb = NULL; for (i = 0; i < fkp->crun; i++) wvReleaseCHPX (&(fkp->grpchpx[i])); fkp->crun = 0; wvFree (fkp->grpchpx); fkp->grpchpx = NULL; wvTrace (("chpx fkp e freeed\n")); }
void wvGetFFN_STTBF(FFN_STTBF *item, U32 offset, U32 len, wvStream *fd) { int i; wvTrace(("reading fonts...\n")); wvTrace(("seeking to %x, len %d\n", offset, len)); if (len == 0) { item->nostrings = 0; item->ffn = NULL; } else { wvStream_goto(fd, offset); item->extendedflag = read_16ubit(fd); if (item->extendedflag == 0xFFFF) item->nostrings = read_16ubit(fd); else item->nostrings = item->extendedflag; item->extradatalen = read_16ubit(fd); item->ffn = (FFN *)wvMalloc(item->nostrings * sizeof(FFN)); for (i = 0; i < item->nostrings; i++) { #ifdef DEBUG char *dbg; #endif wvGetFFN(&(item->ffn[i]), fd); #ifdef DEBUG dbg = wvWideStrToMB(item->ffn[i].xszFfn); wvTrace(("font %d: %s\n", i, dbg)); if (dbg) wvFree(dbg); #endif } } wvTrace(("done reading fonts.\n")); }
int wvGetFRD_PLCF(FRD **frd, U32 **pos, int *nofrd, U32 offset, U32 len, wvStream *fd) { int i; if (len == 0) { *frd = NULL; *pos = NULL; *nofrd = 0; } else { *nofrd = (len - 4) / 6; *pos = (U32 *)wvMalloc((*nofrd + 1) * sizeof(U32)); if (*pos == NULL) { wvError( ("NO MEM 1, failed to alloc %d bytes\n", (*nofrd + 1) * sizeof(U32))); return 1; } *frd = (FRD *)wvMalloc(*nofrd * sizeof(FRD)); if (*frd == NULL) { wvError( ("NO MEM 1, failed to alloc %d bytes\n", *nofrd * sizeof(FRD))); wvFree(pos); return 1; } wvStream_goto(fd, offset); for (i = 0; i < *nofrd + 1; i++) (*pos)[i] = read_32ubit(fd); for (i = 0; i < *nofrd; i++) wvGetFRD(&((*frd)[i]), fd); } return 0; }
void wvOLEFree (wvParseStruct * ps) { if(wvQuerySupported (&ps->fib, NULL) != WORD2 && !ps->fib.fEncrypted) { wvStream_list *tempList = streams; while (tempList != NULL) { wvStream_close(tempList->stream); tempList = tempList->next; } while (streams != NULL) { tempList = streams->next; wvFree (streams); streams = tempList; } } if (ps->ole_file != NULL) { g_object_unref (G_OBJECT(ps->ole_file)); ps->ole_file = NULL; } if (ps->input != NULL) { g_object_unref (G_OBJECT(ps->input)); ps->input = NULL; } }
void wvReleaseBstoreContainer(BstoreContainer *item) { U32 i; for (i = 0; i < item->no_fbse; i++) wvReleaseBlip(&item->blip[i]); wvFree(item->blip); }
void wvGetFFN_STTBF6 (FFN_STTBF * item, U32 offset, U32 len, wvStream * fd) { U32 count = 0; int noffn = 0; wvTrace (("reading fonts 6...\n")); wvTrace (("seeking to %x, len %d\n", offset, len)); if (len == 0) { item->nostrings = 0; item->ffn = NULL; return; } wvStream_goto (fd, offset); item->extendedflag = 0; item->nostrings = 5; /* lets just set a val to start off with */ item->extradatalen = 0; item->ffn = (FFN *) wvMalloc (item->nostrings * sizeof (FFN)); if (len != read_16ubit (fd)) wvError (("FFN STTBF lens differ\n")); count += 2; while (count < len) { #ifdef DEBUG char *dbg; #endif if (noffn == item->nostrings) { /* need to extend the array just in case */ item->nostrings += 5; item->ffn = (FFN *) realloc (item->ffn, item->nostrings * sizeof (FFN)); } wvGetFFN6 (&(item->ffn[noffn]), fd); count += (item->ffn[noffn].cbFfnM1 + 1); #ifdef DEBUG dbg = wvWideStrToMB (item->ffn[noffn].xszFfn); wvTrace (("font %d: %s\n", noffn, dbg)); if (dbg) wvFree (dbg); #endif noffn++; } if (item->nostrings != noffn) item->nostrings = noffn; wvTrace (("done reading fonts 6.\n")); }
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); }
int wvGetBTE_PLCF6 (BTE ** bte, U32 ** pos, U32 * nobte, U32 offset, U32 len, wvStream * fd) { U32 i; if (len == 0) { *bte = NULL; *pos = NULL; *nobte = 0; } else { wvTrace (("offset is %x, len is %d\n", offset, len)); *nobte = (len - 4) / (cb6BTE + 4); wvTrace (("no of bte is %d at %x\n", *nobte, offset)); *pos = (U32 *) wvMalloc ((*nobte + 1) * sizeof (U32)); if (*pos == NULL) { wvError ( ("NO MEM 1, failed to alloc %d bytes\n", (*nobte + 1) * sizeof (U32))); return (1); } *bte = (BTE *) wvMalloc (*nobte * sizeof (BTE)); if (*bte == NULL) { wvError ( ("NO MEM 1, failed to alloc %d bytes\n", *nobte * sizeof (BTE))); wvFree (pos); return (1); } wvStream_goto (fd, offset); for (i = 0; i <= *nobte; i++) { (*pos)[i] = read_32ubit (fd); wvTrace (("pos is %x\n", (*pos)[i])); } for (i = 0; i < *nobte; i++) { wvInitBTE (&((*bte)[i])); (*bte)[i].pn = read_16ubit (fd); } } return (0); }
int wvGetBKD_PLCF (BKD ** bkd, U32 ** pos, U32 * nobkd, U32 offset, U32 len, wvStream * fd) { U32 i; if (len == 0) { *bkd = NULL; *pos = NULL; *nobkd = 0; } else { *nobkd = (len - 4) / (cbBKD + 4); *pos = (U32 *) wvMalloc ((*nobkd + 1) * sizeof (U32)); if (*pos == NULL) { wvError ( ("NO MEM 1, failed to alloc %d bytes\n", (*nobkd + 1) * sizeof (U32))); return (1); } *bkd = (BKD *) wvMalloc (*nobkd * sizeof (BKD)); if (*bkd == NULL) { wvError ( ("NO MEM 1, failed to alloc %d bytes\n", *nobkd * sizeof (BKD))); wvFree (pos); return (1); } wvStream_goto (fd, offset); for (i = 0; i < *nobkd + 1; i++) { (*pos)[i] = read_32ubit (fd); } for (i = 0; i < *nobkd; i++) { wvGetBKD (&((*bkd)[i]), fd); } } return (0); }
int wvGetBTE_PLCF(BTE **bte, U32 **pos, U32 *nobte, U32 offset, U32 len, wvStream *fd) { U32 i; if (len == 0) { *bte = NULL; *pos = NULL; *nobte = 0; } else { *nobte = (len - 4) / (cbBTE + 4); wvTrace(("no of bte is %d at %x\n", *nobte, offset)); *pos = (U32 *)wvMalloc((*nobte + 1) * sizeof(U32)); if (*pos == NULL) { wvError( ("NO MEM 1, failed to alloc %d bytes\n", (*nobte + 1) * sizeof(U32))); return 1; } *bte = (BTE *)wvMalloc(*nobte * sizeof(BTE)); if (*bte == NULL) { wvError( ("NO MEM 1, failed to alloc %d bytes\n", *nobte * sizeof(BTE))); wvFree(*pos); return 1; } wvStream_goto(fd, offset); for (i = 0; i <= *nobte; i++) (*pos)[i] = read_32ubit(fd); for (i = 0; i < *nobte; i++) wvGetBTE(&((*bte)[i]), fd); } return 0; }
void wvReleaseSplitMenuColors(SplitMenuColors *splitmenucolors) { wvFree(splitmenucolors->colors); }
U32 PutWord8Structs(MSOFBH *bse_pic_amsofbh, U8* buf, size_t size) { long count; MSOFBH amsofbh,opt_amsofbh,bse_amsofbh; FBSE afbse; FOPTE *fopte; wvStream OutStream; wvStream *fd; U8* int_buf; int i; if(!bse_pic_amsofbh) return 0; count = 0; if(buf){ fd = &OutStream; int_buf = wvMalloc(size); wvStream_memory_create(&fd, (char*)int_buf, size); } else fd = 0; /*Container Data*/ /*Init Data *OPT amsofbh*/ opt_amsofbh.ver=0; opt_amsofbh.inst=0; opt_amsofbh.fbt = msofbtOPT; opt_amsofbh.cbLength = sizeof(FOPTE); /*OPT*/ fopte = (FOPTE *) wvMalloc (sizeof (FOPTE) * 2); for(i=0;i<2;i++){ (fopte)[i].pid=0; (fopte)[i].op=1;/*-i;*/ (fopte)[i].fComplex=0; (fopte)[i].fBid=1;/*+i*(79999);*/ (fopte)[i].entry=0; } /*Container amsofbh*/ amsofbh.ver=0; amsofbh.inst=0; amsofbh.fbt = msofbtSpContainer; amsofbh.cbLength = sizeof(opt_amsofbh) + opt_amsofbh.cbLength; /*Write Data*/ /*Container amsofbh*/ count+=wvPutMSOFBH(&amsofbh, fd); /*OPT amsofbh*/ count+=wvPutMSOFBH(&opt_amsofbh, fd); /*OPT */ if(buf) wvPutFOPTEArray(&fopte,&opt_amsofbh,fd); count+=opt_amsofbh.cbLength; wvFree(fopte); /*Set Blip Data */ memset(&afbse,0,sizeof(afbse)); afbse.btMacOS = 3; afbse.btWin32 = 4; afbse.cRef = 1; afbse.tag = 0xff; afbse.size = sizeof(*bse_pic_amsofbh) + bse_pic_amsofbh->cbLength; /*msofbtBSE amsofbh*/ bse_amsofbh.ver=0; bse_amsofbh.inst=0; bse_amsofbh.fbt = msofbtBSE; bse_amsofbh.cbLength = sizeof(afbse) + afbse.size; count+=wvPutMSOFBH(&bse_amsofbh, fd); if(buf) wvPutFBSE (&afbse, fd); count+=sizeof(afbse); count+=wvPutMSOFBH(bse_pic_amsofbh, fd); if(buf){ memcpy(buf, int_buf, size); } return count; }
/* Apply the first UPX (UPX.chpx) in std.grupx to the UPE. To apply a UPX.chpx to a UPE.chpx, take the grpprl in UPE.chpx.grpprl (which has a length of UPE.chpx.cbGrpprl) and merge the grpprl in UPX.chpx.grpprl into it. Merging grpprls is a tricky business, but for character styles it is easy because no prls in character style grpprls should interact with each other. Each prl from the source (the UPX.chpx.grpprl) should be inserted into the destination (the UPE.chpx.grpprl) so that the sprm of each prl is in increasing order, and any prls that have the same sprm are replaced by the prl in the source. UPE.chpx.cbGrpprl is then set to the length of resulting grpprl, and UPE.chpx.istd is set to the style's istd. */ void wvMergeCHPXFromBucket(CHPX *dest, UPXF *src) { BintreeInfo tree; Node *testn, *testp; U16 i = 0, j; U16 sprm; U8 len = 0; U8 temp; Node *test = NULL; U8 *pointer, *dpointer; U8 *grpprl = NULL; /* use a binary tree ala the wmf stuff and first insert every dest sprm into it, then insert every src sprm into it, take the full count and take them out of the tree and create the list from them */ InitBintree(&tree, wvCompLT, wvCompEQ); pointer = dest->grpprl; while (i < dest->cbGrpprl) { wvTrace(("gotcha the sprm is %x\n", *((U16 *)pointer))); test = InsertNode(&tree, (void *)pointer); sprm = dread_16ubit(NULL, &pointer); wvTrace(("the sprm is %x\n", sprm)); temp = wvEatSprm(sprm, pointer, &i); pointer += temp; i += 2; if (test) len += temp + 2; } i = 0; pointer = src->upx.chpx.grpprl; i = 0; while (i < src->cbUPX) { /*wvTrace(("gotcha 2 the sprm is %x\n",*((U16 *)pointer))); */ test = InsertNode(&tree, (void *)pointer); sprm = dread_16ubit(NULL, &pointer); i += 2; wvTrace(("the sprm is %x\n", sprm)); temp = wvEatSprm(sprm, pointer, &i); wvTrace(("len of op is %d\n", temp)); pointer += temp; wvTrace(("p dis is %d\n", pointer - src->upx.chpx.grpprl)); if (test) len += temp + 2; } if (len != 0) grpprl = (U8 *)wvMalloc(len); else return; dpointer = grpprl; testn = NextNode(&tree, NULL); while (testn != NULL) { pointer = (U8 *)testn->Data; sprm = sread_16ubit(pointer); wvTrace(("methinks the sprm is %x\n", sprm)); pointer += 2; i = 0; wvEatSprm(sprm, pointer, &i); wvTrace(("i is now %d\n", i)); pointer = (U8 *)testn->Data; for (j = 0; j < i + 2; j++) *dpointer++ = *pointer++; testp = NextNode(&tree, testn); wvDeleteNode(&tree, testn); testn = testp; } wvFree(dest->grpprl); dest->grpprl = grpprl; dest->cbGrpprl = len; /*test */ i = 0; pointer = dest->grpprl; while (i < dest->cbGrpprl) { sprm = dread_16ubit(NULL, &pointer); wvTrace(("final test the sprm is %x\n", sprm)); temp = wvEatSprm(sprm, pointer, &i); pointer += temp; i += 2; if (test) len += temp + 2; } }
void wvReleaseFFN_STTBF (FFN_STTBF * item) { if (item->ffn != NULL) wvFree (item->ffn); }
void wvReleaseClientTextbox(ClientTextbox *item) { wvFree(item->textid); }
void wvReleaseSEPX (SEPX * item) { wvFree (item->grpprl); }
void wvReleaseCHPX(CHPX *item) { wvFree(item->grpprl); }
void wvReleaseBlip(Blip *blip) { wvFree(blip->name); }
void wvUpdateCHPXBucket(UPXF *src) { U16 i = 0, j; U16 sprm; U8 sprm8; U16 len = 0; int temp; U8 *pointer, *dpointer; U8 *grpprl = NULL; i = 0; if (src->cbUPX == 0) return; pointer = src->upx.chpx.grpprl; wvTrace(("Msrc->cbUPX len is %d\n", src->cbUPX)); for (i = 0; i < src->cbUPX; i++) wvTrace(("%x\n", src->upx.chpx.grpprl[i])); wvTrace(("Mend\n")); i = 0; len = 0; while (i < src->cbUPX) { sprm8 = dread_8ubit(NULL, &pointer); wvTrace(("Mpre the sprm is %x\n", sprm8)); sprm = (U16)wvGetrgsprmWord6(sprm8); wvTrace(("Mpost the sprm is %x\n", sprm)); i++; len += 2; temp = wvEatSprm(sprm, pointer, &i); wvTrace(("Mlen of op is %d\n", temp)); pointer += temp; wvTrace(("Mp dis is %d\n", pointer - src->upx.chpx.grpprl)); len += temp; } wvTrace(("Mlen ends up as %d\n", len)); if (len == 0) return; grpprl = (U8 *)wvMalloc(len); dpointer = grpprl; i = 0; pointer = src->upx.chpx.grpprl; while (i < src->cbUPX) { sprm8 = dread_8ubit(NULL, &pointer); sprm = (U16)wvGetrgsprmWord6(sprm8); i++; *dpointer++ = (sprm & 0x00FF); *dpointer++ = (sprm & 0xff00) >> 8; temp = wvEatSprm(sprm, pointer, &i); for (j = 0; j < temp; j++) *dpointer++ = *pointer++; wvTrace(("Mlen of op is %d\n", temp)); } wvFree(src->upx.chpx.grpprl); src->upx.chpx.grpprl = grpprl; src->cbUPX = len; for (i = 0; i < src->cbUPX; i++) wvTrace(("%x\n", src->upx.chpx.grpprl[i])); }
/* ------------------------- | | | ------------------------- | | | | | | | ------------------------- | | ------------------------- | | | | ------------------------- ==> | | | | | | | | | 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 *) wvMalloc (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); wvDeleteNode (&tree, testn); testn = testp; } wvTrace (("No in tree according to i is %d\n", i)); wvTrace (("end of out\n")); ps->vmerges = (S16 **) wvMalloc (sizeof (S16 *) * no); wvTrace (("no of rows is %d\n", no)); for (i = 0; i < no; i++) { ps->vmerges[i] = (S16 *) wvMalloc (sizeof (S16) * ptap[i].itcMac); wvTrace (("no of cells is %d\n", 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])); }
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); }
void wvReleaseDgg(Dgg *dgg) { wvFree(dgg->fidcl); }
void wvReleaseClientData(ClientData *item) { wvFree(item->data); }
int wvGetBKL_PLCF(BKL **bkl, U32 **pos, U32 *nobkl, U32 bkloffset, U32 bkllen, U32 bkfoffset, U32 bkflen, wvStream *fd) { BKF *bkf; U32 *posf, nobkf; U32 i, j; if ((bkllen == 0) || (bkflen == 0)) { *bkl = NULL; *pos = NULL; *nobkl = 0; } else { /* the plcbkl table contains offsets only, bkl has to be calculated from bkf */ *nobkl = (bkllen - 4) / (/*cbBKL +*/ 4); *pos = (U32 *)wvMalloc((*nobkl + 1) * sizeof(U32)); if (*pos == NULL) { wvError( ("NO MEM 1, failed to alloc %d bytes\n", (*nobkl + 1) * sizeof(U32))); return 1; } *nobkl = (*nobkl ? *nobkl : 1); *bkl = (BKL *)wvMalloc(*nobkl * sizeof(BKL)); if (*bkl == NULL) { wvError( ("NO MEM 1, failed to alloc %d bytes\n", *nobkl * sizeof(BKL))); wvFree(*pos); return 1; } wvStream_goto(fd, bkloffset); for (i = 0; i <= *nobkl; i++) (*pos)[i] = read_32ubit(fd); /* now we have to reconstruct the bkl table; we have to get the bkf records, and then search them to find one that matches the index we are processing */ if (wvGetBKF_PLCF(&bkf, &posf, &nobkf, bkfoffset, bkflen, fd)) { wvError( ("call to wvGetBKF_PLCF failed\n")); wvFree(*pos); wvFree(*bkl); return 1; } for (i = 0; i < *nobkl; i++) { for (j = 0; j < nobkf; j++) if (bkf[j].ibkl == i) break; if (j == nobkf) { wvError( ("unmatched closing bookmark\n")); wvFree(*pos); wvFree(*bkl); wvFree(bkf); wvFree(posf); return 1; } (*bkl)[i].ibkf = (U16)j; } wvFree(bkf); wvFree(posf); } return 0; }
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; } char *tmp = wvMalloc( amsofbh->cbLength - count); if (!tmp) { abm->m_pvBits = NULL; return 0; } wvStream_read(tmp,1,amsofbh->cbLength - count,fd); wvStream_write(tmp,1,amsofbh->cbLength - count,stm); wvFree(tmp); wvStream_rewind (stm); abm->m_pvBits = stm; count += i; return count; }