diff -r 59758314f811 -r d4524d6a4472 Symbian3/Examples/guid-6013a680-57f9-415b-8851-c4fa63356636/wordmac_8c_source.html --- a/Symbian3/Examples/guid-6013a680-57f9-415b-8851-c4fa63356636/wordmac_8c_source.html Fri Jun 11 15:24:34 2010 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,124 +0,0 @@ - - -
- -00001 /* -00002 * wordmac.c -00003 * Copyright (C) 2002-2004 A.J. van Os; Released under GNU GPL -00004 * -00005 * Description: -00006 * Deal with the MAC 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, const UCHAR *aucHeader) -00019 { -00020 text_block_type tTextBlock; -00021 ULONG ulBeginOfText, ulEndOfText; -00022 ULONG ulTextLen; -00023 UCHAR ucDocStatus; -00024 BOOL bFastSaved; -00025 -00026 fail(pFile == NULL); -00027 fail(aucHeader == NULL); -00028 -00029 DBG_MSG("bGetDocumentText"); -00030 -00031 NO_DBG_PRINT_BLOCK(aucHeader, 0x20); -00032 -00033 /* Get the status flags from the header */ -00034 ucDocStatus = ucGetByte(0x0a, aucHeader); -00035 DBG_HEX(ucDocStatus); -00036 bFastSaved = (ucDocStatus & BIT(5)) != 0; -00037 DBG_MSG_C(bFastSaved, "This document is Fast Saved"); -00038 if (bFastSaved) { -00039 werr(0, "MacWord: fast saved documents are not supported yet"); -00040 return FALSE; -00041 } -00042 -00043 /* Get length information */ -00044 ulBeginOfText = ulGetLongBE(0x14, aucHeader); -00045 DBG_HEX(ulBeginOfText); -00046 ulEndOfText = ulGetLongBE(0x18, aucHeader); -00047 DBG_HEX(ulEndOfText); -00048 ulTextLen = ulEndOfText - ulBeginOfText; -00049 DBG_DEC(ulTextLen); -00050 tTextBlock.ulFileOffset = ulBeginOfText; -00051 tTextBlock.ulCharPos = ulBeginOfText; -00052 tTextBlock.ulLength = ulTextLen; -00053 tTextBlock.bUsesUnicode = FALSE; -00054 tTextBlock.usPropMod = IGNORE_PROPMOD; -00055 if (!bAdd2TextBlockList(&tTextBlock)) { -00056 DBG_HEX(tTextBlock.ulFileOffset); -00057 DBG_HEX(tTextBlock.ulCharPos); -00058 DBG_DEC(tTextBlock.ulLength); -00059 DBG_DEC(tTextBlock.bUsesUnicode); -00060 DBG_DEC(tTextBlock.usPropMod); -00061 return FALSE; -00062 } -00063 return TRUE; -00064 } /* end of bGetDocumentText */ -00065 -00066 /* -00067 * iInitDocumentMAC - initialize an MAC document -00068 * -00069 * Returns the version of Word that made the document or -1 -00070 */ -00071 int -00072 iInitDocumentMAC(FILE *pFile, long lFilesize) -00073 { -00074 int iWordVersion; -00075 BOOL bSuccess; -00076 USHORT usIdent; -00077 UCHAR aucHeader[256]; -00078 -00079 fail(pFile == NULL); -00080 -00081 if (lFilesize < 256) { -00082 return -1; -00083 } -00084 -00085 /* Read the headerblock */ -00086 if (!bReadBytes(aucHeader, 256, 0x00, pFile)) { -00087 return -1; -00088 } -00089 /* Get the "magic number" from the header */ -00090 usIdent = usGetWord(0x00, aucHeader); -00091 DBG_HEX(usIdent); -00092 fail(usIdent != 0x37fe); /* MacWord 4 and 5 */ -00093 iWordVersion = iGetVersionNumber(aucHeader); -00094 if (iWordVersion != 4 && iWordVersion != 5) { -00095 werr(0, "This file is not from ''Mac Word 4 or 5'."); -00096 return -1; -00097 } -00098 bSuccess = bGetDocumentText(pFile, aucHeader); -00099 if (bSuccess) { -00100 vGetPropertyInfo(pFile, NULL, -00101 NULL, 0, NULL, 0, -00102 aucHeader, iWordVersion); -00103 vSetDefaultTabWidth(pFile, NULL, -00104 NULL, 0, NULL, 0, -00105 aucHeader, iWordVersion); -00106 } -00107 return bSuccess ? iWordVersion : -1; -00108 } /* end of iInitDocumentMAC */ -