diff -r f345bda72bc4 -r 43e37759235e Symbian3/Examples/guid-6013a680-57f9-415b-8851-c4fa63356636/worddos_8c_source.html --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Symbian3/Examples/guid-6013a680-57f9-415b-8851-c4fa63356636/worddos_8c_source.html Tue Mar 30 16:16:55 2010 +0100 @@ -0,0 +1,126 @@ + + + + +TB9.2 Example Applications: examples/PIPS/antiword/src/worddos.c Source File + + + + + +

examples/PIPS/antiword/src/worddos.c

00001 /*
+00002  * worddos.c
+00003  * Copyright (C) 2002-2005 A.J. van Os; Released under GNU GPL
+00004  *
+00005  * Description:
+00006  * Deal with the DOS internals of a MS Word file
+00007  */
+00008 
+00009 #include "antiword.h"
+00010 
+00011 
+00012 /*
+00013  * bGetDocumentText - make a list of the text blocks of a Word document
+00014  *
+00015  * Return TRUE when succesful, otherwise FALSE
+00016  */
+00017 static BOOL
+00018 bGetDocumentText(FILE *pFile, long lFilesize, const UCHAR *aucHeader)
+00019 {
+00020         text_block_type tTextBlock;
+00021         ULONG   ulTextLen;
+00022         BOOL    bFastSaved;
+00023         UCHAR   ucDocStatus, ucVersion;
+00024 
+00025         fail(pFile == NULL);
+00026         fail(lFilesize < 128);
+00027         fail(aucHeader == NULL);
+00028 
+00029         /* Get the status flags from the header */
+00030         ucDocStatus = ucGetByte(0x75, aucHeader);
+00031         DBG_HEX(ucDocStatus);
+00032         bFastSaved = (ucDocStatus & BIT(1)) != 0;
+00033         DBG_MSG_C(bFastSaved, "This document is Fast Saved");
+00034         ucVersion = ucGetByte(0x74, aucHeader);
+00035         DBG_DEC(ucVersion);
+00036         DBG_MSG_C(ucVersion == 0, "Written by Word 4.0 or earlier");
+00037         DBG_MSG_C(ucVersion == 3, "Word 5.0 format, but not written by Word");
+00038         DBG_MSG_C(ucVersion == 4, "Written by Word 5.x");
+00039         if (bFastSaved) {
+00040                 werr(0, "Word for DOS: autosave documents are not supported");
+00041                 return FALSE;
+00042         }
+00043 
+00044         /* Get length information */
+00045         ulTextLen = ulGetLong(0x0e, aucHeader);
+00046         DBG_HEX(ulTextLen);
+00047         ulTextLen -= 128;
+00048         DBG_DEC(ulTextLen);
+00049         tTextBlock.ulFileOffset = 128;
+00050         tTextBlock.ulCharPos = 128;
+00051         tTextBlock.ulLength = ulTextLen;
+00052         tTextBlock.bUsesUnicode = FALSE;
+00053         tTextBlock.usPropMod = IGNORE_PROPMOD;
+00054         if (!bAdd2TextBlockList(&tTextBlock)) {
+00055                 DBG_HEX(tTextBlock.ulFileOffset);
+00056                 DBG_HEX(tTextBlock.ulCharPos);
+00057                 DBG_DEC(tTextBlock.ulLength);
+00058                 DBG_DEC(tTextBlock.bUsesUnicode);
+00059                 DBG_DEC(tTextBlock.usPropMod);
+00060                 return FALSE;
+00061         }
+00062         return TRUE;
+00063 } /* end of bGetDocumentText */
+00064 
+00065 /*
+00066  * iInitDocumentDOS - initialize an DOS document
+00067  *
+00068  * Returns the version of Word that made the document or -1
+00069  */
+00070 int
+00071 iInitDocumentDOS(FILE *pFile, long lFilesize)
+00072 {
+00073         int     iWordVersion;
+00074         BOOL    bSuccess;
+00075         USHORT  usIdent;
+00076         UCHAR   aucHeader[128];
+00077 
+00078         fail(pFile == NULL);
+00079 
+00080         if (lFilesize < 128) {
+00081                 return -1;
+00082         }
+00083 
+00084         /* Read the headerblock */
+00085         if (!bReadBytes(aucHeader, 128, 0x00, pFile)) {
+00086                 return -1;
+00087         }
+00088         /* Get the "magic number" from the header */
+00089         usIdent = usGetWord(0x00, aucHeader);
+00090         DBG_HEX(usIdent);
+00091         fail(usIdent != 0xbe31);        /* Word for DOS */
+00092         iWordVersion = iGetVersionNumber(aucHeader);
+00093         if (iWordVersion != 0) {
+00094                 werr(0, "This file is not from 'Word for DOS'.");
+00095                 return -1;
+00096         }
+00097         bSuccess = bGetDocumentText(pFile, lFilesize, aucHeader);
+00098         if (bSuccess) {
+00099                 vGetPropertyInfo(pFile, NULL,
+00100                                 NULL, 0, NULL, 0,
+00101                                 aucHeader, iWordVersion);
+00102                 vSetDefaultTabWidth(pFile, NULL,
+00103                                 NULL, 0, NULL, 0,
+00104                                 aucHeader, iWordVersion);
+00105                 vGetNotesInfo(pFile, NULL,
+00106                                 NULL, 0, NULL, 0,
+00107                                 aucHeader, iWordVersion);
+00108         }
+00109         return bSuccess ? iWordVersion : -1;
+00110 } /* end of iInitDocumentDOS */
+
+
Generated by  + +doxygen 1.6.2
+ +