diff -r 59758314f811 -r d4524d6a4472 Symbian3/Examples/guid-6013a680-57f9-415b-8851-c4fa63356636/tabstop_8c_source.html --- a/Symbian3/Examples/guid-6013a680-57f9-415b-8851-c4fa63356636/tabstop_8c_source.html Fri Jun 11 15:24:34 2010 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,228 +0,0 @@ - - - - -TB9.2 Example Applications: examples/PIPS/antiword/src/tabstop.c Source File - - - - - -

examples/PIPS/antiword/src/tabstop.c

00001 /*
-00002  * tabstops.c
-00003  * Copyright (C) 1999-2004 A.J. van Os; Released under GNU GPL
-00004  *
-00005  * Description:
-00006  * Read the tab stop information from a MS Word file
-00007  */
-00008 
-00009 #include <stdio.h>
-00010 #include "antiword.h"
-00011 
-00012 #define HALF_INCH       36000L  /* In millipoints */
-00013 
-00014 static long     lDefaultTabWidth = HALF_INCH;
-00015 
-00016 
-00017 /*
-00018  * vSet0DefaultTabWidth -
-00019  */
-00020 static void
-00021 vSet0DefaultTabWidth(const UCHAR *aucHeader)
-00022 {
-00023         USHORT  usTmp;
-00024 
-00025         fail(aucHeader == NULL);
-00026 
-00027         usTmp = usGetWord(0x70, aucHeader); /* dxaTab */
-00028         DBG_DEC(usTmp);
-00029         lDefaultTabWidth = usTmp == 0 ? HALF_INCH : lTwips2MilliPoints(usTmp);
-00030         DBG_DEC(lDefaultTabWidth);
-00031 } /* end of vSet0DefaultTabWidth */
-00032 
-00033 /*
-00034  * vSet2DefaultTabWidth -
-00035  */
-00036 static void
-00037 vSet2DefaultTabWidth(FILE *pFile, const UCHAR *aucHeader)
-00038 {
-00039         UCHAR   *aucBuffer;
-00040         ULONG   ulBeginDocpInfo;
-00041         size_t  tDocpInfoLen;
-00042         USHORT  usTmp;
-00043 
-00044         fail(pFile == NULL || aucHeader == NULL);
-00045 
-00046         ulBeginDocpInfo = ulGetLong(0x112, aucHeader); /* fcDop */
-00047         DBG_HEX(ulBeginDocpInfo);
-00048         tDocpInfoLen = (size_t)usGetWord(0x116, aucHeader); /* cbDop */
-00049         DBG_DEC(tDocpInfoLen);
-00050         if (tDocpInfoLen < 12) {
-00051                 DBG_MSG("No TAB information");
-00052                 return;
-00053         }
-00054 
-00055         aucBuffer = xmalloc(tDocpInfoLen);
-00056         if (!bReadBytes(aucBuffer, tDocpInfoLen, ulBeginDocpInfo, pFile)) {
-00057                 aucBuffer = xfree(aucBuffer);
-00058                 return;
-00059         }
-00060         usTmp = usGetWord(0x0a, aucBuffer); /* dxaTab */
-00061         lDefaultTabWidth = usTmp == 0 ? HALF_INCH : lTwips2MilliPoints(usTmp);
-00062         DBG_DEC(lDefaultTabWidth);
-00063         aucBuffer = xfree(aucBuffer);
-00064 } /* end of vSet2DefaultTabWidth */
-00065 
-00066 /*
-00067  * vSet6DefaultTabWidth -
-00068  */
-00069 static void
-00070 vSet6DefaultTabWidth(FILE *pFile, ULONG ulStartBlock,
-00071         const ULONG *aulBBD, size_t tBBDLen, const UCHAR *aucHeader)
-00072 {
-00073         UCHAR   *aucBuffer;
-00074         ULONG   ulBeginDocpInfo;
-00075         size_t  tDocpInfoLen;
-00076         USHORT  usTmp;
-00077 
-00078         ulBeginDocpInfo = ulGetLong(0x150, aucHeader); /* fcDop */
-00079         DBG_HEX(ulBeginDocpInfo);
-00080         tDocpInfoLen = (size_t)ulGetLong(0x154, aucHeader); /* lcbDop */
-00081         DBG_DEC(tDocpInfoLen);
-00082         if (tDocpInfoLen < 12) {
-00083                 DBG_MSG("No TAB information");
-00084                 return;
-00085         }
-00086 
-00087         aucBuffer = xmalloc(tDocpInfoLen);
-00088         if (!bReadBuffer(pFile, ulStartBlock,
-00089                         aulBBD, tBBDLen, BIG_BLOCK_SIZE,
-00090                         aucBuffer, ulBeginDocpInfo, tDocpInfoLen)) {
-00091                 aucBuffer = xfree(aucBuffer);
-00092                 return;
-00093         }
-00094         usTmp = usGetWord(0x0a, aucBuffer); /* dxaTab */
-00095         lDefaultTabWidth = usTmp == 0 ? HALF_INCH : lTwips2MilliPoints(usTmp);
-00096         DBG_DEC(lDefaultTabWidth);
-00097         aucBuffer = xfree(aucBuffer);
-00098 } /* end of vSet6DefaultTabWidth */
-00099 
-00100 /*
-00101  * vSet8DefaultTabWidth -
-00102  */
-00103 static void
-00104 vSet8DefaultTabWidth(FILE *pFile, const pps_info_type *pPPS,
-00105         const ULONG *aulBBD, size_t tBBDLen,
-00106         const ULONG *aulSBD, size_t tSBDLen,
-00107         const UCHAR *aucHeader)
-00108 {
-00109         const ULONG     *aulBlockDepot;
-00110         UCHAR   *aucBuffer;
-00111         ULONG   ulBeginDocpInfo;
-00112         size_t  tDocpInfoLen, tBlockDepotLen, tBlockSize;
-00113         USHORT  usTmp;
-00114 
-00115         ulBeginDocpInfo = ulGetLong(0x192, aucHeader); /* fcDop */
-00116         DBG_HEX(ulBeginDocpInfo);
-00117         tDocpInfoLen = (size_t)ulGetLong(0x196, aucHeader); /* lcbDop */
-00118         DBG_DEC(tDocpInfoLen);
-00119         if (tDocpInfoLen < 12) {
-00120                 DBG_MSG("No TAB information");
-00121                 return;
-00122         }
-00123 
-00124         DBG_DEC(pPPS->tTable.ulSB);
-00125         DBG_HEX(pPPS->tTable.ulSize);
-00126         if (pPPS->tTable.ulSize == 0) {
-00127                 DBG_MSG("No TAB information");
-00128                 return;
-00129         }
-00130 
-00131         if (pPPS->tTable.ulSize < MIN_SIZE_FOR_BBD_USE) {
-00132                 /* Use the Small Block Depot */
-00133                 aulBlockDepot = aulSBD;
-00134                 tBlockDepotLen = tSBDLen;
-00135                 tBlockSize = SMALL_BLOCK_SIZE;
-00136         } else {
-00137                 /* Use the Big Block Depot */
-00138                 aulBlockDepot = aulBBD;
-00139                 tBlockDepotLen = tBBDLen;
-00140                 tBlockSize = BIG_BLOCK_SIZE;
-00141         }
-00142         aucBuffer = xmalloc(tDocpInfoLen);
-00143         if (!bReadBuffer(pFile, pPPS->tTable.ulSB,
-00144                         aulBlockDepot, tBlockDepotLen, tBlockSize,
-00145                         aucBuffer, ulBeginDocpInfo, tDocpInfoLen)) {
-00146                 aucBuffer = xfree(aucBuffer);
-00147                 return;
-00148         }
-00149         usTmp = usGetWord(0x0a, aucBuffer); /* dxaTab */
-00150         lDefaultTabWidth = usTmp == 0 ? HALF_INCH : lTwips2MilliPoints(usTmp);
-00151         DBG_DEC(lDefaultTabWidth);
-00152         aucBuffer = xfree(aucBuffer);
-00153 } /* end of vSet8DefaultTabWidth */
-00154 
-00155 /*
-00156  * vSetDefaultTabWidth -
-00157  */
-00158 void
-00159 vSetDefaultTabWidth(FILE *pFile, const pps_info_type *pPPS,
-00160         const ULONG *aulBBD, size_t tBBDLen,
-00161         const ULONG *aulSBD, size_t tSBDLen,
-00162         const UCHAR *aucHeader, int iWordVersion)
-00163 {
-00164         fail(pFile == NULL && iWordVersion >= 1);
-00165         fail(pPPS == NULL && iWordVersion >= 6);
-00166         fail(aulBBD == NULL && tBBDLen != 0);
-00167         fail(aulSBD == NULL && tSBDLen != 0);
-00168         fail(aucHeader == NULL);
-00169 
-00170         /* Reset to the default default value */
-00171         lDefaultTabWidth = HALF_INCH;
-00172 
-00173         switch (iWordVersion) {
-00174         case 0:
-00175                 vSet0DefaultTabWidth(aucHeader);
-00176                 break;
-00177         case 1:
-00178         case 2:
-00179                 vSet2DefaultTabWidth(pFile, aucHeader);
-00180                 break;
-00181         case 4:
-00182         case 5:
-00183                 break;
-00184         case 6:
-00185         case 7:
-00186                 vSet6DefaultTabWidth(pFile, pPPS->tWordDocument.ulSB,
-00187                                 aulBBD, tBBDLen, aucHeader);
-00188                 break;
-00189         case 8:
-00190                 vSet8DefaultTabWidth(pFile, pPPS,
-00191                                 aulBBD, tBBDLen, aulSBD, tSBDLen, aucHeader);
-00192                 break;
-00193         default:
-00194                 werr(0, "Sorry, no TAB information");
-00195                 break;
-00196         }
-00197 } /* end of vSetDefaultTabWidth */
-00198 
-00199 #if 0
-00200 /*
-00201  * lGetDefaultTabWidth - Get the default tabwidth in millipoints
-00202  */
-00203 long
-00204 lGetDefaultTabWidth(void)
-00205 {
-00206         if (lDefaultTabWidth <= 0) {
-00207                 DBG_DEC(lDefaultTabWidth);
-00208                 return lTwips2MilliPoints(1);
-00209         }
-00210         return lDefaultTabWidth;
-00211 } /* end of lGetDefaultTabWidth */
-00212 #endif
-
-
Generated by  - -doxygen 1.6.2
- -