On Thu, Sep 07, 2000 at 12:08:27AM -0500, sam th wrote:
[...]
>
> It's always good to have compatibility with as many formats as
> possible. We wouldn't want data to end up lost becuase of format
> incompatibility.
>
> Could you post some Word 2 documents so others of us can test this patch?
>
> Thanks
>
> sam th
> [EMAIL PROTECTED]
> http://www.abisource.com/~sam/
[...]
That's difficult as I don't have the copyright on any of them. But I'm
happy to mail some to any of you personally.
And... I think the main focus of testing should be regression, i.e. nothing
else breaks. I have done very little of that.
Attached an improved version of the patch including the FIB layout
for Word 2, after a little bird whispered in my ear... ;-)
It doesn't do anything yet, but it's there now.
Martin
--
Martin Vermeer [EMAIL PROTECTED]
Helsinki University of Technology
Institute of Geodesy and Cartography
PL 1200, FIN-02015 TKK, Finland
:wq
Index: clx.c
===================================================================
RCS file: /cvsroot/wv/clx.c,v
retrieving revision 1.17
diff -u -r1.17 clx.c
--- clx.c 2000/08/28 04:41:53 1.17
+++ clx.c 2000/09/04 20:35:21
@@ -103,7 +103,7 @@
wvGetPCD_PLCF(&clx->pcd,&clx->pos,&clx->nopcd,wvStream_tell(fd),lcb,fd);
j+=lcb;
- if (ver == WORD7)
+ if (ver <= WORD7) /* MV 28.8.2000 Appears to be valid */
{
#if 0
/* DANGER !!, this is a completely mad attempt to
differenciate
@@ -115,18 +115,6 @@
/* I think that this is the correct reason for this
behaviour */
if (fExtChar == 0)
#endif
- for (i=0;i<clx->nopcd;i++)
- {
- clx->pcd[i].fc *= 2;
- clx->pcd[i].fc |= 0x40000000UL;
- }
- }
- if (ver == WORD6)
- {
- /* Copy the above ;-) MV 27.8.2000
- Note: worth trying for WORD2 etc. also (?)
- */
- if (fExtChar == 0)
for (i=0;i<clx->nopcd;i++)
{
clx->pcd[i].fc *= 2;
Index: decode_simple.c
===================================================================
RCS file: /cvsroot/wv/decode_simple.c,v
retrieving revision 1.48
diff -u -r1.48 decode_simple.c
--- decode_simple.c 2000/06/06 00:55:16 1.48
+++ decode_simple.c 2000/09/04 20:35:24
@@ -2,6 +2,9 @@
#include <stdio.h>
#include "wv.h"
+extern (*charhandler) ();
+extern (*scharhandler) ();
+
/*
how this works,
we seek to the beginning of the text, we loop for a count of charaters that is stored
in the fib.
@@ -166,6 +169,23 @@
If !fib.fComplex, the document text stream is represented by the text
beginning at fib.fcMin up to (but not including) fib.fcMac.
*/
+
+ if ( (ver == WORD2) && !ps->fib.fComplex)
+ {
+ wvHandleDocument(ps,DOCBEGIN);
+ wvStream_goto(ps->mainfd,ps->fib.fcMin);
+ for (i = ps->fib.fcMin; i < ps->fib.fcMac; i++)
+ {
+ eachchar = wvGetChar(ps->mainfd, 1);
+ (*charhandler)(ps, eachchar, 1, ps->fib.lid);
+ /* (*scharhandler)(ps,eachchar,&achp; no go */
+ /* wvOutputTextChar(eachchar, 1, ps, &achp); no go */
+ /* Formatting still lacking. This is just a start. */
+ }
+ wvHandleDocument(ps,DOCEND);
+ return;
+ }
+
#ifdef DEBUG
if ( ps->fib.fcMac != wvGetEndFCPiece(ps->clx.nopcd-1,&ps->clx) )
Index: fib.c
===================================================================
RCS file: /cvsroot/wv/fib.c,v
retrieving revision 1.25
diff -u -r1.25 fib.c
--- fib.c 2000/06/06 00:55:16 1.25
+++ fib.c 2000/09/04 20:35:30
@@ -275,6 +275,14 @@
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);
@@ -618,6 +626,145 @@
return(ret);
}
+void wvGetFIB2(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; /* Unused from here on */
+ item->fReadOnlyRecommended = 0;
+ item->fWriteReservation = 0;
+ item->fExtChar = 0;
+ item->fLoadOverride = 0;
+ item->fFarEast = 0;
+ item->fCrypto = 0;
+
+ item->nFibBack = read_16ubit(fd);
+ wvTrace(("nFibBack is %d\n",item->nFibBack));
+
+ item->Spare = read_32ubit(fd); /* A spare for W2 */
+ item->rgwSpare0[0] = read_16ubit(fd);
+ item->rgwSpare0[1] = read_16ubit(fd);
+ item->rgwSpare0[2] = read_16ubit(fd);
+ item->fcMin = read_32ubit(fd); /* These appear correct MV 29.8.2000 */
+ item->fcMac = read_32ubit(fd);
+ wvTrace(("fc from %d to %d\n", item->fcMin, item->fcMac));
+
+ item->cbMac = read_32ubit(fd); /* Last byte file position plus one. */
+
+ item->fcSpare0 = read_32ubit(fd);
+ item->fcSpare1 = read_32ubit(fd);
+ item->fcSpare2 = read_32ubit(fd);
+ item->fcSpare3 = read_32ubit(fd);
+
+ item->ccpText = read_32ubit(fd);
+ wvTrace(("length %d == %d\n", item->fcMac - item->fcMin, item->ccpText));
+
+ 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->ccpSpare0 = (S32)read_32ubit(fd);
+ item->ccpSpare1 = (S32)read_32ubit(fd);
+ item->ccpSpare2 = (S32)read_32ubit(fd);
+ item->ccpSpare3 = (S32)read_32ubit(fd);
+
+ item->fcStshfOrig = read_32ubit(fd);
+ item->lcbStshfOrig = (S32)read_16ubit(fd);
+ item->fcStshf = read_32ubit(fd);
+ item->lcbStshf = (S32)read_16ubit(fd);
+ item->fcPlcffndRef = read_32ubit(fd);
+ item->lcbPlcffndRef = (S32)read_16ubit(fd);
+ item->fcPlcffndTxt = read_32ubit(fd);
+ item->lcbPlcffndTxt = (S32)read_16ubit(fd);
+ item->fcPlcfandRef = read_32ubit(fd);
+ item->lcbPlcfandRef = (S32)read_16ubit(fd);
+ item->fcPlcfandTxt = read_32ubit(fd);
+ item->lcbPlcfandTxt = (S32)read_16ubit(fd);
+ item->fcPlcfsed = read_32ubit(fd);
+ item->lcbPlcfsed = (S32)read_16ubit(fd);
+ item->fcPlcfpgd = read_32ubit(fd);
+ item->cbPlcfpgd = read_16ubit(fd);
+ item->fcPlcfphe = read_32ubit(fd);
+ item->lcbPlcfphe = (S32)read_16ubit(fd);
+ item->fcPlcfglsy = read_32ubit(fd);
+ item->lcbPlcfglsy = (S32)read_16ubit(fd);
+ item->fcPlcfhdd = read_32ubit(fd);
+ item->lcbPlcfhdd = (S32)read_16ubit(fd);
+ item->fcPlcfbteChpx = read_32ubit(fd);
+ item->lcbPlcfbteChpx = (S32)read_16ubit(fd);
+ item->fcPlcfbtePapx = read_32ubit(fd);
+ item->lcbPlcfbtePapx = (S32)read_16ubit(fd);
+ item->fcPlcfsea = read_32ubit(fd);
+ item->lcbPlcfsea = (S32)read_16ubit(fd);
+ item->fcSttbfffn = read_32ubit(fd);
+ item->lcbSttbfffn = (S32)read_16ubit(fd);
+ item->fcPlcffldMom = read_32ubit(fd);
+ item->lcbPlcffldMom = (S32)read_16ubit(fd);
+ item->fcPlcffldHdr = read_32ubit(fd);
+ item->lcbPlcffldHdr = (S32)read_16ubit(fd);
+ item->fcPlcffldFtn = read_32ubit(fd);
+ item->lcbPlcffldFtn = (S32)read_16ubit(fd);
+ item->fcPlcffldAtn = read_32ubit(fd);
+ item->lcbPlcffldAtn = (S32)read_16ubit(fd);
+ item->fcPlcffldMcr = read_32ubit(fd);
+ item->lcbPlcffldMcr = (S32)read_16ubit(fd);
+ item->fcSttbfbkmk = read_32ubit(fd);
+ item->lcbSttbfbkmk = (S32)read_16ubit(fd);
+ item->fcPlcfbkf = read_32ubit(fd);
+ item->lcbPlcfbkf = (S32)read_16ubit(fd);
+ item->fcPlcfbkl = read_32ubit(fd);
+ item->lcbPlcfbkl = (S32)read_16ubit(fd);
+ item->fcCmds = read_32ubit(fd);
+ item->lcbCmds = (S32)read_16ubit(fd);
+ item->fcPlcmcr = read_32ubit(fd);
+ item->lcbPlcmcr = (S32)read_16ubit(fd);
+ item->fcSttbfmcr = read_32ubit(fd);
+ item->lcbSttbfmcr = (S32)read_16ubit(fd);
+ item->fcPrDrvr = read_32ubit(fd);
+ item->lcbPrDrvr = (S32)read_16ubit(fd);
+ item->fcPrEnvPort = read_32ubit(fd);
+ item->lcbPrEnvPort = (S32)read_16ubit(fd);
+ item->fcPrEnvLand = read_32ubit(fd);
+ item->lcbPrEnvLand = (S32)read_16ubit(fd);
+ item->fcWss = read_32ubit(fd);
+ item->lcbWss = (S32)read_16ubit(fd);
+ item->fcDop = read_32ubit(fd);
+ item->lcbDop = (S32)read_16ubit(fd);
+ item->fcSttbfAssoc = read_32ubit(fd);
+ item->lcbSttbfAssoc = (S32)read_16ubit(fd);
+ item->fcClx = read_32ubit(fd);
+ item->lcbClx = (S32)read_16ubit(fd);
+ item->fcPlcfpgdFtn = read_32ubit(fd);
+ item->lcbPlcfpgdFtn = (S32)read_16ubit(fd);
+ item->fcAutosaveSource = read_32ubit(fd);
+ item->lcbAutosaveSource = (S32)read_16ubit(fd);
+ item->fcSpare5 = read_32ubit(fd);
+ item->cbSpare5 = read_16ubit(fd);
+ item->fcSpare6 = read_32ubit(fd);
+ item->cbSpare6 = read_16ubit(fd);
+ item->wSpare4 = read_16ubit(fd);
+ item->pnChpFirst = read_16ubit(fd);
+ item->pnPapFirst = read_16ubit(fd);
+ item->cpnBteChp = read_16ubit(fd);
+ item->cpnBtePap = read_16ubit(fd);
+
+ }
void wvGetFIB6(FIB *item,wvStream *fd)
{
Index: wv.h
===================================================================
RCS file: /cvsroot/wv/wv.h,v
retrieving revision 1.66
diff -u -r1.66 wv.h
--- wv.h 2000/08/02 23:27:12 1.66
+++ wv.h 2000/09/04 20:35:48
@@ -465,9 +465,33 @@
U32 lcbSttbListNames ; /* 0x0376 */
S32 fcSttbfUssr ; /* 0x037A */
U32 lcbSttbfUssr ; /* 0x037E */
+
+ /* Added for Word 2 */
+
+ U32 Spare ; /* 0x000E */
+ U16 rgwSpare0 [3] ; /* 0x0012 */
+ U32 fcSpare0 ; /* 0x0024 */
+ U32 fcSpare1 ; /* 0x0028 */
+ U32 fcSpare2 ; /* 0x002C */
+ U32 fcSpare3 ; /* 0x0030 */
+ U32 ccpSpare0 ; /* 0x0048 */
+ U32 ccpSpare1 ; /* 0x004C */
+ U32 ccpSpare2 ; /* 0x0050 */
+ U32 ccpSpare3 ; /* 0x0054 */
+
+ U32 fcPlcfpgd ; /* 0x0082 */
+ U16 cbPlcfpgd ; /* 0x0086 */
+
+ U32 fcSpare5 ; /* 0x0130 */
+ U16 cbSpare5 ; /* 0x0136 */
+ U32 fcSpare6 ; /* 0x0130 */
+ U16 cbSpare6 ; /* 0x0136 */
+ U16 wSpare4 ; /* 0x013C */
+
} FIB;
void wvGetFIB(FIB *item,wvStream *fd);
+void wvGetFIB2(FIB *item,wvStream *fd);
void wvGetFIB6(FIB *item,wvStream *fd);
void wvInitFIB(FIB *item);
Index: wvHtml.c
===================================================================
RCS file: /cvsroot/wv/wvHtml.c,v
retrieving revision 1.45
diff -u -r1.45 wvHtml.c
--- wvHtml.c 2000/08/28 04:41:53 1.45
+++ wvHtml.c 2000/09/04 20:35:50
@@ -251,7 +251,7 @@
ps.filename = argv[optind];
ps.dir = dir;
- if (ret & 0x8000)
+ if (ret & 0x8000) /* Password protected? */
{
if ( (ret & 0x7fff) == WORD8)
{
@@ -509,7 +509,7 @@
be done manually for now (until libwmf supports .eps)
but it's a start */
printf("\n\\resizebox{%dpt}{%dpt}\
- {\\includegraphics{%s}}\
+ {\\includegraphics{%s.eps}}\
\n-- %#.2x graphic -- \n",
width, height, source, graphicstype);
else
Index: wvparse.c
===================================================================
RCS file: /cvsroot/wv/wvparse.c,v
retrieving revision 1.26
diff -u -r1.26 wvparse.c
--- wvparse.c 2000/06/06 00:55:16 1.26
+++ wvparse.c 2000/09/04 20:35:51
@@ -62,7 +62,8 @@
if ( (ret&0x7fff) != WORD8 )
ps->data = ps->mainfd;
- if ( (ret != WORD8) && (ret != WORD7) && (ret!= WORD6) )
+ if ( (ret != WORD8) && (ret != WORD7) && (ret!= WORD6) && (ret!= WORD2) )
+ /* WORD2 test */
{
/* return the errors and the encrypted files*/
if (!(ret & 0x8000))
@@ -119,7 +120,8 @@
{
wvError(("Theres a good chance that this is a word 2 doc of nFib
%d\n",read_16ubit(*mainfd)));
wvStream_rewind(*mainfd);
- return(-1);
+// return(-1);
+ return(0);
}
else if (0x37fe == magic)
{
Index: oledecod/oledecod.c
===================================================================
RCS file: /cvsroot/wv/oledecod/oledecod.c,v
retrieving revision 1.8
diff -u -r1.8 oledecod.c
--- oledecod/oledecod.c 2000/03/30 09:01:43 1.8
+++ oledecod/oledecod.c 2000/09/04 20:35:55
@@ -94,13 +94,14 @@
root_list = sbd_list = NULL;
/* open input file */
- test (input != NULL, 4, ends ());
+ test (input != NULL, 4, ends ()); /* cannot be opened */
/* fast check type of file */
verbose ("fast testing type of file");
test ((c = getc (input)) != EOF, 5, ends ());
test (ungetc (c, input) != EOF, 5, ends ());
- test ( (c < 32 || c > 126) , 8, ends ());
+ test ( (c < 32 || c > 126) , 8, ends ()); /* We have a legible character, not good
+*/
+ test (c != 0xdb, 2, ends ()); /* probably non-ole Word 2 file */
test (c == 0xd0, 9, ends ());
/* read header block */