void wvGetFFN (FFN * item, wvStream * fd) { int len, i; U8 temp8; #ifdef PURIFY wvInitFFN (item); #endif item->cbFfnM1 = read_8ubit (fd); temp8 = read_8ubit (fd); item->prq = temp8 & 0x03; item->fTrueType = (temp8 & 0x04) >> 2; item->reserved1 = (temp8 & 0x08) >> 3; item->ff = (temp8 & 0x70) >> 4; item->reserved2 = (temp8 & 0x80) >> 7; item->wWeight = (S16) read_16ubit (fd); item->chs = read_8ubit (fd); item->ixchSzAlt = read_8ubit (fd); wvGetPANOSE (&(item->panose), fd); wvGetFONTSIGNATURE (&(item->fs), fd); len = item->cbFfnM1 - 39; len = len / 2; /* item->xszFfn = (U16) wvMalloc(sizeof(U16) * len)); */ if (len > 65) len = 65; for (i = 0; i < len; i++) item->xszFfn[i] = read_16ubit (fd); }
U16 read_16ubit (wvStream * in) { U16 ret; U8 temp1, temp2; temp1 = read_8ubit (in); temp2 = read_8ubit (in); ret = temp2; ret = ret << 8; ret += temp1; return (ret); }
void wvGetPANOSE(PANOSE *item, wvStream *fd) { item->bFamilyType = read_8ubit(fd); item->bSerifStyle = read_8ubit(fd); item->bWeight = read_8ubit(fd); item->bProportion = read_8ubit(fd); item->bContrast = read_8ubit(fd); item->bStrokeVariation = read_8ubit(fd); item->bArmStyle = read_8ubit(fd); item->bLetterform = read_8ubit(fd); item->bMidline = read_8ubit(fd); item->bXHeight = read_8ubit(fd); }
void wvGetrc (rc * arc, wvStream * infd) { int i; for (i = 0; i < 14; i++) arc->bm[i] = read_8ubit (infd); }
void wvGetBITMAP (BITMAP * bmp, wvStream * infd) { int i; for (i = 0; i < 14; i++) bmp->bm[i] = read_8ubit (infd); }
/* this function retrieves a generic PLCF; this is useful since it means we do not have to add specific functions for retrieving various simple PLCFs (for instance the PLCFs that store information about footnotes, endnotes and annotations are just simple arrays of U32s) plcf - a pointer to a pointer where we should allocate the structure the caller needs to free these using wvFree() once not needed offset - an offset in the stream fd where the PLCF starts len - a length in bytes (!!!) of the PLCF fd - the stream from which to read the PLCF */ int wvGetPLCF (void ** plcf, U32 offset, U32 len, wvStream * fd) { U32 i, i32, i8; if (len == 0) { *plcf = NULL; } else { *plcf = wvMalloc (len); if (*plcf == NULL) { wvError (("NO MEM 1, failed to alloc %d bytes\n",len)); return (1); } wvStream_goto (fd, offset); i32 = len / 4; i8 = len % 4; for (i = 0; i < i32; i++) ((U32*)(*plcf))[i] = read_32ubit (fd); for (i = i32*4; i < i32*4 + i8; i++) ((U8*)(*plcf))[i] = read_8ubit (fd); } return (0); }
U16 wvGetChar(wvStream *fd, U8 chartype) { if (chartype == 1) return read_8ubit(fd); else return read_16ubit(fd); return 0; }
U32 wvGetClientData(ClientData *item, MSOFBH *msofbh, wvStream *fd) { U32 i; if (msofbh->cbLength) { item->data = (U8 *)wvMalloc(msofbh->cbLength); for (i = 0; i < msofbh->cbLength; i++) item->data[i] = read_8ubit(fd); } else item->data = NULL; return msofbh->cbLength; }
U8 dread_8ubit (wvStream * in, U8 ** list) { U8 *temp; if (in != NULL) return (read_8ubit (in)); else { temp = *list; (*list)++; return (sread_8ubit (temp)); } }
U32 wvGetDggContainer(DggContainer *item, MSOFBH *msofbh, wvStream *fd, wvStream *delay) { MSOFBH amsofbh; U32 count = 0; while (count < msofbh->cbLength) { count += wvGetMSOFBH(&amsofbh, fd); wvTrace( ("len is %x, type is %x, count %x,fullen %x\n", amsofbh.cbLength, amsofbh.fbt, count, msofbh->cbLength)); wvTrace(("type is %x\n ", amsofbh.fbt)); switch (amsofbh.fbt) { case msofbtDgg: count += wvGetDgg(&item->dgg, &amsofbh, fd); break; case msofbtSplitMenuColors: count += wvGetSplitMenuColors(&item->splitmenucolors, &amsofbh, fd); break; case msofbtBstoreContainer: count += wvGetBstoreContainer(&item->bstorecontainer, &amsofbh, fd, delay); wvTrace( ("type is %d (number is %d\n", item->bstorecontainer.blip[item->bstorecontainer. no_fbse - 1].type, item->bstorecontainer.no_fbse)); break; default: count += wvEatmsofbt(&amsofbh, fd); wvError(("Eating type 0x%x\n", amsofbh.fbt)); break; } } /* For some reason I appear to have an extra byte associated either with this or its wrapper, I will investigate further. */ read_8ubit(fd); count++; return count; }
void wvGetSEPX (wvVersion ver, SEPX * item, wvStream * fd) { U16 i; item->cb = read_16ubit (fd); if (item->cb) item->grpprl = (U8 *) wvMalloc (item->cb); else item->grpprl = NULL; for (i = 0; i < item->cb; i++) { item->grpprl[i] = read_8ubit (fd); wvTrace (("sep is %x\n", item->grpprl[i])); } }
static void handleImage (Blip * b, long width, long height) { /* TODO: image support */ wvStream * pwv = NULL; size_t size = 0; int data = 0; int cnt = 0; int tag = time (NULL); /* short-circuit this method if we don't support the incoming format */ switch (b->type) { case msoblipPNG: /* conveniently I know how to export to PNG */ rtf_output ("{\\*\\shppict{\\pict\\pngblip\\picw%d\\pich%d\\picwgoal\\pichgoal\n", width, height); break; case msoblipDIB: case msoblipWMF: case msoblipEMF: case msoblipPICT: case msoblipJPEG: default: /* TODO: support other image types */ return; } rtf_output ("\bliptag%d{\\*\\blipuid%032x}", tag, tag); pwv = b->blip.bitmap.m_pvBits; size = wvStream_size (pwv); wvStream_rewind(pwv); while (cnt < size) { if (cnt++ % 64 == 0) rtf_output_char ('\n'); rtf_output ("%02x", read_8ubit(pwv)); } rtf_output_char ('}'); }
U32 twvGetFBSE (FBSE * afbse, wvStream * infd) { int i; afbse->btWin32 = read_8ubit (infd); afbse->btMacOS = read_8ubit (infd); for (i = 0; i < 16; i++) afbse->rgbUid[i] = read_8ubit (infd); afbse->tag = read_16ubit (infd); afbse->size = read_32ubit (infd); afbse->cRef = read_32ubit (infd); afbse->foDelay = read_32ubit (infd); afbse->usage = read_8ubit (infd); afbse->cbName = read_8ubit (infd); afbse->unused2 = read_8ubit (infd); afbse->unused3 = read_8ubit (infd); return (36); }
U32 wvGetFBSE(FBSE *afbse, wvStream *fd) { int i; afbse->btWin32 = read_8ubit(fd); afbse->btMacOS = read_8ubit(fd); for (i = 0; i < 16; i++) afbse->rgbUid[i] = read_8ubit(fd); afbse->tag = read_16ubit(fd); afbse->size = read_32ubit(fd); afbse->cRef = read_32ubit(fd); afbse->foDelay = read_32ubit(fd); wvTrace(("location is %x, size is %d\n", afbse->foDelay, afbse->size)); afbse->usage = read_8ubit(fd); afbse->cbName = read_8ubit(fd); wvTrace(("name len is %d\n", afbse->cbName)); afbse->unused2 = read_8ubit(fd); afbse->unused3 = read_8ubit(fd); return 36; }
void wvGetFIB (FIB * item, wvStream * fd) { U16 temp16; U8 temp8; item->fEncrypted = 0; wvStream_goto (fd, 0); #ifdef PURIFY wvInitFIB (item); #endif item->wIdent = read_16ubit (fd); item->nFib = read_16ubit (fd); if ((wvQuerySupported (item, NULL) == WORD2)) { wvInitFIB (item); wvStream_offset (fd, -4); wvGetFIB2 (item, fd); return; } if ((wvQuerySupported (item, NULL) == WORD5) || (wvQuerySupported (item, NULL) == WORD6) || (wvQuerySupported (item, NULL) == WORD7)) { wvInitFIB (item); wvStream_offset (fd, -4); wvGetFIB6 (item, fd); return; } item->nProduct = read_16ubit (fd); item->lid = read_16ubit (fd); wvTrace (("lid is %x\n", item->lid)); item->pnNext = (S16) read_16ubit (fd); temp16 = read_16ubit (fd); item->fDot = (temp16 & 0x0001); item->fGlsy = (temp16 & 0x0002) >> 1; item->fComplex = (temp16 & 0x0004) >> 2; item->fHasPic = (temp16 & 0x0008) >> 3; item->cQuickSaves = (temp16 & 0x00F0) >> 4; item->fEncrypted = (temp16 & 0x0100) >> 8; item->fWhichTblStm = (temp16 & 0x0200) >> 9; item->fReadOnlyRecommended = (temp16 & 0x0400) >> 10; item->fWriteReservation = (temp16 & 0x0800) >> 11; item->fExtChar = (temp16 & 0x1000) >> 12; wvTrace (("fExtChar is %d\n", item->fExtChar)); item->fLoadOverride = (temp16 & 0x2000) >> 13; item->fFarEast = (temp16 & 0x4000) >> 14; item->fCrypto = (temp16 & 0x8000) >> 15; item->nFibBack = read_16ubit (fd); item->lKey = read_32ubit (fd); item->envr = read_8ubit (fd); temp8 = read_8ubit (fd); item->fMac = (temp8 & 0x01); item->fEmptySpecial = (temp8 & 0x02) >> 1; item->fLoadOverridePage = (temp8 & 0x04) >> 2; item->fFutureSavedUndo = (temp8 & 0x08) >> 3; item->fWord97Saved = (temp8 & 0x10) >> 4; item->fSpare0 = (temp8 & 0xFE) >> 5; item->chse = read_16ubit (fd); item->chsTables = read_16ubit (fd); item->fcMin = read_32ubit (fd); item->fcMac = read_32ubit (fd); item->csw = read_16ubit (fd); item->wMagicCreated = read_16ubit (fd); item->wMagicRevised = read_16ubit (fd); item->wMagicCreatedPrivate = read_16ubit (fd); item->wMagicRevisedPrivate = read_16ubit (fd); item->pnFbpChpFirst_W6 = (S16) read_16ubit (fd); item->pnChpFirst_W6 = (S16) read_16ubit (fd); item->cpnBteChp_W6 = (S16) read_16ubit (fd); item->pnFbpPapFirst_W6 = (S16) read_16ubit (fd); item->pnPapFirst_W6 = (S16) read_16ubit (fd); item->cpnBtePap_W6 = (S16) read_16ubit (fd); item->pnFbpLvcFirst_W6 = (S16) read_16ubit (fd); item->pnLvcFirst_W6 = (S16) read_16ubit (fd); item->cpnBteLvc_W6 = (S16) read_16ubit (fd); item->lidFE = (S16) read_16ubit (fd); item->clw = read_16ubit (fd); item->cbMac = (S32) read_32ubit (fd); item->lProductCreated = read_32ubit (fd); item->lProductRevised = read_32ubit (fd); item->ccpText = read_32ubit (fd); item->ccpFtn = (S32) read_32ubit (fd); item->ccpHdr = (S32) read_32ubit (fd); item->ccpMcr = (S32) read_32ubit (fd); item->ccpAtn = (S32) read_32ubit (fd); item->ccpEdn = (S32) read_32ubit (fd); item->ccpTxbx = (S32) read_32ubit (fd); item->ccpHdrTxbx = (S32) read_32ubit (fd); item->pnFbpChpFirst = (S32) read_32ubit (fd); item->pnChpFirst = (S32) read_32ubit (fd); item->cpnBteChp = (S32) read_32ubit (fd); item->pnFbpPapFirst = (S32) read_32ubit (fd); item->pnPapFirst = (S32) read_32ubit (fd); item->cpnBtePap = (S32) read_32ubit (fd); item->pnFbpLvcFirst = (S32) read_32ubit (fd); item->pnLvcFirst = (S32) read_32ubit (fd); item->cpnBteLvc = (S32) read_32ubit (fd); item->fcIslandFirst = (S32) read_32ubit (fd); item->fcIslandLim = (S32) read_32ubit (fd); item->cfclcb = read_16ubit (fd); item->fcStshfOrig = (S32) read_32ubit (fd); item->lcbStshfOrig = read_32ubit (fd); item->fcStshf = (S32) read_32ubit (fd); item->lcbStshf = read_32ubit (fd); item->fcPlcffndRef = (S32) read_32ubit (fd); item->lcbPlcffndRef = read_32ubit (fd); item->fcPlcffndTxt = (S32) read_32ubit (fd); item->lcbPlcffndTxt = read_32ubit (fd); item->fcPlcfandRef = (S32) read_32ubit (fd); item->lcbPlcfandRef = read_32ubit (fd); item->fcPlcfandTxt = (S32) read_32ubit (fd); item->lcbPlcfandTxt = read_32ubit (fd); item->fcPlcfsed = (S32) read_32ubit (fd); item->lcbPlcfsed = read_32ubit (fd); item->fcPlcpad = (S32) read_32ubit (fd); item->lcbPlcpad = read_32ubit (fd); item->fcPlcfphe = (S32) read_32ubit (fd); item->lcbPlcfphe = read_32ubit (fd); item->fcSttbfglsy = (S32) read_32ubit (fd); item->lcbSttbfglsy = read_32ubit (fd); item->fcPlcfglsy = (S32) read_32ubit (fd); item->lcbPlcfglsy = read_32ubit (fd); item->fcPlcfhdd = (S32) read_32ubit (fd); item->lcbPlcfhdd = read_32ubit (fd); item->fcPlcfbteChpx = (S32) read_32ubit (fd); item->lcbPlcfbteChpx = read_32ubit (fd); item->fcPlcfbtePapx = (S32) read_32ubit (fd); item->lcbPlcfbtePapx = read_32ubit (fd); item->fcPlcfsea = (S32) read_32ubit (fd); item->lcbPlcfsea = read_32ubit (fd); item->fcSttbfffn = (S32) read_32ubit (fd); item->lcbSttbfffn = read_32ubit (fd); item->fcPlcffldMom = (S32) read_32ubit (fd); item->lcbPlcffldMom = read_32ubit (fd); item->fcPlcffldHdr = (S32) read_32ubit (fd); item->lcbPlcffldHdr = read_32ubit (fd); item->fcPlcffldFtn = (S32) read_32ubit (fd); item->lcbPlcffldFtn = read_32ubit (fd); item->fcPlcffldAtn = (S32) read_32ubit (fd); item->lcbPlcffldAtn = read_32ubit (fd); item->fcPlcffldMcr = (S32) read_32ubit (fd); item->lcbPlcffldMcr = read_32ubit (fd); item->fcSttbfbkmk = (S32) read_32ubit (fd); item->lcbSttbfbkmk = read_32ubit (fd); item->fcPlcfbkf = (S32) read_32ubit (fd); item->lcbPlcfbkf = read_32ubit (fd); item->fcPlcfbkl = (S32) read_32ubit (fd); item->lcbPlcfbkl = read_32ubit (fd); item->fcCmds = (S32) read_32ubit (fd); item->lcbCmds = read_32ubit (fd); item->fcPlcmcr = (S32) read_32ubit (fd); item->lcbPlcmcr = read_32ubit (fd); item->fcSttbfmcr = (S32) read_32ubit (fd); item->lcbSttbfmcr = read_32ubit (fd); item->fcPrDrvr = (S32) read_32ubit (fd); item->lcbPrDrvr = read_32ubit (fd); item->fcPrEnvPort = (S32) read_32ubit (fd); item->lcbPrEnvPort = read_32ubit (fd); item->fcPrEnvLand = (S32) read_32ubit (fd); item->lcbPrEnvLand = read_32ubit (fd); item->fcWss = (S32) read_32ubit (fd); item->lcbWss = read_32ubit (fd); item->fcDop = (S32) read_32ubit (fd); item->lcbDop = read_32ubit (fd); item->fcSttbfAssoc = (S32) read_32ubit (fd); item->lcbSttbfAssoc = read_32ubit (fd); item->fcClx = (S32) read_32ubit (fd); item->lcbClx = read_32ubit (fd); item->fcPlcfpgdFtn = (S32) read_32ubit (fd); item->lcbPlcfpgdFtn = read_32ubit (fd); item->fcAutosaveSource = (S32) read_32ubit (fd); item->lcbAutosaveSource = read_32ubit (fd); item->fcGrpXstAtnOwners = (S32) read_32ubit (fd); item->lcbGrpXstAtnOwners = read_32ubit (fd); item->fcSttbfAtnbkmk = (S32) read_32ubit (fd); item->lcbSttbfAtnbkmk = read_32ubit (fd); item->fcPlcdoaMom = (S32) read_32ubit (fd); item->lcbPlcdoaMom = read_32ubit (fd); item->fcPlcdoaHdr = (S32) read_32ubit (fd); item->lcbPlcdoaHdr = read_32ubit (fd); item->fcPlcspaMom = (S32) read_32ubit (fd); item->lcbPlcspaMom = read_32ubit (fd); item->fcPlcspaHdr = (S32) read_32ubit (fd); item->lcbPlcspaHdr = read_32ubit (fd); item->fcPlcfAtnbkf = (S32) read_32ubit (fd); item->lcbPlcfAtnbkf = read_32ubit (fd); item->fcPlcfAtnbkl = (S32) read_32ubit (fd); item->lcbPlcfAtnbkl = read_32ubit (fd); item->fcPms = (S32) read_32ubit (fd); item->lcbPms = read_32ubit (fd); item->fcFormFldSttbs = (S32) read_32ubit (fd); item->lcbFormFldSttbs = read_32ubit (fd); item->fcPlcfendRef = (S32) read_32ubit (fd); item->lcbPlcfendRef = read_32ubit (fd); item->fcPlcfendTxt = (S32) read_32ubit (fd); item->lcbPlcfendTxt = read_32ubit (fd); item->fcPlcffldEdn = (S32) read_32ubit (fd); item->lcbPlcffldEdn = read_32ubit (fd); item->fcPlcfpgdEdn = (S32) read_32ubit (fd); item->lcbPlcfpgdEdn = read_32ubit (fd); item->fcDggInfo = (S32) read_32ubit (fd); item->lcbDggInfo = read_32ubit (fd); item->fcSttbfRMark = (S32) read_32ubit (fd); item->lcbSttbfRMark = read_32ubit (fd); item->fcSttbCaption = (S32) read_32ubit (fd); item->lcbSttbCaption = read_32ubit (fd); item->fcSttbAutoCaption = (S32) read_32ubit (fd); item->lcbSttbAutoCaption = read_32ubit (fd); item->fcPlcfwkb = (S32) read_32ubit (fd); item->lcbPlcfwkb = read_32ubit (fd); item->fcPlcfspl = (S32) read_32ubit (fd); item->lcbPlcfspl = read_32ubit (fd); item->fcPlcftxbxTxt = (S32) read_32ubit (fd); item->lcbPlcftxbxTxt = read_32ubit (fd); item->fcPlcffldTxbx = (S32) read_32ubit (fd); item->lcbPlcffldTxbx = read_32ubit (fd); item->fcPlcfhdrtxbxTxt = (S32) read_32ubit (fd); item->lcbPlcfhdrtxbxTxt = read_32ubit (fd); item->fcPlcffldHdrTxbx = (S32) read_32ubit (fd); item->lcbPlcffldHdrTxbx = read_32ubit (fd); item->fcStwUser = (S32) read_32ubit (fd); item->lcbStwUser = read_32ubit (fd); item->fcSttbttmbd = (S32) read_32ubit (fd); item->cbSttbttmbd = read_32ubit (fd); item->fcUnused = (S32) read_32ubit (fd); item->lcbUnused = read_32ubit (fd); item->fcPgdMother = (S32) read_32ubit (fd); item->lcbPgdMother = read_32ubit (fd); item->fcBkdMother = (S32) read_32ubit (fd); item->lcbBkdMother = read_32ubit (fd); item->fcPgdFtn = (S32) read_32ubit (fd); item->lcbPgdFtn = read_32ubit (fd); item->fcBkdFtn = (S32) read_32ubit (fd); item->lcbBkdFtn = read_32ubit (fd); item->fcPgdEdn = (S32) read_32ubit (fd); item->lcbPgdEdn = read_32ubit (fd); item->fcBkdEdn = (S32) read_32ubit (fd); item->lcbBkdEdn = read_32ubit (fd); item->fcSttbfIntlFld = (S32) read_32ubit (fd); item->lcbSttbfIntlFld = read_32ubit (fd); item->fcRouteSlip = (S32) read_32ubit (fd); item->lcbRouteSlip = read_32ubit (fd); item->fcSttbSavedBy = (S32) read_32ubit (fd); item->lcbSttbSavedBy = read_32ubit (fd); item->fcSttbFnm = (S32) read_32ubit (fd); item->lcbSttbFnm = read_32ubit (fd); item->fcPlcfLst = (S32) read_32ubit (fd); item->lcbPlcfLst = read_32ubit (fd); item->fcPlfLfo = (S32) read_32ubit (fd); item->lcbPlfLfo = read_32ubit (fd); item->fcPlcftxbxBkd = (S32) read_32ubit (fd); item->lcbPlcftxbxBkd = read_32ubit (fd); item->fcPlcftxbxHdrBkd = (S32) read_32ubit (fd); item->lcbPlcftxbxHdrBkd = read_32ubit (fd); item->fcDocUndo = (S32) read_32ubit (fd); item->lcbDocUndo = read_32ubit (fd); item->fcRgbuse = (S32) read_32ubit (fd); item->lcbRgbuse = read_32ubit (fd); item->fcUsp = (S32) read_32ubit (fd); item->lcbUsp = read_32ubit (fd); item->fcUskf = (S32) read_32ubit (fd); item->lcbUskf = read_32ubit (fd); item->fcPlcupcRgbuse = (S32) read_32ubit (fd); item->lcbPlcupcRgbuse = read_32ubit (fd); item->fcPlcupcUsp = (S32) read_32ubit (fd); item->lcbPlcupcUsp = read_32ubit (fd); item->fcSttbGlsyStyle = (S32) read_32ubit (fd); item->lcbSttbGlsyStyle = read_32ubit (fd); item->fcPlgosl = (S32) read_32ubit (fd); item->lcbPlgosl = read_32ubit (fd); item->fcPlcocx = (S32) read_32ubit (fd); item->lcbPlcocx = read_32ubit (fd); item->fcPlcfbteLvc = (S32) read_32ubit (fd); item->lcbPlcfbteLvc = read_32ubit (fd); wvGetFILETIME (&(item->ftModified), fd); item->fcPlcflvc = (S32) read_32ubit (fd); item->lcbPlcflvc = read_32ubit (fd); item->fcPlcasumy = (S32) read_32ubit (fd); item->lcbPlcasumy = read_32ubit (fd); item->fcPlcfgram = (S32) read_32ubit (fd); item->lcbPlcfgram = read_32ubit (fd); item->fcSttbListNames = (S32) read_32ubit (fd); item->lcbSttbListNames = read_32ubit (fd); item->fcSttbfUssr = (S32) read_32ubit (fd); item->lcbSttbfUssr = read_32ubit (fd); }
U32 wvGetMetafile(MetaFileBlip *amf, MSOFBH *amsofbh, wvStream *fd) { char extra = 0; U32 i, count; wvStream *stm = 0; char *buf, *p; for (i = 0; i < 16; i++) amf->m_rgbUid[i] = read_8ubit(fd); count = 16; amf->m_rgbUidPrimary[0] = 0; switch (amsofbh->fbt - msofbtBlipFirst) { case msoblipEMF: wvTrace(("msoblipEMF\n")); /* sprintf(buffer,"%s-wv-%d.emf",aimage,no++); */ if (amsofbh->inst ^ msobiEMF) extra = 1; break; case msoblipWMF: wvTrace(("msoblipWMF\n")); /* sprintf(buffer,"%s-wv-%d.wmf",aimage,no++); */ if (amsofbh->inst ^ msobiWMF) extra = 1; break; case msoblipPICT: wvTrace(("msoblipPICT\n")); /* sprintf(buffer,"%s-wv-%d.pict",aimage,no++); */ if (amsofbh->inst ^ msobiPICT) extra = 1; break; } if (extra) { for (i = 0; i < 16; i++) amf->m_rgbUidPrimary[i] = read_8ubit(fd); count += 16; } amf->m_cb = read_32ubit(fd); amf->m_rcBounds.bottom = read_32ubit(fd); amf->m_rcBounds.top = read_32ubit(fd); amf->m_rcBounds.right = read_32ubit(fd); amf->m_rcBounds.left = read_32ubit(fd); amf->m_ptSize.y = read_32ubit(fd); amf->m_ptSize.x = read_32ubit(fd); amf->m_cbSave = read_32ubit(fd); amf->m_fCompression = read_8ubit(fd); amf->m_fFilter = read_8ubit(fd); amf->m_pvBits = NULL; count += 34; buf = malloc(amsofbh->cbLength); p = buf; for (i = count; i < amsofbh->cbLength; i++) *p++ = read_8ubit(fd); count += i; wvStream_memory_create(&stm, buf, amsofbh->cbLength); amf->m_pvBits = stm; return count; }
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; }
/* 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; }
void wvGetFIB6 (FIB * item, wvStream * fd) { U16 temp16; U8 temp8; item->wIdent = read_16ubit (fd); item->nFib = read_16ubit (fd); item->nProduct = read_16ubit (fd); item->lid = read_16ubit (fd); wvTrace (("lid is %x\n", item->lid)); item->pnNext = (S16) read_16ubit (fd); temp16 = read_16ubit (fd); item->fDot = (temp16 & 0x0001); item->fGlsy = (temp16 & 0x0002) >> 1; item->fComplex = (temp16 & 0x0004) >> 2; item->fHasPic = (temp16 & 0x0008) >> 3; item->cQuickSaves = (temp16 & 0x00F0) >> 4; item->fEncrypted = (temp16 & 0x0100) >> 8; item->fWhichTblStm = 0; /* word 6 files only have one table stream */ item->fReadOnlyRecommended = (temp16 & 0x0400) >> 10; item->fWriteReservation = (temp16 & 0x0800) >> 11; item->fExtChar = (temp16 & 0x1000) >> 12; wvTrace (("fExtChar is %d\n", item->fExtChar)); item->fLoadOverride = 0; item->fFarEast = 0; item->fCrypto = 0; item->nFibBack = read_16ubit (fd); item->lKey = read_32ubit (fd); item->envr = read_8ubit (fd); temp8 = read_8ubit (fd); item->fMac = 0; item->fEmptySpecial = 0; item->fLoadOverridePage = 0; item->fFutureSavedUndo = 0; item->fWord97Saved = 0; item->fSpare0 = 0; item->chse = read_16ubit (fd); item->chsTables = read_16ubit (fd); item->fcMin = read_32ubit (fd); item->fcMac = read_32ubit (fd); item->csw = 14; item->wMagicCreated = 0xCA0; /*this is the unique id of the creater, so its me :-) */ item->cbMac = read_32ubit (fd); read_16ubit (fd); read_16ubit (fd); read_16ubit (fd); read_16ubit (fd); read_16ubit (fd); read_16ubit (fd); read_16ubit (fd); read_16ubit (fd); item->ccpText = read_32ubit (fd); item->ccpFtn = (S32) read_32ubit (fd); item->ccpHdr = (S32) read_32ubit (fd); item->ccpMcr = (S32) read_32ubit (fd); item->ccpAtn = (S32) read_32ubit (fd); item->ccpEdn = (S32) read_32ubit (fd); item->ccpTxbx = (S32) read_32ubit (fd); item->ccpHdrTxbx = (S32) read_32ubit (fd); read_32ubit (fd); item->fcStshfOrig = (S32) read_32ubit (fd); item->lcbStshfOrig = read_32ubit (fd); item->fcStshf = (S32) read_32ubit (fd); item->lcbStshf = read_32ubit (fd); item->fcPlcffndRef = (S32) read_32ubit (fd); item->lcbPlcffndRef = read_32ubit (fd); item->fcPlcffndTxt = (S32) read_32ubit (fd); item->lcbPlcffndTxt = read_32ubit (fd); item->fcPlcfandRef = (S32) read_32ubit (fd); item->lcbPlcfandRef = read_32ubit (fd); item->fcPlcfandTxt = (S32) read_32ubit (fd); item->lcbPlcfandTxt = read_32ubit (fd); item->fcPlcfsed = (S32) read_32ubit (fd); item->lcbPlcfsed = read_32ubit (fd); item->fcPlcpad = (S32) read_32ubit (fd); item->lcbPlcpad = read_32ubit (fd); item->fcPlcfphe = (S32) read_32ubit (fd); item->lcbPlcfphe = read_32ubit (fd); item->fcSttbfglsy = (S32) read_32ubit (fd); item->lcbSttbfglsy = read_32ubit (fd); item->fcPlcfglsy = (S32) read_32ubit (fd); item->lcbPlcfglsy = read_32ubit (fd); item->fcPlcfhdd = (S32) read_32ubit (fd); item->lcbPlcfhdd = read_32ubit (fd); item->fcPlcfbteChpx = (S32) read_32ubit (fd); item->lcbPlcfbteChpx = read_32ubit (fd); item->fcPlcfbtePapx = (S32) read_32ubit (fd); item->lcbPlcfbtePapx = read_32ubit (fd); item->fcPlcfsea = (S32) read_32ubit (fd); item->lcbPlcfsea = read_32ubit (fd); item->fcSttbfffn = (S32) read_32ubit (fd); item->lcbSttbfffn = read_32ubit (fd); item->fcPlcffldMom = (S32) read_32ubit (fd); item->lcbPlcffldMom = read_32ubit (fd); item->fcPlcffldHdr = (S32) read_32ubit (fd); item->lcbPlcffldHdr = read_32ubit (fd); item->fcPlcffldFtn = (S32) read_32ubit (fd); item->lcbPlcffldFtn = read_32ubit (fd); item->fcPlcffldAtn = (S32) read_32ubit (fd); item->lcbPlcffldAtn = read_32ubit (fd); item->fcPlcffldMcr = (S32) read_32ubit (fd); item->lcbPlcffldMcr = read_32ubit (fd); item->fcSttbfbkmk = (S32) read_32ubit (fd); item->lcbSttbfbkmk = read_32ubit (fd); item->fcPlcfbkf = (S32) read_32ubit (fd); item->lcbPlcfbkf = read_32ubit (fd); item->fcPlcfbkl = (S32) read_32ubit (fd); item->lcbPlcfbkl = read_32ubit (fd); item->fcCmds = (S32) read_32ubit (fd); item->lcbCmds = read_32ubit (fd); item->fcPlcmcr = (S32) read_32ubit (fd); item->lcbPlcmcr = read_32ubit (fd); item->fcSttbfmcr = (S32) read_32ubit (fd); item->lcbSttbfmcr = read_32ubit (fd); item->fcPrDrvr = (S32) read_32ubit (fd); item->lcbPrDrvr = read_32ubit (fd); item->fcPrEnvPort = (S32) read_32ubit (fd); item->lcbPrEnvPort = read_32ubit (fd); item->fcPrEnvLand = (S32) read_32ubit (fd); item->lcbPrEnvLand = read_32ubit (fd); item->fcWss = (S32) read_32ubit (fd); item->lcbWss = read_32ubit (fd); item->fcDop = (S32) read_32ubit (fd); item->lcbDop = read_32ubit (fd); item->fcSttbfAssoc = (S32) read_32ubit (fd); item->lcbSttbfAssoc = read_32ubit (fd); item->fcClx = (S32) read_32ubit (fd); item->lcbClx = read_32ubit (fd); item->fcPlcfpgdFtn = (S32) read_32ubit (fd); item->lcbPlcfpgdFtn = read_32ubit (fd); item->fcAutosaveSource = (S32) read_32ubit (fd); item->lcbAutosaveSource = read_32ubit (fd); item->fcGrpXstAtnOwners = (S32) read_32ubit (fd); item->lcbGrpXstAtnOwners = read_32ubit (fd); item->fcSttbfAtnbkmk = (S32) read_32ubit (fd); item->lcbSttbfAtnbkmk = read_32ubit (fd); read_16ubit (fd); item->pnChpFirst = (S32) read_16ubit (fd); item->pnPapFirst = (S32) read_16ubit (fd); item->cpnBteChp = (S32) read_16ubit (fd); item->cpnBtePap = (S32) read_16ubit (fd); item->fcPlcdoaMom = (S32) read_32ubit (fd); item->lcbPlcdoaMom = read_32ubit (fd); item->fcPlcdoaHdr = (S32) read_32ubit (fd); item->lcbPlcdoaHdr = read_32ubit (fd); read_32ubit (fd); read_32ubit (fd); read_32ubit (fd); read_32ubit (fd); item->fcPlcfAtnbkf = (S32) read_32ubit (fd); item->lcbPlcfAtnbkf = read_32ubit (fd); item->fcPlcfAtnbkl = (S32) read_32ubit (fd); item->lcbPlcfAtnbkl = read_32ubit (fd); item->fcPms = (S32) read_32ubit (fd); item->lcbPms = read_32ubit (fd); item->fcFormFldSttbs = (S32) read_32ubit (fd); item->lcbFormFldSttbs = read_32ubit (fd); item->fcPlcfendRef = (S32) read_32ubit (fd); item->lcbPlcfendRef = read_32ubit (fd); item->fcPlcfendTxt = (S32) read_32ubit (fd); item->lcbPlcfendTxt = read_32ubit (fd); item->fcPlcffldEdn = (S32) read_32ubit (fd); item->lcbPlcffldEdn = read_32ubit (fd); item->fcPlcfpgdEdn = (S32) read_32ubit (fd); item->lcbPlcfpgdEdn = read_32ubit (fd); read_32ubit (fd); read_32ubit (fd); item->fcSttbfRMark = (S32) read_32ubit (fd); item->lcbSttbfRMark = read_32ubit (fd); item->fcSttbCaption = (S32) read_32ubit (fd); item->lcbSttbCaption = read_32ubit (fd); item->fcSttbAutoCaption = (S32) read_32ubit (fd); item->lcbSttbAutoCaption = read_32ubit (fd); item->fcPlcfwkb = (S32) read_32ubit (fd); item->lcbPlcfwkb = read_32ubit (fd); read_32ubit (fd); read_32ubit (fd); item->fcPlcftxbxTxt = (S32) read_32ubit (fd); item->lcbPlcftxbxTxt = read_32ubit (fd); item->fcPlcffldTxbx = (S32) read_32ubit (fd); item->lcbPlcffldTxbx = read_32ubit (fd); item->fcPlcfhdrtxbxTxt = (S32) read_32ubit (fd); item->lcbPlcfhdrtxbxTxt = read_32ubit (fd); item->fcPlcffldHdrTxbx = (S32) read_32ubit (fd); item->lcbPlcffldHdrTxbx = read_32ubit (fd); item->fcStwUser = (S32) read_32ubit (fd); item->lcbStwUser = read_32ubit (fd); item->fcSttbttmbd = (S32) read_32ubit (fd); item->cbSttbttmbd = read_32ubit (fd); item->fcUnused = (S32) read_32ubit (fd); item->lcbUnused = read_32ubit (fd); item->fcPgdMother = (S32) read_32ubit (fd); item->lcbPgdMother = read_32ubit (fd); item->fcBkdMother = (S32) read_32ubit (fd); item->lcbBkdMother = read_32ubit (fd); item->fcPgdFtn = (S32) read_32ubit (fd); item->lcbPgdFtn = read_32ubit (fd); item->fcBkdFtn = (S32) read_32ubit (fd); item->lcbBkdFtn = read_32ubit (fd); item->fcPgdEdn = (S32) read_32ubit (fd); item->lcbPgdEdn = read_32ubit (fd); item->fcBkdEdn = (S32) read_32ubit (fd); item->lcbBkdEdn = read_32ubit (fd); item->fcSttbfIntlFld = (S32) read_32ubit (fd); item->lcbSttbfIntlFld = read_32ubit (fd); item->fcRouteSlip = (S32) read_32ubit (fd); item->lcbRouteSlip = read_32ubit (fd); item->fcSttbSavedBy = (S32) read_32ubit (fd); item->lcbSttbSavedBy = read_32ubit (fd); item->fcSttbFnm = (S32) read_32ubit (fd); item->lcbSttbFnm = read_32ubit (fd); }