# HG changeset patch # User Dominic Pinkman # Date 1276680253 -3600 # Node ID d4524d6a4472757948c886154391fb050644b6ca # Parent 59758314f811d1082cf2766c7fc2c6e6c79f92fa removal of PIPS 'antiword' example pending a decision on its license diff -r 59758314f811 -r d4524d6a4472 Symbian3/Examples/guid-6013a680-57f9-415b-8851-c4fa63356636/_p_i_p_s_2antiword_2group_2_bld_8inf_source.html --- a/Symbian3/Examples/guid-6013a680-57f9-415b-8851-c4fa63356636/_p_i_p_s_2antiword_2group_2_bld_8inf_source.html Fri Jun 11 15:24:34 2010 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,80 +0,0 @@ - - - - -TB9.2 Example Applications: examples/PIPS/antiword/group/bld.inf Source File - - - - - -

examples/PIPS/antiword/group/bld.inf

00001 /*
-00002 * ==============================================================================
-00003 *  Name        : Bld.inf
-00004 *  Part of     : Open C / antiword
-00005 *  Interface   : 
-00006 *  Description : Word document conversion project
-00007 *  Version     : 
-00008 *
-00009 *  Copyright (c) 2005-2007 Nokia Corporation.
-00010 *  This material, including documentation and any related 
-00011 *  computer programs, is protected by copyright controlled by 
-00012 *  Nokia Corporation.
-00013 * ==============================================================================
-00014 */
-00015 PRJ_PLATFORMS
-00016 WINSCW
-00017 ARMV5
-00018 GCCE
-00019 
-00020 PRJ_MMPFILES
-00021 antiword.mmp
-00022 
-00023 
-00024 PRJ_EXPORTS
-00025 ..\data\Resources\8859-1.txt                                            \epoc32\winscw\c\private\A0001323\Resources\8859-1.txt
-00026 ..\data\Resources\8859-10.txt                                           \epoc32\winscw\c\private\A0001323\Resources\8859-10.txt
-00027 ..\data\Resources\8859-11.txt                                           \epoc32\winscw\c\private\A0001323\Resources\8859-11.txt
-00028 ..\data\Resources\8859-13.txt                                           \epoc32\winscw\c\private\A0001323\Resources\8859-13.txt
-00029 ..\data\Resources\8859-14.txt                                           \epoc32\winscw\c\private\A0001323\Resources\8859-14.txt
-00030 ..\data\Resources\8859-15.txt                                           \epoc32\winscw\c\private\A0001323\Resources\8859-15.txt
-00031 ..\data\Resources\8859-16.txt                                           \epoc32\winscw\c\private\A0001323\Resources\8859-16.txt
-00032 ..\data\Resources\8859-2.txt                                            \epoc32\winscw\c\private\A0001323\Resources\8859-2.txt
-00033 ..\data\Resources\8859-3.txt                                            \epoc32\winscw\c\private\A0001323\Resources\8859-3.txt
-00034 ..\data\Resources\8859-4.txt                                            \epoc32\winscw\c\private\A0001323\Resources\8859-4.txt
-00035 ..\data\Resources\8859-5.txt                                            \epoc32\winscw\c\private\A0001323\Resources\8859-5.txt
-00036 ..\data\Resources\8859-6.txt                                            \epoc32\winscw\c\private\A0001323\Resources\8859-6.txt
-00037 ..\data\Resources\8859-7.txt                                            \epoc32\winscw\c\private\A0001323\Resources\8859-7.txt
-00038 ..\data\Resources\8859-8.txt                                            \epoc32\winscw\c\private\A0001323\Resources\8859-8.txt
-00039 ..\data\Resources\8859-9.txt                                            \epoc32\winscw\c\private\A0001323\Resources\8859-9.txt
-00040 ..\data\Resources\cp1250.txt                                            \epoc32\winscw\c\private\A0001323\Resources\cp1250.txt
-00041 ..\data\Resources\cp1251.txt                                            \epoc32\winscw\c\private\A0001323\Resources\cp1251.txt
-00042 ..\data\Resources\cp1252.txt                                            \epoc32\winscw\c\private\A0001323\Resources\cp1252.txt
-00043 ..\data\Resources\cp437.txt                                                     \epoc32\winscw\c\private\A0001323\Resources\cp437.txt
-00044 ..\data\Resources\cp850.txt                                                     \epoc32\winscw\c\private\A0001323\Resources\cp850.txt
-00045 ..\data\Resources\cp852.txt                                                     \epoc32\winscw\c\private\A0001323\Resources\cp852.txt
-00046 ..\data\Resources\cp862.txt                                                     \epoc32\winscw\c\private\A0001323\Resources\cp862.txt
-00047 ..\data\Resources\cp864.txt                                                     \epoc32\winscw\c\private\A0001323\Resources\cp864.txt
-00048 ..\data\Resources\cp866.txt                                                     \epoc32\winscw\c\private\A0001323\Resources\cp866.txt
-00049 ..\data\Resources\Default                                                               \epoc32\winscw\c\private\A0001323\Resources\Default     
-00050 ..\data\Resources\Example                                                               \epoc32\winscw\c\private\A0001323\Resources\Example
-00051 ..\data\Resources\fontnames                                                     \epoc32\winscw\c\private\A0001323\Resources\fontnames
-00052 ..\data\Resources\fontnames.russian                     \epoc32\winscw\c\private\A0001323\Resources\fontnames.russian
-00053 ..\data\Resources\koi8-r.txt                                            \epoc32\winscw\c\private\A0001323\Resources\koi8-r.txt
-00054 ..\data\Resources\koi8-u.txt                                            \epoc32\winscw\c\private\A0001323\Resources\koi8-u.txt
-00055 ..\data\Resources\MacCyrillic.txt                               \epoc32\winscw\c\private\A0001323\Resources\MacCrillic.txt
-00056 ..\data\Resources\MacRoman.txt                                  \epoc32\winscw\c\private\A0001323\Resources\MacRoman.txt
-00057 ..\data\Resources\roman.txt                                                     \epoc32\winscw\c\private\A0001323\Resources\roman.txt   
-00058 ..\data\Resources\Unicode01                                                     \epoc32\winscw\c\private\A0001323\Resources\Unicode01
-00059 ..\data\Resources\Unicode15                                                     \epoc32\winscw\c\private\A0001323\Resources\Unicode15
-00060 ..\data\Resources\UTF-8.txt                                                     \epoc32\winscw\c\private\A0001323\Resources\UTF-8.txt
-00061 
-00062 
-00063 //sample data file
-00064 ..\data\sample.doc                                                                                      \epoc32\winscw\c\sample.doc
-
-
Generated by  - -doxygen 1.6.2
- - diff -r 59758314f811 -r d4524d6a4472 Symbian3/Examples/guid-6013a680-57f9-415b-8851-c4fa63356636/_p_i_p_s_2antiword_2sis_2backup__registration_8xml_source.html --- a/Symbian3/Examples/guid-6013a680-57f9-415b-8851-c4fa63356636/_p_i_p_s_2antiword_2sis_2backup__registration_8xml_source.html Fri Jun 11 15:24:34 2010 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,21 +0,0 @@ - - - - -TB9.2 Example Applications: examples/PIPS/antiword/sis/backup_registration.xml Source File - - - - - -

examples/PIPS/antiword/sis/backup_registration.xml

00001 <?xml version="1.0" standalone="yes"?>
-00002 <backup_registration>
-00003   <system_backup/>
-00004   <restore requires_reboot = "no"/>
-00005 </backup_registration>
-
-
Generated by  - -doxygen 1.6.2
- - diff -r 59758314f811 -r d4524d6a4472 Symbian3/Examples/guid-6013a680-57f9-415b-8851-c4fa63356636/antiword_8h_source.html --- a/Symbian3/Examples/guid-6013a680-57f9-415b-8851-c4fa63356636/antiword_8h_source.html Fri Jun 11 15:24:34 2010 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,753 +0,0 @@ - - - - -TB9.2 Example Applications: examples/PIPS/antiword/inc/antiword.h Source File - - - - - -

examples/PIPS/antiword/inc/antiword.h

00001 /*
-00002  * antiword.h
-00003  * Copyright (C) 1998-2004 A.J. van Os; Released under GNU GPL
-00004  *
-00005  * Description:
-00006  * Generic include file for project 'Antiword'
-00007  */
-00008 
-00009 #if !defined(__antiword_h)
-00010 #define __antiword_h 1
-00011 
-00012 #if defined(DEBUG) == defined(NDEBUG)
-00013 #error Exactly one of the DEBUG and NDEBUG flags MUST be set
-00014 #endif /* DEBUG == NDEBUG */
-00015 
-00016 #include <stdio.h>
-00017 #include <limits.h>
-00018 #if defined(__riscos)
-00019 #include "DeskLib:Font.h"
-00020 #include "DeskLib:Wimp.h"
-00021 #include "Desklib:Window.h"
-00022 #include "drawfile.h"
-00023 #define window_ANY      event_ANY
-00024 #define icon_ANY        event_ANY
-00025 #else
-00026 #include <sys/types.h>
-00027 #endif /* __riscos */
-00028 #include "wordconst.h"
-00029 #include "wordtypes.h"
-00030 #include "fail.h"
-00031 #include "debug.h"
-00032 
-00033 /* Constants */
-00034 #if !defined(PATH_MAX)
-00035  #if defined(__riscos)
-00036  #define PATH_MAX                255
-00037  #else
-00038   #if defined(MAXPATHLEN)
-00039   #define PATH_MAX              MAXPATHLEN
-00040   #else
-00041   #define PATH_MAX              255
-00042   #endif /* MAXPATHLEN */
-00043  #endif /* __riscos */
-00044 #endif /* !PATH_MAX */
-00045 
-00046 #if !defined(CHAR_BIT)
-00047 #define CHAR_BIT                8
-00048 #endif /* CHAR_BIT */
-00049 
-00050 #if !defined(TIME_T_MIN)
-00051 #define TIME_T_MIN              ((time_t)0 < (time_t)-1 ?\
-00052                                 (time_t)0 :\
-00053                                 (time_t)1 << (sizeof(time_t) * CHAR_BIT - 1))
-00054 #endif /* TIMER_T_MIN */
-00055 
-00056 #if !defined(TIME_T_MAX)
-00057 #if defined(__TURBOC__) /* Turbo C chokes on the subtraction below */
-00058 #define TIME_T_MAX              (LONG_MAX)
-00059 #else   /* All others */
-00060 #define TIME_T_MAX              (~(time_t)0 - TIME_T_MIN)
-00061 #endif /* __TURBOC__ */
-00062 #endif /* TIME_T_MAX */
-00063 
-00064 #if !defined(SIZE_T_MAX)
-00065 #define SIZE_T_MAX              (~(size_t)0)
-00066 #endif /* SIZE_T_MAX */
-00067 
-00068 #if defined(__riscos)
-00069 #define FILE_SEPARATOR          "."
-00070 #elif defined(__dos) || defined(__CYGMING__)
-00071 #define FILE_SEPARATOR          "\\"
-00072 #else   /* All others */
-00073 #define FILE_SEPARATOR          "/"
-00074 #endif /* __riscos */
-00075 
-00076 /* PNG chunk names */
-00077 #define PNG_CN_IDAT             0x49444154
-00078 #define PNG_CN_IEND             0x49454e44
-00079 #define PNG_CN_IHDR             0x49484452
-00080 #define PNG_CN_PLTE             0x504c5445
-00081 
-00082 /* The screen width */
-00083 #define MIN_SCREEN_WIDTH         45
-00084 #define DEFAULT_SCREEN_WIDTH     76
-00085 #define MAX_SCREEN_WIDTH        145
-00086 
-00087 #if defined(__riscos)
-00088 /* The scale factors as percentages */
-00089 #define MIN_SCALE_FACTOR         25
-00090 #define DEFAULT_SCALE_FACTOR    100
-00091 #define MAX_SCALE_FACTOR        400
-00092 
-00093 /* Filetypes */
-00094 #define FILETYPE_MSWORD         0xae6
-00095 #define FILETYPE_DRAW           0xaff
-00096 #define FILETYPE_JPEG           0xc85
-00097 #define FILETYPE_POSCRIPT       0xff5
-00098 #define FILETYPE_SPRITE         0xff9
-00099 #define FILETYPE_TEXT           0xfff
-00100 
-00101 /* The button numbers in the choices window */
-00102 #define CHOICES_DEFAULT_BUTTON           3
-00103 #define CHOICES_SAVE_BUTTON              2
-00104 #define CHOICES_CANCEL_BUTTON            1
-00105 #define CHOICES_APPLY_BUTTON             0
-00106 #define CHOICES_BREAK_BUTTON             6
-00107 #define CHOICES_BREAK_WRITEABLE          7
-00108 #define CHOICES_BREAK_UP_BUTTON          8
-00109 #define CHOICES_BREAK_DOWN_BUTTON        9
-00110 #define CHOICES_NO_BREAK_BUTTON         11
-00111 #define CHOICES_AUTOFILETYPE_BUTTON     14
-00112 #define CHOICES_HIDDEN_TEXT_BUTTON      22
-00113 #define CHOICES_WITH_IMAGES_BUTTON      17
-00114 #define CHOICES_NO_IMAGES_BUTTON        18
-00115 #define CHOICES_TEXTONLY_BUTTON         19
-00116 #define CHOICES_SCALE_WRITEABLE         25
-00117 #define CHOICES_SCALE_UP_BUTTON         26
-00118 #define CHOICES_SCALE_DOWN_BUTTON       27
-00119 
-00120 /* The button numbers in the scale view window */
-00121 #define SCALE_CANCEL_BUTTON              1
-00122 #define SCALE_SCALE_BUTTON               0
-00123 #define SCALE_SCALE_WRITEABLE            3
-00124 #define SCALE_50_PCT                     5
-00125 #define SCALE_75_PCT                     6
-00126 #define SCALE_100_PCT                    7
-00127 #define SCALE_150_PCT                    8
-00128 
-00129 /* Save menu fields */
-00130 #define SAVEMENU_SCALEVIEW              0
-00131 #define SAVEMENU_SAVEDRAW               1
-00132 #define SAVEMENU_SAVETEXT               2
-00133 #else
-00134 /* Margins for the PostScript version */
-00135 #define PS_LEFT_MARGIN                  (72 * 640L)
-00136 #define PS_RIGHT_MARGIN                 (48 * 640L)
-00137 #define PS_TOP_MARGIN                   (72 * 640L)
-00138 #define PS_BOTTOM_MARGIN                (72 * 640L)
-00139 #endif /* __riscos */
-00140 
-00141 /* Macros */
-00142 #define STREQ(x,y)      (*(x) == *(y) && strcmp(x,y) == 0)
-00143 #define STRNEQ(x,y,n)   (*(x) == *(y) && strncmp(x,y,n) == 0)
-00144 #if defined(__dos) || defined(__EMX__)
-00145 #define STRCEQ(x,y)     (stricmp(x,y) == 0)
-00146 #else
-00147 #define STRCEQ(x,y)     (strcasecmp(x,y) == 0)
-00148 #endif /* __dos or __EMX__ */
-00149 #define elementsof(a)   (sizeof(a) / sizeof(a[0]))
-00150 #define odd(x)          (((x)&0x01)!=0)
-00151 #define ROUND4(x)       (((x)+3)&~0x03)
-00152 #define ROUND128(x)     (((x)+127)&~0x7f)
-00153 #define BIT(x)          (1UL << (x))
-00154 #if !defined(max)
-00155 #define max(x,y)        ((x)>(y)?(x):(y))
-00156 #endif /* !max */
-00157 #if !defined(min)
-00158 #define min(x,y)        ((x)<(y)?(x):(y))
-00159 #endif /* !min */
-00160 
-00161 #if defined(__riscos)
-00162 /* The name of the table font */
-00163 #define TABLE_FONT                      "Corpus.Medium"
-00164 /* Names of the default fonts */
-00165 #define FONT_MONOSPACED_PLAIN           "Corpus.Medium"
-00166 #define FONT_MONOSPACED_BOLD            "Corpus.Bold"
-00167 #define FONT_MONOSPACED_ITALIC          "Corpus.Medium.Oblique"
-00168 #define FONT_MONOSPACED_BOLDITALIC      "Corpus.Bold.Oblique"
-00169 #define FONT_SERIF_PLAIN                "Trinity.Medium"
-00170 #define FONT_SERIF_BOLD                 "Trinity.Bold"
-00171 #define FONT_SERIF_ITALIC               "Trinity.Medium.Italic"
-00172 #define FONT_SERIF_BOLDITALIC           "Trinity.Bold.Italic"
-00173 #define FONT_SANS_SERIF_PLAIN           "Homerton.Medium"
-00174 #define FONT_SANS_SERIF_BOLD            "Homerton.Bold"
-00175 #define FONT_SANS_SERIF_ITALIC          "Homerton.Medium.Oblique"
-00176 #define FONT_SANS_SERIF_BOLDITALIC      "Homerton.Bold.Oblique"
-00177 #else
-00178 /* The name of the table font */
-00179 #define TABLE_FONT                      "Courier"
-00180 /* Names of the default fonts */
-00181 #define FONT_MONOSPACED_PLAIN           "Courier"
-00182 #define FONT_MONOSPACED_BOLD            "Courier-Bold"
-00183 #define FONT_MONOSPACED_ITALIC          "Courier-Oblique"
-00184 #define FONT_MONOSPACED_BOLDITALIC      "Courier-BoldOblique"
-00185 #define FONT_SERIF_PLAIN                "Times-Roman"
-00186 #define FONT_SERIF_BOLD                 "Times-Bold"
-00187 #define FONT_SERIF_ITALIC               "Times-Italic"
-00188 #define FONT_SERIF_BOLDITALIC           "Times-BoldItalic"
-00189 #define FONT_SANS_SERIF_PLAIN           "Helvetica"
-00190 #define FONT_SANS_SERIF_BOLD            "Helvetica-Bold"
-00191 #define FONT_SANS_SERIF_ITALIC          "Helvetica-Oblique"
-00192 #define FONT_SANS_SERIF_BOLDITALIC      "Helvetica-BoldOblique"
-00193 /* The name of the antiword directories and the font information file */
-00194 #if defined(__dos)
-00195 #define GLOBAL_ANTIWORD_DIR     "C:\\antiword"
-00196 #define ANTIWORD_DIR            "antiword"
-00197 #define FONTNAMES_FILE          "fontname.txt"
-00198 #elif defined(__amigaos)
-00199 #define GLOBAL_ANTIWORD_DIR     "SYS:.antiword"
-00200 #define ANTIWORD_DIR            ".antiword"
-00201 #define FONTNAMES_FILE          "fontnames"
-00202 #elif defined(N_PLAT_NLM)
-00203 #define GLOBAL_ANTIWORD_DIR     "SYS:/antiword"
-00204 #define ANTIWORD_DIR            "antiword"
-00205 #define FONTNAMES_FILE          "fontname.txt"
-00206 #elif defined(__vms)
-00207 #define GLOBAL_ANTIWORD_DIR     "/usr/share/antiword"
-00208 #define ANTIWORD_DIR            "antiword"
-00209 #define FONTNAMES_FILE          "fontnames"
-00210 #elif defined(__BEOS__)
-00211 #define GLOBAL_ANTIWORD_DIR     "/boot/home/config/apps/antiword"
-00212 #define ANTIWORD_DIR            "antiword"
-00213 #define FONTNAMES_FILE          "fontnames"
-00214 #elif defined(__CYGMING__)
-00215 #define GLOBAL_ANTIWORD_DIR     "C:\\antiword"
-00216 #define ANTIWORD_DIR            "antiword"
-00217 #define FONTNAMES_FILE          "fontnames"
-00218 #elif defined(__Plan9__)
-00219 #define GLOBAL_ANTIWORD_DIR     "/sys/lib/antiword"
-00220 #define ANTIWORD_DIR            "lib/antiword"
-00221 #define FONTNAMES_FILE          "fontnames"
-00222 #elif defined(__sun__)
-00223 #define GLOBAL_ANTIWORD_DIR     "/usr/local/share/antiword"
-00224 #define ANTIWORD_DIR
-00225 #define FONTNAMES_FILE          "fontnames"
-00226 #else   /* All others */
-00227 #define GLOBAL_ANTIWORD_DIR     "/usr/share/antiword"
-00228 #define ANTIWORD_DIR            ".antiword"
-00229 #define FONTNAMES_FILE          "fontnames"
-00230 #endif /* __dos */
-00231 /* The names of grouped mapping files */
-00232         /* ASCII */
-00233 #define MAPPING_FILE_CP437      "cp437.txt"
-00234         /* Latin1 */
-00235 #define MAPPING_FILE_8859_1     "8859-1.txt"
-00236         /* Latin2 */
-00237 #define MAPPING_FILE_8859_2     "8859-2.txt"
-00238 #define MAPPING_FILE_CP852      "cp852.txt"
-00239 #define MAPPING_FILE_CP1250     "cp1250.txt"
-00240         /* Cyrillic */
-00241 #define MAPPING_FILE_8859_5     "8859-5.txt"
-00242 #define MAPPING_FILE_KOI8_R     "koi8-r.txt"
-00243 #define MAPPING_FILE_KOI8_U     "koi8-u.txt"
-00244 #define MAPPING_FILE_CP866      "cp866.txt"
-00245 #define MAPPING_FILE_CP1251     "cp1251.txt"
-00246         /* Latin9 */
-00247 #define MAPPING_FILE_8859_15    "8859-15.txt"
-00248         /* UTF-8 */
-00249 #define MAPPING_FILE_UTF_8      "UTF-8.txt"
-00250 #endif /* __riscos */
-00251 
-00252 /* Prototypes */
-00253 
-00254 /* asc85enc.c */
-00255 extern void     vASCII85EncodeByte(FILE *, int);
-00256 extern void     vASCII85EncodeArray(FILE *, FILE *, size_t);
-00257 extern void     vASCII85EncodeFile(FILE *, FILE *, size_t);
-00258 /* blocklist.c */
-00259 extern void     vDestroyTextBlockList(void);
-00260 extern BOOL     bAdd2TextBlockList(const text_block_type *);
-00261 extern void     vSplitBlockList(FILE *, ULONG, ULONG, ULONG, ULONG, ULONG,
-00262                         ULONG, ULONG, ULONG, BOOL);
-00263 extern BOOL     bExistsHdrFtr(void);
-00264 extern BOOL     bExistsTextBox(void);
-00265 extern BOOL     bExistsHdrTextBox(void);
-00266 extern USHORT   usNextChar(FILE *, list_id_enum, ULONG *, ULONG *, USHORT *);
-00267 extern USHORT   usToHdrFtrPosition(FILE *, ULONG);
-00268 extern USHORT   usToFootnotePosition(FILE *, ULONG);
-00269 extern ULONG    ulCharPos2FileOffsetX(ULONG, list_id_enum *);
-00270 extern ULONG    ulCharPos2FileOffset(ULONG);
-00271 extern ULONG    ulHdrFtrOffset2CharPos(ULONG);
-00272 extern ULONG    ulGetSeqNumber(ULONG);
-00273 #if defined(__riscos)
-00274 extern ULONG    ulGetDocumentLength(void);
-00275 #endif /* __riscos */
-00276 /* chartrans.c */
-00277 extern UCHAR    ucGetBulletCharacter(conversion_type, encoding_type);
-00278 extern UCHAR    ucGetNbspCharacter(void);
-00279 extern BOOL     bReadCharacterMappingTable(FILE *);
-00280 extern ULONG    ulTranslateCharacters(USHORT, ULONG, int, conversion_type,
-00281                         encoding_type, BOOL);
-00282 extern ULONG    ulToUpper(ULONG);
-00283 /* datalist.c */
-00284 extern void     vDestroyDataBlockList(void);
-00285 extern BOOL     bAdd2DataBlockList(const data_block_type *);
-00286 extern ULONG    ulGetDataOffset(FILE *);
-00287 extern BOOL     bSetDataOffset(FILE *, ULONG);
-00288 extern int      iNextByte(FILE *);
-00289 extern USHORT   usNextWord(FILE *);
-00290 extern ULONG    ulNextLong(FILE *);
-00291 extern USHORT   usNextWordBE(FILE *);
-00292 extern ULONG    ulNextLongBE(FILE *);
-00293 extern size_t   tSkipBytes(FILE *, size_t);
-00294 extern ULONG    ulDataPos2FileOffset(ULONG);
-00295 /* depot.c */
-00296 extern void     vDestroySmallBlockList(void);
-00297 extern BOOL     bCreateSmallBlockList(ULONG, const ULONG *, size_t);
-00298 extern ULONG    ulDepotOffset(ULONG, size_t);
-00299 /* dib2eps & dib2sprt.c */
-00300 extern BOOL     bTranslateDIB(diagram_type *,
-00301                         FILE *, ULONG, const imagedata_type *);
-00302 #if defined(__dos)
-00303 /* dos.c */
-00304 extern int      iGetCodepage(void);
-00305 #endif /* __dos */
-00306 /* doclist.c */
-00307 extern void     vDestroyDocumentInfoList(void);
-00308 extern void     vCreateDocumentInfoList(const document_block_type *);
-00309 extern UCHAR    ucGetDopHdrFtrSpecification(void);
-00310 /* draw.c & output.c */
-00311 extern BOOL     bAddDummyImage(diagram_type *, const imagedata_type *);
-00312 extern diagram_type *pCreateDiagram(const char *, const char *, FILE *);
-00313 extern void     vPrologue2(diagram_type *, int);
-00314 extern void     vMove2NextLine(diagram_type *, drawfile_fontref, USHORT);
-00315 extern void     vSubstring2Diagram(diagram_type *,
-00316                         char *, size_t, long, UCHAR, USHORT,
-00317                         drawfile_fontref, USHORT, USHORT);
-00318 extern void     vStartOfParagraph1(diagram_type *, long);
-00319 extern void     vStartOfParagraph2(diagram_type *);
-00320 extern void     vEndOfParagraph(diagram_type *, drawfile_fontref, USHORT, long);
-00321 extern void     vEndOfPage(diagram_type *, long, BOOL);
-00322 extern void     vSetHeaders(diagram_type *, USHORT);
-00323 extern void     vStartOfList(diagram_type *, UCHAR, BOOL);
-00324 extern void     vEndOfList(diagram_type *);
-00325 extern void     vStartOfListItem(diagram_type *, BOOL);
-00326 extern void     vEndOfTable(diagram_type *);
-00327 extern BOOL     bAddTableRow(diagram_type *, char **, int,
-00328                         const short *, UCHAR);
-00329 #if defined(__riscos)
-00330 extern BOOL     bDestroyDiagram(event_pollblock *, void *);
-00331 #if 0
-00332 extern void     vImage2Diagram(diagram_type *, const imagedata_type *,
-00333                         UCHAR *, size_t);
-00334 #endif //0      
-00335 extern BOOL     bVerifyDiagram(diagram_type *);
-00336 extern void     vShowDiagram(diagram_type *);
-00337 extern void     vMainButtonClick(mouse_block *);
-00338 extern BOOL     bMainKeyPressed(event_pollblock *, void *);
-00339 extern BOOL     bMainEventHandler(event_pollblock *, void *);
-00340 extern BOOL     bRedrawMainWindow(event_pollblock *, void *);
-00341 extern BOOL     bScaleOpenAction(event_pollblock *, void *);
-00342 extern void     vSetTitle(diagram_type *);
-00343 extern void     vScaleButtonClick(mouse_block *, diagram_type *);
-00344 extern BOOL     bScaleKeyPressed(event_pollblock *, void *);
-00345 extern BOOL     bScaleEventHandler(event_pollblock *, void *);
-00346 #else
-00347 extern void     vImagePrologue(diagram_type *, const imagedata_type *);
-00348 extern void     vImageEpilogue(diagram_type *);
-00349 extern void     vDestroyDiagram(diagram_type *);
-00350 #endif /* __riscos */
-00351 /* finddata.c */
-00352 extern BOOL     bAddDataBlocks(ULONG , ULONG, ULONG, const ULONG *, size_t);
-00353 extern BOOL     bGet6DocumentData(FILE *, ULONG,
-00354                                 const ULONG *, size_t, const UCHAR *);
-00355 /* findtext.c */
-00356 extern BOOL     bAddTextBlocks(ULONG , ULONG, BOOL,
-00357                                 USHORT, ULONG, const ULONG *, size_t);
-00358 extern BOOL     bGet6DocumentText(FILE *, BOOL, ULONG,
-00359                                 const ULONG *, size_t, const UCHAR *);
-00360 extern BOOL     bGet8DocumentText(FILE *, const pps_info_type *,
-00361                                 const ULONG *, size_t, const ULONG *, size_t,
-00362                                 const UCHAR *);
-00363 /* fmt_text.c */
-00364 extern void     vPrologueFMT(diagram_type *, const options_type *);
-00365 extern void     vSubstringFMT(diagram_type *, const char *, size_t, long,
-00366                                 USHORT);
-00367 /* fontlist.c */
-00368 extern void     vDestroyFontInfoList(void);
-00369 extern void     vCorrectFontValues(font_block_type *);
-00370 extern void     vAdd2FontInfoList(const font_block_type *);
-00371 extern const font_block_type    *pGetNextFontInfoListItem(
-00372                                         const font_block_type *);
-00373 /* fonts.c */
-00374 extern int      iGetFontByNumber(UCHAR, USHORT);
-00375 extern const char       *szGetOurFontname(int);
-00376 extern int      iFontname2Fontnumber(const char *, USHORT);
-00377 extern void     vCreate0FontTable(void);
-00378 extern void     vCreate2FontTable(FILE *, int, const UCHAR *);
-00379 extern void     vCreate6FontTable(FILE *, ULONG,
-00380                         const ULONG *, size_t, const UCHAR *);
-00381 extern void     vCreate8FontTable(FILE *, const pps_info_type *,
-00382                         const ULONG *, size_t, const ULONG *, size_t,
-00383                         const UCHAR *);
-00384 extern void     vDestroyFontTable(void);
-00385 extern const font_table_type    *pGetNextFontTableRecord(
-00386                                                 const font_table_type *);
-00387 extern size_t   tGetFontTableLength(void);
-00388 extern void     vCorrectFontTable(conversion_type, encoding_type);
-00389 extern long     lComputeSpaceWidth(drawfile_fontref, USHORT);
-00390 /* fonts_r.c & fonts_u.c */
-00391 extern FILE     *pOpenFontTableFile(void);
-00392 extern void     vCloseFont(void);
-00393 extern drawfile_fontref tOpenFont(UCHAR, USHORT, USHORT);
-00394 extern drawfile_fontref tOpenTableFont(USHORT);
-00395 extern long     lComputeStringWidth(const char *, size_t, drawfile_fontref, USHORT);
-00396 extern size_t   tCountColumns(const char *, size_t);
-00397 extern size_t   tGetCharacterLength(const char *);
-00398 /* fonts_u.c */
-00399 #if !defined(__riscos)
-00400 extern const char       *szGetFontname(drawfile_fontref);
-00401 #endif /* !__riscos */
-00402 /* hdrftrlist.c */
-00403 extern void     vDestroyHdrFtrInfoList(void);
-00404 extern void     vCreat8HdrFtrInfoList(const ULONG *, size_t);
-00405 extern void     vCreat6HdrFtrInfoList(const ULONG *, size_t);
-00406 extern void     vCreat2HdrFtrInfoList(const ULONG *, size_t);
-00407 extern const hdrftr_block_type *pGetHdrFtrInfo(int, BOOL, BOOL, BOOL);
-00408 extern void     vPrepareHdrFtrText(FILE *);
-00409 #if defined(__riscos)
-00410 /* icons.c */
-00411 extern void     vUpdateIcon(window_handle, icon_block *);
-00412 extern void     vUpdateRadioButton(window_handle, icon_handle, BOOL);
-00413 extern void     vUpdateWriteable(window_handle, icon_handle, const char *);
-00414 extern void     vUpdateWriteableNumber(window_handle, icon_handle, int);
-00415 #endif /* __riscos */
-00416 /* imgexam.c */
-00417 extern image_info_enum  eExamineImage(FILE *, ULONG, imagedata_type *);
-00418 /* imgtrans */
-00419 extern BOOL     bTranslateImage(diagram_type *,
-00420                         FILE *, BOOL, ULONG, const imagedata_type *);
-00421 /* jpeg2eps.c & jpeg2spr.c */
-00422 extern BOOL     bTranslateJPEG(diagram_type *,
-00423                         FILE *, ULONG, size_t, const imagedata_type *);
-00424 /* listlist.c */
-00425 extern void     vDestroyListInfoList(void);
-00426 extern void     vBuildLfoList(const UCHAR *, size_t);
-00427 extern void     vAdd2ListInfoList(ULONG, USHORT, UCHAR,
-00428                         const list_block_type *);
-00429 extern const list_block_type    *pGetListInfo(USHORT, UCHAR);
-00430 extern USHORT   usGetListValue(int, int, const style_block_type *);
-00431 /* misc.c */
-00432 #if !defined(__riscos)
-00433 extern const char       *szGetHomeDirectory(void);
-00434 extern const char       *szGetAntiwordDirectory(void);
-00435 #endif /* !__riscos */
-00436 extern long     lGetFilesize(const char *);
-00437 #if defined(DEBUG)
-00438 extern void     vPrintBlock(const char *, int, const UCHAR *, size_t);
-00439 extern void     vPrintUnicode(const char *, int, const UCHAR *, size_t);
-00440 extern BOOL     bCheckDoubleLinkedList(output_type *);
-00441 #endif /* DEBUG */
-00442 extern BOOL     bReadBytes(UCHAR *, size_t, ULONG, FILE *);
-00443 extern BOOL     bReadBuffer(FILE *, ULONG, const ULONG *, size_t, size_t,
-00444                         UCHAR *, ULONG, size_t);
-00445 extern ULONG    ulColor2Color(UCHAR);
-00446 extern output_type *pSplitList(output_type *);
-00447 extern size_t   tNumber2Roman(UINT, BOOL, char *);
-00448 extern size_t   tNumber2Alpha(UINT, BOOL, char *);
-00449 extern char     *unincpy(char *, const UCHAR *, size_t);
-00450 extern size_t   unilen(const UCHAR *);
-00451 extern const char       *szBasename(const char *);
-00452 extern long     lComputeLeading(USHORT);
-00453 extern size_t   tUcs2Utf8(ULONG, char *, size_t);
-00454 extern void     vGetBulletValue(conversion_type, encoding_type, char *, size_t);
-00455 extern BOOL     bAllZero(const UCHAR *, size_t);
-00456 extern BOOL     bGetNormalizedCodeset(char *, size_t, BOOL *);
-00457 extern const char       *szGetDefaultMappingFile(void);
-00458 extern time_t   tConvertDTTM(ULONG);
-00459 /* notes.c */
-00460 extern void     vDestroyNotesInfoLists(void);
-00461 extern void     vGetNotesInfo(FILE *, const pps_info_type *,
-00462                         const ULONG *, size_t, const ULONG *, size_t,
-00463                         const UCHAR *, int);
-00464 extern void     vPrepareFootnoteText(FILE *);
-00465 extern const char       *szGetFootnootText(UINT);
-00466 extern notetype_enum eGetNotetype(ULONG);
-00467 /* options.c */
-00468 extern int      iReadOptions(int, char **);
-00469 extern void     vGetOptions(options_type *);
-00470 #if defined(__riscos)
-00471 extern void     vChoicesOpenAction(window_handle);
-00472 extern BOOL     bChoicesMouseClick(event_pollblock *, void *);
-00473 extern BOOL     bChoicesKeyPressed(event_pollblock *, void *);
-00474 #endif /* __riscos */
-00475 /* out2window.c */
-00476 extern void     vSetLeftIndentation(diagram_type *, long);
-00477 extern void     vAlign2Window(diagram_type *, output_type *,
-00478                         long, UCHAR);
-00479 extern void     vJustify2Window(diagram_type *, output_type *,
-00480                         long, long, UCHAR);
-00481 extern void     vResetStyles(void);
-00482 extern size_t   tStyle2Window(char *, size_t, const style_block_type *,
-00483                         const section_block_type *);
-00484 extern void     vTableRow2Window(diagram_type *, output_type *,
-00485                         const row_block_type *, conversion_type, int);
-00486 /* pdf.c */
-00487 extern void     vCreateInfoDictionary(diagram_type *, int);
-00488 extern void     vProloguePDF(diagram_type *,
-00489                         const char *, const options_type *);
-00490 extern void     vEpiloguePDF(diagram_type *);
-00491 extern void     vImageProloguePDF(diagram_type *, const imagedata_type *);
-00492 extern void     vImageEpiloguePDF(diagram_type *);
-00493 extern BOOL     bAddDummyImagePDF(diagram_type *, const imagedata_type *);
-00494 extern void     vAddFontsPDF(diagram_type *);
-00495 extern void     vMove2NextLinePDF(diagram_type *, USHORT);
-00496 extern void     vSubstringPDF(diagram_type *,
-00497                                 char *, size_t, long, UCHAR, USHORT,
-00498                                 drawfile_fontref, USHORT, USHORT);
-00499 extern void     vStartOfParagraphPDF(diagram_type *, long);
-00500 extern void     vEndOfParagraphPDF(diagram_type *, USHORT, long);
-00501 extern void     vEndOfPagePDF(diagram_type *, BOOL);
-00502 /* pictlist.c */
-00503 extern void     vDestroyPictInfoList(void);
-00504 extern void     vAdd2PictInfoList(const picture_block_type *);
-00505 extern ULONG    ulGetPictInfoListItem(ULONG);
-00506 /* png2eps.c & png2spr.c */
-00507 extern BOOL     bTranslatePNG(diagram_type *,
-00508                         FILE *, ULONG, size_t, const imagedata_type *);
-00509 /* postscript.c */
-00510 extern void     vProloguePS(diagram_type *,
-00511                         const char *, const char *, const options_type *);
-00512 extern void     vEpiloguePS(diagram_type *);
-00513 extern void     vImageProloguePS(diagram_type *, const imagedata_type *);
-00514 extern void     vImageEpiloguePS(diagram_type *);
-00515 extern BOOL     bAddDummyImagePS(diagram_type *, const imagedata_type *);
-00516 extern void     vAddFontsPS(diagram_type *);
-00517 extern void     vMove2NextLinePS(diagram_type *, USHORT);
-00518 extern void     vSubstringPS(diagram_type *,
-00519                                 char *, size_t, long, UCHAR, USHORT,
-00520                                 drawfile_fontref, USHORT, USHORT);
-00521 extern void     vStartOfParagraphPS(diagram_type *, long);
-00522 extern void     vEndOfParagraphPS(diagram_type *, USHORT, long);
-00523 extern void     vEndOfPagePS(diagram_type *, BOOL);
-00524 /* prop0.c */
-00525 extern void     vGet0DopInfo(FILE *, const UCHAR *);
-00526 extern void     vGet0SepInfo(FILE *, const UCHAR *);
-00527 extern void     vGet0PapInfo(FILE *, const UCHAR *);
-00528 extern void     vGet0ChrInfo(FILE *, const UCHAR *);
-00529 /* prop2.c */
-00530 extern void     vGet2DopInfo(FILE *, const UCHAR *);
-00531 extern void     vGet2SepInfo(FILE *, const UCHAR *);
-00532 extern void     vGet2HdrFtrInfo(FILE *, const UCHAR *);
-00533 extern row_info_enum    eGet2RowInfo(int,
-00534                         const UCHAR *, int, row_block_type *);
-00535 extern void     vGet2StyleInfo(int,
-00536                         const UCHAR *, int, style_block_type *);
-00537 extern void     vGet2PapInfo(FILE *, const UCHAR *);
-00538 extern void     vGet1FontInfo(int,
-00539                         const UCHAR *, size_t, font_block_type *);
-00540 extern void     vGet2FontInfo(int,
-00541                         const UCHAR *, size_t, font_block_type *);
-00542 extern void     vGet2ChrInfo(FILE *, int, const UCHAR *);
-00543 /* prop6.c */
-00544 extern void     vGet6DopInfo(FILE *, ULONG, const ULONG *, size_t,
-00545                         const UCHAR *);
-00546 extern void     vGet6SepInfo(FILE *, ULONG, const ULONG *, size_t,
-00547                         const UCHAR *);
-00548 extern void     vGet6HdrFtrInfo(FILE *, ULONG, const ULONG *, size_t,
-00549                         const UCHAR *);
-00550 extern row_info_enum    eGet6RowInfo(int,
-00551                         const UCHAR *, int, row_block_type *);
-00552 extern void     vGet6StyleInfo(int,
-00553                         const UCHAR *, int, style_block_type *);
-00554 extern void     vGet6PapInfo(FILE *, ULONG, const ULONG *, size_t,
-00555                         const UCHAR *);
-00556 extern void     vGet6FontInfo(int, USHORT,
-00557                         const UCHAR *, int, font_block_type *);
-00558 extern void     vGet6ChrInfo(FILE *, ULONG, const ULONG *, size_t,
-00559                         const UCHAR *);
-00560 /* prop8.c */
-00561 extern void     vGet8DopInfo(FILE *, const pps_type *,
-00562                         const ULONG *, size_t, const ULONG *, size_t,
-00563                         const UCHAR *);
-00564 extern void     vGet8SepInfo(FILE *, const pps_info_type *,
-00565                         const ULONG *, size_t, const ULONG *, size_t,
-00566                         const UCHAR *);
-00567 extern void     vGet8HdrFtrInfo(FILE *, const pps_type *,
-00568                         const ULONG *, size_t, const ULONG *, size_t,
-00569                         const UCHAR *);
-00570 extern row_info_enum    eGet8RowInfo(int,
-00571                         const UCHAR *, int, row_block_type *);
-00572 extern void     vGet8StyleInfo(int,
-00573                         const UCHAR *, int, style_block_type *);
-00574 extern void     vGet8LstInfo(FILE *, const pps_info_type *,
-00575                         const ULONG *, size_t, const ULONG *, size_t,
-00576                         const UCHAR *);
-00577 extern void     vGet8PapInfo(FILE *, const pps_info_type *,
-00578                         const ULONG *, size_t, const ULONG *, size_t,
-00579                         const UCHAR *);
-00580 extern void     vGet8FontInfo(int, USHORT,
-00581                         const UCHAR *, int, font_block_type *);
-00582 extern void     vGet8ChrInfo(FILE *, const pps_info_type *,
-00583                         const ULONG *, size_t, const ULONG *, size_t,
-00584                         const UCHAR *);
-00585 /* properties.c */
-00586 extern void     vGetPropertyInfo(FILE *, const pps_info_type *,
-00587                         const ULONG *, size_t, const ULONG *, size_t,
-00588                         const UCHAR *, int);
-00589 extern row_info_enum    ePropMod2RowInfo(USHORT, int);
-00590 /* propmod.c */
-00591 extern void     vDestroyPropModList(void);
-00592 extern void     vAdd2PropModList(const UCHAR *);
-00593 extern const UCHAR      *aucReadPropModListItem(USHORT);
-00594 /* rowlist.c */
-00595 extern void     vDestroyRowInfoList(void);
-00596 extern void     vAdd2RowInfoList(const row_block_type *);
-00597 extern const row_block_type     *pGetNextRowInfoListItem(void);
-00598 /* riscos.c */
-00599 #if defined(__riscos)
-00600 extern int      iGetFiletype(const char *);
-00601 extern void     vSetFiletype(const char *, int);
-00602 extern BOOL     bMakeDirectory(const char *);
-00603 extern int      iReadCurrentAlphabetNumber(void);
-00604 extern int      iGetRiscOsVersion(void);
-00605 extern BOOL     bDrawRenderDiag360(void *, size_t,
-00606                         window_redrawblock *, double, os_error *);
-00607 #if defined(DEBUG)
-00608 extern BOOL     bGetJpegInfo(UCHAR *, size_t);
-00609 #endif /* DEBUG */
-00610 #endif /* __riscos */
-00611 /* saveas.c */
-00612 #if defined(__riscos)
-00613 extern BOOL     bSaveTextfile(event_pollblock *, void *);
-00614 extern BOOL     bSaveDrawfile(event_pollblock *, void *);
-00615 #endif /* __riscos */
-00616 /* sectlist.c */
-00617 extern void     vDestroySectionInfoList(void);
-00618 extern void     vAdd2SectionInfoList(const section_block_type *, ULONG);
-00619 extern void     vGetDefaultSection(section_block_type *);
-00620 extern void     vDefault2SectionInfoList(ULONG);
-00621 extern const section_block_type *
-00622                 pGetSectionInfo(const section_block_type *, ULONG);
-00623 extern size_t   tGetNumberOfSections(void);
-00624 extern UCHAR    ucGetSepHdrFtrSpecification(size_t);
-00625 /* stylelist.c */
-00626 extern void     vDestroyStyleInfoList(void);
-00627 extern level_type_enum  eGetNumType(UCHAR);
-00628 extern void     vCorrectStyleValues(style_block_type *);
-00629 extern void     vAdd2StyleInfoList(const style_block_type *);
-00630 extern const style_block_type   *pGetNextStyleInfoListItem(
-00631                                         const style_block_type *);
-00632 extern const style_block_type   *pGetNextTextStyle(const style_block_type *);
-00633 extern USHORT   usGetIstd(ULONG);
-00634 extern BOOL     bStyleImpliesList(const style_block_type *, int);
-00635 /* stylesheet.c */
-00636 extern void     vDestroyStylesheetList(void);
-00637 extern USHORT   usStc2istd(UCHAR);
-00638 extern void     vGet2Stylesheet(FILE *, int, const UCHAR *);
-00639 extern void     vGet6Stylesheet(FILE *, ULONG, const ULONG *, size_t,
-00640                         const UCHAR *);
-00641 extern void     vGet8Stylesheet(FILE *, const pps_info_type *,
-00642                         const ULONG *, size_t, const ULONG *, size_t,
-00643                         const UCHAR *);
-00644 extern void     vFillStyleFromStylesheet(USHORT, style_block_type *);
-00645 extern void     vFillFontFromStylesheet(USHORT, font_block_type *);
-00646 /* summary.c */
-00647 extern void     vDestroySummaryInfo(void);
-00648 extern void     vSet0SummaryInfo(FILE *, const UCHAR *);
-00649 extern void     vSet2SummaryInfo(FILE *, int, const UCHAR *);
-00650 extern void     vSet6SummaryInfo(FILE *, const pps_info_type *,
-00651                         const ULONG *, size_t, const ULONG *, size_t,
-00652                         const UCHAR *);
-00653 extern void     vSet8SummaryInfo(FILE *, const pps_info_type *,
-00654                         const ULONG *, size_t, const ULONG *, size_t,
-00655                         const UCHAR *);
-00656 extern const char       *szGetTitle(void);
-00657 extern const char       *szGetSubject(void);
-00658 extern const char       *szGetAuthor(void);
-00659 extern const char       *szGetLastSaveDtm(void);
-00660 extern const char       *szGetModDate(void);
-00661 extern const char       *szGetCreationDate(void);
-00662 extern const char       *szGetCompany(void);
-00663 extern const char       *szGetLanguage(void);
-00664 /* tabstop.c */
-00665 extern void     vSetDefaultTabWidth(FILE *, const pps_info_type *,
-00666                         const ULONG *, size_t, const ULONG *, size_t,
-00667                         const UCHAR *, int);
-00668 extern long     lGetDefaultTabWidth(void);
-00669 /* text.c */
-00670 extern void     vPrologueTXT(diagram_type *, const options_type *);
-00671 extern void     vEpilogueTXT(FILE *);
-00672 extern void     vMove2NextLineTXT(diagram_type *);
-00673 extern void     vSubstringTXT(diagram_type *, const char *, size_t, long);
-00674 extern void     vStartOfParagraphTXT(diagram_type *, long);
-00675 extern void     vEndOfParagraphTXT(diagram_type *, long);
-00676 extern void     vEndOfPageTXT(diagram_type *, long);
-00677 /* unix.c */
-00678 extern void     werr(int, const char *, ...);
-00679 #if !defined(__riscos)
-00680 extern void     Hourglass_On(void);
-00681 extern void     Hourglass_Off(void);
-00682 #endif /* !__riscos */
-00683 /* utf8.c */
-00684 #if !defined(__riscos)
-00685 extern long     utf8_strwidth(const char *, size_t);
-00686 extern int      utf8_chrlength(const char *);
-00687 extern BOOL     is_locale_utf8(void);
-00688 #endif /* !__riscos */
-00689 /* word2text.c */
-00690 extern BOOL     bOutputContainsText(const output_type *);
-00691 extern BOOL     bWordDecryptor(FILE *, long, diagram_type *);
-00692 extern output_type      *pHdrFtrDecryptor(FILE *, ULONG, ULONG);
-00693 extern char             *szFootnoteDecryptor(FILE *, ULONG, ULONG);
-00694 /* worddos.c */
-00695 extern int      iInitDocumentDOS(FILE *, long);
-00696 /* wordlib.c */
-00697 extern BOOL     bIsWordForDosFile(FILE *, long);
-00698 extern BOOL     bIsRtfFile(FILE *);
-00699 extern BOOL     bIsWordPerfectFile(FILE *);
-00700 extern BOOL     bIsWinWord12File(FILE *, long);
-00701 extern BOOL     bIsMacWord45File(FILE *);
-00702 extern int      iGuessVersionNumber(FILE *, long);
-00703 extern int      iGetVersionNumber(const UCHAR *);
-00704 extern BOOL     bIsOldMacFile(void);
-00705 extern int      iInitDocument(FILE *, long);
-00706 extern void     vFreeDocument(void);
-00707 /* wordmac.c */
-00708 extern int      iInitDocumentMAC(FILE *, long);
-00709 /* wordole.c */
-00710 extern int      iInitDocumentOLE(FILE *, long);
-00711 /* wordwin.c */
-00712 extern int      iInitDocumentWIN(FILE *, long);
-00713 /* xmalloc.c */
-00714 extern void     *xmalloc(size_t);
-00715 extern void     *xcalloc(size_t, size_t);
-00716 extern void     *xrealloc(void *, size_t);
-00717 extern char     *xstrdup(const char *);
-00718 extern void     *xfree(void *);
-00719 /* xml.c */
-00720 extern void     vCreateBookIntro(diagram_type *, int);
-00721 extern void     vPrologueXML(diagram_type *, const options_type *);
-00722 extern void     vEpilogueXML(diagram_type *);
-00723 extern void     vMove2NextLineXML(diagram_type *);
-00724 extern void     vSubstringXML(diagram_type *,
-00725                                 const char *, size_t, long, USHORT);
-00726 extern void     vStartOfParagraphXML(diagram_type *, UINT);
-00727 extern void     vEndOfParagraphXML(diagram_type *, UINT);
-00728 extern void     vEndOfPageXML(diagram_type *);
-00729 extern void     vSetHeadersXML(diagram_type *, USHORT);
-00730 extern void     vStartOfListXML(diagram_type *, UCHAR, BOOL);
-00731 extern void     vEndOfListXML(diagram_type *);
-00732 extern void     vStartOfListItemXML(diagram_type *, BOOL);
-00733 extern void     vEndOfTableXML(diagram_type *);
-00734 extern void     vAddTableRowXML(diagram_type *, char **, int,
-00735                         const short *, UCHAR);
-00736 
-00737 #endif /* __antiword_h */
-
-
Generated by  - -doxygen 1.6.2
- - diff -r 59758314f811 -r d4524d6a4472 Symbian3/Examples/guid-6013a680-57f9-415b-8851-c4fa63356636/antiword_8mmp_source.html --- a/Symbian3/Examples/guid-6013a680-57f9-415b-8851-c4fa63356636/antiword_8mmp_source.html Fri Jun 11 15:24:34 2010 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,143 +0,0 @@ - - - - -TB9.2 Example Applications: examples/PIPS/antiword/group/antiword.mmp Source File - - - - - -

examples/PIPS/antiword/group/antiword.mmp

00001 /*
-00002 * ==============================================================================
-00003 *  Name        : antiword.mmp
-00004 *  Part of     : Open C / antiword
-00005 *  Interface   : 
-00006 *  Description : Word document conversion project
-00007 *  Version     : 
-00008 *
-00009 *  Copyright (c) 2005-2007 Nokia Corporation.
-00010 *  This material, including documentation and any related 
-00011 *  computer programs, is protected by copyright controlled by 
-00012 *  Nokia Corporation.
-00013 * ==============================================================================
-00014 */
-00015 
-00016 TARGET          antiword.exe
-00017 TARGETTYPE      exe
-00018 UID             0x100039CE 0xA0001323
-00019 VENDORID        0
-00020 
-00021 
-00022 SOURCEPATH      ..\data
-00023 START RESOURCE  antiword_reg.rss
-00024 #ifdef WINSCW
-00025 TARGETPATH          \private\10003a3f\apps
-00026 #else
-00027 TARGETPATH          \private\10003a3f\import\apps
-00028 #endif
-00029 END //RESOURCE
-00030 
-00031 SOURCEPATH      ..\src
-00032 
-00033 //Sourcefile
-00034 SOURCE          asc85enc.c
-00035 SOURCE          blocklist.c
-00036 SOURCE          chartrans.c
-00037 SOURCE          datalist.c
-00038 SOURCE          depot.c
-00039 SOURCE          dib2eps.c
-00040 SOURCE          doclist.c
-00041 SOURCE          fail.c
-00042 SOURCE          finddata.c
-00043 SOURCE          findtext.c
-00044 SOURCE          fmt_text.c
-00045 SOURCE          fontlist.c
-00046 SOURCE          fonts.c
-00047 SOURCE          fonts_u.c
-00048 SOURCE          hdrftrlist.c
-00049 SOURCE          imgexam.c
-00050 SOURCE          imgtrans.c
-00051 SOURCE          jpeg2eps.c
-00052 SOURCE          listlist.c
-00053 SOURCE          main_u.c
-00054 SOURCE          misc.c
-00055 SOURCE          notes.c
-00056 SOURCE          options.c
-00057 SOURCE          out2window.c
-00058 SOURCE          output.c
-00059 SOURCE          pdf.c
-00060 SOURCE          pictlist.c
-00061 SOURCE          png2eps.c
-00062 SOURCE          png2sprt.c
-00063 SOURCE          postscript.c
-00064 SOURCE          prop0.c
-00065 SOURCE          prop2.c
-00066 SOURCE          prop6.c
-00067 SOURCE          prop8.c
-00068 SOURCE          properties.c
-00069 SOURCE          propmod.c
-00070 SOURCE          rowlist.c
-00071 SOURCE          sectlist.c
-00072 SOURCE          stylelist.c
-00073 SOURCE          stylesheet.c
-00074 SOURCE          summary.c
-00075 SOURCE          tabstop.c
-00076 SOURCE          text.c
-00077 SOURCE          unix.c
-00078 SOURCE          utf8.c
-00079 SOURCE          word2text.c
-00080 SOURCE          worddos.c
-00081 SOURCE          wordlib.c
-00082 SOURCE          wordmac.c
-00083 SOURCE          wordole.c
-00084 SOURCE          wordwin.c
-00085 SOURCE          xmalloc.c
-00086 SOURCE          xml.c
-00087 
-00088 // Some of the files removed
-00089 // sprite support is not present in openc
-00090 //SOURCE          dib2sprt.c
-00091 //SOURCE          draw.c
-00092 //SOURCE          drawfile.c
-00093 //SOURCE          fonts_r.c
-00094 //SOURCE          icons.c
-00095 //SOURCE          jpeg2sprt.c
-00096 //SOURCE          main_ros.c
-00097 //SOURCE          riscos.c
-00098 //SOURCE          saveas.c
-00099 //SOURCE          startup.c
-00100 
-00101 
-00102 USERINCLUDE     ..\inc 
-00103 
-00104 
-00105 
-00106 
-00107 //Project Specific Macro and reqmts.
-00108 MACRO                           SYMBIAN
-00109 MACRO                           NDEBUG
-00110 epocheapsize            0x4000 0x8000
-00111 epocstacksize           0x8000
-00112 
-00113 //Standard System include paths
-00114 SYSTEMINCLUDE           \epoc32\include
-00115 // These are needed for including Open C headers
-00116 // NOTE! When part of SDK, path will differ
-00117 SYSTEMINCLUDE           \epoc32\include\stdapis
-00118 
-00119 STATICLIBRARY           libcrt0.lib
-00120 
-00121 LIBRARY                 euser.lib
-00122 LIBRARY                 libc.lib
-00123 
-00124 // No capabilities needed by this application
-00125 CAPABILITY                      None
-00126 
-00127 LANG                    SC
-
-
Generated by  - -doxygen 1.6.2
- - diff -r 59758314f811 -r d4524d6a4472 Symbian3/Examples/guid-6013a680-57f9-415b-8851-c4fa63356636/antiword__reg_8rss_source.html --- a/Symbian3/Examples/guid-6013a680-57f9-415b-8851-c4fa63356636/antiword__reg_8rss_source.html Fri Jun 11 15:24:34 2010 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,29 +0,0 @@ - - - - -TB9.2 Example Applications: examples/PIPS/antiword/data/antiword_reg.rss Source File - - - - - -

examples/PIPS/antiword/data/antiword_reg.rss

00001 #include <appinfo.rh>
-00002 
-00003 UID2 KUidAppRegistrationResourceFile
-00004 UID3 0xA0001323
-00005 
-00006 RESOURCE APP_REGISTRATION_INFO
-00007   {
-00008   app_file="Antiword";
-00009 
-00010   embeddability=KAppNotEmbeddable;
-00011   newfile=KAppDoesNotSupportNewFile;
-00012   }
-00013 
-
-
Generated by  - -doxygen 1.6.2
- - diff -r 59758314f811 -r d4524d6a4472 Symbian3/Examples/guid-6013a680-57f9-415b-8851-c4fa63356636/asc85enc_8c_source.html --- a/Symbian3/Examples/guid-6013a680-57f9-415b-8851-c4fa63356636/asc85enc_8c_source.html Fri Jun 11 15:24:34 2010 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,170 +0,0 @@ - - - - -TB9.2 Example Applications: examples/PIPS/antiword/src/asc85enc.c Source File - - - - - -

examples/PIPS/antiword/src/asc85enc.c

00001 /*
-00002  * asc85enc.c
-00003  * Copyright (C) 2000-2003 A.J. van Os; Released under GPL
-00004  *
-00005  * Description:
-00006  * Functions to for ASCII 85 encoding
-00007  *
-00008  *====================================================================
-00009  * This part of the software is based on:
-00010  * asc85ec.c - ASCII85 and Hex encoding for PostScript Level 2 and PDF
-00011  * Copyright (C) 1994-99 Thomas Merz (tm@muc.de)
-00012  *====================================================================
-00013  * The credit should go to him, but all the bugs are mine.
-00014  */
-00015 
-00016 #include <stdio.h>
-00017 #include "antiword.h"
-00018 
-00019 static const ULONG      aulPower85[5] = {
-00020         1UL, 85UL, 85UL * 85, 85UL * 85 * 85, 85UL * 85 * 85 * 85,
-00021 };
-00022 static int      iOutBytes = 0;  /* Number of characters in an output line */
-00023 static char     cCharPrev = '\0';
-00024 
-00025 /*
-00026  * Two percent characters at the start of a line will cause trouble
-00027  * with some post-processing software. In order to avoid this, we
-00028  * simply insert a line break if we encounter two percent characters
-00029  * at the start of the line. Of course, this rather simplistic
-00030  * algorithm may lead to a large line count in pathological cases,
-00031  * but the chance for hitting such a case is very small, and even
-00032  * so it's only a cosmetic flaw and not a functional restriction.
-00033  */
-00034 
-00035 /*
-00036  * vOutputByte - output one byte
-00037  */
-00038 static void
-00039 vOutputByte(ULONG ulChar, FILE *pOutFile)
-00040 {
-00041         if (iOutBytes == 1 && cCharPrev == '%' && ulChar == (ULONG)'%') {
-00042                 if (putc('\n', pOutFile) != EOF) {
-00043                         iOutBytes = 0;
-00044                 }
-00045         }
-00046         if (putc((int)ulChar, pOutFile) == EOF) {
-00047                 return;
-00048         }
-00049         iOutBytes++;
-00050         if (iOutBytes > 63) {
-00051                 if (putc('\n', pOutFile) != EOF) {
-00052                         iOutBytes = 0;
-00053                 }
-00054         }
-00055         cCharPrev = (char)ulChar;
-00056 } /* end of vOutputByte */
-00057 
-00058 /*
-00059  * vASCII85EncodeByte - ASCII 85 encode a byte
-00060  */
-00061 void
-00062 vASCII85EncodeByte(FILE *pOutFile, int iByte)
-00063 {
-00064         static ULONG    ulBuffer[4] = { 0, 0, 0, 0 };
-00065         static int      iInBuffer = 0;
-00066         ULONG   ulValue, ulTmp;
-00067         int     iIndex;
-00068 
-00069         fail(pOutFile == NULL);
-00070         fail(iInBuffer < 0);
-00071         fail(iInBuffer > 3);
-00072 
-00073         if (iByte == EOF) {
-00074                 /* End Of File, time to clean up */
-00075                 if (iInBuffer > 0 && iInBuffer < 4) {
-00076                         /* Encode the remaining bytes */
-00077                         ulValue = 0;
-00078                         for (iIndex = iInBuffer - 1; iIndex >= 0; iIndex--) {
-00079                                 ulValue |=
-00080                                         ulBuffer[iIndex] << (8 * (3 - iIndex));
-00081                         }
-00082                         for (iIndex = 4; iIndex >= 4 - iInBuffer; iIndex--) {
-00083                                 ulTmp = ulValue / aulPower85[iIndex];
-00084                                 vOutputByte(ulTmp + '!', pOutFile);
-00085                                 ulValue -= ulTmp * aulPower85[iIndex];
-00086                         }
-00087                 }
-00088                 /* Add the End Of Data marker */
-00089                 (void)putc('~', pOutFile);
-00090                 (void)putc('>', pOutFile);
-00091                 (void)putc('\n', pOutFile);
-00092                 /* Reset the control variables */
-00093                 iInBuffer = 0;
-00094                 iOutBytes = 0;
-00095                 cCharPrev = '\0';
-00096                 return;
-00097         }
-00098 
-00099         ulBuffer[iInBuffer] = (ULONG)iByte & 0xff;
-00100         iInBuffer++;
-00101 
-00102         if (iInBuffer >= 4) {
-00103                 ulValue = (ulBuffer[0] << 24) | (ulBuffer[1] << 16) |
-00104                         (ulBuffer[2] << 8) | ulBuffer[3];
-00105                 if (ulValue == 0) {
-00106                         vOutputByte((ULONG)'z', pOutFile); /* Shortcut for 0 */
-00107                 } else {
-00108                         for (iIndex = 4; iIndex >= 0; iIndex--) {
-00109                                 ulTmp = ulValue / aulPower85[iIndex];
-00110                                 vOutputByte(ulTmp + '!', pOutFile);
-00111                                 ulValue -= ulTmp * aulPower85[iIndex];
-00112                         }
-00113                 }
-00114                 /* Reset the buffer */
-00115                 iInBuffer = 0;
-00116         }
-00117 } /* end of vASCII85EncodeByte */
-00118 
-00119 /*
-00120  * vASCII85EncodeArray - ASCII 85 encode a byte array
-00121  */
-00122 void
-00123 vASCII85EncodeArray(FILE *pInFile, FILE *pOutFile, size_t tLength)
-00124 {
-00125         size_t  tCount;
-00126         int     iByte;
-00127 
-00128         fail(pInFile == NULL);
-00129         fail(pOutFile == NULL);
-00130 
-00131         DBG_DEC(tLength);
-00132 
-00133         for (tCount = 0; tCount < tLength; tCount++) {
-00134                 iByte = iNextByte(pInFile);
-00135                 if (iByte == EOF) {
-00136                         break;
-00137                 }
-00138                 vASCII85EncodeByte(pOutFile, iByte);
-00139         }
-00140 } /* end of vASCII85EncodeArray */
-00141 
-00142 /*
-00143  * vASCII85EncodeFile - ASCII 85 encode part of a file
-00144  */
-00145 void
-00146 vASCII85EncodeFile(FILE *pInFile, FILE *pOutFile, size_t tLength)
-00147 {
-00148         fail(pInFile == NULL);
-00149         fail(pOutFile == NULL);
-00150         fail(tLength == 0);
-00151 
-00152         vASCII85EncodeArray(pInFile, pOutFile, tLength);
-00153         vASCII85EncodeByte(pOutFile, EOF);
-00154 } /* end of vASCII85EncodeFile */
-
-
Generated by  - -doxygen 1.6.2
- - diff -r 59758314f811 -r d4524d6a4472 Symbian3/Examples/guid-6013a680-57f9-415b-8851-c4fa63356636/blocklist_8c_source.html --- a/Symbian3/Examples/guid-6013a680-57f9-415b-8851-c4fa63356636/blocklist_8c_source.html Fri Jun 11 15:24:34 2010 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,839 +0,0 @@ - - - - -TB9.2 Example Applications: examples/PIPS/antiword/src/blocklist.c Source File - - - - - -

examples/PIPS/antiword/src/blocklist.c

00001 /*
-00002  * blocklist.c
-00003  * Copyright (C) 1998-2005 A.J. van Os; Released under GNU GPL
-00004  *
-00005  * Description:
-00006  * Build, read and destroy the lists of Word "text" blocks
-00007  */
-00008 
-00009 #include <stdlib.h>
-00010 #include "antiword.h"
-00011 
-00012 
-00013 /*
-00014  * Private structure to hide the way the information
-00015  * is stored from the rest of the program
-00016  */
-00017 typedef struct list_mem_tag {
-00018         text_block_type         tInfo;
-00019         struct list_mem_tag     *pNext;
-00020 } list_mem_type;
-00021 
-00022 typedef struct readinfo_tag {
-00023         list_mem_type           *pBlockCurrent;
-00024         ULONG                   ulBlockOffset;
-00025         size_t                  tByteNext;
-00026         UCHAR                   aucBlock[BIG_BLOCK_SIZE];
-00027 } readinfo_type;
-00028 
-00029 /* Variables to describe the start of the block lists */
-00030 static list_mem_type    *pTextAnchor = NULL;
-00031 static list_mem_type    *pFootnoteAnchor = NULL;
-00032 static list_mem_type    *pHdrFtrAnchor = NULL;
-00033 static list_mem_type    *pMacroAnchor = NULL;
-00034 static list_mem_type    *pAnnotationAnchor = NULL;
-00035 static list_mem_type    *pEndnoteAnchor = NULL;
-00036 static list_mem_type    *pTextBoxAnchor = NULL;
-00037 static list_mem_type    *pHdrTextBoxAnchor = NULL;
-00038 /* Variable needed to build the block list */
-00039 static list_mem_type    *pBlockLast = NULL;
-00040 /* Variable needed to read the block lists */
-00041 static readinfo_type    tOthers = { NULL, 0, 0, };
-00042 static readinfo_type    tHdrFtr = { NULL, 0, 0, };
-00043 static readinfo_type    tFootnote = { NULL, 0, 0, };
-00044 
-00045 
-00046 /*
-00047  * pFreeOneList - free a text block list
-00048  *
-00049  * Will always return NULL
-00050  */
-00051 static list_mem_type *
-00052 pFreeOneList(list_mem_type *pAnchor)
-00053 {
-00054         list_mem_type   *pCurr, *pNext;
-00055 
-00056         pCurr = pAnchor;
-00057         while (pCurr != NULL) {
-00058                 pNext = pCurr->pNext;
-00059                 pCurr = xfree(pCurr);
-00060                 pCurr = pNext;
-00061         }
-00062         return NULL;
-00063 } /* end of pFreeOneList */
-00064 
-00065 /*
-00066  * vDestroyTextBlockList - destroy the text block lists
-00067  */
-00068 void
-00069 vDestroyTextBlockList(void)
-00070 {
-00071         DBG_MSG("vDestroyTextBlockList");
-00072 
-00073         /* Free the lists one by one */
-00074         pTextAnchor = pFreeOneList(pTextAnchor);
-00075         pFootnoteAnchor = pFreeOneList(pFootnoteAnchor);
-00076         pHdrFtrAnchor = pFreeOneList(pHdrFtrAnchor);
-00077         pMacroAnchor = pFreeOneList(pMacroAnchor);
-00078         pAnnotationAnchor = pFreeOneList(pAnnotationAnchor);
-00079         pEndnoteAnchor = pFreeOneList(pEndnoteAnchor);
-00080         pTextBoxAnchor = pFreeOneList(pTextBoxAnchor);
-00081         pHdrTextBoxAnchor = pFreeOneList(pHdrTextBoxAnchor);
-00082         /* Reset all the controle variables */
-00083         pBlockLast = NULL;
-00084         tOthers.pBlockCurrent = NULL;
-00085         tHdrFtr.pBlockCurrent = NULL;
-00086         tFootnote.pBlockCurrent = NULL;
-00087 } /* end of vDestroyTextBlockList */
-00088 
-00089 /*
-00090  * bAdd2TextBlockList - add an element to the text block list
-00091  *
-00092  * returns: TRUE when successful, otherwise FALSE
-00093  */
-00094 BOOL
-00095 bAdd2TextBlockList(const text_block_type *pTextBlock)
-00096 {
-00097         list_mem_type   *pListMember;
-00098 
-00099         fail(pTextBlock == NULL);
-00100         fail(pTextBlock->ulFileOffset == FC_INVALID);
-00101         fail(pTextBlock->ulCharPos == CP_INVALID);
-00102         fail(pTextBlock->ulLength == 0);
-00103         fail(pTextBlock->bUsesUnicode && odd(pTextBlock->ulLength));
-00104 
-00105         NO_DBG_MSG("bAdd2TextBlockList");
-00106         NO_DBG_HEX(pTextBlock->ulFileOffset);
-00107         NO_DBG_HEX(pTextBlock->ulCharPos);
-00108         NO_DBG_HEX(pTextBlock->ulLength);
-00109         NO_DBG_DEC(pTextBlock->bUsesUnicode);
-00110         NO_DBG_DEC(pTextBlock->usPropMod);
-00111 
-00112         if (pTextBlock->ulFileOffset == FC_INVALID ||
-00113             pTextBlock->ulCharPos == CP_INVALID ||
-00114             pTextBlock->ulLength == 0 ||
-00115             (pTextBlock->bUsesUnicode && odd(pTextBlock->ulLength))) {
-00116                 werr(0, "Software (textblock) error");
-00117                 return FALSE;
-00118         }
-00119         /*
-00120          * Check for continuous blocks of the same character size and
-00121          * the same properties modifier
-00122          */
-00123         if (pBlockLast != NULL &&
-00124             pBlockLast->tInfo.ulFileOffset +
-00125              pBlockLast->tInfo.ulLength == pTextBlock->ulFileOffset &&
-00126             pBlockLast->tInfo.ulCharPos +
-00127              pBlockLast->tInfo.ulLength == pTextBlock->ulCharPos &&
-00128             pBlockLast->tInfo.bUsesUnicode == pTextBlock->bUsesUnicode &&
-00129             pBlockLast->tInfo.usPropMod == pTextBlock->usPropMod) {
-00130                 /* These are continous blocks */
-00131                 pBlockLast->tInfo.ulLength += pTextBlock->ulLength;
-00132                 return TRUE;
-00133         }
-00134         /* Make a new block */
-00135         pListMember = xmalloc(sizeof(list_mem_type));
-00136         /* Add the block to the list */
-00137         pListMember->tInfo = *pTextBlock;
-00138         pListMember->pNext = NULL;
-00139         if (pTextAnchor == NULL) {
-00140                 pTextAnchor = pListMember;
-00141         } else {
-00142                 fail(pBlockLast == NULL);
-00143                 pBlockLast->pNext = pListMember;
-00144         }
-00145         pBlockLast = pListMember;
-00146         return TRUE;
-00147 } /* end of bAdd2TextBlockList */
-00148 
-00149 /*
-00150  * vSpitList - Split the list in two
-00151  */
-00152 static void
-00153 vSpitList(list_mem_type **ppAnchorCurr, list_mem_type **ppAnchorNext,
-00154         ULONG ulListLen)
-00155 {
-00156         list_mem_type   *pCurr;
-00157         long            lCharsToGo, lBytesTooFar;
-00158 
-00159         fail(ppAnchorCurr == NULL);
-00160         fail(ppAnchorNext == NULL);
-00161         fail(ulListLen > (ULONG)LONG_MAX);
-00162 
-00163         pCurr = NULL;
-00164         lCharsToGo = (long)ulListLen;
-00165         lBytesTooFar = -1;
-00166         if (ulListLen != 0) {
-00167                 DBG_DEC(ulListLen);
-00168                 for (pCurr = *ppAnchorCurr;
-00169                      pCurr != NULL;
-00170                      pCurr = pCurr->pNext) {
-00171                         NO_DBG_DEC(pCurr->tInfo.ulLength);
-00172                         fail(pCurr->tInfo.ulLength == 0);
-00173                         fail(pCurr->tInfo.ulLength > (ULONG)LONG_MAX);
-00174                         if (pCurr->tInfo.bUsesUnicode) {
-00175                                 fail(odd(pCurr->tInfo.ulLength));
-00176                                 lCharsToGo -= (long)(pCurr->tInfo.ulLength / 2);
-00177                                 if (lCharsToGo < 0) {
-00178                                         lBytesTooFar = -2 * lCharsToGo;
-00179                                 }
-00180                         } else {
-00181                                 lCharsToGo -= (long)pCurr->tInfo.ulLength;
-00182                                 if (lCharsToGo < 0) {
-00183                                         lBytesTooFar = -lCharsToGo;
-00184                                 }
-00185                         }
-00186                         if (lCharsToGo <= 0) {
-00187                                 break;
-00188                         }
-00189                 }
-00190         }
-00191 /* Split the list */
-00192         if (ulListLen == 0) {
-00193                 /* Current blocklist is empty */
-00194                 *ppAnchorNext = *ppAnchorCurr;
-00195                 *ppAnchorCurr = NULL;
-00196         } else if (pCurr == NULL) {
-00197                 /* No blocks for the next list */
-00198                 *ppAnchorNext = NULL;
-00199         } else if (lCharsToGo == 0) {
-00200                 /* Move the integral number of blocks to the next list */
-00201                 *ppAnchorNext = pCurr->pNext;
-00202                 pCurr->pNext = NULL;
-00203         } else {
-00204                 /* Split the part current block list, part next block list */
-00205                 DBG_DEC(lBytesTooFar);
-00206                 fail(lBytesTooFar <= 0);
-00207                 *ppAnchorNext = xmalloc(sizeof(list_mem_type));
-00208                 DBG_HEX(pCurr->tInfo.ulFileOffset);
-00209                 (*ppAnchorNext)->tInfo.ulFileOffset =
-00210                                 pCurr->tInfo.ulFileOffset +
-00211                                 pCurr->tInfo.ulLength -
-00212                                 lBytesTooFar;
-00213                 DBG_HEX((*ppAnchorNext)->tInfo.ulFileOffset);
-00214                 DBG_HEX(pCurr->tInfo.ulCharPos);
-00215                 (*ppAnchorNext)->tInfo.ulCharPos =
-00216                                 pCurr->tInfo.ulCharPos +
-00217                                 pCurr->tInfo.ulLength -
-00218                                 lBytesTooFar;
-00219                 DBG_HEX((*ppAnchorNext)->tInfo.ulCharPos);
-00220                 (*ppAnchorNext)->tInfo.ulLength = (ULONG)lBytesTooFar;
-00221                 pCurr->tInfo.ulLength -= (ULONG)lBytesTooFar;
-00222                 (*ppAnchorNext)->tInfo.bUsesUnicode = pCurr->tInfo.bUsesUnicode;
-00223                 (*ppAnchorNext)->tInfo.usPropMod = pCurr->tInfo.usPropMod;
-00224                 /* Move the integral number of blocks to the next list */
-00225                 (*ppAnchorNext)->pNext = pCurr->pNext;
-00226                 pCurr->pNext = NULL;
-00227         }
-00228 } /* end of vSpitList */
-00229 
-00230 #if defined(DEBUG) || defined(__riscos)
-00231 /*
-00232  * ulComputeListLength - compute the length of a list
-00233  *
-00234  * returns the list length in characters
-00235  */
-00236 static ULONG
-00237 ulComputeListLength(const list_mem_type *pAnchor)
-00238 {
-00239         const list_mem_type     *pCurr;
-00240         ULONG           ulTotal;
-00241 
-00242         ulTotal = 0;
-00243         for (pCurr = pAnchor; pCurr != NULL; pCurr = pCurr->pNext) {
-00244                 fail(pCurr->tInfo.ulLength == 0);
-00245                 if (pCurr->tInfo.bUsesUnicode) {
-00246                         fail(odd(pCurr->tInfo.ulLength));
-00247                         ulTotal += pCurr->tInfo.ulLength / 2;
-00248                 } else {
-00249                         ulTotal += pCurr->tInfo.ulLength;
-00250                 }
-00251         }
-00252         return ulTotal;
-00253 } /* end of ulComputeListLength */
-00254 #endif /* DEBUG || __riscos */
-00255 
-00256 #if defined(DEBUG)
-00257 /*
-00258  * vCheckList - check the number of bytes in a block list
-00259  */
-00260 static void
-00261 vCheckList(const list_mem_type *pAnchor, ULONG ulListLen, char *szMsg)
-00262 {
-00263         ULONG           ulTotal;
-00264 
-00265         ulTotal = ulComputeListLength(pAnchor);
-00266         DBG_DEC(ulTotal);
-00267         if (ulTotal != ulListLen) {
-00268                 DBG_DEC(ulListLen);
-00269                 werr(1, szMsg);
-00270         }
-00271 } /* end of vCheckList */
-00272 #endif /* DEBUG */
-00273 
-00274 /*
-00275  * bIsEmptyBox - check to see if the given text box is empty
-00276  */
-00277 static BOOL
-00278 bIsEmptyBox(FILE *pFile, const list_mem_type *pAnchor)
-00279 {
-00280         const list_mem_type     *pCurr;
-00281         size_t  tIndex, tSize;
-00282         UCHAR   *aucBuffer;
-00283         char    cChar;
-00284 
-00285         fail(pFile == NULL);
-00286 
-00287         if (pAnchor == NULL) {
-00288                 return TRUE;
-00289         }
-00290 
-00291         aucBuffer = NULL;
-00292         for (pCurr = pAnchor; pCurr != NULL; pCurr = pCurr->pNext) {
-00293                 fail(pCurr->tInfo.ulLength == 0);
-00294                 tSize = (size_t)pCurr->tInfo.ulLength;
-00295 #if defined(__dos) && !defined(__DJGPP__)
-00296                 if (pCurr->tInfo.ulLength > 0xffffUL) {
-00297                         tSize = 0xffff;
-00298                 }
-00299 #endif /* __dos && !__DJGPP__ */
-00300                 fail(aucBuffer != NULL);
-00301                 aucBuffer = xmalloc(tSize);
-00302                 if (!bReadBytes(aucBuffer, tSize,
-00303                                 pCurr->tInfo.ulFileOffset, pFile)) {
-00304                         aucBuffer = xfree(aucBuffer);
-00305                         return FALSE;
-00306                 }
-00307                 for (tIndex = 0; tIndex < tSize; tIndex++) {
-00308                         cChar = (char)aucBuffer[tIndex];
-00309                         switch (cChar) {
-00310                         case '\0': case '\r': case '\n':
-00311                         case '\f': case '\t': case '\v':
-00312                         case ' ':
-00313                                 break;
-00314                         default:
-00315                                 aucBuffer = xfree(aucBuffer);
-00316                                 return FALSE;
-00317                         }
-00318                 }
-00319                 aucBuffer = xfree(aucBuffer);
-00320         }
-00321         fail(aucBuffer != NULL);
-00322         return TRUE;
-00323 } /* end of bIsEmptyBox */
-00324 
-00325 /*
-00326  * vSplitBlockList - split the block list in the various parts
-00327  *
-00328  * Split the blocklist in a Text block list, a Footnote block list, a
-00329  * HeaderFooter block list, a Macro block list, an Annotation block list,
-00330  * an Endnote block list, a TextBox list and a HeaderTextBox list.
-00331  *
-00332  * NOTE:
-00333  * The various ul*Len input parameters are given in characters, but the
-00334  * length of the blocks are in bytes.
-00335  */
-00336 void
-00337 vSplitBlockList(FILE *pFile, ULONG ulTextLen, ULONG ulFootnoteLen,
-00338         ULONG ulHdrFtrLen, ULONG ulMacroLen, ULONG ulAnnotationLen,
-00339         ULONG ulEndnoteLen, ULONG ulTextBoxLen, ULONG ulHdrTextBoxLen,
-00340         BOOL bMustExtend)
-00341 {
-00342         list_mem_type   *apAnchors[8];
-00343         list_mem_type   *pGarbageAnchor, *pCurr;
-00344         size_t          tIndex;
-00345 
-00346         DBG_MSG("vSplitBlockList");
-00347 
-00348         pGarbageAnchor = NULL;
-00349 
-00350         DBG_MSG_C(ulTextLen != 0, "Text block list");
-00351         vSpitList(&pTextAnchor, &pFootnoteAnchor, ulTextLen);
-00352         DBG_MSG_C(ulFootnoteLen != 0, "Footnote block list");
-00353         vSpitList(&pFootnoteAnchor, &pHdrFtrAnchor, ulFootnoteLen);
-00354         DBG_MSG_C(ulHdrFtrLen != 0, "Header/Footer block list");
-00355         vSpitList(&pHdrFtrAnchor, &pMacroAnchor, ulHdrFtrLen);
-00356         DBG_MSG_C(ulMacroLen != 0, "Macro block list");
-00357         vSpitList(&pMacroAnchor, &pAnnotationAnchor, ulMacroLen);
-00358         DBG_MSG_C(ulAnnotationLen != 0, "Annotation block list");
-00359         vSpitList(&pAnnotationAnchor, &pEndnoteAnchor, ulAnnotationLen);
-00360         DBG_MSG_C(ulEndnoteLen != 0, "Endnote block list");
-00361         vSpitList(&pEndnoteAnchor, &pTextBoxAnchor, ulEndnoteLen);
-00362         DBG_MSG_C(ulTextBoxLen != 0, "Textbox block list");
-00363         vSpitList(&pTextBoxAnchor, &pHdrTextBoxAnchor, ulTextBoxLen);
-00364         DBG_MSG_C(ulHdrTextBoxLen != 0, "HeaderTextbox block list");
-00365         vSpitList(&pHdrTextBoxAnchor, &pGarbageAnchor, ulHdrTextBoxLen);
-00366 
-00367         /* Free the garbage block list, this should not be needed */
-00368         DBG_DEC_C(pGarbageAnchor != NULL, pGarbageAnchor->tInfo.ulLength);
-00369         pGarbageAnchor = pFreeOneList(pGarbageAnchor);
-00370 
-00371 #if defined(DEBUG)
-00372         vCheckList(pTextAnchor, ulTextLen, "Software error (Text)");
-00373         vCheckList(pFootnoteAnchor, ulFootnoteLen, "Software error (Footnote)");
-00374         vCheckList(pHdrFtrAnchor, ulHdrFtrLen, "Software error (Hdr/Ftr)");
-00375         vCheckList(pMacroAnchor, ulMacroLen, "Software error (Macro)");
-00376         vCheckList(pAnnotationAnchor, ulAnnotationLen,
-00377                                                 "Software error (Annotation)");
-00378         vCheckList(pEndnoteAnchor, ulEndnoteLen, "Software error (Endnote)");
-00379         vCheckList(pTextBoxAnchor, ulTextBoxLen, "Software error (TextBox)");
-00380         vCheckList(pHdrTextBoxAnchor, ulHdrTextBoxLen,
-00381                                                 "Software error (HdrTextBox)");
-00382 #endif /* DEBUG */
-00383 
-00384         /* Remove the list if the text box is empty */
-00385         if (bIsEmptyBox(pFile, pTextBoxAnchor)) {
-00386                 pTextBoxAnchor = pFreeOneList(pTextBoxAnchor);
-00387         }
-00388         if (bIsEmptyBox(pFile, pHdrTextBoxAnchor)) {
-00389                 pHdrTextBoxAnchor = pFreeOneList(pHdrTextBoxAnchor);
-00390         }
-00391 
-00392         if (!bMustExtend) {
-00393                 return;
-00394         }
-00395         /*
-00396          * All blocks (except the last one) must have a length that
-00397          * is a multiple of the Big Block Size
-00398          */
-00399 
-00400         apAnchors[0] = pTextAnchor;
-00401         apAnchors[1] = pFootnoteAnchor;
-00402         apAnchors[2] = pHdrFtrAnchor;
-00403         apAnchors[3] = pMacroAnchor;
-00404         apAnchors[4] = pAnnotationAnchor;
-00405         apAnchors[5] = pEndnoteAnchor;
-00406         apAnchors[6] = pTextBoxAnchor;
-00407         apAnchors[7] = pHdrTextBoxAnchor;
-00408 
-00409         for (tIndex = 0; tIndex < elementsof(apAnchors); tIndex++) {
-00410                 for (pCurr = apAnchors[tIndex];
-00411                      pCurr != NULL;
-00412                      pCurr = pCurr->pNext) {
-00413                         if (pCurr->pNext != NULL &&
-00414                             pCurr->tInfo.ulLength % BIG_BLOCK_SIZE != 0) {
-00415                                 DBG_DEC(tIndex);
-00416                                 DBG_HEX(pCurr->tInfo.ulFileOffset);
-00417                                 DBG_HEX(pCurr->tInfo.ulCharPos);
-00418                                 DBG_DEC(pCurr->tInfo.ulLength);
-00419                                 pCurr->tInfo.ulLength /= BIG_BLOCK_SIZE;
-00420                                 pCurr->tInfo.ulLength++;
-00421                                 pCurr->tInfo.ulLength *= BIG_BLOCK_SIZE;
-00422                                 DBG_DEC(pCurr->tInfo.ulLength);
-00423                         }
-00424                 }
-00425         }
-00426 } /* end of vSplitBlockList */
-00427 
-00428 #if defined(__riscos)
-00429 /*
-00430  * ulGetDocumentLength - get the total character length of the printable lists
-00431  *
-00432  * returns: The total number of characters
-00433  */
-00434 ULONG
-00435 ulGetDocumentLength(void)
-00436 {
-00437         long            ulTotal;
-00438 
-00439         DBG_MSG("ulGetDocumentLength");
-00440 
-00441         ulTotal = ulComputeListLength(pTextAnchor);
-00442         ulTotal += ulComputeListLength(pFootnoteAnchor);
-00443         ulTotal += ulComputeListLength(pEndnoteAnchor);
-00444         ulTotal += ulComputeListLength(pTextBoxAnchor);
-00445         ulTotal += ulComputeListLength(pHdrTextBoxAnchor);
-00446         DBG_DEC(ulTotal);
-00447         return ulTotal;
-00448 } /* end of ulGetDocumentLength */
-00449 #endif /* __riscos */
-00450 
-00451 #if 0
-00452 /*
-00453  * bExistsHdrFtr - are there headers and/or footers?
-00454  */
-00455 BOOL
-00456 bExistsHdrFtr(void)
-00457 {
-00458         return pHdrFtrAnchor != NULL &&
-00459                 pHdrFtrAnchor->tInfo.ulLength != 0;
-00460 } /* end of bExistsHdrFtr */
-00461 #endif
-00462 
-00463 /*
-00464  * bExistsTextBox - is there a text box?
-00465  */
-00466 BOOL
-00467 bExistsTextBox(void)
-00468 {
-00469         return pTextBoxAnchor != NULL &&
-00470                 pTextBoxAnchor->tInfo.ulLength != 0;
-00471 } /* end of bExistsTextBox */
-00472 
-00473 /*
-00474  * bExistsHdrTextBox - is there a header text box?
-00475  */
-00476 BOOL
-00477 bExistsHdrTextBox(void)
-00478 {
-00479         return pHdrTextBoxAnchor != NULL &&
-00480                 pHdrTextBoxAnchor->tInfo.ulLength != 0;
-00481 } /* end of bExistsHdrTextBox */
-00482 
-00483 /*
-00484  * usGetNextByte - get the next byte from the specified block list
-00485  */
-00486 static USHORT
-00487 usGetNextByte(FILE *pFile, readinfo_type *pInfoCurrent, list_mem_type *pAnchor,
-00488         ULONG *pulFileOffset, ULONG *pulCharPos, USHORT *pusPropMod)
-00489 {
-00490         ULONG   ulReadOff;
-00491         size_t  tReadLen;
-00492 
-00493         fail(pInfoCurrent == NULL);
-00494 
-00495         if (pInfoCurrent->pBlockCurrent == NULL ||
-00496             pInfoCurrent->tByteNext >= sizeof(pInfoCurrent->aucBlock) ||
-00497             pInfoCurrent->ulBlockOffset + pInfoCurrent->tByteNext >=
-00498                                 pInfoCurrent->pBlockCurrent->tInfo.ulLength) {
-00499                 if (pInfoCurrent->pBlockCurrent == NULL) {
-00500                         /* First block, first part */
-00501                         pInfoCurrent->pBlockCurrent = pAnchor;
-00502                         pInfoCurrent->ulBlockOffset = 0;
-00503                 } else if (pInfoCurrent->ulBlockOffset +
-00504                                 sizeof(pInfoCurrent->aucBlock) <
-00505                                 pInfoCurrent->pBlockCurrent->tInfo.ulLength) {
-00506                         /* Same block, next part */
-00507                         pInfoCurrent->ulBlockOffset +=
-00508                                         sizeof(pInfoCurrent->aucBlock);
-00509                 } else {
-00510                         /* Next block, first part */
-00511                         pInfoCurrent->pBlockCurrent =
-00512                                         pInfoCurrent->pBlockCurrent->pNext;
-00513                         pInfoCurrent->ulBlockOffset = 0;
-00514                 }
-00515                 if (pInfoCurrent->pBlockCurrent == NULL) {
-00516                         /* Past the last part of the last block */
-00517                         return (USHORT)EOF;
-00518                 }
-00519                 tReadLen = (size_t)
-00520                         (pInfoCurrent->pBlockCurrent->tInfo.ulLength -
-00521                          pInfoCurrent->ulBlockOffset);
-00522                 if (tReadLen > sizeof(pInfoCurrent->aucBlock)) {
-00523                         tReadLen = sizeof(pInfoCurrent->aucBlock);
-00524                 }
-00525                 ulReadOff = pInfoCurrent->pBlockCurrent->tInfo.ulFileOffset +
-00526                                 pInfoCurrent->ulBlockOffset;
-00527                 if (!bReadBytes(pInfoCurrent->aucBlock,
-00528                                                 tReadLen, ulReadOff, pFile)) {
-00529                         /* Don't read from this list any longer */
-00530                         pInfoCurrent->pBlockCurrent = NULL;
-00531                         return (USHORT)EOF;
-00532                 }
-00533                 pInfoCurrent->tByteNext = 0;
-00534         }
-00535         if (pulFileOffset != NULL) {
-00536                 *pulFileOffset =
-00537                         pInfoCurrent->pBlockCurrent->tInfo.ulFileOffset +
-00538                         pInfoCurrent->ulBlockOffset +
-00539                         pInfoCurrent->tByteNext;
-00540         }
-00541         if (pulCharPos != NULL) {
-00542                 *pulCharPos =
-00543                         pInfoCurrent->pBlockCurrent->tInfo.ulCharPos +
-00544                         pInfoCurrent->ulBlockOffset +
-00545                         pInfoCurrent->tByteNext;
-00546         }
-00547         if (pusPropMod != NULL) {
-00548                 *pusPropMod = pInfoCurrent->pBlockCurrent->tInfo.usPropMod;
-00549         }
-00550         return (USHORT)pInfoCurrent->aucBlock[pInfoCurrent->tByteNext++];
-00551 } /* end of usGetNextByte */
-00552 
-00553 
-00554 /*
-00555  * usGetNextChar - get the next character from the specified block list
-00556  */
-00557 static USHORT
-00558 usGetNextChar(FILE *pFile, list_id_enum eListID,
-00559         ULONG *pulFileOffset, ULONG *pulCharPos, USHORT *pusPropMod)
-00560 {
-00561         readinfo_type   *pReadinfo;
-00562         list_mem_type   *pAnchor;
-00563         USHORT  usLSB, usMSB;
-00564 
-00565         switch (eListID) {
-00566         case text_list:
-00567                 pReadinfo = &tOthers;
-00568                 pAnchor = pTextAnchor;
-00569                 break;
-00570         case footnote_list:
-00571                 pReadinfo = &tFootnote;
-00572                 pAnchor = pFootnoteAnchor;
-00573                 break;
-00574         case hdrftr_list:
-00575                 pReadinfo = &tHdrFtr;
-00576                 pAnchor = pHdrFtrAnchor;
-00577                 break;
-00578         case endnote_list:
-00579                 pReadinfo = &tOthers;
-00580                 pAnchor = pEndnoteAnchor;
-00581                 break;
-00582         case textbox_list:
-00583                 pReadinfo = &tOthers;
-00584                 pAnchor = pTextBoxAnchor;
-00585                 break;
-00586         case hdrtextbox_list:
-00587                 pReadinfo = &tOthers;
-00588                 pAnchor = pHdrTextBoxAnchor;
-00589                 break;
-00590         default:
-00591                 DBG_DEC(eListID);
-00592                 return (USHORT)EOF;
-00593         }
-00594 
-00595         usLSB = usGetNextByte(pFile, pReadinfo, pAnchor,
-00596                                 pulFileOffset, pulCharPos, pusPropMod);
-00597         if (usLSB == (USHORT)EOF) {
-00598                 return (USHORT)EOF;
-00599         }
-00600         fail(pReadinfo->pBlockCurrent == NULL);
-00601 
-00602         if (pReadinfo->pBlockCurrent->tInfo.bUsesUnicode) {
-00603                 usMSB = usGetNextByte(pFile,
-00604                                 pReadinfo, pAnchor, NULL, NULL, NULL);
-00605         } else {
-00606                 usMSB = 0x00;
-00607         }
-00608         if (usMSB == (USHORT)EOF) {
-00609                 DBG_MSG("usGetNextChar: Unexpected EOF");
-00610                 DBG_HEX_C(pulFileOffset != NULL, *pulFileOffset);
-00611                 DBG_HEX_C(pulCharPos != NULL, *pulCharPos);
-00612                 return (USHORT)EOF;
-00613         }
-00614         return (usMSB << 8) | usLSB;
-00615 } /* end of usGetNextChar */
-00616 
-00617 /*
-00618  * usNextChar - get the next character from the given block list
-00619  */
-00620 USHORT
-00621 usNextChar(FILE *pFile, list_id_enum eListID,
-00622         ULONG *pulFileOffset, ULONG *pulCharPos, USHORT *pusPropMod)
-00623 {
-00624         USHORT  usRetVal;
-00625 
-00626         fail(pFile == NULL);
-00627 
-00628         usRetVal = usGetNextChar(pFile, eListID,
-00629                                 pulFileOffset, pulCharPos, pusPropMod);
-00630         if (usRetVal == (USHORT)EOF) {
-00631                 if (pulFileOffset != NULL) {
-00632                         *pulFileOffset = FC_INVALID;
-00633                 }
-00634                 if (pulCharPos != NULL) {
-00635                         *pulCharPos = CP_INVALID;
-00636                 }
-00637                 if (pusPropMod != NULL) {
-00638                         *pusPropMod = IGNORE_PROPMOD;
-00639                 }
-00640         }
-00641         return usRetVal;
-00642 } /* end of usNextChar */
-00643 
-00644 /*
-00645  * usToHdrFtrPosition - Go to a character position in header/foorter list
-00646  *
-00647  * Returns the character found on the specified character position
-00648  */
-00649 USHORT
-00650 usToHdrFtrPosition(FILE *pFile, ULONG ulCharPos)
-00651 {
-00652         ULONG   ulCharPosCurr;
-00653         USHORT  usChar;
-00654 
-00655         tHdrFtr.pBlockCurrent = NULL;   /* To reset the header/footer list */
-00656         do {
-00657                 usChar = usNextChar(pFile,
-00658                                 hdrftr_list, NULL, &ulCharPosCurr, NULL);
-00659         } while (usChar != (USHORT)EOF && ulCharPosCurr != ulCharPos);
-00660         return usChar;
-00661 } /* end of usToHdrFtrPosition */
-00662 
-00663 /*
-00664  * usToFootnotePosition - Go to a character position in footnote list
-00665  *
-00666  * Returns the character found on the specified character position
-00667  */
-00668 USHORT
-00669 usToFootnotePosition(FILE *pFile, ULONG ulCharPos)
-00670 {
-00671         ULONG   ulCharPosCurr;
-00672         USHORT  usChar;
-00673 
-00674         tFootnote.pBlockCurrent = NULL; /* To reset the footnote list */
-00675         do {
-00676                 usChar = usNextChar(pFile,
-00677                                 footnote_list, NULL, &ulCharPosCurr, NULL);
-00678         } while (usChar != (USHORT)EOF && ulCharPosCurr != ulCharPos);
-00679         return usChar;
-00680 } /* end of usToFootnotePosition */
-00681 
-00682 /*
-00683  * Convert a character position to an offset in the file.
-00684  * Logical to physical offset.
-00685  *
-00686  * Returns:     FC_INVALID: in case of error
-00687  *              otherwise: the computed file offset
-00688  */
-00689 ULONG
-00690 ulCharPos2FileOffsetX(ULONG ulCharPos, list_id_enum *peListID)
-00691 {
-00692         static list_id_enum     eListIDs[8] = {
-00693                 text_list,      footnote_list,          hdrftr_list,
-00694                 macro_list,     annotation_list,        endnote_list,
-00695                 textbox_list,   hdrtextbox_list,
-00696         };
-00697         list_mem_type   *apAnchors[8];
-00698         list_mem_type   *pCurr;
-00699         list_id_enum    eListGuess;
-00700         ULONG           ulBestGuess;
-00701         size_t          tIndex;
-00702 
-00703         fail(peListID == NULL);
-00704 
-00705         if (ulCharPos == CP_INVALID) {
-00706                 *peListID = no_list;
-00707                 return FC_INVALID;
-00708         }
-00709 
-00710         apAnchors[0] = pTextAnchor;
-00711         apAnchors[1] = pFootnoteAnchor;
-00712         apAnchors[2] = pHdrFtrAnchor;
-00713         apAnchors[3] = pMacroAnchor;
-00714         apAnchors[4] = pAnnotationAnchor;
-00715         apAnchors[5] = pEndnoteAnchor;
-00716         apAnchors[6] = pTextBoxAnchor;
-00717         apAnchors[7] = pHdrTextBoxAnchor;
-00718 
-00719         eListGuess = no_list;     /* Best guess is no list */
-00720         ulBestGuess = FC_INVALID; /* Best guess is "file offset not found" */
-00721 
-00722         for (tIndex = 0; tIndex < elementsof(apAnchors); tIndex++) {
-00723                 for (pCurr = apAnchors[tIndex];
-00724                      pCurr != NULL;
-00725                      pCurr = pCurr->pNext) {
-00726                         if (ulCharPos == pCurr->tInfo.ulCharPos +
-00727                              pCurr->tInfo.ulLength &&
-00728                             pCurr->pNext != NULL) {
-00729                                 /*
-00730                                  * The character position is one beyond this
-00731                                  * block, so we guess it's the first byte of
-00732                                  * the next block (if there is a next block)
-00733                                  */
-00734                                 eListGuess= eListIDs[tIndex];
-00735                                 ulBestGuess = pCurr->pNext->tInfo.ulFileOffset;
-00736                         }
-00737 
-00738                         if (ulCharPos < pCurr->tInfo.ulCharPos ||
-00739                             ulCharPos >= pCurr->tInfo.ulCharPos +
-00740                              pCurr->tInfo.ulLength) {
-00741                                 /* Character position is not in this block */
-00742                                 continue;
-00743                         }
-00744 
-00745                         /* The character position is in the current block */
-00746                         *peListID = eListIDs[tIndex];
-00747                         return pCurr->tInfo.ulFileOffset +
-00748                                 ulCharPos - pCurr->tInfo.ulCharPos;
-00749                 }
-00750         }
-00751         /* Passed beyond the end of the last list */
-00752         NO_DBG_HEX(ulCharPos);
-00753         NO_DBG_HEX(ulBestGuess);
-00754         *peListID = eListGuess;
-00755         return ulBestGuess;
-00756 } /* end of ulCharPos2FileOffsetX */
-00757 
-00758 /*
-00759  * Convert a character position to an offset in the file.
-00760  * Logical to physical offset.
-00761  *
-00762  * Returns:     FC_INVALID: in case of error
-00763  *              otherwise: the computed file offset
-00764  */
-00765 ULONG
-00766 ulCharPos2FileOffset(ULONG ulCharPos)
-00767 {
-00768         list_id_enum    eListID;
-00769 
-00770         return ulCharPos2FileOffsetX(ulCharPos, &eListID);
-00771 } /* end of ulCharPos2FileOffset */
-00772 
-00773 /*
-00774  * Convert an offset in the header/footer list to a character position.
-00775  *
-00776  * Returns:     CP_INVALID: in case of error
-00777  *              otherwise: the computed character position
-00778  */
-00779 ULONG
-00780 ulHdrFtrOffset2CharPos(ULONG ulHdrFtrOffset)
-00781 {
-00782         list_mem_type   *pCurr;
-00783         ULONG           ulOffset;
-00784 
-00785         ulOffset = ulHdrFtrOffset;
-00786         for (pCurr = pHdrFtrAnchor; pCurr != NULL; pCurr = pCurr->pNext) {
-00787                 if (ulOffset >= pCurr->tInfo.ulLength) {
-00788                         /* The offset is not in this block */
-00789                         ulOffset -= pCurr->tInfo.ulLength;
-00790                         continue;
-00791                 }
-00792                 return pCurr->tInfo.ulCharPos + ulOffset;
-00793         }
-00794         return CP_INVALID;
-00795 } /* end of ulHdrFtrOffset2CharPos */
-00796 
-00797 /*
-00798  * Get the sequence number beloning to the given file offset
-00799  *
-00800  * Returns the sequence number
-00801  */
-00802 ULONG
-00803 ulGetSeqNumber(ULONG ulFileOffset)
-00804 {
-00805         list_mem_type   *pCurr;
-00806         ULONG           ulSeq;
-00807 
-00808         if (ulFileOffset == FC_INVALID) {
-00809                 return FC_INVALID;
-00810         }
-00811 
-00812         ulSeq = 0;
-00813         for (pCurr = pTextAnchor; pCurr != NULL; pCurr = pCurr->pNext) {
-00814                 if (ulFileOffset >= pCurr->tInfo.ulFileOffset &&
-00815                     ulFileOffset < pCurr->tInfo.ulFileOffset +
-00816                      pCurr->tInfo.ulLength) {
-00817                         /* The file offset is within the current textblock */
-00818                         return ulSeq + ulFileOffset - pCurr->tInfo.ulFileOffset;
-00819                 }
-00820                 ulSeq += pCurr->tInfo.ulLength;
-00821         }
-00822         return FC_INVALID;
-00823 } /* end of ulGetSeqNumber */
-
-
Generated by  - -doxygen 1.6.2
- - diff -r 59758314f811 -r d4524d6a4472 Symbian3/Examples/guid-6013a680-57f9-415b-8851-c4fa63356636/chartrans_8c_source.html --- a/Symbian3/Examples/guid-6013a680-57f9-415b-8851-c4fa63356636/chartrans_8c_source.html Fri Jun 11 15:24:34 2010 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,736 +0,0 @@ - - - - -TB9.2 Example Applications: examples/PIPS/antiword/src/chartrans.c Source File - - - - - -

examples/PIPS/antiword/src/chartrans.c

00001 /*
-00002  * chartrans.c
-00003  * Copyright (C) 1999-2004 A.J. van Os; Released under GNU GPL
-00004  *
-00005  * Description:
-00006  * Translate Word characters to local representation
-00007  */
-00008 
-00009 #include <stdlib.h>
-00010 #include <string.h>
-00011 #include <ctype.h>
-00012 #if defined(__STDC_ISO_10646__)
-00013 #include <wctype.h>
-00014 #endif /* __STDC_ISO_10646__ */
-00015 #include "antiword.h"
-00016 
-00017 static const USHORT usCp850[] = {       /* DOS implementation of Latin1 */
-00018         0x00c7, 0x00fc, 0x00e9, 0x00e2, 0x00e4, 0x00e0, 0x00e5, 0x00e7,
-00019         0x00ea, 0x00eb, 0x00e8, 0x00ef, 0x00ee, 0x00ec, 0x00c4, 0x00c5,
-00020         0x00c9, 0x00e6, 0x00c6, 0x00f4, 0x00f6, 0x00f2, 0x00fb, 0x00f9,
-00021         0x00ff, 0x00d6, 0x00dc, 0x00f8, 0x00a3, 0x00d8, 0x00d7, 0x0192,
-00022         0x00e1, 0x00ed, 0x00f3, 0x00fa, 0x00f1, 0x00d1, 0x00aa, 0x00ba,
-00023         0x00bf, 0x00ae, 0x00ac, 0x00bd, 0x00bc, 0x00a1, 0x00ab, 0x00bb,
-00024         0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x00c1, 0x00c2, 0x00c0,
-00025         0x00a9, 0x2563, 0x2551, 0x2557, 0x255d, 0x00a2, 0x00a5, 0x2510,
-00026         0x2514, 0x2534, 0x252c, 0x251c, 0x2500, 0x253c, 0x00e3, 0x00c3,
-00027         0x255a, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256c, 0x00a4,
-00028         0x00f0, 0x00d0, 0x00ca, 0x00cb, 0x00c8, 0x0131, 0x00cd, 0x00ce,
-00029         0x00cf, 0x2518, 0x250c, 0x2588, 0x2584, 0x00a6, 0x00cc, 0x2580,
-00030         0x00d3, 0x00df, 0x00d4, 0x00d2, 0x00f5, 0x00d5, 0x00b5, 0x00fe,
-00031         0x00de, 0x00da, 0x00db, 0x00d9, 0x00fd, 0x00dd, 0x00af, 0x00b4,
-00032         0x00ad, 0x00b1, 0x2017, 0x00be, 0x00b6, 0x00a7, 0x00f7, 0x00b8,
-00033         0x00b0, 0x00a8, 0x00b7, 0x00b9, 0x00b3, 0x00b2, 0x25a0, 0x00a0,
-00034 };
-00035 
-00036 static const USHORT usCp1250[] = {      /* Windows implementation of Latin2 */
-00037         0x20ac, 0x003f, 0x201a, 0x003f, 0x201e, 0x2026, 0x2020, 0x2021,
-00038         0x003f, 0x2030, 0x0160, 0x2039, 0x015a, 0x0164, 0x017d, 0x0179,
-00039         0x003f, 0x2018, 0x2019, 0x201c, 0x201d, 0x2022, 0x2013, 0x2014,
-00040         0x003f, 0x2122, 0x0161, 0x203a, 0x015b, 0x0165, 0x017e, 0x017a,
-00041         0x00a0, 0x02c7, 0x02d8, 0x0141, 0x00a4, 0x0104, 0x00a6, 0x00a7,
-00042         0x00a8, 0x00a9, 0x015e, 0x00ab, 0x00ac, 0x00ad, 0x00ae, 0x017b,
-00043         0x00b0, 0x00b1, 0x02db, 0x0142, 0x00b4, 0x00b5, 0x00b6, 0x00b7,
-00044         0x00b8, 0x0105, 0x015f, 0x00bb, 0x013d, 0x02dd, 0x013e, 0x017c,
-00045         0x0154, 0x00c1, 0x00c2, 0x0102, 0x00c4, 0x0139, 0x0106, 0x00c7,
-00046         0x010c, 0x00c9, 0x0118, 0x00cb, 0x011a, 0x00cd, 0x00ce, 0x010e,
-00047         0x0110, 0x0143, 0x0147, 0x00d3, 0x00d4, 0x0150, 0x00d6, 0x00d7,
-00048         0x0158, 0x016e, 0x00da, 0x0170, 0x00dc, 0x00dd, 0x0162, 0x00df,
-00049         0x0155, 0x00e1, 0x00e2, 0x0103, 0x00e4, 0x013a, 0x0107, 0x00e7,
-00050         0x010d, 0x00e9, 0x0119, 0x00eb, 0x011b, 0x00ed, 0x00ee, 0x010f,
-00051         0x0111, 0x0144, 0x0148, 0x00f3, 0x00f4, 0x0151, 0x00f6, 0x00f7,
-00052         0x0159, 0x016f, 0x00fa, 0x0171, 0x00fc, 0x00fd, 0x0163, 0x02d9,
-00053 };
-00054 
-00055 static const USHORT usCp1251[] = {      /* Windows implementation of Cyrillic */
-00056         0x0402, 0x0403, 0x201a, 0x0453, 0x201e, 0x2026, 0x2020, 0x2021,
-00057         0x20ac, 0x2030, 0x0409, 0x2039, 0x040a, 0x040c, 0x040b, 0x040f,
-00058         0x0452, 0x2018, 0x2019, 0x201c, 0x201d, 0x2022, 0x2013, 0x2014,
-00059         0x00f3, 0x2122, 0x0459, 0x203a, 0x045a, 0x045c, 0x045b, 0x045f,
-00060         0x00a0, 0x040e, 0x045e, 0x0408, 0x00a4, 0x0490, 0x00a6, 0x00a7,
-00061         0x0401, 0x00a9, 0x0404, 0x00ab, 0x00ac, 0x00ad, 0x00ae, 0x0407,
-00062         0x00b0, 0x00b1, 0x0406, 0x0456, 0x0491, 0x00b5, 0x00b6, 0x00b7,
-00063         0x0451, 0x2116, 0x0454, 0x00bb, 0x0458, 0x0405, 0x0455, 0x0457,
-00064         0x0410, 0x0411, 0x0412, 0x0413, 0x0414, 0x0415, 0x0416, 0x0417,
-00065         0x0418, 0x0419, 0x041a, 0x041b, 0x041c, 0x041d, 0x041e, 0x041f,
-00066         0x0420, 0x0421, 0x0422, 0x0423, 0x0424, 0x0425, 0x0426, 0x0427,
-00067         0x0428, 0x0429, 0x042a, 0x042b, 0x042c, 0x042d, 0x042e, 0x042f,
-00068         0x0430, 0x0431, 0x0432, 0x0433, 0x0434, 0x0435, 0x0436, 0x0437,
-00069         0x0438, 0x0439, 0x043a, 0x043b, 0x043c, 0x043d, 0x043e, 0x043f,
-00070         0x0440, 0x0441, 0x0442, 0x0443, 0x0444, 0x0445, 0x0446, 0x0447,
-00071         0x0448, 0x0449, 0x044a, 0x044b, 0x044c, 0x044d, 0x044e, 0x044f,
-00072 };
-00073 
-00074 static const USHORT usCp1252[] = {      /* Windows implementation of Latin1 */
-00075         0x20ac, 0x003f, 0x201a, 0x0192, 0x201e, 0x2026, 0x2020, 0x2021,
-00076         0x02c6, 0x2030, 0x0160, 0x2039, 0x0152, 0x003f, 0x017d, 0x003f,
-00077         0x003f, 0x2018, 0x2019, 0x201c, 0x201d, 0x2022, 0x2013, 0x2014,
-00078         0x02dc, 0x2122, 0x0161, 0x203a, 0x0153, 0x003f, 0x017e, 0x0178,
-00079         0x00a0, 0x00a1, 0x00a2, 0x00a3, 0x00a4, 0x00a5, 0x00a6, 0x00a7,
-00080         0x00a8, 0x00a9, 0x00aa, 0x00ab, 0x00ac, 0x00ad, 0x00ae, 0x00af,
-00081         0x00b0, 0x00b1, 0x00b2, 0x00b3, 0x00b4, 0x00b5, 0x00b6, 0x00b7,
-00082         0x00b8, 0x00b9, 0x00ba, 0x00bb, 0x00bc, 0x00bd, 0x00be, 0x00bf,
-00083         0x00c0, 0x00c1, 0x00c2, 0x00c3, 0x00c4, 0x00c5, 0x00c6, 0x00c7,
-00084         0x00c8, 0x00c9, 0x00ca, 0x00cb, 0x00cc, 0x00cd, 0x00ce, 0x00cf,
-00085         0x00d0, 0x00d1, 0x00d2, 0x00d3, 0x00d4, 0x00d5, 0x00d6, 0x00d7,
-00086         0x00d8, 0x00d9, 0x00da, 0x00db, 0x00dc, 0x00dd, 0x00de, 0x00df,
-00087         0x00e0, 0x00e1, 0x00e2, 0x00e3, 0x00e4, 0x00e5, 0x00e6, 0x00e7,
-00088         0x00e8, 0x00e9, 0x00ea, 0x00eb, 0x00ec, 0x00ed, 0x00ee, 0x00ef,
-00089         0x00f0, 0x00f1, 0x00f2, 0x00f3, 0x00f4, 0x00f5, 0x00f6, 0x00f7,
-00090         0x00f8, 0x00f9, 0x00fa, 0x00fb, 0x00fc, 0x00fd, 0x00fe, 0x00ff,
-00091 };
-00092 
-00093 static const USHORT usMacRoman[] = {    /* Apple implementation of Latin1 */
-00094         0x00c4, 0x00c5, 0x00c7, 0x00c9, 0x00d1, 0x00d6, 0x00dc, 0x00e1,
-00095         0x00e0, 0x00e2, 0x00e4, 0x00e3, 0x00e5, 0x00e7, 0x00e9, 0x00e8,
-00096         0x00ea, 0x00eb, 0x00ed, 0x00ec, 0x00ee, 0x00ef, 0x00f1, 0x00f3,
-00097         0x00f2, 0x00f4, 0x00f6, 0x00f5, 0x00fa, 0x00f9, 0x00fb, 0x00fc,
-00098         0x2020, 0x00b0, 0x00a2, 0x00a3, 0x00a7, 0x2022, 0x00b6, 0x00df,
-00099         0x00ae, 0x00a9, 0x2122, 0x00b4, 0x00a8, 0x2260, 0x00c6, 0x00d8,
-00100         0x221e, 0x00b1, 0x2264, 0x2265, 0x00a5, 0x00b5, 0x2202, 0x2211,
-00101         0x220f, 0x03c0, 0x222b, 0x00aa, 0x00ba, 0x2126, 0x00e6, 0x00f8,
-00102         0x00bf, 0x00a1, 0x00ac, 0x221a, 0x0192, 0x2248, 0x2206, 0x00ab,
-00103         0x00bb, 0x2026, 0x00a0, 0x00c0, 0x00c3, 0x00d5, 0x0152, 0x0153,
-00104         0x2013, 0x2014, 0x201c, 0x201d, 0x2018, 0x2019, 0x00f7, 0x25ca,
-00105         0x00ff, 0x0178, 0x2044, 0x00a4, 0x2039, 0x203a, 0xfb01, 0xfb02,
-00106         0x2021, 0x00b7, 0x201a, 0x201e, 0x2030, 0x00c2, 0x00ca, 0x00c1,
-00107         0x00cb, 0x00c8, 0x00cd, 0x00ce, 0x00cf, 0x00cc, 0x00d3, 0x00d4,
-00108         0x003f, 0x00d2, 0x00da, 0x00db, 0x00d9, 0x0131, 0x02c6, 0x02dc,
-00109         0x00af, 0x02d8, 0x02d9, 0x02da, 0x00b8, 0x02dd, 0x02db, 0x02c7,
-00110 };
-00111 
-00112 static const USHORT usPrivateArea[] = {
-00113         0x0020, 0x0021, 0x2200, 0x0023, 0x2203, 0x0025, 0x0026, 0x220d,
-00114         0x0028, 0x0029, 0x2217, 0x002b, 0x002c, 0x2212, 0x002e, 0x002f,
-00115         0x0030, 0x0031, 0x0032, 0x0033, 0x0034, 0x0035, 0x0036, 0x0037,
-00116         0x0038, 0x0039, 0x003a, 0x003b, 0x003c, 0x2019, 0x003e, 0x003f,
-00117         0x201d, 0x201c, 0x0392, 0x03a7, 0x0394, 0x0395, 0x03a6, 0x0393,
-00118         0x0397, 0x0399, 0x03d1, 0x039a, 0x039b, 0x039c, 0x039d, 0x039f,
-00119         0x03a0, 0x0398, 0x03a1, 0x03a3, 0x03a4, 0x03a5, 0x03c2, 0x03a9,
-00120         0x039e, 0x03a8, 0x0396, 0x005b, 0x2234, 0x005d, 0x22a5, 0x005f,
-00121         0x003f, 0x03b1, 0x03b2, 0x03c7, 0x03b4, 0x03b5, 0x03c6, 0x03b3,
-00122         0x03b7, 0x03b9, 0x03d5, 0x03ba, 0x03bb, 0x03bc, 0x03bd, 0x03bf,
-00123         0x03c0, 0x03b8, 0x03c1, 0x03c3, 0x03c4, 0x03c5, 0x03d6, 0x03c9,
-00124         0x03be, 0x03c8, 0x03b6, 0x007b, 0x007c, 0x007d, 0x223c, 0x003f,
-00125         0x003f, 0x003f, 0x003f, 0x003f, 0x003f, 0x003f, 0x003f, 0x003f,
-00126         0x003f, 0x003f, 0x003f, 0x003f, 0x003f, 0x003f, 0x003f, 0x003f,
-00127         0x003f, 0x003f, 0x003f, 0x2022, 0x003f, 0x003f, 0x003f, 0x003f,
-00128         0x003f, 0x003f, 0x003f, 0x003f, 0x003f, 0x003f, 0x003f, 0x003f,
-00129         0x20ac, 0x03d2, 0x2032, 0x2264, 0x2044, 0x221e, 0x0192, 0x2663,
-00130         0x2666, 0x2665, 0x2660, 0x2194, 0x2190, 0x2191, 0x2192, 0x2193,
-00131         0x00b0, 0x00b1, 0x2033, 0x2265, 0x00d7, 0x221d, 0x2202, 0x2022,
-00132         0x00f7, 0x2260, 0x2261, 0x2248, 0x2026, 0x007c, 0x23af, 0x21b5,
-00133         0x2135, 0x2111, 0x211c, 0x2118, 0x2297, 0x2295, 0x2205, 0x2229,
-00134         0x222a, 0x2283, 0x2287, 0x2284, 0x2282, 0x2286, 0x2208, 0x2209,
-00135         0x2220, 0x2207, 0x00ae, 0x00a9, 0x2122, 0x220f, 0x221a, 0x22c5,
-00136         0x00ac, 0x2227, 0x2228, 0x21d4, 0x21d0, 0x21d1, 0x21d2, 0x21d3,
-00137         0x22c4, 0x3008, 0x00ae, 0x00a9, 0x2122, 0x2211, 0x239b, 0x239c,
-00138         0x239d, 0x23a1, 0x23a2, 0x23a3, 0x23a7, 0x23a8, 0x23a9, 0x23aa,
-00139         0x003f, 0x3009, 0x222b, 0x2320, 0x23ae, 0x2321, 0x239e, 0x239f,
-00140         0x23a0, 0x23a4, 0x23a5, 0x23a6, 0x23ab, 0x23ac, 0x23ad, 0x003f,
-00141 };
-00142 
-00143 typedef struct char_table_tag {
-00144         UCHAR   ucLocal;
-00145         USHORT  usUnicode;
-00146 } char_table_type;
-00147 
-00148 static char_table_type  atCharTable[256];
-00149 static size_t           tNextPosFree = 0;
-00150 
-00151 
-00152 /*
-00153  * iCompare - compare two records
-00154  *
-00155  * Compares two records. For use by qsort(3C) and bsearch(3C).
-00156  *
-00157  * returns -1 if rec1 < rec2, 0 if rec1 == rec2, 1 if rec1 > rec2
-00158  */
-00159 static int
-00160 iCompare(const void *pvRecord1, const void *pvRecord2)
-00161 {
-00162         USHORT  usUnicode1, usUnicode2;
-00163 
-00164         usUnicode1 = ((char_table_type *)pvRecord1)->usUnicode;
-00165         usUnicode2 = ((char_table_type *)pvRecord2)->usUnicode;
-00166 
-00167         if (usUnicode1 < usUnicode2) {
-00168                 return -1;
-00169         }
-00170         if (usUnicode1 > usUnicode2) {
-00171                 return 1;
-00172         }
-00173         return 0;
-00174 } /* end of iCompare */
-00175 
-00176 /*
-00177  * pGetCharTableRecord - get the character table record
-00178  *
-00179  * returns a pointer to the record when found, otherwise NULL
-00180  */
-00181 static const char_table_type *
-00182 pGetCharTableRecord(USHORT usUnicode)
-00183 {
-00184         char_table_type tKey;
-00185 
-00186         if (tNextPosFree == 0) {
-00187                 return NULL;
-00188         }
-00189         tKey.usUnicode = usUnicode;
-00190         tKey.ucLocal = 0;
-00191         return (char_table_type *)bsearch(&tKey,
-00192                         atCharTable,
-00193                         tNextPosFree, sizeof(atCharTable[0]),
-00194                         iCompare);
-00195 } /* end of pGetCharTableRecord */
-00196 
-00197 /*
-00198  * ucGetBulletCharacter - get the local representation of the bullet
-00199  */
-00200 UCHAR
-00201 ucGetBulletCharacter(conversion_type eConversionType, encoding_type eEncoding)
-00202 {
-00203 #if defined(__riscos)
-00204         return 0x8f;
-00205 #else
-00206         const char_table_type   *pRec;
-00207 
-00208         fail(eEncoding == encoding_utf_8);
-00209 
-00210         if (eEncoding == encoding_latin_1 &&
-00211             (eConversionType == conversion_ps ||
-00212              eConversionType == conversion_pdf)) {
-00213                 /* Ugly, but it makes the PostScript and PDF look better */
-00214                 return (UCHAR)143;
-00215         }
-00216         if (eConversionType != conversion_text &&
-00217             eConversionType != conversion_fmt_text) {
-00218                 pRec = pGetCharTableRecord(UNICODE_BULLET);
-00219                 if (pRec != NULL) {
-00220                         return pRec->ucLocal;
-00221                 }
-00222                 pRec = pGetCharTableRecord(UNICODE_BULLET_OPERATOR);
-00223                 if (pRec != NULL) {
-00224                         return pRec->ucLocal;
-00225                 }
-00226                 pRec = pGetCharTableRecord(UNICODE_MIDDLE_DOT);
-00227                 if (pRec != NULL) {
-00228                         return pRec->ucLocal;
-00229                 }
-00230         }
-00231         return (UCHAR)'.';
-00232 #endif /* __riscos */
-00233 } /* end of ucGetBulletCharacter */
-00234 
-00235 /*
-00236  * ucGetNbspCharacter - get the local representation of the non-breaking space
-00237  */
-00238 UCHAR
-00239 ucGetNbspCharacter(void)
-00240 {
-00241         const char_table_type   *pRec;
-00242 
-00243         pRec = pGetCharTableRecord(0x00a0);     /* Unicode non-breaking space */
-00244         if (pRec == NULL) {
-00245                 DBG_MSG("Non-breaking space record not found");
-00246                 /* No value found, use the best guess */
-00247                 return (UCHAR)0xa0;
-00248         }
-00249         return pRec->ucLocal;
-00250 } /* end of ucGetNbspCharacter */
-00251 
-00252 /*
-00253  * bReadCharacterMappingTable - read the mapping table
-00254  *
-00255  * Read the character mapping table from file and have the contents sorted
-00256  *
-00257  * returns TRUE if successful, otherwise FALSE
-00258  */
-00259 BOOL
-00260 bReadCharacterMappingTable(FILE *pFile)
-00261 {
-00262         char    *pcTmp;
-00263         ULONG   ulUnicode;
-00264         UINT    uiLocal;
-00265         int     iFields;
-00266         char    szLine[81];
-00267 
-00268         if (pFile == NULL) {
-00269                 return FALSE;
-00270         }
-00271 
-00272         /* Clean the table first */
-00273         (void)memset(atCharTable, 0, sizeof(atCharTable));
-00274 
-00275         /* Fill the table */
-00276         while (fgets(szLine, (int)sizeof(szLine), pFile)) {
-00277                 if (szLine[0] == '#' ||
-00278                     szLine[0] == '\r' ||
-00279                     szLine[0] == '\n') {
-00280                         /* Comment or empty line */
-00281                         continue;
-00282                 }
-00283                 iFields = sscanf(szLine, "%x %lx %*s", &uiLocal, &ulUnicode);
-00284                 if (iFields != 2) {
-00285                         pcTmp = strchr(szLine, '\r');
-00286                         if (pcTmp != NULL) {
-00287                                 *pcTmp = '\0';
-00288                         }
-00289                         pcTmp = strchr(szLine, '\n');
-00290                         if (pcTmp != NULL) {
-00291                                 *pcTmp = '\0';
-00292                         }
-00293                         werr(0, "Syntax error in: '%s'", szLine);
-00294                         continue;
-00295                 }
-00296                 if (uiLocal > 0xff || ulUnicode > 0xffff) {
-00297                         werr(0, "Syntax error in: '%02x %04lx'",
-00298                                         uiLocal, ulUnicode);
-00299                         continue;
-00300                 }
-00301                 /* Store only the relevant entries */
-00302                 if (uiLocal != ulUnicode || uiLocal >= 0x80) {
-00303                         atCharTable[tNextPosFree].ucLocal = (UCHAR)uiLocal;
-00304                         atCharTable[tNextPosFree].usUnicode = (USHORT)ulUnicode;
-00305                         tNextPosFree++;
-00306                 }
-00307                 if (tNextPosFree >= elementsof(atCharTable)) {
-00308                         werr(0, "Too many entries in the character mapping "
-00309                                 "file. Ignoring the rest.");
-00310                         break;
-00311                 }
-00312         }
-00313 
-00314         if (tNextPosFree != 0) {
-00315                 DBG_HEX(atCharTable[0].usUnicode);
-00316                 DBG_HEX(atCharTable[tNextPosFree - 1].usUnicode);
-00317 
-00318                 qsort(atCharTable,
-00319                         tNextPosFree, sizeof(atCharTable[0]),
-00320                         iCompare);
-00321 
-00322                 DBG_HEX(atCharTable[0].usUnicode);
-00323                 DBG_HEX(atCharTable[tNextPosFree - 1].usUnicode);
-00324         }
-00325 
-00326         return TRUE;
-00327 } /* end of bReadCharacterMappingTable */
-00328 
-00329 /*
-00330  * ulTranslateCharacters - Translate characters to local representation
-00331  *
-00332  * Translate all characters to local representation
-00333  *
-00334  * returns the translated character
-00335  */
-00336 ULONG
-00337 ulTranslateCharacters(USHORT usChar, ULONG ulFileOffset, int iWordVersion,
-00338         conversion_type eConversionType, encoding_type eEncoding,
-00339         BOOL bUseMacCharSet)
-00340 {
-00341         const char_table_type   *pTmp;
-00342         const USHORT    *usCharSet;
-00343 
-00344         usCharSet = NULL;
-00345         if (bUseMacCharSet) {
-00346                 /* Macintosh character set */
-00347                 usCharSet = usMacRoman;
-00348         } else if (iWordVersion == 0) {
-00349                 /* DOS character set */
-00350                 usCharSet = usCp850;
-00351         } else {
-00352                 /* Windows character set */
-00353                 switch (eEncoding) {
-00354                 case encoding_latin_2:
-00355                         usCharSet = usCp1250;
-00356                         break;
-00357                 case encoding_cyrillic:
-00358                         usCharSet = usCp1251;
-00359                         break;
-00360                 case encoding_latin_1:
-00361                 default:
-00362                         usCharSet = usCp1252;
-00363                         break;
-00364                 }
-00365         }
-00366         fail(usCharSet == NULL);
-00367         if (usChar >= 0x80 && usChar <= 0x9f) {
-00368                 /* Translate implementation defined characters */
-00369                 usChar = usCharSet[usChar - 0x80];
-00370         } else if (iWordVersion < 8 && usChar >= 0xa0 && usChar <= 0xff) {
-00371                 /* Translate old character set to Unixcode */
-00372                 usChar = usCharSet[usChar - 0x80];
-00373         }
-00374 
-00375         /* Microsoft Unicode to real Unicode */
-00376         if (usChar >= 0xf020 && usChar <= 0xf0ff) {
-00377                 DBG_HEX_C(usPrivateArea[usChar - 0xf020] == 0x003f, usChar);
-00378                 usChar = usPrivateArea[usChar - 0xf020];
-00379         }
-00380 
-00381         /* Characters with a special meaning in Word */
-00382         switch (usChar) {
-00383         case IGNORE_CHARACTER:
-00384         case FOOTNOTE_SEPARATOR:
-00385         case FOOTNOTE_CONTINUATION:
-00386         case ANNOTATION:
-00387         case FRAME:
-00388         case LINE_FEED:
-00389         case WORD_SOFT_HYPHEN:
-00390         case UNICODE_HYPHENATION_POINT:
-00391                 return IGNORE_CHARACTER;
-00392         case PICTURE:
-00393         case TABLE_SEPARATOR:
-00394         case TAB:
-00395         case HARD_RETURN:
-00396         case PAGE_BREAK:
-00397         case PAR_END:
-00398         case COLUMN_FEED:
-00399                 return (ULONG)usChar;
-00400         case FOOTNOTE_OR_ENDNOTE:
-00401                 NO_DBG_HEX(ulFileOffset);
-00402                 switch (eGetNotetype(ulFileOffset)) {
-00403                 case notetype_is_footnote:
-00404                         return FOOTNOTE_CHAR;
-00405                 case notetype_is_endnote:
-00406                         return ENDNOTE_CHAR;
-00407                 default:
-00408                         return UNKNOWN_NOTE_CHAR;
-00409                 }
-00410         case WORD_UNBREAKABLE_JOIN:
-00411                 return (ULONG)OUR_UNBREAKABLE_JOIN;
-00412         default:
-00413                 break;
-00414         }
-00415 
-00416         if (eEncoding != encoding_utf_8) {
-00417                 /* Latin characters in an oriental text */
-00418                 if (usChar >= 0xff01 && usChar <= 0xff5e) {
-00419                         usChar -= 0xfee0;
-00420                 }
-00421         }
-00422 
-00423         if (eEncoding == encoding_latin_1 &&
-00424             (eConversionType == conversion_ps ||
-00425              eConversionType == conversion_pdf)) {
-00426                 /* Ugly, but it makes the PostScript and PDF look better */
-00427                 switch (usChar) {
-00428                 case UNICODE_ELLIPSIS:
-00429                         return 140;
-00430                 case UNICODE_TRADEMARK_SIGN:
-00431                         return 141;
-00432                 case UNICODE_PER_MILLE_SIGN:
-00433                         return 142;
-00434                 case UNICODE_BULLET:
-00435                 case UNICODE_BULLET_OPERATOR:
-00436                 case UNICODE_BLACK_CLUB_SUIT:
-00437                         return 143;
-00438                 case UNICODE_LEFT_SINGLE_QMARK:
-00439                         return 144;
-00440                 case UNICODE_RIGHT_SINGLE_QMARK:
-00441                         return 145;
-00442                 case UNICODE_SINGLE_LEFT_ANGLE_QMARK:
-00443                         return 146;
-00444                 case UNICODE_SINGLE_RIGHT_ANGLE_QMARK:
-00445                         return 147;
-00446                 case UNICODE_LEFT_DOUBLE_QMARK:
-00447                         return 148;
-00448                 case UNICODE_RIGHT_DOUBLE_QMARK:
-00449                         return 149;
-00450                 case UNICODE_DOUBLE_LOW_9_QMARK:
-00451                         return 150;
-00452                 case UNICODE_EN_DASH:
-00453                         return 151;
-00454                 case UNICODE_EM_DASH:
-00455                         return 152;
-00456                 case UNICODE_MINUS_SIGN:
-00457                         return 153;
-00458                 case UNICODE_CAPITAL_LIGATURE_OE:
-00459                         return 154;
-00460                 case UNICODE_SMALL_LIGATURE_OE:
-00461                         return 155;
-00462                 case UNICODE_DAGGER:
-00463                         return 156;
-00464                 case UNICODE_DOUBLE_DAGGER:
-00465                         return 157;
-00466                 case UNICODE_SMALL_LIGATURE_FI:
-00467                         return 158;
-00468                 case UNICODE_SMALL_LIGATURE_FL:
-00469                         return 159;
-00470                 default:
-00471                         break;
-00472                 }
-00473         }
-00474 
-00475         if (eConversionType == conversion_pdf) {
-00476                 if (eEncoding == encoding_latin_1) {
-00477                         switch (usChar) {
-00478                         case UNICODE_EURO_SIGN:
-00479                                 return 128;
-00480                         default:
-00481                                 break;
-00482                         }
-00483                 } else if (eEncoding == encoding_latin_2) {
-00484                         switch (usChar) {
-00485                         case UNICODE_CAPITAL_D_WITH_STROKE:
-00486                         case UNICODE_SMALL_D_WITH_STROKE:
-00487                                 return 0x3f;
-00488                         default:
-00489                                 break;
-00490                         }
-00491                 }
-00492         }
-00493 
-00494         if (usChar < 0x80) {
-00495                 /* US ASCII */
-00496                 if (usChar < 0x20 || usChar == 0x7f) {
-00497                         /* Ignore control characters */
-00498                         DBG_HEX(usChar);
-00499                         DBG_FIXME();
-00500                         return IGNORE_CHARACTER;
-00501                 }
-00502                 return (ULONG)usChar;
-00503         }
-00504 
-00505         if (eEncoding == encoding_utf_8) {
-00506                 /* No need to convert Unicode characters */
-00507                 return (ULONG)usChar;
-00508         }
-00509 
-00510         /* Unicode to local representation */
-00511         pTmp = pGetCharTableRecord(usChar);
-00512         if (pTmp != NULL) {
-00513                 DBG_HEX_C(usChar >= 0x7f && usChar <= 0x9f, usChar);
-00514                 return (ULONG)pTmp->ucLocal;
-00515         }
-00516 
-00517         /* Fancy characters to simple US ASCII */
-00518         switch (usChar) {
-00519         case UNICODE_SMALL_F_HOOK:
-00520                 return (ULONG)'f';
-00521         case UNICODE_GREEK_CAPITAL_CHI:
-00522                 return (ULONG)'X';
-00523         case UNICODE_GREEK_SMALL_UPSILON:
-00524                 return (ULONG)'v';
-00525         case UNICODE_MODIFIER_CIRCUMFLEX:
-00526         case UNICODE_UPWARDS_ARROW:
-00527                 return (ULONG)'^';
-00528         case UNICODE_SMALL_TILDE:
-00529         case UNICODE_TILDE_OPERATOR:
-00530                 return (ULONG)'~';
-00531         case UNICODE_EN_QUAD:
-00532         case UNICODE_EM_QUAD:
-00533         case UNICODE_EN_SPACE:
-00534         case UNICODE_EM_SPACE:
-00535         case UNICODE_THREE_PER_EM_SPACE:
-00536         case UNICODE_FOUR_PER_EM_SPACE:
-00537         case UNICODE_SIX_PER_EM_SPACE:
-00538         case UNICODE_FIGURE_SPACE:
-00539         case UNICODE_PUNCTUATION_SPACE:
-00540         case UNICODE_THIN_SPACE:
-00541         case UNICODE_NARROW_NO_BREAK_SPACE:
-00542         case UNICODE_LIGHT_SHADE:
-00543         case UNICODE_MEDIUM_SHADE:
-00544         case UNICODE_DARK_SHADE:
-00545                 return (ULONG)' ';
-00546         case UNICODE_LEFT_DOUBLE_QMARK:
-00547         case UNICODE_RIGHT_DOUBLE_QMARK:
-00548         case UNICODE_DOUBLE_LOW_9_QMARK:
-00549         case UNICODE_DOUBLE_HIGH_REV_9_QMARK:
-00550         case UNICODE_DOUBLE_PRIME:
-00551                 return (ULONG)'"';
-00552         case UNICODE_LEFT_SINGLE_QMARK:
-00553         case UNICODE_RIGHT_SINGLE_QMARK:
-00554         case UNICODE_SINGLE_LOW_9_QMARK:
-00555         case UNICODE_SINGLE_HIGH_REV_9_QMARK:
-00556         case UNICODE_PRIME:
-00557                 return (ULONG)'\'';
-00558         case UNICODE_HYPHEN:
-00559         case UNICODE_NON_BREAKING_HYPHEN:
-00560         case UNICODE_FIGURE_DASH:
-00561         case UNICODE_EN_DASH:
-00562         case UNICODE_EM_DASH:
-00563         case UNICODE_HORIZONTAL_BAR:
-00564         case UNICODE_MINUS_SIGN:
-00565         case UNICODE_BD_LIGHT_HORIZONTAL:
-00566         case UNICODE_BD_DOUBLE_HORIZONTAL:
-00567                 return (ULONG)'-';
-00568         case UNICODE_DOUBLE_VERTICAL_LINE:
-00569         case UNICODE_BD_LIGHT_VERTICAL:
-00570         case UNICODE_BD_DOUBLE_VERTICAL:
-00571                 return (ULONG)'|';
-00572         case UNICODE_DOUBLE_LOW_LINE:
-00573                 return (ULONG)'_';
-00574         case UNICODE_DAGGER:
-00575                 return (ULONG)'+';
-00576         case UNICODE_DOUBLE_DAGGER:
-00577                 return (ULONG)'#';
-00578         case UNICODE_BULLET:
-00579         case UNICODE_BULLET_OPERATOR:
-00580         case UNICODE_BLACK_CLUB_SUIT:
-00581                 return (ULONG)ucGetBulletCharacter(eConversionType, eEncoding);
-00582         case UNICODE_ONE_DOT_LEADER:
-00583         case UNICODE_TWO_DOT_LEADER:
-00584                 return (ULONG)'.';
-00585         case UNICODE_ELLIPSIS:
-00586 #if defined(__riscos)
-00587                 return (ULONG)OUR_ELLIPSIS;
-00588 #else
-00589                 if (ulFileOffset == 0) {
-00590                         return (ULONG)OUR_ELLIPSIS;
-00591                 }
-00592                 return UNICODE_ELLIPSIS;
-00593 #endif /* __riscos */
-00594         case UNICODE_DOUBLE_LEFT_ANGLE_QMARK:
-00595         case UNICODE_TRIANGULAR_BULLET:
-00596         case UNICODE_SINGLE_LEFT_ANGLE_QMARK:
-00597         case UNICODE_LEFTWARDS_ARROW:
-00598                 return (ULONG)'<';
-00599         case UNICODE_DOUBLE_RIGHT_ANGLE_QMARK:
-00600         case UNICODE_SINGLE_RIGHT_ANGLE_QMARK:
-00601         case UNICODE_RIGHTWARDS_ARROW:
-00602                 return (ULONG)'>';
-00603         case UNICODE_UNDERTIE:
-00604                 return (ULONG)'-';
-00605         case UNICODE_N_ARY_SUMMATION:
-00606                 return (ULONG)'S';
-00607         case UNICODE_EURO_SIGN:
-00608                 return (ULONG)'E';
-00609         case UNICODE_CIRCLE:
-00610         case UNICODE_SQUARE:
-00611                 return (ULONG)'O';
-00612         case UNICODE_DIAMOND:
-00613                 return (ULONG)OUR_DIAMOND;
-00614         case UNICODE_NUMERO_SIGN:
-00615                 return (ULONG)'N';
-00616         case UNICODE_KELVIN_SIGN:
-00617                 return (ULONG)'K';
-00618         case UNICODE_DOWNWARDS_ARROW:
-00619                 return (ULONG)'v';
-00620         case UNICODE_FRACTION_SLASH:
-00621         case UNICODE_DIVISION_SLASH:
-00622                 return (ULONG)'/';
-00623         case UNICODE_ASTERISK_OPERATOR:
-00624                 return (ULONG)'*';
-00625         case UNICODE_RATIO:
-00626                 return (ULONG)':';
-00627         case UNICODE_BD_LIGHT_DOWN_RIGHT:
-00628         case UNICODE_BD_LIGHT_DOWN_AND_LEFT:
-00629         case UNICODE_BD_LIGHT_UP_AND_RIGHT:
-00630         case UNICODE_BD_LIGHT_UP_AND_LEFT:
-00631         case UNICODE_BD_LIGHT_VERTICAL_AND_RIGHT:
-00632         case UNICODE_BD_LIGHT_VERTICAL_AND_LEFT:
-00633         case UNICODE_BD_LIGHT_DOWN_AND_HORIZONTAL:
-00634         case UNICODE_BD_LIGHT_UP_AND_HORIZONTAL:
-00635         case UNICODE_BD_LIGHT_VERTICAL_AND_HORIZONTAL:
-00636         case UNICODE_BD_DOUBLE_DOWN_AND_RIGHT:
-00637         case UNICODE_BD_DOUBLE_DOWN_AND_LEFT:
-00638         case UNICODE_BD_DOUBLE_UP_AND_RIGHT:
-00639         case UNICODE_BD_DOUBLE_UP_AND_LEFT:
-00640         case UNICODE_BD_DOUBLE_VERTICAL_AND_RIGHT:
-00641         case UNICODE_BD_DOUBLE_VERTICAL_AND_LEFT:
-00642         case UNICODE_BD_DOUBLE_DOWN_AND_HORIZONTAL:
-00643         case UNICODE_BD_DOUBLE_UP_AND_HORIZONTAL:
-00644         case UNICODE_BD_DOUBLE_VERTICAL_AND_HORIZONTAL:
-00645         case UNICODE_BLACK_SQUARE:
-00646                 return (ULONG)'+';
-00647         case UNICODE_HAIR_SPACE:
-00648         case UNICODE_ZERO_WIDTH_SPACE:
-00649         case UNICODE_ZERO_WIDTH_NON_JOINER:
-00650         case UNICODE_ZERO_WIDTH_JOINER:
-00651         case UNICODE_LEFT_TO_RIGHT_MARK:
-00652         case UNICODE_RIGHT_TO_LEFT_MARK:
-00653         case UNICODE_LEFT_TO_RIGHT_EMBEDDING:
-00654         case UNICODE_RIGHT_TO_LEFT_EMBEDDING:
-00655         case UNICODE_POP_DIRECTIONAL_FORMATTING:
-00656         case UNICODE_LEFT_TO_RIGHT_OVERRIDE:
-00657         case UNICODE_RIGHT_TO_LEFT_OVERRIDE:
-00658         case UNICODE_ZERO_WIDTH_NO_BREAK_SPACE:
-00659                 return IGNORE_CHARACTER;
-00660         default:
-00661                 break;
-00662         }
-00663 
-00664         if (usChar == UNICODE_TRADEMARK_SIGN) {
-00665                 /*
-00666                  * No local representation, it doesn't look like anything in
-00667                  * US-ASCII and a question mark does more harm than good.
-00668                  */
-00669                 return IGNORE_CHARACTER;
-00670         }
-00671 
-00672         if (usChar >= 0xa0 && usChar <= 0xff) {
-00673                 /* Before Word 97, Word did't use Unicode */
-00674                 return (ULONG)usChar;
-00675         }
-00676 
-00677         DBG_HEX_C(usChar < 0x3000 || usChar >= 0xd800, ulFileOffset);
-00678         DBG_HEX_C(usChar < 0x3000 || usChar >= 0xd800, usChar);
-00679         DBG_MSG_C(usChar >= 0xe000 && usChar < 0xf900, "Private Use Area");
-00680 
-00681         /* Untranslated Unicode character */
-00682         return 0x3f;
-00683 } /* end of ulTranslateCharacters */
-00684 
-00685 /*
-00686  * ulToUpper - convert letter to upper case
-00687  *
-00688  * This function converts a letter to upper case. Unlike toupper(3) this
-00689  * function is independent from the settings of locale. This comes in handy
-00690  * for people who have to read Word documents in more than one language or
-00691  * contain more than one language.
-00692  *
-00693  * returns the converted letter, or ulChar if the conversion was not possible.
-00694  */
-00695 ULONG
-00696 ulToUpper(ULONG ulChar)
-00697 {
-00698         if (ulChar < 0x80) {
-00699                 /* US ASCII: use standard function */
-00700                 return (ULONG)toupper((int)ulChar);
-00701         }
-00702         if (ulChar >= 0xe0 && ulChar <= 0xfe && ulChar != 0xf7) {
-00703                 /*
-00704                  * Lower case accented characters
-00705                  * 0xf7 is Division sign; 0xd7 is Multiplication sign
-00706                  * 0xff is y with diaeresis; 0xdf is Sharp s
-00707                  */
-00708                 return ulChar & ~0x20;
-00709         }
-00710 #if defined(__STDC_ISO_10646__)
-00711         /*
-00712          * If this is ISO C99 and all locales have wchar_t = ISO 10646
-00713          * (e.g., glibc 2.2 or newer), then use standard function
-00714          */
-00715         if (ulChar > 0xff) {
-00716                 return (ULONG)towupper((wint_t)ulChar);
-00717         }
-00718 #endif /* __STDC_ISO_10646__ */
-00719         return ulChar;
-00720 } /* end of ulToUpper */
-
-
Generated by  - -doxygen 1.6.2
- - diff -r 59758314f811 -r d4524d6a4472 Symbian3/Examples/guid-6013a680-57f9-415b-8851-c4fa63356636/datalist_8c_source.html --- a/Symbian3/Examples/guid-6013a680-57f9-415b-8851-c4fa63356636/datalist_8c_source.html Fri Jun 11 15:24:34 2010 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,390 +0,0 @@ - - - - -TB9.2 Example Applications: examples/PIPS/antiword/src/datalist.c Source File - - - - - -

examples/PIPS/antiword/src/datalist.c

00001 /*
-00002  * datalist.c
-00003  * Copyright (C) 2000-2002 A.J. van Os; Released under GPL
-00004  *
-00005  * Description:
-00006  * Build, read and destroy a list of Word data blocks
-00007  */
-00008 
-00009 #include <stdlib.h>
-00010 #include <errno.h>
-00011 #include "antiword.h"
-00012 
-00013 #if defined(__riscos)
-00014 #define EIO             42
-00015 #endif /* __riscos */
-00016 
-00017 
-00018 /*
-00019  * Private structure to hide the way the information
-00020  * is stored from the rest of the program
-00021  */
-00022 typedef struct data_mem_tag {
-00023         data_block_type         tInfo;
-00024         struct data_mem_tag     *pNext;
-00025 } data_mem_type;
-00026 
-00027 /* Variable to describe the start of the data block list */
-00028 static data_mem_type    *pAnchor = NULL;
-00029 /* Variable needed to read the data block list */
-00030 static data_mem_type    *pBlockLast = NULL;
-00031 /* Variable needed to read the data block list */
-00032 static data_mem_type    *pBlockCurrent = NULL;
-00033 static ULONG    ulBlockOffset = 0;
-00034 static size_t   tByteNext = 0;
-00035 /* Last block read */
-00036 static UCHAR    aucBlock[BIG_BLOCK_SIZE];
-00037 
-00038 
-00039 /*
-00040  * vDestroyDataBlockList - destroy the data block list
-00041  */
-00042 void
-00043 vDestroyDataBlockList(void)
-00044 {
-00045         data_mem_type   *pCurr, *pNext;
-00046 
-00047         DBG_MSG("vDestroyDataBlockList");
-00048 
-00049         pCurr = pAnchor;
-00050         while (pCurr != NULL) {
-00051                 pNext = pCurr->pNext;
-00052                 pCurr = xfree(pCurr);
-00053                 pCurr = pNext;
-00054         }
-00055         pAnchor = NULL;
-00056         /* Reset all the control variables */
-00057         pBlockLast = NULL;
-00058         pBlockCurrent = NULL;
-00059         ulBlockOffset = 0;
-00060         tByteNext = 0;
-00061 } /* end of vDestroyDataBlockList */
-00062 
-00063 /*
-00064  * bAdd2DataBlockList - add an element to the data block list
-00065  *
-00066  * Returns TRUE when successful, otherwise FALSE
-00067  */
-00068 BOOL
-00069 bAdd2DataBlockList(const data_block_type *pDataBlock)
-00070 {
-00071         data_mem_type   *pListMember;
-00072 
-00073         fail(pDataBlock == NULL);
-00074         fail(pDataBlock->ulFileOffset == FC_INVALID);
-00075         fail(pDataBlock->ulDataPos == CP_INVALID);
-00076         fail(pDataBlock->ulLength == 0);
-00077 
-00078         NO_DBG_MSG("bAdd2DataBlockList");
-00079         NO_DBG_HEX(pDataBlock->ulFileOffset);
-00080         NO_DBG_HEX(pDataBlock->ulDataPos);
-00081         NO_DBG_HEX(pDataBlock->ulLength);
-00082 
-00083         if (pDataBlock->ulFileOffset == FC_INVALID ||
-00084             pDataBlock->ulDataPos == CP_INVALID ||
-00085             pDataBlock->ulLength == 0) {
-00086                 werr(0, "Software (datablock) error");
-00087                 return FALSE;
-00088         }
-00089         /* Check for continuous blocks */
-00090         if (pBlockLast != NULL &&
-00091             pBlockLast->tInfo.ulFileOffset +
-00092              pBlockLast->tInfo.ulLength == pDataBlock->ulFileOffset &&
-00093             pBlockLast->tInfo.ulDataPos +
-00094              pBlockLast->tInfo.ulLength == pDataBlock->ulDataPos) {
-00095                 /* These are continous blocks */
-00096                 pBlockLast->tInfo.ulLength += pDataBlock->ulLength;
-00097                 return TRUE;
-00098         }
-00099         /* Make a new block */
-00100         pListMember = xmalloc(sizeof(data_mem_type));
-00101         /* Add the block to the data list */
-00102         pListMember->tInfo = *pDataBlock;
-00103         pListMember->pNext = NULL;
-00104         if (pAnchor == NULL) {
-00105                 pAnchor = pListMember;
-00106         } else {
-00107                 fail(pBlockLast == NULL);
-00108                 pBlockLast->pNext = pListMember;
-00109         }
-00110         pBlockLast = pListMember;
-00111         return TRUE;
-00112 } /* end of bAdd2DataBlockList */
-00113 
-00114 /*
-00115  * ulGetDataOffset - get the offset in the data block list
-00116  *
-00117  * Get the fileoffset the current position in the data block list
-00118  */
-00119 ULONG
-00120 ulGetDataOffset(FILE *pFile)
-00121 {
-00122         return pBlockCurrent->tInfo.ulFileOffset + ulBlockOffset + tByteNext;
-00123 } /* end of ulGetDataOffset */
-00124 
-00125 /*
-00126  * bSetDataOffset - set the offset in the data block list
-00127  *
-00128  * Make the given fileoffset the current position in the data block list
-00129  */
-00130 BOOL
-00131 bSetDataOffset(FILE *pFile, ULONG ulFileOffset)
-00132 {
-00133         data_mem_type   *pCurr;
-00134         size_t  tReadLen;
-00135 
-00136         DBG_HEX(ulFileOffset);
-00137 
-00138         for (pCurr = pAnchor; pCurr != NULL; pCurr = pCurr->pNext) {
-00139                 if (ulFileOffset < pCurr->tInfo.ulFileOffset ||
-00140                     ulFileOffset >= pCurr->tInfo.ulFileOffset +
-00141                      pCurr->tInfo.ulLength) {
-00142                         /* The file offset is not in this block */
-00143                         continue;
-00144                 }
-00145                 /* Compute the maximum number of bytes to read */
-00146                 tReadLen = (size_t)(pCurr->tInfo.ulFileOffset +
-00147                                 pCurr->tInfo.ulLength -
-00148                                 ulFileOffset);
-00149                 /* Compute the real number of bytes to read */
-00150                 if (tReadLen > sizeof(aucBlock)) {
-00151                         tReadLen = sizeof(aucBlock);
-00152                 }
-00153                 /* Read the bytes */
-00154                 if (!bReadBytes(aucBlock, tReadLen, ulFileOffset, pFile)) {
-00155                         return FALSE;
-00156                 }
-00157                 /* Set the control variables */
-00158                 pBlockCurrent = pCurr;
-00159                 ulBlockOffset = ulFileOffset - pCurr->tInfo.ulFileOffset;
-00160                 tByteNext = 0;
-00161                 return TRUE;
-00162         }
-00163         return FALSE;
-00164 } /* end of bSetDataOffset */
-00165 
-00166 /*
-00167  * iNextByte - get the next byte from the data block list
-00168  */
-00169 int
-00170 iNextByte(FILE *pFile)
-00171 {
-00172         ULONG   ulReadOff;
-00173         size_t  tReadLen;
-00174 
-00175         fail(pBlockCurrent == NULL);
-00176 
-00177         if (tByteNext >= sizeof(aucBlock) ||
-00178             ulBlockOffset + tByteNext >= pBlockCurrent->tInfo.ulLength) {
-00179                 if (ulBlockOffset + sizeof(aucBlock) <
-00180                                         pBlockCurrent->tInfo.ulLength) {
-00181                         /* Same block, next part */
-00182                         ulBlockOffset += sizeof(aucBlock);
-00183                 } else {
-00184                         /* Next block, first part */
-00185                         pBlockCurrent = pBlockCurrent->pNext;
-00186                         ulBlockOffset = 0;
-00187                 }
-00188                 if (pBlockCurrent == NULL) {
-00189                         /* Past the last part of the last block */
-00190                         errno = EIO;
-00191                         return EOF;
-00192                 }
-00193                 tReadLen = (size_t)
-00194                                 (pBlockCurrent->tInfo.ulLength - ulBlockOffset);
-00195                 if (tReadLen > sizeof(aucBlock)) {
-00196                         tReadLen = sizeof(aucBlock);
-00197                 }
-00198                 ulReadOff = pBlockCurrent->tInfo.ulFileOffset + ulBlockOffset;
-00199                 if (!bReadBytes(aucBlock, tReadLen, ulReadOff, pFile)) {
-00200                         errno = EIO;
-00201                         return EOF;
-00202                 }
-00203                 tByteNext = 0;
-00204         }
-00205         return (int)aucBlock[tByteNext++];
-00206 } /* end of iNextByte */
-00207 
-00208 /*
-00209  * usNextWord - get the next word from the data block list
-00210  *
-00211  * Read a two byte value in Little Endian order, that means MSB last
-00212  *
-00213  * All return values can be valid so errno is set in case of error
-00214  */
-00215 USHORT
-00216 usNextWord(FILE *pFile)
-00217 {
-00218         USHORT  usLSB, usMSB;
-00219 
-00220         usLSB = (USHORT)iNextByte(pFile);
-00221         if (usLSB == (USHORT)EOF) {
-00222                 errno = EIO;
-00223                 return (USHORT)EOF;
-00224         }
-00225         usMSB = (USHORT)iNextByte(pFile);
-00226         if (usMSB == (USHORT)EOF) {
-00227                 DBG_MSG("usNextWord: Unexpected EOF");
-00228                 errno = EIO;
-00229                 return (USHORT)EOF;
-00230         }
-00231         return (usMSB << 8) | usLSB;
-00232 } /* end of usNextWord */
-00233 
-00234 /*
-00235  * ulNextLong - get the next long from the data block list
-00236  *
-00237  * Read a four byte value in Little Endian order, that means MSW last
-00238  *
-00239  * All return values can be valid so errno is set in case of error
-00240  */
-00241 ULONG
-00242 ulNextLong(FILE *pFile)
-00243 {
-00244         ULONG   ulLSW, ulMSW;
-00245 
-00246         ulLSW = (ULONG)usNextWord(pFile);
-00247         if (ulLSW == (ULONG)EOF) {
-00248                 errno = EIO;
-00249                 return (ULONG)EOF;
-00250         }
-00251         ulMSW = (ULONG)usNextWord(pFile);
-00252         if (ulMSW == (ULONG)EOF) {
-00253                 DBG_MSG("ulNextLong: Unexpected EOF");
-00254                 errno = EIO;
-00255                 return (ULONG)EOF;
-00256         }
-00257         return (ulMSW << 16) | ulLSW;
-00258 } /* end of ulNextLong */
-00259 
-00260 /*
-00261  * usNextWordBE - get the next two byte value
-00262  *
-00263  * Read a two byte value in Big Endian order, that means MSB first
-00264  *
-00265  * All return values can be valid so errno is set in case of error
-00266  */
-00267 USHORT
-00268 usNextWordBE(FILE *pFile)
-00269 {
-00270         USHORT usLSB, usMSB;
-00271 
-00272         usMSB = (USHORT)iNextByte(pFile);
-00273         if (usMSB == (USHORT)EOF) {
-00274                 errno = EIO;
-00275                 return (USHORT)EOF;
-00276         }
-00277         usLSB = (USHORT)iNextByte(pFile);
-00278         if (usLSB == (USHORT)EOF) {
-00279                 DBG_MSG("usNextWordBE: Unexpected EOF");
-00280                 errno = EIO;
-00281                 return (USHORT)EOF;
-00282         }
-00283         return (usMSB << 8) | usLSB;
-00284 } /* end of usNextWordBE */
-00285 
-00286 /*
-00287  * ulNextLongBE - get the next four byte value
-00288  *
-00289  * Read a four byte value in Big Endian order, that means MSW first
-00290  *
-00291  * All return values can be valid so errno is set in case of error
-00292  */
-00293 ULONG
-00294 ulNextLongBE(FILE *pFile)
-00295 {
-00296         ULONG   ulLSW, ulMSW;
-00297 
-00298         ulMSW = (ULONG)usNextWordBE(pFile);
-00299         if (ulMSW == (ULONG)EOF) {
-00300                 errno = EIO;
-00301                 return (ULONG)EOF;
-00302         }
-00303         ulLSW = (ULONG)usNextWordBE(pFile);
-00304         if (ulLSW == (ULONG)EOF) {
-00305                 DBG_MSG("ulNextLongBE: Unexpected EOF");
-00306                 errno = EIO;
-00307                 return (ULONG)EOF;
-00308         }
-00309         return (ulMSW << 16) | ulLSW;
-00310 } /* end of ulNextLongBE */
-00311 
-00312 /*
-00313  * tSkipBytes - skip over the given number of bytes
-00314  *
-00315  * Returns the number of skipped bytes
-00316  */
-00317 size_t
-00318 tSkipBytes(FILE *pFile, size_t tToSkip)
-00319 {
-00320         size_t  tToGo, tMaxMove, tMove;
-00321 
-00322         fail(pFile == NULL);
-00323         fail(pBlockCurrent == NULL);
-00324 
-00325         tToGo = tToSkip;
-00326         while (tToGo != 0) {
-00327                 /* Goto the end of the current block */
-00328                 tMaxMove = min(sizeof(aucBlock) - tByteNext,
-00329                                 (size_t)(pBlockCurrent->tInfo.ulLength -
-00330                                 ulBlockOffset - tByteNext));
-00331                 tMove = min(tMaxMove, tToGo);
-00332                 tByteNext += tMove;
-00333                 tToGo -= tMove;
-00334                 if (tToGo != 0) {
-00335                         /* Goto the next block */
-00336                         if (iNextByte(pFile) == EOF) {
-00337                                 return tToSkip - tToGo;
-00338                         }
-00339                         tToGo--;
-00340                 }
-00341         }
-00342         return tToSkip;
-00343 } /* end of tSkipBytes */
-00344 
-00345 /*
-00346  * Translate  a data position to an offset in the file.
-00347  * Logical to physical offset.
-00348  *
-00349  * Returns:     FC_INVALID: in case of error
-00350  *              otherwise: the computed file offset
-00351  */
-00352 ULONG
-00353 ulDataPos2FileOffset(ULONG ulDataPos)
-00354 {
-00355         data_mem_type   *pCurr;
-00356 
-00357         fail(ulDataPos == CP_INVALID);
-00358 
-00359         for (pCurr = pAnchor; pCurr != NULL; pCurr = pCurr->pNext) {
-00360                 if (ulDataPos < pCurr->tInfo.ulDataPos ||
-00361                     ulDataPos >= pCurr->tInfo.ulDataPos +
-00362                      pCurr->tInfo.ulLength) {
-00363                         /* The data offset is not in this block, try the next */
-00364                         continue;
-00365                 }
-00366                 /* The data offset is in the current block */
-00367                 return pCurr->tInfo.ulFileOffset +
-00368                                 ulDataPos -
-00369                                 pCurr->tInfo.ulDataPos;
-00370         }
-00371         /* Passed beyond the end of the list */
-00372         DBG_HEX_C(ulDataPos != 0, ulDataPos);
-00373         return FC_INVALID;
-00374 } /* end of ulDataPos2FileOffset */
-
-
Generated by  - -doxygen 1.6.2
- - diff -r 59758314f811 -r d4524d6a4472 Symbian3/Examples/guid-6013a680-57f9-415b-8851-c4fa63356636/debug_8h_source.html --- a/Symbian3/Examples/guid-6013a680-57f9-415b-8851-c4fa63356636/debug_8h_source.html Fri Jun 11 15:24:34 2010 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,133 +0,0 @@ - - - - -TB9.2 Example Applications: examples/PIPS/antiword/inc/debug.h Source File - - - - - -

examples/PIPS/antiword/inc/debug.h

00001 /*
-00002  * debug.h
-00003  * Copyright (C) 1998-2005 A.J. van Os; Released under GPL
-00004  *
-00005  * Description:
-00006  * Macro's for debuging.
-00007  */
-00008 
-00009 #if !defined(__debug_h)
-00010 #define __debug_h 1
-00011 
-00012 #include <stdio.h>
-00013 #include <ctype.h>
-00014 
-00015 #if defined(DEBUG)
-00016 
-00017 #define DBG_MSG(t)      (void)fprintf(stderr,\
-00018                                 "%s[%3d]: %.240s\n",\
-00019                                 __FILE__, __LINE__, (t))
-00020 
-00021 #define DBG_STRN(t,m)   (void)fprintf(stderr,\
-00022                                 "%s[%3d]: %d '%.*s'\n",\
-00023                                 __FILE__, __LINE__,\
-00024                                 (int)(m), (int)(m), (const char *)(t))
-00025 
-00026 #define DBG_CHR(m)    (void)fprintf(stderr,\
-00027                                 "%s[%3d]: "#m" = %3d 0x%02x '%c'\n",\
-00028                                 __FILE__, __LINE__,\
-00029                                 (int)(m), (unsigned int)(unsigned char)(m),\
-00030                                 isprint((int)(unsigned char)(m))?(char)(m):' ')
-00031 
-00032 #define DBG_DEC(m)      (void)fprintf(stderr,\
-00033                                 "%s[%3d]: "#m" = %ld\n",\
-00034                                 __FILE__, __LINE__, (long)(m))
-00035 
-00036 #define DBG_HEX(m)      (void)fprintf(stderr,\
-00037                                 "%s[%3d]: "#m" = 0x%02lx\n",\
-00038                                 __FILE__, __LINE__, (unsigned long)(m))
-00039 
-00040 #define DBG_FLT(m)      (void)fprintf(stderr,\
-00041                                 "%s[%3d]: "#m" = %.3f\n",\
-00042                                 __FILE__, __LINE__, (double)(m))
-00043 
-00044 #define DBG_FIXME()     (void)fprintf(stderr,\
-00045                                 "%s[%3d]: FIXME\n",\
-00046                                 __FILE__, __LINE__)
-00047 
-00048 #define DBG_PRINT_BLOCK(b,m)    vPrintBlock(__FILE__, __LINE__,(b),(m))
-00049 #define DBG_UNICODE(t)          vPrintUnicode(__FILE__, __LINE__,\
-00050                                         (const UCHAR *)(t),unilen(t))
-00051 #define DBG_UNICODE_N(t,m)      vPrintUnicode(__FILE__, __LINE__,\
-00052                                         (const UCHAR *)(t),(m))
-00053 
-00054 #define DBG_MSG_C(c,t)          do { if (c) DBG_MSG(t); } while(0)
-00055 #define DBG_STRN_C(c,t,m)       do { if (c) DBG_STRN(t,m); } while(0)
-00056 #define DBG_CHR_C(c,m)          do { if (c) DBG_CHR(m); } while(0)
-00057 #define DBG_DEC_C(c,m)          do { if (c) DBG_DEC(m); } while(0)
-00058 #define DBG_HEX_C(c,m)          do { if (c) DBG_HEX(m); } while(0)
-00059 #define DBG_FLT_C(c,m)          do { if (c) DBG_FLT(m); } while(0)
-00060 
-00061 #else
-00062 
-00063 #define DBG_MSG(t)              /* EMPTY */
-00064 #define DBG_STRN(t,m)           /* EMPTY */
-00065 #define DBG_CHR(m)              /* EMPTY */
-00066 #define DBG_DEC(m)              /* EMPTY */
-00067 #define DBG_HEX(m)              /* EMPTY */
-00068 #define DBG_FLT(m)              /* EMPTY */
-00069 
-00070 #define DBG_FIXME()             /* EMPTY */
-00071 #define DBG_PRINT_BLOCK(b,m)    /* EMPTY */
-00072 #define DBG_UNICODE(t)          /* EMPTY */
-00073 #define DBG_UNICODE_N(t,m)      /* EMPTY */
-00074 
-00075 #define DBG_MSG_C(c,t)          /* EMPTY */
-00076 #define DBG_STRN_C(c,t,m)       /* EMPTY */
-00077 #define DBG_CHR_C(c,m)          /* EMPTY */
-00078 #define DBG_DEC_C(c,m)          /* EMPTY */
-00079 #define DBG_HEX_C(c,m)          /* EMPTY */
-00080 #define DBG_FLT_C(c,m)          /* EMPTY */
-00081 
-00082 #endif /* DEBUG */
-00083 
-00084 #define NO_DBG_MSG(t)           /* EMPTY */
-00085 #define NO_DBG_STRN(t,m)        /* EMPTY */
-00086 #define NO_DBG_CHR(m)           /* EMPTY */
-00087 #define NO_DBG_DEC(m)           /* EMPTY */
-00088 #define NO_DBG_HEX(m)           /* EMPTY */
-00089 #define NO_DBG_FLT(m)           /* EMPTY */
-00090 
-00091 #define NO_DBG_PRINT_BLOCK(b,m) /* EMPTY */
-00092 #define NO_DBG_UNICODE(t)       /* EMPTY */
-00093 #define NO_DBG_UNICODE_N(t,m)   /* EMPTY */
-00094 
-00095 #define NO_DBG_MSG_C(c,t)       /* EMPTY */
-00096 #define NO_DBG_STRN_C(c,t,m)    /* EMPTY */
-00097 #define NO_DBG_CHR_C(c,m)       /* EMPTY */
-00098 #define NO_DBG_DEC_C(c,m)       /* EMPTY */
-00099 #define NO_DBG_HEX_C(c,m)       /* EMPTY */
-00100 #define NO_DBG_FLT_C(c,m)       /* EMPTY */
-00101 
-00102 #if defined(TRACE)
-00103 
-00104 #define TRACE_MSG(t)    do {\
-00105                         (void)fprintf(stderr,\
-00106                                 "%s[%3d]: TRACE:%.40s\n",\
-00107                                 __FILE__, __LINE__, (t));\
-00108                         (void)fflush(stderr);\
-00109                         } while(0)
-00110 
-00111 #else
-00112 
-00113 #define TRACE_MSG(t)            /* EMPTY */
-00114 
-00115 #endif /* TRACE */
-00116 
-00117 #endif /* !__debug_h */
-
-
Generated by  - -doxygen 1.6.2
- - diff -r 59758314f811 -r d4524d6a4472 Symbian3/Examples/guid-6013a680-57f9-415b-8851-c4fa63356636/depot_8c_source.html --- a/Symbian3/Examples/guid-6013a680-57f9-415b-8851-c4fa63356636/depot_8c_source.html Fri Jun 11 15:24:34 2010 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,130 +0,0 @@ - - - - -TB9.2 Example Applications: examples/PIPS/antiword/src/depot.c Source File - - - - - -

examples/PIPS/antiword/src/depot.c

00001 /*
-00002  * depot.c
-00003  * Copyright (C) 1998-2002 A.J. van Os; Released under GPL
-00004  *
-00005  * Description:
-00006  * Functions to compute the depot offset
-00007  */
-00008 
-00009 #include "antiword.h"
-00010 
-00011 #define SIZE_RATIO      (BIG_BLOCK_SIZE/SMALL_BLOCK_SIZE)
-00012 
-00013 static ULONG    *aulSmallBlockList = NULL;
-00014 static size_t   tSmallBlockListLen = 0;
-00015 
-00016 
-00017 /*
-00018  * vDestroySmallBlockList - destroy the small block list
-00019  */
-00020 void
-00021 vDestroySmallBlockList(void)
-00022 {
-00023         DBG_MSG("vDestroySmallBlockList");
-00024 
-00025         aulSmallBlockList = xfree(aulSmallBlockList);
-00026         tSmallBlockListLen = 0;
-00027 } /* end of vDestroySmalBlockList */
-00028 
-00029 /*
-00030  * vCreateSmallBlockList - create the small block list
-00031  *
-00032  * returns: TRUE when successful, otherwise FALSE
-00033  */
-00034 BOOL
-00035 bCreateSmallBlockList(ULONG ulStartblock, const ULONG *aulBBD, size_t tBBDLen)
-00036 {
-00037         ULONG   ulTmp;
-00038         size_t  tSize;
-00039         int     iIndex;
-00040 
-00041         fail(aulSmallBlockList != NULL);
-00042         fail(tSmallBlockListLen != 0);
-00043         fail(ulStartblock > MAX_BLOCKNUMBER && ulStartblock != END_OF_CHAIN);
-00044         fail(aulBBD == NULL);
-00045         fail(tBBDLen == 0);
-00046 
-00047         /* Find the length of the small block list */
-00048         for (tSmallBlockListLen = 0, ulTmp = ulStartblock;
-00049              tSmallBlockListLen < tBBDLen && ulTmp != END_OF_CHAIN;
-00050              tSmallBlockListLen++, ulTmp = aulBBD[ulTmp]) {
-00051                 if (ulTmp >= (ULONG)tBBDLen) {
-00052                         DBG_DEC(ulTmp);
-00053                         DBG_DEC(tBBDLen);
-00054                         werr(1, "The Big Block Depot is damaged");
-00055                 }
-00056         }
-00057         DBG_DEC(tSmallBlockListLen);
-00058 
-00059         if (tSmallBlockListLen == 0) {
-00060                 /* There is no small block list */
-00061                 fail(ulStartblock != END_OF_CHAIN);
-00062                 aulSmallBlockList = NULL;
-00063                 return TRUE;
-00064         }
-00065 
-00066         /* Create the small block list */
-00067         tSize = tSmallBlockListLen * sizeof(ULONG);
-00068         aulSmallBlockList = xmalloc(tSize);
-00069         for (iIndex = 0, ulTmp = ulStartblock;
-00070              iIndex < (int)tBBDLen && ulTmp != END_OF_CHAIN;
-00071              iIndex++, ulTmp = aulBBD[ulTmp]) {
-00072                 if (ulTmp >= (ULONG)tBBDLen) {
-00073                         DBG_DEC(ulTmp);
-00074                         DBG_DEC(tBBDLen);
-00075                         werr(1, "The Big Block Depot is damaged");
-00076                 }
-00077                 aulSmallBlockList[iIndex] = ulTmp;
-00078                 NO_DBG_DEC(aulSmallBlockList[iIndex]);
-00079         }
-00080         return TRUE;
-00081 } /* end of bCreateSmallBlockList */
-00082 
-00083 /*
-00084  * ulDepotOffset - get the depot offset the block list
-00085  */
-00086 ULONG
-00087 ulDepotOffset(ULONG ulIndex, size_t tBlockSize)
-00088 {
-00089         ULONG   ulTmp;
-00090         size_t  tTmp;
-00091 
-00092         fail(ulIndex >= ULONG_MAX / BIG_BLOCK_SIZE);
-00093 
-00094         switch (tBlockSize) {
-00095         case BIG_BLOCK_SIZE:
-00096                 return (ulIndex + 1) * BIG_BLOCK_SIZE;
-00097         case SMALL_BLOCK_SIZE:
-00098                 tTmp = (size_t)(ulIndex / SIZE_RATIO);
-00099                 ulTmp = ulIndex % SIZE_RATIO;
-00100                 if (aulSmallBlockList == NULL ||
-00101                     tTmp >= tSmallBlockListLen) {
-00102                         DBG_HEX(aulSmallBlockList);
-00103                         DBG_DEC(tSmallBlockListLen);
-00104                         DBG_DEC(tTmp);
-00105                         return 0;
-00106                 }
-00107                 return ((aulSmallBlockList[tTmp] + 1) * SIZE_RATIO +
-00108                                 ulTmp) * SMALL_BLOCK_SIZE;
-00109         default:
-00110                 DBG_DEC(tBlockSize);
-00111                 DBG_FIXME();
-00112                 return 0;
-00113         }
-00114 } /* end of ulDepotOffset */
-
-
Generated by  - -doxygen 1.6.2
- - diff -r 59758314f811 -r d4524d6a4472 Symbian3/Examples/guid-6013a680-57f9-415b-8851-c4fa63356636/dib2eps_8c_source.html --- a/Symbian3/Examples/guid-6013a680-57f9-415b-8851-c4fa63356636/dib2eps_8c_source.html Fri Jun 11 15:24:34 2010 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,525 +0,0 @@ - - - - -TB9.2 Example Applications: examples/PIPS/antiword/src/dib2eps.c Source File - - - - - -

examples/PIPS/antiword/src/dib2eps.c

00001 /*
-00002  * dib2eps.c
-00003  * Copyright (C) 2000-2003 A.J. van Os; Released under GPL
-00004  *
-00005  * Description:
-00006  * Functions to translate dib pictures into eps
-00007  *
-00008  *================================================================
-00009  * This part of the software is based on:
-00010  * The Windows Bitmap Decoder Class part of paintlib
-00011  * Paintlib is copyright (c) 1996-2000 Ulrich von Zadow
-00012  *================================================================
-00013  * The credit should go to him, but all the bugs are mine.
-00014  */
-00015 
-00016 #include <stdio.h>
-00017 #include "antiword.h"
-00018 
-00019 
-00020 /*
-00021  * vDecode1bpp - decode an uncompressed 1 bit per pixel image
-00022  */
-00023 static void
-00024 vDecode1bpp(FILE *pInFile, FILE *pOutFile, const imagedata_type *pImg)
-00025 {
-00026         size_t  tPadding;
-00027         int     iX, iY, iN, iByte, iTmp, iEighthWidth, iUse;
-00028 
-00029         DBG_MSG("vDecode1bpp");
-00030 
-00031         fail(pOutFile == NULL);
-00032         fail(pImg == NULL);
-00033         fail(pImg->iColorsUsed < 1 || pImg->iColorsUsed > 2);
-00034 
-00035         DBG_DEC(pImg->iWidth);
-00036         DBG_DEC(pImg->iHeight);
-00037 
-00038         iEighthWidth = (pImg->iWidth + 7) / 8;
-00039         tPadding = (size_t)(ROUND4(iEighthWidth) - iEighthWidth);
-00040 
-00041         for (iY = 0; iY < pImg->iHeight; iY++) {
-00042                 for (iX = 0; iX < iEighthWidth; iX++) {
-00043                         iByte = iNextByte(pInFile);
-00044                         if (iByte == EOF) {
-00045                                 vASCII85EncodeByte(pOutFile, EOF);
-00046                                 return;
-00047                         }
-00048                         if (iX == iEighthWidth - 1 && pImg->iWidth % 8 != 0) {
-00049                                 iUse = pImg->iWidth % 8;
-00050                         } else {
-00051                                 iUse = 8;
-00052                         }
-00053                         for (iN = 0; iN < iUse; iN++) {
-00054                                 switch (iN) {
-00055                                 case 0: iTmp = (iByte & 0x80) / 128; break;
-00056                                 case 1: iTmp = (iByte & 0x40) / 64; break;
-00057                                 case 2: iTmp = (iByte & 0x20) / 32; break;
-00058                                 case 3: iTmp = (iByte & 0x10) / 16; break;
-00059                                 case 4: iTmp = (iByte & 0x08) / 8; break;
-00060                                 case 5: iTmp = (iByte & 0x04) / 4; break;
-00061                                 case 6: iTmp = (iByte & 0x02) / 2; break;
-00062                                 case 7: iTmp = (iByte & 0x01); break;
-00063                                 default: iTmp = 0; break;
-00064                                 }
-00065                                 vASCII85EncodeByte(pOutFile, iTmp);
-00066                         }
-00067                 }
-00068                 (void)tSkipBytes(pInFile, tPadding);
-00069         }
-00070         vASCII85EncodeByte(pOutFile, EOF);
-00071 } /* end of vDecode1bpp */
-00072 
-00073 /*
-00074  * vDecode4bpp - decode an uncompressed 4 bits per pixel image
-00075  */
-00076 static void
-00077 vDecode4bpp(FILE *pInFile, FILE *pOutFile, const imagedata_type *pImg)
-00078 {
-00079         size_t  tPadding;
-00080         int     iX, iY, iN, iByte, iTmp, iHalfWidth, iUse;
-00081 
-00082         DBG_MSG("vDecode4bpp");
-00083 
-00084         fail(pInFile == NULL);
-00085         fail(pOutFile == NULL);
-00086         fail(pImg == NULL);
-00087         fail(pImg->iColorsUsed < 1 || pImg->iColorsUsed > 16);
-00088 
-00089         DBG_DEC(pImg->iWidth);
-00090         DBG_DEC(pImg->iHeight);
-00091 
-00092         iHalfWidth = (pImg->iWidth + 1) / 2;
-00093         tPadding = (size_t)(ROUND4(iHalfWidth) - iHalfWidth);
-00094 
-00095         for (iY = 0; iY < pImg->iHeight; iY++) {
-00096                 for (iX = 0; iX < iHalfWidth; iX++) {
-00097                         iByte = iNextByte(pInFile);
-00098                         if (iByte == EOF) {
-00099                                 vASCII85EncodeByte(pOutFile, EOF);
-00100                                 return;
-00101                         }
-00102                         if (iX == iHalfWidth - 1 && odd(pImg->iWidth)) {
-00103                                 iUse = 1;
-00104                         } else {
-00105                                 iUse = 2;
-00106                         }
-00107                         for (iN = 0; iN < iUse; iN++) {
-00108                                 if (odd(iN)) {
-00109                                         iTmp = iByte & 0x0f;
-00110                                 } else {
-00111                                         iTmp = (iByte & 0xf0) / 16;
-00112                                 }
-00113                                 vASCII85EncodeByte(pOutFile, iTmp);
-00114                         }
-00115                 }
-00116                 (void)tSkipBytes(pInFile, tPadding);
-00117         }
-00118         vASCII85EncodeByte(pOutFile, EOF);
-00119 } /* end of vDecode4bpp */
-00120 
-00121 /*
-00122  * vDecode8bpp - decode an uncompressed 8 bits per pixel image
-00123  */
-00124 static void
-00125 vDecode8bpp(FILE *pInFile, FILE *pOutFile, const imagedata_type *pImg)
-00126 {
-00127         size_t  tPadding;
-00128         int     iX, iY, iByte;
-00129 
-00130         DBG_MSG("vDecode8bpp");
-00131 
-00132         fail(pInFile == NULL);
-00133         fail(pOutFile == NULL);
-00134         fail(pImg == NULL);
-00135         fail(pImg->iColorsUsed < 1 || pImg->iColorsUsed > 256);
-00136 
-00137         DBG_DEC(pImg->iWidth);
-00138         DBG_DEC(pImg->iHeight);
-00139 
-00140         tPadding = (size_t)(ROUND4(pImg->iWidth) - pImg->iWidth);
-00141 
-00142         for (iY = 0; iY < pImg->iHeight; iY++) {
-00143                 for (iX = 0; iX < pImg->iWidth; iX++) {
-00144                         iByte = iNextByte(pInFile);
-00145                         if (iByte == EOF) {
-00146                                 vASCII85EncodeByte(pOutFile, EOF);
-00147                                 return;
-00148                         }
-00149                         vASCII85EncodeByte(pOutFile, iByte);
-00150                 }
-00151                 (void)tSkipBytes(pInFile, tPadding);
-00152         }
-00153         vASCII85EncodeByte(pOutFile, EOF);
-00154 } /* end of vDecode8bpp */
-00155 
-00156 /*
-00157  * vDecode24bpp - decode an uncompressed 24 bits per pixel image
-00158  */
-00159 static void
-00160 vDecode24bpp(FILE *pInFile, FILE *pOutFile, const imagedata_type *pImg)
-00161 {
-00162         size_t  tPadding;
-00163         int     iX, iY, iBlue, iGreen, iRed, iTripleWidth;
-00164 
-00165         DBG_MSG("vDecode24bpp");
-00166 
-00167         fail(pInFile == NULL);
-00168         fail(pOutFile == NULL);
-00169         fail(pImg == NULL);
-00170         fail(!pImg->bColorImage);
-00171 
-00172         DBG_DEC(pImg->iWidth);
-00173         DBG_DEC(pImg->iHeight);
-00174 
-00175         iTripleWidth = pImg->iWidth * 3;
-00176         tPadding = (size_t)(ROUND4(iTripleWidth) - iTripleWidth);
-00177 
-00178         for (iY = 0; iY < pImg->iHeight; iY++) {
-00179                 for (iX = 0; iX < pImg->iWidth; iX++) {
-00180                         /* Change from BGR order to RGB order */
-00181                         iBlue = iNextByte(pInFile);
-00182                         if (iBlue == EOF) {
-00183                                 vASCII85EncodeByte(pOutFile, EOF);
-00184                                 return;
-00185                         }
-00186                         iGreen = iNextByte(pInFile);
-00187                         if (iGreen == EOF) {
-00188                                 vASCII85EncodeByte(pOutFile, EOF);
-00189                                 return;
-00190                         }
-00191                         iRed = iNextByte(pInFile);
-00192                         if (iRed == EOF) {
-00193                                 vASCII85EncodeByte(pOutFile, EOF);
-00194                                 return;
-00195                         }
-00196                         vASCII85EncodeByte(pOutFile, iRed);
-00197                         vASCII85EncodeByte(pOutFile, iGreen);
-00198                         vASCII85EncodeByte(pOutFile, iBlue);
-00199                 }
-00200                 (void)tSkipBytes(pInFile, tPadding);
-00201         }
-00202         vASCII85EncodeByte(pOutFile, EOF);
-00203 } /* end of vDecode24bpp */
-00204 
-00205 /*
-00206  * vDecodeRle4 - decode a RLE compressed 4 bits per pixel image
-00207  */
-00208 static void
-00209 vDecodeRle4(FILE *pInFile, FILE *pOutFile, const imagedata_type *pImg)
-00210 {
-00211         int     iX, iY, iByte, iTmp, iRunLength, iRun;
-00212         BOOL    bEOF, bEOL;
-00213 
-00214         DBG_MSG("vDecodeRle4");
-00215 
-00216         fail(pInFile == NULL);
-00217         fail(pOutFile == NULL);
-00218         fail(pImg == NULL);
-00219         fail(pImg->iColorsUsed < 1 || pImg->iColorsUsed > 16);
-00220 
-00221         DBG_DEC(pImg->iWidth);
-00222         DBG_DEC(pImg->iHeight);
-00223 
-00224         bEOF = FALSE;
-00225 
-00226         for (iY =  0; iY < pImg->iHeight && !bEOF; iY++) {
-00227                 bEOL = FALSE;
-00228                 iX = 0;
-00229                 while (!bEOL) {
-00230                         iRunLength = iNextByte(pInFile);
-00231                         if (iRunLength == EOF) {
-00232                                 vASCII85EncodeByte(pOutFile, EOF);
-00233                                 return;
-00234                         }
-00235                         if (iRunLength != 0) {
-00236                                 /*
-00237                                  * Encoded packet:
-00238                                  * RunLength pixels, all the "same" value
-00239                                  */
-00240                                 iByte = iNextByte(pInFile);
-00241                                 if (iByte == EOF) {
-00242                                         vASCII85EncodeByte(pOutFile, EOF);
-00243                                         return;
-00244                                 }
-00245                                 for (iRun = 0; iRun < iRunLength; iRun++) {
-00246                                         if (odd(iRun)) {
-00247                                                 iTmp = iByte & 0x0f;
-00248                                         } else {
-00249                                                 iTmp = (iByte & 0xf0) / 16;
-00250                                         }
-00251                                         if (iX < pImg->iWidth) {
-00252                                                 vASCII85EncodeByte(pOutFile, iTmp);
-00253                                         }
-00254                                         iX++;
-00255                                 }
-00256                                 continue;
-00257                         }
-00258                         /* Literal or escape */
-00259                         iRunLength = iNextByte(pInFile);
-00260                         if (iRunLength == EOF) {
-00261                                 vASCII85EncodeByte(pOutFile, EOF);
-00262                                 return;
-00263                         }
-00264                         if (iRunLength == 0) {          /* End of line escape */
-00265                                 bEOL = TRUE;
-00266                         } else if (iRunLength == 1) {   /* End of file escape */
-00267                                 bEOF = TRUE;
-00268                                 bEOL = TRUE;
-00269                         } else if (iRunLength == 2) {   /* Delta escape */
-00270                                 DBG_MSG("RLE4: encountered delta escape");
-00271                                 bEOF = TRUE;
-00272                                 bEOL = TRUE;
-00273                         } else {                        /* Literal packet */
-00274                                 iByte = 0;
-00275                                 for (iRun = 0; iRun < iRunLength; iRun++) {
-00276                                         if (odd(iRun)) {
-00277                                                 iTmp = iByte & 0x0f;
-00278                                         } else {
-00279                                                 iByte = iNextByte(pInFile);
-00280                                                 if (iByte == EOF) {
-00281                                                         vASCII85EncodeByte(pOutFile, EOF);
-00282                                                         return;
-00283                                                 }
-00284                                                 iTmp = (iByte & 0xf0) / 16;
-00285                                         }
-00286                                         if (iX < pImg->iWidth) {
-00287                                                 vASCII85EncodeByte(pOutFile, iTmp);
-00288                                         }
-00289                                         iX++;
-00290                                 }
-00291                                 /* Padding if the number of bytes is odd */
-00292                                 if (odd((iRunLength + 1) / 2)) {
-00293                                         (void)tSkipBytes(pInFile, 1);
-00294                                 }
-00295                         }
-00296                 }
-00297                 DBG_DEC_C(iX != pImg->iWidth, iX);
-00298         }
-00299         vASCII85EncodeByte(pOutFile, EOF);
-00300 } /* end of vDecodeRle4 */
-00301 
-00302 /*
-00303  * vDecodeRle8 - decode a RLE compressed 8 bits per pixel image
-00304  */
-00305 static void
-00306 vDecodeRle8(FILE *pInFile, FILE *pOutFile, const imagedata_type *pImg)
-00307 {
-00308         int     iX, iY, iByte, iRunLength, iRun;
-00309         BOOL    bEOF, bEOL;
-00310 
-00311         DBG_MSG("vDecodeRle8");
-00312 
-00313         fail(pInFile == NULL);
-00314         fail(pOutFile == NULL);
-00315         fail(pImg == NULL);
-00316         fail(pImg->iColorsUsed < 1 || pImg->iColorsUsed > 256);
-00317 
-00318         DBG_DEC(pImg->iWidth);
-00319         DBG_DEC(pImg->iHeight);
-00320 
-00321         bEOF = FALSE;
-00322 
-00323         for (iY = 0; iY < pImg->iHeight && !bEOF; iY++) {
-00324                 bEOL = FALSE;
-00325                 iX = 0;
-00326                 while (!bEOL) {
-00327                         iRunLength = iNextByte(pInFile);
-00328                         if (iRunLength == EOF) {
-00329                                 vASCII85EncodeByte(pOutFile, EOF);
-00330                                 return;
-00331                         }
-00332                         if (iRunLength != 0) {
-00333                                 /*
-00334                                  * Encoded packet:
-00335                                  * RunLength pixels, all the same value
-00336                                  */
-00337                                 iByte = iNextByte(pInFile);
-00338                                 if (iByte == EOF) {
-00339                                         vASCII85EncodeByte(pOutFile, EOF);
-00340                                         return;
-00341                                 }
-00342                                 for (iRun = 0; iRun < iRunLength; iRun++) {
-00343                                         if (iX < pImg->iWidth) {
-00344                                                 vASCII85EncodeByte(pOutFile, iByte);
-00345                                         }
-00346                                         iX++;
-00347                                 }
-00348                                 continue;
-00349                         }
-00350                         /* Literal or escape */
-00351                         iRunLength = iNextByte(pInFile);
-00352                         if (iRunLength == EOF) {
-00353                                 vASCII85EncodeByte(pOutFile, EOF);
-00354                                 return;
-00355                         }
-00356                         if (iRunLength == 0) {          /* End of line escape */
-00357                                 bEOL = TRUE;
-00358                         } else if (iRunLength == 1) {   /* End of file escape */
-00359                                 bEOF = TRUE;
-00360                                 bEOL = TRUE;
-00361                         } else if (iRunLength == 2) {   /* Delta escape */
-00362                                 DBG_MSG("RLE8: encountered delta escape");
-00363                                 bEOF = TRUE;
-00364                                 bEOL = TRUE;
-00365                         } else {                        /* Literal packet */
-00366                                 for (iRun = 0; iRun < iRunLength; iRun++) {
-00367                                         iByte = iNextByte(pInFile);
-00368                                         if (iByte == EOF) {
-00369                                                 vASCII85EncodeByte(pOutFile, EOF);
-00370                                                 return;
-00371                                         }
-00372                                         if (iX < pImg->iWidth) {
-00373                                                 vASCII85EncodeByte(pOutFile, iByte);
-00374                                         }
-00375                                         iX++;
-00376                                 }
-00377                                 /* Padding if the number of bytes is odd */
-00378                                 if (odd(iRunLength)) {
-00379                                         (void)tSkipBytes(pInFile, 1);
-00380                                 }
-00381                         }
-00382                 }
-00383                 DBG_DEC_C(iX != pImg->iWidth, iX);
-00384         }
-00385         vASCII85EncodeByte(pOutFile, EOF);
-00386 } /* end of vDecodeRle8 */
-00387 
-00388 /*
-00389  * vDecodeDIB - decode a dib picture
-00390  */
-00391 static void
-00392 vDecodeDIB(FILE *pInFile, FILE *pOutFile, const imagedata_type *pImg)
-00393 {
-00394         size_t  tHeaderSize;
-00395 
-00396         fail(pInFile == NULL);
-00397         fail(pOutFile == NULL);
-00398         fail(pImg == NULL);
-00399 
-00400         /* Skip the bitmap info header */
-00401         tHeaderSize = (size_t)ulNextLong(pInFile);
-00402         (void)tSkipBytes(pInFile, tHeaderSize - 4);
-00403         /* Skip the colortable */
-00404         if (pImg->uiBitsPerComponent <= 8) {
-00405                 (void)tSkipBytes(pInFile,
-00406                         (size_t)(pImg->iColorsUsed *
-00407                          ((tHeaderSize > 12) ? 4 : 3)));
-00408         }
-00409 
-00410         switch (pImg->uiBitsPerComponent) {
-00411         case 1:
-00412                 fail(pImg->eCompression != compression_none);
-00413                 vDecode1bpp(pInFile, pOutFile, pImg);
-00414                 break;
-00415         case 4:
-00416                 fail(pImg->eCompression != compression_none &&
-00417                                 pImg->eCompression != compression_rle4);
-00418                 if (pImg->eCompression == compression_rle4) {
-00419                         vDecodeRle4(pInFile, pOutFile, pImg);
-00420                 } else {
-00421                         vDecode4bpp(pInFile, pOutFile, pImg);
-00422                 }
-00423                 break;
-00424         case 8:
-00425                 fail(pImg->eCompression != compression_none &&
-00426                                 pImg->eCompression != compression_rle8);
-00427                 if (pImg->eCompression == compression_rle8) {
-00428                         vDecodeRle8(pInFile, pOutFile, pImg);
-00429                 } else {
-00430                         vDecode8bpp(pInFile, pOutFile, pImg);
-00431                 }
-00432                 break;
-00433         case 24:
-00434                 fail(pImg->eCompression != compression_none);
-00435                 vDecode24bpp(pInFile, pOutFile, pImg);
-00436                 break;
-00437         default:
-00438                 DBG_DEC(pImg->uiBitsPerComponent);
-00439                 break;
-00440         }
-00441 } /* end of vDecodeDIB */
-00442 
-00443 #if defined(DEBUG)
-00444 /*
-00445  * vCopy2File
-00446  */
-00447 static void
-00448 vCopy2File(FILE *pInFile, ULONG ulFileOffset, size_t tPictureLen)
-00449 {
-00450         static int      iPicCounter = 0;
-00451         FILE    *pOutFile;
-00452         size_t  tIndex;
-00453         int     iTmp;
-00454         char    szFilename[30];
-00455 
-00456         if (!bSetDataOffset(pInFile, ulFileOffset)) {
-00457                 return;
-00458         }
-00459 
-00460         sprintf(szFilename, "/tmp/pic/pic%04d.bmp", ++iPicCounter);
-00461         pOutFile = fopen(szFilename, "wb");
-00462         if (pOutFile == NULL) {
-00463                 return;
-00464         }
-00465         /* Turn a dib into a bmp by adding a fake 14 byte header */
-00466         (void)putc('B', pOutFile);
-00467         (void)putc('M', pOutFile);
-00468         for (iTmp = 0; iTmp < 12; iTmp++) {
-00469                 if (putc(0, pOutFile) == EOF) {
-00470                         break;
-00471                 }
-00472         }
-00473         for (tIndex = 0; tIndex < tPictureLen; tIndex++) {
-00474                 iTmp = iNextByte(pInFile);
-00475                 if (putc(iTmp, pOutFile) == EOF) {
-00476                         break;
-00477                 }
-00478         }
-00479         (void)fclose(pOutFile);
-00480 } /* end of vCopy2File */
-00481 #endif /* DEBUG */
-00482 
-00483 /*
-00484  * bTranslateDIB - translate a DIB picture
-00485  *
-00486  * This function translates a picture from dib to eps
-00487  *
-00488  * return TRUE when sucessful, otherwise FALSE
-00489  */
-00490 BOOL
-00491 bTranslateDIB(diagram_type *pDiag, FILE *pInFile,
-00492                 ULONG ulFileOffset, const imagedata_type *pImg)
-00493 {
-00494 #if defined(DEBUG)
-00495         fail(pImg->tPosition > pImg->tLength);
-00496         vCopy2File(pInFile, ulFileOffset, pImg->tLength - pImg->tPosition);
-00497 #endif /* DEBUG */
-00498 
-00499         /* Seek to start position of DIB data */
-00500         if (!bSetDataOffset(pInFile, ulFileOffset)) {
-00501                 return FALSE;
-00502         }
-00503 
-00504         vImagePrologue(pDiag, pImg);
-00505         vDecodeDIB(pInFile, pDiag->pOutFile, pImg);
-00506         vImageEpilogue(pDiag);
-00507 
-00508         return TRUE;
-00509 } /* end of bTranslateDIB */
-
-
Generated by  - -doxygen 1.6.2
- - diff -r 59758314f811 -r d4524d6a4472 Symbian3/Examples/guid-6013a680-57f9-415b-8851-c4fa63356636/dib2sprt_8c_source.html --- a/Symbian3/Examples/guid-6013a680-57f9-415b-8851-c4fa63356636/dib2sprt_8c_source.html Fri Jun 11 15:24:34 2010 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,613 +0,0 @@ - - - - -TB9.2 Example Applications: examples/PIPS/antiword/src/dib2sprt.c Source File - - - - - -

examples/PIPS/antiword/src/dib2sprt.c

00001 /*
-00002  * dib2sprt.c
-00003  * Copyright (C) 2000-2003 A.J. van Os; Released under GPL
-00004  *
-00005  * Description:
-00006  * Functions to translate dib pictures into sprites
-00007  */
-00008 
-00009 #include <stdio.h>
-00010 #include <string.h>
-00011 #include "DeskLib:Error.h"
-00012 #include "DeskLib:Sprite.h"
-00013 #include "antiword.h"
-00014 
-00015 #if 0 /* defined(DEBUG) */
-00016 static int iPicCounter = 0;
-00017 #endif /* DEBUG */
-00018 
-00019 
-00020 /*
-00021  * iGetByteWidth - compute the number of bytes needed for a row of pixels
-00022  */
-00023 static int
-00024 iGetByteWidth(const imagedata_type *pImg)
-00025 {
-00026         switch (pImg->uiBitsPerComponent) {
-00027         case  1:
-00028                 return (pImg->iWidth + 31) / 32 * sizeof(int);
-00029         case  4:
-00030                 return (pImg->iWidth + 7) / 8 * sizeof(int);
-00031         case  8:
-00032         case 24:
-00033                 return (pImg->iWidth + 3) / 4 * sizeof(int);
-00034         default:
-00035                 DBG_DEC(pImg->uiBitsPerComponent);
-00036                 return 0;
-00037         }
-00038 } /* end of iGetByteWidth */
-00039 
-00040 /*
-00041  * pCreateBlankSprite - Create a blank sprite.
-00042  *
-00043  * Create a blank sprite and add a palette if needed
-00044  *
-00045  * returns a pointer to the sprite when successful, otherwise NULL
-00046  */
-00047 static sprite_areainfo *
-00048 pCreateBlankSprite(const imagedata_type *pImg, size_t *pSize)
-00049 {
-00050         sprite_areainfo *pArea;
-00051         UCHAR   *pucTmp;
-00052         size_t  tSize;
-00053         screen_modeval  uMode;
-00054         int     iIndex, iPaletteEntries;
-00055 
-00056         TRACE_MSG("pCreateBlankSprite");
-00057 
-00058         fail(pImg == NULL);
-00059         fail(pSize == NULL);
-00060 
-00061         switch (pImg->uiBitsPerComponent) {
-00062         case  1:
-00063                 uMode.screen_mode = 18;
-00064                 iPaletteEntries = 2;
-00065                 break;
-00066         case  4:
-00067                 uMode.screen_mode = 20;
-00068                 iPaletteEntries = 16;
-00069                 break;
-00070         case  8:
-00071         case 24:
-00072                 uMode.screen_mode = 21;
-00073                 iPaletteEntries = 0;
-00074                 break;
-00075         default:
-00076                 DBG_DEC(pImg->uiBitsPerComponent);
-00077                 return NULL;
-00078         }
-00079         fail(iPaletteEntries < 0 || iPaletteEntries > 16);
-00080 
-00081         /* Get memory for the sprite */
-00082         tSize = sizeof(sprite_areainfo) +
-00083                 Sprite_MemorySize(pImg->iWidth, pImg->iHeight, uMode,
-00084                 iPaletteEntries > 0 ? sprite_HASPAL : sprite_HASNOMASKPAL);
-00085         DBG_DEC(tSize);
-00086         pArea = xmalloc(tSize);
-00087 
-00088         /* Initialise sprite area */
-00089         pArea->areasize = tSize;
-00090         pArea->numsprites = 0;
-00091         pArea->firstoffset = sizeof(sprite_areainfo);
-00092         pArea->freeoffset = sizeof(sprite_areainfo);
-00093 
-00094         /* Create a blank sprite */
-00095         Error_CheckFatal(Sprite_Create(pArea, "wordimage",
-00096                 iPaletteEntries > 0 ? 1 : 0,
-00097                 pImg->iWidth, pImg->iHeight, uMode));
-00098 
-00099         /* Add the palette */
-00100         pucTmp = (UCHAR *)pArea + pArea->firstoffset + sizeof(sprite_header);
-00101         for (iIndex = 0; iIndex < iPaletteEntries; iIndex++) {
-00102                 /* First color */
-00103                 *pucTmp++ = 0;
-00104                 *pucTmp++ = pImg->aucPalette[iIndex][0];
-00105                 *pucTmp++ = pImg->aucPalette[iIndex][1];
-00106                 *pucTmp++ = pImg->aucPalette[iIndex][2];
-00107                 /* Second color */
-00108                 *pucTmp++ = 0;
-00109                 *pucTmp++ = pImg->aucPalette[iIndex][0];
-00110                 *pucTmp++ = pImg->aucPalette[iIndex][1];
-00111                 *pucTmp++ = pImg->aucPalette[iIndex][2];
-00112         }
-00113 
-00114         *pSize = tSize;
-00115         return pArea;
-00116 } /* end of pCreateBlankSprite */
-00117 
-00118 /*
-00119  * iReduceColor - reduce from 24 bit to 8 bit color
-00120  *
-00121  * Reduce 24 bit true colors to RISC OS default 256 color palette
-00122  *
-00123  * returns the resulting color
-00124  */
-00125 static int
-00126 iReduceColor(int iRed, int iGreen, int iBlue)
-00127 {
-00128         int     iResult;
-00129 
-00130         iResult = (iBlue & 0x80) ? 0x80 : 0;
-00131         iResult |= (iGreen & 0x80) ? 0x40 : 0;
-00132         iResult |= (iGreen & 0x40) ? 0x20 : 0;
-00133         iResult |= (iRed & 0x80) ? 0x10 : 0;
-00134         iResult |= (iBlue & 0x40) ? 0x08 : 0;
-00135         iResult |= (iRed & 0x40) ? 0x04 : 0;
-00136         iResult |= ((iRed | iGreen | iBlue) & 0x20) ? 0x02 : 0;
-00137         iResult |= ((iRed | iGreen | iBlue) & 0x10) ? 0x01 : 0;
-00138         return iResult;
-00139 } /* end of iReduceColor */
-00140 
-00141 /*
-00142  * vDecode1bpp - decode an uncompressed 1 bit per pixel image
-00143  */
-00144 static void
-00145 vDecode1bpp(FILE *pFile, UCHAR *pucData, const imagedata_type *pImg)
-00146 {
-00147         int     iX, iY, iByteWidth, iOffset, iTmp, iEighthWidth, iPadding;
-00148         UCHAR   ucTmp;
-00149 
-00150         DBG_MSG("vDecode1bpp");
-00151 
-00152         fail(pFile == NULL);
-00153         fail(pucData == NULL);
-00154         fail(pImg == NULL);
-00155         fail(pImg->iColorsUsed < 1 || pImg->iColorsUsed > 2);
-00156 
-00157         iByteWidth = iGetByteWidth(pImg);
-00158 
-00159         iEighthWidth = (pImg->iWidth + 7) / 8;
-00160         iPadding = ROUND4(iEighthWidth) - iEighthWidth;
-00161 
-00162         for (iY = pImg->iHeight - 1; iY >= 0; iY--) {
-00163                 for (iX = 0; iX < iEighthWidth; iX++) {
-00164                         iTmp = iNextByte(pFile);
-00165                         if (iTmp == EOF) {
-00166                                 return;
-00167                         }
-00168                         /* Reverse the bit order */
-00169                         ucTmp  = (iTmp & BIT(0)) ? (UCHAR)BIT(7) : 0;
-00170                         ucTmp |= (iTmp & BIT(1)) ? (UCHAR)BIT(6) : 0;
-00171                         ucTmp |= (iTmp & BIT(2)) ? (UCHAR)BIT(5) : 0;
-00172                         ucTmp |= (iTmp & BIT(3)) ? (UCHAR)BIT(4) : 0;
-00173                         ucTmp |= (iTmp & BIT(4)) ? (UCHAR)BIT(3) : 0;
-00174                         ucTmp |= (iTmp & BIT(5)) ? (UCHAR)BIT(2) : 0;
-00175                         ucTmp |= (iTmp & BIT(6)) ? (UCHAR)BIT(1) : 0;
-00176                         ucTmp |= (iTmp & BIT(7)) ? (UCHAR)BIT(0) : 0;
-00177                         iOffset = iY * iByteWidth + iX;
-00178                         *(pucData + iOffset) = ucTmp;
-00179                 }
-00180                 (void)tSkipBytes(pFile, iPadding);
-00181         }
-00182 } /* end of vDecode1bpp */
-00183 
-00184 /*
-00185  * vDecode4bpp - decode an uncompressed 4 bits per pixel image
-00186  */
-00187 static void
-00188 vDecode4bpp(FILE *pFile, UCHAR *pucData, const imagedata_type *pImg)
-00189 {
-00190         int     iX, iY, iByteWidth, iOffset, iTmp, iHalfWidth, iPadding;
-00191         UCHAR   ucTmp;
-00192 
-00193         DBG_MSG("vDecode4bpp");
-00194 
-00195         fail(pFile == NULL);
-00196         fail(pucData == NULL);
-00197         fail(pImg == NULL);
-00198         fail(pImg->iColorsUsed < 1 || pImg->iColorsUsed > 16);
-00199 
-00200         iByteWidth = iGetByteWidth(pImg);
-00201 
-00202         iHalfWidth = (pImg->iWidth + 1) / 2;
-00203         iPadding = ROUND4(iHalfWidth) - iHalfWidth;
-00204 
-00205         for (iY = pImg->iHeight - 1; iY >= 0; iY--) {
-00206                 for (iX = 0; iX < iHalfWidth; iX++) {
-00207                         iTmp = iNextByte(pFile);
-00208                         if (iTmp == EOF) {
-00209                                 return;
-00210                         }
-00211                         /* Reverse the nibble order */
-00212                         ucTmp = (iTmp & 0xf0) >> 4;
-00213                         ucTmp |= (iTmp & 0x0f) << 4;
-00214                         iOffset = iY * iByteWidth + iX;
-00215                         *(pucData + iOffset) = ucTmp;
-00216                 }
-00217                 (void)tSkipBytes(pFile, iPadding);
-00218         }
-00219 } /* end of vDecode4bpp */
-00220 
-00221 /*
-00222  * vDecode8bpp - decode an uncompressed 8 bits per pixel image
-00223  */
-00224 static void
-00225 vDecode8bpp(FILE *pFile, UCHAR *pucData, const imagedata_type *pImg)
-00226 {
-00227         int     iX, iY, iByteWidth, iOffset, iIndex, iPadding;
-00228 
-00229         DBG_MSG("vDecode8bpp");
-00230 
-00231         fail(pFile == NULL);
-00232         fail(pucData == NULL);
-00233         fail(pImg == NULL);
-00234         fail(pImg->iColorsUsed < 1 || pImg->iColorsUsed > 256);
-00235 
-00236         iByteWidth = iGetByteWidth(pImg);
-00237 
-00238         iPadding = ROUND4(pImg->iWidth) - pImg->iWidth;
-00239 
-00240         for (iY = pImg->iHeight - 1; iY >= 0; iY--) {
-00241                 for (iX = 0; iX < pImg->iWidth; iX++) {
-00242                         iIndex = iNextByte(pFile);
-00243                         if (iIndex == EOF) {
-00244                                 return;
-00245                         }
-00246                         iOffset = iY * iByteWidth + iX;
-00247                         *(pucData + iOffset) = iReduceColor(
-00248                                 pImg->aucPalette[iIndex][0],
-00249                                 pImg->aucPalette[iIndex][1],
-00250                                 pImg->aucPalette[iIndex][2]);
-00251                 }
-00252                 (void)tSkipBytes(pFile, iPadding);
-00253         }
-00254 } /* end of vDecode8bpp */
-00255 
-00256 /*
-00257  * vDecode24bpp - decode an uncompressed 24 bits per pixel image
-00258  */
-00259 static void
-00260 vDecode24bpp(FILE *pFile, UCHAR *pucData, const imagedata_type *pImg)
-00261 {
-00262         int     iX, iY, iTripleWidth, iByteWidth, iOffset, iPadding;
-00263         int     iRed, iGreen, iBlue;
-00264 
-00265         DBG_MSG("vDecode24bpp");
-00266 
-00267         fail(pFile == NULL);
-00268         fail(pucData == NULL);
-00269         fail(pImg == NULL);
-00270 
-00271         iByteWidth = iGetByteWidth(pImg);
-00272 
-00273         iTripleWidth = pImg->iWidth * 3;
-00274         iPadding = ROUND4(iTripleWidth) - iTripleWidth;
-00275 
-00276         for (iY = pImg->iHeight - 1; iY >= 0; iY--) {
-00277                 for (iX = 0; iX < pImg->iWidth; iX++) {
-00278                         iBlue = iNextByte(pFile);
-00279                         if (iBlue == EOF) {
-00280                                 return;
-00281                         }
-00282                         iGreen = iNextByte(pFile);
-00283                         if (iGreen == EOF) {
-00284                                 return;
-00285                         }
-00286                         iRed = iNextByte(pFile);
-00287                         if (iRed == EOF) {
-00288                                 return;
-00289                         }
-00290                         iOffset = iY * iByteWidth + iX;
-00291                         *(pucData + iOffset) =
-00292                                         iReduceColor(iRed, iGreen, iBlue);
-00293                 }
-00294                 (void)tSkipBytes(pFile, iPadding);
-00295         }
-00296 } /* end of vDecode24bpp */
-00297 
-00298 /*
-00299  * vDecodeRle4 - decode a RLE compressed 4 bits per pixel image
-00300  */
-00301 static void
-00302 vDecodeRle4(FILE *pFile, UCHAR *pucData, const imagedata_type *pImg)
-00303 {
-00304         int     iX, iY, iByteWidth, iOffset, iTmp, iHalfWidth;
-00305         int     iRun, iRunLength, iHalfRun;
-00306         BOOL    bEOL;
-00307         UCHAR   ucTmp;
-00308 
-00309         DBG_MSG("vDecodeRle4");
-00310 
-00311         fail(pFile == NULL);
-00312         fail(pucData == NULL);
-00313         fail(pImg == NULL);
-00314         fail(pImg->iColorsUsed < 1 || pImg->iColorsUsed > 16);
-00315 
-00316         DBG_DEC(pImg->iWidth);
-00317         DBG_DEC(pImg->iHeight);
-00318 
-00319         iByteWidth = iGetByteWidth(pImg);
-00320         iHalfWidth = (pImg->iWidth + 1) / 2;
-00321 
-00322         for (iY = pImg->iHeight - 1; iY >= 0; iY--) {
-00323                 bEOL = FALSE;
-00324                 iX = 0;
-00325                 while (!bEOL) {
-00326                         iRunLength = iNextByte(pFile);
-00327                         if (iRunLength == EOF) {
-00328                                 return;
-00329                         }
-00330                         if (iRunLength != 0) {
-00331                                 /*
-00332                                  * Encoded packet:
-00333                                  * RunLength pixels, all the "same" value
-00334                                  */
-00335                                 iTmp = iNextByte(pFile);
-00336                                 if (iTmp == EOF) {
-00337                                         return;
-00338                                 }
-00339                                 /* Reverse the nibble order */
-00340                                 ucTmp = (iTmp & 0xf0) >> 4;
-00341                                 ucTmp |= (iTmp & 0x0f) << 4;
-00342                                 iHalfRun = (iRunLength + 1) / 2;
-00343                                 for (iRun = 0; iRun < iHalfRun; iRun++) {
-00344                                         if (iX < iHalfWidth) {
-00345                                                 iOffset = iY * iByteWidth + iX;
-00346                                                 *(pucData + iOffset) = ucTmp;
-00347                                         }
-00348                                         iX++;
-00349                                 }
-00350                                 continue;
-00351                         }
-00352                         /* Literal or escape */
-00353                         iRunLength = iNextByte(pFile);
-00354                         if (iRunLength == EOF) {
-00355                                 return;
-00356                         }
-00357                         if (iRunLength == 0) {          /* End of line escape */
-00358                                 bEOL = TRUE;
-00359                         } else if (iRunLength == 1) {   /* End of file escape */
-00360                                 return;
-00361                         } else if (iRunLength == 2) {   /* Delta escape */
-00362                                 DBG_MSG("RLE4: encountered delta escape");
-00363                                 return;
-00364                         } else {                        /* Literal packet */
-00365                                 iHalfRun = (iRunLength + 1) / 2;
-00366                                 for (iRun = 0; iRun < iHalfRun; iRun++) {
-00367                                         iTmp = iNextByte(pFile);
-00368                                         if (iTmp == EOF) {
-00369                                                 return;
-00370                                         }
-00371                                         /* Reverse the nibble order */
-00372                                         ucTmp = (iTmp & 0xf0) >> 4;
-00373                                         ucTmp |= (iTmp & 0x0f) << 4;
-00374                                         if (iX < iHalfWidth) {
-00375                                                 iOffset = iY * iByteWidth + iX;
-00376                                                 *(pucData + iOffset) = ucTmp;
-00377                                         }
-00378                                         iX++;
-00379                                 }
-00380                                 /* Padding if the number of bytes is odd */
-00381                                 if (odd(iHalfRun)) {
-00382                                         (void)tSkipBytes(pFile, 1);
-00383                                 }
-00384                         }
-00385                 }
-00386                 DBG_DEC_C(iX != iHalfWidth, iX);
-00387         }
-00388 } /* end of vDecodeRle4 */
-00389 
-00390 /*
-00391  * vDecodeRle8 - decode a RLE compressed 8 bits per pixel image
-00392  */
-00393 static void
-00394 vDecodeRle8(FILE *pFile, UCHAR *pucData, const imagedata_type *pImg)
-00395 {
-00396         int     iX, iY, iRun, iRunLength, iOffset, iIndex, iByteWidth;
-00397         BOOL    bEOL;
-00398 
-00399         DBG_MSG("vDecodeRle8");
-00400 
-00401         fail(pFile == NULL);
-00402         fail(pucData == NULL);
-00403         fail(pImg == NULL);
-00404         fail(pImg->iColorsUsed < 1 || pImg->iColorsUsed > 256);
-00405 
-00406         DBG_DEC(pImg->iWidth);
-00407         DBG_DEC(pImg->iHeight);
-00408 
-00409         iByteWidth = iGetByteWidth(pImg);
-00410 
-00411         for (iY = pImg->iHeight - 1; iY >= 0; iY--) {
-00412                 bEOL = FALSE;
-00413                 iX = 0;
-00414                 while (!bEOL) {
-00415                         iRunLength = iNextByte(pFile);
-00416                         if (iRunLength == EOF) {
-00417                                 return;
-00418                         }
-00419                         if (iRunLength != 0) {
-00420                                 /*
-00421                                  * Encoded packet:
-00422                                  * RunLength pixels, all the same value
-00423                                  */
-00424                                 iIndex = iNextByte(pFile);
-00425                                 if (iIndex == EOF) {
-00426                                         return;
-00427                                 }
-00428                                 for (iRun = 0; iRun < iRunLength; iRun++) {
-00429                                         if (iX < pImg->iWidth) {
-00430                                                 iOffset = iY * iByteWidth + iX;
-00431                                                 *(pucData + iOffset) =
-00432                                                         iReduceColor(
-00433                                                         pImg->aucPalette[iIndex][0],
-00434                                                         pImg->aucPalette[iIndex][1],
-00435                                                         pImg->aucPalette[iIndex][2]);
-00436                                         }
-00437                                         iX++;
-00438                                 }
-00439                                 continue;
-00440                         }
-00441                         /* Literal or escape */
-00442                         iRunLength = iNextByte(pFile);
-00443                         if (iRunLength == EOF) {
-00444                                 return;
-00445                         }
-00446                         if (iRunLength == 0) {          /* End of line escape */
-00447                                 bEOL = TRUE;
-00448                         } else if (iRunLength == 1) {   /* End of file escape */
-00449                                 return;
-00450                         } else if (iRunLength == 2) {   /* Delta escape */
-00451                                 DBG_MSG("RLE8: encountered delta escape");
-00452                                 return;
-00453                         } else {                        /* Literal packet */
-00454                                 for (iRun = 0; iRun < iRunLength; iRun++) {
-00455                                         iIndex = iNextByte(pFile);
-00456                                         if (iIndex == EOF) {
-00457                                                 return;
-00458                                         }
-00459                                         if (iX < pImg->iWidth) {
-00460                                                 iOffset = iY * iByteWidth + iX;
-00461                                                 *(pucData + iOffset) =
-00462                                                         iReduceColor(
-00463                                                         pImg->aucPalette[iIndex][0],
-00464                                                         pImg->aucPalette[iIndex][1],
-00465                                                         pImg->aucPalette[iIndex][2]);
-00466                                         }
-00467                                         iX++;
-00468                                 }
-00469                                 /* Padding if the number of bytes is odd */
-00470                                 if (odd(iRunLength)) {
-00471                                         (void)tSkipBytes(pFile, 1);
-00472                                 }
-00473                         }
-00474                 }
-00475                 DBG_DEC_C(iX != pImg->iWidth, iX);
-00476         }
-00477 } /* end of vDecodeRle8 */
-00478 
-00479 #if 0 /* defined(DEBUG) */
-00480 static void
-00481 vCopy2File(UCHAR *pucSprite, size_t tSpriteSize)
-00482 {
-00483         FILE    *pOutFile;
-00484         int     iIndex;
-00485         char    szFilename[30];
-00486 
-00487         sprintf(szFilename, "<Wimp$ScrapDir>.sprt%04d", ++iPicCounter);
-00488         pOutFile = fopen(szFilename, "wb");
-00489         if (pOutFile == NULL) {
-00490                 return;
-00491         }
-00492         DBG_MSG(szFilename);
-00493         for (iIndex = 4; iIndex < (int)tSpriteSize; iIndex++) {
-00494                 if (putc(pucSprite[iIndex], pOutFile) == EOF) {
-00495                         break;
-00496                 }
-00497         }
-00498         (void)fclose(pOutFile);
-00499         vSetFiletype(szFilename, FILETYPE_SPRITE);
-00500 } /* end of vCopy2File */
-00501 #endif /* DEBUG */
-00502 
-00503 /*
-00504  * vDecodeDIB - decode a dib picture
-00505  */
-00506 static void
-00507 vDecodeDIB(diagram_type *pDiag, FILE *pFile, const imagedata_type *pImg)
-00508 {
-00509         sprite_areainfo *pSprite;
-00510         UCHAR   *pucPalette, *pucData;
-00511         size_t  tSpriteSize;
-00512         int     iHeaderSize;
-00513 
-00514         /* Skip the bitmap info header */
-00515         iHeaderSize = (int)ulNextLong(pFile);
-00516         (void)tSkipBytes(pFile, iHeaderSize - 4);
-00517         /* Skip the colortable */
-00518         if (pImg->uiBitsPerComponent <= 8) {
-00519                 (void)tSkipBytes(pFile,
-00520                         pImg->iColorsUsed * ((iHeaderSize > 12) ? 4 : 3));
-00521         }
-00522 
-00523         /* Create an blank sprite */
-00524         pSprite = pCreateBlankSprite(pImg, &tSpriteSize);
-00525         pucPalette = (UCHAR *)pSprite +
-00526                         pSprite->firstoffset + sizeof(sprite_header);
-00527 
-00528         /* Add the pixel information */
-00529         switch (pImg->uiBitsPerComponent) {
-00530         case  1:
-00531                 fail(pImg->eCompression != compression_none);
-00532                 pucData = pucPalette + 2 * 8;
-00533                 vDecode1bpp(pFile, pucData, pImg);
-00534                 break;
-00535         case  4:
-00536                 fail(pImg->eCompression != compression_none &&
-00537                                 pImg->eCompression != compression_rle4);
-00538                 pucData = pucPalette + 16 * 8;
-00539                 if (pImg->eCompression == compression_rle4) {
-00540                         vDecodeRle4(pFile, pucData, pImg);
-00541                 } else {
-00542                         vDecode4bpp(pFile, pucData, pImg);
-00543                 }
-00544                 break;
-00545         case  8:
-00546                 fail(pImg->eCompression != compression_none &&
-00547                                 pImg->eCompression != compression_rle8);
-00548                 pucData = pucPalette + 0 * 8;
-00549                 if (pImg->eCompression == compression_rle8) {
-00550                         vDecodeRle8(pFile, pucData, pImg);
-00551                 } else {
-00552                         vDecode8bpp(pFile, pucData, pImg);
-00553                 }
-00554                 break;
-00555         case 24:
-00556                 fail(pImg->eCompression != compression_none);
-00557                 pucData = pucPalette + 0 * 8;
-00558                 vDecode24bpp(pFile, pucData, pImg);
-00559                 break;
-00560         default:
-00561                 DBG_DEC(pImg->uiBitsPerComponent);
-00562                 break;
-00563         }
-00564 
-00565 #if 0 /* defined(DEBUG) */
-00566         vCopy2File((UCHAR *)pSprite, tSpriteSize);
-00567 #endif /* DEBUG */
-00568 
-00569         /* Add the sprite to the Draw file */
-00570         vImage2Diagram(pDiag, pImg,
-00571                 (UCHAR *)pSprite + pSprite->firstoffset,
-00572                 tSpriteSize - pSprite->firstoffset);
-00573 
-00574         /* Clean up before you leave */
-00575         pSprite = xfree(pSprite);
-00576 } /* end of vDecodeDIB */
-00577 
-00578 /*
-00579  * bTranslateDIB - translate a DIB picture
-00580  *
-00581  * This function translates a picture from dib to sprite
-00582  *
-00583  * return TRUE when sucessful, otherwise FALSE
-00584  */
-00585 BOOL
-00586 bTranslateDIB(diagram_type *pDiag, FILE *pFile,
-00587         ULONG ulFileOffset, const imagedata_type *pImg)
-00588 {
-00589         /* Seek to start position of DIB data */
-00590         if (!bSetDataOffset(pFile, ulFileOffset)) {
-00591                 return FALSE;
-00592         }
-00593 
-00594         vDecodeDIB(pDiag, pFile, pImg);
-00595 
-00596         return TRUE;
-00597 } /* end of bTranslateDIB */
-
-
Generated by  - -doxygen 1.6.2
- - diff -r 59758314f811 -r d4524d6a4472 Symbian3/Examples/guid-6013a680-57f9-415b-8851-c4fa63356636/doclist_8c_source.html --- a/Symbian3/Examples/guid-6013a680-57f9-415b-8851-c4fa63356636/doclist_8c_source.html Fri Jun 11 15:24:34 2010 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,91 +0,0 @@ - - - - -TB9.2 Example Applications: examples/PIPS/antiword/src/doclist.c Source File - - - - - -

examples/PIPS/antiword/src/doclist.c

00001 /*
-00002  * doclist.c
-00003  * Copyright (C) 2004 A.J. van Os; Released under GNU GPL
-00004  *
-00005  * Description:
-00006  * Build, read and destroy list(s) of Word document information
-00007  *
-00008  * Note:
-00009  * There is no real list there is always one document per document
-00010  */
-00011 
-00012 #include "antiword.h"
-00013 
-00014 #define HALF_INCH       36000L  /* In millipoints */
-00015 
-00016 /* Variables needed to write the Document Information List */
-00017 static document_block_type *pAnchor = NULL;
-00018 static document_block_type tInfo;
-00019 
-00020 
-00021 /*
-00022  * vDestroyDocumentInfoList - destroy the Document Information List
-00023  */
-00024 void
-00025 vDestroyDocumentInfoList(void)
-00026 {
-00027         DBG_MSG("vDestroyDocumentInfoList");
-00028 
-00029         pAnchor = NULL;
-00030 } /* end of vDestoryDocumentInfoList */
-00031 
-00032 /*
-00033  * vCreateDocumentInfoList - create the Document Information List
-00034  */
-00035 void
-00036 vCreateDocumentInfoList(const document_block_type *pDocument)
-00037 {
-00038         fail(pDocument == NULL);
-00039         fail(pAnchor != NULL);
-00040 
-00041         tInfo = *pDocument;
-00042         pAnchor = &tInfo;
-00043 } /* end of vCreateDocumentInfoList */
-00044 
-00045 /*
-00046  * lGetDefaultTabWidth - get the default tabwidth in millipoints
-00047  */
-00048 long
-00049 lGetDefaultTabWidth(void)
-00050 {
-00051         long    lDefaultTabWidth;
-00052         USHORT  usTmp;
-00053 
-00054         if (pAnchor == NULL) {
-00055                 DBG_FIXME();
-00056                 return HALF_INCH;
-00057         }
-00058         usTmp = pAnchor->usDefaultTabWidth;
-00059         lDefaultTabWidth = usTmp == 0 ? HALF_INCH : lTwips2MilliPoints(usTmp);
-00060         NO_DBG_DEC(lDefaultTabWidth);
-00061         return lDefaultTabWidth;
-00062 } /* end of lGetDefaultTabWidth */
-00063 
-00064 /*
-00065  * ucGetDopHdrFtrSpecification - get the Heder/footer specification
-00066  */
-00067 UCHAR
-00068 ucGetDopHdrFtrSpecification(void)
-00069 {
-00070         if (pAnchor == NULL) {
-00071                 DBG_FIXME();
-00072                 return 0x00;
-00073         }
-00074         return pAnchor->ucHdrFtrSpecification;
-00075 } /* end of ucGetDopHdrFtrSpecification */
-
-
Generated by  - -doxygen 1.6.2
- - diff -r 59758314f811 -r d4524d6a4472 Symbian3/Examples/guid-6013a680-57f9-415b-8851-c4fa63356636/draw_8c_source.html --- a/Symbian3/Examples/guid-6013a680-57f9-415b-8851-c4fa63356636/draw_8c_source.html Fri Jun 11 15:24:34 2010 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1063 +0,0 @@ - - - - -TB9.2 Example Applications: examples/PIPS/antiword/src/draw.c Source File - - - - - -

examples/PIPS/antiword/src/draw.c

00001 /*
-00002  * draw.c
-00003  * Copyright (C) 1998-2005 A.J. van Os; Released under GPL
-00004  *
-00005  * Description:
-00006  * Functions to deal with the Draw format
-00007  */
-00008 
-00009 #include <stdlib.h>
-00010 #include <ctype.h>
-00011 #include <string.h>
-00012 #include "DeskLib:KeyCodes.h"
-00013 #include "DeskLib:Error.h"
-00014 #include "DeskLib:Menu.h"
-00015 #include "DeskLib:Template.h"
-00016 #include "DeskLib:Window.h"
-00017 #include "DeskLib:EventMsg.h"
-00018 #include "flexlib:flex.h"
-00019 #include "drawfile.h"
-00020 #include "antiword.h"
-00021 
-00022 /* The work area must be a little bit larger than the diagram */
-00023 #define WORKAREA_EXTENSION          5
-00024 /* Diagram memory */
-00025 #define INITIAL_SIZE            32768   /* 32k */
-00026 #define EXTENSION_SIZE           4096   /*  4k */
-00027 /* Main window title */
-00028 #define WINDOW_TITLE_LEN           28
-00029 #define FILENAME_TITLE_LEN      (WINDOW_TITLE_LEN - 10)
-00030 
-00031 
-00032 #if !defined(__GNUC__)
-00033 int
-00034 flex_alloc(flex_ptr anchor, int n)
-00035 {
-00036         void    *pvTmp;
-00037 
-00038         TRACE_MSG("flex_alloc");
-00039 
-00040         if (anchor == NULL || n < 0) {
-00041                 return 0;
-00042         }
-00043         if (n == 0) {
-00044                 n = 1;
-00045         }
-00046         pvTmp = malloc(n);
-00047         if (pvTmp == NULL) {
-00048                 return 0;
-00049         }
-00050         *anchor = pvTmp;
-00051         return 1;
-00052 } /* end of flex_alloc */
-00053 
-00054 void
-00055 flex_free(flex_ptr anchor)
-00056 {
-00057         TRACE_MSG("flex_free");
-00058 
-00059         if (anchor == NULL || *anchor == NULL) {
-00060                 return;
-00061         }
-00062         free(*anchor);
-00063         *anchor = NULL;
-00064 } /* end of flex_free */
-00065 
-00066 int
-00067 flex_extend(flex_ptr anchor, int newsize)
-00068 {
-00069         void    *pvTmp;
-00070 
-00071         TRACE_MSG("flex_extend");
-00072 
-00073         if (anchor == NULL || newsize < 0) {
-00074                 return 0;
-00075         }
-00076         if (newsize == 0) {
-00077                 newsize = 1;
-00078         }
-00079         pvTmp = realloc(*anchor, newsize);
-00080         if (pvTmp == NULL) {
-00081                 return 0;
-00082         }
-00083         *anchor = pvTmp;
-00084         return 1;
-00085 } /* end of flex_extend */
-00086 #endif /* !__GNUC__ */
-00087 
-00088 /*
-00089  * vCreateMainWindow - create the Main window
-00090  *
-00091  * remark: does not return if the Main window can't be created
-00092  */
-00093 static window_handle
-00094 tCreateMainWindow(void)
-00095 {
-00096         window_handle   tMainWindow;
-00097 
-00098         TRACE_MSG("tCreateMainWindow");
-00099 
-00100         tMainWindow = Window_Create("MainWindow", template_TITLEMIN);
-00101         if (tMainWindow == 0) {
-00102                 werr(1, "I can't find the 'MainWindow' template");
-00103         }
-00104         return tMainWindow;
-00105 } /* end of tCreateMainWindow */
-00106 
-00107 /*
-00108  * vCreateScaleWindow - create the Scale view window
-00109  *
-00110  * remark: does not return if the Scale view window can't be created
-00111  */
-00112 static window_handle
-00113 tCreateScaleWindow(void)
-00114 {
-00115         window_handle   tScaleWindow;
-00116 
-00117         TRACE_MSG("tCreateScaleWindow");
-00118 
-00119         tScaleWindow = Window_Create("ScaleView", template_TITLEMIN);
-00120         if (tScaleWindow == 0) {
-00121                 werr(1, "I can't find the 'ScaleView' template");
-00122         }
-00123         return tScaleWindow;
-00124 } /* end of tCreateScaleWindow */
-00125 
-00126 /*
-00127  * pCreateDiagram - create and initialize a diagram
-00128  *
-00129  * remark: does not return if the diagram can't be created
-00130  */
-00131 diagram_type *
-00132 pCreateDiagram(const char *szTask, const char *szFilename)
-00133 {
-00134         diagram_type    *pDiag;
-00135         options_type    tOptions;
-00136         window_handle   tMainWindow, tScaleWindow;
-00137         wimp_box        tBox;
-00138 
-00139         TRACE_MSG("pCreateDiagram");
-00140 
-00141         fail(szTask == NULL || szTask[0] == '\0');
-00142 
-00143         /* Create the main window */
-00144         tMainWindow = tCreateMainWindow();
-00145 
-00146         /* Create the scale view window */
-00147         tScaleWindow = tCreateScaleWindow();
-00148 
-00149         /* Get the necessary memory */
-00150         pDiag = xmalloc(sizeof(diagram_type));
-00151         if (flex_alloc((flex_ptr)&pDiag->tInfo.data, INITIAL_SIZE) != 1) {
-00152                 werr(1, "Memory allocation failed, unable to continue");
-00153         }
-00154 
-00155         /* Initialize the diagram */
-00156         vGetOptions(&tOptions);
-00157         pDiag->tMainWindow = tMainWindow;
-00158         pDiag->tScaleWindow = tScaleWindow;
-00159         pDiag->iScaleFactorCurr = tOptions.iScaleFactor;
-00160         pDiag->iScaleFactorTemp = tOptions.iScaleFactor;
-00161         pDiag->tMemorySize = INITIAL_SIZE;
-00162         tBox.min.x = 0;
-00163         tBox.min.y = -(Drawfile_ScreenToDraw(32 + 3) * 8 + 1);
-00164         tBox.max.x = Drawfile_ScreenToDraw(16) * MIN_SCREEN_WIDTH + 1;
-00165         tBox.max.y = 0;
-00166         Error_CheckFatal(Drawfile_CreateDiagram(&pDiag->tInfo,
-00167                                         pDiag->tMemorySize, szTask, tBox));
-00168         DBG_DEC(pDiag->tInfo.length);
-00169         pDiag->lXleft = 0;
-00170         pDiag->lYtop = 0;
-00171         strncpy(pDiag->szFilename,
-00172                         szBasename(szFilename), sizeof(pDiag->szFilename) - 1);
-00173         pDiag->szFilename[sizeof(pDiag->szFilename) - 1] = '\0';
-00174         /* Return success */
-00175         return pDiag;
-00176 } /* end of pCreateDiagram */
-00177 
-00178 /*
-00179  * bDestroyDiagram - remove a diagram by freeing the memory it uses
-00180  */
-00181 BOOL
-00182 bDestroyDiagram(event_pollblock *pEvent, void *pvReference)
-00183 {
-00184         diagram_type    *pDiag;
-00185         window_handle   tWindow;
-00186 
-00187         TRACE_MSG("bDestroyDiagram");
-00188 
-00189         fail(pEvent == NULL);
-00190         fail(pvReference == NULL);
-00191 
-00192         if (pEvent == NULL || pvReference == NULL) {
-00193                 return FALSE;
-00194         }
-00195 
-00196         pDiag = (diagram_type *)pvReference;
-00197 
-00198         switch (pEvent->type) {
-00199         case event_CLOSE:
-00200                 tWindow = pEvent->data.openblock.window;
-00201                 break;
-00202         case event_KEY:
-00203                 tWindow = pEvent->data.key.caret.window;
-00204                 break;
-00205         default:
-00206                 DBG_DEC(pEvent->type);
-00207                 return FALSE;
-00208         }
-00209         if (tWindow != pDiag->tMainWindow) {
-00210                 return FALSE;
-00211         }
-00212 
-00213         /* Delete the main window */
-00214         Window_Delete(pDiag->tMainWindow);
-00215         pDiag->tMainWindow = 0;
-00216 
-00217         /* Delete the scale window */
-00218         Window_Delete(pDiag->tScaleWindow);
-00219         pDiag->tScaleWindow = 0;
-00220 
-00221 #if defined(__GNUC__)
-00222         /*
-00223          * Remove all references to the diagram that will be free-ed
-00224          * by undoing the EventMsg_Claim's from within the Menu_Warn's
-00225          */
-00226         while (EventMsg_ReleaseSpecific(message_MENUWARNING, window_ANY,
-00227                                         bSaveTextfile, pDiag))
-00228                 ; /* EMPTY */
-00229         while (EventMsg_ReleaseSpecific(message_MENUWARNING, window_ANY,
-00230                                         bSaveDrawfile, pDiag))
-00231                 ; /* EMPTY */
-00232         while (EventMsg_ReleaseSpecific(message_MENUWARNING, window_ANY,
-00233                                         bScaleOpenAction, pDiag))
-00234                 ; /* EMPTY */
-00235 #endif /* __GNUC__ */
-00236 
-00237         /* Free the memory */
-00238         if (pDiag->tInfo.data != NULL && pDiag->tMemorySize != 0) {
-00239                 flex_free((flex_ptr)&pDiag->tInfo.data);
-00240         }
-00241         /* Just to be on the save side */
-00242         pDiag->tInfo.data = NULL;
-00243         pDiag->tInfo.length = 0;
-00244         pDiag->tMemorySize = 0;
-00245 
-00246         /* Destroy the diagram itself */
-00247         pDiag = xfree(pDiag);
-00248         return TRUE;
-00249 } /* end of bDestroyDiagram */
-00250 
-00251 /*
-00252  * vExtendDiagramSize - make sure the diagram is big enough
-00253  */
-00254 static void
-00255 vExtendDiagramSize(diagram_type *pDiag, size_t tSize)
-00256 {
-00257         TRACE_MSG("vExtendDiagramSize");
-00258 
-00259         fail(pDiag == NULL || tSize % 4 != 0);
-00260 
-00261         while (pDiag->tInfo.length + tSize > pDiag->tMemorySize) {
-00262                 if (flex_extend((flex_ptr)&pDiag->tInfo.data,
-00263                                 pDiag->tMemorySize + EXTENSION_SIZE) != 1) {
-00264                         werr(1, "Memory extend failed, unable to continue");
-00265                 }
-00266                 pDiag->tMemorySize += EXTENSION_SIZE;
-00267                 NO_DBG_DEC(pDiag->tMemorySize);
-00268         }
-00269         TRACE_MSG("end of vExtendDiagramSize");
-00270 } /* end of vExtendDiagramSize */
-00271 
-00272 /*
-00273  * vPrologue2 - prologue part 2; add a font list to a diagram
-00274  */
-00275 void
-00276 vPrologue2(diagram_type *pDiag, int iWordVersion)
-00277 {
-00278         drawfile_object *pNew;
-00279         const font_table_type   *pTmp;
-00280         char    *pcTmp;
-00281         size_t  tRealSize, tSize;
-00282         int     iCount;
-00283 
-00284         TRACE_MSG("vPrologue2");
-00285 
-00286         fail(pDiag == NULL);
-00287 
-00288         if (tGetFontTableLength() == 0) {
-00289                 return;
-00290         }
-00291         tRealSize = offsetof(drawfile_object, data);
-00292         pTmp = NULL;
-00293         while ((pTmp = pGetNextFontTableRecord(pTmp)) != NULL) {
-00294                 tRealSize += 2 + strlen(pTmp->szOurFontname);
-00295         }
-00296         DBG_DEC(tRealSize);
-00297         tSize = ROUND4(tRealSize);
-00298         vExtendDiagramSize(pDiag, tSize);
-00299         pNew = xmalloc(tSize);
-00300         memset(pNew, 0, tSize);
-00301         pNew->type = drawfile_TYPE_FONT_TABLE;
-00302         pNew->size = tSize;
-00303         pcTmp = (char *)&pNew->data.font_table.font_def[0].font_ref;
-00304         iCount = 0;
-00305         pTmp = NULL;
-00306         while ((pTmp = pGetNextFontTableRecord(pTmp)) != NULL) {
-00307                 *pcTmp = ++iCount;
-00308                 pcTmp++;
-00309                 strcpy(pcTmp, pTmp->szOurFontname);
-00310                 pcTmp += 1 + strlen(pTmp->szOurFontname);
-00311         }
-00312         Error_CheckFatal(Drawfile_AppendObject(&pDiag->tInfo,
-00313                         pDiag->tMemorySize, pNew, TRUE));
-00314         pNew = xfree(pNew);
-00315 } /* end of vPrologue2 */
-00316 
-00317 /*
-00318  * vSubstring2Diagram - put a sub string into a diagram
-00319  */
-00320 void
-00321 vSubstring2Diagram(diagram_type *pDiag,
-00322         char *szString, size_t tStringLength, long lStringWidth,
-00323         UCHAR ucFontColor, USHORT usFontstyle, drawfile_fontref tFontRef,
-00324         USHORT usFontSize, USHORT usMaxFontSize)
-00325 {
-00326         drawfile_object *pNew;
-00327         long    lSizeX, lSizeY, lOffset, l20, lYMove;
-00328         size_t  tRealSize, tSize;
-00329 
-00330         TRACE_MSG("vSubstring2Diagram");
-00331 
-00332         fail(pDiag == NULL || szString == NULL);
-00333         fail(pDiag->lXleft < 0);
-00334         fail(tStringLength != strlen(szString));
-00335         fail(usFontSize < MIN_FONT_SIZE || usFontSize > MAX_FONT_SIZE);
-00336         fail(usMaxFontSize < MIN_FONT_SIZE || usMaxFontSize > MAX_FONT_SIZE);
-00337         fail(usFontSize > usMaxFontSize);
-00338 
-00339         if (szString[0] == '\0' || tStringLength == 0) {
-00340                 return;
-00341         }
-00342 
-00343         if (tFontRef == 0) {
-00344                 lOffset = Drawfile_ScreenToDraw(2);
-00345                 l20 = Drawfile_ScreenToDraw(32 + 3);
-00346                 lSizeX = Drawfile_ScreenToDraw(16);
-00347                 lSizeY = Drawfile_ScreenToDraw(32);
-00348         } else {
-00349                 lOffset = lToBaseLine(usMaxFontSize);
-00350                 l20 = lWord2DrawUnits20(usMaxFontSize);
-00351                 lSizeX = lWord2DrawUnits00(usFontSize);
-00352                 lSizeY = lWord2DrawUnits00(usFontSize);
-00353         }
-00354 
-00355         lYMove = 0;
-00356 
-00357         /* Up for superscript */
-00358         if (bIsSuperscript(usFontstyle)) {
-00359                 lYMove = lMilliPoints2DrawUnits((((long)usFontSize + 1) / 2) * 375);
-00360         }
-00361         /* Down for subscript */
-00362         if (bIsSubscript(usFontstyle)) {
-00363                 lYMove = -lMilliPoints2DrawUnits((long)usFontSize * 125);
-00364         }
-00365 
-00366         tRealSize = offsetof(drawfile_object, data);
-00367         tRealSize += sizeof(drawfile_text) + tStringLength;
-00368         tSize = ROUND4(tRealSize);
-00369         vExtendDiagramSize(pDiag, tSize);
-00370         pNew = xmalloc(tSize);
-00371         memset(pNew, 0, tSize);
-00372         pNew->type = drawfile_TYPE_TEXT;
-00373         pNew->size = tSize;
-00374         pNew->data.text.bbox.min.x = (int)pDiag->lXleft;
-00375         pNew->data.text.bbox.min.y = (int)(pDiag->lYtop + lYMove);
-00376         pNew->data.text.bbox.max.x = (int)(pDiag->lXleft + lStringWidth);
-00377         pNew->data.text.bbox.max.y = (int)(pDiag->lYtop + l20 + lYMove);
-00378         pNew->data.text.fill.value = (int)ulColor2Color(ucFontColor);
-00379         pNew->data.text.bg_hint.value = 0xffffff00;     /* White */
-00380         pNew->data.text.style.font_ref = tFontRef;
-00381         pNew->data.text.style.reserved[0] = 0;
-00382         pNew->data.text.style.reserved[1] = 0;
-00383         pNew->data.text.style.reserved[2] = 0;
-00384         pNew->data.text.xsize = (int)lSizeX;
-00385         pNew->data.text.ysize = (int)lSizeY;
-00386         pNew->data.text.base.x = (int)pDiag->lXleft;
-00387         pNew->data.text.base.y = (int)(pDiag->lYtop + lOffset + lYMove);
-00388         strncpy(pNew->data.text.text, szString, tStringLength);
-00389         pNew->data.text.text[tStringLength] = '\0';
-00390         Error_CheckFatal(Drawfile_AppendObject(&pDiag->tInfo,
-00391                         pDiag->tMemorySize, pNew, TRUE));
-00392         pNew = xfree(pNew);
-00393         /*draw_translateText(&pDiag->tInfo);*/
-00394         pDiag->lXleft += lStringWidth;
-00395         TRACE_MSG("leaving vSubstring2Diagram");
-00396 } /* end of vSubstring2Diagram */
-00397 
-00398 /*
-00399  * vImage2Diagram - put an image into a diagram
-00400  */
-00401 void
-00402 vImage2Diagram(diagram_type *pDiag, const imagedata_type *pImg,
-00403         UCHAR *pucImage, size_t tImageSize)
-00404 {
-00405         drawfile_object *pNew;
-00406         long    lWidth, lHeight;
-00407         size_t  tRealSize, tSize;
-00408 
-00409         TRACE_MSG("vImage2Diagram");
-00410 
-00411         fail(pDiag == NULL);
-00412         fail(pImg == NULL);
-00413         fail(pDiag->lXleft < 0);
-00414         fail(pImg->eImageType != imagetype_is_dib &&
-00415              pImg->eImageType != imagetype_is_jpeg);
-00416 
-00417         DBG_DEC_C(pDiag->lXleft != 0, pDiag->lXleft);
-00418 
-00419         lWidth = lPoints2DrawUnits(pImg->iHorSizeScaled);
-00420         lHeight = lPoints2DrawUnits(pImg->iVerSizeScaled);
-00421         DBG_DEC(lWidth);
-00422         DBG_DEC(lHeight);
-00423 
-00424         pDiag->lYtop -= lHeight;
-00425 
-00426         tRealSize = offsetof(drawfile_object, data);
-00427         switch (pImg->eImageType) {
-00428         case imagetype_is_dib:
-00429                 tRealSize += sizeof(drawfile_sprite) + tImageSize;
-00430                 tSize = ROUND4(tRealSize);
-00431                 vExtendDiagramSize(pDiag, tSize);
-00432                 pNew = xmalloc(tSize);
-00433                 memset(pNew, 0, tSize);
-00434                 pNew->type = drawfile_TYPE_SPRITE;
-00435                 pNew->size = tSize;
-00436                 pNew->data.sprite.bbox.min.x = (int)pDiag->lXleft;
-00437                 pNew->data.sprite.bbox.min.y = (int)pDiag->lYtop;
-00438                 pNew->data.sprite.bbox.max.x = (int)(pDiag->lXleft + lWidth);
-00439                 pNew->data.sprite.bbox.max.y = (int)(pDiag->lYtop + lHeight);
-00440                 memcpy(&pNew->data.sprite.header, pucImage, tImageSize);
-00441                 break;
-00442         case imagetype_is_jpeg:
-00443 #if defined(DEBUG)
-00444                 (void)bGetJpegInfo(pucImage, tImageSize);
-00445 #endif /* DEBUG */
-00446                 tRealSize += sizeof(drawfile_jpeg) + tImageSize;
-00447                 tSize = ROUND4(tRealSize);
-00448                 vExtendDiagramSize(pDiag, tSize);
-00449                 pNew = xmalloc(tSize);
-00450                 memset(pNew, 0, tSize);
-00451                 pNew->type = drawfile_TYPE_JPEG;
-00452                 pNew->size = tSize;
-00453                 pNew->data.jpeg.bbox.min.x = (int)pDiag->lXleft;
-00454                 pNew->data.jpeg.bbox.min.y = (int)pDiag->lYtop;
-00455                 pNew->data.jpeg.bbox.max.x = (int)(pDiag->lXleft + lWidth);
-00456                 pNew->data.jpeg.bbox.max.y = (int)(pDiag->lYtop + lHeight);
-00457                 pNew->data.jpeg.width = (int)lWidth;
-00458                 pNew->data.jpeg.height = (int)lHeight;
-00459                 pNew->data.jpeg.xdpi = 90;
-00460                 pNew->data.jpeg.ydpi = 90;
-00461                 pNew->data.jpeg.trfm.entries[0][0] = 0x10000;
-00462                 pNew->data.jpeg.trfm.entries[0][1] = 0;
-00463                 pNew->data.jpeg.trfm.entries[1][0] = 0;
-00464                 pNew->data.jpeg.trfm.entries[1][1] = 0x10000;
-00465                 pNew->data.jpeg.trfm.entries[2][0] = (int)pDiag->lXleft;
-00466                 pNew->data.jpeg.trfm.entries[2][1] = (int)pDiag->lYtop;
-00467                 pNew->data.jpeg.len = tImageSize;
-00468                 memcpy(pNew->data.jpeg.data, pucImage, tImageSize);
-00469                 break;
-00470         default:
-00471                 DBG_DEC(pImg->eImageType);
-00472                 pNew = NULL;
-00473                 break;
-00474         }
-00475 
-00476         Error_CheckFatal(Drawfile_AppendObject(&pDiag->tInfo,
-00477                                         pDiag->tMemorySize, pNew, TRUE));
-00478         pNew = xfree(pNew);
-00479         pDiag->lXleft = 0;
-00480 } /* end of vImage2Diagram */
-00481 
-00482 /*
-00483  * bAddDummyImage - add a dummy image
-00484  *
-00485  * return TRUE when successful, otherwise FALSE
-00486  */
-00487 BOOL
-00488 bAddDummyImage(diagram_type *pDiag, const imagedata_type *pImg)
-00489 {
-00490         drawfile_object *pNew;
-00491         int     *piTmp;
-00492         long    lWidth, lHeight;
-00493         size_t  tRealSize, tSize;
-00494 
-00495         TRACE_MSG("bAddDummyImage");
-00496 
-00497         fail(pDiag == NULL);
-00498         fail(pImg == NULL);
-00499         fail(pDiag->lXleft < 0);
-00500 
-00501         if (pImg->iVerSizeScaled <= 0 || pImg->iHorSizeScaled <= 0) {
-00502                 return FALSE;
-00503         }
-00504 
-00505         DBG_DEC_C(pDiag->lXleft != 0, pDiag->lXleft);
-00506 
-00507         lWidth = lPoints2DrawUnits(pImg->iHorSizeScaled);
-00508         lHeight = lPoints2DrawUnits(pImg->iVerSizeScaled);
-00509 
-00510         pDiag->lYtop -= lHeight;
-00511 
-00512         tRealSize = offsetof(drawfile_object, data);
-00513         tRealSize += sizeof(drawfile_path) + (14 - 1) * sizeof(int);
-00514         tSize = ROUND4(tRealSize);
-00515         vExtendDiagramSize(pDiag, tSize);
-00516         pNew = xmalloc(tSize);
-00517         memset(pNew, 0, tSize);
-00518         pNew->type = drawfile_TYPE_PATH;
-00519         pNew->size = tSize;
-00520         pNew->data.path.bbox.min.x = (int)pDiag->lXleft;
-00521         pNew->data.path.bbox.min.y = (int)pDiag->lYtop;
-00522         pNew->data.path.bbox.max.x = (int)(pDiag->lXleft + lWidth);
-00523         pNew->data.path.bbox.max.y = (int)(pDiag->lYtop + lHeight);
-00524         pNew->data.path.fill.value = -1;
-00525         pNew->data.path.outline.value = 0x4d4d4d00;     /* Gray 70 percent */
-00526         pNew->data.path.width = (int)lMilliPoints2DrawUnits(500);
-00527         pNew->data.path.style.flags = 0;
-00528         pNew->data.path.style.reserved = 0;
-00529         pNew->data.path.style.cap_width = 0;
-00530         pNew->data.path.style.cap_length = 0;
-00531         piTmp = pNew->data.path.path;
-00532         *piTmp++ = drawfile_PATH_MOVE_TO;
-00533         *piTmp++ = pNew->data.path.bbox.min.x;
-00534         *piTmp++ = pNew->data.path.bbox.min.y;
-00535         *piTmp++ = drawfile_PATH_LINE_TO;
-00536         *piTmp++ = pNew->data.path.bbox.min.x;
-00537         *piTmp++ = pNew->data.path.bbox.max.y;
-00538         *piTmp++ = drawfile_PATH_LINE_TO;
-00539         *piTmp++ = pNew->data.path.bbox.max.x;
-00540         *piTmp++ = pNew->data.path.bbox.max.y;
-00541         *piTmp++ = drawfile_PATH_LINE_TO;
-00542         *piTmp++ = pNew->data.path.bbox.max.x;
-00543         *piTmp++ = pNew->data.path.bbox.min.y;
-00544         *piTmp++ = drawfile_PATH_CLOSE_LINE;
-00545         *piTmp++ = drawfile_PATH_END_PATH;
-00546 
-00547         Error_CheckFatal(Drawfile_AppendObject(&pDiag->tInfo,
-00548                                         pDiag->tMemorySize, pNew, TRUE));
-00549         pNew = xfree(pNew);
-00550         pDiag->lXleft = 0;
-00551         return TRUE;
-00552 } /* end of bAddDummyImage */
-00553 
-00554 /*
-00555  * vMove2NextLine - move to the next line
-00556  */
-00557 void
-00558 vMove2NextLine(diagram_type *pDiag, drawfile_fontref tFontRef,
-00559         USHORT usFontSize)
-00560 {
-00561         long    l20;
-00562 
-00563         TRACE_MSG("vMove2NextLine");
-00564 
-00565         fail(pDiag == NULL);
-00566         fail(usFontSize < MIN_FONT_SIZE || usFontSize > MAX_FONT_SIZE);
-00567 
-00568         if (tFontRef == 0) {
-00569                 l20 = Drawfile_ScreenToDraw(32 + 3);
-00570         } else {
-00571                 l20 = lWord2DrawUnits20(usFontSize);
-00572         }
-00573         pDiag->lYtop -= l20;
-00574 } /* end of vMove2NextLine */
-00575 
-00576 /*
-00577  * Create an start of paragraph (Phase 1)
-00578  */
-00579 void
-00580 vStartOfParagraph1(diagram_type *pDiag, long lBeforeIndentation)
-00581 {
-00582         TRACE_MSG("vStartOfParagraph1");
-00583 
-00584         fail(pDiag == NULL);
-00585         fail(lBeforeIndentation < 0);
-00586 
-00587         pDiag->lXleft = 0;
-00588         pDiag->lYtop -= lMilliPoints2DrawUnits(lBeforeIndentation);
-00589 } /* end of vStartOfParagraph1 */
-00590 
-00591 /*
-00592  * Create an start of paragraph (Phase 2)
-00593  * DUMMY function
-00594  */
-00595 void
-00596 vStartOfParagraph2(diagram_type *pDiag)
-00597 {
-00598         TRACE_MSG("vStartOfParagraph2");
-00599 } /* end of vStartOfParagraph2 */
-00600 
-00601 /*
-00602  * Create an end of paragraph
-00603  */
-00604 void
-00605 vEndOfParagraph(diagram_type *pDiag,
-00606         drawfile_fontref tFontRef, USHORT usFontSize, long lAfterIndentation)
-00607 {
-00608         TRACE_MSG("vEndOfParagraph");
-00609 
-00610         fail(pDiag == NULL);
-00611         fail(usFontSize < MIN_FONT_SIZE || usFontSize > MAX_FONT_SIZE);
-00612         fail(lAfterIndentation < 0);
-00613 
-00614         pDiag->lXleft = 0;
-00615         pDiag->lYtop -= lMilliPoints2DrawUnits(lAfterIndentation);
-00616 } /* end of vEndOfParagraph */
-00617 
-00618 /*
-00619  * Create an end of page
-00620  */
-00621 void
-00622 vEndOfPage(diagram_type *pDiag, long lAfterIndentation, BOOL bNewSection)
-00623 {
-00624         TRACE_MSG("vEndOfPage");
-00625 
-00626         fail(pDiag == NULL);
-00627         fail(lAfterIndentation < 0);
-00628 
-00629         pDiag->lXleft = 0;
-00630         pDiag->lYtop -= lMilliPoints2DrawUnits(lAfterIndentation);
-00631 } /* end of vEndOfPage */
-00632 
-00633 /*
-00634  * vSetHeaders - set the headers
-00635  * DUMMY function
-00636  */
-00637 void
-00638 vSetHeaders(diagram_type *pDiag, USHORT usIstd)
-00639 {
-00640         TRACE_MSG("vSetHeaders");
-00641 } /* end of vSetHeaders */
-00642 
-00643 /*
-00644  * Create a start of list
-00645  * DUMMY function
-00646  */
-00647 void
-00648 vStartOfList(diagram_type *pDiag, UCHAR ucNFC, BOOL bIsEndOfTable)
-00649 {
-00650         TRACE_MSG("vStartOfList");
-00651 } /* end of vStartOfList */
-00652 
-00653 /*
-00654  * Create an end of list
-00655  * DUMMY function
-00656  */
-00657 void
-00658 vEndOfList(diagram_type *pDiag)
-00659 {
-00660         TRACE_MSG("vEndOfList");
-00661 } /* end of vEndOfList */
-00662 
-00663 /*
-00664  * Create a start of a list item
-00665  * DUMMY function
-00666  */
-00667 void
-00668 vStartOfListItem(diagram_type *pDiag, BOOL bNoMarks)
-00669 {
-00670         TRACE_MSG("vStartOfListItem");
-00671 } /* end of vStartOfListItem */
-00672 
-00673 /*
-00674  * Create an end of a table
-00675  * DUMMY function
-00676  */
-00677 void
-00678 vEndOfTable(diagram_type *pDiag)
-00679 {
-00680         TRACE_MSG("vEndOfTable");
-00681 } /* end of vEndTable */
-00682 
-00683 /*
-00684  * Add a table row
-00685  * DUMMY function
-00686  *
-00687  * Returns TRUE when conversion type is XML
-00688  */
-00689 BOOL
-00690 bAddTableRow(diagram_type *pDiag, char **aszColTxt,
-00691         int iNbrOfColumns, const short *asColumnWidth, UCHAR ucBorderInfo)
-00692 {
-00693         TRACE_MSG("bAddTableRow");
-00694 
-00695         return FALSE;
-00696 } /* end of bAddTableRow */
-00697 
-00698 /*
-00699  * vForceRedraw - force a redraw of the main window
-00700  */
-00701 static void
-00702 vForceRedraw(diagram_type *pDiag)
-00703 {
-00704         window_state            tWindowState;
-00705         window_redrawblock      tRedraw;
-00706         int     x0, y0, x1, y1;
-00707 
-00708         TRACE_MSG("vForceRedraw");
-00709 
-00710         fail(pDiag == NULL);
-00711 
-00712         DBG_DEC(pDiag->iScaleFactorCurr);
-00713 
-00714         /* Read the size of the current diagram */
-00715         Drawfile_QueryBox(&pDiag->tInfo, &tRedraw.rect, TRUE);
-00716         /* Adjust the size of the work area */
-00717         x0 = tRedraw.rect.min.x * pDiag->iScaleFactorCurr / 100 - 1;
-00718         y0 = tRedraw.rect.min.y * pDiag->iScaleFactorCurr / 100 - 1;
-00719         x1 = tRedraw.rect.max.x * pDiag->iScaleFactorCurr / 100 + 1;
-00720         y1 = tRedraw.rect.max.y * pDiag->iScaleFactorCurr / 100 + 1;
-00721         /* Work area extension */
-00722         x0 -= WORKAREA_EXTENSION;
-00723         y0 -= WORKAREA_EXTENSION;
-00724         x1 += WORKAREA_EXTENSION;
-00725         y1 += WORKAREA_EXTENSION;
-00726         Window_SetExtent(pDiag->tMainWindow, x0, y0, x1, y1);
-00727         /* Widen the box slightly to be sure all the edges are drawn */
-00728         x0 -= 5;
-00729         y0 -= 5;
-00730         x1 += 5;
-00731         y1 += 5;
-00732         /* Force the redraw */
-00733         Window_ForceRedraw(pDiag->tMainWindow, x0, y0, x1, y1);
-00734         /* Reopen the window to show the correct size */
-00735         Error_CheckFatal(Wimp_GetWindowState(pDiag->tMainWindow, &tWindowState));
-00736         tWindowState.openblock.behind = -1;
-00737         Error_CheckFatal(Wimp_OpenWindow(&tWindowState.openblock));
-00738 } /* end of vForceRedraw */
-00739 
-00740 /*
-00741  * vShowDiagram - put the diagram on the screen
-00742  */
-00743 void
-00744 vShowDiagram(diagram_type *pDiag)
-00745 {
-00746         wimp_box        tRect;
-00747         int     x0, y0, x1, y1;
-00748 
-00749         TRACE_MSG("vShowDiagram");
-00750 
-00751         fail(pDiag == NULL);
-00752 
-00753         Window_Show(pDiag->tMainWindow, open_NEARLAST);
-00754         Drawfile_QueryBox(&pDiag->tInfo, &tRect, TRUE);
-00755         /* Work area extension */
-00756         x0 = tRect.min.x - WORKAREA_EXTENSION;
-00757         y0 = tRect.min.y - WORKAREA_EXTENSION;
-00758         x1 = tRect.max.x + WORKAREA_EXTENSION;
-00759         y1 = tRect.max.y + WORKAREA_EXTENSION;
-00760         Window_SetExtent(pDiag->tMainWindow, x0, y0, x1, y1);
-00761         vForceRedraw(pDiag);
-00762 } /* end of vShowDiagram */
-00763 
-00764 /*
-00765  * vMainButtonClick - handle mouse buttons clicks for the main screen
-00766  */
-00767 void
-00768 vMainButtonClick(mouse_block *pMouse)
-00769 {
-00770         caret_block     tCaret;
-00771         window_state    ws;
-00772 
-00773         TRACE_MSG("vMainButtonClick");
-00774 
-00775         fail(pMouse == NULL);
-00776 
-00777         DBG_DEC(pMouse->button.data.select);
-00778         DBG_DEC(pMouse->button.data.adjust);
-00779         DBG_DEC(pMouse->window);
-00780         DBG_DEC(pMouse->icon);
-00781 
-00782         if (pMouse->window >= 0 &&
-00783             pMouse->icon == -1 &&
-00784             (pMouse->button.data.select || pMouse->button.data.adjust)) {
-00785                 /* Get the input focus */
-00786                 Error_CheckFatal(Wimp_GetWindowState(pMouse->window, &ws));
-00787                 tCaret.window = pMouse->window;
-00788                 tCaret.icon = -1;
-00789                 tCaret.offset.x = pMouse->pos.x - ws.openblock.screenrect.min.x;
-00790                 tCaret.offset.y = pMouse->pos.y - ws.openblock.screenrect.max.y;
-00791                 tCaret.height = (int)BIT(25);
-00792                 tCaret.index = 0;
-00793                 Error_CheckFatal(Wimp_SetCaretPosition(&tCaret));
-00794         }
-00795 } /* end of vMainButtonClick */
-00796 
-00797 /*
-00798  * bMainKeyPressed - handle pressed keys for the main window
-00799  */
-00800 BOOL
-00801 bMainKeyPressed(event_pollblock *pEvent, void *pvReference)
-00802 {
-00803         diagram_type    *pDiag;
-00804 
-00805         TRACE_MSG("bMainKeyPressed");
-00806 
-00807         fail(pEvent == NULL);
-00808         fail(pEvent->type != event_KEY);
-00809         fail(pvReference == NULL);
-00810 
-00811         pDiag = (diagram_type *)pvReference;
-00812 
-00813         fail(pEvent->data.key.caret.window != pDiag->tMainWindow);
-00814 
-00815 
-00816         switch (pEvent->data.key.code) {
-00817         case keycode_CTRL_F2:           /* Ctrl F2 */
-00818                 bDestroyDiagram(pEvent, pvReference);
-00819                 break;
-00820         case keycode_F3:                /* F3 */
-00821                 bSaveDrawfile(pEvent, pvReference);
-00822                 break;
-00823         case keycode_SHIFT_F3:          /* Shift F3 */
-00824                 bSaveTextfile(pEvent, pvReference);
-00825                 break;
-00826         default:
-00827                 DBG_DEC(pEvent->data.key.code);
-00828                 Error_CheckFatal(Wimp_ProcessKey(pEvent->data.key.code));
-00829         }
-00830         return TRUE;
-00831 } /* end of bMainKeyPressed */
-00832 
-00833 /*
-00834  * bRedrawMainWindow - redraw the main window
-00835  */
-00836 BOOL
-00837 bRedrawMainWindow(event_pollblock *pEvent, void *pvReference)
-00838 {
-00839         window_redrawblock      tBlock;
-00840         diagram_type    *pDiag;
-00841         drawfile_info   *pInfo;
-00842         double          dScaleFactor;
-00843         BOOL            bMore;
-00844 
-00845         TRACE_MSG("bRedrawMainWindow");
-00846 
-00847         fail(pEvent == NULL);
-00848         fail(pEvent->type != event_REDRAW);
-00849         fail(pvReference == NULL);
-00850 
-00851         pDiag = (diagram_type *)pvReference;
-00852 
-00853         fail(pDiag->tMainWindow != pEvent->data.openblock.window);
-00854         fail(pDiag->iScaleFactorCurr < MIN_SCALE_FACTOR);
-00855         fail(pDiag->iScaleFactorCurr > MAX_SCALE_FACTOR);
-00856 
-00857         dScaleFactor = (double)pDiag->iScaleFactorCurr / 100.0;
-00858         pInfo = &pDiag->tInfo;
-00859 
-00860         tBlock.window = pEvent->data.openblock.window;
-00861         Error_CheckFatal(Wimp_RedrawWindow(&tBlock, &bMore));
-00862 
-00863         /* If there is no real diagram just go thru the motions */
-00864         while (bMore) {
-00865                 if (pInfo->data != NULL && pInfo->length != 0) {
-00866                         Error_CheckFatal(Drawfile_RenderDiagram(pInfo,
-00867                                                 &tBlock, dScaleFactor));
-00868                 }
-00869                 Error_CheckFatal(Wimp_GetRectangle(&tBlock, &bMore));
-00870         }
-00871         return TRUE;
-00872 } /* end of bRedrawMainWindow */
-00873 
-00874 /*
-00875  * bScaleOpenAction - action to be taken when the Scale view window opens
-00876  */
-00877 BOOL
-00878 bScaleOpenAction(event_pollblock *pEvent, void *pvReference)
-00879 {
-00880         window_state    tWindowState;
-00881         diagram_type    *pDiag;
-00882 
-00883         TRACE_MSG("bScaleOpenAction");
-00884 
-00885         fail(pEvent == NULL);
-00886         fail(pEvent->type != event_SEND);
-00887         fail(pEvent->data.message.header.action != message_MENUWARN);
-00888         fail(pvReference == NULL);
-00889 
-00890         pDiag = (diagram_type *)pvReference;
-00891 
-00892         if (menu_currentopen != pDiag->pSaveMenu ||
-00893             pEvent->data.message.data.menuwarn.selection[0] != SAVEMENU_SCALEVIEW) {
-00894                 return FALSE;
-00895         }
-00896 
-00897         Error_CheckFatal(Wimp_GetWindowState(pDiag->tScaleWindow,
-00898                                                 &tWindowState));
-00899         if (tWindowState.flags.data.open) {
-00900                 /* The window is already open */
-00901                 return TRUE;
-00902         }
-00903 
-00904         DBG_MSG("vScaleOpenAction for real");
-00905 
-00906         pDiag->iScaleFactorTemp = pDiag->iScaleFactorCurr;
-00907         vUpdateWriteableNumber(pDiag->tScaleWindow,
-00908                         SCALE_SCALE_WRITEABLE, pDiag->iScaleFactorTemp);
-00909         Window_Show(pDiag->tScaleWindow, open_UNDERPOINTER);
-00910         return TRUE;
-00911 } /* end of bScaleOpenAction */
-00912 
-00913 /*
-00914  * vSetTitle - set the title of a window
-00915  */
-00916 void
-00917 vSetTitle(diagram_type *pDiag)
-00918 {
-00919         char    szTitle[WINDOW_TITLE_LEN];
-00920 
-00921         TRACE_MSG("vSetTitle");
-00922 
-00923         fail(pDiag == NULL);
-00924         fail(pDiag->szFilename[0] == '\0');
-00925 
-00926         (void)sprintf(szTitle, "%.*s at %d%%",
-00927                                 FILENAME_TITLE_LEN,
-00928                                 pDiag->szFilename,
-00929                                 pDiag->iScaleFactorCurr % 1000);
-00930         if (strlen(pDiag->szFilename) > FILENAME_TITLE_LEN) {
-00931                 szTitle[FILENAME_TITLE_LEN - 1] = OUR_ELLIPSIS;
-00932         }
-00933 
-00934         Window_SetTitle(pDiag->tMainWindow, szTitle);
-00935 } /* end of vSetTitle */
-00936 
-00937 /*
-00938  * vScaleButtonClick - handle a mouse button click in the Scale view window
-00939  */
-00940 void
-00941 vScaleButtonClick(mouse_block *pMouse, diagram_type *pDiag)
-00942 {
-00943         BOOL    bCloseWindow, bRedraw;
-00944 
-00945         TRACE_MSG("vScaleButtonClick");
-00946 
-00947         fail(pMouse == NULL || pDiag == NULL);
-00948         fail(pMouse->window != pDiag->tScaleWindow);
-00949 
-00950         bCloseWindow = FALSE;
-00951         bRedraw = FALSE;
-00952         switch (pMouse->icon) {
-00953         case SCALE_CANCEL_BUTTON:
-00954                 bCloseWindow = TRUE;
-00955                 pDiag->iScaleFactorTemp = pDiag->iScaleFactorCurr;
-00956                 break;
-00957         case SCALE_SCALE_BUTTON:
-00958                 bCloseWindow = TRUE;
-00959                 bRedraw = pDiag->iScaleFactorCurr != pDiag->iScaleFactorTemp;
-00960                 pDiag->iScaleFactorCurr = pDiag->iScaleFactorTemp;
-00961                 break;
-00962         case SCALE_50_PCT:
-00963                 pDiag->iScaleFactorTemp = 50;
-00964                 break;
-00965         case SCALE_75_PCT:
-00966                 pDiag->iScaleFactorTemp = 75;
-00967                 break;
-00968         case SCALE_100_PCT:
-00969                 pDiag->iScaleFactorTemp = 100;
-00970                 break;
-00971         case SCALE_150_PCT:
-00972                 pDiag->iScaleFactorTemp = 150;
-00973                 break;
-00974         default:
-00975                 DBG_DEC(pMouse->icon);
-00976                 break;
-00977         }
-00978         if (bCloseWindow) {
-00979                 /* Close the scale window */
-00980                 Error_CheckFatal(Wimp_CloseWindow(pMouse->window));
-00981                 if (bRedraw) {
-00982                         /* Redraw the main window */
-00983                         vSetTitle(pDiag);
-00984                         vForceRedraw(pDiag);
-00985                 }
-00986         } else {
-00987                 vUpdateWriteableNumber(pMouse->window,
-00988                                 SCALE_SCALE_WRITEABLE,
-00989                                 pDiag->iScaleFactorTemp);
-00990         }
-00991 } /* end of vScaleButtonClick */
-00992 
-00993 /*
-00994  * bScaleKeyPressed - handle pressed keys for the scale window
-00995  */
-00996 BOOL
-00997 bScaleKeyPressed(event_pollblock *pEvent, void *pvReference)
-00998 {
-00999         icon_block      tIcon;
-01000         diagram_type    *pDiag;
-01001         caret_block     *pCaret;
-01002         char            *pcChar;
-01003         int             iTmp;
-01004 
-01005         TRACE_MSG("bScaleKeyPressed");
-01006 
-01007         fail(pEvent == NULL);
-01008         fail(pEvent->type != event_KEY);
-01009         fail(pvReference == NULL);
-01010 
-01011         pCaret = &pEvent->data.key.caret;
-01012         pDiag = (diagram_type *)pvReference;
-01013 
-01014         fail(pEvent->data.key.caret.window != pDiag->tScaleWindow);
-01015 
-01016         DBG_DEC_C(pCaret->icon != SCALE_SCALE_WRITEABLE, pCaret->icon);
-01017         DBG_DEC_C(pCaret->icon == SCALE_SCALE_WRITEABLE, pEvent->data.key.code);
-01018 
-01019         if (pEvent->data.key.code != '\r' ||
-01020             pCaret->icon != SCALE_SCALE_WRITEABLE) {
-01021                 Error_CheckFatal(Wimp_ProcessKey(pEvent->data.key.code));
-01022                 return TRUE;
-01023         }
-01024 
-01025         Error_CheckFatal(Wimp_GetIconState(pCaret->window, pCaret->icon, &tIcon));
-01026         if (!tIcon.flags.data.text || !tIcon.flags.data.indirected) {
-01027                 werr(1, "Icon %d must be indirected text", (int)pCaret->icon);
-01028         }
-01029         iTmp = (int)strtol(tIcon.data.indirecttext.buffer, &pcChar, 10);
-01030         if (*pcChar != '\0' && *pcChar != '\r') {
-01031                 DBG_DEC(*pcChar);
-01032         } else if (iTmp < MIN_SCALE_FACTOR) {
-01033                 pDiag->iScaleFactorTemp = MIN_SCALE_FACTOR;
-01034         } else if (iTmp > MAX_SCALE_FACTOR) {
-01035                 pDiag->iScaleFactorTemp = MAX_SCALE_FACTOR;
-01036         } else {
-01037                 pDiag->iScaleFactorTemp = iTmp;
-01038         }
-01039         pDiag->iScaleFactorCurr = pDiag->iScaleFactorTemp;
-01040         /* Close the scale window */
-01041         Error_CheckFatal(Wimp_CloseWindow(pCaret->window));
-01042         /* Redraw the main window */
-01043         vSetTitle(pDiag);
-01044         vForceRedraw(pDiag);
-01045         return TRUE;
-01046 } /* end of bScaleKeyPressed */
-01047 
-
-
Generated by  - -doxygen 1.6.2
- - diff -r 59758314f811 -r d4524d6a4472 Symbian3/Examples/guid-6013a680-57f9-415b-8851-c4fa63356636/draw_8h_source.html --- a/Symbian3/Examples/guid-6013a680-57f9-415b-8851-c4fa63356636/draw_8h_source.html Fri Jun 11 15:24:34 2010 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,62 +0,0 @@ - - - - -TB9.2 Example Applications: examples/PIPS/antiword/inc/draw.h Source File - - - - - -

examples/PIPS/antiword/inc/draw.h

00001 /*
-00002  * draw.h
-00003  * Copyright (C) 2001 A.J. van Os; Released under GPL
-00004  *
-00005  * Description:
-00006  * Constants and macros to deal with the Draw format
-00007  */
-00008 
-00009 #if !defined(__draw_h)
-00010 #define __draw_h 1
-00011 
-00012 #include "drawftypes.h"
-00013 
-00014 typedef struct draw_jpegstrhdr_tag {
-00015         draw_tagtyp     tag;    /* 1 word  */
-00016         draw_sizetyp    size;   /* 1 word  */
-00017         draw_bboxtyp    bbox;   /* 4 words */
-00018         int     width;          /* 1 word  */
-00019         int     height;         /* 1 word  */
-00020         int     xdpi;           /* 1 word  */
-00021         int     ydpi;           /* 1 word  */
-00022         int     trfm[6];        /* 6 words */
-00023         int     len;            /* 1 word  */
-00024 } draw_jpegstrhdr;
-00025 
-00026 typedef struct draw_jpegstr_tag {
-00027         draw_tagtyp     tag;    /* 1 word  */
-00028         draw_sizetyp    size;   /* 1 word  */
-00029         draw_bboxtyp    bbox;   /* 4 words */
-00030         int     width;          /* 1 word  */
-00031         int     height;         /* 1 word  */
-00032         int     xdpi;           /* 1 word  */
-00033         int     ydpi;           /* 1 word  */
-00034         int     trfm[6];        /* 6 words */
-00035         int     len;            /* 1 word  */
-00036         unsigned char   *jpeg;
-00037 } draw_jpegstr;
-00038 
-00039 typedef union draw_imageType_tag {
-00040         draw_spristr    *sprite;
-00041         draw_jpegstr    *jpeg;
-00042         char            *bytep;
-00043         int             *wordp;
-00044 } draw_imageType;
-00045 
-00046 #endif /* !__draw_h */
-
-
Generated by  - -doxygen 1.6.2
- - diff -r 59758314f811 -r d4524d6a4472 Symbian3/Examples/guid-6013a680-57f9-415b-8851-c4fa63356636/drawfile_8c_source.html --- a/Symbian3/Examples/guid-6013a680-57f9-415b-8851-c4fa63356636/drawfile_8c_source.html Fri Jun 11 15:24:34 2010 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,438 +0,0 @@ - - - - -TB9.2 Example Applications: examples/PIPS/antiword/src/drawfile.c Source File - - - - - -

examples/PIPS/antiword/src/drawfile.c

00001 /*
-00002  * drawfile.c
-00003  * Copyright (C) 2005 A.J. van Os; Released under GPL
-00004  *
-00005  * Description:
-00006  * Functions to process with the Draw diagram
-00007  */
-00008 
-00009 #include <string.h>
-00010 #include "DeskLib:Error.h"
-00011 #include "DeskLib:SWI.h"
-00012 #include "drawfile.h"
-00013 #include "antiword.h"
-00014 
-00015 #define DRAWFILE_OBJECT_TOO_SMALL       200
-00016 #define DRAWFILE_NO_TEXT                201
-00017 #define DRAWFILE_BAD_CHARACTER          202
-00018 #define DRAWFILE_SMALL_MEMORY           203
-00019 #define DRAWFILE_PATH_WITHOUT_LINES     204
-00020 #define DRAWFILE_BAD_PATH_TYPE          205
-00021 #define DRAWFILE_PATH_WITHOUT_END       206
-00022 #define DRAWFILE_BAD_SPRITE_SIZE        207
-00023 #define DRAWFILE_BAD_JPEG_SIZE          208
-00024 #define DRAWFILE_TOO_SMALL              209
-00025 #define DRAWFILE_NOT_A_DRAWFILE         210
-00026 #define DRAWFILE_OBJECT_SIZE            211
-00027 #define DRAWFILE_MANY_FONTTABLES        212
-00028 #define DRAWFILE_TEXT_NO_FONT           213
-00029 #define DRAWFILE_OBJECT_UNEXPECTED      214
-00030 #define DRAWFILE_SIZE_ERROR             215
-00031 
-00032 typedef struct drawfile_error_tag {
-00033         int             iErrorNumber;
-00034         const char      *szErrorText;
-00035 } drawfile_error_type;
-00036 
-00037 static const drawfile_error_type atErrors[] = {
-00038         { DRAWFILE_OBJECT_TOO_SMALL, "Object too small"},
-00039         { DRAWFILE_NO_TEXT, "Text object without text"},
-00040         { DRAWFILE_BAD_CHARACTER, "Bad character in string"},
-00041         { DRAWFILE_SMALL_MEMORY, "Not enough memory reserved"},
-00042         { DRAWFILE_PATH_WITHOUT_LINES, "This path has no lines"},
-00043         { DRAWFILE_BAD_PATH_TYPE, "Bad path-type in path"},
-00044         { DRAWFILE_PATH_WITHOUT_END, "No end of path seen"},
-00045         { DRAWFILE_BAD_SPRITE_SIZE, "Bad sprite size"},
-00046         { DRAWFILE_BAD_JPEG_SIZE, "Bad jpeg size"},
-00047         { DRAWFILE_TOO_SMALL, "Too small to be a drawfile"},
-00048         { DRAWFILE_NOT_A_DRAWFILE, "Not a drawfile"},
-00049         { DRAWFILE_OBJECT_SIZE, "Object with incorrect size"},
-00050         { DRAWFILE_MANY_FONTTABLES, "More than one font table"},
-00051         { DRAWFILE_TEXT_NO_FONT, "Text, but no font table seen"},
-00052         { DRAWFILE_OBJECT_UNEXPECTED, "Unexpected object type"},
-00053         { DRAWFILE_SIZE_ERROR, "Sizes don't match"},
-00054 };
-00055 
-00056 
-00057 /*
-00058  * pFillError - error number to error struct
-00059  */
-00060 static os_error *
-00061 pFillError(int iErrorNumber)
-00062 {
-00063         static os_error         tError;
-00064         const drawfile_error_type       *pTmp;
-00065         const char      *szErrorText;
-00066 
-00067         szErrorText = "Unknown error";
-00068         for (pTmp = atErrors; pTmp < atErrors + elementsof(atErrors); pTmp++) {
-00069                 if (iErrorNumber == pTmp->iErrorNumber) {
-00070                         szErrorText = pTmp->szErrorText;
-00071                         break;
-00072                 }
-00073         }
-00074         tError.errnum = iErrorNumber;
-00075         strncpy(tError.errmess, szErrorText, sizeof(tError.errmess) - 1);
-00076         tError.errmess[sizeof(tError.errmess) - 1] = '\0';
-00077         DBG_DEC(tError.errnum);
-00078         DBG_MSG(tError.errmess);
-00079         return &tError;
-00080 } /* end of pFillError */
-00081 
-00082 /*
-00083  * Drawfile_BBox - Find the bounding box of a diagram
-00084  */
-00085 os_error *
-00086 Drawfile_Bbox(drawfile_bbox_flags flags,
-00087         drawfile_diagram const *diagram,
-00088         int size,
-00089         os_trfm const *trfm,
-00090         wimp_box *bbox)
-00091 {
-00092         return SWI(5, 0, DrawFile_BBox | XOS_Bit,
-00093                 flags, diagram, size, trfm, bbox);
-00094 } /* end of Drawfile_Bbox */
-00095 
-00096 /*
-00097  * Drawfile_CreateDiagram - create an empty drawfile diagram
-00098  */
-00099 os_error *
-00100 Drawfile_CreateDiagram(drawfile_info *pInfo, size_t tMemorySize,
-00101         const char *szCreator, wimp_box tBbox)
-00102 {
-00103         drawfile_diagram        *pDiag;
-00104 
-00105         if (tMemorySize < offsetof(drawfile_diagram, objects)) {
-00106                 return pFillError(DRAWFILE_SMALL_MEMORY);
-00107         }
-00108         pDiag = (drawfile_diagram *)pInfo->data;
-00109         strncpy(pDiag->tag, "Draw", 4);
-00110         pDiag->major_version = 201;
-00111         pDiag->minor_version = 0;
-00112         strncpy(pDiag->source, szCreator, sizeof(pDiag->source));
-00113         pDiag->bbox = tBbox;
-00114         /* Memory in use */
-00115         pInfo->length = offsetof(drawfile_diagram, objects);
-00116         return NULL;
-00117 } /* end of Drawfile_CreateDiagram */
-00118 
-00119 /*
-00120  * Drawfile_AppendObject - append an object to a diagram
-00121  */
-00122 os_error *
-00123 Drawfile_AppendObject(drawfile_info *pInfo, size_t tMemorySize,
-00124         const drawfile_object *pObject, BOOL bRebind)
-00125 {
-00126         wimp_box        *pMainBbox;
-00127         const wimp_box  *pBbox;
-00128         byte            *pAfter;
-00129 
-00130         if (tMemorySize < pInfo->length + pObject->size) {
-00131                 return pFillError(DRAWFILE_OBJECT_TOO_SMALL);
-00132         }
-00133         /* After the last object */
-00134         pAfter = (byte *)pInfo->data + pInfo->length;
-00135         /* Copy in the new data */
-00136         memcpy(pAfter, pObject, pObject->size);
-00137         /* Rebind if needed */
-00138         if (bRebind) {
-00139                 pMainBbox = &((drawfile_diagram *)pInfo->data)->bbox;
-00140                 switch (pObject->type) {
-00141                 case drawfile_TYPE_FONT_TABLE:
-00142                         pBbox = NULL;
-00143                         break;
-00144                 case drawfile_TYPE_TEXT:
-00145                         pBbox = &pObject->data.text.bbox;
-00146                         break;
-00147                 case drawfile_TYPE_PATH:
-00148                         pBbox = &pObject->data.path.bbox;
-00149                         break;
-00150                 case drawfile_TYPE_SPRITE:
-00151                         pBbox = &pObject->data.sprite.bbox;
-00152                         break;
-00153                 case drawfile_TYPE_GROUP:
-00154                         pBbox = &pObject->data.group.bbox;
-00155                         break;
-00156                 case drawfile_TYPE_TAGGED:
-00157                         pBbox = &pObject->data.tagged.bbox;
-00158                         break;
-00159                 case drawfile_TYPE_TEXT_AREA:
-00160                         pBbox = &pObject->data.text_area.bbox;
-00161                         break;
-00162                 case drawfile_TYPE_TEXT_COLUMN:
-00163                         pBbox = NULL;
-00164                         break;
-00165                 case drawfile_TYPE_OPTIONS:
-00166                         pBbox = &pObject->data.options.bbox;
-00167                         break;
-00168                 case drawfile_TYPE_TRFM_TEXT:
-00169                         pBbox = &pObject->data.trfm_text.bbox;
-00170                         break;
-00171                 case drawfile_TYPE_TRFM_SPRITE:
-00172                         pBbox = &pObject->data.trfm_sprite.bbox;
-00173                         break;
-00174                 case drawfile_TYPE_JPEG:
-00175                         pBbox = &pObject->data.jpeg.bbox;
-00176                         break;
-00177                 default:
-00178                         pBbox = NULL;
-00179                         break;
-00180                 }
-00181                 if (pBbox != NULL) {
-00182                         if (pBbox->min.x < pMainBbox->min.x) {
-00183                                 pMainBbox->min.x = pBbox->min.x;
-00184                         }
-00185                         if (pBbox->min.y < pMainBbox->min.y) {
-00186                                 pMainBbox->min.y = pBbox->min.y;
-00187                         }
-00188                         if (pBbox->max.x > pMainBbox->max.x) {
-00189                                 pMainBbox->max.x = pBbox->max.x;
-00190                         }
-00191                         if (pBbox->max.y > pMainBbox->max.y) {
-00192                                 pMainBbox->max.y = pBbox->max.y;
-00193                         }
-00194                 }
-00195         }
-00196         /* Memory in use */
-00197         pInfo->length += pObject->size;
-00198         return NULL;
-00199 } /* end of Drawfile_AppendObject */
-00200 
-00201 /*
-00202  * Replaces the draw_render_diag function from RISC_OSLib
-00203  */
-00204 os_error *
-00205 Drawfile_RenderDiagram(drawfile_info *pInfo, window_redrawblock *pRedraw,
-00206         double dScale)
-00207 {
-00208         int     aiTransform[6];
-00209 
-00210         fail(pInfo == NULL);
-00211         fail(pInfo->data == NULL);
-00212         fail(pRedraw == NULL);
-00213         fail(dScale < 0.01);
-00214 
-00215         aiTransform[0] = (int)(dScale * 0x10000);
-00216         aiTransform[1] = 0;
-00217         aiTransform[2] = 0;
-00218         aiTransform[3] = (int)(dScale * 0x10000);
-00219         aiTransform[4] = (pRedraw->rect.min.x - pRedraw->scroll.x) * 256;
-00220         aiTransform[5] = (pRedraw->rect.max.y - pRedraw->scroll.y) * 256;
-00221 
-00222         return SWI(6, 0, DrawFile_Render | XOS_Bit,
-00223                 0, pInfo->data, pInfo->length, aiTransform, &pRedraw->rect, 0);
-00224 } /* end of Drawfile_RenderDiagram */
-00225 
-00226 /*
-00227  * pVerifyText - verify a text object
-00228  */
-00229 static os_error *
-00230 pVerifyText(const drawfile_text *pText)
-00231 {
-00232         const unsigned char     *pucTmp;
-00233 
-00234         if (pText->text[0] == '\0') {
-00235                 return pFillError(DRAWFILE_NO_TEXT);
-00236         }
-00237         pucTmp = (const unsigned char *)pText->text;
-00238         while (*pucTmp != '\0') {
-00239                 if (*pucTmp < 0x20 || *pucTmp == 0x7f) {
-00240                         return pFillError(DRAWFILE_BAD_CHARACTER);
-00241                 }
-00242                 pucTmp++;
-00243         }
-00244         return NULL;
-00245 } /* end of pVerifyText */
-00246 
-00247 /*
-00248  * pVerifyPath - verify a path object
-00249  */
-00250 static os_error *
-00251 pVerifyPath(const drawfile_path *pPath, int iSize)
-00252 {
-00253         const int       *piTmp;
-00254         int     iElements;
-00255         BOOL    bLine;
-00256 
-00257         bLine = FALSE;
-00258         iElements = (iSize - offsetof(drawfile_path, path)) / 4;
-00259 
-00260         for (piTmp = pPath->path; piTmp < pPath->path + iElements; piTmp++) {
-00261                 switch(*piTmp) {
-00262                 case drawfile_PATH_END_PATH:
-00263                         if (bLine) {
-00264                                 return NULL;
-00265                         }
-00266                         return pFillError(DRAWFILE_PATH_WITHOUT_LINES);
-00267                 case drawfile_PATH_LINE_TO:
-00268                         bLine = TRUE;
-00269                         piTmp += 2;
-00270                         break;
-00271                 case drawfile_PATH_MOVE_TO:
-00272                         piTmp += 2;
-00273                         break;
-00274                 case drawfile_PATH_CLOSE_LINE:
-00275                         bLine = TRUE;
-00276                         break;
-00277                 default:
-00278                         return pFillError(DRAWFILE_BAD_PATH_TYPE);
-00279                 }
-00280         }
-00281         return pFillError(DRAWFILE_PATH_WITHOUT_END);
-00282 } /* end of pVerifyPath */
-00283 
-00284 /*
-00285  * pVerifySprite - verify a sprite object
-00286  */
-00287 static os_error *
-00288 pVerifySprite(const drawfile_sprite *pSprite, int iSize)
-00289 {
-00290         iSize -= offsetof(drawfile_sprite, header);
-00291         if (iSize < pSprite->header.offset_next) {
-00292                 DBG_DEC(iSize);
-00293                 DBG_DEC(pSprite->header.offset_next);
-00294                 return pFillError(DRAWFILE_BAD_SPRITE_SIZE);
-00295         }
-00296         return NULL;
-00297 } /* end of pVerifySprite */
-00298 
-00299 /*
-00300  * pVerifyJpeg - verify a jpeg object
-00301  */
-00302 static os_error *
-00303 pVerifyJpeg(const drawfile_jpeg *pJpeg, int iSize)
-00304 {
-00305         iSize -= offsetof(drawfile_jpeg, data);
-00306         if (iSize < pJpeg->len) {
-00307                 DBG_DEC(iSize);
-00308                 DBG_DEC(pJpeg->len);
-00309                 return pFillError(DRAWFILE_BAD_JPEG_SIZE);
-00310         }
-00311         return NULL;
-00312 } /* end of pVerifyJpeg */
-00313 
-00314 /*
-00315  * Drawfile_VerifyDiagram - Verify the diagram generated from the Word file
-00316  *
-00317  * returns NULL if the diagram is correct
-00318  */
-00319 os_error *
-00320 Drawfile_VerifyDiagram(drawfile_info *pInfo)
-00321 {
-00322         drawfile_diagram        *pDiag;
-00323         drawfile_object *pObj;
-00324         os_error        *pError;
-00325         const char      *pcTmp;
-00326         int             iToGo, iFontTables;
-00327         BOOL            bTypeFontTable;
-00328 
-00329         TRACE_MSG("Drawfile_VerifyDiagram");
-00330 
-00331         fail(pInfo == NULL);
-00332 
-00333         if (pInfo->length < offsetof(drawfile_diagram, objects)) {
-00334                 return pFillError(DRAWFILE_TOO_SMALL);
-00335         }
-00336 
-00337         pDiag = (drawfile_diagram *)pInfo->data;
-00338         if (strncmp(pDiag->tag, "Draw", 4) != 0 ||
-00339             pDiag->major_version != 201 ||
-00340             pDiag->minor_version != 0) {
-00341                 return pFillError(DRAWFILE_NOT_A_DRAWFILE);
-00342         }
-00343 
-00344         iToGo = pInfo->length - offsetof(drawfile_diagram, objects);
-00345         pcTmp = (const char *)pInfo->data + offsetof(drawfile_diagram, objects);
-00346         iFontTables = 0;
-00347         bTypeFontTable = FALSE;
-00348 
-00349         while (iToGo > 0) {
-00350                 pObj = (drawfile_object *)pcTmp;
-00351                 if (pObj->size < 0 || pObj->size % 4 != 0) {
-00352                         return pFillError(DRAWFILE_OBJECT_SIZE);
-00353                 }
-00354                 switch (pObj->type) {
-00355                 case drawfile_TYPE_FONT_TABLE:
-00356                         if (bTypeFontTable) {
-00357                                 return pFillError(DRAWFILE_MANY_FONTTABLES);
-00358                         }
-00359                         bTypeFontTable = TRUE;
-00360                         break;
-00361                 case drawfile_TYPE_TEXT:
-00362                         if (pObj->data.text.style.font_ref != 0 &&
-00363                             !bTypeFontTable) {
-00364                                 return pFillError(DRAWFILE_TEXT_NO_FONT);
-00365                         }
-00366                         pError = pVerifyText(&pObj->data.text);
-00367                         if (pError != NULL) {
-00368                                 return pError;
-00369                         }
-00370                         break;
-00371                 case drawfile_TYPE_PATH:
-00372                         pError = pVerifyPath(&pObj->data.path,
-00373                                 pObj->size - offsetof(drawfile_object, data));
-00374                         if (pError != NULL) {
-00375                                 return pError;
-00376                         }
-00377                         break;
-00378                 case drawfile_TYPE_SPRITE:
-00379                         pError = pVerifySprite(&pObj->data.sprite,
-00380                                 pObj->size - offsetof(drawfile_object, data));
-00381                         if (pError != NULL) {
-00382                                 return pError;
-00383                         }
-00384                         break;
-00385                 case drawfile_TYPE_JPEG:
-00386                         pError = pVerifyJpeg(&pObj->data.jpeg,
-00387                                 pObj->size - offsetof(drawfile_object, data));
-00388                         if (pError != NULL) {
-00389                                 return pError;
-00390                         }
-00391                         break;
-00392                 default:
-00393                         DBG_DEC(pObj->type);
-00394                         return pFillError(DRAWFILE_OBJECT_UNEXPECTED);
-00395                 }
-00396                 pcTmp += pObj->size;
-00397                 iToGo -= pObj->size;
-00398         }
-00399         if (iToGo < 0) {
-00400                 return pFillError(DRAWFILE_SIZE_ERROR);
-00401         }
-00402         return NULL;
-00403 } /* end of Drawfile_VerifyDiagram */
-00404 
-00405 /*
-00406  * Drawfile_QueryBox - Find the bounding box of a diagram
-00407  */
-00408 void
-00409 Drawfile_QueryBox(drawfile_info *pInfo, wimp_box *pRect, BOOL bScreenUnits)
-00410 {
-00411         fail(pInfo == NULL);
-00412         fail(pRect == NULL);
-00413 
-00414         Error_CheckFatal(Drawfile_Bbox(0,
-00415                 pInfo->data, pInfo->length, NULL, pRect));
-00416         if (bScreenUnits) {
-00417                 pRect->min.x = Drawfile_DrawToScreen(pRect->min.x);
-00418                 pRect->min.y = Drawfile_DrawToScreen(pRect->min.y);
-00419                 pRect->max.x = Drawfile_DrawToScreen(pRect->max.x);
-00420                 pRect->max.y = Drawfile_DrawToScreen(pRect->max.y);
-00421         }
-00422 } /* end of Drawfile_QueryBox */
-
-
Generated by  - -doxygen 1.6.2
- - diff -r 59758314f811 -r d4524d6a4472 Symbian3/Examples/guid-6013a680-57f9-415b-8851-c4fa63356636/drawfile_8h_source.html --- a/Symbian3/Examples/guid-6013a680-57f9-415b-8851-c4fa63356636/drawfile_8h_source.html Fri Jun 11 15:24:34 2010 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,449 +0,0 @@ - - - - -TB9.2 Example Applications: examples/PIPS/antiword/inc/drawfile.h Source File - - - - - -

examples/PIPS/antiword/inc/drawfile.h

00001 /*
-00002  * drawfile.h
-00003  * Copyright (C) 2005 A.J. van Os; Released under GNU GPL
-00004  *
-00005  * Description:
-00006  * Include file to deal with drawfiles
-00007  *
-00008  * Based on:
-00009  * C header file for DrawFile
-00010  * written by DefMod (May  4 2004) on Tue May  4 13:34:17 2004
-00011  * Jonathan Coxhead, jonathan@doves.demon.co.uk, 21 Aug 1995
-00012  * OSLib---efficient, type-safe, transparent, extensible,
-00013  * register-safe A P I coverage of RISC O S
-00014  * Copyright (C) 1994 Jonathan Coxhead
-00015  *
-00016  * All credit should go to him, but all the bugs are mine
-00017  */
-00018 
-00019 #if !defined(__drawfile_h)
-00020 #define __drawfile_h
-00021 
-00022 #include "DeskLib:Sprite.h"
-00023 #include "DeskLib:Wimp.h"
-00024 
-00025 #if !defined(BOOL)
-00026 #define BOOL int
-00027 #define TRUE 1
-00028 #define FALSE 0
-00029 #endif /* !BOOL */
-00030 
-00031 /*********************
-00032  * Conversion macros *
-00033  *********************/
-00034 #define Drawfile_DrawToScreen(i) ((i) / 256)
-00035 #define Drawfile_ScreenToDraw(i) ((i) * 256)
-00036 
-00037 /**********************************
-00038  * SWI names and SWI reason codes *
-00039  **********************************/
-00040 #define DrawFile_Render                         0x45540
-00041 #define DrawFile_BBox                           0x45541
-00042 #define DrawFile_DeclareFonts                   0x45542
-00043 
-00044 /********************
-00045  * Type definitions *
-00046  ********************/
-00047 typedef unsigned int                            bits;
-00048 typedef unsigned char                           byte;
-00049 
-00050 typedef byte drawfile_fontref;
-00051 
-00052 typedef byte drawfile_path_style_flags;
-00053 
-00054 typedef bits drawfile_text_flags;
-00055 
-00056 typedef bits drawfile_render_flags;
-00057 
-00058 typedef bits drawfile_declare_fonts_flags;
-00059 
-00060 typedef bits drawfile_paper_options;
-00061 
-00062 typedef bits drawfile_entry_mode;
-00063 
-00064 typedef enum {
-00065   drawfile_TYPE_FONT_TABLE = 0,
-00066   drawfile_TYPE_TEXT = 1,
-00067   drawfile_TYPE_PATH = 2,
-00068   drawfile_TYPE_SPRITE = 5,
-00069   drawfile_TYPE_GROUP = 6,
-00070   drawfile_TYPE_TAGGED = 7,
-00071   drawfile_TYPE_TEXT_AREA = 9,
-00072   drawfile_TYPE_TEXT_COLUMN = 10,
-00073   drawfile_TYPE_OPTIONS = 11,
-00074   drawfile_TYPE_TRFM_TEXT = 12,
-00075   drawfile_TYPE_TRFM_SPRITE = 13,
-00076   drawfile_TYPE_JPEG = 16
-00077 } drawfile_type;
-00078 
-00079 typedef enum {
-00080   drawfile_PATH_END_PATH = 0,
-00081   drawfile_PATH_CONTINUATION = 1,
-00082   drawfile_PATH_MOVE_TO = 2,
-00083   drawfile_PATH_SPECIAL_MOVE_TO = 3,
-00084   drawfile_PATH_CLOSE_GAP = 4,
-00085   drawfile_PATH_CLOSE_LINE = 5,
-00086   drawfile_PATH_BEZIER_TO = 6,
-00087   drawfile_PATH_GAP_TO = 7,
-00088   drawfile_PATH_LINE_TO = 8
-00089 } drawfile_path_type;
-00090 
-00091 typedef struct {
-00092   int start;
-00093   int element_count;
-00094   int elements [6];
-00095 } draw_dash_pattern;
-00096 
-00097 typedef struct {
-00098   int entries [3] [2];
-00099 } os_trfm;
-00100 
-00101 typedef struct {
-00102   void *data;
-00103   size_t length;
-00104 } drawfile_info;
-00105 
-00106 typedef struct {
-00107   drawfile_fontref font_ref;
-00108   char font_name [1];
-00109 } drawfile_font_def;
-00110 
-00111 typedef struct {
-00112   drawfile_fontref font_ref;
-00113   byte reserved [3];
-00114 } drawfile_text_style;
-00115 
-00116 typedef struct {
-00117   drawfile_path_style_flags flags;
-00118   byte reserved;
-00119   byte cap_width;
-00120   byte cap_length;
-00121 } drawfile_path_style;
-00122 
-00123 typedef struct {
-00124   drawfile_font_def font_def[1];
-00125 } drawfile_font_table;
-00126 
-00127 typedef struct {
-00128   wimp_box bbox;
-00129   palette_entry fill;
-00130   palette_entry bg_hint;
-00131   drawfile_text_style style;
-00132   int xsize;
-00133   int ysize;
-00134   wimp_coord base;
-00135   char text [1];
-00136 } drawfile_text;
-00137 
-00138 typedef struct {
-00139   wimp_box bbox;
-00140   palette_entry fill;
-00141   palette_entry outline;
-00142   int width;
-00143   drawfile_path_style style;
-00144   int path [1];
-00145 } drawfile_path;
-00146 
-00147 typedef struct {
-00148   wimp_box bbox;
-00149   palette_entry fill;
-00150   palette_entry outline;
-00151   int width;
-00152   drawfile_path_style style;
-00153   draw_dash_pattern pattern;
-00154   int path [1];
-00155 } drawfile_path_with_pattern;
-00156 
-00157 typedef struct {
-00158   wimp_box bbox;
-00159   sprite_header header;
-00160   byte data [1];
-00161 } drawfile_sprite;
-00162 
-00163 typedef struct  {
-00164   wimp_box bbox;
-00165   char name [12];
-00166   int objects [1];
-00167 } drawfile_group;
-00168 
-00169 typedef struct {
-00170   wimp_box bbox;
-00171   drawfile_type tag;
-00172   int object [1];
-00173 } drawfile_tagged;
-00174 
-00175 typedef struct {
-00176   wimp_box box;
-00177 } drawfile_text_column;
-00178 
-00179 typedef struct {
-00180   struct {
-00181     drawfile_type type;
-00182     int size;
-00183     drawfile_text_column data;
-00184   } columns [1];
-00185 } drawfile_text_column_list;
-00186 
-00187 typedef struct {
-00188   drawfile_type type;
-00189   int reserved [2];
-00190   palette_entry fill;
-00191   palette_entry bg_hint;
-00192   char text [1];
-00193 } drawfile_area_text;
-00194 
-00195 typedef struct {
-00196   wimp_box bbox;
-00197   drawfile_text_column_list header;
-00198   drawfile_area_text area_text;
-00199 } drawfile_text_area;
-00200 
-00201 typedef struct {
-00202   wimp_box bbox;
-00203   int paper_size;
-00204   drawfile_paper_options paper_options;
-00205   double grid_spacing;
-00206   int grid_division;
-00207   BOOL isometric;
-00208   BOOL auto_adjust;
-00209   BOOL show;
-00210   BOOL lock;
-00211   BOOL cm;
-00212   int zoom_mul;
-00213   int zoom_div;
-00214   BOOL zoom_lock;
-00215   BOOL toolbox;
-00216   drawfile_entry_mode entry_mode;
-00217   int undo_size;
-00218 } drawfile_options;
-00219 
-00220 typedef struct {
-00221   wimp_box bbox;
-00222   os_trfm trfm;
-00223   drawfile_text_flags flags;
-00224   palette_entry fill;
-00225   palette_entry bg_hint;
-00226   drawfile_text_style style;
-00227   int xsize;
-00228   int ysize;
-00229   wimp_coord base;
-00230   char text [1];
-00231 } drawfile_trfm_text;
-00232 
-00233 typedef struct {
-00234   wimp_box bbox;
-00235   os_trfm trfm;
-00236   sprite_header header;
-00237   byte data [1];
-00238 } drawfile_trfm_sprite;
-00239 
-00240 typedef struct {
-00241   wimp_box bbox;
-00242   int width;
-00243   int height;
-00244   int xdpi;
-00245   int ydpi;
-00246   os_trfm trfm;
-00247   int len;
-00248   byte data [1];
-00249 } drawfile_jpeg;
-00250 
-00251 /* ------------------------------------------------------------------------
-00252  * Type:          drawfile_object
-00253  *
-00254  * Description:   This type is used to declare pointers rather than objects
-00255  */
-00256 
-00257 typedef struct {
-00258   drawfile_type type;
-00259   int size;
-00260   union {
-00261     drawfile_font_table font_table;
-00262     drawfile_text text;
-00263     drawfile_path path;
-00264     drawfile_path_with_pattern path_with_pattern;
-00265     drawfile_sprite sprite;
-00266     drawfile_group group;
-00267     drawfile_tagged tagged;
-00268     drawfile_text_column text_column;
-00269     drawfile_text_area text_area;
-00270     drawfile_options options;
-00271     drawfile_trfm_text trfm_text;
-00272     drawfile_trfm_sprite trfm_sprite;
-00273     drawfile_jpeg jpeg;
-00274   } data;
-00275 } drawfile_object;
-00276 
-00277 typedef struct {
-00278   char tag [4];
-00279   int major_version;
-00280   int minor_version;
-00281   char source [12];
-00282   wimp_box bbox;
-00283   drawfile_object objects [1];
-00284 } drawfile_diagram;
-00285 
-00286 typedef bits drawfile_bbox_flags;
-00287 
-00288 typedef struct {
-00289   drawfile_object *object;
-00290   drawfile_diagram *diagram;
-00291   drawfile_object *font_table;
-00292   drawfile_declare_fonts_flags flags;
-00293   os_error *error;
-00294 } drawfile_declare_fonts_state;
-00295 
-00296 /************************
-00297  * Constant definitions *
-00298  ************************/
-00299 #define error_DRAW_FILE_NOT_DRAW                0x20C00u
-00300 #define error_DRAW_FILE_VERSION                 0x20C01u
-00301 #define error_DRAW_FILE_FONT_TAB                0x20C02u
-00302 #define error_DRAW_FILE_BAD_FONT_NO             0x20C03u
-00303 #define error_DRAW_FILE_BAD_MODE                0x20C04u
-00304 #define error_DRAW_FILE_BAD_FILE                0x20C05u
-00305 #define error_DRAW_FILE_BAD_GROUP               0x20C06u
-00306 #define error_DRAW_FILE_BAD_TAG                 0x20C07u
-00307 #define error_DRAW_FILE_SYNTAX                  0x20C08u
-00308 #define error_DRAW_FILE_FONT_NO                 0x20C09u
-00309 #define error_DRAW_FILE_AREA_VER                0x20C0Au
-00310 #define error_DRAW_FILE_NO_AREA_VER             0x20C0Bu
-00311 
-00312 #define drawfile_PATH_MITRED                    ((drawfile_path_style_flags) 0x0u)
-00313 #define drawfile_PATH_ROUND                     ((drawfile_path_style_flags) 0x1u)
-00314 #define drawfile_PATH_BEVELLED                  ((drawfile_path_style_flags) 0x2u)
-00315 #define drawfile_PATH_BUTT                      ((drawfile_path_style_flags) 0x0u)
-00316 #define drawfile_PATH_SQUARE                    ((drawfile_path_style_flags) 0x2u)
-00317 #define drawfile_PATH_TRIANGLE                  ((drawfile_path_style_flags) 0x3u)
-00318 #define drawfile_PATH_JOIN_SHIFT                0
-00319 #define drawfile_PATH_JOIN                      ((drawfile_path_style_flags) 0x3u)
-00320 #define drawfile_PATH_END_SHIFT                 2
-00321 #define drawfile_PATH_END                       ((drawfile_path_style_flags) 0xCu)
-00322 #define drawfile_PATH_START_SHIFT               4
-00323 #define drawfile_PATH_START                     ((drawfile_path_style_flags) 0x30u)
-00324 #define drawfile_PATH_WINDING_EVEN_ODD          ((drawfile_path_style_flags) 0x40u)
-00325 #define drawfile_PATH_DASHED                    ((drawfile_path_style_flags) 0x80u)
-00326 #define drawfile_PATH_CAP_WIDTH_SHIFT           16
-00327 #define drawfile_PATH_CAP_WIDTH                 ((drawfile_path_style_flags) 0xFF0000u)
-00328 #define drawfile_PATH_CAP_LENGTH_SHIFT          24
-00329 #define drawfile_PATH_CAP_LENGTH                ((drawfile_path_style_flags) 0xFF000000u)
-00330 #define drawfile_TEXT_KERN                      ((drawfile_text_flags) 0x1u)
-00331 #define drawfile_TEXT_RIGHT_TO_LEFT             ((drawfile_text_flags) 0x2u)
-00332 #define drawfile_TEXT_UNDERLINE                 ((drawfile_text_flags) 0x4u)
-00333 #define drawfile_RENDER_BBOXES                  ((drawfile_render_flags) 0x1u)
-00334 #define drawfile_RENDER_SUPPRESS                ((drawfile_render_flags) 0x2u)
-00335 #define drawfile_RENDER_GIVEN_FLATNESS          ((drawfile_render_flags) 0x4u)
-00336 #define drawfile_RENDER_GIVEN_COLOUR_MAPPING    ((drawfile_render_flags) 0x8u)
-00337 #define drawfile_NO_DOWNLOAD                    ((drawfile_declare_fonts_flags) 0x1u)
-00338 #define drawfile_PAPER_SHOW                     ((drawfile_paper_options) 0x1u)
-00339 #define drawfile_PAPER_LANDSCAPE                ((drawfile_paper_options) 0x10u)
-00340 #define drawfile_PAPER_DEFAULT                  ((drawfile_paper_options) 0x100u)
-00341 #define drawfile_ENTRY_MODE_LINE                ((drawfile_entry_mode) 0x1u)
-00342 #define drawfile_ENTRY_MODE_CLOSED_LINE         ((drawfile_entry_mode) 0x2u)
-00343 #define drawfile_ENTRY_MODE_CURVE               ((drawfile_entry_mode) 0x4u)
-00344 #define drawfile_ENTRY_MODE_CLOSED_CURVE        ((drawfile_entry_mode) 0x8u)
-00345 #define drawfile_ENTRY_MODE_RECTANGLE           ((drawfile_entry_mode) 0x10u)
-00346 #define drawfile_ENTRY_MODE_ELLIPSE             ((drawfile_entry_mode) 0x20u)
-00347 #define drawfile_ENTRY_MODE_TEXT_LINE           ((drawfile_entry_mode) 0x40u)
-00348 #define drawfile_ENTRY_MODE_SELECT              ((drawfile_entry_mode) 0x80u)
-00349 
-00350 /*************************
-00351  * Function declarations *
-00352  *************************/
-00353 
-00354 #if defined(__cplusplus)
-00355    extern "C" {
-00356 #endif /* __cplusplus */
-00357 
-00358 /* ------------------------------------------------------------------------
-00359  * Function:      drawfile_render()
-00360  *
-00361  * Description:   Calls SWI 0x45540
-00362  *
-00363  * Input:         flags - value of R0 on entry
-00364  *                diagram - value of R1 on entry
-00365  *                size - value of R2 on entry
-00366  *                trfm - value of R3 on entry
-00367  *                clip - value of R4 on entry
-00368  *                flatness - value of R5 on entry
-00369  */
-00370 
-00371 extern os_error *Drawfile_Render (drawfile_render_flags flags,
-00372       drawfile_diagram const *diagram,
-00373       int size,
-00374       os_trfm const *trfm,
-00375       wimp_box const *clip,
-00376       int flatness);
-00377 
-00378 /* ------------------------------------------------------------------------
-00379  * Function:      drawfile_bbox()
-00380  *
-00381  * Description:   Calls SWI 0x45541
-00382  *
-00383  * Input:         flags - value of R0 on entry
-00384  *                diagram - value of R1 on entry
-00385  *                size - value of R2 on entry
-00386  *                trfm - value of R3 on entry
-00387  *                bbox - value of R4 on entry
-00388  */
-00389 
-00390 extern os_error *Drawfile_Bbox (drawfile_bbox_flags flags,
-00391       drawfile_diagram const *diagram,
-00392       int size,
-00393       os_trfm const *trfm,
-00394       wimp_box *bbox);
-00395 
-00396 /* ------------------------------------------------------------------------
-00397  * Function:      Drawfile_DeclareFonts()
-00398  *
-00399  * Description:   Calls SWI 0x45542
-00400  *
-00401  * Input:         flags - value of R0 on entry
-00402  *                diagram - value of R1 on entry
-00403  *                size - value of R2 on entry
-00404  */
-00405 
-00406 extern os_error *Drawfile_DeclareFonts (drawfile_declare_fonts_flags flags,
-00407       drawfile_diagram const *diagram,
-00408       int size);
-00409 
-00410 /* ------------------------------------------------------------------------
-00411  * Function:      Drawfile_CreateDiagram()
-00412  *
-00413  */
-00414 
-00415 extern os_error * Drawfile_CreateDiagram(drawfile_info *info, size_t memory,
-00416         const char *creator, wimp_box box);
-00417 
-00418 extern os_error *Drawfile_AppendObject(drawfile_info *info, size_t memory,
-00419         const drawfile_object *object, BOOL rebind);
-00420 
-00421 extern os_error *Drawfile_RenderDiagram(drawfile_info *info,
-00422         window_redrawblock *redraw, double scale);
-00423 
-00424 extern os_error *Drawfile_VerifyDiagram(drawfile_info *info);
-00425 
-00426 extern void     Drawfile_QueryBox(drawfile_info *info,
-00427         wimp_box *rect, BOOL screenUnits);
-00428 
-00429 #if defined(__cplusplus)
-00430    }
-00431 #endif /* __cplusplus */
-00432 
-00433 #endif /* __drawfile.h */
-
-
Generated by  - -doxygen 1.6.2
- - diff -r 59758314f811 -r d4524d6a4472 Symbian3/Examples/guid-6013a680-57f9-415b-8851-c4fa63356636/fail_8c_source.html --- a/Symbian3/Examples/guid-6013a680-57f9-415b-8851-c4fa63356636/fail_8c_source.html Fri Jun 11 15:24:34 2010 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,42 +0,0 @@ - - - - -TB9.2 Example Applications: examples/PIPS/antiword/src/fail.c Source File - - - - - -

examples/PIPS/antiword/src/fail.c

00001 /*
-00002  * fail.c
-00003  * Copyright (C) 1998 A.J. van Os
-00004  *
-00005  * Description:
-00006  * An alternative form of assert()
-00007  */
-00008 
-00009 #include <stdlib.h>
-00010 #include "antiword.h"
-00011 
-00012 #if !defined(NDEBUG)
-00013 void
-00014 __fail(char *szExpression, char *szFilename, int iLineNumber)
-00015 {
-00016         if (szExpression == NULL || szFilename == NULL) {
-00017                 werr(1, "Internal error: no expression");
-00018         }
-00019 #if defined(DEBUG)
-00020         fprintf(stderr, "%s[%3d]: Internal error in '%s'\n",
-00021                 szFilename, iLineNumber, szExpression);
-00022 #endif /* DEBUG */
-00023         werr(1, "Internal error in '%s' in file %s at line %d",
-00024                 szExpression, szFilename, iLineNumber);
-00025 } /* end of __fail */
-00026 #endif /* !NDEBUG */
-
-
Generated by  - -doxygen 1.6.2
- - diff -r 59758314f811 -r d4524d6a4472 Symbian3/Examples/guid-6013a680-57f9-415b-8851-c4fa63356636/fail_8h_source.html --- a/Symbian3/Examples/guid-6013a680-57f9-415b-8851-c4fa63356636/fail_8h_source.html Fri Jun 11 15:24:34 2010 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,38 +0,0 @@ - - - - -TB9.2 Example Applications: examples/PIPS/antiword/inc/fail.h Source File - - - - - -

examples/PIPS/antiword/inc/fail.h

00001 /*
-00002  * fail.h
-00003  * Copyright (C) 1998-2000 A.J. van Os; Released under GPL
-00004  *
-00005  * Description:
-00006  * Support for an alternative form of assert()
-00007  */
-00008 
-00009 #if !defined(__fail_h)
-00010 #define __fail_h 1
-00011 
-00012 #undef fail
-00013 
-00014 #if defined(NDEBUG)
-00015 #define fail(e) ((void)0)
-00016 #else
-00017 #define fail(e) ((e) ? __fail(#e, __FILE__, __LINE__) : (void)0)
-00018 #endif /* NDEBUG */
-00019 
-00020 extern void     __fail(char *, char *, int);
-00021 
-00022 #endif /* __fail_h */
-
-
Generated by  - -doxygen 1.6.2
- - diff -r 59758314f811 -r d4524d6a4472 Symbian3/Examples/guid-6013a680-57f9-415b-8851-c4fa63356636/finddata_8c_source.html --- a/Symbian3/Examples/guid-6013a680-57f9-415b-8851-c4fa63356636/finddata_8c_source.html Fri Jun 11 15:24:34 2010 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,170 +0,0 @@ - - - - -TB9.2 Example Applications: examples/PIPS/antiword/src/finddata.c Source File - - - - - -

examples/PIPS/antiword/src/finddata.c

00001 /*
-00002  * finddata.c
-00003  * Copyright (C) 2000-2002 A.J. van Os; Released under GPL
-00004  *
-00005  * Description:
-00006  * Find the blocks that contain the data of MS Word files
-00007  */
-00008 
-00009 #include <stdio.h>
-00010 #include <stdlib.h>
-00011 #include "antiword.h"
-00012 
-00013 
-00014 /*
-00015  * bAddDataBlocks - Add the blocks to the data block list
-00016  *
-00017  * Returns TRUE when successful, otherwise FALSE
-00018  */
-00019 BOOL
-00020 bAddDataBlocks(ULONG ulDataPosFirst, ULONG ulTotalLength,
-00021         ULONG ulStartBlock, const ULONG *aulBBD, size_t tBBDLen)
-00022 {
-00023         data_block_type tDataBlock;
-00024         ULONG   ulDataPos, ulOffset, ulIndex;
-00025         long    lToGo;
-00026         BOOL    bSuccess;
-00027 
-00028         fail(ulTotalLength > (ULONG)LONG_MAX);
-00029         fail(ulStartBlock > MAX_BLOCKNUMBER && ulStartBlock != END_OF_CHAIN);
-00030         fail(aulBBD == NULL);
-00031 
-00032         NO_DBG_HEX(ulDataPosFirst);
-00033         NO_DBG_DEC(ulTotalLength);
-00034 
-00035         lToGo = (long)ulTotalLength;
-00036 
-00037         ulDataPos = ulDataPosFirst;
-00038         ulOffset = ulDataPosFirst;
-00039         for (ulIndex = ulStartBlock;
-00040              ulIndex != END_OF_CHAIN && lToGo > 0;
-00041              ulIndex = aulBBD[ulIndex]) {
-00042                 if (ulIndex == UNUSED_BLOCK || ulIndex >= (ULONG)tBBDLen) {
-00043                         DBG_DEC(ulIndex);
-00044                         DBG_DEC(tBBDLen);
-00045                         return FALSE;
-00046                 }
-00047                 if (ulOffset >= BIG_BLOCK_SIZE) {
-00048                         ulOffset -= BIG_BLOCK_SIZE;
-00049                         continue;
-00050                 }
-00051                 tDataBlock.ulFileOffset =
-00052                         (ulIndex + 1) * BIG_BLOCK_SIZE + ulOffset;
-00053                 tDataBlock.ulDataPos = ulDataPos;
-00054                 tDataBlock.ulLength = min(BIG_BLOCK_SIZE - ulOffset,
-00055                                                 (ULONG)lToGo);
-00056                 fail(tDataBlock.ulLength > BIG_BLOCK_SIZE);
-00057                 ulOffset = 0;
-00058                 if (!bAdd2DataBlockList(&tDataBlock)) {
-00059                         DBG_HEX(tDataBlock.ulFileOffset);
-00060                         DBG_HEX(tDataBlock.ulDataPos);
-00061                         DBG_DEC(tDataBlock.ulLength);
-00062                         return FALSE;
-00063                 }
-00064                 ulDataPos += tDataBlock.ulLength;
-00065                 lToGo -= (long)tDataBlock.ulLength;
-00066         }
-00067         bSuccess = lToGo == 0 ||
-00068                 (ulTotalLength == (ULONG)LONG_MAX && ulIndex == END_OF_CHAIN);
-00069         DBG_DEC_C(!bSuccess, lToGo);
-00070         DBG_DEC_C(!bSuccess, ulTotalLength);
-00071         DBG_DEC_C(!bSuccess, ulIndex);
-00072         return bSuccess;
-00073 } /* end of bAddDataBlocks */
-00074 
-00075 /*
-00076  * bGet6DocumentData - make a list of the data blocks of Word 6/7 files
-00077  *
-00078  * Code for "fast saved" files.
-00079  *
-00080  * Returns TRUE when successful, otherwise FALSE
-00081  */
-00082 BOOL
-00083 bGet6DocumentData(FILE *pFile, ULONG ulStartBlock,
-00084         const ULONG *aulBBD, size_t tBBDLen, const UCHAR *aucHeader)
-00085 {
-00086         UCHAR   *aucBuffer;
-00087         ULONG   ulBeginTextInfo, ulOffset, ulTotLength;
-00088         size_t  tTextInfoLen;
-00089         int     iIndex, iOff, iType, iLen, iPieces;
-00090 
-00091         DBG_MSG("bGet6DocumentData");
-00092 
-00093         fail(pFile == NULL);
-00094         fail(aulBBD == NULL);
-00095         fail(aucHeader == NULL);
-00096 
-00097         ulBeginTextInfo = ulGetLong(0x160, aucHeader);
-00098         DBG_HEX(ulBeginTextInfo);
-00099         tTextInfoLen = (size_t)ulGetLong(0x164, aucHeader);
-00100         DBG_DEC(tTextInfoLen);
-00101 
-00102         aucBuffer = xmalloc(tTextInfoLen);
-00103         if (!bReadBuffer(pFile, ulStartBlock,
-00104                         aulBBD, tBBDLen, BIG_BLOCK_SIZE,
-00105                         aucBuffer, ulBeginTextInfo, tTextInfoLen)) {
-00106                 aucBuffer = xfree(aucBuffer);
-00107                 return FALSE;
-00108         }
-00109         NO_DBG_PRINT_BLOCK(aucBuffer, tTextInfoLen);
-00110 
-00111         iOff = 0;
-00112         while (iOff < (int)tTextInfoLen) {
-00113                 iType = (int)ucGetByte(iOff, aucBuffer);
-00114                 iOff++;
-00115                 if (iType == 0) {
-00116                         iOff++;
-00117                         continue;
-00118                 }
-00119                 iLen = (int)usGetWord(iOff, aucBuffer);
-00120                 iOff += 2;
-00121                 if (iType == 1) {
-00122                         iOff += iLen;
-00123                         continue;
-00124                 }
-00125                 if (iType != 2) {
-00126                         werr(0, "Unknown type of 'fastsaved' format");
-00127                         aucBuffer = xfree(aucBuffer);
-00128                         return FALSE;
-00129                 }
-00130                 /* Type 2 */
-00131                 NO_DBG_DEC(iLen);
-00132                 iOff += 2;
-00133                 iPieces = (iLen - 4) / 12;
-00134                 DBG_DEC(iPieces);
-00135                 for (iIndex = 0; iIndex < iPieces; iIndex++) {
-00136                         ulOffset = ulGetLong(
-00137                                 iOff + (iPieces + 1) * 4 + iIndex * 8 + 2,
-00138                                 aucBuffer);
-00139                         ulTotLength = ulGetLong(iOff + (iIndex + 1) * 4,
-00140                                                 aucBuffer) -
-00141                                         ulGetLong(iOff + iIndex * 4,
-00142                                                 aucBuffer);
-00143                         if (!bAddDataBlocks(ulOffset, ulTotLength,
-00144                                         ulStartBlock,
-00145                                         aulBBD, tBBDLen)) {
-00146                                 aucBuffer = xfree(aucBuffer);
-00147                                 return FALSE;
-00148                         }
-00149                 }
-00150                 break;
-00151         }
-00152         aucBuffer = xfree(aucBuffer);
-00153         return TRUE;
-00154 } /* end of bGet6DocumentData */
-
-
Generated by  - -doxygen 1.6.2
- - diff -r 59758314f811 -r d4524d6a4472 Symbian3/Examples/guid-6013a680-57f9-415b-8851-c4fa63356636/findtext_8c_source.html --- a/Symbian3/Examples/guid-6013a680-57f9-415b-8851-c4fa63356636/findtext_8c_source.html Fri Jun 11 15:24:34 2010 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,305 +0,0 @@ - - - - -TB9.2 Example Applications: examples/PIPS/antiword/src/findtext.c Source File - - - - - -

examples/PIPS/antiword/src/findtext.c

00001 /*
-00002  * findtext.c
-00003  * Copyright (C) 1998-2004 A.J. van Os; Released under GNU GPL
-00004  *
-00005  * Description:
-00006  * Find the blocks that contain the text of MS Word files
-00007  */
-00008 
-00009 #include <stdio.h>
-00010 #include <stdlib.h>
-00011 #include "antiword.h"
-00012 
-00013 
-00014 /*
-00015  * bAddTextBlocks - Add the blocks to the text block list
-00016  *
-00017  * Returns TRUE when successful, FALSE if not
-00018  */
-00019 BOOL
-00020 bAddTextBlocks(ULONG ulCharPosFirst, ULONG ulTotalLength,
-00021         BOOL bUsesUnicode, USHORT usPropMod,
-00022         ULONG ulStartBlock, const ULONG *aulBBD, size_t tBBDLen)
-00023 {
-00024         text_block_type tTextBlock;
-00025         ULONG   ulCharPos, ulOffset, ulIndex;
-00026         long    lToGo;
-00027 
-00028         fail(ulTotalLength > (ULONG)LONG_MAX / 2);
-00029         fail(ulStartBlock > MAX_BLOCKNUMBER && ulStartBlock != END_OF_CHAIN);
-00030         fail(aulBBD == NULL);
-00031 
-00032         NO_DBG_HEX(ulCharPosFirst);
-00033         NO_DBG_DEC(ulTotalLength);
-00034 
-00035         if (bUsesUnicode) {
-00036                 /* One character equals two bytes */
-00037                 NO_DBG_MSG("Uses Unicode");
-00038                 lToGo = (long)ulTotalLength * 2;
-00039         } else {
-00040                 /* One character equals one byte */
-00041                 NO_DBG_MSG("Uses ASCII");
-00042                 lToGo = (long)ulTotalLength;
-00043         }
-00044 
-00045         ulCharPos = ulCharPosFirst;
-00046         ulOffset = ulCharPosFirst;
-00047         for (ulIndex = ulStartBlock;
-00048              ulIndex != END_OF_CHAIN && lToGo > 0;
-00049              ulIndex = aulBBD[ulIndex]) {
-00050                 if (ulIndex >= (ULONG)tBBDLen) {
-00051                         DBG_DEC(ulIndex);
-00052                         DBG_DEC(tBBDLen);
-00053                         werr(1, "The Big Block Depot is damaged");
-00054                 }
-00055                 if (ulOffset >= BIG_BLOCK_SIZE) {
-00056                         ulOffset -= BIG_BLOCK_SIZE;
-00057                         continue;
-00058                 }
-00059                 tTextBlock.ulFileOffset =
-00060                         (ulIndex + 1) * BIG_BLOCK_SIZE + ulOffset;
-00061                 tTextBlock.ulCharPos = ulCharPos;
-00062                 tTextBlock.ulLength = min(BIG_BLOCK_SIZE - ulOffset,
-00063                                                 (ULONG)lToGo);
-00064                 tTextBlock.bUsesUnicode = bUsesUnicode;
-00065                 tTextBlock.usPropMod = usPropMod;
-00066                 ulOffset = 0;
-00067                 if (!bAdd2TextBlockList(&tTextBlock)) {
-00068                         DBG_HEX(tTextBlock.ulFileOffset);
-00069                         DBG_HEX(tTextBlock.ulCharPos);
-00070                         DBG_DEC(tTextBlock.ulLength);
-00071                         DBG_DEC(tTextBlock.bUsesUnicode);
-00072                         DBG_DEC(tTextBlock.usPropMod);
-00073                         return FALSE;
-00074                 }
-00075                 ulCharPos += tTextBlock.ulLength;
-00076                 lToGo -= (long)tTextBlock.ulLength;
-00077         }
-00078         DBG_DEC_C(lToGo != 0, lToGo);
-00079         return lToGo == 0;
-00080 } /* end of bAddTextBlocks */
-00081 
-00082 /*
-00083  * bGet6DocumentText - make a list of the text blocks of Word 6/7 files
-00084  *
-00085  * Code for "fast saved" files.
-00086  *
-00087  * Returns TRUE when successful, FALSE if not
-00088  */
-00089 BOOL
-00090 bGet6DocumentText(FILE *pFile, BOOL bUsesUnicode, ULONG ulStartBlock,
-00091         const ULONG *aulBBD, size_t tBBDLen, const UCHAR *aucHeader)
-00092 {
-00093         UCHAR   *aucBuffer;
-00094         ULONG   ulBeginTextInfo, ulTextOffset, ulTotLength;
-00095         size_t  tTextInfoLen;
-00096         int     iIndex, iType, iOff, iLen, iPieces;
-00097         USHORT  usPropMod;
-00098 
-00099         DBG_MSG("bGet6DocumentText");
-00100 
-00101         fail(pFile == NULL);
-00102         fail(aulBBD == NULL);
-00103         fail(aucHeader == NULL);
-00104 
-00105         ulBeginTextInfo = ulGetLong(0x160, aucHeader);  /* fcClx */
-00106         DBG_HEX(ulBeginTextInfo);
-00107         tTextInfoLen = (size_t)ulGetLong(0x164, aucHeader);     /* lcbClx */
-00108         DBG_DEC(tTextInfoLen);
-00109 
-00110         aucBuffer = xmalloc(tTextInfoLen);
-00111         if (!bReadBuffer(pFile, ulStartBlock,
-00112                         aulBBD, tBBDLen, BIG_BLOCK_SIZE,
-00113                         aucBuffer, ulBeginTextInfo, tTextInfoLen)) {
-00114                 aucBuffer = xfree(aucBuffer);
-00115                 return FALSE;
-00116         }
-00117         NO_DBG_PRINT_BLOCK(aucBuffer, tTextInfoLen);
-00118 
-00119         iOff = 0;
-00120         while ((size_t)iOff < tTextInfoLen) {
-00121                 iType = (int)ucGetByte(iOff, aucBuffer);
-00122                 iOff++;
-00123                 if (iType == 0) {
-00124                         DBG_FIXME();
-00125                         iOff++;
-00126                         continue;
-00127                 }
-00128                 if (iType == 1) {
-00129                         iLen = (int)usGetWord(iOff, aucBuffer);
-00130                         vAdd2PropModList(aucBuffer + iOff);
-00131                         iOff += iLen + 2;
-00132                         continue;
-00133                 }
-00134                 if (iType != 2) {
-00135                         werr(0, "Unknown type of 'fastsaved' format");
-00136                         aucBuffer = xfree(aucBuffer);
-00137                         return FALSE;
-00138                 }
-00139                 /* Type 2 */
-00140                 iLen = (int)usGetWord(iOff, aucBuffer);
-00141                 NO_DBG_DEC(iLen);
-00142                 iOff += 4;
-00143                 iPieces = (iLen - 4) / 12;
-00144                 DBG_DEC(iPieces);
-00145                 for (iIndex = 0; iIndex < iPieces; iIndex++) {
-00146                         ulTextOffset = ulGetLong(
-00147                                 iOff + (iPieces + 1) * 4 + iIndex * 8 + 2,
-00148                                 aucBuffer);
-00149                         usPropMod = usGetWord(
-00150                                 iOff + (iPieces + 1) * 4 + iIndex * 8 + 6,
-00151                                 aucBuffer);
-00152                         ulTotLength = ulGetLong(iOff + (iIndex + 1) * 4,
-00153                                                 aucBuffer) -
-00154                                         ulGetLong(iOff + iIndex * 4,
-00155                                                 aucBuffer);
-00156                         NO_DBG_HEX_C(usPropMod != 0, usPropMod);
-00157                         if (!bAddTextBlocks(ulTextOffset, ulTotLength,
-00158                                         bUsesUnicode, usPropMod,
-00159                                         ulStartBlock,
-00160                                         aulBBD, tBBDLen)) {
-00161                                 aucBuffer = xfree(aucBuffer);
-00162                                 return FALSE;
-00163                         }
-00164                 }
-00165                 break;
-00166         }
-00167         aucBuffer = xfree(aucBuffer);
-00168         return TRUE;
-00169 } /* end of bGet6DocumentText */
-00170 
-00171 /*
-00172  * bGet8DocumentText - make a list of the text blocks of Word 8/97 files
-00173  *
-00174  * Returns TRUE when successful, FALSE if not
-00175  */
-00176 BOOL
-00177 bGet8DocumentText(FILE *pFile, const pps_info_type *pPPS,
-00178         const ULONG *aulBBD, size_t tBBDLen,
-00179         const ULONG *aulSBD, size_t tSBDLen,
-00180         const UCHAR *aucHeader)
-00181 {
-00182         const ULONG     *aulBlockDepot;
-00183         UCHAR   *aucBuffer;
-00184         ULONG   ulTextOffset, ulBeginTextInfo;
-00185         ULONG   ulTotLength, ulLen;
-00186         long    lIndex, lPieces, lOff;
-00187         size_t  tTextInfoLen, tBlockDepotLen, tBlockSize;
-00188         int     iType, iLen;
-00189         BOOL    bUsesUnicode;
-00190         USHORT  usPropMod;
-00191 
-00192         DBG_MSG("bGet8DocumentText");
-00193 
-00194         fail(pFile == NULL || pPPS == NULL);
-00195         fail(aulBBD == NULL || aulSBD == NULL);
-00196         fail(aucHeader == NULL);
-00197 
-00198         ulBeginTextInfo = ulGetLong(0x1a2, aucHeader);  /* fcClx */
-00199         DBG_HEX(ulBeginTextInfo);
-00200         tTextInfoLen = (size_t)ulGetLong(0x1a6, aucHeader);     /* lcbClx */
-00201         DBG_DEC(tTextInfoLen);
-00202 
-00203         DBG_DEC(pPPS->tTable.ulSB);
-00204         DBG_HEX(pPPS->tTable.ulSize);
-00205         if (pPPS->tTable.ulSize == 0) {
-00206                 return FALSE;
-00207         }
-00208 
-00209         if (pPPS->tTable.ulSize < MIN_SIZE_FOR_BBD_USE) {
-00210                 /* Use the Small Block Depot */
-00211                 aulBlockDepot = aulSBD;
-00212                 tBlockDepotLen = tSBDLen;
-00213                 tBlockSize = SMALL_BLOCK_SIZE;
-00214         } else {
-00215                 /* Use the Big Block Depot */
-00216                 aulBlockDepot = aulBBD;
-00217                 tBlockDepotLen = tBBDLen;
-00218                 tBlockSize = BIG_BLOCK_SIZE;
-00219         }
-00220         aucBuffer = xmalloc(tTextInfoLen);
-00221         if (!bReadBuffer(pFile, pPPS->tTable.ulSB,
-00222                         aulBlockDepot, tBlockDepotLen, tBlockSize,
-00223                         aucBuffer, ulBeginTextInfo, tTextInfoLen)) {
-00224                 aucBuffer = xfree(aucBuffer);
-00225                 return FALSE;
-00226         }
-00227         NO_DBG_PRINT_BLOCK(aucBuffer, tTextInfoLen);
-00228 
-00229         lOff = 0;
-00230         while (lOff < (long)tTextInfoLen) {
-00231                 iType = (int)ucGetByte(lOff, aucBuffer);
-00232                 lOff++;
-00233                 if (iType == 0) {
-00234                         DBG_FIXME();
-00235                         lOff++;
-00236                         continue;
-00237                 }
-00238                 if (iType == 1) {
-00239                         iLen = (int)usGetWord(lOff, aucBuffer);
-00240                         vAdd2PropModList(aucBuffer + lOff);
-00241                         lOff += (long)iLen + 2;
-00242                         continue;
-00243                 }
-00244                 if (iType != 2) {
-00245                         werr(0, "Unknown type of 'fastsaved' format");
-00246                         aucBuffer = xfree(aucBuffer);
-00247                         return FALSE;
-00248                 }
-00249                 /* Type 2 */
-00250                 ulLen = ulGetLong(lOff, aucBuffer);
-00251                 if (ulLen < 4) {
-00252                         DBG_DEC(ulLen);
-00253                         return FALSE;
-00254                 }
-00255                 lOff += 4;
-00256                 lPieces = (long)((ulLen - 4) / 12);
-00257                 DBG_DEC(lPieces);
-00258                 for (lIndex = 0; lIndex < lPieces; lIndex++) {
-00259                         ulTextOffset = ulGetLong(
-00260                                 lOff + (lPieces + 1) * 4 + lIndex * 8 + 2,
-00261                                 aucBuffer);
-00262                         usPropMod = usGetWord(
-00263                                 lOff + (lPieces + 1) * 4 + lIndex * 8 + 6,
-00264                                 aucBuffer);
-00265                         ulTotLength = ulGetLong(lOff + (lIndex + 1) * 4,
-00266                                                 aucBuffer) -
-00267                                         ulGetLong(lOff + lIndex * 4,
-00268                                                 aucBuffer);
-00269                         if ((ulTextOffset & BIT(30)) == 0) {
-00270                                 bUsesUnicode = TRUE;
-00271                         } else {
-00272                                 bUsesUnicode = FALSE;
-00273                                 ulTextOffset &= ~BIT(30);
-00274                                 ulTextOffset /= 2;
-00275                         }
-00276                         NO_DBG_HEX_C(usPropMod != 0, usPropMod);
-00277                         if (!bAddTextBlocks(ulTextOffset, ulTotLength,
-00278                                         bUsesUnicode, usPropMod,
-00279                                         pPPS->tWordDocument.ulSB,
-00280                                         aulBBD, tBBDLen)) {
-00281                                 aucBuffer = xfree(aucBuffer);
-00282                                 return FALSE;
-00283                         }
-00284                 }
-00285                 break;
-00286         }
-00287         aucBuffer = xfree(aucBuffer);
-00288         return TRUE;
-00289 } /* end of bGet8DocumentText */
-
-
Generated by  - -doxygen 1.6.2
- - diff -r 59758314f811 -r d4524d6a4472 Symbian3/Examples/guid-6013a680-57f9-415b-8851-c4fa63356636/fmt__text_8c_source.html --- a/Symbian3/Examples/guid-6013a680-57f9-415b-8851-c4fa63356636/fmt__text_8c_source.html Fri Jun 11 15:24:34 2010 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,183 +0,0 @@ - - - - -TB9.2 Example Applications: examples/PIPS/antiword/src/fmt_text.c Source File - - - - - -

examples/PIPS/antiword/src/fmt_text.c

00001 /*
-00002  * fmt_text.c
-00003  * Copyright (C) 2004 A.J. van Os; Released under GNU GPL
-00004  *
-00005  * Description:
-00006  * Functions to deal with the Formatted Text format
-00007  *
-00008  * Based on patches send by: Ofir Reichenberg <ofir@qlusters.com>
-00009  *
-00010  * The credit should go to him, but all the bugs are mine.
-00011  */
-00012 
-00013 #include <string.h>
-00014 #include "antiword.h"
-00015 
-00016 /* The character set */
-00017 static encoding_type    eEncoding = encoding_neutral;
-00018 /* Current vertical position information */
-00019 static long             lYtopCurr = 0;
-00020 /* Local representation of the non-breaking space */
-00021 static UCHAR            ucNbsp = 0;
-00022 
-00023 
-00024 /*
-00025  * vPrologueFMT - set options and perform the Formatted Text initialization
-00026  */
-00027 void
-00028 vPrologueFMT(diagram_type *pDiag, const options_type *pOptions)
-00029 {
-00030         fail(pDiag == NULL);
-00031         fail(pOptions == NULL);
-00032 
-00033         eEncoding = pOptions->eEncoding;
-00034         pDiag->lXleft = 0;
-00035         pDiag->lYtop = 0;
-00036         lYtopCurr = 0;
-00037 } /* end of vPrologueFMT */
-00038 
-00039 /*
-00040  * vPrintFMT - print a Formatted Text string
-00041  */
-00042 static void
-00043 vPrintFMT(FILE *pFile,
-00044         const char *szString, size_t tStringLength, USHORT usFontstyle)
-00045 {
-00046         const UCHAR     *pucByte, *pucStart, *pucLast, *pucNonSpace;
-00047 
-00048         fail(szString == NULL);
-00049 
-00050         if (szString == NULL || szString[0] == '\0' || tStringLength == 0) {
-00051                 return;
-00052         }
-00053 
-00054         if (eEncoding == encoding_utf_8) {
-00055                 fprintf(pFile, "%.*s", (int)tStringLength, szString);
-00056                 return;
-00057         }
-00058 
-00059         if (ucNbsp == 0) {
-00060                 ucNbsp = ucGetNbspCharacter();
-00061                 DBG_HEX_C(ucNbsp != 0xa0, ucNbsp);
-00062         }
-00063 
-00064         pucStart = (UCHAR *)szString;
-00065         pucLast = pucStart + tStringLength - 1;
-00066         pucNonSpace = pucLast;
-00067         while ((*pucNonSpace == (UCHAR)' ' || *pucNonSpace == ucNbsp) &&
-00068                pucNonSpace > pucStart) {
-00069                 pucNonSpace--;
-00070         }
-00071 
-00072         /* 1: The spaces at the start */
-00073         pucByte = pucStart;
-00074         while ((*pucByte == (UCHAR)' ' || *pucByte == ucNbsp) &&
-00075                pucByte <= pucLast) {
-00076                 (void)putc(' ', pFile);
-00077                 pucByte++;
-00078         }
-00079 
-00080         if (pucByte > pucLast) {
-00081                 /* There is no text, just spaces */
-00082                 return;
-00083         }
-00084 
-00085         /* 2: Start the *bold*, /italic/ and _underline_ */
-00086         if (bIsBold(usFontstyle)) {
-00087                 (void)putc('*', pFile);
-00088         }
-00089         if (bIsItalic(usFontstyle)) {
-00090                 (void)putc('/', pFile);
-00091         }
-00092         if (bIsUnderline(usFontstyle)) {
-00093                 (void)putc('_', pFile);
-00094         }
-00095 
-00096         /* 3: The text itself */
-00097         while (pucByte <= pucNonSpace) {
-00098                 if (*pucByte == ucNbsp) {
-00099                         (void)putc(' ', pFile);
-00100                 } else {
-00101                         (void)putc((char)*pucByte, pFile);
-00102                 }
-00103                 pucByte++;
-00104         }
-00105 
-00106         /* 4: End the *bold*, /italic/ and _underline_ */
-00107         if (bIsUnderline(usFontstyle)) {
-00108                 (void)putc('_', pFile);
-00109         }
-00110         if (bIsItalic(usFontstyle)) {
-00111                 (void)putc('/', pFile);
-00112         }
-00113         if (bIsBold(usFontstyle)) {
-00114                 (void)putc('*', pFile);
-00115         }
-00116 
-00117         /* 5: The spaces at the end */
-00118         while (pucByte <= pucLast) {
-00119                 (void)putc(' ', pFile);
-00120                 pucByte++;
-00121         }
-00122 } /* end of vPrintFMT */
-00123 
-00124 /*
-00125  * vMoveTo - move to the given X,Y coordinates
-00126  *
-00127  * Move the current position of the given diagram to its X,Y coordinates,
-00128  * start on a new page if needed
-00129  */
-00130 static void
-00131 vMoveTo(diagram_type *pDiag)
-00132 {
-00133         int     iCount, iNbr;
-00134 
-00135         fail(pDiag == NULL);
-00136         fail(pDiag->pOutFile == NULL);
-00137 
-00138         if (pDiag->lYtop != lYtopCurr) {
-00139                 iNbr = iDrawUnits2Char(pDiag->lXleft);
-00140                 for (iCount = 0; iCount < iNbr; iCount++) {
-00141                         (void)putc(FILLER_CHAR, pDiag->pOutFile);
-00142                 }
-00143                 lYtopCurr = pDiag->lYtop;
-00144         }
-00145 } /* end of vMoveTo */
-00146 
-00147 /*
-00148  * vSubstringFMT - print a sub string
-00149  */
-00150 void
-00151 vSubstringFMT(diagram_type *pDiag,
-00152         const char *szString, size_t tStringLength, long lStringWidth,
-00153         USHORT usFontstyle)
-00154 {
-00155         fail(pDiag == NULL || szString == NULL);
-00156         fail(pDiag->pOutFile == NULL);
-00157         fail(pDiag->lXleft < 0);
-00158         fail(tStringLength != strlen(szString));
-00159 
-00160         if (szString[0] == '\0' || tStringLength == 0) {
-00161                 return;
-00162         }
-00163 
-00164         vMoveTo(pDiag);
-00165         vPrintFMT(pDiag->pOutFile, szString, tStringLength, usFontstyle);
-00166         pDiag->lXleft += lStringWidth;
-00167 } /* end of vSubstringFMT */
-
-
Generated by  - -doxygen 1.6.2
- - diff -r 59758314f811 -r d4524d6a4472 Symbian3/Examples/guid-6013a680-57f9-415b-8851-c4fa63356636/fontinfo_8h_source.html --- a/Symbian3/Examples/guid-6013a680-57f9-415b-8851-c4fa63356636/fontinfo_8h_source.html Fri Jun 11 15:24:34 2010 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,2267 +0,0 @@ - - - - -TB9.2 Example Applications: examples/PIPS/antiword/inc/fontinfo.h Source File - - - - - -

examples/PIPS/antiword/inc/fontinfo.h

00001 /* THIS FILE IS AUTOMATICALLY GENERATED - DO NOT EDIT! */
-00002 static const char *szFontnames[32] = {
-00003         "Courier",
-00004         "Courier-Bold",
-00005         "Courier-Oblique",
-00006         "Courier-BoldOblique",
-00007         "Times-Roman",
-00008         "Times-Bold",
-00009         "Times-Italic",
-00010         "Times-BoldItalic",
-00011         "Helvetica",
-00012         "Helvetica-Bold",
-00013         "Helvetica-Oblique",
-00014         "Helvetica-BoldOblique",
-00015         "Palatino-Roman",
-00016         "Palatino-Bold",
-00017         "Palatino-Italic",
-00018         "Palatino-BoldItalic",
-00019         "Helvetica-Narrow",
-00020         "Helvetica-Narrow-Bold",
-00021         "Helvetica-Narrow-Oblique",
-00022         "Helvetica-Narrow-BoldOblique",
-00023         "Bookman-Light",
-00024         "Bookman-Demi",
-00025         "Bookman-LightItalic",
-00026         "Bookman-DemiItalic",
-00027         "AvantGarde-Book",
-00028         "AvantGarde-Demi",
-00029         "AvantGarde-BookOblique",
-00030         "AvantGarde-DemiOblique",
-00031         "NewCenturySchlbk-Roman",
-00032         "NewCenturySchlbk-Bold",
-00033         "NewCenturySchlbk-Italic",
-00034         "NewCenturySchlbk-BoldItalic",
-00035 };
-00036 static unsigned short ausCharacterWidths1[32][256] = {
-00037         {       /* Courier */
-00038         /*   0 */     0,    0,    0,    0,    0,    0,    0,    0,
-00039         /*   8 */     0,    0,    0,    0,    0,    0,    0,    0,
-00040         /*  16 */     0,    0,    0,    0,    0,    0,    0,    0,
-00041         /*  24 */     0,    0,    0,    0,    0,    0,    0,    0,
-00042         /*  32 */   600,  600,  600,  600,  600,  600,  600,  600,
-00043         /*  40 */   600,  600,  600,  600,  600,  600,  600,  600,
-00044         /*  48 */   600,  600,  600,  600,  600,  600,  600,  600,
-00045         /*  56 */   600,  600,  600,  600,  600,  600,  600,  600,
-00046         /*  64 */   600,  600,  600,  600,  600,  600,  600,  600,
-00047         /*  72 */   600,  600,  600,  600,  600,  600,  600,  600,
-00048         /*  80 */   600,  600,  600,  600,  600,  600,  600,  600,
-00049         /*  88 */   600,  600,  600,  600,  600,  600,  600,  600,
-00050         /*  96 */   600,  600,  600,  600,  600,  600,  600,  600,
-00051         /* 104 */   600,  600,  600,  600,  600,  600,  600,  600,
-00052         /* 112 */   600,  600,  600,  600,  600,  600,  600,  600,
-00053         /* 120 */   600,  600,  600,  600,  600,  600,  600,    0,
-00054         /* 128 */     0,    0,    0,    0,    0,    0,    0,    0,
-00055         /* 136 */     0,    0,    0,    0,  600,  600,  600,  600,
-00056         /* 144 */   600,  600,  600,  600,  600,  600,  600,  600,
-00057         /* 152 */   600,  600,  600,  600,  600,  600,  600,  600,
-00058         /* 160 */   600,  600,  600,  600,  600,  600,  600,  600,
-00059         /* 168 */   600,  600,  600,  600,  600,  600,  600,  600,
-00060         /* 176 */   600,  600,  600,  600,  600,  600,  600,  600,
-00061         /* 184 */   600,  600,  600,  600,  600,  600,  600,  600,
-00062         /* 192 */   600,  600,  600,  600,  600,  600,  600,  600,
-00063         /* 200 */   600,  600,  600,  600,  600,  600,  600,  600,
-00064         /* 208 */   600,  600,  600,  600,  600,  600,  600,  600,
-00065         /* 216 */   600,  600,  600,  600,  600,  600,  600,  600,
-00066         /* 224 */   600,  600,  600,  600,  600,  600,  600,  600,
-00067         /* 232 */   600,  600,  600,  600,  600,  600,  600,  600,
-00068         /* 240 */   600,  600,  600,  600,  600,  600,  600,  600,
-00069         /* 248 */   600,  600,  600,  600,  600,  600,  600,  600,
-00070         },
-00071         {       /* Courier-Bold */
-00072         /*   0 */     0,    0,    0,    0,    0,    0,    0,    0,
-00073         /*   8 */     0,    0,    0,    0,    0,    0,    0,    0,
-00074         /*  16 */     0,    0,    0,    0,    0,    0,    0,    0,
-00075         /*  24 */     0,    0,    0,    0,    0,    0,    0,    0,
-00076         /*  32 */   600,  600,  600,  600,  600,  600,  600,  600,
-00077         /*  40 */   600,  600,  600,  600,  600,  600,  600,  600,
-00078         /*  48 */   600,  600,  600,  600,  600,  600,  600,  600,
-00079         /*  56 */   600,  600,  600,  600,  600,  600,  600,  600,
-00080         /*  64 */   600,  600,  600,  600,  600,  600,  600,  600,
-00081         /*  72 */   600,  600,  600,  600,  600,  600,  600,  600,
-00082         /*  80 */   600,  600,  600,  600,  600,  600,  600,  600,
-00083         /*  88 */   600,  600,  600,  600,  600,  600,  600,  600,
-00084         /*  96 */   600,  600,  600,  600,  600,  600,  600,  600,
-00085         /* 104 */   600,  600,  600,  600,  600,  600,  600,  600,
-00086         /* 112 */   600,  600,  600,  600,  600,  600,  600,  600,
-00087         /* 120 */   600,  600,  600,  600,  600,  600,  600,    0,
-00088         /* 128 */     0,    0,    0,    0,    0,    0,    0,    0,
-00089         /* 136 */     0,    0,    0,    0,  600,  600,  600,  600,
-00090         /* 144 */   600,  600,  600,  600,  600,  600,  600,  600,
-00091         /* 152 */   600,  600,  600,  600,  600,  600,  600,  600,
-00092         /* 160 */   600,  600,  600,  600,  600,  600,  600,  600,
-00093         /* 168 */   600,  600,  600,  600,  600,  600,  600,  600,
-00094         /* 176 */   600,  600,  600,  600,  600,  600,  600,  600,
-00095         /* 184 */   600,  600,  600,  600,  600,  600,  600,  600,
-00096         /* 192 */   600,  600,  600,  600,  600,  600,  600,  600,
-00097         /* 200 */   600,  600,  600,  600,  600,  600,  600,  600,
-00098         /* 208 */   600,  600,  600,  600,  600,  600,  600,  600,
-00099         /* 216 */   600,  600,  600,  600,  600,  600,  600,  600,
-00100         /* 224 */   600,  600,  600,  600,  600,  600,  600,  600,
-00101         /* 232 */   600,  600,  600,  600,  600,  600,  600,  600,
-00102         /* 240 */   600,  600,  600,  600,  600,  600,  600,  600,
-00103         /* 248 */   600,  600,  600,  600,  600,  600,  600,  600,
-00104         },
-00105         {       /* Courier-Oblique */
-00106         /*   0 */     0,    0,    0,    0,    0,    0,    0,    0,
-00107         /*   8 */     0,    0,    0,    0,    0,    0,    0,    0,
-00108         /*  16 */     0,    0,    0,    0,    0,    0,    0,    0,
-00109         /*  24 */     0,    0,    0,    0,    0,    0,    0,    0,
-00110         /*  32 */   600,  600,  600,  600,  600,  600,  600,  600,
-00111         /*  40 */   600,  600,  600,  600,  600,  600,  600,  600,
-00112         /*  48 */   600,  600,  600,  600,  600,  600,  600,  600,
-00113         /*  56 */   600,  600,  600,  600,  600,  600,  600,  600,
-00114         /*  64 */   600,  600,  600,  600,  600,  600,  600,  600,
-00115         /*  72 */   600,  600,  600,  600,  600,  600,  600,  600,
-00116         /*  80 */   600,  600,  600,  600,  600,  600,  600,  600,
-00117         /*  88 */   600,  600,  600,  600,  600,  600,  600,  600,
-00118         /*  96 */   600,  600,  600,  600,  600,  600,  600,  600,
-00119         /* 104 */   600,  600,  600,  600,  600,  600,  600,  600,
-00120         /* 112 */   600,  600,  600,  600,  600,  600,  600,  600,
-00121         /* 120 */   600,  600,  600,  600,  600,  600,  600,    0,
-00122         /* 128 */     0,    0,    0,    0,    0,    0,    0,    0,
-00123         /* 136 */     0,    0,    0,    0,  600,  600,  600,  600,
-00124         /* 144 */   600,  600,  600,  600,  600,  600,  600,  600,
-00125         /* 152 */   600,  600,  600,  600,  600,  600,  600,  600,
-00126         /* 160 */   600,  600,  600,  600,  600,  600,  600,  600,
-00127         /* 168 */   600,  600,  600,  600,  600,  600,  600,  600,
-00128         /* 176 */   600,  600,  600,  600,  600,  600,  600,  600,
-00129         /* 184 */   600,  600,  600,  600,  600,  600,  600,  600,
-00130         /* 192 */   600,  600,  600,  600,  600,  600,  600,  600,
-00131         /* 200 */   600,  600,  600,  600,  600,  600,  600,  600,
-00132         /* 208 */   600,  600,  600,  600,  600,  600,  600,  600,
-00133         /* 216 */   600,  600,  600,  600,  600,  600,  600,  600,
-00134         /* 224 */   600,  600,  600,  600,  600,  600,  600,  600,
-00135         /* 232 */   600,  600,  600,  600,  600,  600,  600,  600,
-00136         /* 240 */   600,  600,  600,  600,  600,  600,  600,  600,
-00137         /* 248 */   600,  600,  600,  600,  600,  600,  600,  600,
-00138         },
-00139         {       /* Courier-BoldOblique */
-00140         /*   0 */     0,    0,    0,    0,    0,    0,    0,    0,
-00141         /*   8 */     0,    0,    0,    0,    0,    0,    0,    0,
-00142         /*  16 */     0,    0,    0,    0,    0,    0,    0,    0,
-00143         /*  24 */     0,    0,    0,    0,    0,    0,    0,    0,
-00144         /*  32 */   600,  600,  600,  600,  600,  600,  600,  600,
-00145         /*  40 */   600,  600,  600,  600,  600,  600,  600,  600,
-00146         /*  48 */   600,  600,  600,  600,  600,  600,  600,  600,
-00147         /*  56 */   600,  600,  600,  600,  600,  600,  600,  600,
-00148         /*  64 */   600,  600,  600,  600,  600,  600,  600,  600,
-00149         /*  72 */   600,  600,  600,  600,  600,  600,  600,  600,
-00150         /*  80 */   600,  600,  600,  600,  600,  600,  600,  600,
-00151         /*  88 */   600,  600,  600,  600,  600,  600,  600,  600,
-00152         /*  96 */   600,  600,  600,  600,  600,  600,  600,  600,
-00153         /* 104 */   600,  600,  600,  600,  600,  600,  600,  600,
-00154         /* 112 */   600,  600,  600,  600,  600,  600,  600,  600,
-00155         /* 120 */   600,  600,  600,  600,  600,  600,  600,    0,
-00156         /* 128 */     0,    0,    0,    0,    0,    0,    0,    0,
-00157         /* 136 */     0,    0,    0,    0,  600,  600,  600,  600,
-00158         /* 144 */   600,  600,  600,  600,  600,  600,  600,  600,
-00159         /* 152 */   600,  600,  600,  600,  600,  600,  600,  600,
-00160         /* 160 */   600,  600,  600,  600,  600,  600,  600,  600,
-00161         /* 168 */   600,  600,  600,  600,  600,  600,  600,  600,
-00162         /* 176 */   600,  600,  600,  600,  600,  600,  600,  600,
-00163         /* 184 */   600,  600,  600,  600,  600,  600,  600,  600,
-00164         /* 192 */   600,  600,  600,  600,  600,  600,  600,  600,
-00165         /* 200 */   600,  600,  600,  600,  600,  600,  600,  600,
-00166         /* 208 */   600,  600,  600,  600,  600,  600,  600,  600,
-00167         /* 216 */   600,  600,  600,  600,  600,  600,  600,  600,
-00168         /* 224 */   600,  600,  600,  600,  600,  600,  600,  600,
-00169         /* 232 */   600,  600,  600,  600,  600,  600,  600,  600,
-00170         /* 240 */   600,  600,  600,  600,  600,  600,  600,  600,
-00171         /* 248 */   600,  600,  600,  600,  600,  600,  600,  600,
-00172         },
-00173         {       /* Times-Roman */
-00174         /*   0 */     0,    0,    0,    0,    0,    0,    0,    0,
-00175         /*   8 */     0,    0,    0,    0,    0,    0,    0,    0,
-00176         /*  16 */     0,    0,    0,    0,    0,    0,    0,    0,
-00177         /*  24 */     0,    0,    0,    0,    0,    0,    0,    0,
-00178         /*  32 */   250,  333,  408,  500,  500,  833,  778,  333,
-00179         /*  40 */   333,  333,  500,  564,  250,  333,  250,  278,
-00180         /*  48 */   500,  500,  500,  500,  500,  500,  500,  500,
-00181         /*  56 */   500,  500,  278,  278,  564,  564,  564,  444,
-00182         /*  64 */   921,  722,  667,  667,  722,  611,  556,  722,
-00183         /*  72 */   722,  333,  389,  722,  611,  889,  722,  722,
-00184         /*  80 */   556,  722,  667,  556,  611,  722,  722,  944,
-00185         /*  88 */   722,  722,  611,  333,  278,  333,  469,  500,
-00186         /*  96 */   333,  444,  500,  444,  500,  444,  333,  500,
-00187         /* 104 */   500,  278,  278,  500,  278,  778,  500,  500,
-00188         /* 112 */   500,  500,  333,  389,  278,  500,  500,  722,
-00189         /* 120 */   500,  500,  444,  480,  200,  480,  541,    0,
-00190         /* 128 */     0,    0,    0,    0,    0,    0,    0,    0,
-00191         /* 136 */     0,    0,    0,    0, 1000,  980, 1000,  350,
-00192         /* 144 */   333,  333,  333,  333,  444,  444,  444,  500,
-00193         /* 152 */  1000,  564,  889,  722,  500,  500,  556,  556,
-00194         /* 160 */   250,  333,  500,  500,  500,  500,  200,  500,
-00195         /* 168 */   333,  760,  276,  500,  564,  333,  760,  333,
-00196         /* 176 */   400,  564,  300,  300,  333,  500,  453,  250,
-00197         /* 184 */   333,  300,  310,  500,  750,  750,  750,  444,
-00198         /* 192 */   722,  722,  722,  722,  722,  722,  889,  667,
-00199         /* 200 */   611,  611,  611,  611,  333,  333,  333,  333,
-00200         /* 208 */   722,  722,  722,  722,  722,  722,  722,  564,
-00201         /* 216 */   722,  722,  722,  722,  722,  722,  556,  500,
-00202         /* 224 */   444,  444,  444,  444,  444,  444,  667,  444,
-00203         /* 232 */   444,  444,  444,  444,  278,  278,  278,  278,
-00204         /* 240 */   500,  500,  500,  500,  500,  500,  500,  564,
-00205         /* 248 */   500,  500,  500,  500,  500,  500,  500,  500,
-00206         },
-00207         {       /* Times-Bold */
-00208         /*   0 */     0,    0,    0,    0,    0,    0,    0,    0,
-00209         /*   8 */     0,    0,    0,    0,    0,    0,    0,    0,
-00210         /*  16 */     0,    0,    0,    0,    0,    0,    0,    0,
-00211         /*  24 */     0,    0,    0,    0,    0,    0,    0,    0,
-00212         /*  32 */   250,  333,  555,  500,  500, 1000,  833,  333,
-00213         /*  40 */   333,  333,  500,  570,  250,  333,  250,  278,
-00214         /*  48 */   500,  500,  500,  500,  500,  500,  500,  500,
-00215         /*  56 */   500,  500,  333,  333,  570,  570,  570,  500,
-00216         /*  64 */   930,  722,  667,  722,  722,  667,  611,  778,
-00217         /*  72 */   778,  389,  500,  778,  667,  944,  722,  778,
-00218         /*  80 */   611,  778,  722,  556,  667,  722,  722, 1000,
-00219         /*  88 */   722,  722,  667,  333,  278,  333,  581,  500,
-00220         /*  96 */   333,  500,  556,  444,  556,  444,  333,  500,
-00221         /* 104 */   556,  278,  333,  556,  278,  833,  556,  500,
-00222         /* 112 */   556,  556,  444,  389,  333,  556,  500,  722,
-00223         /* 120 */   500,  500,  444,  394,  220,  394,  520,    0,
-00224         /* 128 */     0,    0,    0,    0,    0,    0,    0,    0,
-00225         /* 136 */     0,    0,    0,    0, 1000, 1000, 1000,  350,
-00226         /* 144 */   333,  333,  333,  333,  500,  500,  500,  500,
-00227         /* 152 */  1000,  570, 1000,  722,  500,  500,  556,  556,
-00228         /* 160 */   250,  333,  500,  500,  500,  500,  220,  500,
-00229         /* 168 */   333,  747,  300,  500,  570,  333,  747,  333,
-00230         /* 176 */   400,  570,  300,  300,  333,  556,  540,  250,
-00231         /* 184 */   333,  300,  330,  500,  750,  750,  750,  500,
-00232         /* 192 */   722,  722,  722,  722,  722,  722, 1000,  722,
-00233         /* 200 */   667,  667,  667,  667,  389,  389,  389,  389,
-00234         /* 208 */   722,  722,  778,  778,  778,  778,  778,  570,
-00235         /* 216 */   778,  722,  722,  722,  722,  722,  611,  556,
-00236         /* 224 */   500,  500,  500,  500,  500,  500,  722,  444,
-00237         /* 232 */   444,  444,  444,  444,  278,  278,  278,  278,
-00238         /* 240 */   500,  556,  500,  500,  500,  500,  500,  570,
-00239         /* 248 */   500,  556,  556,  556,  556,  500,  556,  500,
-00240         },
-00241         {       /* Times-Italic */
-00242         /*   0 */     0,    0,    0,    0,    0,    0,    0,    0,
-00243         /*   8 */     0,    0,    0,    0,    0,    0,    0,    0,
-00244         /*  16 */     0,    0,    0,    0,    0,    0,    0,    0,
-00245         /*  24 */     0,    0,    0,    0,    0,    0,    0,    0,
-00246         /*  32 */   250,  333,  420,  500,  500,  833,  778,  333,
-00247         /*  40 */   333,  333,  500,  675,  250,  333,  250,  278,
-00248         /*  48 */   500,  500,  500,  500,  500,  500,  500,  500,
-00249         /*  56 */   500,  500,  333,  333,  675,  675,  675,  500,
-00250         /*  64 */   920,  611,  611,  667,  722,  611,  611,  722,
-00251         /*  72 */   722,  333,  444,  667,  556,  833,  667,  722,
-00252         /*  80 */   611,  722,  611,  500,  556,  722,  611,  833,
-00253         /*  88 */   611,  556,  556,  389,  278,  389,  422,  500,
-00254         /*  96 */   333,  500,  500,  444,  500,  444,  278,  500,
-00255         /* 104 */   500,  278,  278,  444,  278,  722,  500,  500,
-00256         /* 112 */   500,  500,  389,  389,  278,  500,  444,  667,
-00257         /* 120 */   444,  444,  389,  400,  275,  400,  541,    0,
-00258         /* 128 */     0,    0,    0,    0,    0,    0,    0,    0,
-00259         /* 136 */     0,    0,    0,    0,  889,  980, 1000,  350,
-00260         /* 144 */   333,  333,  333,  333,  556,  556,  556,  500,
-00261         /* 152 */   889,  675,  944,  667,  500,  500,  500,  500,
-00262         /* 160 */   250,  389,  500,  500,  500,  500,  275,  500,
-00263         /* 168 */   333,  760,  276,  500,  675,  333,  760,  333,
-00264         /* 176 */   400,  675,  300,  300,  333,  500,  523,  250,
-00265         /* 184 */   333,  300,  310,  500,  750,  750,  750,  500,
-00266         /* 192 */   611,  611,  611,  611,  611,  611,  889,  667,
-00267         /* 200 */   611,  611,  611,  611,  333,  333,  333,  333,
-00268         /* 208 */   722,  667,  722,  722,  722,  722,  722,  675,
-00269         /* 216 */   722,  722,  722,  722,  722,  556,  611,  500,
-00270         /* 224 */   500,  500,  500,  500,  500,  500,  667,  444,
-00271         /* 232 */   444,  444,  444,  444,  278,  278,  278,  278,
-00272         /* 240 */   500,  500,  500,  500,  500,  500,  500,  675,
-00273         /* 248 */   500,  500,  500,  500,  500,  444,  500,  444,
-00274         },
-00275         {       /* Times-BoldItalic */
-00276         /*   0 */     0,    0,    0,    0,    0,    0,    0,    0,
-00277         /*   8 */     0,    0,    0,    0,    0,    0,    0,    0,
-00278         /*  16 */     0,    0,    0,    0,    0,    0,    0,    0,
-00279         /*  24 */     0,    0,    0,    0,    0,    0,    0,    0,
-00280         /*  32 */   250,  389,  555,  500,  500,  833,  778,  333,
-00281         /*  40 */   333,  333,  500,  570,  250,  333,  250,  278,
-00282         /*  48 */   500,  500,  500,  500,  500,  500,  500,  500,
-00283         /*  56 */   500,  500,  333,  333,  570,  570,  570,  500,
-00284         /*  64 */   832,  667,  667,  667,  722,  667,  667,  722,
-00285         /*  72 */   778,  389,  500,  667,  611,  889,  722,  722,
-00286         /*  80 */   611,  722,  667,  556,  611,  722,  667,  889,
-00287         /*  88 */   667,  611,  611,  333,  278,  333,  570,  500,
-00288         /*  96 */   333,  500,  500,  444,  500,  444,  333,  500,
-00289         /* 104 */   556,  278,  278,  500,  278,  778,  556,  500,
-00290         /* 112 */   500,  500,  389,  389,  278,  556,  444,  667,
-00291         /* 120 */   500,  444,  389,  348,  220,  348,  570,    0,
-00292         /* 128 */     0,    0,    0,    0,    0,    0,    0,    0,
-00293         /* 136 */     0,    0,    0,    0, 1000, 1000, 1000,  350,
-00294         /* 144 */   333,  333,  333,  333,  500,  500,  500,  500,
-00295         /* 152 */  1000,  606,  944,  722,  500,  500,  556,  556,
-00296         /* 160 */   250,  389,  500,  500,  500,  500,  220,  500,
-00297         /* 168 */   333,  747,  266,  500,  606,  333,  747,  333,
-00298         /* 176 */   400,  570,  300,  300,  333,  576,  500,  250,
-00299         /* 184 */   333,  300,  300,  500,  750,  750,  750,  500,
-00300         /* 192 */   667,  667,  667,  667,  667,  667,  944,  667,
-00301         /* 200 */   667,  667,  667,  667,  389,  389,  389,  389,
-00302         /* 208 */   722,  722,  722,  722,  722,  722,  722,  570,
-00303         /* 216 */   722,  722,  722,  722,  722,  611,  611,  500,
-00304         /* 224 */   500,  500,  500,  500,  500,  500,  722,  444,
-00305         /* 232 */   444,  444,  444,  444,  278,  278,  278,  278,
-00306         /* 240 */   500,  556,  500,  500,  500,  500,  500,  570,
-00307         /* 248 */   500,  556,  556,  556,  556,  444,  500,  444,
-00308         },
-00309         {       /* Helvetica */
-00310         /*   0 */     0,    0,    0,    0,    0,    0,    0,    0,
-00311         /*   8 */     0,    0,    0,    0,    0,    0,    0,    0,
-00312         /*  16 */     0,    0,    0,    0,    0,    0,    0,    0,
-00313         /*  24 */     0,    0,    0,    0,    0,    0,    0,    0,
-00314         /*  32 */   278,  278,  355,  556,  556,  889,  667,  221,
-00315         /*  40 */   333,  333,  389,  584,  278,  333,  278,  278,
-00316         /*  48 */   556,  556,  556,  556,  556,  556,  556,  556,
-00317         /*  56 */   556,  556,  278,  278,  584,  584,  584,  556,
-00318         /*  64 */  1015,  667,  667,  722,  722,  667,  611,  778,
-00319         /*  72 */   722,  278,  500,  667,  556,  833,  722,  778,
-00320         /*  80 */   667,  778,  722,  667,  611,  722,  667,  944,
-00321         /*  88 */   667,  667,  611,  278,  278,  278,  469,  556,
-00322         /*  96 */   222,  556,  556,  500,  556,  556,  278,  556,
-00323         /* 104 */   556,  222,  222,  500,  222,  833,  556,  556,
-00324         /* 112 */   556,  556,  333,  500,  278,  556,  500,  722,
-00325         /* 120 */   500,  500,  500,  334,  260,  334,  584,    0,
-00326         /* 128 */     0,    0,    0,    0,    0,    0,    0,    0,
-00327         /* 136 */     0,    0,    0,    0, 1000, 1000, 1000,  350,
-00328         /* 144 */   222,  221,  333,  333,  333,  333,  333,  556,
-00329         /* 152 */  1000,  584, 1000,  944,  556,  556,  500,  500,
-00330         /* 160 */   278,  333,  556,  556,  556,  556,  260,  556,
-00331         /* 168 */   333,  737,  370,  556,  584,  333,  737,  333,
-00332         /* 176 */   606,  584,  351,  351,  333,  556,  537,  278,
-00333         /* 184 */   333,  351,  365,  556,  869,  869,  869,  611,
-00334         /* 192 */   667,  667,  667,  667,  667,  667, 1000,  722,
-00335         /* 200 */   667,  667,  667,  667,  278,  278,  278,  278,
-00336         /* 208 */   722,  722,  778,  778,  778,  778,  778,  584,
-00337         /* 216 */   778,  722,  722,  722,  722,  666,  666,  611,
-00338         /* 224 */   556,  556,  556,  556,  556,  556,  889,  500,
-00339         /* 232 */   556,  556,  556,  556,  278,  278,  278,  278,
-00340         /* 240 */   556,  556,  556,  556,  556,  556,  556,  584,
-00341         /* 248 */   611,  556,  556,  556,  556,  500,  555,  500,
-00342         },
-00343         {       /* Helvetica-Bold */
-00344         /*   0 */     0,    0,    0,    0,    0,    0,    0,    0,
-00345         /*   8 */     0,    0,    0,    0,    0,    0,    0,    0,
-00346         /*  16 */     0,    0,    0,    0,    0,    0,    0,    0,
-00347         /*  24 */     0,    0,    0,    0,    0,    0,    0,    0,
-00348         /*  32 */   278,  333,  474,  556,  556,  889,  722,  278,
-00349         /*  40 */   333,  333,  389,  584,  278,  333,  278,  278,
-00350         /*  48 */   556,  556,  556,  556,  556,  556,  556,  556,
-00351         /*  56 */   556,  556,  333,  333,  584,  584,  584,  611,
-00352         /*  64 */   975,  722,  722,  722,  722,  667,  611,  778,
-00353         /*  72 */   722,  278,  556,  722,  611,  833,  722,  778,
-00354         /*  80 */   667,  778,  722,  667,  611,  722,  667,  944,
-00355         /*  88 */   667,  667,  611,  333,  278,  333,  584,  556,
-00356         /*  96 */   278,  556,  611,  556,  611,  556,  333,  611,
-00357         /* 104 */   611,  278,  278,  556,  278,  889,  611,  611,
-00358         /* 112 */   611,  611,  389,  556,  333,  611,  556,  778,
-00359         /* 120 */   556,  556,  500,  389,  280,  389,  584,    0,
-00360         /* 128 */     0,    0,    0,    0,    0,    0,    0,    0,
-00361         /* 136 */     0,    0,    0,    0, 1000, 1000, 1000,  350,
-00362         /* 144 */   278,  278,  333,  333,  500,  500,  500,  556,
-00363         /* 152 */  1000,  584, 1000,  944,  556,  556,  611,  611,
-00364         /* 160 */   278,  333,  556,  556,  556,  556,  280,  556,
-00365         /* 168 */   333,  737,  370,  556,  584,  333,  737,  333,
-00366         /* 176 */   606,  584,  351,  351,  333,  611,  556,  278,
-00367         /* 184 */   333,  351,  365,  556,  869,  869,  869,  611,
-00368         /* 192 */   722,  722,  722,  722,  722,  722, 1000,  722,
-00369         /* 200 */   667,  667,  667,  667,  278,  278,  278,  278,
-00370         /* 208 */   722,  722,  778,  778,  778,  778,  778,  584,
-00371         /* 216 */   778,  722,  722,  722,  722,  667,  667,  611,
-00372         /* 224 */   556,  556,  556,  556,  556,  556,  889,  556,
-00373         /* 232 */   556,  556,  556,  556,  278,  278,  278,  278,
-00374         /* 240 */   611,  611,  611,  611,  611,  611,  611,  584,
-00375         /* 248 */   611,  611,  611,  611,  611,  556,  611,  556,
-00376         },
-00377         {       /* Helvetica-Oblique */
-00378         /*   0 */     0,    0,    0,    0,    0,    0,    0,    0,
-00379         /*   8 */     0,    0,    0,    0,    0,    0,    0,    0,
-00380         /*  16 */     0,    0,    0,    0,    0,    0,    0,    0,
-00381         /*  24 */     0,    0,    0,    0,    0,    0,    0,    0,
-00382         /*  32 */   278,  278,  355,  556,  556,  889,  667,  222,
-00383         /*  40 */   333,  333,  389,  584,  278,  333,  278,  278,
-00384         /*  48 */   556,  556,  556,  556,  556,  556,  556,  556,
-00385         /*  56 */   556,  556,  278,  278,  584,  584,  584,  556,
-00386         /*  64 */  1015,  667,  667,  722,  722,  667,  611,  778,
-00387         /*  72 */   722,  278,  500,  667,  556,  833,  722,  778,
-00388         /*  80 */   667,  778,  722,  667,  611,  722,  667,  944,
-00389         /*  88 */   667,  667,  611,  278,  278,  278,  469,  556,
-00390         /*  96 */   222,  556,  556,  500,  556,  556,  278,  556,
-00391         /* 104 */   556,  222,  222,  500,  222,  833,  556,  556,
-00392         /* 112 */   556,  556,  333,  500,  278,  556,  500,  722,
-00393         /* 120 */   500,  500,  500,  334,  260,  334,  584,    0,
-00394         /* 128 */     0,    0,    0,    0,    0,    0,    0,    0,
-00395         /* 136 */     0,    0,    0,    0, 1000, 1000, 1000,  350,
-00396         /* 144 */   222,  222,  333,  333,  333,  333,  333,  556,
-00397         /* 152 */  1000,  584, 1000,  944,  556,  556,  500,  500,
-00398         /* 160 */   278,  333,  556,  556,  556,  556,  260,  556,
-00399         /* 168 */   333,  737,  370,  556,  584,  333,  737,  333,
-00400         /* 176 */   606,  584,  390,  390,  333,  556,  537,  278,
-00401         /* 184 */   333,  390,  365,  556,  947,  947,  947,  611,
-00402         /* 192 */   667,  667,  667,  667,  667,  667, 1000,  722,
-00403         /* 200 */   667,  667,  667,  667,  278,  278,  278,  278,
-00404         /* 208 */   722,  722,  778,  778,  778,  778,  778,  584,
-00405         /* 216 */   778,  722,  722,  722,  722,  667,  667,  611,
-00406         /* 224 */   556,  556,  556,  556,  556,  556,  889,  500,
-00407         /* 232 */   556,  556,  556,  556,  278,  278,  278,  278,
-00408         /* 240 */   556,  556,  556,  556,  556,  556,  556,  584,
-00409         /* 248 */   611,  556,  556,  556,  556,  500,  556,  500,
-00410         },
-00411         {       /* Helvetica-BoldOblique */
-00412         /*   0 */     0,    0,    0,    0,    0,    0,    0,    0,
-00413         /*   8 */     0,    0,    0,    0,    0,    0,    0,    0,
-00414         /*  16 */     0,    0,    0,    0,    0,    0,    0,    0,
-00415         /*  24 */     0,    0,    0,    0,    0,    0,    0,    0,
-00416         /*  32 */   278,  333,  474,  556,  556,  889,  722,  278,
-00417         /*  40 */   333,  333,  389,  584,  278,  333,  278,  278,
-00418         /*  48 */   556,  556,  556,  556,  556,  556,  556,  556,
-00419         /*  56 */   556,  556,  333,  333,  584,  584,  584,  611,
-00420         /*  64 */   975,  722,  722,  722,  722,  667,  611,  778,
-00421         /*  72 */   722,  278,  556,  722,  611,  833,  722,  778,
-00422         /*  80 */   667,  778,  722,  667,  611,  722,  667,  944,
-00423         /*  88 */   667,  667,  611,  333,  278,  333,  584,  556,
-00424         /*  96 */   278,  556,  611,  556,  611,  556,  333,  611,
-00425         /* 104 */   611,  278,  278,  556,  278,  889,  611,  611,
-00426         /* 112 */   611,  611,  389,  556,  333,  611,  556,  778,
-00427         /* 120 */   556,  556,  500,  389,  280,  389,  584,    0,
-00428         /* 128 */     0,    0,    0,    0,    0,    0,    0,    0,
-00429         /* 136 */     0,    0,    0,    0, 1000, 1000, 1000,  350,
-00430         /* 144 */   278,  278,  333,  333,  500,  500,  500,  556,
-00431         /* 152 */  1000,  584, 1000,  944,  556,  556,  611,  611,
-00432         /* 160 */   278,  333,  556,  556,  556,  556,  280,  556,
-00433         /* 168 */   333,  737,  370,  556,  584,  333,  737,  333,
-00434         /* 176 */   606,  584,  444,  444,  333,  611,  556,  278,
-00435         /* 184 */   333,  444,  365,  556, 1055, 1055, 1055,  611,
-00436         /* 192 */   722,  722,  722,  722,  722,  722, 1000,  722,
-00437         /* 200 */   667,  667,  667,  667,  278,  278,  278,  278,
-00438         /* 208 */   722,  722,  778,  778,  778,  778,  778,  584,
-00439         /* 216 */   778,  722,  722,  722,  722,  667,  667,  611,
-00440         /* 224 */   556,  556,  556,  556,  556,  556,  889,  556,
-00441         /* 232 */   556,  556,  556,  556,  278,  278,  278,  278,
-00442         /* 240 */   611,  611,  611,  611,  611,  611,  611,  584,
-00443         /* 248 */   611,  611,  611,  611,  611,  556,  611,  556,
-00444         },
-00445         {       /* Palatino-Roman */
-00446         /*   0 */     0,    0,    0,    0,    0,    0,    0,    0,
-00447         /*   8 */     0,    0,    0,    0,    0,    0,    0,    0,
-00448         /*  16 */     0,    0,    0,    0,    0,    0,    0,    0,
-00449         /*  24 */     0,    0,    0,    0,    0,    0,    0,    0,
-00450         /*  32 */   250,  278,  371,  500,  500,  840,  778,  278,
-00451         /*  40 */   333,  333,  389,  606,  250,  333,  250,  606,
-00452         /*  48 */   500,  500,  500,  500,  500,  500,  500,  500,
-00453         /*  56 */   500,  500,  250,  250,  606,  606,  606,  444,
-00454         /*  64 */   747,  778,  611,  709,  774,  611,  556,  763,
-00455         /*  72 */   832,  337,  333,  726,  611,  946,  831,  786,
-00456         /*  80 */   604,  786,  668,  525,  613,  778,  722, 1000,
-00457         /*  88 */   667,  667,  667,  333,  606,  333,  606,  500,
-00458         /*  96 */   278,  500,  553,  444,  611,  479,  333,  556,
-00459         /* 104 */   582,  291,  234,  556,  291,  883,  582,  546,
-00460         /* 112 */   601,  560,  395,  424,  326,  603,  565,  834,
-00461         /* 120 */   516,  556,  500,  333,  606,  333,  606,    0,
-00462         /* 128 */     0,    0,    0,    0,    0,    0,    0,    0,
-00463         /* 136 */     0,    0,    0,    0, 1000,  979, 1144,  606,
-00464         /* 144 */   278,  278,  331,  331,  500,  500,  500,  500,
-00465         /* 152 */  1000,  606,  998,  827,  500,  500,  605,  608,
-00466         /* 160 */   250,  278,  500,  500,  500,  500,  606,  500,
-00467         /* 168 */   333,  747,  333,  500,  606,  333,  747,  333,
-00468         /* 176 */   400,  606,  300,  300,  333,  603,  628,  250,
-00469         /* 184 */   333,  300,  333,  500,  750,  750,  750,  444,
-00470         /* 192 */   778,  778,  778,  778,  778,  778,  944,  709,
-00471         /* 200 */   611,  611,  611,  611,  337,  337,  337,  337,
-00472         /* 208 */   774,  831,  786,  786,  786,  786,  786,  606,
-00473         /* 216 */   833,  778,  778,  778,  778,  667,  604,  556,
-00474         /* 224 */   500,  500,  500,  500,  500,  500,  758,  444,
-00475         /* 232 */   479,  479,  479,  479,  287,  287,  287,  287,
-00476         /* 240 */   546,  582,  546,  546,  546,  546,  546,  606,
-00477         /* 248 */   556,  603,  603,  603,  603,  556,  601,  556,
-00478         },
-00479         {       /* Palatino-Bold */
-00480         /*   0 */     0,    0,    0,    0,    0,    0,    0,    0,
-00481         /*   8 */     0,    0,    0,    0,    0,    0,    0,    0,
-00482         /*  16 */     0,    0,    0,    0,    0,    0,    0,    0,
-00483         /*  24 */     0,    0,    0,    0,    0,    0,    0,    0,
-00484         /*  32 */   250,  278,  402,  500,  500,  889,  833,  278,
-00485         /*  40 */   333,  333,  444,  606,  250,  333,  250,  296,
-00486         /*  48 */   500,  500,  500,  500,  500,  500,  500,  500,
-00487         /*  56 */   500,  500,  250,  250,  606,  606,  606,  444,
-00488         /*  64 */   747,  778,  667,  722,  833,  611,  556,  833,
-00489         /*  72 */   833,  389,  389,  778,  611, 1000,  833,  833,
-00490         /*  80 */   611,  833,  722,  611,  667,  778,  778, 1000,
-00491         /*  88 */   667,  667,  667,  333,  606,  333,  606,  500,
-00492         /*  96 */   278,  500,  611,  444,  611,  500,  389,  556,
-00493         /* 104 */   611,  333,  333,  611,  333,  889,  611,  556,
-00494         /* 112 */   611,  611,  389,  444,  333,  611,  556,  833,
-00495         /* 120 */   500,  556,  500,  310,  606,  310,  606,    0,
-00496         /* 128 */     0,    0,    0,    0,    0,    0,    0,    0,
-00497         /* 136 */     0,    0,    0,    0, 1000,  998, 1000,  606,
-00498         /* 144 */   278,  278,  389,  389,  500,  500,  500,  500,
-00499         /* 152 */  1000,  606, 1000,  833,  500,  500,  611,  611,
-00500         /* 160 */   250,  278,  500,  500,  500,  500,  606,  500,
-00501         /* 168 */   333,  747,  438,  500,  606,  333,  747,  333,
-00502         /* 176 */   400,  606,  300,  300,  333,  611,  641,  250,
-00503         /* 184 */   333,  300,  488,  500,  750,  750,  750,  444,
-00504         /* 192 */   778,  778,  778,  778,  778,  778, 1000,  722,
-00505         /* 200 */   611,  611,  611,  611,  389,  389,  389,  389,
-00506         /* 208 */   833,  833,  833,  833,  833,  833,  833,  606,
-00507         /* 216 */   833,  778,  778,  778,  778,  667,  611,  611,
-00508         /* 224 */   500,  500,  500,  500,  500,  500,  778,  444,
-00509         /* 232 */   500,  500,  500,  500,  333,  333,  333,  333,
-00510         /* 240 */   556,  611,  556,  556,  556,  556,  556,  606,
-00511         /* 248 */   556,  611,  611,  611,  611,  556,  611,  556,
-00512         },
-00513         {       /* Palatino-Italic */
-00514         /*   0 */     0,    0,    0,    0,    0,    0,    0,    0,
-00515         /*   8 */     0,    0,    0,    0,    0,    0,    0,    0,
-00516         /*  16 */     0,    0,    0,    0,    0,    0,    0,    0,
-00517         /*  24 */     0,    0,    0,    0,    0,    0,    0,    0,
-00518         /*  32 */   250,  333,  500,  500,  500,  889,  778,  278,
-00519         /*  40 */   333,  333,  389,  606,  250,  333,  250,  296,
-00520         /*  48 */   500,  500,  500,  500,  500,  500,  500,  500,
-00521         /*  56 */   500,  500,  250,  250,  606,  606,  606,  500,
-00522         /*  64 */   747,  722,  611,  667,  778,  611,  556,  722,
-00523         /*  72 */   778,  333,  333,  667,  556,  944,  778,  778,
-00524         /*  80 */   611,  778,  667,  556,  611,  778,  722,  944,
-00525         /*  88 */   722,  667,  667,  333,  606,  333,  606,  500,
-00526         /*  96 */   278,  444,  463,  407,  500,  389,  278,  500,
-00527         /* 104 */   500,  278,  278,  444,  278,  778,  556,  444,
-00528         /* 112 */   500,  463,  389,  389,  333,  556,  500,  722,
-00529         /* 120 */   500,  500,  444,  333,  606,  333,  606,    0,
-00530         /* 128 */     0,    0,    0,    0,    0,    0,    0,    0,
-00531         /* 136 */     0,    0,    0,    0, 1000, 1000, 1000,  500,
-00532         /* 144 */   278,  278,  333,  333,  500,  500,  500,  500,
-00533         /* 152 */  1000,  606, 1028,  669,  500,  500,  528,  545,
-00534         /* 160 */   250,  333,  500,  500,  500,  500,  606,  500,
-00535         /* 168 */   333,  747,  333,  500,  606,  333,  747,  333,
-00536         /* 176 */   400,  606,  300,  300,  333,  556,  500,  250,
-00537         /* 184 */   333,  300,  333,  500,  750,  750,  750,  500,
-00538         /* 192 */   722,  722,  722,  722,  722,  722,  941,  667,
-00539         /* 200 */   611,  611,  611,  611,  333,  333,  333,  333,
-00540         /* 208 */   778,  778,  778,  778,  778,  778,  778,  606,
-00541         /* 216 */   778,  778,  778,  778,  778,  667,  611,  500,
-00542         /* 224 */   444,  444,  444,  444,  444,  444,  638,  407,
-00543         /* 232 */   389,  389,  389,  389,  278,  278,  278,  278,
-00544         /* 240 */   444,  556,  444,  444,  444,  444,  444,  606,
-00545         /* 248 */   444,  556,  556,  556,  556,  500,  500,  500,
-00546         },
-00547         {       /* Palatino-BoldItalic */
-00548         /*   0 */     0,    0,    0,    0,    0,    0,    0,    0,
-00549         /*   8 */     0,    0,    0,    0,    0,    0,    0,    0,
-00550         /*  16 */     0,    0,    0,    0,    0,    0,    0,    0,
-00551         /*  24 */     0,    0,    0,    0,    0,    0,    0,    0,
-00552         /*  32 */   250,  333,  500,  500,  500,  889,  833,  278,
-00553         /*  40 */   333,  333,  444,  606,  250,  389,  250,  315,
-00554         /*  48 */   500,  500,  500,  500,  500,  500,  500,  500,
-00555         /*  56 */   500,  500,  250,  250,  606,  606,  606,  444,
-00556         /*  64 */   833,  722,  667,  685,  778,  611,  556,  778,
-00557         /*  72 */   778,  389,  389,  722,  611,  944,  778,  833,
-00558         /*  80 */   667,  833,  722,  556,  611,  778,  667, 1000,
-00559         /*  88 */   722,  611,  667,  333,  606,  333,  606,  500,
-00560         /*  96 */   278,  556,  537,  444,  556,  444,  333,  500,
-00561         /* 104 */   556,  333,  333,  556,  333,  833,  556,  556,
-00562         /* 112 */   556,  537,  389,  444,  389,  556,  556,  833,
-00563         /* 120 */   500,  556,  500,  333,  606,  333,  606,    0,
-00564         /* 128 */     0,    0,    0,    0,    0,    0,    0,    0,
-00565         /* 136 */     0,    0,    0,    0, 1000, 1000, 1000,  606,
-00566         /* 144 */   278,  278,  333,  333,  500,  500,  500,  500,
-00567         /* 152 */  1000,  606,  944,  778,  556,  556,  611,  611,
-00568         /* 160 */   250,  333,  500,  500,  500,  500,  606,  556,
-00569         /* 168 */   333,  747,  333,  500,  606,  389,  747,  333,
-00570         /* 176 */   400,  606,  300,  300,  333,  556,  556,  250,
-00571         /* 184 */   333,  300,  333,  500,  750,  750,  750,  444,
-00572         /* 192 */   722,  722,  722,  722,  722,  722,  944,  685,
-00573         /* 200 */   611,  611,  611,  611,  389,  389,  389,  389,
-00574         /* 208 */   778,  778,  833,  833,  833,  833,  833,  606,
-00575         /* 216 */   833,  778,  778,  778,  778,  611,  667,  556,
-00576         /* 224 */   556,  556,  556,  556,  556,  556,  738,  444,
-00577         /* 232 */   444,  444,  444,  444,  333,  333,  333,  333,
-00578         /* 240 */   556,  556,  556,  556,  556,  556,  556,  606,
-00579         /* 248 */   556,  556,  556,  556,  556,  556,  556,  556,
-00580         },
-00581         {       /* Helvetica-Narrow */
-00582         /*   0 */     0,    0,    0,    0,    0,    0,    0,    0,
-00583         /*   8 */     0,    0,    0,    0,    0,    0,    0,    0,
-00584         /*  16 */     0,    0,    0,    0,    0,    0,    0,    0,
-00585         /*  24 */     0,    0,    0,    0,    0,    0,    0,    0,
-00586         /*  32 */   228,  228,  291,  456,  456,  729,  547,  182,
-00587         /*  40 */   273,  273,  319,  479,  228,  273,  228,  228,
-00588         /*  48 */   456,  456,  456,  456,  456,  456,  456,  456,
-00589         /*  56 */   456,  456,  228,  228,  479,  479,  479,  456,
-00590         /*  64 */   832,  547,  547,  592,  592,  547,  501,  638,
-00591         /*  72 */   592,  228,  410,  547,  456,  683,  592,  638,
-00592         /*  80 */   547,  638,  592,  547,  501,  592,  547,  774,
-00593         /*  88 */   547,  547,  501,  228,  228,  228,  385,  456,
-00594         /*  96 */   182,  456,  456,  410,  456,  456,  228,  456,
-00595         /* 104 */   456,  182,  182,  410,  182,  683,  456,  456,
-00596         /* 112 */   456,  456,  273,  410,  228,  456,  410,  592,
-00597         /* 120 */   410,  410,  410,  274,  213,  274,  479,    0,
-00598         /* 128 */     0,    0,    0,    0,    0,    0,    0,    0,
-00599         /* 136 */     0,    0,    0,    0,  820,  820,  820,  287,
-00600         /* 144 */   182,  182,  273,  273,  273,  273,  273,  456,
-00601         /* 152 */   820,  479,  820,  774,  456,  456,  410,  410,
-00602         /* 160 */   228,  273,  456,  456,  456,  456,  213,  456,
-00603         /* 168 */   273,  604,  303,  456,  479,  273,  604,  273,
-00604         /* 176 */   328,  479,  273,  273,  273,  456,  440,  228,
-00605         /* 184 */   273,  273,  299,  456,  684,  684,  684,  501,
-00606         /* 192 */   547,  547,  547,  547,  547,  547,  820,  592,
-00607         /* 200 */   547,  547,  547,  547,  228,  228,  228,  228,
-00608         /* 208 */   592,  592,  638,  638,  638,  638,  638,  479,
-00609         /* 216 */   638,  592,  592,  592,  592,  547,  547,  501,
-00610         /* 224 */   456,  456,  456,  456,  456,  456,  729,  410,
-00611         /* 232 */   456,  456,  456,  456,  228,  228,  228,  228,
-00612         /* 240 */   456,  456,  456,  456,  456,  456,  456,  479,
-00613         /* 248 */   501,  456,  456,  456,  456,  410,  456,  410,
-00614         },
-00615         {       /* Helvetica-Narrow-Bold */
-00616         /*   0 */     0,    0,    0,    0,    0,    0,    0,    0,
-00617         /*   8 */     0,    0,    0,    0,    0,    0,    0,    0,
-00618         /*  16 */     0,    0,    0,    0,    0,    0,    0,    0,
-00619         /*  24 */     0,    0,    0,    0,    0,    0,    0,    0,
-00620         /*  32 */   228,  273,  389,  456,  456,  729,  592,  228,
-00621         /*  40 */   273,  273,  319,  479,  228,  273,  228,  228,
-00622         /*  48 */   456,  456,  456,  456,  456,  456,  456,  456,
-00623         /*  56 */   456,  456,  273,  273,  479,  479,  479,  501,
-00624         /*  64 */   800,  592,  592,  592,  592,  547,  501,  638,
-00625         /*  72 */   592,  228,  456,  592,  501,  683,  592,  638,
-00626         /*  80 */   547,  638,  592,  547,  501,  592,  547,  774,
-00627         /*  88 */   547,  547,  501,  273,  228,  273,  479,  456,
-00628         /*  96 */   228,  456,  501,  456,  501,  456,  273,  501,
-00629         /* 104 */   501,  228,  228,  456,  228,  729,  501,  501,
-00630         /* 112 */   501,  501,  319,  456,  273,  501,  456,  638,
-00631         /* 120 */   456,  456,  410,  319,  230,  319,  479,    0,
-00632         /* 128 */     0,    0,    0,    0,    0,    0,    0,    0,
-00633         /* 136 */     0,    0,    0,    0,  820,  820,  820,  287,
-00634         /* 144 */   228,  228,  273,  273,  410,  410,  410,  456,
-00635         /* 152 */   820,  479,  820,  774,  456,  456,  501,  501,
-00636         /* 160 */   228,  273,  456,  456,  456,  456,  230,  456,
-00637         /* 168 */   273,  604,  303,  456,  479,  273,  604,  273,
-00638         /* 176 */   328,  479,  273,  273,  273,  501,  456,  228,
-00639         /* 184 */   273,  273,  299,  456,  684,  684,  684,  501,
-00640         /* 192 */   592,  592,  592,  592,  592,  592,  820,  592,
-00641         /* 200 */   547,  547,  547,  547,  228,  228,  228,  228,
-00642         /* 208 */   592,  592,  638,  638,  638,  638,  638,  479,
-00643         /* 216 */   638,  592,  592,  592,  592,  547,  547,  501,
-00644         /* 224 */   456,  456,  456,  456,  456,  456,  729,  456,
-00645         /* 232 */   456,  456,  456,  456,  228,  228,  228,  228,
-00646         /* 240 */   501,  501,  501,  501,  501,  501,  501,  479,
-00647         /* 248 */   501,  501,  501,  501,  501,  456,  501,  456,
-00648         },
-00649         {       /* Helvetica-Narrow-Oblique */
-00650         /*   0 */     0,    0,    0,    0,    0,    0,    0,    0,
-00651         /*   8 */     0,    0,    0,    0,    0,    0,    0,    0,
-00652         /*  16 */     0,    0,    0,    0,    0,    0,    0,    0,
-00653         /*  24 */     0,    0,    0,    0,    0,    0,    0,    0,
-00654         /*  32 */   228,  228,  291,  456,  456,  729,  547,  182,
-00655         /*  40 */   273,  273,  319,  479,  228,  273,  228,  228,
-00656         /*  48 */   456,  456,  456,  456,  456,  456,  456,  456,
-00657         /*  56 */   456,  456,  228,  228,  479,  479,  479,  456,
-00658         /*  64 */   832,  547,  547,  592,  592,  547,  501,  638,
-00659         /*  72 */   592,  228,  410,  547,  456,  683,  592,  638,
-00660         /*  80 */   547,  638,  592,  547,  501,  592,  547,  774,
-00661         /*  88 */   547,  547,  501,  228,  228,  228,  385,  456,
-00662         /*  96 */   182,  456,  456,  410,  456,  456,  228,  456,
-00663         /* 104 */   456,  182,  182,  410,  182,  683,  456,  456,
-00664         /* 112 */   456,  456,  273,  410,  228,  456,  410,  592,
-00665         /* 120 */   410,  410,  410,  274,  213,  274,  479,    0,
-00666         /* 128 */     0,    0,    0,    0,    0,    0,    0,    0,
-00667         /* 136 */     0,    0,    0,    0,  820,  820,  820,  287,
-00668         /* 144 */   182,  182,  273,  273,  273,  273,  273,  456,
-00669         /* 152 */   820,  479,  820,  774,  456,  456,  410,  410,
-00670         /* 160 */   228,  273,  456,  456,  456,  456,  213,  456,
-00671         /* 168 */   273,  604,  303,  456,  479,  273,  604,  273,
-00672         /* 176 */   328,  479,  273,  273,  273,  456,  440,  228,
-00673         /* 184 */   273,  273,  299,  456,  684,  684,  684,  501,
-00674         /* 192 */   547,  547,  547,  547,  547,  547,  820,  592,
-00675         /* 200 */   547,  547,  547,  547,  228,  228,  228,  228,
-00676         /* 208 */   592,  592,  638,  638,  638,  638,  638,  479,
-00677         /* 216 */   638,  592,  592,  592,  592,  547,  547,  501,
-00678         /* 224 */   456,  456,  456,  456,  456,  456,  729,  410,
-00679         /* 232 */   456,  456,  456,  456,  228,  228,  228,  228,
-00680         /* 240 */   456,  456,  456,  456,  456,  456,  456,  479,
-00681         /* 248 */   501,  456,  456,  456,  456,  410,  456,  410,
-00682         },
-00683         {       /* Helvetica-Narrow-BoldOblique */
-00684         /*   0 */     0,    0,    0,    0,    0,    0,    0,    0,
-00685         /*   8 */     0,    0,    0,    0,    0,    0,    0,    0,
-00686         /*  16 */     0,    0,    0,    0,    0,    0,    0,    0,
-00687         /*  24 */     0,    0,    0,    0,    0,    0,    0,    0,
-00688         /*  32 */   228,  273,  389,  456,  456,  729,  592,  228,
-00689         /*  40 */   273,  273,  319,  479,  228,  273,  228,  228,
-00690         /*  48 */   456,  456,  456,  456,  456,  456,  456,  456,
-00691         /*  56 */   456,  456,  273,  273,  479,  479,  479,  501,
-00692         /*  64 */   800,  592,  592,  592,  592,  547,  501,  638,
-00693         /*  72 */   592,  228,  456,  592,  501,  683,  592,  638,
-00694         /*  80 */   547,  638,  592,  547,  501,  592,  547,  774,
-00695         /*  88 */   547,  547,  501,  273,  228,  273,  479,  456,
-00696         /*  96 */   228,  456,  501,  456,  501,  456,  273,  501,
-00697         /* 104 */   501,  228,  228,  456,  228,  729,  501,  501,
-00698         /* 112 */   501,  501,  319,  456,  273,  501,  456,  638,
-00699         /* 120 */   456,  456,  410,  319,  230,  319,  479,    0,
-00700         /* 128 */     0,    0,    0,    0,    0,    0,    0,    0,
-00701         /* 136 */     0,    0,    0,    0,  820,  820,  820,  287,
-00702         /* 144 */   228,  228,  273,  273,  410,  410,  410,  456,
-00703         /* 152 */   820,  479,  820,  774,  456,  456,  501,  501,
-00704         /* 160 */   228,  273,  456,  456,  456,  456,  230,  456,
-00705         /* 168 */   273,  604,  303,  456,  479,  273,  604,  273,
-00706         /* 176 */   328,  479,  273,  273,  273,  501,  456,  228,
-00707         /* 184 */   273,  273,  299,  456,  684,  684,  684,  501,
-00708         /* 192 */   592,  592,  592,  592,  592,  592,  820,  592,
-00709         /* 200 */   547,  547,  547,  547,  228,  228,  228,  228,
-00710         /* 208 */   592,  592,  638,  638,  638,  638,  638,  479,
-00711         /* 216 */   638,  592,  592,  592,  592,  547,  547,  501,
-00712         /* 224 */   456,  456,  456,  456,  456,  456,  729,  456,
-00713         /* 232 */   456,  456,  456,  456,  228,  228,  228,  228,
-00714         /* 240 */   501,  501,  501,  501,  501,  501,  501,  479,
-00715         /* 248 */   501,  501,  501,  501,  501,  456,  501,  456,
-00716         },
-00717         {       /* Bookman-Light */
-00718         /*   0 */     0,    0,    0,    0,    0,    0,    0,    0,
-00719         /*   8 */     0,    0,    0,    0,    0,    0,    0,    0,
-00720         /*  16 */     0,    0,    0,    0,    0,    0,    0,    0,
-00721         /*  24 */     0,    0,    0,    0,    0,    0,    0,    0,
-00722         /*  32 */   320,  300,  380,  620,  620,  900,  800,  220,
-00723         /*  40 */   300,  300,  440,  600,  320,  400,  320,  600,
-00724         /*  48 */   620,  620,  620,  620,  620,  620,  620,  620,
-00725         /*  56 */   620,  620,  320,  320,  600,  600,  600,  540,
-00726         /*  64 */   820,  680,  740,  740,  800,  720,  640,  800,
-00727         /*  72 */   800,  340,  600,  720,  600,  920,  740,  800,
-00728         /*  80 */   620,  820,  720,  660,  620,  780,  700,  960,
-00729         /*  88 */   720,  640,  640,  300,  600,  300,  600,  500,
-00730         /*  96 */   220,  580,  620,  520,  620,  520,  320,  540,
-00731         /* 104 */   660,  300,  300,  620,  300,  940,  660,  560,
-00732         /* 112 */   620,  580,  440,  520,  380,  680,  520,  780,
-00733         /* 120 */   560,  540,  480,  280,  600,  280,  600,    0,
-00734         /* 128 */     0,    0,    0,    0,    0,    0,    0,    0,
-00735         /* 136 */     0,    0,    0,    0, 1000,  980, 1280,  460,
-00736         /* 144 */   220,  220,  240,  240,  400,  400,  400,  500,
-00737         /* 152 */  1000,  600, 1240,  900,  540,  540,  620,  620,
-00738         /* 160 */   320,  300,  620,  620,  620,  620,  600,  520,
-00739         /* 168 */   420,  740,  420,  360,  600,  400,  740,  440,
-00740         /* 176 */   400,  600,  372,  372,  340,  680,  600,  320,
-00741         /* 184 */   320,  372,  420,  360,  930,  930,  930,  540,
-00742         /* 192 */   680,  680,  680,  680,  680,  680, 1260,  740,
-00743         /* 200 */   720,  720,  720,  720,  340,  340,  340,  340,
-00744         /* 208 */   800,  740,  800,  800,  800,  800,  800,  600,
-00745         /* 216 */   800,  780,  780,  780,  780,  640,  620,  660,
-00746         /* 224 */   580,  580,  580,  580,  580,  580,  860,  520,
-00747         /* 232 */   520,  520,  520,  520,  300,  300,  300,  300,
-00748         /* 240 */   560,  660,  560,  560,  560,  560,  560,  600,
-00749         /* 248 */   560,  680,  680,  680,  680,  540,  620,  540,
-00750         },
-00751         {       /* Bookman-Demi */
-00752         /*   0 */     0,    0,    0,    0,    0,    0,    0,    0,
-00753         /*   8 */     0,    0,    0,    0,    0,    0,    0,    0,
-00754         /*  16 */     0,    0,    0,    0,    0,    0,    0,    0,
-00755         /*  24 */     0,    0,    0,    0,    0,    0,    0,    0,
-00756         /*  32 */   340,  360,  420,  660,  660,  940,  800,  320,
-00757         /*  40 */   320,  320,  460,  600,  340,  360,  340,  600,
-00758         /*  48 */   660,  660,  660,  660,  660,  660,  660,  660,
-00759         /*  56 */   660,  660,  340,  340,  600,  600,  600,  660,
-00760         /*  64 */   820,  720,  720,  740,  780,  720,  680,  780,
-00761         /*  72 */   820,  400,  640,  800,  640,  940,  740,  800,
-00762         /*  80 */   660,  800,  780,  660,  700,  740,  720,  940,
-00763         /*  88 */   780,  700,  640,  300,  600,  300,  600,  500,
-00764         /*  96 */   320,  580,  600,  580,  640,  580,  380,  580,
-00765         /* 104 */   680,  360,  340,  660,  340, 1000,  680,  620,
-00766         /* 112 */   640,  620,  460,  520,  460,  660,  600,  800,
-00767         /* 120 */   600,  620,  560,  320,  600,  320,  600,    0,
-00768         /* 128 */     0,    0,    0,    0,    0,    0,    0,    0,
-00769         /* 136 */     0,    0,    0,    0, 1000,  980, 1360,  460,
-00770         /* 144 */   320,  320,  220,  220,  540,  540,  540,  500,
-00771         /* 152 */  1000,  600, 1220,  940,  440,  380,  740,  740,
-00772         /* 160 */   340,  360,  660,  660,  660,  660,  600,  600,
-00773         /* 168 */   500,  740,  400,  400,  600,  360,  740,  460,
-00774         /* 176 */   400,  600,  396,  396,  400,  660,  800,  340,
-00775         /* 184 */   360,  396,  400,  400,  990,  990,  990,  660,
-00776         /* 192 */   720,  720,  720,  720,  720,  720, 1140,  740,
-00777         /* 200 */   720,  720,  720,  720,  400,  400,  400,  400,
-00778         /* 208 */   780,  740,  800,  800,  800,  800,  800,  600,
-00779         /* 216 */   800,  740,  740,  740,  740,  700,  660,  660,
-00780         /* 224 */   580,  580,  580,  580,  580,  580,  880,  580,
-00781         /* 232 */   580,  580,  580,  580,  360,  360,  360,  360,
-00782         /* 240 */   620,  680,  620,  620,  620,  620,  620,  600,
-00783         /* 248 */   620,  660,  660,  660,  660,  620,  640,  620,
-00784         },
-00785         {       /* Bookman-LightItalic */
-00786         /*   0 */     0,    0,    0,    0,    0,    0,    0,    0,
-00787         /*   8 */     0,    0,    0,    0,    0,    0,    0,    0,
-00788         /*  16 */     0,    0,    0,    0,    0,    0,    0,    0,
-00789         /*  24 */     0,    0,    0,    0,    0,    0,    0,    0,
-00790         /*  32 */   300,  320,  360,  620,  620,  800,  820,  280,
-00791         /*  40 */   280,  280,  440,  600,  300,  320,  300,  600,
-00792         /*  48 */   620,  620,  620,  620,  620,  620,  620,  620,
-00793         /*  56 */   620,  620,  300,  300,  600,  600,  600,  540,
-00794         /*  64 */   780,  700,  720,  720,  740,  680,  620,  760,
-00795         /*  72 */   800,  320,  560,  720,  580,  860,  720,  760,
-00796         /*  80 */   600,  780,  700,  640,  600,  720,  680,  960,
-00797         /*  88 */   700,  660,  580,  260,  600,  260,  600,  500,
-00798         /*  96 */   280,  620,  600,  480,  640,  540,  340,  560,
-00799         /* 104 */   620,  280,  280,  600,  280,  880,  620,  540,
-00800         /* 112 */   600,  560,  400,  540,  340,  620,  540,  880,
-00801         /* 120 */   540,  600,  520,  360,  600,  380,  600,    0,
-00802         /* 128 */     0,    0,    0,    0,    0,    0,    0,    0,
-00803         /* 136 */     0,    0,    0,    0, 1000,  980, 1180,  460,
-00804         /* 144 */   280,  280,  180,  180,  440,  440,  480,  500,
-00805         /* 152 */  1000,  600, 1180,  900,  620,  620,  640,  660,
-00806         /* 160 */   300,  320,  620,  620,  620,  620,  600,  620,
-00807         /* 168 */   420,  740,  440,  300,  600,  320,  740,  440,
-00808         /* 176 */   400,  600,  372,  372,  320,  620,  620,  300,
-00809         /* 184 */   320,  372,  400,  300,  930,  930,  930,  540,
-00810         /* 192 */   700,  700,  700,  700,  700,  700, 1220,  720,
-00811         /* 200 */   680,  680,  680,  680,  320,  320,  320,  320,
-00812         /* 208 */   740,  720,  760,  760,  760,  760,  760,  600,
-00813         /* 216 */   760,  720,  720,  720,  720,  660,  600,  620,
-00814         /* 224 */   620,  620,  620,  620,  620,  620,  880,  480,
-00815         /* 232 */   540,  540,  540,  540,  280,  280,  280,  280,
-00816         /* 240 */   540,  620,  540,  540,  540,  540,  540,  600,
-00817         /* 248 */   540,  620,  620,  620,  620,  600,  600,  600,
-00818         },
-00819         {       /* Bookman-DemiItalic */
-00820         /*   0 */     0,    0,    0,    0,    0,    0,    0,    0,
-00821         /*   8 */     0,    0,    0,    0,    0,    0,    0,    0,
-00822         /*  16 */     0,    0,    0,    0,    0,    0,    0,    0,
-00823         /*  24 */     0,    0,    0,    0,    0,    0,    0,    0,
-00824         /*  32 */   340,  320,  380,  680,  680,  880,  980,  320,
-00825         /*  40 */   260,  260,  460,  600,  340,  280,  340,  360,
-00826         /*  48 */   680,  680,  680,  680,  680,  680,  680,  680,
-00827         /*  56 */   680,  680,  340,  340,  620,  600,  620,  620,
-00828         /*  64 */   780,  720,  720,  700,  760,  720,  660,  760,
-00829         /*  72 */   800,  380,  620,  780,  640,  860,  740,  760,
-00830         /*  80 */   640,  760,  740,  700,  700,  740,  660, 1000,
-00831         /*  88 */   740,  660,  680,  260,  580,  260,  620,  500,
-00832         /*  96 */   320,  680,  600,  560,  680,  560,  420,  620,
-00833         /* 104 */   700,  380,  320,  700,  380,  960,  680,  600,
-00834         /* 112 */   660,  620,  500,  540,  440,  680,  540,  860,
-00835         /* 120 */   620,  600,  560,  300,  620,  300,  620,    0,
-00836         /* 128 */     0,    0,    0,    0,    0,    0,    0,    0,
-00837         /* 136 */     0,    0,    0,    0, 1000,  940, 1360,  360,
-00838         /* 144 */   320,  320,  220,  220,  520,  520,  520,  500,
-00839         /* 152 */  1000,  600, 1180,  920,  420,  420,  820,  820,
-00840         /* 160 */   340,  320,  680,  680,  680,  680,  620,  620,
-00841         /* 168 */   520,  780,  440,  380,  620,  280,  780,  480,
-00842         /* 176 */   400,  600,  408,  408,  340,  680,  680,  340,
-00843         /* 184 */   360,  408,  440,  380, 1020, 1020, 1020,  620,
-00844         /* 192 */   720,  720,  720,  720,  720,  720, 1140,  700,
-00845         /* 200 */   720,  720,  720,  720,  380,  380,  380,  380,
-00846         /* 208 */   760,  740,  760,  760,  760,  760,  760,  600,
-00847         /* 216 */   760,  740,  740,  740,  740,  660,  640,  660,
-00848         /* 224 */   680,  680,  680,  680,  680,  680,  880,  560,
-00849         /* 232 */   560,  560,  560,  560,  380,  380,  380,  380,
-00850         /* 240 */   600,  680,  600,  600,  600,  600,  600,  600,
-00851         /* 248 */   600,  680,  680,  680,  680,  600,  660,  600,
-00852         },
-00853         {       /* AvantGarde-Book */
-00854         /*   0 */     0,    0,    0,    0,    0,    0,    0,    0,
-00855         /*   8 */     0,    0,    0,    0,    0,    0,    0,    0,
-00856         /*  16 */     0,    0,    0,    0,    0,    0,    0,    0,
-00857         /*  24 */     0,    0,    0,    0,    0,    0,    0,    0,
-00858         /*  32 */   277,  295,  309,  554,  554,  775,  757,  351,
-00859         /*  40 */   369,  369,  425,  606,  277,  332,  277,  437,
-00860         /*  48 */   554,  554,  554,  554,  554,  554,  554,  554,
-00861         /*  56 */   554,  554,  277,  277,  606,  606,  606,  591,
-00862         /*  64 */   867,  740,  574,  813,  744,  536,  485,  872,
-00863         /*  72 */   683,  226,  482,  591,  462,  919,  740,  869,
-00864         /*  80 */   592,  871,  607,  498,  426,  655,  702,  960,
-00865         /*  88 */   609,  592,  480,  351,  605,  351,  606,  500,
-00866         /*  96 */   351,  683,  682,  647,  685,  650,  314,  673,
-00867         /* 104 */   610,  200,  203,  502,  200,  938,  610,  655,
-00868         /* 112 */   682,  682,  301,  388,  339,  608,  554,  831,
-00869         /* 120 */   480,  536,  425,  351,  672,  351,  606,    0,
-00870         /* 128 */     0,    0,    0,    0,    0,    0,    0,    0,
-00871         /* 136 */     0,    0,    0,    0, 1000, 1000, 1174,  606,
-00872         /* 144 */   351,  351,  251,  251,  502,  484,  502,  500,
-00873         /* 152 */  1000,  606, 1194, 1137,  553,  553,  487,  485,
-00874         /* 160 */   277,  295,  554,  554,  554,  554,  672,  615,
-00875         /* 168 */   369,  747,  369,  425,  606,  332,  747,  485,
-00876         /* 176 */   400,  606,  332,  332,  375,  608,  564,  277,
-00877         /* 184 */   324,  332,  369,  425,  831,  831,  831,  591,
-00878         /* 192 */   740,  740,  740,  740,  740,  740,  992,  813,
-00879         /* 200 */   536,  536,  536,  536,  226,  226,  226,  226,
-00880         /* 208 */   790,  740,  869,  869,  869,  869,  869,  606,
-00881         /* 216 */   868,  655,  655,  655,  655,  592,  592,  554,
-00882         /* 224 */   683,  683,  683,  683,  683,  683, 1157,  647,
-00883         /* 232 */   650,  650,  650,  650,  200,  200,  200,  200,
-00884         /* 240 */   655,  610,  655,  655,  655,  655,  655,  606,
-00885         /* 248 */   653,  608,  608,  608,  608,  536,  682,  536,
-00886         },
-00887         {       /* AvantGarde-Demi */
-00888         /*   0 */     0,    0,    0,    0,    0,    0,    0,    0,
-00889         /*   8 */     0,    0,    0,    0,    0,    0,    0,    0,
-00890         /*  16 */     0,    0,    0,    0,    0,    0,    0,    0,
-00891         /*  24 */     0,    0,    0,    0,    0,    0,    0,    0,
-00892         /*  32 */   280,  280,  360,  560,  560,  860,  680,  280,
-00893         /*  40 */   380,  380,  440,  600,  280,  420,  280,  460,
-00894         /*  48 */   560,  560,  560,  560,  560,  560,  560,  560,
-00895         /*  56 */   560,  560,  280,  280,  600,  600,  600,  560,
-00896         /*  64 */   740,  740,  580,  780,  700,  520,  480,  840,
-00897         /*  72 */   680,  280,  480,  620,  440,  900,  740,  840,
-00898         /*  80 */   560,  840,  580,  520,  420,  640,  700,  900,
-00899         /*  88 */   680,  620,  500,  320,  640,  320,  600,  500,
-00900         /*  96 */   280,  660,  660,  640,  660,  640,  280,  660,
-00901         /* 104 */   600,  240,  260,  580,  240,  940,  600,  640,
-00902         /* 112 */   660,  660,  320,  440,  300,  600,  560,  800,
-00903         /* 120 */   560,  580,  460,  340,  600,  340,  600,    0,
-00904         /* 128 */     0,    0,    0,    0,    0,    0,    0,    0,
-00905         /* 136 */     0,    0,    0,    0, 1000, 1000, 1280,  600,
-00906         /* 144 */   280,  280,  240,  240,  480,  480,  480,  500,
-00907         /* 152 */  1000,  600, 1060, 1080,  560,  560,  520,  520,
-00908         /* 160 */   280,  280,  560,  560,  560,  560,  600,  560,
-00909         /* 168 */   500,  740,  360,  460,  600,  420,  740,  420,
-00910         /* 176 */   400,  600,  336,  336,  420,  576,  600,  280,
-00911         /* 184 */   340,  336,  360,  460,  840,  840,  840,  560,
-00912         /* 192 */   740,  740,  740,  740,  740,  740,  900,  780,
-00913         /* 200 */   520,  520,  520,  520,  280,  280,  280,  280,
-00914         /* 208 */   742,  740,  840,  840,  840,  840,  840,  600,
-00915         /* 216 */   840,  640,  640,  640,  640,  620,  560,  600,
-00916         /* 224 */   660,  660,  660,  660,  660,  660, 1080,  640,
-00917         /* 232 */   640,  640,  640,  640,  240,  240,  240,  240,
-00918         /* 240 */   640,  600,  640,  640,  640,  640,  640,  600,
-00919         /* 248 */   660,  600,  600,  600,  600,  580,  660,  580,
-00920         },
-00921         {       /* AvantGarde-BookOblique */
-00922         /*   0 */     0,    0,    0,    0,    0,    0,    0,    0,
-00923         /*   8 */     0,    0,    0,    0,    0,    0,    0,    0,
-00924         /*  16 */     0,    0,    0,    0,    0,    0,    0,    0,
-00925         /*  24 */     0,    0,    0,    0,    0,    0,    0,    0,
-00926         /*  32 */   277,  295,  309,  554,  554,  775,  757,  351,
-00927         /*  40 */   369,  369,  425,  606,  277,  332,  277,  437,
-00928         /*  48 */   554,  554,  554,  554,  554,  554,  554,  554,
-00929         /*  56 */   554,  554,  277,  277,  606,  606,  606,  591,
-00930         /*  64 */   867,  740,  574,  813,  744,  536,  485,  872,
-00931         /*  72 */   683,  226,  482,  591,  462,  919,  740,  869,
-00932         /*  80 */   592,  871,  607,  498,  426,  655,  702,  960,
-00933         /*  88 */   609,  592,  480,  351,  605,  351,  606,  500,
-00934         /*  96 */   351,  683,  682,  647,  685,  650,  314,  673,
-00935         /* 104 */   610,  200,  203,  502,  200,  938,  610,  655,
-00936         /* 112 */   682,  682,  301,  388,  339,  608,  554,  831,
-00937         /* 120 */   480,  536,  425,  351,  672,  351,  606,    0,
-00938         /* 128 */     0,    0,    0,    0,    0,    0,    0,    0,
-00939         /* 136 */     0,    0,    0,    0, 1000, 1000, 1174,  606,
-00940         /* 144 */   351,  351,  251,  251,  502,  484,  502,  500,
-00941         /* 152 */  1000,  606, 1194, 1137,  553,  553,  487,  485,
-00942         /* 160 */   277,  295,  554,  554,  554,  554,  672,  615,
-00943         /* 168 */   369,  747,  369,  425,  606,  332,  747,  485,
-00944         /* 176 */   400,  606,  332,  332,  375,  608,  564,  277,
-00945         /* 184 */   324,  332,  369,  425,  831,  831,  831,  591,
-00946         /* 192 */   740,  740,  740,  740,  740,  740,  992,  813,
-00947         /* 200 */   536,  536,  536,  536,  226,  226,  226,  226,
-00948         /* 208 */   790,  740,  869,  869,  869,  869,  869,  606,
-00949         /* 216 */   868,  655,  655,  655,  655,  592,  592,  554,
-00950         /* 224 */   683,  683,  683,  683,  683,  683, 1157,  647,
-00951         /* 232 */   650,  650,  650,  650,  200,  200,  200,  200,
-00952         /* 240 */   655,  610,  655,  655,  655,  655,  655,  606,
-00953         /* 248 */   653,  608,  608,  608,  608,  536,  682,  536,
-00954         },
-00955         {       /* AvantGarde-DemiOblique */
-00956         /*   0 */     0,    0,    0,    0,    0,    0,    0,    0,
-00957         /*   8 */     0,    0,    0,    0,    0,    0,    0,    0,
-00958         /*  16 */     0,    0,    0,    0,    0,    0,    0,    0,
-00959         /*  24 */     0,    0,    0,    0,    0,    0,    0,    0,
-00960         /*  32 */   280,  280,  360,  560,  560,  860,  680,  280,
-00961         /*  40 */   380,  380,  440,  600,  280,  420,  280,  460,
-00962         /*  48 */   560,  560,  560,  560,  560,  560,  560,  560,
-00963         /*  56 */   560,  560,  280,  280,  600,  600,  600,  560,
-00964         /*  64 */   740,  740,  580,  780,  700,  520,  480,  840,
-00965         /*  72 */   680,  280,  480,  620,  440,  900,  740,  840,
-00966         /*  80 */   560,  840,  580,  520,  420,  640,  700,  900,
-00967         /*  88 */   680,  620,  500,  320,  640,  320,  600,  500,
-00968         /*  96 */   280,  660,  660,  640,  660,  640,  280,  660,
-00969         /* 104 */   600,  240,  260,  580,  240,  940,  600,  640,
-00970         /* 112 */   660,  660,  320,  440,  300,  600,  560,  800,
-00971         /* 120 */   560,  580,  460,  340,  600,  340,  600,    0,
-00972         /* 128 */     0,    0,    0,    0,    0,    0,    0,    0,
-00973         /* 136 */     0,    0,    0,    0, 1000, 1000, 1280,  600,
-00974         /* 144 */   280,  280,  240,  240,  480,  480,  480,  500,
-00975         /* 152 */  1000,  600, 1060, 1080,  560,  560,  520,  520,
-00976         /* 160 */   280,  280,  560,  560,  560,  560,  600,  560,
-00977         /* 168 */   500,  740,  360,  460,  600,  420,  740,  420,
-00978         /* 176 */   400,  600,  336,  336,  420,  576,  600,  280,
-00979         /* 184 */   340,  336,  360,  460,  840,  840,  840,  560,
-00980         /* 192 */   740,  740,  740,  740,  740,  740,  900,  780,
-00981         /* 200 */   520,  520,  520,  520,  280,  280,  280,  280,
-00982         /* 208 */   742,  740,  840,  840,  840,  840,  840,  600,
-00983         /* 216 */   840,  640,  640,  640,  640,  620,  560,  600,
-00984         /* 224 */   660,  660,  660,  660,  660,  660, 1080,  640,
-00985         /* 232 */   640,  640,  640,  640,  240,  240,  240,  240,
-00986         /* 240 */   640,  600,  640,  640,  640,  640,  640,  600,
-00987         /* 248 */   660,  600,  600,  600,  600,  580,  660,  580,
-00988         },
-00989         {       /* NewCenturySchlbk-Roman */
-00990         /*   0 */     0,    0,    0,    0,    0,    0,    0,    0,
-00991         /*   8 */     0,    0,    0,    0,    0,    0,    0,    0,
-00992         /*  16 */     0,    0,    0,    0,    0,    0,    0,    0,
-00993         /*  24 */     0,    0,    0,    0,    0,    0,    0,    0,
-00994         /*  32 */   278,  296,  389,  556,  556,  833,  815,  204,
-00995         /*  40 */   333,  333,  500,  606,  278,  333,  278,  278,
-00996         /*  48 */   556,  556,  556,  556,  556,  556,  556,  556,
-00997         /*  56 */   556,  556,  278,  278,  606,  606,  606,  444,
-00998         /*  64 */   737,  722,  722,  722,  778,  722,  667,  778,
-00999         /*  72 */   833,  407,  556,  778,  667,  944,  815,  778,
-01000         /*  80 */   667,  778,  722,  630,  667,  815,  722,  981,
-01001         /*  88 */   704,  704,  611,  333,  606,  333,  606,  500,
-01002         /*  96 */   204,  556,  556,  444,  574,  500,  333,  537,
-01003         /* 104 */   611,  315,  296,  593,  315,  889,  611,  500,
-01004         /* 112 */   574,  556,  444,  463,  389,  611,  537,  778,
-01005         /* 120 */   537,  537,  481,  333,  606,  333,  606,    0,
-01006         /* 128 */     0,    0,    0,    0,    0,    0,    0,    0,
-01007         /* 136 */     0,    0,    0,    0, 1000, 1000, 1000,  606,
-01008         /* 144 */   204,  204,  259,  259,  389,  389,  389,  556,
-01009         /* 152 */  1000,  606, 1000,  833,  500,  500,  611,  611,
-01010         /* 160 */   278,  296,  556,  556,  556,  556,  606,  500,
-01011         /* 168 */   333,  737,  334,  426,  606,  333,  737,  333,
-01012         /* 176 */   400,  606,  333,  333,  333,  611,  606,  278,
-01013         /* 184 */   333,  333,  300,  426,  834,  834,  834,  444,
-01014         /* 192 */   722,  722,  722,  722,  722,  722, 1000,  722,
-01015         /* 200 */   722,  722,  722,  722,  407,  407,  407,  407,
-01016         /* 208 */   778,  815,  778,  778,  778,  778,  778,  606,
-01017         /* 216 */   778,  815,  815,  815,  815,  704,  667,  574,
-01018         /* 224 */   556,  556,  556,  556,  556,  556,  796,  444,
-01019         /* 232 */   500,  500,  500,  500,  315,  315,  315,  315,
-01020         /* 240 */   500,  611,  500,  500,  500,  500,  500,  606,
-01021         /* 248 */   500,  611,  611,  611,  611,  537,  574,  537,
-01022         },
-01023         {       /* NewCenturySchlbk-Bold */
-01024         /*   0 */     0,    0,    0,    0,    0,    0,    0,    0,
-01025         /*   8 */     0,    0,    0,    0,    0,    0,    0,    0,
-01026         /*  16 */     0,    0,    0,    0,    0,    0,    0,    0,
-01027         /*  24 */     0,    0,    0,    0,    0,    0,    0,    0,
-01028         /*  32 */   287,  296,  333,  574,  574,  833,  852,  241,
-01029         /*  40 */   389,  389,  500,  606,  278,  333,  278,  278,
-01030         /*  48 */   574,  574,  574,  574,  574,  574,  574,  574,
-01031         /*  56 */   574,  574,  278,  278,  606,  606,  606,  500,
-01032         /*  64 */   747,  759,  778,  778,  833,  759,  722,  833,
-01033         /*  72 */   870,  444,  648,  815,  722,  981,  833,  833,
-01034         /*  80 */   759,  833,  815,  667,  722,  833,  759,  981,
-01035         /*  88 */   722,  722,  667,  389,  606,  389,  606,  500,
-01036         /*  96 */   241,  611,  648,  556,  667,  574,  389,  611,
-01037         /* 104 */   685,  370,  352,  667,  352,  963,  685,  611,
-01038         /* 112 */   667,  648,  519,  500,  426,  685,  611,  889,
-01039         /* 120 */   611,  611,  537,  389,  606,  389,  606,    0,
-01040         /* 128 */     0,    0,    0,    0,    0,    0,    0,    0,
-01041         /* 136 */     0,    0,    0,    0, 1000, 1000, 1000,  606,
-01042         /* 144 */   241,  241,  333,  333,  481,  481,  481,  500,
-01043         /* 152 */  1000,  606, 1000,  907,  500,  500,  685,  685,
-01044         /* 160 */   287,  296,  574,  574,  574,  574,  606,  500,
-01045         /* 168 */   333,  747,  367,  500,  606,  333,  747,  333,
-01046         /* 176 */   400,  606,  344,  344,  333,  685,  747,  278,
-01047         /* 184 */   333,  344,  367,  500,  861,  861,  861,  500,
-01048         /* 192 */   759,  759,  759,  759,  759,  759,  981,  778,
-01049         /* 200 */   759,  759,  759,  759,  444,  444,  444,  444,
-01050         /* 208 */   833,  833,  833,  833,  833,  833,  833,  606,
-01051         /* 216 */   833,  833,  833,  833,  833,  722,  759,  611,
-01052         /* 224 */   611,  611,  611,  611,  611,  611,  870,  556,
-01053         /* 232 */   574,  574,  574,  574,  370,  370,  370,  370,
-01054         /* 240 */   611,  685,  611,  611,  611,  611,  611,  606,
-01055         /* 248 */   611,  685,  685,  685,  685,  611,  667,  611,
-01056         },
-01057         {       /* NewCenturySchlbk-Italic */
-01058         /*   0 */     0,    0,    0,    0,    0,    0,    0,    0,
-01059         /*   8 */     0,    0,    0,    0,    0,    0,    0,    0,
-01060         /*  16 */     0,    0,    0,    0,    0,    0,    0,    0,
-01061         /*  24 */     0,    0,    0,    0,    0,    0,    0,    0,
-01062         /*  32 */   278,  333,  400,  556,  556,  833,  852,  204,
-01063         /*  40 */   333,  333,  500,  606,  278,  333,  278,  606,
-01064         /*  48 */   556,  556,  556,  556,  556,  556,  556,  556,
-01065         /*  56 */   556,  556,  278,  278,  606,  606,  606,  444,
-01066         /*  64 */   747,  704,  722,  722,  778,  722,  667,  778,
-01067         /*  72 */   833,  407,  611,  741,  667,  944,  815,  778,
-01068         /*  80 */   667,  778,  741,  667,  685,  815,  704,  926,
-01069         /*  88 */   704,  685,  667,  333,  606,  333,  606,  500,
-01070         /*  96 */   204,  574,  556,  444,  611,  444,  333,  537,
-01071         /* 104 */   611,  333,  315,  556,  333,  889,  611,  500,
-01072         /* 112 */   574,  556,  444,  444,  352,  611,  519,  778,
-01073         /* 120 */   500,  500,  463,  333,  606,  333,  606,    0,
-01074         /* 128 */     0,    0,    0,    0,    0,    0,    0,    0,
-01075         /* 136 */     0,    0,    0,    0, 1000,  950, 1000,  606,
-01076         /* 144 */   204,  204,  333,  333,  389,  389,  389,  500,
-01077         /* 152 */  1000,  606,  981,  778,  500,  500,  611,  611,
-01078         /* 160 */   278,  333,  556,  556,  556,  556,  606,  500,
-01079         /* 168 */   333,  747,  422,  426,  606,  333,  747,  333,
-01080         /* 176 */   400,  606,  333,  333,  333,  611,  650,  278,
-01081         /* 184 */   333,  333,  372,  426,  834,  834,  834,  444,
-01082         /* 192 */   704,  704,  704,  704,  704,  704,  870,  722,
-01083         /* 200 */   722,  722,  722,  722,  407,  407,  407,  407,
-01084         /* 208 */   778,  815,  778,  778,  778,  778,  778,  606,
-01085         /* 216 */   778,  815,  815,  815,  815,  685,  667,  556,
-01086         /* 224 */   574,  574,  574,  574,  574,  574,  722,  444,
-01087         /* 232 */   444,  444,  444,  444,  333,  333,  333,  333,
-01088         /* 240 */   500,  611,  500,  500,  500,  500,  500,  606,
-01089         /* 248 */   500,  611,  611,  611,  611,  500,  574,  500,
-01090         },
-01091         {       /* NewCenturySchlbk-BoldItalic */
-01092         /*   0 */     0,    0,    0,    0,    0,    0,    0,    0,
-01093         /*   8 */     0,    0,    0,    0,    0,    0,    0,    0,
-01094         /*  16 */     0,    0,    0,    0,    0,    0,    0,    0,
-01095         /*  24 */     0,    0,    0,    0,    0,    0,    0,    0,
-01096         /*  32 */   287,  333,  400,  574,  574,  889,  889,  259,
-01097         /*  40 */   407,  407,  500,  606,  287,  333,  287,  278,
-01098         /*  48 */   574,  574,  574,  574,  574,  574,  574,  574,
-01099         /*  56 */   574,  574,  287,  287,  606,  606,  606,  481,
-01100         /*  64 */   747,  741,  759,  759,  833,  741,  704,  815,
-01101         /*  72 */   870,  444,  667,  778,  704,  944,  852,  833,
-01102         /*  80 */   741,  833,  796,  685,  722,  833,  741,  944,
-01103         /*  88 */   741,  704,  704,  407,  606,  407,  606,  500,
-01104         /*  96 */   259,  667,  611,  537,  667,  519,  389,  611,
-01105         /* 104 */   685,  389,  370,  648,  389,  944,  685,  574,
-01106         /* 112 */   648,  630,  519,  481,  407,  685,  556,  833,
-01107         /* 120 */   574,  519,  519,  407,  606,  407,  606,    0,
-01108         /* 128 */     0,    0,    0,    0,    0,    0,    0,    0,
-01109         /* 136 */     0,    0,    0,    0, 1000,  950, 1167,  606,
-01110         /* 144 */   259,  259,  278,  278,  481,  481,  481,  500,
-01111         /* 152 */  1000,  606,  963,  852,  500,  500,  685,  685,
-01112         /* 160 */   287,  333,  574,  574,  574,  574,  606,  500,
-01113         /* 168 */   333,  747,  412,  481,  606,  333,  747,  333,
-01114         /* 176 */   400,  606,  344,  344,  333,  685,  650,  287,
-01115         /* 184 */   333,  344,  356,  481,  861,  861,  861,  481,
-01116         /* 192 */   741,  741,  741,  741,  741,  741,  889,  759,
-01117         /* 200 */   741,  741,  741,  741,  444,  444,  444,  444,
-01118         /* 208 */   833,  852,  833,  833,  833,  833,  833,  606,
-01119         /* 216 */   833,  833,  833,  833,  833,  704,  741,  574,
-01120         /* 224 */   667,  667,  667,  667,  667,  667,  815,  537,
-01121         /* 232 */   519,  519,  519,  519,  389,  389,  389,  389,
-01122         /* 240 */   574,  685,  574,  574,  574,  574,  574,  606,
-01123         /* 248 */   574,  685,  685,  685,  685,  519,  648,  519,
-01124         },
-01125 };
-01126 static unsigned short ausCharacterWidths2[32][256] = {
-01127         {       /* Courier */
-01128         /*   0 */     0,    0,    0,    0,    0,    0,    0,    0,
-01129         /*   8 */     0,    0,    0,    0,    0,    0,    0,    0,
-01130         /*  16 */     0,    0,    0,    0,    0,    0,    0,    0,
-01131         /*  24 */     0,    0,    0,    0,    0,    0,    0,    0,
-01132         /*  32 */   600,  600,  600,  600,  600,  600,  600,  600,
-01133         /*  40 */   600,  600,  600,  600,  600,  600,  600,  600,
-01134         /*  48 */   600,  600,  600,  600,  600,  600,  600,  600,
-01135         /*  56 */   600,  600,  600,  600,  600,  600,  600,  600,
-01136         /*  64 */   600,  600,  600,  600,  600,  600,  600,  600,
-01137         /*  72 */   600,  600,  600,  600,  600,  600,  600,  600,
-01138         /*  80 */   600,  600,  600,  600,  600,  600,  600,  600,
-01139         /*  88 */   600,  600,  600,  600,  600,  600,  600,  600,
-01140         /*  96 */   600,  600,  600,  600,  600,  600,  600,  600,
-01141         /* 104 */   600,  600,  600,  600,  600,  600,  600,  600,
-01142         /* 112 */   600,  600,  600,  600,  600,  600,  600,  600,
-01143         /* 120 */   600,  600,  600,  600,  600,  600,  600,    0,
-01144         /* 128 */     0,    0,    0,    0,    0,    0,    0,    0,
-01145         /* 136 */     0,    0,    0,    0,    0,    0,    0,    0,
-01146         /* 144 */     0,    0,    0,    0,    0,    0,    0,    0,
-01147         /* 152 */     0,    0,    0,    0,    0,    0,    0,    0,
-01148         /* 160 */   600,  600,  600,  600,  600,  600,  600,  600,
-01149         /* 168 */   600,  600,  600,  600,  600,  600,  600,  600,
-01150         /* 176 */   600,  600,  600,  600,  600,  600,  600,  600,
-01151         /* 184 */   600,  600,  600,  600,  600,  600,  600,  600,
-01152         /* 192 */   600,  600,  600,  600,  600,  600,  600,  600,
-01153         /* 200 */   600,  600,  600,  600,  600,  600,  600,  600,
-01154         /* 208 */   600,  600,  600,  600,  600,  600,  600,  600,
-01155         /* 216 */   600,  600,  600,  600,  600,  600,  600,  600,
-01156         /* 224 */   600,  600,  600,  600,  600,  600,  600,  600,
-01157         /* 232 */   600,  600,  600,  600,  600,  600,  600,  600,
-01158         /* 240 */   600,  600,  600,  600,  600,  600,  600,  600,
-01159         /* 248 */   600,  600,  600,  600,  600,  600,  600,  600,
-01160         },
-01161         {       /* Courier-Bold */
-01162         /*   0 */     0,    0,    0,    0,    0,    0,    0,    0,
-01163         /*   8 */     0,    0,    0,    0,    0,    0,    0,    0,
-01164         /*  16 */     0,    0,    0,    0,    0,    0,    0,    0,
-01165         /*  24 */     0,    0,    0,    0,    0,    0,    0,    0,
-01166         /*  32 */   600,  600,  600,  600,  600,  600,  600,  600,
-01167         /*  40 */   600,  600,  600,  600,  600,  600,  600,  600,
-01168         /*  48 */   600,  600,  600,  600,  600,  600,  600,  600,
-01169         /*  56 */   600,  600,  600,  600,  600,  600,  600,  600,
-01170         /*  64 */   600,  600,  600,  600,  600,  600,  600,  600,
-01171         /*  72 */   600,  600,  600,  600,  600,  600,  600,  600,
-01172         /*  80 */   600,  600,  600,  600,  600,  600,  600,  600,
-01173         /*  88 */   600,  600,  600,  600,  600,  600,  600,  600,
-01174         /*  96 */   600,  600,  600,  600,  600,  600,  600,  600,
-01175         /* 104 */   600,  600,  600,  600,  600,  600,  600,  600,
-01176         /* 112 */   600,  600,  600,  600,  600,  600,  600,  600,
-01177         /* 120 */   600,  600,  600,  600,  600,  600,  600,    0,
-01178         /* 128 */     0,    0,    0,    0,    0,    0,    0,    0,
-01179         /* 136 */     0,    0,    0,    0,    0,    0,    0,    0,
-01180         /* 144 */     0,    0,    0,    0,    0,    0,    0,    0,
-01181         /* 152 */     0,    0,    0,    0,    0,    0,    0,    0,
-01182         /* 160 */   600,  600,  600,  600,  600,  600,  600,  600,
-01183         /* 168 */   600,  600,  600,  600,  600,  600,  600,  600,
-01184         /* 176 */   600,  600,  600,  600,  600,  600,  600,  600,
-01185         /* 184 */   600,  600,  600,  600,  600,  600,  600,  600,
-01186         /* 192 */   600,  600,  600,  600,  600,  600,  600,  600,
-01187         /* 200 */   600,  600,  600,  600,  600,  600,  600,  600,
-01188         /* 208 */   600,  600,  600,  600,  600,  600,  600,  600,
-01189         /* 216 */   600,  600,  600,  600,  600,  600,  600,  600,
-01190         /* 224 */   600,  600,  600,  600,  600,  600,  600,  600,
-01191         /* 232 */   600,  600,  600,  600,  600,  600,  600,  600,
-01192         /* 240 */   600,  600,  600,  600,  600,  600,  600,  600,
-01193         /* 248 */   600,  600,  600,  600,  600,  600,  600,  600,
-01194         },
-01195         {       /* Courier-Oblique */
-01196         /*   0 */     0,    0,    0,    0,    0,    0,    0,    0,
-01197         /*   8 */     0,    0,    0,    0,    0,    0,    0,    0,
-01198         /*  16 */     0,    0,    0,    0,    0,    0,    0,    0,
-01199         /*  24 */     0,    0,    0,    0,    0,    0,    0,    0,
-01200         /*  32 */   600,  600,  600,  600,  600,  600,  600,  600,
-01201         /*  40 */   600,  600,  600,  600,  600,  600,  600,  600,
-01202         /*  48 */   600,  600,  600,  600,  600,  600,  600,  600,
-01203         /*  56 */   600,  600,  600,  600,  600,  600,  600,  600,
-01204         /*  64 */   600,  600,  600,  600,  600,  600,  600,  600,
-01205         /*  72 */   600,  600,  600,  600,  600,  600,  600,  600,
-01206         /*  80 */   600,  600,  600,  600,  600,  600,  600,  600,
-01207         /*  88 */   600,  600,  600,  600,  600,  600,  600,  600,
-01208         /*  96 */   600,  600,  600,  600,  600,  600,  600,  600,
-01209         /* 104 */   600,  600,  600,  600,  600,  600,  600,  600,
-01210         /* 112 */   600,  600,  600,  600,  600,  600,  600,  600,
-01211         /* 120 */   600,  600,  600,  600,  600,  600,  600,    0,
-01212         /* 128 */     0,    0,    0,    0,    0,    0,    0,    0,
-01213         /* 136 */     0,    0,    0,    0,    0,    0,    0,    0,
-01214         /* 144 */     0,    0,    0,    0,    0,    0,    0,    0,
-01215         /* 152 */     0,    0,    0,    0,    0,    0,    0,    0,
-01216         /* 160 */   600,  600,  600,  600,  600,  600,  600,  600,
-01217         /* 168 */   600,  600,  600,  600,  600,  600,  600,  600,
-01218         /* 176 */   600,  600,  600,  600,  600,  600,  600,  600,
-01219         /* 184 */   600,  600,  600,  600,  600,  600,  600,  600,
-01220         /* 192 */   600,  600,  600,  600,  600,  600,  600,  600,
-01221         /* 200 */   600,  600,  600,  600,  600,  600,  600,  600,
-01222         /* 208 */   600,  600,  600,  600,  600,  600,  600,  600,
-01223         /* 216 */   600,  600,  600,  600,  600,  600,  600,  600,
-01224         /* 224 */   600,  600,  600,  600,  600,  600,  600,  600,
-01225         /* 232 */   600,  600,  600,  600,  600,  600,  600,  600,
-01226         /* 240 */   600,  600,  600,  600,  600,  600,  600,  600,
-01227         /* 248 */   600,  600,  600,  600,  600,  600,  600,  600,
-01228         },
-01229         {       /* Courier-BoldOblique */
-01230         /*   0 */     0,    0,    0,    0,    0,    0,    0,    0,
-01231         /*   8 */     0,    0,    0,    0,    0,    0,    0,    0,
-01232         /*  16 */     0,    0,    0,    0,    0,    0,    0,    0,
-01233         /*  24 */     0,    0,    0,    0,    0,    0,    0,    0,
-01234         /*  32 */   600,  600,  600,  600,  600,  600,  600,  600,
-01235         /*  40 */   600,  600,  600,  600,  600,  600,  600,  600,
-01236         /*  48 */   600,  600,  600,  600,  600,  600,  600,  600,
-01237         /*  56 */   600,  600,  600,  600,  600,  600,  600,  600,
-01238         /*  64 */   600,  600,  600,  600,  600,  600,  600,  600,
-01239         /*  72 */   600,  600,  600,  600,  600,  600,  600,  600,
-01240         /*  80 */   600,  600,  600,  600,  600,  600,  600,  600,
-01241         /*  88 */   600,  600,  600,  600,  600,  600,  600,  600,
-01242         /*  96 */   600,  600,  600,  600,  600,  600,  600,  600,
-01243         /* 104 */   600,  600,  600,  600,  600,  600,  600,  600,
-01244         /* 112 */   600,  600,  600,  600,  600,  600,  600,  600,
-01245         /* 120 */   600,  600,  600,  600,  600,  600,  600,    0,
-01246         /* 128 */     0,    0,    0,    0,    0,    0,    0,    0,
-01247         /* 136 */     0,    0,    0,    0,    0,    0,    0,    0,
-01248         /* 144 */     0,    0,    0,    0,    0,    0,    0,    0,
-01249         /* 152 */     0,    0,    0,    0,    0,    0,    0,    0,
-01250         /* 160 */   600,  600,  600,  600,  600,  600,  600,  600,
-01251         /* 168 */   600,  600,  600,  600,  600,  600,  600,  600,
-01252         /* 176 */   600,  600,  600,  600,  600,  600,  600,  600,
-01253         /* 184 */   600,  600,  600,  600,  600,  600,  600,  600,
-01254         /* 192 */   600,  600,  600,  600,  600,  600,  600,  600,
-01255         /* 200 */   600,  600,  600,  600,  600,  600,  600,  600,
-01256         /* 208 */   600,  600,  600,  600,  600,  600,  600,  600,
-01257         /* 216 */   600,  600,  600,  600,  600,  600,  600,  600,
-01258         /* 224 */   600,  600,  600,  600,  600,  600,  600,  600,
-01259         /* 232 */   600,  600,  600,  600,  600,  600,  600,  740,
-01260         /* 240 */   600,  600,  600,  600,  600,  600,  600,  600,
-01261         /* 248 */   600,  600,  600,  600,  600,  600,  600,  600,
-01262         },
-01263         {       /* Times-Roman */
-01264         /*   0 */     0,    0,    0,    0,    0,    0,    0,    0,
-01265         /*   8 */     0,    0,    0,    0,    0,    0,    0,    0,
-01266         /*  16 */     0,    0,    0,    0,    0,    0,    0,    0,
-01267         /*  24 */     0,    0,    0,    0,    0,    0,    0,    0,
-01268         /*  32 */   250,  333,  408,  500,  500,  833,  778,  180,
-01269         /*  40 */   333,  333,  500,  564,  250,  333,  250,  278,
-01270         /*  48 */   500,  500,  500,  500,  500,  500,  500,  500,
-01271         /*  56 */   500,  500,  278,  278,  564,  564,  564,  444,
-01272         /*  64 */   921,  722,  667,  667,  722,  611,  556,  722,
-01273         /*  72 */   722,  333,  389,  722,  611,  889,  722,  722,
-01274         /*  80 */   556,  722,  667,  556,  611,  722,  722,  944,
-01275         /*  88 */   722,  722,  611,  333,  278,  333,  469,  500,
-01276         /*  96 */   333,  444,  500,  444,  500,  444,  333,  500,
-01277         /* 104 */   500,  278,  278,  500,  278,  778,  500,  500,
-01278         /* 112 */   500,  500,  333,  389,  278,  500,  500,  722,
-01279         /* 120 */   500,  500,  444,  480,  200,  480,  541,    0,
-01280         /* 128 */     0,    0,    0,    0,    0,    0,    0,    0,
-01281         /* 136 */     0,    0,    0,    0,    0,    0,    0,    0,
-01282         /* 144 */     0,    0,    0,    0,    0,    0,    0,    0,
-01283         /* 152 */     0,    0,    0,    0,    0,    0,    0,    0,
-01284         /* 160 */   250,  722,  333,  611,  500,  611,  556,  500,
-01285         /* 168 */   333,  556,  556,  611,  611,  333,  611,  611,
-01286         /* 176 */   333,  444,  333,  278,  333,  348,  389,  333,
-01287         /* 184 */   333,  389,  389,  278,  444,  333,  444,  444,
-01288         /* 192 */   667,  722,  722,  722,  722,  611,  667,  667,
-01289         /* 200 */   667,  611,  611,  611,  611,  333,  333,  722,
-01290         /* 208 */   722,  722,  722,  722,  722,  722,  722,  564,
-01291         /* 216 */   667,  722,  722,  722,  722,  722,  611,  500,
-01292         /* 224 */   333,  444,  444,  444,  444,  278,  444,  444,
-01293         /* 232 */   444,  444,  444,  444,  444,  278,  278,  600,
-01294         /* 240 */   500,  500,  500,  500,  500,  500,  500,  564,
-01295         /* 248 */   333,  500,  500,  500,  500,  500,  278,  333,
-01296         },
-01297         {       /* Times-Bold */
-01298         /*   0 */     0,    0,    0,    0,    0,    0,    0,    0,
-01299         /*   8 */     0,    0,    0,    0,    0,    0,    0,    0,
-01300         /*  16 */     0,    0,    0,    0,    0,    0,    0,    0,
-01301         /*  24 */     0,    0,    0,    0,    0,    0,    0,    0,
-01302         /*  32 */   250,  333,  555,  500,  500, 1000,  833,  278,
-01303         /*  40 */   333,  333,  500,  570,  250,  333,  250,  278,
-01304         /*  48 */   500,  500,  500,  500,  500,  500,  500,  500,
-01305         /*  56 */   500,  500,  333,  333,  570,  570,  570,  500,
-01306         /*  64 */   930,  722,  667,  722,  722,  667,  611,  778,
-01307         /*  72 */   778,  389,  500,  778,  667,  944,  722,  778,
-01308         /*  80 */   611,  778,  722,  556,  667,  722,  722, 1000,
-01309         /*  88 */   722,  722,  667,  333,  278,  333,  581,  500,
-01310         /*  96 */   333,  500,  556,  444,  556,  444,  333,  500,
-01311         /* 104 */   556,  278,  333,  556,  278,  833,  556,  500,
-01312         /* 112 */   556,  556,  444,  389,  333,  556,  500,  722,
-01313         /* 120 */   500,  500,  444,  394,  220,  394,  520,    0,
-01314         /* 128 */     0,    0,    0,    0,    0,    0,    0,    0,
-01315         /* 136 */     0,    0,    0,    0,    0,    0,    0,    0,
-01316         /* 144 */     0,    0,    0,    0,    0,    0,    0,    0,
-01317         /* 152 */     0,    0,    0,    0,    0,    0,    0,    0,
-01318         /* 160 */   250,  722,  333,  667,  500,  667,  556,  500,
-01319         /* 168 */   333,  556,  556,  667,  667,  333,  667,  667,
-01320         /* 176 */   333,  500,  333,  278,  333,  396,  389,  333,
-01321         /* 184 */   333,  389,  389,  400,  444,  333,  444,  444,
-01322         /* 192 */   722,  722,  722,  722,  722,  667,  722,  722,
-01323         /* 200 */   722,  667,  667,  667,  667,  389,  389,  722,
-01324         /* 208 */   722,  722,  722,  778,  778,  778,  778,  570,
-01325         /* 216 */   722,  722,  722,  722,  722,  722,  667,  556,
-01326         /* 224 */   444,  500,  500,  500,  500,  278,  444,  444,
-01327         /* 232 */   444,  444,  444,  444,  444,  278,  278,  665,
-01328         /* 240 */   556,  556,  556,  500,  500,  500,  500,  570,
-01329         /* 248 */   444,  556,  556,  556,  556,  500,  333,  333,
-01330         },
-01331         {       /* Times-Italic */
-01332         /*   0 */     0,    0,    0,    0,    0,    0,    0,    0,
-01333         /*   8 */     0,    0,    0,    0,    0,    0,    0,    0,
-01334         /*  16 */     0,    0,    0,    0,    0,    0,    0,    0,
-01335         /*  24 */     0,    0,    0,    0,    0,    0,    0,    0,
-01336         /*  32 */   250,  333,  420,  500,  500,  833,  778,  214,
-01337         /*  40 */   333,  333,  500,  675,  250,  333,  250,  278,
-01338         /*  48 */   500,  500,  500,  500,  500,  500,  500,  500,
-01339         /*  56 */   500,  500,  333,  333,  675,  675,  675,  500,
-01340         /*  64 */   920,  611,  611,  667,  722,  611,  611,  722,
-01341         /*  72 */   722,  333,  444,  667,  556,  833,  667,  722,
-01342         /*  80 */   611,  722,  611,  500,  556,  722,  611,  833,
-01343         /*  88 */   611,  556,  556,  389,  278,  389,  422,  500,
-01344         /*  96 */   333,  500,  500,  444,  500,  444,  278,  500,
-01345         /* 104 */   500,  278,  278,  444,  278,  722,  500,  500,
-01346         /* 112 */   500,  500,  389,  389,  278,  500,  444,  667,
-01347         /* 120 */   444,  444,  389,  400,  275,  400,  541,    0,
-01348         /* 128 */     0,    0,    0,    0,    0,    0,    0,    0,
-01349         /* 136 */     0,    0,    0,    0,    0,    0,    0,    0,
-01350         /* 144 */     0,    0,    0,    0,    0,    0,    0,    0,
-01351         /* 152 */     0,    0,    0,    0,    0,    0,    0,    0,
-01352         /* 160 */   250,  611,  333,  556,  500,  556,  500,  500,
-01353         /* 168 */   333,  500,  500,  556,  556,  333,  556,  556,
-01354         /* 176 */   333,  500,  333,  278,  333,  278,  389,  333,
-01355         /* 184 */   333,  389,  389,  278,  389,  333,  389,  389,
-01356         /* 192 */   611,  611,  611,  611,  611,  556,  667,  667,
-01357         /* 200 */   667,  611,  611,  611,  611,  333,  333,  722,
-01358         /* 208 */   722,  667,  667,  722,  722,  722,  722,  675,
-01359         /* 216 */   611,  722,  722,  722,  722,  556,  556,  500,
-01360         /* 224 */   389,  500,  500,  500,  500,  278,  444,  444,
-01361         /* 232 */   444,  444,  444,  444,  444,  278,  278,  521,
-01362         /* 240 */   500,  500,  500,  500,  500,  500,  500,  675,
-01363         /* 248 */   389,  500,  500,  500,  500,  444,  278,  333,
-01364         },
-01365         {       /* Times-BoldItalic */
-01366         /*   0 */     0,    0,    0,    0,    0,    0,    0,    0,
-01367         /*   8 */     0,    0,    0,    0,    0,    0,    0,    0,
-01368         /*  16 */     0,    0,    0,    0,    0,    0,    0,    0,
-01369         /*  24 */     0,    0,    0,    0,    0,    0,    0,    0,
-01370         /*  32 */   250,  389,  555,  500,  500,  833,  778,  278,
-01371         /*  40 */   333,  333,  500,  570,  250,  333,  250,  278,
-01372         /*  48 */   500,  500,  500,  500,  500,  500,  500,  500,
-01373         /*  56 */   500,  500,  333,  333,  570,  570,  570,  500,
-01374         /*  64 */   832,  667,  667,  667,  722,  667,  667,  722,
-01375         /*  72 */   778,  389,  500,  667,  611,  889,  722,  722,
-01376         /*  80 */   611,  722,  667,  556,  611,  722,  667,  889,
-01377         /*  88 */   667,  611,  611,  333,  278,  333,  570,  500,
-01378         /*  96 */   333,  500,  500,  444,  500,  444,  333,  500,
-01379         /* 104 */   556,  278,  278,  500,  278,  778,  556,  500,
-01380         /* 112 */   500,  500,  389,  389,  278,  556,  444,  667,
-01381         /* 120 */   500,  444,  389,  348,  220,  348,  570,    0,
-01382         /* 128 */     0,    0,    0,    0,    0,    0,    0,    0,
-01383         /* 136 */     0,    0,    0,    0,    0,    0,    0,    0,
-01384         /* 144 */     0,    0,    0,    0,    0,    0,    0,    0,
-01385         /* 152 */     0,    0,    0,    0,    0,    0,    0,    0,
-01386         /* 160 */   250,  667,  333,  611,  500,  611,  556,  500,
-01387         /* 168 */   333,  556,  556,  611,  611,  333,  611,  611,
-01388         /* 176 */   333,  500,  333,  278,  333,  382,  389,  333,
-01389         /* 184 */   333,  389,  389,  345,  389,  333,  389,  389,
-01390         /* 192 */   667,  667,  667,  667,  667,  611,  667,  667,
-01391         /* 200 */   667,  667,  667,  667,  667,  389,  389,  722,
-01392         /* 208 */   722,  722,  722,  722,  722,  722,  722,  570,
-01393         /* 216 */   667,  722,  722,  722,  722,  611,  611,  500,
-01394         /* 224 */   389,  500,  500,  500,  500,  278,  444,  444,
-01395         /* 232 */   444,  444,  444,  444,  444,  278,  278,  600,
-01396         /* 240 */   500,  556,  556,  500,  500,  500,  500,  570,
-01397         /* 248 */   389,  556,  556,  556,  556,  444,  278,  333,
-01398         },
-01399         {       /* Helvetica */
-01400         /*   0 */     0,    0,    0,    0,    0,    0,    0,    0,
-01401         /*   8 */     0,    0,    0,    0,    0,    0,    0,    0,
-01402         /*  16 */     0,    0,    0,    0,    0,    0,    0,    0,
-01403         /*  24 */     0,    0,    0,    0,    0,    0,    0,    0,
-01404         /*  32 */   278,  278,  355,  556,  556,  889,  667,  191,
-01405         /*  40 */   333,  333,  389,  584,  278,  333,  278,  278,
-01406         /*  48 */   556,  556,  556,  556,  556,  556,  556,  556,
-01407         /*  56 */   556,  556,  278,  278,  584,  584,  584,  556,
-01408         /*  64 */  1015,  667,  667,  722,  722,  667,  611,  778,
-01409         /*  72 */   722,  278,  500,  667,  556,  833,  722,  778,
-01410         /*  80 */   667,  778,  722,  667,  611,  722,  667,  944,
-01411         /*  88 */   667,  667,  611,  278,  278,  278,  469,  556,
-01412         /*  96 */   333,  556,  556,  500,  556,  556,  278,  556,
-01413         /* 104 */   556,  222,  222,  500,  222,  833,  556,  556,
-01414         /* 112 */   556,  556,  333,  500,  278,  556,  500,  722,
-01415         /* 120 */   500,  500,  500,  334,  260,  334,  584,    0,
-01416         /* 128 */     0,    0,    0,    0,    0,    0,    0,    0,
-01417         /* 136 */     0,    0,    0,    0,    0,    0,    0,    0,
-01418         /* 144 */     0,    0,    0,    0,    0,    0,    0,    0,
-01419         /* 152 */     0,    0,    0,    0,    0,    0,    0,    0,
-01420         /* 160 */   278,  667,  333,  556,  556,  556,  667,  556,
-01421         /* 168 */   333,  667,  667,  611,  611,  333,  611,  611,
-01422         /* 176 */   333,  556,  333,  222,  333,  292,  500,  333,
-01423         /* 184 */   333,  500,  500,  308,  500,  333,  500,  500,
-01424         /* 192 */   722,  667,  667,  667,  667,  556,  722,  722,
-01425         /* 200 */   722,  667,  667,  667,  667,  278,  278,  722,
-01426         /* 208 */   722,  722,  722,  778,  778,  778,  778,  584,
-01427         /* 216 */   722,  722,  722,  722,  722,  666,  611,  611,
-01428         /* 224 */   333,  556,  556,  556,  556,  222,  500,  500,
-01429         /* 232 */   500,  556,  556,  556,  556,  278,  278,  635,
-01430         /* 240 */   556,  556,  556,  556,  556,  556,  556,  584,
-01431         /* 248 */   333,  556,  556,  556,  556,  500,  278,  333,
-01432         },
-01433         {       /* Helvetica-Bold */
-01434         /*   0 */     0,    0,    0,    0,    0,    0,    0,    0,
-01435         /*   8 */     0,    0,    0,    0,    0,    0,    0,    0,
-01436         /*  16 */     0,    0,    0,    0,    0,    0,    0,    0,
-01437         /*  24 */     0,    0,    0,    0,    0,    0,    0,    0,
-01438         /*  32 */   278,  333,  474,  556,  556,  889,  722,  238,
-01439         /*  40 */   333,  333,  389,  584,  278,  333,  278,  278,
-01440         /*  48 */   556,  556,  556,  556,  556,  556,  556,  556,
-01441         /*  56 */   556,  556,  333,  333,  584,  584,  584,  611,
-01442         /*  64 */   975,  722,  722,  722,  722,  667,  611,  778,
-01443         /*  72 */   722,  278,  556,  722,  611,  833,  722,  778,
-01444         /*  80 */   667,  778,  722,  667,  611,  722,  667,  944,
-01445         /*  88 */   667,  667,  611,  333,  278,  333,  584,  556,
-01446         /*  96 */   333,  556,  611,  556,  611,  556,  333,  611,
-01447         /* 104 */   611,  278,  278,  556,  278,  889,  611,  611,
-01448         /* 112 */   611,  611,  389,  556,  333,  611,  556,  778,
-01449         /* 120 */   556,  556,  500,  389,  280,  389,  584,    0,
-01450         /* 128 */     0,    0,    0,    0,    0,    0,    0,    0,
-01451         /* 136 */     0,    0,    0,    0,    0,    0,    0,    0,
-01452         /* 144 */     0,    0,    0,    0,    0,    0,    0,    0,
-01453         /* 152 */     0,    0,    0,    0,    0,    0,    0,    0,
-01454         /* 160 */   278,  722,  333,  611,  556,  611,  667,  556,
-01455         /* 168 */   333,  667,  667,  611,  611,  333,  611,  611,
-01456         /* 176 */   333,  556,  333,  278,  333,  369,  556,  333,
-01457         /* 184 */   333,  556,  556,  385,  500,  333,  500,  500,
-01458         /* 192 */   722,  722,  722,  722,  722,  611,  722,  722,
-01459         /* 200 */   722,  667,  667,  667,  667,  278,  278,  722,
-01460         /* 208 */   722,  722,  722,  778,  778,  778,  778,  584,
-01461         /* 216 */   722,  722,  722,  722,  722,  667,  611,  611,
-01462         /* 224 */   389,  556,  556,  556,  556,  278,  556,  556,
-01463         /* 232 */   556,  556,  556,  556,  556,  278,  278,  707,
-01464         /* 240 */   611,  611,  611,  611,  611,  611,  611,  584,
-01465         /* 248 */   389,  611,  611,  611,  611,  556,  333,  333,
-01466         },
-01467         {       /* Helvetica-Oblique */
-01468         /*   0 */     0,    0,    0,    0,    0,    0,    0,    0,
-01469         /*   8 */     0,    0,    0,    0,    0,    0,    0,    0,
-01470         /*  16 */     0,    0,    0,    0,    0,    0,    0,    0,
-01471         /*  24 */     0,    0,    0,    0,    0,    0,    0,    0,
-01472         /*  32 */   278,  278,  355,  556,  556,  889,  667,  191,
-01473         /*  40 */   333,  333,  389,  584,  278,  333,  278,  278,
-01474         /*  48 */   556,  556,  556,  556,  556,  556,  556,  556,
-01475         /*  56 */   556,  556,  278,  278,  584,  584,  584,  556,
-01476         /*  64 */  1015,  667,  667,  722,  722,  667,  611,  778,
-01477         /*  72 */   722,  278,  500,  667,  556,  833,  722,  778,
-01478         /*  80 */   667,  778,  722,  667,  611,  722,  667,  944,
-01479         /*  88 */   667,  667,  611,  278,  278,  278,  469,  556,
-01480         /*  96 */   333,  556,  556,  500,  556,  556,  278,  556,
-01481         /* 104 */   556,  222,  222,  500,  222,  833,  556,  556,
-01482         /* 112 */   556,  556,  333,  500,  278,  556,  500,  722,
-01483         /* 120 */   500,  500,  500,  334,  260,  334,  584,    0,
-01484         /* 128 */     0,    0,    0,    0,    0,    0,    0,    0,
-01485         /* 136 */     0,    0,    0,    0,    0,    0,    0,    0,
-01486         /* 144 */     0,    0,    0,    0,    0,    0,    0,    0,
-01487         /* 152 */     0,    0,    0,    0,    0,    0,    0,    0,
-01488         /* 160 */   278,  667,  333,  556,  556,  556,  667,  556,
-01489         /* 168 */   333,  667,  667,  611,  611,  333,  611,  611,
-01490         /* 176 */   333,  556,  333,  222,  333,  307,  500,  333,
-01491         /* 184 */   333,  500,  500,  319,  500,  333,  500,  500,
-01492         /* 192 */   722,  667,  667,  667,  667,  556,  722,  722,
-01493         /* 200 */   722,  667,  667,  667,  667,  278,  278,  722,
-01494         /* 208 */   722,  722,  722,  778,  778,  778,  778,  584,
-01495         /* 216 */   722,  722,  722,  722,  722,  667,  611,  611,
-01496         /* 224 */   333,  556,  556,  556,  556,  222,  500,  500,
-01497         /* 232 */   500,  556,  556,  556,  556,  278,  278,  650,
-01498         /* 240 */   556,  556,  556,  556,  556,  556,  556,  584,
-01499         /* 248 */   333,  556,  556,  556,  556,  500,  278,  333,
-01500         },
-01501         {       /* Helvetica-BoldOblique */
-01502         /*   0 */     0,    0,    0,    0,    0,    0,    0,    0,
-01503         /*   8 */     0,    0,    0,    0,    0,    0,    0,    0,
-01504         /*  16 */     0,    0,    0,    0,    0,    0,    0,    0,
-01505         /*  24 */     0,    0,    0,    0,    0,    0,    0,    0,
-01506         /*  32 */   278,  333,  474,  556,  556,  889,  722,  238,
-01507         /*  40 */   333,  333,  389,  584,  278,  333,  278,  278,
-01508         /*  48 */   556,  556,  556,  556,  556,  556,  556,  556,
-01509         /*  56 */   556,  556,  333,  333,  584,  584,  584,  611,
-01510         /*  64 */   975,  722,  722,  722,  722,  667,  611,  778,
-01511         /*  72 */   722,  278,  556,  722,  611,  833,  722,  778,
-01512         /*  80 */   667,  778,  722,  667,  611,  722,  667,  944,
-01513         /*  88 */   667,  667,  611,  333,  278,  333,  584,  556,
-01514         /*  96 */   333,  556,  611,  556,  611,  556,  333,  611,
-01515         /* 104 */   611,  278,  278,  556,  278,  889,  611,  611,
-01516         /* 112 */   611,  611,  389,  556,  333,  611,  556,  778,
-01517         /* 120 */   556,  556,  500,  389,  280,  389,  584,    0,
-01518         /* 128 */     0,    0,    0,    0,    0,    0,    0,    0,
-01519         /* 136 */     0,    0,    0,    0,    0,    0,    0,    0,
-01520         /* 144 */     0,    0,    0,    0,    0,    0,    0,    0,
-01521         /* 152 */     0,    0,    0,    0,    0,    0,    0,    0,
-01522         /* 160 */   278,  722,  333,  611,  556,  611,  667,  556,
-01523         /* 168 */   333,  667,  667,  611,  611,  333,  611,  611,
-01524         /* 176 */   333,  556,  333,  278,  333,  384,  556,  333,
-01525         /* 184 */   333,  556,  556,  404,  500,  333,  500,  500,
-01526         /* 192 */   722,  722,  722,  722,  722,  611,  722,  722,
-01527         /* 200 */   722,  667,  667,  667,  667,  278,  278,  722,
-01528         /* 208 */   722,  722,  722,  778,  778,  778,  778,  584,
-01529         /* 216 */   722,  722,  722,  722,  722,  667,  611,  611,
-01530         /* 224 */   389,  556,  556,  556,  556,  278,  556,  556,
-01531         /* 232 */   556,  556,  556,  556,  556,  278,  278,  722,
-01532         /* 240 */   611,  611,  611,  611,  611,  611,  611,  584,
-01533         /* 248 */   389,  611,  611,  611,  611,  556,  333,  333,
-01534         },
-01535         {       /* Palatino-Roman */
-01536         /*   0 */     0,    0,    0,    0,    0,    0,    0,    0,
-01537         /*   8 */     0,    0,    0,    0,    0,    0,    0,    0,
-01538         /*  16 */     0,    0,    0,    0,    0,    0,    0,    0,
-01539         /*  24 */     0,    0,    0,    0,    0,    0,    0,    0,
-01540         /*  32 */   250,  278,  371,  500,  500,  840,  778,  208,
-01541         /*  40 */   333,  333,  389,  606,  250,  333,  250,  606,
-01542         /*  48 */   500,  500,  500,  500,  500,  500,  500,  500,
-01543         /*  56 */   500,  500,  250,  250,  606,  606,  606,  444,
-01544         /*  64 */   747,  778,  611,  709,  774,  611,  556,  763,
-01545         /*  72 */   832,  337,  333,  726,  611,  946,  831,  786,
-01546         /*  80 */   604,  786,  668,  525,  613,  778,  722, 1000,
-01547         /*  88 */   667,  667,  667,  333,  606,  333,  606,  500,
-01548         /*  96 */   333,  500,  553,  444,  611,  479,  333,  556,
-01549         /* 104 */   582,  291,  234,  556,  291,  883,  582,  546,
-01550         /* 112 */   601,  560,  395,  424,  326,  603,  565,  834,
-01551         /* 120 */   516,  556,  500,  333,  606,  333,  606,    0,
-01552         /* 128 */     0,    0,    0,    0,    0,    0,    0,    0,
-01553         /* 136 */     0,    0,    0,    0,    0,    0,    0,    0,
-01554         /* 144 */     0,    0,    0,    0,    0,    0,    0,    0,
-01555         /* 152 */     0,    0,    0,    0,    0,    0,    0,    0,
-01556         /* 160 */   250,  778,  333,  611,  500,  611,  525,  500,
-01557         /* 168 */   333,  525,  525,  613,  667,  333,  667,  667,
-01558         /* 176 */   333,  500,  313,  291,  333,  375,  424,  333,
-01559         /* 184 */   333,  424,  424,  375,  500,  380,  500,  500,
-01560         /* 192 */   668,  778,  778,  778,  778,  611,  709,  709,
-01561         /* 200 */   709,  611,  611,  611,  611,  337,  337,  774,
-01562         /* 208 */   774,  831,  831,  786,  786,  786,  786,  606,
-01563         /* 216 */   668,  778,  778,  778,  778,  667,  613,  556,
-01564         /* 224 */   395,  500,  500,  500,  500,  291,  444,  444,
-01565         /* 232 */   444,  479,  479,  479,  479,  287,  287,  671,
-01566         /* 240 */   611,  582,  582,  546,  546,  546,  546,  606,
-01567         /* 248 */   395,  603,  603,  603,  603,  556,  326,  250,
-01568         },
-01569         {       /* Palatino-Bold */
-01570         /*   0 */     0,    0,    0,    0,    0,    0,    0,    0,
-01571         /*   8 */     0,    0,    0,    0,    0,    0,    0,    0,
-01572         /*  16 */     0,    0,    0,    0,    0,    0,    0,    0,
-01573         /*  24 */     0,    0,    0,    0,    0,    0,    0,    0,
-01574         /*  32 */   250,  278,  402,  500,  500,  889,  833,  227,
-01575         /*  40 */   333,  333,  444,  606,  250,  333,  250,  296,
-01576         /*  48 */   500,  500,  500,  500,  500,  500,  500,  500,
-01577         /*  56 */   500,  500,  250,  250,  606,  606,  606,  444,
-01578         /*  64 */   747,  778,  667,  722,  833,  611,  556,  833,
-01579         /*  72 */   833,  389,  389,  778,  611, 1000,  833,  833,
-01580         /*  80 */   611,  833,  722,  611,  667,  778,  778, 1000,
-01581         /*  88 */   667,  667,  667,  333,  606,  333,  606,  500,
-01582         /*  96 */   333,  500,  611,  444,  611,  500,  389,  556,
-01583         /* 104 */   611,  333,  333,  611,  333,  889,  611,  556,
-01584         /* 112 */   611,  611,  389,  444,  333,  611,  556,  833,
-01585         /* 120 */   500,  556,  500,  310,  606,  310,  606,    0,
-01586         /* 128 */     0,    0,    0,    0,    0,    0,    0,    0,
-01587         /* 136 */     0,    0,    0,    0,    0,    0,    0,    0,
-01588         /* 144 */     0,    0,    0,    0,    0,    0,    0,    0,
-01589         /* 152 */     0,    0,    0,    0,    0,    0,    0,    0,
-01590         /* 160 */   250,  778,  333,  611,  500,  611,  611,  500,
-01591         /* 168 */   333,  611,  611,  667,  667,  333,  667,  667,
-01592         /* 176 */   333,  500,  333,  333,  333,  433,  444,  333,
-01593         /* 184 */   333,  444,  444,  402,  500,  333,  500,  500,
-01594         /* 192 */   722,  778,  778,  778,  778,  611,  722,  722,
-01595         /* 200 */   722,  611,  611,  611,  611,  389,  389,  833,
-01596         /* 208 */   833,  833,  833,  833,  833,  833,  833,  606,
-01597         /* 216 */   722,  778,  778,  778,  778,  667,  667,  611,
-01598         /* 224 */   389,  500,  500,  500,  500,  333,  444,  444,
-01599         /* 232 */   444,  500,  500,  500,  500,  333,  333,  711,
-01600         /* 240 */   611,  611,  611,  556,  556,  556,  556,  606,
-01601         /* 248 */   389,  611,  611,  611,  611,  556,  333,  333,
-01602         },
-01603         {       /* Palatino-Italic */
-01604         /*   0 */     0,    0,    0,    0,    0,    0,    0,    0,
-01605         /*   8 */     0,    0,    0,    0,    0,    0,    0,    0,
-01606         /*  16 */     0,    0,    0,    0,    0,    0,    0,    0,
-01607         /*  24 */     0,    0,    0,    0,    0,    0,    0,    0,
-01608         /*  32 */   250,  333,  500,  500,  500,  889,  778,  333,
-01609         /*  40 */   333,  333,  389,  606,  250,  333,  250,  296,
-01610         /*  48 */   500,  500,  500,  500,  500,  500,  500,  500,
-01611         /*  56 */   500,  500,  250,  250,  606,  606,  606,  500,
-01612         /*  64 */   747,  722,  611,  667,  778,  611,  556,  722,
-01613         /*  72 */   778,  333,  333,  667,  556,  944,  778,  778,
-01614         /*  80 */   611,  778,  667,  556,  611,  778,  722,  944,
-01615         /*  88 */   722,  667,  667,  333,  606,  333,  606,  500,
-01616         /*  96 */   333,  444,  463,  407,  500,  389,  278,  500,
-01617         /* 104 */   500,  278,  278,  444,  278,  778,  556,  444,
-01618         /* 112 */   500,  463,  389,  389,  333,  556,  500,  722,
-01619         /* 120 */   500,  500,  444,  333,  606,  333,  606,    0,
-01620         /* 128 */     0,    0,    0,    0,    0,    0,    0,    0,
-01621         /* 136 */     0,    0,    0,    0,    0,    0,    0,    0,
-01622         /* 144 */     0,    0,    0,    0,    0,    0,    0,    0,
-01623         /* 152 */     0,    0,    0,    0,    0,    0,    0,    0,
-01624         /* 160 */   250,  722,  333,  556,  500,  556,  556,  500,
-01625         /* 168 */   333,  556,  556,  611,  667,  333,  667,  667,
-01626         /* 176 */   333,  444,  333,  278,  333,  346,  389,  333,
-01627         /* 184 */   333,  389,  389,  361,  444,  333,  444,  444,
-01628         /* 192 */   667,  722,  722,  722,  722,  556,  667,  667,
-01629         /* 200 */   667,  611,  611,  611,  611,  333,  333,  778,
-01630         /* 208 */   778,  778,  778,  778,  778,  778,  778,  606,
-01631         /* 216 */   667,  778,  778,  778,  778,  667,  611,  500,
-01632         /* 224 */   389,  444,  444,  444,  444,  278,  407,  407,
-01633         /* 232 */   407,  389,  389,  389,  389,  278,  278,  577,
-01634         /* 240 */   500,  556,  556,  444,  444,  444,  444,  606,
-01635         /* 248 */   389,  556,  556,  556,  556,  500,  333,  333,
-01636         },
-01637         {       /* Palatino-BoldItalic */
-01638         /*   0 */     0,    0,    0,    0,    0,    0,    0,    0,
-01639         /*   8 */     0,    0,    0,    0,    0,    0,    0,    0,
-01640         /*  16 */     0,    0,    0,    0,    0,    0,    0,    0,
-01641         /*  24 */     0,    0,    0,    0,    0,    0,    0,    0,
-01642         /*  32 */   250,  333,  500,  500,  500,  889,  833,  250,
-01643         /*  40 */   333,  333,  444,  606,  250,  389,  250,  315,
-01644         /*  48 */   500,  500,  500,  500,  500,  500,  500,  500,
-01645         /*  56 */   500,  500,  250,  250,  606,  606,  606,  444,
-01646         /*  64 */   833,  722,  667,  685,  778,  611,  556,  778,
-01647         /*  72 */   778,  389,  389,  722,  611,  944,  778,  833,
-01648         /*  80 */   667,  833,  722,  556,  611,  778,  667, 1000,
-01649         /*  88 */   722,  611,  667,  333,  606,  333,  606,  500,
-01650         /*  96 */   333,  556,  537,  444,  556,  444,  333,  500,
-01651         /* 104 */   556,  333,  333,  556,  333,  833,  556,  556,
-01652         /* 112 */   556,  537,  389,  444,  389,  556,  556,  833,
-01653         /* 120 */   500,  556,  500,  333,  606,  333,  606,    0,
-01654         /* 128 */     0,    0,    0,    0,    0,    0,    0,    0,
-01655         /* 136 */     0,    0,    0,    0,    0,    0,    0,    0,
-01656         /* 144 */     0,    0,    0,    0,    0,    0,    0,    0,
-01657         /* 152 */     0,    0,    0,    0,    0,    0,    0,    0,
-01658         /* 160 */   250,  722,  333,  611,  500,  611,  556,  556,
-01659         /* 168 */   333,  556,  556,  611,  667,  389,  667,  667,
-01660         /* 176 */   556,  556,  333,  333,  333,  429,  444,  333,
-01661         /* 184 */   333,  444,  444,  389,  500,  333,  500,  500,
-01662         /* 192 */   722,  722,  722,  722,  722,  611,  685,  685,
-01663         /* 200 */   685,  611,  611,  611,  611,  389,  389,  778,
-01664         /* 208 */   778,  778,  778,  833,  833,  833,  833,  606,
-01665         /* 216 */   722,  778,  778,  778,  778,  611,  611,  556,
-01666         /* 224 */   389,  556,  556,  556,  556,  333,  444,  444,
-01667         /* 232 */   444,  444,  444,  444,  444,  333,  333,  667,
-01668         /* 240 */   556,  556,  556,  556,  556,  556,  556,  606,
-01669         /* 248 */   389,  556,  556,  556,  556,  556,  389,  333,
-01670         },
-01671         {       /* Helvetica-Narrow */
-01672         /*   0 */     0,    0,    0,    0,    0,    0,    0,    0,
-01673         /*   8 */     0,    0,    0,    0,    0,    0,    0,    0,
-01674         /*  16 */     0,    0,    0,    0,    0,    0,    0,    0,
-01675         /*  24 */     0,    0,    0,    0,    0,    0,    0,    0,
-01676         /*  32 */   228,  228,  291,  456,  456,  729,  547,  157,
-01677         /*  40 */   273,  273,  319,  479,  228,  273,  228,  228,
-01678         /*  48 */   456,  456,  456,  456,  456,  456,  456,  456,
-01679         /*  56 */   456,  456,  228,  228,  479,  479,  479,  456,
-01680         /*  64 */   832,  547,  547,  592,  592,  547,  501,  638,
-01681         /*  72 */   592,  228,  410,  547,  456,  683,  592,  638,
-01682         /*  80 */   547,  638,  592,  547,  501,  592,  547,  774,
-01683         /*  88 */   547,  547,  501,  228,  228,  228,  385,  456,
-01684         /*  96 */   273,  456,  456,  410,  456,  456,  228,  456,
-01685         /* 104 */   456,  182,  182,  410,  182,  683,  456,  456,
-01686         /* 112 */   456,  456,  273,  410,  228,  456,  410,  592,
-01687         /* 120 */   410,  410,  410,  274,  213,  274,  479,    0,
-01688         /* 128 */     0,    0,    0,    0,    0,    0,    0,    0,
-01689         /* 136 */     0,    0,    0,    0,    0,    0,    0,    0,
-01690         /* 144 */     0,    0,    0,    0,    0,    0,    0,    0,
-01691         /* 152 */     0,    0,    0,    0,    0,    0,    0,    0,
-01692         /* 160 */   228,  547,  273,  456,  456,  456,  547,  456,
-01693         /* 168 */   273,  547,  547,  501,  501,  273,  501,  501,
-01694         /* 176 */   273,  456,  273,  182,  273,  212,  410,  273,
-01695         /* 184 */   273,  410,  410,  248,  410,  273,  410,  410,
-01696         /* 192 */   592,  547,  547,  547,  547,  456,  592,  592,
-01697         /* 200 */   592,  547,  547,  547,  547,  228,  228,  592,
-01698         /* 208 */   592,  592,  592,  638,  638,  638,  638,  479,
-01699         /* 216 */   592,  592,  592,  592,  592,  547,  501,  501,
-01700         /* 224 */   273,  456,  456,  456,  456,  182,  410,  410,
-01701         /* 232 */   410,  456,  456,  456,  456,  228,  228,  496,
-01702         /* 240 */   456,  456,  456,  456,  456,  456,  456,  479,
-01703         /* 248 */   273,  456,  456,  456,  456,  410,  228,  273,
-01704         },
-01705         {       /* Helvetica-Narrow-Bold */
-01706         /*   0 */     0,    0,    0,    0,    0,    0,    0,    0,
-01707         /*   8 */     0,    0,    0,    0,    0,    0,    0,    0,
-01708         /*  16 */     0,    0,    0,    0,    0,    0,    0,    0,
-01709         /*  24 */     0,    0,    0,    0,    0,    0,    0,    0,
-01710         /*  32 */   228,  273,  389,  456,  456,  729,  592,  195,
-01711         /*  40 */   273,  273,  319,  479,  228,  273,  228,  228,
-01712         /*  48 */   456,  456,  456,  456,  456,  456,  456,  456,
-01713         /*  56 */   456,  456,  273,  273,  479,  479,  479,  501,
-01714         /*  64 */   800,  592,  592,  592,  592,  547,  501,  638,
-01715         /*  72 */   592,  228,  456,  592,  501,  683,  592,  638,
-01716         /*  80 */   547,  638,  592,  547,  501,  592,  547,  774,
-01717         /*  88 */   547,  547,  501,  273,  228,  273,  479,  456,
-01718         /*  96 */   273,  456,  501,  456,  501,  456,  273,  501,
-01719         /* 104 */   501,  228,  228,  456,  228,  729,  501,  501,
-01720         /* 112 */   501,  501,  319,  456,  273,  501,  456,  638,
-01721         /* 120 */   456,  456,  410,  319,  230,  319,  479,    0,
-01722         /* 128 */     0,    0,    0,    0,    0,    0,    0,    0,
-01723         /* 136 */     0,    0,    0,    0,    0,    0,    0,    0,
-01724         /* 144 */     0,    0,    0,    0,    0,    0,    0,    0,
-01725         /* 152 */     0,    0,    0,    0,    0,    0,    0,    0,
-01726         /* 160 */   228,  592,  273,  501,  456,  501,  547,  456,
-01727         /* 168 */   273,  547,  547,  501,  501,  273,  501,  501,
-01728         /* 176 */   273,  456,  273,  228,  273,  280,  456,  273,
-01729         /* 184 */   273,  456,  456,  338,  410,  273,  410,  410,
-01730         /* 192 */   592,  592,  592,  592,  592,  501,  592,  592,
-01731         /* 200 */   592,  547,  547,  547,  547,  228,  228,  592,
-01732         /* 208 */   592,  592,  592,  638,  638,  638,  638,  479,
-01733         /* 216 */   592,  592,  592,  592,  592,  547,  501,  501,
-01734         /* 224 */   319,  456,  456,  456,  456,  228,  456,  456,
-01735         /* 232 */   456,  456,  456,  456,  456,  228,  228,  561,
-01736         /* 240 */   501,  501,  501,  501,  501,  501,  501,  479,
-01737         /* 248 */   319,  501,  501,  501,  501,  456,  273,  273,
-01738         },
-01739         {       /* Helvetica-Narrow-Oblique */
-01740         /*   0 */     0,    0,    0,    0,    0,    0,    0,    0,
-01741         /*   8 */     0,    0,    0,    0,    0,    0,    0,    0,
-01742         /*  16 */     0,    0,    0,    0,    0,    0,    0,    0,
-01743         /*  24 */     0,    0,    0,    0,    0,    0,    0,    0,
-01744         /*  32 */   228,  228,  291,  456,  456,  729,  547,  157,
-01745         /*  40 */   273,  273,  319,  479,  228,  273,  228,  228,
-01746         /*  48 */   456,  456,  456,  456,  456,  456,  456,  456,
-01747         /*  56 */   456,  456,  228,  228,  479,  479,  479,  456,
-01748         /*  64 */   832,  547,  547,  592,  592,  547,  501,  638,
-01749         /*  72 */   592,  228,  410,  547,  456,  683,  592,  638,
-01750         /*  80 */   547,  638,  592,  547,  501,  592,  547,  774,
-01751         /*  88 */   547,  547,  501,  228,  228,  228,  385,  456,
-01752         /*  96 */   273,  456,  456,  410,  456,  456,  228,  456,
-01753         /* 104 */   456,  182,  182,  410,  182,  683,  456,  456,
-01754         /* 112 */   456,  456,  273,  410,  228,  456,  410,  592,
-01755         /* 120 */   410,  410,  410,  274,  213,  274,  479,    0,
-01756         /* 128 */     0,    0,    0,    0,    0,    0,    0,    0,
-01757         /* 136 */     0,    0,    0,    0,    0,    0,    0,    0,
-01758         /* 144 */     0,    0,    0,    0,    0,    0,    0,    0,
-01759         /* 152 */     0,    0,    0,    0,    0,    0,    0,    0,
-01760         /* 160 */   228,  547,  273,  456,  456,  456,  547,  456,
-01761         /* 168 */   273,  547,  547,  501,  501,  273,  501,  501,
-01762         /* 176 */   273,  456,  273,  182,  273,  217,  410,  273,
-01763         /* 184 */   273,  410,  410,  254,  410,  273,  410,  410,
-01764         /* 192 */   592,  547,  547,  547,  547,  456,  592,  592,
-01765         /* 200 */   592,  547,  547,  547,  547,  228,  228,  592,
-01766         /* 208 */   592,  592,  592,  638,  638,  638,  638,  479,
-01767         /* 216 */   592,  592,  592,  592,  592,  547,  501,  501,
-01768         /* 224 */   273,  456,  456,  456,  456,  182,  410,  410,
-01769         /* 232 */   410,  456,  456,  456,  456,  228,  228,  503,
-01770         /* 240 */   456,  456,  456,  456,  456,  456,  456,  479,
-01771         /* 248 */   273,  456,  456,  456,  456,  410,  228,  273,
-01772         },
-01773         {       /* Helvetica-Narrow-BoldOblique */
-01774         /*   0 */     0,    0,    0,    0,    0,    0,    0,    0,
-01775         /*   8 */     0,    0,    0,    0,    0,    0,    0,    0,
-01776         /*  16 */     0,    0,    0,    0,    0,    0,    0,    0,
-01777         /*  24 */     0,    0,    0,    0,    0,    0,    0,    0,
-01778         /*  32 */   228,  273,  389,  456,  456,  729,  592,  195,
-01779         /*  40 */   273,  273,  319,  479,  228,  273,  228,  228,
-01780         /*  48 */   456,  456,  456,  456,  456,  456,  456,  456,
-01781         /*  56 */   456,  456,  273,  273,  479,  479,  479,  501,
-01782         /*  64 */   800,  592,  592,  592,  592,  547,  501,  638,
-01783         /*  72 */   592,  228,  456,  592,  501,  683,  592,  638,
-01784         /*  80 */   547,  638,  592,  547,  501,  592,  547,  774,
-01785         /*  88 */   547,  547,  501,  273,  228,  273,  479,  456,
-01786         /*  96 */   273,  456,  501,  456,  501,  456,  273,  501,
-01787         /* 104 */   501,  228,  228,  456,  228,  729,  501,  501,
-01788         /* 112 */   501,  501,  319,  456,  273,  501,  456,  638,
-01789         /* 120 */   456,  456,  410,  319,  230,  319,  479,    0,
-01790         /* 128 */     0,    0,    0,    0,    0,    0,    0,    0,
-01791         /* 136 */     0,    0,    0,    0,    0,    0,    0,    0,
-01792         /* 144 */     0,    0,    0,    0,    0,    0,    0,    0,
-01793         /* 152 */     0,    0,    0,    0,    0,    0,    0,    0,
-01794         /* 160 */   228,  592,  273,  501,  456,  501,  547,  456,
-01795         /* 168 */   273,  547,  547,  501,  501,  273,  501,  501,
-01796         /* 176 */   273,  456,  273,  228,  273,  283,  456,  273,
-01797         /* 184 */   273,  456,  456,  312,  410,  273,  410,  410,
-01798         /* 192 */   592,  592,  592,  592,  592,  501,  592,  592,
-01799         /* 200 */   592,  547,  547,  547,  547,  228,  228,  592,
-01800         /* 208 */   592,  592,  592,  638,  638,  638,  638,  479,
-01801         /* 216 */   592,  592,  592,  592,  592,  547,  501,  501,
-01802         /* 224 */   319,  456,  456,  456,  456,  228,  456,  456,
-01803         /* 232 */   456,  456,  456,  456,  456,  228,  228,  561,
-01804         /* 240 */   501,  501,  501,  501,  501,  501,  501,  479,
-01805         /* 248 */   319,  501,  501,  501,  501,  456,  273,  273,
-01806         },
-01807         {       /* Bookman-Light */
-01808         /*   0 */     0,    0,    0,    0,    0,    0,    0,    0,
-01809         /*   8 */     0,    0,    0,    0,    0,    0,    0,    0,
-01810         /*  16 */     0,    0,    0,    0,    0,    0,    0,    0,
-01811         /*  24 */     0,    0,    0,    0,    0,    0,    0,    0,
-01812         /*  32 */   320,  300,  380,  620,  620,  900,  800,  220,
-01813         /*  40 */   300,  300,  440,  600,  320,  400,  320,  600,
-01814         /*  48 */   620,  620,  620,  620,  620,  620,  620,  620,
-01815         /*  56 */   620,  620,  320,  320,  600,  600,  600,  540,
-01816         /*  64 */   820,  680,  740,  740,  800,  720,  640,  800,
-01817         /*  72 */   800,  340,  600,  720,  600,  920,  740,  800,
-01818         /*  80 */   620,  820,  720,  660,  620,  780,  700,  960,
-01819         /*  88 */   720,  640,  640,  300,  600,  300,  600,  500,
-01820         /*  96 */   340,  580,  620,  520,  620,  520,  320,  540,
-01821         /* 104 */   660,  300,  300,  620,  300,  940,  660,  560,
-01822         /* 112 */   620,  580,  440,  520,  380,  680,  520,  780,
-01823         /* 120 */   560,  540,  480,  280,  600,  280,  600,    0,
-01824         /* 128 */     0,    0,    0,    0,    0,    0,    0,    0,
-01825         /* 136 */     0,    0,    0,    0,    0,    0,    0,    0,
-01826         /* 144 */     0,    0,    0,    0,    0,    0,    0,    0,
-01827         /* 152 */     0,    0,    0,    0,    0,    0,    0,    0,
-01828         /* 160 */   320,  680,  460,  600,  620,  600,  660,  520,
-01829         /* 168 */   420,  660,  660,  620,  640,  400,  640,  640,
-01830         /* 176 */   320,  580,  320,  320,  340,  336,  520,  420,
-01831         /* 184 */   320,  520,  520,  380,  480,  380,  480,  480,
-01832         /* 192 */   720,  680,  680,  680,  680,  600,  740,  740,
-01833         /* 200 */   740,  720,  720,  720,  720,  340,  340,  800,
-01834         /* 208 */   800,  740,  740,  800,  800,  800,  800,  600,
-01835         /* 216 */   720,  780,  780,  780,  780,  640,  620,  660,
-01836         /* 224 */   440,  580,  580,  580,  580,  300,  520,  520,
-01837         /* 232 */   520,  520,  520,  520,  520,  300,  300,  620,
-01838         /* 240 */   620,  660,  660,  560,  560,  560,  560,  600,
-01839         /* 248 */   440,  680,  680,  680,  680,  540,  380,  260,
-01840         },
-01841         {       /* Bookman-Demi */
-01842         /*   0 */     0,    0,    0,    0,    0,    0,    0,    0,
-01843         /*   8 */     0,    0,    0,    0,    0,    0,    0,    0,
-01844         /*  16 */     0,    0,    0,    0,    0,    0,    0,    0,
-01845         /*  24 */     0,    0,    0,    0,    0,    0,    0,    0,
-01846         /*  32 */   340,  360,  420,  660,  660,  940,  800,  240,
-01847         /*  40 */   320,  320,  460,  600,  340,  360,  340,  600,
-01848         /*  48 */   660,  660,  660,  660,  660,  660,  660,  660,
-01849         /*  56 */   660,  660,  340,  340,  600,  600,  600,  660,
-01850         /*  64 */   820,  720,  720,  740,  780,  720,  680,  780,
-01851         /*  72 */   820,  400,  640,  800,  640,  940,  740,  800,
-01852         /*  80 */   660,  800,  780,  660,  700,  740,  720,  940,
-01853         /*  88 */   780,  700,  640,  300,  600,  300,  600,  500,
-01854         /*  96 */   400,  580,  600,  580,  640,  580,  380,  580,
-01855         /* 104 */   680,  360,  340,  660,  340, 1000,  680,  620,
-01856         /* 112 */   640,  620,  460,  520,  460,  660,  600,  800,
-01857         /* 120 */   600,  620,  560,  320,  600,  320,  600,    0,
-01858         /* 128 */     0,    0,    0,    0,    0,    0,    0,    0,
-01859         /* 136 */     0,    0,    0,    0,    0,    0,    0,    0,
-01860         /* 144 */     0,    0,    0,    0,    0,    0,    0,    0,
-01861         /* 152 */     0,    0,    0,    0,    0,    0,    0,    0,
-01862         /* 160 */   340,  720,  500,  640,  660,  640,  660,  600,
-01863         /* 168 */   500,  660,  660,  700,  640,  360,  640,  640,
-01864         /* 176 */   340,  580,  320,  340,  400,  430,  520,  500,
-01865         /* 184 */   360,  520,  520,  470,  560,  440,  560,  560,
-01866         /* 192 */   780,  720,  720,  720,  720,  640,  740,  740,
-01867         /* 200 */   740,  720,  720,  720,  720,  400,  400,  780,
-01868         /* 208 */   780,  740,  740,  800,  800,  800,  800,  600,
-01869         /* 216 */   780,  740,  740,  740,  740,  700,  700,  660,
-01870         /* 224 */   460,  580,  580,  580,  580,  340,  580,  580,
-01871         /* 232 */   580,  580,  580,  580,  580,  360,  360,  720,
-01872         /* 240 */   640,  680,  680,  620,  620,  620,  620,  600,
-01873         /* 248 */   460,  660,  660,  660,  660,  620,  460,  320,
-01874         },
-01875         {       /* Bookman-LightItalic */
-01876         /*   0 */     0,    0,    0,    0,    0,    0,    0,    0,
-01877         /*   8 */     0,    0,    0,    0,    0,    0,    0,    0,
-01878         /*  16 */     0,    0,    0,    0,    0,    0,    0,    0,
-01879         /*  24 */     0,    0,    0,    0,    0,    0,    0,    0,
-01880         /*  32 */   300,  320,  360,  620,  620,  800,  820,  200,
-01881         /*  40 */   280,  280,  440,  600,  300,  320,  300,  600,
-01882         /*  48 */   620,  620,  620,  620,  620,  620,  620,  620,
-01883         /*  56 */   620,  620,  300,  300,  600,  600,  600,  540,
-01884         /*  64 */   780,  700,  720,  720,  740,  680,  620,  760,
-01885         /*  72 */   800,  320,  560,  720,  580,  860,  720,  760,
-01886         /*  80 */   600,  780,  700,  640,  600,  720,  680,  960,
-01887         /*  88 */   700,  660,  580,  260,  600,  260,  600,  500,
-01888         /*  96 */   340,  620,  600,  480,  640,  540,  340,  560,
-01889         /* 104 */   620,  280,  280,  600,  280,  880,  620,  540,
-01890         /* 112 */   600,  560,  400,  540,  340,  620,  540,  880,
-01891         /* 120 */   540,  600,  520,  360,  600,  380,  600,    0,
-01892         /* 128 */     0,    0,    0,    0,    0,    0,    0,    0,
-01893         /* 136 */     0,    0,    0,    0,    0,    0,    0,    0,
-01894         /* 144 */     0,    0,    0,    0,    0,    0,    0,    0,
-01895         /* 152 */     0,    0,    0,    0,    0,    0,    0,    0,
-01896         /* 160 */   300,  700,  440,  580,  620,  580,  640,  620,
-01897         /* 168 */   420,  640,  640,  600,  580,  320,  580,  580,
-01898         /* 176 */   300,  620,  260,  340,  320,  380,  540,  440,
-01899         /* 184 */   320,  540,  540,  340,  520,  340,  520,  520,
-01900         /* 192 */   700,  700,  700,  700,  700,  580,  720,  720,
-01901         /* 200 */   720,  680,  680,  680,  680,  320,  320,  740,
-01902         /* 208 */   740,  720,  720,  760,  760,  760,  760,  600,
-01903         /* 216 */   700,  720,  720,  720,  720,  660,  600,  620,
-01904         /* 224 */   400,  620,  620,  620,  620,  280,  480,  480,
-01905         /* 232 */   480,  540,  540,  540,  540,  280,  280,  730,
-01906         /* 240 */   640,  620,  620,  540,  540,  540,  540,  600,
-01907         /* 248 */   400,  620,  620,  620,  620,  600,  340,  260,
-01908         },
-01909         {       /* Bookman-DemiItalic */
-01910         /*   0 */     0,    0,    0,    0,    0,    0,    0,    0,
-01911         /*   8 */     0,    0,    0,    0,    0,    0,    0,    0,
-01912         /*  16 */     0,    0,    0,    0,    0,    0,    0,    0,
-01913         /*  24 */     0,    0,    0,    0,    0,    0,    0,    0,
-01914         /*  32 */   340,  320,  380,  680,  680,  880,  980,  180,
-01915         /*  40 */   260,  260,  460,  600,  340,  280,  340,  360,
-01916         /*  48 */   680,  680,  680,  680,  680,  680,  680,  680,
-01917         /*  56 */   680,  680,  340,  340,  620,  600,  620,  620,
-01918         /*  64 */   780,  720,  720,  700,  760,  720,  660,  760,
-01919         /*  72 */   800,  380,  620,  780,  640,  860,  740,  760,
-01920         /*  80 */   640,  760,  740,  700,  700,  740,  660, 1000,
-01921         /*  88 */   740,  660,  680,  260,  580,  260,  620,  500,
-01922         /*  96 */   380,  680,  600,  560,  680,  560,  420,  620,
-01923         /* 104 */   700,  380,  320,  700,  380,  960,  680,  600,
-01924         /* 112 */   660,  620,  500,  540,  440,  680,  540,  860,
-01925         /* 120 */   620,  600,  560,  300,  620,  300,  620,    0,
-01926         /* 128 */     0,    0,    0,    0,    0,    0,    0,    0,
-01927         /* 136 */     0,    0,    0,    0,    0,    0,    0,    0,
-01928         /* 144 */     0,    0,    0,    0,    0,    0,    0,    0,
-01929         /* 152 */     0,    0,    0,    0,    0,    0,    0,    0,
-01930         /* 160 */   340,  720,  460,  640,  680,  640,  700,  620,
-01931         /* 168 */   520,  700,  700,  700,  680,  280,  680,  680,
-01932         /* 176 */   360,  680,  320,  380,  340,  509,  540,  480,
-01933         /* 184 */   360,  540,  540,  520,  560,  560,  560,  560,
-01934         /* 192 */   740,  720,  720,  720,  720,  640,  700,  700,
-01935         /* 200 */   700,  720,  720,  720,  720,  380,  380,  760,
-01936         /* 208 */   760,  740,  740,  760,  760,  760,  760,  600,
-01937         /* 216 */   740,  740,  740,  740,  740,  660,  700,  660,
-01938         /* 224 */   500,  680,  680,  680,  680,  380,  560,  560,
-01939         /* 232 */   560,  560,  560,  560,  560,  380,  380,  810,
-01940         /* 240 */   680,  680,  680,  600,  600,  600,  600,  600,
-01941         /* 248 */   500,  680,  680,  680,  680,  600,  440,  380,
-01942         },
-01943         {       /* AvantGarde-Book */
-01944         /*   0 */     0,    0,    0,    0,    0,    0,    0,    0,
-01945         /*   8 */     0,    0,    0,    0,    0,    0,    0,    0,
-01946         /*  16 */     0,    0,    0,    0,    0,    0,    0,    0,
-01947         /*  24 */     0,    0,    0,    0,    0,    0,    0,    0,
-01948         /*  32 */   277,  295,  309,  554,  554,  775,  757,  198,
-01949         /*  40 */   369,  369,  425,  606,  277,  332,  277,  437,
-01950         /*  48 */   554,  554,  554,  554,  554,  554,  554,  554,
-01951         /*  56 */   554,  554,  277,  277,  606,  606,  606,  591,
-01952         /*  64 */   867,  740,  574,  813,  744,  536,  485,  872,
-01953         /*  72 */   683,  226,  482,  591,  462,  919,  740,  869,
-01954         /*  80 */   592,  871,  607,  498,  426,  655,  702,  960,
-01955         /*  88 */   609,  592,  480,  351,  605,  351,  606,  500,
-01956         /*  96 */   378,  683,  682,  647,  685,  650,  314,  673,
-01957         /* 104 */   610,  200,  203,  502,  200,  938,  610,  655,
-01958         /* 112 */   682,  682,  301,  388,  339,  608,  554,  831,
-01959         /* 120 */   480,  536,  425,  351,  672,  351,  606,    0,
-01960         /* 128 */     0,    0,    0,    0,    0,    0,    0,    0,
-01961         /* 136 */     0,    0,    0,    0,    0,    0,    0,    0,
-01962         /* 144 */     0,    0,    0,    0,    0,    0,    0,    0,
-01963         /* 152 */     0,    0,    0,    0,    0,    0,    0,    0,
-01964         /* 160 */   277,  740,  453,  517,  554,  462,  498,  615,
-01965         /* 168 */   369,  498,  498,  426,  480,  332,  480,  480,
-01966         /* 176 */   332,  683,  302,  300,  375,  245,  388,  502,
-01967         /* 184 */   324,  388,  388,  339,  425,  552,  425,  425,
-01968         /* 192 */   607,  740,  740,  740,  740,  462,  813,  813,
-01969         /* 200 */   813,  536,  536,  536,  536,  226,  226,  744,
-01970         /* 208 */   790,  740,  740,  869,  869,  869,  869,  606,
-01971         /* 216 */   607,  655,  655,  655,  655,  592,  426,  554,
-01972         /* 224 */   301,  683,  683,  683,  683,  200,  647,  647,
-01973         /* 232 */   647,  650,  650,  650,  650,  200,  200,  725,
-01974         /* 240 */   685,  610,  610,  655,  655,  655,  655,  606,
-01975         /* 248 */   301,  608,  608,  608,  608,  536,  339,  222,
-01976         },
-01977         {       /* AvantGarde-Demi */
-01978         /*   0 */     0,    0,    0,    0,    0,    0,    0,    0,
-01979         /*   8 */     0,    0,    0,    0,    0,    0,    0,    0,
-01980         /*  16 */     0,    0,    0,    0,    0,    0,    0,    0,
-01981         /*  24 */     0,    0,    0,    0,    0,    0,    0,    0,
-01982         /*  32 */   280,  280,  360,  560,  560,  860,  680,  220,
-01983         /*  40 */   380,  380,  440,  600,  280,  420,  280,  460,
-01984         /*  48 */   560,  560,  560,  560,  560,  560,  560,  560,
-01985         /*  56 */   560,  560,  280,  280,  600,  600,  600,  560,
-01986         /*  64 */   740,  740,  580,  780,  700,  520,  480,  840,
-01987         /*  72 */   680,  280,  480,  620,  440,  900,  740,  840,
-01988         /*  80 */   560,  840,  580,  520,  420,  640,  700,  900,
-01989         /*  88 */   680,  620,  500,  320,  640,  320,  600,  500,
-01990         /*  96 */   420,  660,  660,  640,  660,  640,  280,  660,
-01991         /* 104 */   600,  240,  260,  580,  240,  940,  600,  640,
-01992         /* 112 */   660,  660,  320,  440,  300,  600,  560,  800,
-01993         /* 120 */   560,  580,  460,  340,  600,  340,  600,    0,
-01994         /* 128 */     0,    0,    0,    0,    0,    0,    0,    0,
-01995         /* 136 */     0,    0,    0,    0,    0,    0,    0,    0,
-01996         /* 144 */     0,    0,    0,    0,    0,    0,    0,    0,
-01997         /* 152 */     0,    0,    0,    0,    0,    0,    0,    0,
-01998         /* 160 */   280,  740,  480,  480,  560,  440,  520,  560,
-01999         /* 168 */   500,  520,  520,  420,  500,  420,  500,  500,
-02000         /* 176 */   360,  660,  340,  320,  420,  330,  440,  540,
-02001         /* 184 */   340,  440,  440,  369,  460,  700,  460,  460,
-02002         /* 192 */   580,  740,  740,  740,  740,  440,  780,  780,
-02003         /* 200 */   780,  520,  520,  520,  520,  280,  280,  700,
-02004         /* 208 */   742,  740,  740,  840,  840,  840,  840,  600,
-02005         /* 216 */   580,  640,  640,  640,  640,  620,  420,  600,
-02006         /* 224 */   320,  660,  660,  660,  660,  240,  640,  640,
-02007         /* 232 */   640,  640,  640,  640,  640,  240,  240,  754,
-02008         /* 240 */   660,  600,  600,  640,  640,  640,  640,  600,
-02009         /* 248 */   320,  600,  600,  600,  600,  580,  300,  280,
-02010         },
-02011         {       /* AvantGarde-BookOblique */
-02012         /*   0 */     0,    0,    0,    0,    0,    0,    0,    0,
-02013         /*   8 */     0,    0,    0,    0,    0,    0,    0,    0,
-02014         /*  16 */     0,    0,    0,    0,    0,    0,    0,    0,
-02015         /*  24 */     0,    0,    0,    0,    0,    0,    0,    0,
-02016         /*  32 */   277,  295,  309,  554,  554,  775,  757,  198,
-02017         /*  40 */   369,  369,  425,  606,  277,  332,  277,  437,
-02018         /*  48 */   554,  554,  554,  554,  554,  554,  554,  554,
-02019         /*  56 */   554,  554,  277,  277,  606,  606,  606,  591,
-02020         /*  64 */   867,  740,  574,  813,  744,  536,  485,  872,
-02021         /*  72 */   683,  226,  482,  591,  462,  919,  740,  869,
-02022         /*  80 */   592,  871,  607,  498,  426,  655,  702,  960,
-02023         /*  88 */   609,  592,  480,  351,  605,  351,  606,  500,
-02024         /*  96 */   378,  683,  682,  647,  685,  650,  314,  673,
-02025         /* 104 */   610,  200,  203,  502,  200,  938,  610,  655,
-02026         /* 112 */   682,  682,  301,  388,  339,  608,  554,  831,
-02027         /* 120 */   480,  536,  425,  351,  672,  351,  606,    0,
-02028         /* 128 */     0,    0,    0,    0,    0,    0,    0,    0,
-02029         /* 136 */     0,    0,    0,    0,    0,    0,    0,    0,
-02030         /* 144 */     0,    0,    0,    0,    0,    0,    0,    0,
-02031         /* 152 */     0,    0,    0,    0,    0,    0,    0,    0,
-02032         /* 160 */   277,  740,  453,  517,  554,  462,  498,  615,
-02033         /* 168 */   369,  498,  498,  426,  480,  332,  480,  480,
-02034         /* 176 */   332,  683,  302,  300,  375,  231,  388,  502,
-02035         /* 184 */   324,  388,  388,  339,  425,  552,  425,  425,
-02036         /* 192 */   607,  740,  740,  740,  740,  462,  813,  813,
-02037         /* 200 */   813,  536,  536,  536,  536,  226,  226,  744,
-02038         /* 208 */   790,  740,  740,  869,  869,  869,  869,  606,
-02039         /* 216 */   607,  655,  655,  655,  655,  592,  426,  554,
-02040         /* 224 */   301,  683,  683,  683,  683,  200,  647,  647,
-02041         /* 232 */   647,  650,  650,  650,  650,  200,  200,  714,
-02042         /* 240 */   685,  610,  610,  655,  655,  655,  655,  606,
-02043         /* 248 */   301,  608,  608,  608,  608,  536,  339,  222,
-02044         },
-02045         {       /* AvantGarde-DemiOblique */
-02046         /*   0 */     0,    0,    0,    0,    0,    0,    0,    0,
-02047         /*   8 */     0,    0,    0,    0,    0,    0,    0,    0,
-02048         /*  16 */     0,    0,    0,    0,    0,    0,    0,    0,
-02049         /*  24 */     0,    0,    0,    0,    0,    0,    0,    0,
-02050         /*  32 */   280,  280,  360,  560,  560,  860,  680,  220,
-02051         /*  40 */   380,  380,  440,  600,  280,  420,  280,  460,
-02052         /*  48 */   560,  560,  560,  560,  560,  560,  560,  560,
-02053         /*  56 */   560,  560,  280,  280,  600,  600,  600,  560,
-02054         /*  64 */   740,  740,  580,  780,  700,  520,  480,  840,
-02055         /*  72 */   680,  280,  480,  620,  440,  900,  740,  840,
-02056         /*  80 */   560,  840,  580,  520,  420,  640,  700,  900,
-02057         /*  88 */   680,  620,  500,  320,  640,  320,  600,  500,
-02058         /*  96 */   420,  660,  660,  640,  660,  640,  280,  660,
-02059         /* 104 */   600,  240,  260,  580,  240,  940,  600,  640,
-02060         /* 112 */   660,  660,  320,  440,  300,  600,  560,  800,
-02061         /* 120 */   560,  580,  460,  340,  600,  340,  600,    0,
-02062         /* 128 */     0,    0,    0,    0,    0,    0,    0,    0,
-02063         /* 136 */     0,    0,    0,    0,    0,    0,    0,    0,
-02064         /* 144 */     0,    0,    0,    0,    0,    0,    0,    0,
-02065         /* 152 */     0,    0,    0,    0,    0,    0,    0,    0,
-02066         /* 160 */   280,  740,  480,  480,  560,  440,  520,  560,
-02067         /* 168 */   500,  520,  520,  420,  500,  420,  500,  500,
-02068         /* 176 */   360,  660,  340,  320,  420,  326,  440,  540,
-02069         /* 184 */   340,  440,  440,  364,  460,  700,  460,  460,
-02070         /* 192 */   580,  740,  740,  740,  740,  440,  780,  780,
-02071         /* 200 */   780,  520,  520,  520,  520,  280,  280,  700,
-02072         /* 208 */   742,  740,  740,  840,  840,  840,  840,  600,
-02073         /* 216 */   580,  640,  640,  640,  640,  620,  420,  600,
-02074         /* 224 */   320,  660,  660,  660,  660,  240,  640,  640,
-02075         /* 232 */   640,  640,  640,  640,  640,  240,  240,  752,
-02076         /* 240 */   660,  600,  600,  640,  640,  640,  640,  600,
-02077         /* 248 */   320,  600,  600,  600,  600,  580,  300,  280,
-02078         },
-02079         {       /* NewCenturySchlbk-Roman */
-02080         /*   0 */     0,    0,    0,    0,    0,    0,    0,    0,
-02081         /*   8 */     0,    0,    0,    0,    0,    0,    0,    0,
-02082         /*  16 */     0,    0,    0,    0,    0,    0,    0,    0,
-02083         /*  24 */     0,    0,    0,    0,    0,    0,    0,    0,
-02084         /*  32 */   278,  296,  389,  556,  556,  833,  815,  204,
-02085         /*  40 */   333,  333,  500,  606,  278,  333,  278,  278,
-02086         /*  48 */   556,  556,  556,  556,  556,  556,  556,  556,
-02087         /*  56 */   556,  556,  278,  278,  606,  606,  606,  444,
-02088         /*  64 */   737,  722,  722,  722,  778,  722,  667,  778,
-02089         /*  72 */   833,  407,  556,  778,  667,  944,  815,  778,
-02090         /*  80 */   667,  778,  722,  630,  667,  815,  722,  981,
-02091         /*  88 */   704,  704,  611,  333,  606,  333,  606,  500,
-02092         /*  96 */   333,  556,  556,  444,  574,  500,  333,  537,
-02093         /* 104 */   611,  315,  296,  593,  315,  889,  611,  500,
-02094         /* 112 */   574,  556,  444,  463,  389,  611,  537,  778,
-02095         /* 120 */   537,  537,  481,  333,  606,  333,  606,    0,
-02096         /* 128 */     0,    0,    0,    0,    0,    0,    0,    0,
-02097         /* 136 */     0,    0,    0,    0,    0,    0,    0,    0,
-02098         /* 144 */     0,    0,    0,    0,    0,    0,    0,    0,
-02099         /* 152 */     0,    0,    0,    0,    0,    0,    0,    0,
-02100         /* 160 */   278,  722,  333,  667,  556,  667,  630,  500,
-02101         /* 168 */   333,  630,  630,  667,  611,  333,  611,  611,
-02102         /* 176 */   333,  556,  333,  315,  333,  339,  463,  333,
-02103         /* 184 */   333,  463,  463,  389,  481,  333,  481,  481,
-02104         /* 192 */   722,  722,  722,  722,  722,  667,  722,  722,
-02105         /* 200 */   722,  722,  722,  722,  722,  407,  407,  778,
-02106         /* 208 */   778,  815,  815,  778,  778,  778,  778,  606,
-02107         /* 216 */   722,  815,  815,  815,  815,  704,  667,  574,
-02108         /* 224 */   444,  556,  556,  556,  556,  315,  444,  444,
-02109         /* 232 */   444,  500,  500,  500,  500,  315,  315,  606,
-02110         /* 240 */   574,  611,  611,  500,  500,  500,  500,  606,
-02111         /* 248 */   444,  611,  611,  611,  611,  537,  389,  333,
-02112         },
-02113         {       /* NewCenturySchlbk-Bold */
-02114         /*   0 */     0,    0,    0,    0,    0,    0,    0,    0,
-02115         /*   8 */     0,    0,    0,    0,    0,    0,    0,    0,
-02116         /*  16 */     0,    0,    0,    0,    0,    0,    0,    0,
-02117         /*  24 */     0,    0,    0,    0,    0,    0,    0,    0,
-02118         /*  32 */   287,  296,  333,  574,  574,  833,  852,  241,
-02119         /*  40 */   389,  389,  500,  606,  278,  333,  278,  278,
-02120         /*  48 */   574,  574,  574,  574,  574,  574,  574,  574,
-02121         /*  56 */   574,  574,  278,  278,  606,  606,  606,  500,
-02122         /*  64 */   747,  759,  778,  778,  833,  759,  722,  833,
-02123         /*  72 */   870,  444,  648,  815,  722,  981,  833,  833,
-02124         /*  80 */   759,  833,  815,  667,  722,  833,  759,  981,
-02125         /*  88 */   722,  722,  667,  389,  606,  389,  606,  500,
-02126         /*  96 */   333,  611,  648,  556,  667,  574,  389,  611,
-02127         /* 104 */   685,  370,  352,  667,  352,  963,  685,  611,
-02128         /* 112 */   667,  648,  519,  500,  426,  685,  611,  889,
-02129         /* 120 */   611,  611,  537,  389,  606,  389,  606,    0,
-02130         /* 128 */     0,    0,    0,    0,    0,    0,    0,    0,
-02131         /* 136 */     0,    0,    0,    0,    0,    0,    0,    0,
-02132         /* 144 */     0,    0,    0,    0,    0,    0,    0,    0,
-02133         /* 152 */     0,    0,    0,    0,    0,    0,    0,    0,
-02134         /* 160 */   287,  759,  333,  722,  574,  722,  667,  500,
-02135         /* 168 */   333,  667,  667,  722,  667,  333,  667,  667,
-02136         /* 176 */   333,  611,  333,  352,  333,  436,  500,  333,
-02137         /* 184 */   333,  500,  500,  446,  537,  333,  537,  537,
-02138         /* 192 */   815,  759,  759,  759,  759,  722,  778,  778,
-02139         /* 200 */   778,  759,  759,  759,  759,  444,  444,  833,
-02140         /* 208 */   833,  833,  833,  833,  833,  833,  833,  606,
-02141         /* 216 */   815,  833,  833,  833,  833,  722,  722,  611,
-02142         /* 224 */   519,  611,  611,  611,  611,  352,  556,  556,
-02143         /* 232 */   556,  574,  574,  574,  574,  370,  370,  747,
-02144         /* 240 */   667,  685,  685,  611,  611,  611,  611,  606,
-02145         /* 248 */   519,  685,  685,  685,  685,  611,  426,  333,
-02146         },
-02147         {       /* NewCenturySchlbk-Italic */
-02148         /*   0 */     0,    0,    0,    0,    0,    0,    0,    0,
-02149         /*   8 */     0,    0,    0,    0,    0,    0,    0,    0,
-02150         /*  16 */     0,    0,    0,    0,    0,    0,    0,    0,
-02151         /*  24 */     0,    0,    0,    0,    0,    0,    0,    0,
-02152         /*  32 */   278,  333,  400,  556,  556,  833,  852,  278,
-02153         /*  40 */   333,  333,  500,  606,  278,  333,  278,  606,
-02154         /*  48 */   556,  556,  556,  556,  556,  556,  556,  556,
-02155         /*  56 */   556,  556,  278,  278,  606,  606,  606,  444,
-02156         /*  64 */   747,  704,  722,  722,  778,  722,  667,  778,
-02157         /*  72 */   833,  407,  611,  741,  667,  944,  815,  778,
-02158         /*  80 */   667,  778,  741,  667,  685,  815,  704,  926,
-02159         /*  88 */   704,  685,  667,  333,  606,  333,  606,  500,
-02160         /*  96 */   333,  574,  556,  444,  611,  444,  333,  537,
-02161         /* 104 */   611,  333,  315,  556,  333,  889,  611,  500,
-02162         /* 112 */   574,  556,  444,  444,  352,  611,  519,  778,
-02163         /* 120 */   500,  500,  463,  333,  606,  333,  606,    0,
-02164         /* 128 */     0,    0,    0,    0,    0,    0,    0,    0,
-02165         /* 136 */     0,    0,    0,    0,    0,    0,    0,    0,
-02166         /* 144 */     0,    0,    0,    0,    0,    0,    0,    0,
-02167         /* 152 */     0,    0,    0,    0,    0,    0,    0,    0,
-02168         /* 160 */   278,  704,  333,  667,  556,  667,  667,  500,
-02169         /* 168 */   333,  667,  667,  685,  667,  333,  667,  667,
-02170         /* 176 */   333,  574,  333,  333,  333,  359,  444,  333,
-02171         /* 184 */   333,  444,  444,  368,  463,  333,  463,  463,
-02172         /* 192 */   741,  704,  704,  704,  704,  667,  722,  722,
-02173         /* 200 */   722,  722,  722,  722,  722,  407,  407,  778,
-02174         /* 208 */   778,  815,  815,  778,  778,  778,  778,  606,
-02175         /* 216 */   741,  815,  815,  815,  815,  685,  685,  556,
-02176         /* 224 */   444,  574,  574,  574,  574,  333,  444,  444,
-02177         /* 232 */   444,  444,  444,  444,  444,  333,  333,  651,
-02178         /* 240 */   611,  611,  611,  500,  500,  500,  500,  606,
-02179         /* 248 */   444,  611,  611,  611,  611,  500,  352,  333,
-02180         },
-02181         {       /* NewCenturySchlbk-BoldItalic */
-02182         /*   0 */     0,    0,    0,    0,    0,    0,    0,    0,
-02183         /*   8 */     0,    0,    0,    0,    0,    0,    0,    0,
-02184         /*  16 */     0,    0,    0,    0,    0,    0,    0,    0,
-02185         /*  24 */     0,    0,    0,    0,    0,    0,    0,    0,
-02186         /*  32 */   287,  333,  400,  574,  574,  889,  889,  287,
-02187         /*  40 */   407,  407,  500,  606,  287,  333,  287,  278,
-02188         /*  48 */   574,  574,  574,  574,  574,  574,  574,  574,
-02189         /*  56 */   574,  574,  287,  287,  606,  606,  606,  481,
-02190         /*  64 */   747,  741,  759,  759,  833,  741,  704,  815,
-02191         /*  72 */   870,  444,  667,  778,  704,  944,  852,  833,
-02192         /*  80 */   741,  833,  796,  685,  722,  833,  741,  944,
-02193         /*  88 */   741,  704,  704,  407,  606,  407,  606,  500,
-02194         /*  96 */   333,  667,  611,  537,  667,  519,  389,  611,
-02195         /* 104 */   685,  389,  370,  648,  389,  944,  685,  574,
-02196         /* 112 */   648,  630,  519,  481,  407,  685,  556,  833,
-02197         /* 120 */   574,  519,  519,  407,  606,  407,  606,    0,
-02198         /* 128 */     0,    0,    0,    0,    0,    0,    0,    0,
-02199         /* 136 */     0,    0,    0,    0,    0,    0,    0,    0,
-02200         /* 144 */     0,    0,    0,    0,    0,    0,    0,    0,
-02201         /* 152 */     0,    0,    0,    0,    0,    0,    0,    0,
-02202         /* 160 */   287,  741,  333,  704,  574,  704,  685,  500,
-02203         /* 168 */   333,  685,  685,  722,  704,  333,  704,  704,
-02204         /* 176 */   333,  667,  333,  389,  333,  486,  481,  333,
-02205         /* 184 */   333,  481,  481,  483,  519,  333,  519,  519,
-02206         /* 192 */   796,  741,  741,  741,  741,  704,  759,  759,
-02207         /* 200 */   759,  741,  741,  741,  741,  444,  444,  833,
-02208         /* 208 */   833,  852,  852,  833,  833,  833,  833,  606,
-02209         /* 216 */   796,  833,  833,  833,  833,  704,  722,  574,
-02210         /* 224 */   519,  667,  667,  667,  667,  389,  537,  537,
-02211         /* 232 */   537,  519,  519,  519,  519,  389,  389,  780,
-02212         /* 240 */   667,  685,  685,  574,  574,  574,  574,  606,
-02213         /* 248 */   519,  685,  685,  685,  685,  519,  407,  333,
-02214         },
-02215 };
-02216 #if 0 /* Until this array is needed */
-02217 static int aiUnderlineInfo[32][2] = {
-02218         { -100, 50 },
-02219         { -100, 50 },
-02220         { -100, 50 },
-02221         { -100, 50 },
-02222         { -100, 50 },
-02223         { -100, 50 },
-02224         { -100, 50 },
-02225         { -100, 50 },
-02226         { -151, 50 },
-02227         { -155, 69 },
-02228         { -151, 50 },
-02229         { -111, 69 },
-02230         { -100, 50 },
-02231         { -100, 50 },
-02232         { -100, 50 },
-02233         { -100, 50 },
-02234         { -100, 50 },
-02235         { -100, 50 },
-02236         { -100, 50 },
-02237         { -100, 50 },
-02238         { -125, 60 },
-02239         { -125, 60 },
-02240         { -125, 60 },
-02241         { -125, 60 },
-02242         { -96, 58 },
-02243         { -93, 90 },
-02244         { -96, 58 },
-02245         { -93, 90 },
-02246         { -104, 61 },
-02247         { -103, 90 },
-02248         { -102, 42 },
-02249         { -102, 54 },
-02250 };
-02251 #endif /* 0 */
-
-
Generated by  - -doxygen 1.6.2
- - diff -r 59758314f811 -r d4524d6a4472 Symbian3/Examples/guid-6013a680-57f9-415b-8851-c4fa63356636/fontlist_8c_source.html --- a/Symbian3/Examples/guid-6013a680-57f9-415b-8851-c4fa63356636/fontlist_8c_source.html Fri Jun 11 15:24:34 2010 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,189 +0,0 @@ - - - - -TB9.2 Example Applications: examples/PIPS/antiword/src/fontlist.c Source File - - - - - -

examples/PIPS/antiword/src/fontlist.c

00001 /*
-00002  * fontlist.c
-00003  * Copyright (C) 1998-2004 A.J. van Os; Released under GNU GPL
-00004  *
-00005  * Description:
-00006  * Build, read and destroy a list of Word font information
-00007  */
-00008 
-00009 #include <stdlib.h>
-00010 #include <stddef.h>
-00011 #include "antiword.h"
-00012 
-00013 
-00014 /*
-00015  * Private structure to hide the way the information
-00016  * is stored from the rest of the program
-00017  */
-00018 typedef struct font_desc_tag {
-00019         font_block_type tInfo;
-00020         struct font_desc_tag    *pNext;
-00021 } font_mem_type;
-00022 
-00023 /* Variables needed to write the Font Information List */
-00024 static font_mem_type    *pAnchor = NULL;
-00025 static font_mem_type    *pFontLast = NULL;
-00026 
-00027 
-00028 /*
-00029  * vDestroyFontInfoList - destroy the Font Information List
-00030  */
-00031 void
-00032 vDestroyFontInfoList(void)
-00033 {
-00034         font_mem_type   *pCurr, *pNext;
-00035 
-00036         DBG_MSG("vDestroyFontInfoList");
-00037 
-00038         /* Free the Font Information List */
-00039         pCurr = pAnchor;
-00040         while (pCurr != NULL) {
-00041                 pNext = pCurr->pNext;
-00042                 pCurr = xfree(pCurr);
-00043                 pCurr = pNext;
-00044         }
-00045         pAnchor = NULL;
-00046         /* Reset all control variables */
-00047         pFontLast = NULL;
-00048 } /* end of vDestroyFontInfoList */
-00049 
-00050 /*
-00051  * vCorrectFontValues - correct font values to values Antiword can use
-00052  */
-00053 void
-00054 vCorrectFontValues(font_block_type *pFontBlock)
-00055 {
-00056         UINT    uiRealSize;
-00057         USHORT  usRealStyle;
-00058 
-00059         uiRealSize = pFontBlock->usFontSize;
-00060         usRealStyle = pFontBlock->usFontStyle;
-00061         if (bIsSmallCapitals(pFontBlock->usFontStyle)) {
-00062                 /* Small capitals become normal capitals in a smaller font */
-00063                 uiRealSize = (uiRealSize * 4 + 2) / 5;
-00064                 usRealStyle &= ~FONT_SMALL_CAPITALS;
-00065                 usRealStyle |= FONT_CAPITALS;
-00066         }
-00067         if (bIsSuperscript(pFontBlock->usFontStyle) ||
-00068             bIsSubscript(pFontBlock->usFontStyle)) {
-00069                 /* Superscript and subscript use a smaller fontsize */
-00070                 uiRealSize = (uiRealSize * 2 + 1) / 3;
-00071         }
-00072 
-00073         if (uiRealSize < MIN_FONT_SIZE) {
-00074                 DBG_DEC(uiRealSize);
-00075                 uiRealSize = MIN_FONT_SIZE;
-00076         } else if (uiRealSize > MAX_FONT_SIZE) {
-00077                 DBG_DEC(uiRealSize);
-00078                 uiRealSize = MAX_FONT_SIZE;
-00079         }
-00080 
-00081         pFontBlock->usFontSize = (USHORT)uiRealSize;
-00082         if (pFontBlock->ucFontColor == 8) {
-00083                 /* White text to light gray text */
-00084                 pFontBlock->ucFontColor = 16;
-00085         }
-00086         pFontBlock->usFontStyle = usRealStyle;
-00087 } /* end of vCorrectFontValues */
-00088 
-00089 /*
-00090  * vAdd2FontInfoList - Add an element to the Font Information List
-00091  */
-00092 void
-00093 vAdd2FontInfoList(const font_block_type *pFontBlock)
-00094 {
-00095         font_mem_type   *pListMember;
-00096 
-00097         fail(pFontBlock == NULL);
-00098 
-00099         NO_DBG_MSG("bAdd2FontInfoList");
-00100 
-00101         if (pFontBlock->ulFileOffset == FC_INVALID) {
-00102                 /*
-00103                  * This offset is really past the end of the file,
-00104                  * so don't waste any memory by storing it.
-00105                  */
-00106                 return;
-00107         }
-00108 
-00109         NO_DBG_HEX(pFontBlock->ulFileOffset);
-00110         NO_DBG_DEC_C(pFontBlock->ucFontNumber != 0,
-00111                                         pFontBlock->ucFontNumber);
-00112         NO_DBG_DEC_C(pFontBlock->usFontSize != DEFAULT_FONT_SIZE,
-00113                                         pFontBlock->usFontSize);
-00114         NO_DBG_DEC_C(pFontBlock->ucFontColor != 0,
-00115                                         pFontBlock->ucFontColor);
-00116         NO_DBG_HEX_C(pFontBlock->usFontStyle != 0x00,
-00117                                         pFontBlock->usFontStyle);
-00118 
-00119         if (pFontLast != NULL &&
-00120             pFontLast->tInfo.ulFileOffset == pFontBlock->ulFileOffset) {
-00121                 /*
-00122                  * If two consecutive fonts share the same
-00123                  * offset, remember only the last font
-00124                  */
-00125                 fail(pFontLast->pNext != NULL);
-00126                 pFontLast->tInfo = *pFontBlock;
-00127                 return;
-00128         }
-00129 
-00130         /* Create list member */
-00131         pListMember = xmalloc(sizeof(font_mem_type));
-00132         /* Fill the list member */
-00133         pListMember->tInfo = *pFontBlock;
-00134         pListMember->pNext = NULL;
-00135         /* Correct the values where needed */
-00136         vCorrectFontValues(&pListMember->tInfo);
-00137         /* Add the new member to the list */
-00138         if (pAnchor == NULL) {
-00139                 pAnchor = pListMember;
-00140         } else {
-00141                 fail(pFontLast == NULL);
-00142                 pFontLast->pNext = pListMember;
-00143         }
-00144         pFontLast = pListMember;
-00145 } /* end of vAdd2FontInfoList */
-00146 
-00147 /*
-00148  * Get the record that follows the given recored in the Font Information List
-00149  */
-00150 const font_block_type *
-00151 pGetNextFontInfoListItem(const font_block_type *pCurr)
-00152 {
-00153         const font_mem_type     *pRecord;
-00154         size_t  tOffset;
-00155 
-00156         if (pCurr == NULL) {
-00157                 if (pAnchor == NULL) {
-00158                         /* There are no records */
-00159                         return NULL;
-00160                 }
-00161                 /* The first record is the only one without a predecessor */
-00162                 return &pAnchor->tInfo;
-00163         }
-00164         tOffset = offsetof(font_mem_type, tInfo);
-00165         /* Many casts to prevent alignment warnings */
-00166         pRecord = (font_mem_type *)(void *)((char *)pCurr - tOffset);
-00167         fail(pCurr != &pRecord->tInfo);
-00168         if (pRecord->pNext == NULL) {
-00169                 /* The last record has no successor */
-00170                 return NULL;
-00171         }
-00172         return &pRecord->pNext->tInfo;
-00173 } /* end of pGetNextFontInfoListItem */
-
-
Generated by  - -doxygen 1.6.2
- - diff -r 59758314f811 -r d4524d6a4472 Symbian3/Examples/guid-6013a680-57f9-415b-8851-c4fa63356636/fonts_8c_source.html --- a/Symbian3/Examples/guid-6013a680-57f9-415b-8851-c4fa63356636/fonts_8c_source.html Fri Jun 11 15:24:34 2010 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1034 +0,0 @@ - - - - -TB9.2 Example Applications: examples/PIPS/antiword/src/fonts.c Source File - - - - - -

examples/PIPS/antiword/src/fonts.c

00001 /*
-00002  * fonts.c
-00003  * Copyright (C) 1998-2004 A.J. van Os; Released under GNU GPL
-00004  *
-00005  * Description:
-00006  * Functions to deal with fonts (generic)
-00007  */
-00008 
-00009 #include <ctype.h>
-00010 #include <string.h>
-00011 #include "antiword.h"
-00012 
-00013 /* Maximum line length in the font file */
-00014 #define FONT_LINE_LENGTH        81
-00015 
-00016 /* Pitch */
-00017 #define PITCH_UNKNOWN           0
-00018 #define PITCH_FIXED             1
-00019 #define PITCH_VARIABLE          2
-00020 
-00021 /* Font Family */
-00022 #define FAMILY_UNKNOWN          0
-00023 #define FAMILY_ROMAN            1
-00024 #define FAMILY_SWISS            2
-00025 #define FAMILY_MODERN           3
-00026 #define FAMILY_SCRIPT           4
-00027 #define FAMILY_DECORATIVE       5
-00028 
-00029 /* Font Translation Table */
-00030 static size_t           tFontTableRecords = 0;
-00031 static font_table_type  *pFontTable = NULL;
-00032 
-00033 /*
-00034  * Find the given font in the font table
-00035  *
-00036  * returns the index into the FontTable, -1 if not found
-00037  */
-00038 int
-00039 iGetFontByNumber(UCHAR ucWordFontNumber, USHORT usFontStyle)
-00040 {
-00041         int     iIndex;
-00042 
-00043         for (iIndex = 0; iIndex < (int)tFontTableRecords; iIndex++) {
-00044                 if (ucWordFontNumber == pFontTable[iIndex].ucWordFontNumber &&
-00045                     usFontStyle == pFontTable[iIndex].usFontStyle &&
-00046                     pFontTable[iIndex].szOurFontname[0] != '\0') {
-00047                         return iIndex;
-00048                 }
-00049         }
-00050         DBG_DEC(ucWordFontNumber);
-00051         DBG_HEX(usFontStyle);
-00052         return -1;
-00053 } /* end of iGetFontByNumber */
-00054 
-00055 /*
-00056  * szGetOurFontname - Get our font name
-00057  *
-00058  * return our font name from the given index, NULL if not found
-00059  */
-00060 const char *
-00061 szGetOurFontname(int iIndex)
-00062 {
-00063         if (iIndex < 0 || iIndex >= (int)tFontTableRecords) {
-00064                 return NULL;
-00065         }
-00066         return pFontTable[iIndex].szOurFontname;
-00067 } /* end of szGetOurFontname */
-00068 
-00069 /*
-00070  * Find the given font in the font table
-00071  *
-00072  * returns the Word font number, -1 if not found
-00073  */
-00074 int
-00075 iFontname2Fontnumber(const char *szOurFontname, USHORT usFontStyle)
-00076 {
-00077         int     iIndex;
-00078 
-00079         for (iIndex = 0; iIndex < (int)tFontTableRecords; iIndex++) {
-00080                 if (pFontTable[iIndex].usFontStyle == usFontStyle &&
-00081                     STREQ(pFontTable[iIndex].szOurFontname, szOurFontname)) {
-00082                         return (int)pFontTable[iIndex].ucWordFontNumber;
-00083                 }
-00084         }
-00085         return -1;
-00086 } /* end of iFontname2Fontnumber */
-00087 
-00088 /*
-00089  * szGetDefaultFont - get the default font that matches the parameters
-00090  */
-00091 static const char *
-00092 szGetDefaultFont(UCHAR ucFFN, int iEmphasis)
-00093 {
-00094         UCHAR   ucPrq, ucFf;
-00095 
-00096         fail(iEmphasis < 0 || iEmphasis > 3);
-00097 
-00098         ucPrq = ucFFN & 0x03;
-00099         ucFf = (ucFFN & 0x70) >> 4;
-00100         NO_DBG_DEC(ucPrq);
-00101         NO_DBG_DEC(ucFf);
-00102         if (ucPrq == PITCH_FIXED) {
-00103                 /* Set to the default monospaced font */
-00104                 switch (iEmphasis) {
-00105                 case 1: return FONT_MONOSPACED_BOLD;
-00106                 case 2: return FONT_MONOSPACED_ITALIC;
-00107                 case 3: return FONT_MONOSPACED_BOLDITALIC;
-00108                 default: return FONT_MONOSPACED_PLAIN;
-00109                 }
-00110         } else if (ucFf == FAMILY_ROMAN) {
-00111                 /* Set to the default serif font */
-00112                 switch (iEmphasis) {
-00113                 case 1: return FONT_SERIF_BOLD;
-00114                 case 2: return FONT_SERIF_ITALIC;
-00115                 case 3: return FONT_SERIF_BOLDITALIC;
-00116                 default: return FONT_SERIF_PLAIN;
-00117                 }
-00118         } else if (ucFf == FAMILY_SWISS) {
-00119                 /* Set to the default sans serif font */
-00120                 switch (iEmphasis) {
-00121                 case 1: return FONT_SANS_SERIF_BOLD;
-00122                 case 2: return FONT_SANS_SERIF_ITALIC;
-00123                 case 3: return FONT_SANS_SERIF_BOLDITALIC;
-00124                 default: return FONT_SANS_SERIF_PLAIN;
-00125                 }
-00126         } else {
-00127                 /* Set to the default default font */
-00128                 switch (iEmphasis) {
-00129                 case 1: return FONT_SERIF_BOLD;
-00130                 case 2: return FONT_SERIF_ITALIC;
-00131                 case 3: return FONT_SERIF_BOLDITALIC;
-00132                 default: return FONT_SERIF_PLAIN;
-00133                 }
-00134         }
-00135 } /* end of szGetDefaultFont */
-00136 
-00137 /*
-00138  * See if the fontname from the Word file matches the fontname from the
-00139  * font translation file.
-00140  * If iBytesPerChar is one than aucWord is in ISO-8859-x (Word 2/6/7),
-00141  * if iBytesPerChar is two than aucWord is in Unicode (Word 8/9/10).
-00142  */
-00143 static BOOL
-00144 bFontEqual(const UCHAR *aucWord, const char *szTable, int iBytesPerChar)
-00145 {
-00146         const UCHAR     *pucTmp;
-00147         const char      *pcTmp;
-00148 
-00149         fail(aucWord == NULL || szTable == NULL);
-00150         fail(iBytesPerChar != 1 && iBytesPerChar != 2);
-00151 
-00152         for (pucTmp = aucWord, pcTmp = szTable;
-00153              *pucTmp != 0;
-00154              pucTmp += iBytesPerChar, pcTmp++) {
-00155                 if (ulToUpper((ULONG)*pucTmp) !=
-00156                     ulToUpper((ULONG)(UCHAR)*pcTmp)) {
-00157                         return FALSE;
-00158                 }
-00159         }
-00160         return *pcTmp == '\0';
-00161 } /* end of bFontEqual */
-00162 
-00163 /*
-00164  * vFontname2Table - add fontnames to the font table
-00165  */
-00166 static void
-00167 vFontname2Table(const UCHAR *aucFont, const UCHAR *aucAltFont,
-00168         int iBytesPerChar, int iEmphasis, UCHAR ucFFN,
-00169         const char *szWordFont, const char *szOurFont,
-00170         font_table_type *pFontTableRecord)
-00171 {
-00172         BOOL    bMatchFound;
-00173 
-00174         fail(aucFont == NULL || aucFont[0] == 0);
-00175         fail(aucAltFont != NULL && aucAltFont[0] == 0);
-00176         fail(iBytesPerChar != 1 && iBytesPerChar != 2);
-00177         fail(iEmphasis < 0 || iEmphasis > 3);
-00178         fail(szWordFont == NULL || szWordFont[0] == '\0');
-00179         fail(szOurFont == NULL || szOurFont[0] == '\0');
-00180         fail(pFontTableRecord == NULL);
-00181 
-00182         bMatchFound = bFontEqual(aucFont, szWordFont, iBytesPerChar);
-00183 
-00184         if (!bMatchFound && aucAltFont != NULL) {
-00185                 bMatchFound = bFontEqual(aucAltFont, szWordFont, iBytesPerChar);
-00186         }
-00187 
-00188         if (!bMatchFound &&
-00189             pFontTableRecord->szWordFontname[0] == '\0' &&
-00190             szWordFont[0] == '*' &&
-00191             szWordFont[1] == '\0') {
-00192                 /*
-00193                  * szWordFont contains a "*", so szOurFont will contain the
-00194                  * "default default" font. See if we can do better than that.
-00195                  */
-00196                 szOurFont = szGetDefaultFont(ucFFN, iEmphasis);
-00197                 bMatchFound = TRUE;
-00198         }
-00199 
-00200         if (bMatchFound) {
-00201                 switch (iBytesPerChar) {
-00202                 case 1:
-00203                         (void)strncpy(pFontTableRecord->szWordFontname,
-00204                                 (const char *)aucFont,
-00205                                 sizeof(pFontTableRecord->szWordFontname) - 1);
-00206                         break;
-00207                 case 2:
-00208                         (void)unincpy(pFontTableRecord->szWordFontname,
-00209                                 aucFont,
-00210                                 sizeof(pFontTableRecord->szWordFontname) - 1);
-00211                         break;
-00212                 default:
-00213                         DBG_FIXME();
-00214                         pFontTableRecord->szWordFontname[0] = '\0';
-00215                         break;
-00216                 }
-00217                 pFontTableRecord->szWordFontname[
-00218                         sizeof(pFontTableRecord->szWordFontname) - 1] = '\0';
-00219                 (void)strncpy(pFontTableRecord->szOurFontname, szOurFont,
-00220                         sizeof(pFontTableRecord->szOurFontname) - 1);
-00221                 pFontTableRecord->szOurFontname[
-00222                         sizeof(pFontTableRecord->szOurFontname) - 1] = '\0';
-00223                 NO_DBG_MSG(pFontTableRecord->szWordFontname);
-00224                 NO_DBG_MSG(pFontTableRecord->szOurFontname);
-00225                 pFontTableRecord->ucFFN = ucFFN;
-00226                 pFontTableRecord->ucEmphasis = (UCHAR)iEmphasis;
-00227         }
-00228 } /* end of vFontname2Table */
-00229 
-00230 /*
-00231  * vCreateFontTable - Create and initialize the internal font table
-00232  */
-00233 static void
-00234 vCreateFontTable(void)
-00235 {
-00236         font_table_type *pTmp;
-00237         int     iNbr;
-00238 
-00239         if (tFontTableRecords == 0) {
-00240                 pFontTable = xfree(pFontTable);
-00241                 return;
-00242         }
-00243 
-00244         /* Create the font table */
-00245         pFontTable = xcalloc(tFontTableRecords, sizeof(*pFontTable));
-00246 
-00247         /* Initialize the font table */
-00248         for (iNbr = 0, pTmp = pFontTable;
-00249              pTmp < pFontTable + tFontTableRecords;
-00250              iNbr++, pTmp++) {
-00251                 pTmp->ucWordFontNumber = (UCHAR)(iNbr / 4);
-00252                 switch (iNbr % 4) {
-00253                 case 0:
-00254                         pTmp->usFontStyle = FONT_REGULAR;
-00255                         break;
-00256                 case 1:
-00257                         pTmp->usFontStyle = FONT_BOLD;
-00258                         break;
-00259                 case 2:
-00260                         pTmp->usFontStyle = FONT_ITALIC;
-00261                         break;
-00262                 case 3:
-00263                         pTmp->usFontStyle = FONT_BOLD|FONT_ITALIC;
-00264                         break;
-00265                 default:
-00266                         DBG_DEC(iNbr);
-00267                         break;
-00268                 }
-00269         }
-00270 } /* end of vCreateFontTable */
-00271 
-00272 /*
-00273  * vMinimizeFontTable - make the font table as small as possible
-00274  */
-00275 static void
-00276 vMinimizeFontTable(void)
-00277 {
-00278         font_block_type         tFontNext;
-00279         const style_block_type  *pStyle;
-00280         const font_block_type   *pFont;
-00281         font_table_type         *pTmp;
-00282         int     iUnUsed;
-00283         BOOL    bMustAddTableFont;
-00284 
-00285         NO_DBG_MSG("vMinimizeFontTable");
-00286 
-00287         if (tFontTableRecords == 0) {
-00288                 pFontTable = xfree(pFontTable);
-00289                 return;
-00290         }
-00291 
-00292         /* See if we must add a font for our tables */
-00293         bMustAddTableFont = TRUE;
-00294 
-00295 #if 0
-00296         DBG_MSG("Before");
-00297         DBG_DEC(tFontTableRecords);
-00298         for (pTmp = pFontTable;
-00299              pTmp < pFontTable + tFontTableRecords;
-00300              pTmp++) {
-00301                 DBG_DEC(pTmp->ucWordFontNumber);
-00302                 DBG_HEX(pTmp->usFontStyle);
-00303                 DBG_MSG(pTmp->szWordFontname);
-00304                 DBG_MSG(pTmp->szOurFontname);
-00305         }
-00306 #endif /* DEBUG */
-00307 
-00308         /* See which fonts/styles we really need */
-00309 
-00310         /* Default font/style is by definition in use */
-00311         pFontTable[0].ucInUse = 1;
-00312 
-00313         /* Make InUse 1 for all the fonts/styles that WILL be used */
-00314         pFont = NULL;
-00315         while((pFont = pGetNextFontInfoListItem(pFont)) != NULL) {
-00316                 pTmp = pFontTable + 4 * (int)pFont->ucFontNumber;
-00317                 if (bIsBold(pFont->usFontStyle)) {
-00318                         pTmp++;
-00319                 }
-00320                 if (bIsItalic(pFont->usFontStyle)) {
-00321                         pTmp += 2;
-00322                 }
-00323                 if (pTmp >= pFontTable + tFontTableRecords) {
-00324                         continue;
-00325                 }
-00326                 if (STREQ(pTmp->szOurFontname, TABLE_FONT)) {
-00327                         /* The table font is already present */
-00328                         bMustAddTableFont = FALSE;
-00329                 }
-00330                 pTmp->ucInUse = 1;
-00331         }
-00332 
-00333         /* Make InUse 1 for all the fonts/styles that MIGHT be used */
-00334         pStyle = NULL;
-00335         while((pStyle = pGetNextStyleInfoListItem(pStyle)) != NULL) {
-00336                 vFillFontFromStylesheet(pStyle->usIstdNext, &tFontNext);
-00337                 vCorrectFontValues(&tFontNext);
-00338                 pTmp = pFontTable + 4 * (int)tFontNext.ucFontNumber;
-00339                 if (bIsBold(tFontNext.usFontStyle)) {
-00340                         pTmp++;
-00341                 }
-00342                 if (bIsItalic(tFontNext.usFontStyle)) {
-00343                         pTmp += 2;
-00344                 }
-00345                 if (pTmp >= pFontTable + tFontTableRecords) {
-00346                         continue;
-00347                 }
-00348                 if (STREQ(pTmp->szOurFontname, TABLE_FONT)) {
-00349                         /* The table font is already present */
-00350                         bMustAddTableFont = FALSE;
-00351                 }
-00352                 pTmp->ucInUse = 1;
-00353         }
-00354 
-00355         /* Remove the unused font entries from the font table */
-00356         iUnUsed = 0;
-00357         for (pTmp = pFontTable;
-00358              pTmp < pFontTable + tFontTableRecords;
-00359              pTmp++) {
-00360                 if (pTmp->ucInUse == 0) {
-00361                         iUnUsed++;
-00362                         continue;
-00363                 }
-00364                 if (iUnUsed > 0) {
-00365                         fail(pTmp - iUnUsed <= pFontTable);
-00366                         *(pTmp - iUnUsed) = *pTmp;
-00367                 }
-00368         }
-00369         fail(iUnUsed < 0);
-00370         fail(tFontTableRecords <= (size_t)iUnUsed);
-00371         tFontTableRecords -= (size_t)iUnUsed;
-00372 
-00373         if (bMustAddTableFont) {
-00374                 pTmp = pFontTable + tFontTableRecords;
-00375                 fail(pTmp <= pFontTable);
-00376                 pTmp->ucWordFontNumber = (pTmp - 1)->ucWordFontNumber + 1;
-00377                 pTmp->usFontStyle = FONT_REGULAR;
-00378                 pTmp->ucInUse = 1;
-00379                 strcpy(pTmp->szWordFontname, "Extra Table Font");
-00380                 strcpy(pTmp->szOurFontname, TABLE_FONT);
-00381                 tFontTableRecords++;
-00382                 iUnUsed--;
-00383         }
-00384         if (iUnUsed > 0) {
-00385                 /* Resize the font table */
-00386                 pFontTable = xrealloc(pFontTable,
-00387                                 tFontTableRecords * sizeof(*pFontTable));
-00388         }
-00389 #if defined(DEBUG)
-00390         DBG_MSG("After");
-00391         DBG_DEC(tFontTableRecords);
-00392         for (pTmp = pFontTable;
-00393              pTmp < pFontTable + tFontTableRecords;
-00394              pTmp++) {
-00395                 DBG_DEC(pTmp->ucWordFontNumber);
-00396                 DBG_HEX(pTmp->usFontStyle);
-00397                 DBG_MSG(pTmp->szWordFontname);
-00398                 DBG_MSG(pTmp->szOurFontname);
-00399         }
-00400 #endif /* DEBUG */
-00401 } /* end of vMinimizeFontTable */
-00402 
-00403 /*
-00404  * bReadFontFile - read and check a line from the font translation file
-00405  *
-00406  * returns TRUE when a correct line has been read, otherwise FALSE
-00407  */
-00408 static BOOL
-00409 bReadFontFile(FILE *pFontTableFile, char *szWordFont,
-00410         int *piItalic, int *piBold, char *szOurFont, int *piSpecial)
-00411 {
-00412         char    *pcTmp;
-00413         int     iFields;
-00414         char    szLine[FONT_LINE_LENGTH];
-00415 
-00416         fail(szWordFont == NULL || szOurFont == NULL);
-00417         fail(piItalic == NULL || piBold == NULL || piSpecial == NULL);
-00418 
-00419         while (fgets(szLine, (int)sizeof(szLine), pFontTableFile) != NULL) {
-00420                 if (szLine[0] == '#' ||
-00421                     szLine[0] == '\n' ||
-00422                     szLine[0] == '\r') {
-00423                         continue;
-00424                 }
-00425                 iFields = sscanf(szLine, "%[^,],%d,%d,%1s%[^,],%d",
-00426                         szWordFont, piItalic, piBold,
-00427                         &szOurFont[0], &szOurFont[1], piSpecial);
-00428                 if (iFields != 6) {
-00429                         pcTmp = strchr(szLine, '\r');
-00430                         if (pcTmp != NULL) {
-00431                                 *pcTmp = '\0';
-00432                         }
-00433                         pcTmp = strchr(szLine, '\n');
-00434                         if (pcTmp != NULL) {
-00435                                 *pcTmp = '\0';
-00436                         }
-00437                         DBG_DEC(iFields);
-00438                         werr(0, "Syntax error in: '%s'", szLine);
-00439                         continue;
-00440                 }
-00441                 if (strlen(szWordFont) >=
-00442                                 sizeof(pFontTable[0].szWordFontname)) {
-00443                         werr(0, "Word fontname too long: '%s'", szWordFont);
-00444                         continue;
-00445                 }
-00446                 if (strlen(szOurFont) >=
-00447                                 sizeof(pFontTable[0].szOurFontname)) {
-00448                         werr(0, "Local fontname too long: '%s'", szOurFont);
-00449                         continue;
-00450                 }
-00451                 /* The current line passed all the tests */
-00452                 return TRUE;
-00453         }
-00454         return FALSE;
-00455 } /* end of bReadFontFile */
-00456 
-00457 /*
-00458  * vCreate0FontTable - create a font table from Word for DOS
-00459  */
-00460 void
-00461 vCreate0FontTable(void)
-00462 {
-00463         FILE    *pFontTableFile;
-00464         font_table_type *pTmp;
-00465         UCHAR   *aucFont;
-00466         int     iBold, iItalic, iSpecial, iEmphasis, iFtc;
-00467         UCHAR   ucPrq, ucFf, ucFFN;
-00468         char    szWordFont[FONT_LINE_LENGTH], szOurFont[FONT_LINE_LENGTH];
-00469 
-00470         tFontTableRecords = 0;
-00471         pFontTable = xfree(pFontTable);
-00472 
-00473         pFontTableFile = pOpenFontTableFile();
-00474         if (pFontTableFile == NULL) {
-00475                 /* No translation table file, no translation table */
-00476                 return;
-00477         }
-00478 
-00479         /* Get the maximum number of entries in the font table */
-00480         tFontTableRecords = 64;
-00481         tFontTableRecords *= 4; /* Plain, Bold, Italic and Bold/italic */
-00482         tFontTableRecords++;    /* One extra for the table-font */
-00483         vCreateFontTable();
-00484 
-00485         /* Read the font translation file */
-00486         iItalic = 0;
-00487         iBold = 0;
-00488         iSpecial = 0;
-00489         while (bReadFontFile(pFontTableFile, szWordFont,
-00490                         &iItalic, &iBold, szOurFont, &iSpecial)) {
-00491                 iEmphasis = 0;
-00492                 if (iBold != 0) {
-00493                         iEmphasis++;
-00494                 }
-00495                 if (iItalic != 0) {
-00496                         iEmphasis += 2;
-00497                 }
-00498                 for (iFtc = 0, pTmp = pFontTable + iEmphasis;
-00499                      pTmp < pFontTable + tFontTableRecords;
-00500                      iFtc++, pTmp += 4) {
-00501                         if (iFtc >= 16 && iFtc <= 55) {
-00502                                 ucPrq = PITCH_VARIABLE;
-00503                                 ucFf = FAMILY_ROMAN;
-00504                                 aucFont = (UCHAR *)"Times";
-00505                         } else {
-00506                                 ucPrq = PITCH_FIXED;
-00507                                 ucFf = FAMILY_MODERN;
-00508                                 aucFont = (UCHAR *)"Courier";
-00509                         }
-00510                         ucFFN = (ucFf << 4) | ucPrq;
-00511                         vFontname2Table(aucFont, NULL, 1, iEmphasis,
-00512                                         ucFFN, szWordFont, szOurFont, pTmp);
-00513                 }
-00514         }
-00515         (void)fclose(pFontTableFile);
-00516         vMinimizeFontTable();
-00517 } /* end of vCreate0FontTable */
-00518 
-00519 /*
-00520  * vCreate2FontTable - create a font table from WinWord 1/2
-00521  */
-00522 void
-00523 vCreate2FontTable(FILE *pFile, int iWordVersion, const UCHAR *aucHeader)
-00524 {
-00525         FILE    *pFontTableFile;
-00526         font_table_type *pTmp;
-00527         UCHAR   *aucFont;
-00528         UCHAR   *aucBuffer;
-00529         ULONG   ulBeginFontInfo;
-00530         size_t  tFontInfoLen;
-00531         int     iPos, iOff, iRecLen;
-00532         int     iBold, iItalic, iSpecial, iEmphasis;
-00533         UCHAR   ucFFN;
-00534         char    szWordFont[FONT_LINE_LENGTH], szOurFont[FONT_LINE_LENGTH];
-00535 
-00536         fail(pFile == NULL || aucHeader == NULL);
-00537         fail(iWordVersion != 1 && iWordVersion != 2);
-00538 
-00539         tFontTableRecords = 0;
-00540         pFontTable = xfree(pFontTable);
-00541 
-00542         pFontTableFile = pOpenFontTableFile();
-00543         if (pFontTableFile == NULL) {
-00544                 /* No translation table file, no translation table */
-00545                 return;
-00546         }
-00547 
-00548         ulBeginFontInfo = ulGetLong(0xb2, aucHeader); /* fcSttbfffn */
-00549         DBG_HEX(ulBeginFontInfo);
-00550         tFontInfoLen = (size_t)usGetWord(0xb6, aucHeader); /* cbSttbfffn */
-00551         DBG_DEC(tFontInfoLen);
-00552 
-00553         if (ulBeginFontInfo > (ULONG)LONG_MAX || tFontInfoLen == 0) {
-00554                 /* Don't ask me why this is needed */
-00555                 DBG_HEX_C(tFontInfoLen != 0, ulBeginFontInfo);
-00556                 (void)fclose(pFontTableFile);
-00557                 return;
-00558         }
-00559 
-00560         aucBuffer = xmalloc(tFontInfoLen);
-00561         if (!bReadBytes(aucBuffer, tFontInfoLen, ulBeginFontInfo, pFile)) {
-00562                 aucBuffer = xfree(aucBuffer);
-00563                 (void)fclose(pFontTableFile);
-00564                 return;
-00565         }
-00566         NO_DBG_PRINT_BLOCK(aucBuffer, tFontInfoLen);
-00567         DBG_DEC(usGetWord(0, aucBuffer));
-00568 
-00569         /* Compute the maximum number of entries in the font table */
-00570         if (iWordVersion == 1) {
-00571                 fail(tFontInfoLen < 2);
-00572                 /* WinWord 1 has three implicit fonts */
-00573                 tFontTableRecords = 3;
-00574                 iOff = 2;
-00575         } else {
-00576                 fail(tFontInfoLen < 6);
-00577                 /* WinWord 2 and up have no implicit fonts */
-00578                 tFontTableRecords = 0;
-00579                 iOff = 3;
-00580         }
-00581         iPos = 2;
-00582         while (iPos + iOff < (int)tFontInfoLen) {
-00583                 iRecLen = (int)ucGetByte(iPos, aucBuffer);
-00584                 NO_DBG_DEC(iRecLen);
-00585                 NO_DBG_MSG(aucBuffer + iPos + iOff);
-00586                 iPos += iRecLen + 1;
-00587                 tFontTableRecords++;
-00588         }
-00589         tFontTableRecords *= 4; /* Plain, Bold, Italic and Bold/Italic */
-00590         tFontTableRecords++;    /* One extra for the table-font */
-00591         vCreateFontTable();
-00592 
-00593         /* Add the tree implicit fonts (in four variations) */
-00594         if (iWordVersion == 1) {
-00595                 fail(tFontTableRecords < 13);
-00596                 vFontname2Table((UCHAR *)"Tms Rmn", NULL, 1, 0,
-00597                         (UCHAR)((FAMILY_ROMAN << 4) | PITCH_VARIABLE),
-00598                         "*", "Times-Roman", pFontTable + 0);
-00599                 vFontname2Table((UCHAR *)"Tms Rmn", NULL, 1, 1,
-00600                         (UCHAR)((FAMILY_ROMAN << 4) | PITCH_VARIABLE),
-00601                         "*", "Times-Bold", pFontTable + 1);
-00602                 vFontname2Table((UCHAR *)"Tms Rmn", NULL, 1, 2,
-00603                         (UCHAR)((FAMILY_ROMAN << 4) | PITCH_VARIABLE),
-00604                         "*", "Times-Italic", pFontTable + 2);
-00605                 vFontname2Table((UCHAR *)"Tms Rmn", NULL, 1, 3,
-00606                         (UCHAR)((FAMILY_ROMAN << 4) | PITCH_VARIABLE),
-00607                         "*", "Times-BoldItalic", pFontTable + 3);
-00608                 vFontname2Table((UCHAR *)"Symbol", NULL, 1, 0,
-00609                         (UCHAR)((FAMILY_ROMAN << 4) | PITCH_VARIABLE),
-00610                         "*", "Times-Roman", pFontTable + 4);
-00611                 vFontname2Table((UCHAR *)"Symbol", NULL, 1, 1,
-00612                         (UCHAR)((FAMILY_ROMAN << 4) | PITCH_VARIABLE),
-00613                         "*", "Times-Bold", pFontTable + 5);
-00614                 vFontname2Table((UCHAR *)"Symbol", NULL, 1, 2,
-00615                         (UCHAR)((FAMILY_ROMAN << 4) | PITCH_VARIABLE),
-00616                         "*", "Times-Italic", pFontTable + 6);
-00617                 vFontname2Table((UCHAR *)"Symbol", NULL, 1, 3,
-00618                         (UCHAR)((FAMILY_ROMAN << 4) | PITCH_VARIABLE),
-00619                         "*", "Times-BoldItalic", pFontTable + 7);
-00620                 vFontname2Table((UCHAR *)"Helv", NULL, 1, 0,
-00621                         (UCHAR)((FAMILY_SWISS << 4) | PITCH_VARIABLE),
-00622                         "*", "Helvetica", pFontTable + 8);
-00623                 vFontname2Table((UCHAR *)"Helv", NULL, 1, 1,
-00624                         (UCHAR)((FAMILY_SWISS << 4) | PITCH_VARIABLE),
-00625                         "*", "Helvetica-Bold", pFontTable + 9);
-00626                 vFontname2Table((UCHAR *)"Helv", NULL, 1, 2,
-00627                         (UCHAR)((FAMILY_SWISS << 4) | PITCH_VARIABLE),
-00628                         "*", "Helvetica-Oblique", pFontTable + 10);
-00629                 vFontname2Table((UCHAR *)"Helv", NULL, 1, 3,
-00630                         (UCHAR)((FAMILY_SWISS << 4) | PITCH_VARIABLE),
-00631                         "*", "Helvetica-BoldOblique", pFontTable + 11);
-00632         }
-00633 
-00634         /* Read the font translation file */
-00635         iItalic = 0;
-00636         iBold = 0;
-00637         iSpecial = 0;
-00638         while (bReadFontFile(pFontTableFile, szWordFont,
-00639                         &iItalic, &iBold, szOurFont, &iSpecial)) {
-00640                 iEmphasis = 0;
-00641                 if (iBold != 0) {
-00642                         iEmphasis++;
-00643                 }
-00644                 if (iItalic != 0) {
-00645                         iEmphasis += 2;
-00646                 }
-00647                 pTmp = pFontTable + iEmphasis;
-00648                 iPos = 2;
-00649                 while (iPos + iOff < (int)tFontInfoLen) {
-00650                         iRecLen = (int)ucGetByte(iPos, aucBuffer);
-00651                         ucFFN = ucGetByte(iPos + 1, aucBuffer);
-00652                         aucFont = aucBuffer + iPos + iOff;
-00653                         vFontname2Table(aucFont, NULL, 1, iEmphasis,
-00654                                         ucFFN, szWordFont, szOurFont, pTmp);
-00655                         pTmp += 4;
-00656                         iPos += iRecLen + 1;
-00657                 }
-00658         }
-00659         (void)fclose(pFontTableFile);
-00660         aucBuffer = xfree(aucBuffer);
-00661         vMinimizeFontTable();
-00662 } /* end of vCreate2FontTable */
-00663 
-00664 /*
-00665  * vCreate6FontTable - create a font table from Word 6/7
-00666  */
-00667 void
-00668 vCreate6FontTable(FILE *pFile, ULONG ulStartBlock,
-00669         const ULONG *aulBBD, size_t tBBDLen,
-00670         const UCHAR *aucHeader)
-00671 {
-00672         FILE    *pFontTableFile;
-00673         font_table_type *pTmp;
-00674         UCHAR   *aucFont, *aucAltFont;
-00675         UCHAR   *aucBuffer;
-00676         ULONG   ulBeginFontInfo;
-00677         size_t  tFontInfoLen;
-00678         int     iPos, iRecLen, iOffsetAltName;
-00679         int     iBold, iItalic, iSpecial, iEmphasis;
-00680         UCHAR   ucFFN;
-00681         char    szWordFont[FONT_LINE_LENGTH], szOurFont[FONT_LINE_LENGTH];
-00682 
-00683         fail(pFile == NULL || aucHeader == NULL);
-00684         fail(ulStartBlock > MAX_BLOCKNUMBER && ulStartBlock != END_OF_CHAIN);
-00685         fail(aulBBD == NULL);
-00686 
-00687         tFontTableRecords = 0;
-00688         pFontTable = xfree(pFontTable);
-00689 
-00690         pFontTableFile = pOpenFontTableFile();
-00691         if (pFontTableFile == NULL) {
-00692                 /* No translation table file, no translation table */
-00693                 return;
-00694         }
-00695 
-00696         ulBeginFontInfo = ulGetLong(0xd0, aucHeader); /* fcSttbfffn */
-00697         DBG_HEX(ulBeginFontInfo);
-00698         tFontInfoLen = (size_t)ulGetLong(0xd4, aucHeader); /* lcbSttbfffn */
-00699         DBG_DEC(tFontInfoLen);
-00700         fail(tFontInfoLen < 9);
-00701 
-00702         aucBuffer = xmalloc(tFontInfoLen);
-00703         if (!bReadBuffer(pFile, ulStartBlock,
-00704                         aulBBD, tBBDLen, BIG_BLOCK_SIZE,
-00705                         aucBuffer, ulBeginFontInfo, tFontInfoLen)) {
-00706                 aucBuffer = xfree(aucBuffer);
-00707                 (void)fclose(pFontTableFile);
-00708                 return;
-00709         }
-00710         DBG_DEC(usGetWord(0, aucBuffer));
-00711 
-00712         /* Compute the maximum number of entries in the font table */
-00713         tFontTableRecords = 0;
-00714         iPos = 2;
-00715         while (iPos + 6 < (int)tFontInfoLen) {
-00716                 iRecLen = (int)ucGetByte(iPos, aucBuffer);
-00717                 NO_DBG_DEC(iRecLen);
-00718                 iOffsetAltName = (int)ucGetByte(iPos + 5, aucBuffer);
-00719                 NO_DBG_MSG(aucBuffer + iPos + 6);
-00720                 NO_DBG_MSG_C(iOffsetAltName > 0,
-00721                                 aucBuffer + iPos + 6 + iOffsetAltName);
-00722                 iPos += iRecLen + 1;
-00723                 tFontTableRecords++;
-00724         }
-00725         tFontTableRecords *= 4; /* Plain, Bold, Italic and Bold/italic */
-00726         tFontTableRecords++;    /* One extra for the table-font */
-00727         vCreateFontTable();
-00728 
-00729         /* Read the font translation file */
-00730         iItalic = 0;
-00731         iBold = 0;
-00732         iSpecial = 0;
-00733         while (bReadFontFile(pFontTableFile, szWordFont,
-00734                         &iItalic, &iBold, szOurFont, &iSpecial)) {
-00735                 iEmphasis = 0;
-00736                 if (iBold != 0) {
-00737                         iEmphasis++;
-00738                 }
-00739                 if (iItalic != 0) {
-00740                         iEmphasis += 2;
-00741                 }
-00742                 pTmp = pFontTable + iEmphasis;
-00743                 iPos = 2;
-00744                 while (iPos + 6 < (int)tFontInfoLen) {
-00745                         iRecLen = (int)ucGetByte(iPos, aucBuffer);
-00746                         ucFFN = ucGetByte(iPos + 1, aucBuffer);
-00747                         aucFont = aucBuffer + iPos + 6;
-00748                         iOffsetAltName = (int)ucGetByte(iPos + 5, aucBuffer);
-00749                         if (iOffsetAltName <= 0) {
-00750                                 aucAltFont = NULL;
-00751                         } else {
-00752                                 aucAltFont = aucFont + iOffsetAltName;
-00753                                 NO_DBG_MSG(aucFont);
-00754                                 NO_DBG_MSG(aucAltFont);
-00755                         }
-00756                         vFontname2Table(aucFont, aucAltFont, 1, iEmphasis,
-00757                                         ucFFN, szWordFont, szOurFont, pTmp);
-00758                         pTmp += 4;
-00759                         iPos += iRecLen + 1;
-00760                 }
-00761         }
-00762         (void)fclose(pFontTableFile);
-00763         aucBuffer = xfree(aucBuffer);
-00764         vMinimizeFontTable();
-00765 } /* end of vCreate6FontTable */
-00766 
-00767 /*
-00768  * vCreate8FontTable - create a font table from Word 8/9/10
-00769  */
-00770 void
-00771 vCreate8FontTable(FILE *pFile, const pps_info_type *pPPS,
-00772         const ULONG *aulBBD, size_t tBBDLen,
-00773         const ULONG *aulSBD, size_t tSBDLen,
-00774         const UCHAR *aucHeader)
-00775 {
-00776         FILE    *pFontTableFile;
-00777         font_table_type *pTmp;
-00778         const ULONG     *aulBlockDepot;
-00779         UCHAR   *aucFont, *aucAltFont;
-00780         UCHAR   *aucBuffer;
-00781         ULONG   ulBeginFontInfo;
-00782         size_t  tFontInfoLen, tBlockDepotLen, tBlockSize;
-00783         int     iPos, iRecLen, iOffsetAltName;
-00784         int     iBold, iItalic, iSpecial, iEmphasis;
-00785         UCHAR   ucFFN;
-00786         char    szWordFont[FONT_LINE_LENGTH], szOurFont[FONT_LINE_LENGTH];
-00787 
-00788         fail(pFile == NULL || pPPS == NULL || aucHeader == NULL);
-00789         fail(aulBBD == NULL || aulSBD == NULL);
-00790 
-00791         tFontTableRecords = 0;
-00792         pFontTable = xfree(pFontTable);
-00793 
-00794         pFontTableFile = pOpenFontTableFile();
-00795         if (pFontTableFile == NULL) {
-00796                 /* No translation table file, no translation table */
-00797                 return;
-00798         }
-00799 
-00800         ulBeginFontInfo = ulGetLong(0x112, aucHeader); /* fcSttbfffn */
-00801         DBG_HEX(ulBeginFontInfo);
-00802         tFontInfoLen = (size_t)ulGetLong(0x116, aucHeader); /* lcbSttbfffn */
-00803         DBG_DEC(tFontInfoLen);
-00804         fail(tFontInfoLen < 46);
-00805 
-00806         DBG_DEC(pPPS->tTable.ulSB);
-00807         DBG_HEX(pPPS->tTable.ulSize);
-00808         if (pPPS->tTable.ulSize == 0) {
-00809                 DBG_MSG("No fontname table");
-00810                 (void)fclose(pFontTableFile);
-00811                 return;
-00812         }
-00813 
-00814         if (pPPS->tTable.ulSize < MIN_SIZE_FOR_BBD_USE) {
-00815                 /* Use the Small Block Depot */
-00816                 aulBlockDepot = aulSBD;
-00817                 tBlockDepotLen = tSBDLen;
-00818                 tBlockSize = SMALL_BLOCK_SIZE;
-00819         } else {
-00820                 /* Use the Big Block Depot */
-00821                 aulBlockDepot = aulBBD;
-00822                 tBlockDepotLen = tBBDLen;
-00823                 tBlockSize = BIG_BLOCK_SIZE;
-00824         }
-00825         aucBuffer = xmalloc(tFontInfoLen);
-00826         if (!bReadBuffer(pFile, pPPS->tTable.ulSB,
-00827                         aulBlockDepot, tBlockDepotLen, tBlockSize,
-00828                         aucBuffer, ulBeginFontInfo, tFontInfoLen)) {
-00829                 aucBuffer = xfree(aucBuffer);
-00830                 (void)fclose(pFontTableFile);
-00831                 return;
-00832         }
-00833         NO_DBG_PRINT_BLOCK(aucBuffer, tFontInfoLen);
-00834 
-00835         /* Get the maximum number of entries in the font table */
-00836         tFontTableRecords = (size_t)usGetWord(0, aucBuffer);
-00837         tFontTableRecords *= 4; /* Plain, Bold, Italic and Bold/italic */
-00838         tFontTableRecords++;    /* One extra for the table-font */
-00839         vCreateFontTable();
-00840 
-00841         /* Read the font translation file */
-00842         iItalic = 0;
-00843         iBold = 0;
-00844         iSpecial = 0;
-00845         while (bReadFontFile(pFontTableFile, szWordFont,
-00846                         &iItalic, &iBold, szOurFont, &iSpecial)) {
-00847                 iEmphasis = 0;
-00848                 if (iBold != 0) {
-00849                         iEmphasis++;
-00850                 }
-00851                 if (iItalic != 0) {
-00852                         iEmphasis += 2;
-00853                 }
-00854                 pTmp = pFontTable + iEmphasis;
-00855                 iPos = 4;
-00856                 while (iPos + 40 < (int)tFontInfoLen) {
-00857                         iRecLen = (int)ucGetByte(iPos, aucBuffer);
-00858                         ucFFN = ucGetByte(iPos + 1, aucBuffer);
-00859                         aucFont = aucBuffer + iPos + 40;
-00860                         iOffsetAltName = (int)unilen(aucFont);
-00861                         if (iPos + 40 + iOffsetAltName + 4 >= iRecLen) {
-00862                                 aucAltFont = NULL;
-00863                         } else {
-00864                                 aucAltFont = aucFont + iOffsetAltName + 2;
-00865                                 NO_DBG_UNICODE(aucFont);
-00866                                 NO_DBG_UNICODE(aucAltFont);
-00867                         }
-00868                         vFontname2Table(aucFont, aucAltFont, 2, iEmphasis,
-00869                                         ucFFN, szWordFont, szOurFont, pTmp);
-00870                         pTmp += 4;
-00871                         iPos += iRecLen + 1;
-00872                 }
-00873         }
-00874         (void)fclose(pFontTableFile);
-00875         aucBuffer = xfree(aucBuffer);
-00876         vMinimizeFontTable();
-00877 } /* end of vCreate8FontTable */
-00878 
-00879 /*
-00880  * Destroy the internal font table by freeing its memory
-00881  */
-00882 void
-00883 vDestroyFontTable(void)
-00884 {
-00885         DBG_MSG("vDestroyFontTable");
-00886 
-00887         tFontTableRecords = 0;
-00888         pFontTable = xfree(pFontTable);
-00889 } /* end of vDestroyFontTable */
-00890 
-00891 /*
-00892  * pGetNextFontTableRecord
-00893  *
-00894  * returns the next record in the table or NULL if there is no next record
-00895  */
-00896 const font_table_type *
-00897 pGetNextFontTableRecord(const font_table_type *pRecordCurr)
-00898 {
-00899         size_t  tIndexCurr;
-00900 
-00901         if (pRecordCurr == NULL) {
-00902                 /* No current record, so start with the first one */
-00903                 return &pFontTable[0];
-00904         }
-00905 
-00906         if (pRecordCurr < pFontTable ||
-00907             pRecordCurr >= pFontTable + tFontTableRecords) {
-00908                 /* Not a pointer in the array */
-00909                 DBG_HEX(pRecordCurr);
-00910                 DBG_HEX(pFontTable);
-00911                 return NULL;
-00912         }
-00913 
-00914         tIndexCurr = (size_t)(pRecordCurr - pFontTable);
-00915         if (tIndexCurr + 1 < tFontTableRecords) {
-00916                 /* There is a next record, so return it */
-00917                 return &pFontTable[tIndexCurr + 1];
-00918         }
-00919         /* There is no next record */
-00920         return NULL;
-00921 } /* end of pGetNextFontTableRecord */
-00922 
-00923 /*
-00924  * tGetFontTableLength
-00925  *
-00926  * returns the number of records in the internal font table
-00927  */
-00928 size_t
-00929 tGetFontTableLength(void)
-00930 {
-00931         return tFontTableRecords;
-00932 } /* end of tGetFontTableLength */
-00933 
-00934 #if !defined(__riscos)
-00935 /*
-00936  * vCorrect4PDF - only include PDF default fonts
-00937  */
-00938 static void
-00939 vCorrect4PDF(void)
-00940 {
-00941         font_table_type *pTmp;
-00942         const char      *szOurFont;
-00943 
-00944         for (pTmp = pFontTable; pTmp < pFontTable + tFontTableRecords; pTmp++) {
-00945                 if (STRCEQ(pTmp->szOurFontname, FONT_MONOSPACED_PLAIN) ||
-00946                     STRCEQ(pTmp->szOurFontname, FONT_MONOSPACED_BOLD) ||
-00947                     STRCEQ(pTmp->szOurFontname, FONT_MONOSPACED_ITALIC) ||
-00948                     STRCEQ(pTmp->szOurFontname, FONT_MONOSPACED_BOLDITALIC) ||
-00949                     STRCEQ(pTmp->szOurFontname, FONT_SERIF_PLAIN) ||
-00950                     STRCEQ(pTmp->szOurFontname, FONT_SERIF_BOLD) ||
-00951                     STRCEQ(pTmp->szOurFontname, FONT_SERIF_ITALIC) ||
-00952                     STRCEQ(pTmp->szOurFontname, FONT_SERIF_BOLDITALIC) ||
-00953                     STRCEQ(pTmp->szOurFontname, FONT_SANS_SERIF_PLAIN) ||
-00954                     STRCEQ(pTmp->szOurFontname, FONT_SANS_SERIF_BOLD) ||
-00955                     STRCEQ(pTmp->szOurFontname, FONT_SANS_SERIF_ITALIC) ||
-00956                     STRCEQ(pTmp->szOurFontname, FONT_SANS_SERIF_BOLDITALIC)) {
-00957                         /* Already a default font */
-00958                         continue;
-00959                 }
-00960                 szOurFont =
-00961                         szGetDefaultFont(pTmp->ucFFN, (int)pTmp->ucEmphasis);
-00962                 (void)strncpy(pTmp->szOurFontname, szOurFont,
-00963                         sizeof(pTmp->szOurFontname) - 1);
-00964                 pTmp->szOurFontname[sizeof(pTmp->szOurFontname) - 1] = '\0';
-00965         }
-00966 } /* end of vCorrect4PDF */
-00967 
-00968 /*
-00969  * vCorrect4CyrPS - only include monospaced fonts
-00970  */
-00971 static void
-00972 vCorrect4CyrPS(void)
-00973 {
-00974         font_table_type *pTmp;
-00975         const char      *szOurFont;
-00976         UCHAR   ucFFN;
-00977 
-00978         ucFFN = (FAMILY_UNKNOWN << 4) | PITCH_FIXED;
-00979         for (pTmp = pFontTable; pTmp < pFontTable + tFontTableRecords; pTmp++) {
-00980                 szOurFont = szGetDefaultFont(ucFFN, (int)pTmp->ucEmphasis);
-00981                 (void)strncpy(pTmp->szOurFontname, szOurFont,
-00982                         sizeof(pTmp->szOurFontname) - 1);
-00983                 pTmp->szOurFontname[sizeof(pTmp->szOurFontname) - 1] = '\0';
-00984         }
-00985 } /* end of vCorrect4CyrPS */
-00986 #endif /* __riscos */
-00987 
-00988 /*
-00989  * vCorrectFontTable - correct the font table in special cases
-00990  */
-00991 void
-00992 vCorrectFontTable(conversion_type eConversionType, encoding_type eEncoding)
-00993 {
-00994 #if !defined(__riscos)
-00995         if (eConversionType == conversion_pdf) {
-00996                 vCorrect4PDF();
-00997         }
-00998         if (eConversionType == conversion_ps &&
-00999             eEncoding == encoding_cyrillic) {
-01000                 vCorrect4CyrPS();
-01001         }
-01002 #endif /* __riscos */
-01003 } /* end of vCorrectFontTable */
-01004 
-01005 /*
-01006  * lComputeSpaceWidth - compute the width of a space character
-01007  *
-01008  * Returns the space width in millipoints
-01009  */
-01010 long
-01011 lComputeSpaceWidth(drawfile_fontref tFontRef, USHORT usFontSize)
-01012 {
-01013         char    szSpace[] = " ";
-01014 
-01015         fail(usFontSize < MIN_FONT_SIZE || usFontSize > MAX_FONT_SIZE);
-01016 
-01017         return lComputeStringWidth(szSpace, 1, tFontRef, usFontSize);
-01018 } /* end of lComputeSpaceWidth */
-
-
Generated by  - -doxygen 1.6.2
- - diff -r 59758314f811 -r d4524d6a4472 Symbian3/Examples/guid-6013a680-57f9-415b-8851-c4fa63356636/fonts__r_8c_source.html --- a/Symbian3/Examples/guid-6013a680-57f9-415b-8851-c4fa63356636/fonts__r_8c_source.html Fri Jun 11 15:24:34 2010 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,267 +0,0 @@ - - - - -TB9.2 Example Applications: examples/PIPS/antiword/src/fonts_r.c Source File - - - - - -

examples/PIPS/antiword/src/fonts_r.c

00001 /*
-00002  * fonts_r.c
-00003  * Copyright (C) 1999-2002 A.J. van Os; Released under GPL
-00004  *
-00005  * Description:
-00006  * Functions to deal with fonts (RiscOs version)
-00007  */
-00008 
-00009 #include <stdlib.h>
-00010 #include <string.h>
-00011 #include "DeskLib:Font.h"
-00012 #include "drawfile.h"
-00013 #include "antiword.h"
-00014 
-00015 static font_handle      tFontCurr = (font_handle)-1;
-00016 
-00017 /*
-00018  * pOpenFontTableFile - open the Font translation file
-00019  * Copy the file to the proper place if necessary.
-00020  *
-00021  * Returns the file pointer or NULL
-00022  */
-00023 FILE *
-00024 pOpenFontTableFile(void)
-00025 {
-00026         FILE    *pFileR, *pFileW;
-00027         char    *szFontNamesFile;
-00028         size_t  tSize;
-00029         BOOL    bFailed;
-00030         char    acBuffer[256];
-00031 
-00032         pFileR = fopen("<AntiWord$FontNamesFile>", "r");
-00033         if (pFileR != NULL) {
-00034                 /* The font table is already in the right directory */
-00035                 return pFileR;
-00036         }
-00037 
-00038         szFontNamesFile = getenv("AntiWord$FontNamesSave");
-00039         if (szFontNamesFile == NULL) {
-00040                 werr(0, "Warning: Name of the FontNames file not found");
-00041                 return NULL;
-00042         }
-00043         DBG_MSG(szFontNamesFile);
-00044 
-00045         pFileR = fopen("<AntiWord$Dir>.Resources.Default", "r");
-00046         if (pFileR == NULL) {
-00047                 werr(0, "I can't find 'Resources.Default'");
-00048                 return NULL;
-00049         }
-00050         /* Here the default font translation table is known to exist */
-00051 
-00052         if (!bMakeDirectory(szFontNamesFile)) {
-00053                 werr(0,
-00054                 "I can't make a directory for the FontNames file");
-00055                 return NULL;
-00056         }
-00057         /* Here the proper directory is known to exist */
-00058 
-00059         pFileW = fopen(szFontNamesFile, "w");
-00060         if (pFileW == NULL) {
-00061                 (void)fclose(pFileR);
-00062                 werr(0, "I can't create a default FontNames file");
-00063                 return NULL;
-00064         }
-00065         /* Here the proper directory is known to be writeable */
-00066 
-00067         /* Copy the default FontNames file */
-00068         bFailed = FALSE;
-00069         while (!feof(pFileR)) {
-00070                 tSize = fread(acBuffer, 1, sizeof(acBuffer), pFileR);
-00071                 if (ferror(pFileR)) {
-00072                         DBG_MSG("Read error");
-00073                         bFailed = TRUE;
-00074                         break;
-00075                 }
-00076                 if (fwrite(acBuffer, 1, tSize, pFileW) != tSize) {
-00077                         DBG_MSG("Write error");
-00078                         bFailed = TRUE;
-00079                         break;
-00080                 }
-00081         }
-00082         (void)fclose(pFileW);
-00083         (void)fclose(pFileR);
-00084         if (bFailed) {
-00085                 DBG_MSG("Copying the FontNames file failed");
-00086                 (void)remove(szFontNamesFile);
-00087                 return NULL;
-00088         }
-00089         return fopen(szFontNamesFile, "r");
-00090 } /* end of pOpenFontTableFile */
-00091 
-00092 /*
-00093  * vCloseFont - close the current font, if any
-00094  */
-00095 void
-00096 vCloseFont(void)
-00097 {
-00098         os_error        *e;
-00099 
-00100         NO_DBG_MSG("vCloseFont");
-00101 
-00102         if (tFontCurr == (font_handle)-1) {
-00103                 return;
-00104         }
-00105         e = Font_LoseFont(tFontCurr);
-00106         if (e != NULL) {
-00107                 werr(0, "Close font error %d: %s", e->errnum, e->errmess);
-00108         }
-00109         tFontCurr = (font_handle)-1;
-00110 } /* end of vCloseFont */
-00111 
-00112 /*
-00113  * tOpenFont - make the specified font the current font
-00114  *
-00115  * Returns the font reference number for use in a draw file
-00116  */
-00117 drawfile_fontref
-00118 tOpenFont(UCHAR ucWordFontNumber, USHORT usFontStyle, USHORT usWordFontSize)
-00119 {
-00120         os_error        *e;
-00121         const char      *szOurFontname;
-00122         font_handle     tFont;
-00123         int     iFontnumber;
-00124 
-00125         NO_DBG_MSG("tOpenFont");
-00126         NO_DBG_DEC(ucWordFontNumber);
-00127         NO_DBG_HEX(usFontStyle);
-00128         NO_DBG_DEC(usWordFontSize);
-00129 
-00130         /* Keep the relevant bits */
-00131         usFontStyle &= FONT_BOLD|FONT_ITALIC;
-00132         NO_DBG_HEX(usFontStyle);
-00133 
-00134         iFontnumber = iGetFontByNumber(ucWordFontNumber, usFontStyle);
-00135         szOurFontname = szGetOurFontname(iFontnumber);
-00136         if (szOurFontname == NULL || szOurFontname[0] == '\0') {
-00137                 tFontCurr = (font_handle)-1;
-00138                 return (byte)0;
-00139         }
-00140         NO_DBG_MSG(szOurFontname);
-00141         e = Font_FindFont(&tFont, (char *)szOurFontname,
-00142                         (int)usWordFontSize * 8, (int)usWordFontSize * 8,
-00143                         0, 0);
-00144         if (e != NULL) {
-00145                 switch (e->errnum) {
-00146                 case 523:
-00147                         werr(0, "%s", e->errmess);
-00148                         break;
-00149                 default:
-00150                         werr(0, "Open font error %d: %s",
-00151                                 e->errnum, e->errmess);
-00152                         break;
-00153                 }
-00154                 tFontCurr = (font_handle)-1;
-00155                 return (drawfile_fontref)0;
-00156         }
-00157         tFontCurr = tFont;
-00158         NO_DBG_DEC(tFontCurr);
-00159         return (drawfile_fontref)(iFontnumber + 1);
-00160 } /* end of tOpenFont */
-00161 
-00162 /*
-00163  * tOpenTableFont - make the table font the current font
-00164  *
-00165  * Returns the font reference number for use in a draw file
-00166  */
-00167 drawfile_fontref
-00168 tOpenTableFont(USHORT usWordFontSize)
-00169 {
-00170         int     iWordFontnumber;
-00171 
-00172         NO_DBG_MSG("tOpenTableFont");
-00173 
-00174         iWordFontnumber = iFontname2Fontnumber(TABLE_FONT, FONT_REGULAR);
-00175         if (iWordFontnumber < 0 || iWordFontnumber > (int)UCHAR_MAX) {
-00176                 DBG_DEC(iWordFontnumber);
-00177                 tFontCurr = (font_handle)-1;
-00178                 return (drawfile_fontref)0;
-00179         }
-00180 
-00181         return tOpenFont((UCHAR)iWordFontnumber, FONT_REGULAR, usWordFontSize);
-00182 } /* end of tOpenTableFont */
-00183 
-00184 /*
-00185  * lComputeStringWidth - compute the string width
-00186  *
-00187  * Returns the string width in millipoints
-00188  */
-00189 long
-00190 lComputeStringWidth(const char *szString, size_t tStringLength,
-00191         drawfile_fontref tFontRef, USHORT usFontSize)
-00192 {
-00193         font_string     tStr;
-00194         os_error        *e;
-00195 
-00196         fail(szString == NULL);
-00197         fail(usFontSize < MIN_FONT_SIZE || usFontSize > MAX_FONT_SIZE);
-00198 
-00199         if (szString[0] == '\0' || tStringLength == 0) {
-00200                 /* Empty string */
-00201                 return 0;
-00202         }
-00203         if (tStringLength == 1 && szString[0] == TABLE_SEPARATOR) {
-00204                 /* Font_strwidth doesn't like control characters */
-00205                 return 0;
-00206         }
-00207         if (tFontCurr == (font_handle)-1) {
-00208                 /* No current font, use systemfont */
-00209                 return lChar2MilliPoints(tStringLength);
-00210         }
-00211         tStr.s = (char *)szString;
-00212         tStr.x = INT_MAX;
-00213         tStr.y = INT_MAX;
-00214         tStr.split = -1;
-00215         tStr.term = tStringLength;
-00216         e = Font_StringWidth(&tStr);
-00217         if (e == NULL) {
-00218                 return (long)tStr.x;
-00219         }
-00220         DBG_DEC(e->errnum);
-00221         DBG_MSG(e->errmess);
-00222         DBG_DEC(tStringLength);
-00223         DBG_MSG(szString);
-00224         werr(0, "String width error %d: %s", e->errnum, e->errmess);
-00225         return lChar2MilliPoints(tStringLength);
-00226 } /* end of lComputeStringWidth */
-00227 
-00228 /*
-00229  * tCountColumns - count the number of columns in a string
-00230  *
-00231  * Returns the number of columns
-00232  */
-00233 size_t
-00234 tCountColumns(const char *szString, size_t tLength)
-00235 {
-00236         fail(szString == NULL);
-00237 
-00238         /* One byte, one character, one column */
-00239         return tLength;
-00240 } /* end of tCountColumns */
-00241 
-00242 /*
-00243  * tGetCharacterLength - the length of the specified character in bytes
-00244  *
-00245  * Returns the length in bytes
-00246  */
-00247 size_t
-00248 tGetCharacterLength(const char *szString)
-00249 {
-00250         return 1;
-00251 } /* end of tGetCharacterLength */
-
-
Generated by  - -doxygen 1.6.2
- - diff -r 59758314f811 -r d4524d6a4472 Symbian3/Examples/guid-6013a680-57f9-415b-8851-c4fa63356636/fonts__u_8c_source.html --- a/Symbian3/Examples/guid-6013a680-57f9-415b-8851-c4fa63356636/fonts__u_8c_source.html Fri Jun 11 15:24:34 2010 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,327 +0,0 @@ - - - - -TB9.2 Example Applications: examples/PIPS/antiword/src/fonts_u.c Source File - - - - - -

examples/PIPS/antiword/src/fonts_u.c

00001 /*
-00002  * fonts_u.c
-00003  * Copyright (C) 1999-2004 A.J. van Os; Released under GNU GPL
-00004  *
-00005  * Description:
-00006  * Functions to deal with fonts (Unix version)
-00007  */
-00008 
-00009 #include <stdio.h>
-00010 #include <stdlib.h>
-00011 #include <string.h>
-00012 #include "antiword.h"
-00013 #include "fontinfo.h"
-00014 
-00015 /* Don't use fonts, just plain text */
-00016 static BOOL             bUsePlainText = TRUE;
-00017 /* Which character set should be used */
-00018 static encoding_type    eEncoding = encoding_neutral;
-00019 
-00020 
-00021 /*
-00022  * pOpenFontTableFile - open the Font translation file
-00023  *
-00024  * Returns the file pointer or NULL
-00025  */
-00026 FILE *
-00027 pOpenFontTableFile(void)
-00028 {
-00029         FILE            *pFile;
-00030         const char      *szHome, *szAntiword, *szGlobalFile;
-00031         char            szEnvironmentFile[PATH_MAX+1];
-00032         char            szLocalFile[PATH_MAX+1];
-00033 
-00034         szEnvironmentFile[0] = '\0';
-00035         szLocalFile[0] = '\0';
-00036 
-00037         /* Try the environment version of the fontnames file */
-00038         szAntiword = szGetAntiwordDirectory();
-00039         if (szAntiword != NULL && szAntiword[0] != '\0') {
-00040                 if (strlen(szAntiword) +
-00041                     sizeof(FILE_SEPARATOR FONTNAMES_FILE) >=
-00042                     sizeof(szEnvironmentFile)) {
-00043                         werr(0,
-00044                         "The name of your ANTIWORDHOME directory is too long");
-00045                         return NULL;
-00046                 }
-00047                 sprintf(szEnvironmentFile, "%s%s",
-00048                         szAntiword,
-00049                         FILE_SEPARATOR FONTNAMES_FILE);
-00050                 DBG_MSG(szEnvironmentFile);
-00051 
-00052                 pFile = fopen(szEnvironmentFile, "r");
-00053                 if (pFile != NULL) {
-00054                         return pFile;
-00055                 }
-00056         }
-00057 
-00058         /* Try the local version of the fontnames file */
-00059         szHome = szGetHomeDirectory();
-00060         if (strlen(szHome) +
-00061             sizeof(FILE_SEPARATOR ANTIWORD_DIR FILE_SEPARATOR FONTNAMES_FILE) >=
-00062             sizeof(szLocalFile)) {
-00063                 werr(0, "The name of your HOME directory is too long");
-00064                 return NULL;
-00065         }
-00066 
-00067         #ifndef SYMBIAN
-00068         sprintf(szLocalFile, "%s%s",
-00069                 szHome,
-00070                 FILE_SEPARATOR ANTIWORD_DIR FILE_SEPARATOR FONTNAMES_FILE);
-00071                 DBG_MSG(szLocalFile);
-00072         #else
-00073         sprintf(szLocalFile, "%s%s",
-00074                 szHome,
-00075                 FONTNAMES_FILE);
-00076                 DBG_MSG(szLocalFile);
-00077         #endif /*SYMBIAN*/
-00078         pFile = fopen(szLocalFile, "r");
-00079         if (pFile != NULL) {
-00080                 return pFile;
-00081         }
-00082 
-00083         /* Try the global version of the fontnames file */
-00084         szGlobalFile = GLOBAL_ANTIWORD_DIR FILE_SEPARATOR FONTNAMES_FILE;
-00085         DBG_MSG(szGlobalFile);
-00086 
-00087         pFile = fopen(szGlobalFile, "r");
-00088         if (pFile != NULL) {
-00089                 return pFile;
-00090         }
-00091 
-00092         if (szEnvironmentFile[0] != '\0') {
-00093                 werr(0, "I can not open your fontnames file.\n"
-00094                         "Neither '%s' nor\n"
-00095                         "'%s' nor\n"
-00096                         "'%s' can be opened for reading.",
-00097                         szEnvironmentFile, szLocalFile, szGlobalFile);
-00098         } else {
-00099                 werr(0, "I can not open your fontnames file.\n"
-00100                         "Neither '%s' nor\n"
-00101                         "'%s' can be opened for reading.",
-00102                         szLocalFile, szGlobalFile);
-00103         }
-00104         return NULL;
-00105 } /* end of pOpenFontTableFile */
-00106 
-00107 /*
-00108  * vCloseFont - close the current font, if any
-00109  */
-00110 void
-00111 vCloseFont(void)
-00112 {
-00113         NO_DBG_MSG("vCloseFont");
-00114         /* For safety: to be overwritten at the next call of tOpenfont() */
-00115         eEncoding = encoding_neutral;
-00116         bUsePlainText = TRUE;
-00117 } /* end of vCloseFont */
-00118 
-00119 /*
-00120  * tOpenFont - make the specified font the current font
-00121  *
-00122  * Returns the font reference number
-00123  */
-00124 drawfile_fontref
-00125 tOpenFont(UCHAR ucWordFontNumber, USHORT usFontStyle, USHORT usWordFontSize)
-00126 {
-00127         options_type    tOptions;
-00128         const char      *szOurFontname;
-00129         size_t  tIndex;
-00130         int     iFontnumber;
-00131 
-00132         NO_DBG_MSG("tOpenFont");
-00133         NO_DBG_DEC(ucWordFontNumber);
-00134         NO_DBG_HEX(usFontStyle);
-00135         NO_DBG_DEC(usWordFontSize);
-00136 
-00137         /* Keep the relevant bits */
-00138         usFontStyle &= FONT_BOLD|FONT_ITALIC;
-00139         NO_DBG_HEX(usFontStyle);
-00140 
-00141         vGetOptions(&tOptions);
-00142         eEncoding = tOptions.eEncoding;
-00143         bUsePlainText = tOptions.eConversionType != conversion_draw &&
-00144                         tOptions.eConversionType != conversion_ps &&
-00145                         tOptions.eConversionType != conversion_pdf;
-00146 
-00147         if (bUsePlainText) {
-00148                 /* Plain text, no fonts */
-00149                 return (drawfile_fontref)0;
-00150         }
-00151 
-00152         iFontnumber = iGetFontByNumber(ucWordFontNumber, usFontStyle);
-00153         szOurFontname = szGetOurFontname(iFontnumber);
-00154         if (szOurFontname == NULL || szOurFontname[0] == '\0') {
-00155                 DBG_DEC(iFontnumber);
-00156                 return (drawfile_fontref)0;
-00157         }
-00158         NO_DBG_MSG(szOurFontname);
-00159 
-00160         for (tIndex = 0; tIndex < elementsof(szFontnames); tIndex++) {
-00161                 if (STREQ(szFontnames[tIndex], szOurFontname)) {
-00162                         NO_DBG_DEC(tIndex);
-00163                         return (drawfile_fontref)tIndex;
-00164                 }
-00165         }
-00166         return (drawfile_fontref)0;
-00167 } /* end of tOpenFont */
-00168 
-00169 /*
-00170  * tOpenTableFont - make the table font the current font
-00171  *
-00172  * Returns the font reference number
-00173  */
-00174 drawfile_fontref
-00175 tOpenTableFont(USHORT usWordFontSize)
-00176 {
-00177         options_type    tOptions;
-00178         int     iWordFontnumber;
-00179 
-00180         NO_DBG_MSG("tOpenTableFont");
-00181 
-00182         vGetOptions(&tOptions);
-00183         eEncoding = tOptions.eEncoding;
-00184         bUsePlainText = tOptions.eConversionType != conversion_draw &&
-00185                         tOptions.eConversionType != conversion_ps &&
-00186                         tOptions.eConversionType != conversion_pdf;
-00187 
-00188         if (bUsePlainText) {
-00189                 /* Plain text, no fonts */
-00190                 return (drawfile_fontref)0;
-00191         }
-00192 
-00193         iWordFontnumber = iFontname2Fontnumber(TABLE_FONT, FONT_REGULAR);
-00194         if (iWordFontnumber < 0 || iWordFontnumber > (int)UCHAR_MAX) {
-00195                 DBG_DEC(iWordFontnumber);
-00196                 return (drawfile_fontref)0;
-00197         }
-00198 
-00199         return tOpenFont((UCHAR)iWordFontnumber, FONT_REGULAR, usWordFontSize);
-00200 } /* end of tOpenTableFont */
-00201 
-00202 /*
-00203  * szGetFontname - get the fontname
-00204  */
-00205 const char *
-00206 szGetFontname(drawfile_fontref tFontRef)
-00207 {
-00208         fail((size_t)(UCHAR)tFontRef >= elementsof(szFontnames));
-00209         return szFontnames[(int)(UCHAR)tFontRef];
-00210 } /* end of szGetFontname */
-00211 
-00212 /*
-00213  * lComputeStringWidth - compute the string width
-00214  *
-00215  * Note: the fontsize is specified in half-points!
-00216  *       the stringlength is specified in bytes, not characters!
-00217  *
-00218  * Returns the string width in millipoints
-00219  */
-00220 long
-00221 lComputeStringWidth(const char *szString, size_t tStringLength,
-00222         drawfile_fontref tFontRef, USHORT usFontSize)
-00223 {
-00224         USHORT  *ausCharWidths;
-00225         UCHAR   *pucChar;
-00226         long    lRelWidth;
-00227         size_t  tIndex;
-00228         int     iFontRef;
-00229 
-00230         fail(szString == NULL);
-00231         fail(usFontSize < MIN_FONT_SIZE || usFontSize > MAX_FONT_SIZE);
-00232 
-00233         if (szString[0] == '\0' || tStringLength == 0) {
-00234                 /* Empty string */
-00235                 return 0;
-00236         }
-00237 
-00238         if (eEncoding == encoding_utf_8) {
-00239                 fail(!bUsePlainText);
-00240                 return lChar2MilliPoints(
-00241                         utf8_strwidth(szString, tStringLength));
-00242         }
-00243 
-00244         if (bUsePlainText) {
-00245                 /* No current font, use "systemfont" */
-00246                 return lChar2MilliPoints(tStringLength);
-00247         }
-00248 
-00249         if (eEncoding == encoding_cyrillic) {
-00250                 /* FIXME: until the character tables are available */
-00251                 return (tStringLength * 600L * (long)usFontSize + 1) / 2;
-00252         }
-00253 
-00254         DBG_DEC_C(eEncoding != encoding_latin_1 &&
-00255                 eEncoding != encoding_latin_2, eEncoding);
-00256         fail(eEncoding != encoding_latin_1 &&
-00257                 eEncoding != encoding_latin_2);
-00258 
-00259         /* Compute the relative string width */
-00260         iFontRef = (int)(UCHAR)tFontRef;
-00261         if (eEncoding == encoding_latin_2) {
-00262                 ausCharWidths = ausCharacterWidths2[iFontRef];
-00263         } else {
-00264                 ausCharWidths = ausCharacterWidths1[iFontRef];
-00265         }
-00266         lRelWidth = 0;
-00267         for (tIndex = 0, pucChar = (UCHAR *)szString;
-00268              tIndex < tStringLength;
-00269              tIndex++, pucChar++) {
-00270                 lRelWidth += (long)ausCharWidths[(int)*pucChar];
-00271         }
-00272 
-00273         /* Compute the absolute string width */
-00274         return (lRelWidth * (long)usFontSize + 1) / 2;
-00275 } /* end of lComputeStringWidth */
-00276 
-00277 /*
-00278  * tCountColumns - count the number of columns in a string
-00279  *
-00280  * Note: the length is specified in bytes!
-00281  *       A UTF-8 a character can be 0, 1 or 2 columns wide.
-00282  *
-00283  * Returns the number of columns
-00284  */
-00285 size_t
-00286 tCountColumns(const char *szString, size_t tLength)
-00287 {
-00288         fail(szString == NULL);
-00289 
-00290         if (eEncoding != encoding_utf_8) {
-00291                 /* One byte, one character, one column */
-00292                 return tLength;
-00293         }
-00294         return (size_t)utf8_strwidth(szString, tLength);
-00295 } /* end of tCountColumns */
-00296 
-00297 /*
-00298  * tGetCharacterLength - the length of the specified character in bytes
-00299  *
-00300  * Returns the length in bytes
-00301  */
-00302 size_t
-00303 tGetCharacterLength(const char *szString)
-00304 {
-00305         fail(szString == NULL);
-00306 
-00307         if (eEncoding != encoding_utf_8) {
-00308                 return 1;
-00309         }
-00310         return (size_t)utf8_chrlength(szString);
-00311 } /* end of tGetCharacterLength */
-
-
Generated by  - -doxygen 1.6.2
- - diff -r 59758314f811 -r d4524d6a4472 Symbian3/Examples/guid-6013a680-57f9-415b-8851-c4fa63356636/guid-72f72df3-653c-414c-a357-7613ad8bc169.html --- a/Symbian3/Examples/guid-6013a680-57f9-415b-8851-c4fa63356636/guid-72f72df3-653c-414c-a357-7613ad8bc169.html Fri Jun 11 15:24:34 2010 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,98 +0,0 @@ - - - - -TB9.2 Example Applications: antiword - - - - - -
- - -

antiword

Source files:

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

examples/PIPS/antiword/src/hdrftrlist.c

00001 /*
-00002  * hdrftrlist.c
-00003  * Copyright (C) 2004,2005 A.J. van Os; Released under GNU GPL
-00004  *
-00005  * Description:
-00006  * Build, read and destroy list(s) of Word Header/footer information
-00007  */
-00008 
-00009 #include <string.h>
-00010 #include "antiword.h"
-00011 
-00012 
-00013 #define HDR_EVEN_PAGES  0
-00014 #define HDR_ODD_PAGES   1
-00015 #define FTR_EVEN_PAGES  2
-00016 #define FTR_ODD_PAGES   3
-00017 #define HDR_FIRST_PAGE  4
-00018 #define FTR_FIRST_PAGE  5
-00019 
-00020 /*
-00021  * Private structures to hide the way the information
-00022  * is stored from the rest of the program
-00023  */
-00024 typedef struct hdrftr_local_tag {
-00025         hdrftr_block_type       tInfo;
-00026         ULONG                   ulCharPosStart;
-00027         ULONG                   ulCharPosNext;
-00028         BOOL                    bUseful;
-00029         BOOL                    bTextOriginal;
-00030 } hdrftr_local_type;
-00031 typedef struct hdrftr_mem_tag {
-00032         hdrftr_local_type       atElement[6];
-00033 } hdrftr_mem_type;
-00034 
-00035 /* Variables needed to write the Header/footer Information List */
-00036 static hdrftr_mem_type  *pHdrFtrList = NULL;
-00037 static size_t           tHdrFtrLen = 0;
-00038 
-00039 
-00040 /*
-00041  * vDestroyHdrFtrInfoList - destroy the Header/footer Information List
-00042  */
-00043 void
-00044 vDestroyHdrFtrInfoList(void)
-00045 {
-00046         hdrftr_mem_type *pRecord;
-00047         output_type     *pCurr, *pNext;
-00048         size_t          tHdrFtr, tIndex;
-00049 
-00050         DBG_MSG("vDestroyHdrFtrInfoList");
-00051 
-00052         /* Free the Header/footer Information List */
-00053         for (tHdrFtr = 0; tHdrFtr < tHdrFtrLen; tHdrFtr++) {
-00054                 pRecord = pHdrFtrList + tHdrFtr;
-00055                 for (tIndex = 0;
-00056                      tIndex < elementsof(pRecord->atElement);
-00057                      tIndex++) {
-00058                         if (!pRecord->atElement[tIndex].bTextOriginal) {
-00059                                 continue;
-00060                         }
-00061                         pCurr = pRecord->atElement[tIndex].tInfo.pText;
-00062                         while (pCurr != NULL) {
-00063                                 pCurr->szStorage = xfree(pCurr->szStorage);
-00064                                 pNext = pCurr->pNext;
-00065                                 pCurr = xfree(pCurr);
-00066                                 pCurr = pNext;
-00067                         }
-00068                 }
-00069         }
-00070         pHdrFtrList = xfree(pHdrFtrList);
-00071         /* Reset all control variables */
-00072         tHdrFtrLen = 0;
-00073 } /* end of vDestroyHdrFtrInfoList */
-00074 
-00075 /*
-00076  * vCreat8HdrFtrInfoList - Create the Header/footer Information List
-00077  */
-00078 void
-00079 vCreat8HdrFtrInfoList(const ULONG *aulCharPos, size_t tLength)
-00080 {
-00081         hdrftr_mem_type *pListMember;
-00082         size_t  tHdrFtr, tIndex, tMainIndex;
-00083 
-00084         fail(aulCharPos == NULL);
-00085 
-00086         DBG_DEC(tLength);
-00087         if (tLength <= 1) {
-00088                 return;
-00089         }
-00090         tHdrFtrLen = tLength / 12;
-00091         if (tLength % 12 != 0 && tLength % 12 != 1) {
-00092                 tHdrFtrLen++;
-00093         }
-00094         DBG_DEC(tHdrFtrLen);
-00095 
-00096         pHdrFtrList = xcalloc(tHdrFtrLen, sizeof(hdrftr_mem_type));
-00097 
-00098         for (tHdrFtr = 0; tHdrFtr < tHdrFtrLen; tHdrFtr++) {
-00099                 pListMember = pHdrFtrList + tHdrFtr;
-00100                 for (tIndex = 0, tMainIndex = tHdrFtr * 12;
-00101                      tIndex < 6 && tMainIndex < tLength;
-00102                      tIndex++, tMainIndex++) {
-00103                         pListMember->atElement[tIndex].tInfo.pText = NULL;
-00104                         pListMember->atElement[tIndex].ulCharPosStart =
-00105                                                 aulCharPos[tMainIndex];
-00106                         if (tMainIndex + 1 < tLength) {
-00107                                 pListMember->atElement[tIndex].ulCharPosNext =
-00108                                         aulCharPos[tMainIndex + 1];
-00109                         } else {
-00110                                 pListMember->atElement[tIndex].ulCharPosNext =
-00111                                         aulCharPos[tMainIndex];
-00112                         }
-00113                 }
-00114         }
-00115 } /* end of vCreat8HdrFtrInfoList */
-00116 
-00117 /*
-00118  * vCreat6HdrFtrInfoList - Create the Header/footer Information List
-00119  */
-00120 void
-00121 vCreat6HdrFtrInfoList(const ULONG *aulCharPos, size_t tLength)
-00122 {
-00123         static const size_t     atIndex[] =
-00124                 { SIZE_T_MAX, SIZE_T_MAX, FTR_FIRST_PAGE, HDR_FIRST_PAGE,
-00125                   FTR_ODD_PAGES, FTR_EVEN_PAGES, HDR_ODD_PAGES, HDR_EVEN_PAGES,
-00126                 };
-00127         hdrftr_mem_type *pListMember;
-00128         size_t  tHdrFtr, tTmp, tIndex, tMainIndex, tBit;
-00129         UCHAR   ucDopSpecification, ucSepSpecification;
-00130 
-00131         fail(aulCharPos == NULL);
-00132 
-00133         DBG_DEC(tLength);
-00134         if (tLength <= 1) {
-00135                 return;
-00136         }
-00137         tHdrFtrLen = tGetNumberOfSections();
-00138         if (tHdrFtrLen == 0) {
-00139                 tHdrFtrLen = 1;
-00140         }
-00141         DBG_DEC(tHdrFtrLen);
-00142 
-00143         pHdrFtrList = xcalloc(tHdrFtrLen, sizeof(hdrftr_mem_type));
-00144 
-00145         /* Get the start index in aulCharPos */
-00146         ucDopSpecification = ucGetDopHdrFtrSpecification();
-00147         DBG_HEX(ucDopSpecification & 0xe0);
-00148         tMainIndex = 0;
-00149         for (tBit = 7; tBit >= 5; tBit--) {
-00150                 if ((ucDopSpecification & BIT(tBit)) != 0) {
-00151                         tMainIndex++;
-00152                 }
-00153         }
-00154         DBG_DEC(tMainIndex);
-00155 
-00156         for (tHdrFtr = 0; tHdrFtr < tHdrFtrLen; tHdrFtr++) {
-00157                 ucSepSpecification = ucGetSepHdrFtrSpecification(tHdrFtr);
-00158                 DBG_HEX(ucSepSpecification & 0xfc);
-00159                 pListMember = pHdrFtrList + tHdrFtr;
-00160                 for (tTmp = 0;
-00161                      tTmp < elementsof(pListMember->atElement);
-00162                      tTmp++) {
-00163                         pListMember->atElement[tTmp].tInfo.pText = NULL;
-00164                 }
-00165                 for (tBit = 7; tBit >= 2; tBit--) {
-00166                         if (tMainIndex >= tLength) {
-00167                                 break;
-00168                         }
-00169                         if ((ucSepSpecification & BIT(tBit)) == 0) {
-00170                                 continue;
-00171                         }
-00172                         tIndex = atIndex[tBit];
-00173                         fail(tIndex >= 6);
-00174                         pListMember->atElement[tIndex].ulCharPosStart =
-00175                                 aulCharPos[tMainIndex];
-00176                         if (tMainIndex + 1 < tLength) {
-00177                                 pListMember->atElement[tIndex].ulCharPosNext =
-00178                                         aulCharPos[tMainIndex + 1];
-00179                         } else {
-00180                                 pListMember->atElement[tIndex].ulCharPosNext =
-00181                                         aulCharPos[tMainIndex];
-00182                         }
-00183                         tMainIndex++;
-00184                 }
-00185         }
-00186 } /* end of vCreat6HdrFtrInfoList */
-00187 
-00188 /*
-00189  * vCreat2HdrFtrInfoList - Create the Header/footer Information List
-00190  */
-00191 void
-00192 vCreat2HdrFtrInfoList(const ULONG *aulCharPos, size_t tLength)
-00193 {
-00194         vCreat6HdrFtrInfoList(aulCharPos, tLength);
-00195 } /* end of vCreat2HdrFtrInfoList */
-00196 
-00197 /*
-00198  * pGetHdrFtrInfo - get the Header/footer information
-00199  */
-00200 const hdrftr_block_type *
-00201 pGetHdrFtrInfo(int iSectionIndex,
-00202         BOOL bWantHeader, BOOL bOddPage, BOOL bFirstInSection)
-00203 {
-00204         hdrftr_mem_type *pCurr;
-00205 
-00206         fail(iSectionIndex < 0);
-00207         fail(pHdrFtrList == NULL && tHdrFtrLen != 0);
-00208 
-00209         if (pHdrFtrList == NULL || tHdrFtrLen == 0) {
-00210                 /* No information */
-00211                 return NULL;
-00212         }
-00213 
-00214         if (iSectionIndex < 0) {
-00215                 iSectionIndex = 0;
-00216         } else if (iSectionIndex >= (int)tHdrFtrLen) {
-00217                 iSectionIndex = (int)(tHdrFtrLen - 1);
-00218         }
-00219 
-00220         pCurr = pHdrFtrList + iSectionIndex;
-00221 
-00222         if (bFirstInSection) {
-00223                 if (bWantHeader) {
-00224                         return &pCurr->atElement[HDR_FIRST_PAGE].tInfo;
-00225                 } else {
-00226                         return &pCurr->atElement[FTR_FIRST_PAGE].tInfo;
-00227                 }
-00228         } else {
-00229                 if (bWantHeader) {
-00230                         if (bOddPage) {
-00231                                 return &pCurr->atElement[HDR_ODD_PAGES].tInfo;
-00232                         } else {
-00233                                 return &pCurr->atElement[HDR_EVEN_PAGES].tInfo;
-00234                         }
-00235                 } else {
-00236                         if (bOddPage) {
-00237                                 return &pCurr->atElement[FTR_ODD_PAGES].tInfo;
-00238                         } else {
-00239                                 return &pCurr->atElement[FTR_EVEN_PAGES].tInfo;
-00240                         }
-00241                 }
-00242         }
-00243 } /* end of pGetHdrFtrInfo */
-00244 
-00245 /*
-00246  * lComputeHdrFtrHeight - compute the height of a header or footer
-00247  *
-00248  * Returns the height in DrawUnits
-00249  */
-00250 static long
-00251 lComputeHdrFtrHeight(const output_type *pAnchor)
-00252 {
-00253         const output_type *pCurr;
-00254         long    lTotal;
-00255         USHORT  usFontSizeMax;
-00256 
-00257         lTotal = 0;
-00258         usFontSizeMax = 0;
-00259         for (pCurr = pAnchor; pCurr != NULL; pCurr = pCurr->pNext) {
-00260                 if (pCurr->tNextFree == 1) {
-00261                         if (pCurr->szStorage[0] == PAR_END) {
-00262                                 /* End of a paragraph */
-00263                                 lTotal += lComputeLeading(usFontSizeMax);
-00264                                 lTotal += lMilliPoints2DrawUnits(
-00265                                                 (long)pCurr->usFontSize * 200);
-00266                                 usFontSizeMax = 0;
-00267                                 continue;
-00268                         }
-00269                         if (pCurr->szStorage[0] == HARD_RETURN) {
-00270                                 /* End of a line */
-00271                                 lTotal += lComputeLeading(usFontSizeMax);
-00272                                 usFontSizeMax = 0;
-00273                                 continue;
-00274                         }
-00275                 }
-00276                 if (pCurr->usFontSize > usFontSizeMax) {
-00277                         usFontSizeMax = pCurr->usFontSize;
-00278                 }
-00279         }
-00280         if (usFontSizeMax != 0) {
-00281                 /* Height of the last paragraph */
-00282                 lTotal += lComputeLeading(usFontSizeMax);
-00283         }
-00284         return lTotal;
-00285 } /* end of lComputeHdrFtrHeight */
-00286 
-00287 /*
-00288  * vPrepareHdrFtrText - prepare the header/footer text
-00289  */
-00290 void
-00291 vPrepareHdrFtrText(FILE *pFile)
-00292 {
-00293         hdrftr_mem_type         *pCurr, *pPrev;
-00294         hdrftr_local_type       *pTmp;
-00295         output_type             *pText;
-00296         size_t          tHdrFtr, tIndex;
-00297 
-00298         fail(pFile == NULL);
-00299         fail(pHdrFtrList == NULL && tHdrFtrLen != 0);
-00300 
-00301         if (pHdrFtrList == NULL || tHdrFtrLen == 0) {
-00302                 /* No information */
-00303                 return;
-00304         }
-00305 
-00306         /* Fill text, text height and useful-ness */
-00307         for (tHdrFtr = 0; tHdrFtr < tHdrFtrLen; tHdrFtr++) {
-00308                 pCurr = pHdrFtrList + tHdrFtr;
-00309                 for (tIndex = 0;
-00310                      tIndex < elementsof(pHdrFtrList->atElement);
-00311                      tIndex++) {
-00312                         pTmp = &pCurr->atElement[tIndex];
-00313                         pTmp->bUseful =
-00314                                 pTmp->ulCharPosStart != pTmp->ulCharPosNext;
-00315                         if (pTmp->bUseful) {
-00316                                 pText = pHdrFtrDecryptor(pFile,
-00317                                                 pTmp->ulCharPosStart,
-00318                                                 pTmp->ulCharPosNext);
-00319                                 pTmp->tInfo.pText = pText;
-00320                                 pTmp->tInfo.lHeight =
-00321                                                 lComputeHdrFtrHeight(pText);
-00322                                 pTmp->bTextOriginal = pText != NULL;
-00323                         } else {
-00324                                 pTmp->tInfo.pText = NULL;
-00325                                 pTmp->tInfo.lHeight = 0;
-00326                                 pTmp->bTextOriginal = FALSE;
-00327                         }
-00328                 }
-00329         }
-00330 
-00331         /* Replace not-useful records by using inheritance */
-00332         if (pHdrFtrList->atElement[HDR_FIRST_PAGE].bUseful) {
-00333                 pTmp = &pHdrFtrList->atElement[HDR_ODD_PAGES];
-00334                 if (!pTmp->bUseful) {
-00335                         *pTmp = pHdrFtrList->atElement[HDR_FIRST_PAGE];
-00336                         pTmp->bTextOriginal = FALSE;
-00337                 }
-00338                 pTmp = &pHdrFtrList->atElement[HDR_EVEN_PAGES];
-00339                 if (!pTmp->bUseful) {
-00340                         *pTmp = pHdrFtrList->atElement[HDR_FIRST_PAGE];
-00341                         pTmp->bTextOriginal = FALSE;
-00342                 }
-00343         }
-00344         if (pHdrFtrList->atElement[FTR_FIRST_PAGE].bUseful) {
-00345                 pTmp = &pHdrFtrList->atElement[FTR_ODD_PAGES];
-00346                 if (!pTmp->bUseful) {
-00347                         *pTmp = pHdrFtrList->atElement[FTR_FIRST_PAGE];
-00348                         pTmp->bTextOriginal = FALSE;
-00349                 }
-00350                 pTmp = &pHdrFtrList->atElement[FTR_EVEN_PAGES];
-00351                 if (!pTmp->bUseful) {
-00352                         *pTmp = pHdrFtrList->atElement[FTR_FIRST_PAGE];
-00353                         pTmp->bTextOriginal = FALSE;
-00354                 }
-00355         }
-00356         for (tHdrFtr = 1, pCurr = &pHdrFtrList[1];
-00357              tHdrFtr < tHdrFtrLen;
-00358              tHdrFtr++, pCurr++) {
-00359                 pPrev = pCurr - 1;
-00360                 for (tIndex = 0;
-00361                      tIndex < elementsof(pHdrFtrList->atElement);
-00362                      tIndex++) {
-00363                         if (!pCurr->atElement[tIndex].bUseful &&
-00364                             pPrev->atElement[tIndex].bUseful) {
-00365                                 pCurr->atElement[tIndex] =
-00366                                                 pPrev->atElement[tIndex];
-00367                                 pCurr->atElement[tIndex].bTextOriginal = FALSE;
-00368                         }
-00369                 }
-00370         }
-00371 } /* end of vPrepareHdrFtrText */
-
-
Generated by  - -doxygen 1.6.2
- - diff -r 59758314f811 -r d4524d6a4472 Symbian3/Examples/guid-6013a680-57f9-415b-8851-c4fa63356636/icons_8c_source.html --- a/Symbian3/Examples/guid-6013a680-57f9-415b-8851-c4fa63356636/icons_8c_source.html Fri Jun 11 15:24:34 2010 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,112 +0,0 @@ - - - - -TB9.2 Example Applications: examples/PIPS/antiword/src/icons.c Source File - - - - - -

examples/PIPS/antiword/src/icons.c

00001 /*
-00002  * icons.c
-00003  * Copyright (C) 1998-2001 A.J. van Os; Released under GPL
-00004  *
-00005  * Description:
-00006  * Update window icons
-00007  */
-00008 
-00009 #include <string.h>
-00010 #include "DeskLib:Error.h"
-00011 #include "DeskLib:WimpSWIs.h"
-00012 #include "antiword.h"
-00013 
-00014 void
-00015 vUpdateIcon(window_handle tWindow, icon_block *pIcon)
-00016 {
-00017         window_redrawblock      tRedraw;
-00018         BOOL            bMore;
-00019 
-00020         tRedraw.window = tWindow;
-00021         tRedraw.rect = pIcon->workarearect;
-00022         Error_CheckFatal(Wimp_UpdateWindow(&tRedraw, &bMore));
-00023         while (bMore) {
-00024                 Error_CheckFatal(Wimp_PlotIcon(pIcon));
-00025                 Error_CheckFatal(Wimp_GetRectangle(&tRedraw, &bMore));
-00026         }
-00027 } /* end of vUpdateIcon */
-00028 
-00029 void
-00030 vUpdateRadioButton(window_handle tWindow, icon_handle tIconNumber,
-00031         BOOL bSelected)
-00032 {
-00033         icon_block      tIcon;
-00034 
-00035         Error_CheckFatal(Wimp_GetIconState(tWindow, tIconNumber, &tIcon));
-00036         DBG_DEC(tIconNumber);
-00037         DBG_HEX(tIcon.flags.data.selected);
-00038         if (bSelected == (tIcon.flags.data.selected == 1)) {
-00039                 /* No update needed */
-00040                 return;
-00041         }
-00042         Error_CheckFatal(Wimp_SetIconState(tWindow, tIconNumber,
-00043                         bSelected ? 0x00200000 : 0, 0x00200000));
-00044         vUpdateIcon(tWindow, &tIcon);
-00045 } /* end of vUpdateRadioButton */
-00046 
-00047 /*
-00048  * vUpdateWriteable - update a writeable icon with a string
-00049  */
-00050 void
-00051 vUpdateWriteable(window_handle tWindow, icon_handle tIconNumber,
-00052         const char *szString)
-00053 {
-00054         icon_block      tIcon;
-00055         caret_block     tCaret;
-00056         int             iLen;
-00057 
-00058         fail(szString == NULL);
-00059 
-00060         NO_DBG_DEC(tIconNumber);
-00061         NO_DBG_MSG(szString);
-00062 
-00063         Error_CheckFatal(Wimp_GetIconState(tWindow, tIconNumber, &tIcon));
-00064         NO_DBG_HEX(tIcon.flags);
-00065         if (!tIcon.flags.data.text || !tIcon.flags.data.indirected) {
-00066                 werr(1, "Icon %d must be indirected text", (int)tIconNumber);
-00067                 return;
-00068         }
-00069         strncpy(tIcon.data.indirecttext.buffer,
-00070                 szString,
-00071                 tIcon.data.indirecttext.bufflen - 1);
-00072         /* Ensure the caret is behind the last character of the text */
-00073         Error_CheckFatal(Wimp_GetCaretPosition(&tCaret));
-00074         if (tCaret.window == tWindow && tCaret.icon == tIconNumber) {
-00075                 iLen = strlen(tIcon.data.indirecttext.buffer);
-00076                 if (tCaret.index != iLen) {
-00077                         tCaret.index = iLen;
-00078                         Error_CheckFatal(Wimp_SetCaretPosition(&tCaret));
-00079                 }
-00080         }
-00081         Error_CheckFatal(Wimp_SetIconState(tWindow, tIconNumber, 0, 0));
-00082         vUpdateIcon(tWindow, &tIcon);
-00083 } /* end of vUpdateWriteable */
-00084 
-00085 /*
-00086  * vUpdateWriteableNumber - update a writeable icon with a number
-00087  */
-00088 void
-00089 vUpdateWriteableNumber(window_handle tWindow, icon_handle tIconNumber,
-00090         int iNumber)
-00091 {
-00092         char    szTmp[1+3*sizeof(int)+1];
-00093 
-00094         (void)sprintf(szTmp, "%d", iNumber);
-00095         vUpdateWriteable(tWindow, tIconNumber, szTmp);
-00096 } /* end of vUpdateWriteableNumber */
-
-
Generated by  - -doxygen 1.6.2
- - diff -r 59758314f811 -r d4524d6a4472 Symbian3/Examples/guid-6013a680-57f9-415b-8851-c4fa63356636/imgexam_8c_source.html --- a/Symbian3/Examples/guid-6013a680-57f9-415b-8851-c4fa63356636/imgexam_8c_source.html Fri Jun 11 15:24:34 2010 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1060 +0,0 @@ - - - - -TB9.2 Example Applications: examples/PIPS/antiword/src/imgexam.c Source File - - - - - -

examples/PIPS/antiword/src/imgexam.c

00001 /*
-00002  * imgexam.c
-00003  * Copyright (C) 2000-2004 A.J. van Os; Released under GNU GPL
-00004  *
-00005  * Description:
-00006  * Functions to examine image headers
-00007  *
-00008  *================================================================
-00009  * Part of this software is based on:
-00010  * jpeg2ps - convert JPEG compressed images to PostScript Level 2
-00011  * Copyright (C) 1994-99 Thomas Merz (tm@muc.de)
-00012  *================================================================
-00013  * The credit should go to him, but all the bugs are mine.
-00014  */
-00015 
-00016 #include <stdio.h>
-00017 #include <string.h>
-00018 #include <ctype.h>
-00019 #include "antiword.h"
-00020 
-00021 /* BMP compression types */
-00022 #define BI_RGB          0
-00023 #define BI_RLE8         1
-00024 #define BI_RLE4         2
-00025 
-00026 /* PNG colortype bits */
-00027 #define PNG_CB_PALETTE          0x01
-00028 #define PNG_CB_COLOR            0x02
-00029 #define PNG_CB_ALPHA            0x04
-00030 
-00031 /* Instance signature */
-00032 #define MSOBI_WMF       0x0216
-00033 #define MSOBI_EMF       0x03d4
-00034 #define MSOBI_PICT      0x0542
-00035 #define MSOBI_PNG       0x06e0
-00036 #define MSOBI_JPEG      0x046a
-00037 #define MSOBI_DIB       0x07a8
-00038 
-00039 /* The following enum is stolen from the IJG JPEG library */
-00040 typedef enum {          /* JPEG marker codes                    */
-00041         M_SOF0  = 0xc0, /* baseline DCT                         */
-00042         M_SOF1  = 0xc1, /* extended sequential DCT              */
-00043         M_SOF2  = 0xc2, /* progressive DCT                      */
-00044         M_SOF3  = 0xc3, /* lossless (sequential)                */
-00045 
-00046         M_SOF5  = 0xc5, /* differential sequential DCT          */
-00047         M_SOF6  = 0xc6, /* differential progressive DCT         */
-00048         M_SOF7  = 0xc7, /* differential lossless                */
-00049 
-00050         M_JPG   = 0xc8, /* JPEG extensions                      */
-00051         M_SOF9  = 0xc9, /* extended sequential DCT              */
-00052         M_SOF10 = 0xca, /* progressive DCT                      */
-00053         M_SOF11 = 0xcb, /* lossless (sequential)                */
-00054 
-00055         M_SOF13 = 0xcd, /* differential sequential DCT          */
-00056         M_SOF14 = 0xce, /* differential progressive DCT         */
-00057         M_SOF15 = 0xcf, /* differential lossless                */
-00058 
-00059         M_DHT   = 0xc4, /* define Huffman tables                */
-00060 
-00061         M_DAC   = 0xcc, /* define arithmetic conditioning table */
-00062 
-00063         M_RST0  = 0xd0, /* restart                              */
-00064         M_RST1  = 0xd1, /* restart                              */
-00065         M_RST2  = 0xd2, /* restart                              */
-00066         M_RST3  = 0xd3, /* restart                              */
-00067         M_RST4  = 0xd4, /* restart                              */
-00068         M_RST5  = 0xd5, /* restart                              */
-00069         M_RST6  = 0xd6, /* restart                              */
-00070         M_RST7  = 0xd7, /* restart                              */
-00071 
-00072         M_SOI   = 0xd8, /* start of image                       */
-00073         M_EOI   = 0xd9, /* end of image                         */
-00074         M_SOS   = 0xda, /* start of scan                        */
-00075         M_DQT   = 0xdb, /* define quantization tables           */
-00076         M_DNL   = 0xdc, /* define number of lines               */
-00077         M_DRI   = 0xdd, /* define restart interval              */
-00078         M_DHP   = 0xde, /* define hierarchical progression      */
-00079         M_EXP   = 0xdf, /* expand reference image(s)            */
-00080 
-00081         M_APP0  = 0xe0, /* application marker, used for JFIF    */
-00082         M_APP1  = 0xe1, /* application marker                   */
-00083         M_APP2  = 0xe2, /* application marker                   */
-00084         M_APP3  = 0xe3, /* application marker                   */
-00085         M_APP4  = 0xe4, /* application marker                   */
-00086         M_APP5  = 0xe5, /* application marker                   */
-00087         M_APP6  = 0xe6, /* application marker                   */
-00088         M_APP7  = 0xe7, /* application marker                   */
-00089         M_APP8  = 0xe8, /* application marker                   */
-00090         M_APP9  = 0xe9, /* application marker                   */
-00091         M_APP10 = 0xea, /* application marker                   */
-00092         M_APP11 = 0xeb, /* application marker                   */
-00093         M_APP12 = 0xec, /* application marker                   */
-00094         M_APP13 = 0xed, /* application marker                   */
-00095         M_APP14 = 0xee, /* application marker, used by Adobe    */
-00096         M_APP15 = 0xef, /* application marker                   */
-00097 
-00098         M_JPG0  = 0xf0, /* reserved for JPEG extensions         */
-00099         M_JPG13 = 0xfd, /* reserved for JPEG extensions         */
-00100         M_COM   = 0xfe, /* comment                              */
-00101 
-00102         M_TEM   = 0x01  /* temporary use                        */
-00103 } JPEG_MARKER;
-00104 
-00105 
-00106 /*
-00107  * bFillPaletteDIB - fill the palette part of the imagesdata
-00108  *
-00109  * returns TRUE if the images must be a color image, otherwise FALSE;
-00110  */
-00111 static BOOL
-00112 bFillPaletteDIB(FILE *pFile, imagedata_type *pImg, BOOL bNewFormat)
-00113 {
-00114         int     iIndex;
-00115         BOOL    bIsColorPalette;
-00116 
-00117         fail(pFile == NULL);
-00118         fail(pImg == NULL);
-00119 
-00120         if (pImg->uiBitsPerComponent > 8) {
-00121                 /* No palette, image uses more than 256 colors */
-00122                 return TRUE;
-00123         }
-00124 
-00125         if (pImg->iColorsUsed <= 0) {
-00126                 /* Not specified, so compute the number of colors used */
-00127                 pImg->iColorsUsed = 1 << pImg->uiBitsPerComponent;
-00128         }
-00129 
-00130         fail(pImg->iColorsUsed > 256);
-00131         if (pImg->iColorsUsed > 256) {
-00132                 pImg->iColorsUsed = 256;
-00133         }
-00134 
-00135         bIsColorPalette = FALSE;
-00136         for (iIndex = 0; iIndex < pImg->iColorsUsed; iIndex++) {
-00137                 /* From BGR order to RGB order */
-00138                 pImg->aucPalette[iIndex][2] = (UCHAR)iNextByte(pFile);
-00139                 pImg->aucPalette[iIndex][1] = (UCHAR)iNextByte(pFile);
-00140                 pImg->aucPalette[iIndex][0] = (UCHAR)iNextByte(pFile);
-00141                 if (bNewFormat) {
-00142                         (void)iNextByte(pFile);
-00143                 }
-00144                 NO_DBG_PRINT_BLOCK(pImg->aucPalette[iIndex], 3);
-00145                 if (pImg->aucPalette[iIndex][0] !=
-00146                      pImg->aucPalette[iIndex][1] ||
-00147                     pImg->aucPalette[iIndex][1] !=
-00148                      pImg->aucPalette[iIndex][2]) {
-00149                         bIsColorPalette = TRUE;
-00150                 }
-00151         }
-00152 
-00153         return bIsColorPalette;
-00154 } /* end of bFillPaletteDIB */
-00155 
-00156 /*
-00157  * bExamineDIB - Examine a DIB header
-00158  *
-00159  * return TRUE if successful, otherwise FALSE
-00160  */
-00161 static BOOL
-00162 bExamineDIB(FILE *pFile, imagedata_type *pImg)
-00163 {
-00164         size_t  tHeaderSize;
-00165         int     iPlanes, iCompression;
-00166 
-00167         tHeaderSize = (size_t)ulNextLong(pFile);
-00168         switch (tHeaderSize) {
-00169         case 12:
-00170                 pImg->iWidth = (int)usNextWord(pFile);
-00171                 pImg->iHeight = (int)usNextWord(pFile);
-00172                 iPlanes = (int)usNextWord(pFile);
-00173                 pImg->uiBitsPerComponent = (UINT)usNextWord(pFile);
-00174                 iCompression = BI_RGB;
-00175                 pImg->iColorsUsed = 0;
-00176                 break;
-00177         case 40:
-00178         case 64:
-00179                 pImg->iWidth = (int)ulNextLong(pFile);
-00180                 pImg->iHeight = (int)ulNextLong(pFile);
-00181                 iPlanes = (int)usNextWord(pFile);
-00182                 pImg->uiBitsPerComponent = (UINT)usNextWord(pFile);
-00183                 iCompression = (int)ulNextLong(pFile);
-00184                 (void)tSkipBytes(pFile, 12);
-00185                 pImg->iColorsUsed = (int)ulNextLong(pFile);
-00186                 (void)tSkipBytes(pFile, tHeaderSize - 36);
-00187                 break;
-00188         default:
-00189                 DBG_DEC(tHeaderSize);
-00190                 return FALSE;
-00191         }
-00192         DBG_DEC(pImg->iWidth);
-00193         DBG_DEC(pImg->iHeight);
-00194         DBG_DEC(pImg->uiBitsPerComponent);
-00195         DBG_DEC(iCompression);
-00196         DBG_DEC(pImg->iColorsUsed);
-00197 
-00198         /* Do some sanity checks with the parameters */
-00199         if (iPlanes != 1) {
-00200                 DBG_DEC(iPlanes);
-00201                 return FALSE;
-00202         }
-00203         if (pImg->iWidth <= 0 || pImg->iHeight <= 0) {
-00204                 DBG_DEC(pImg->iWidth);
-00205                 DBG_DEC(pImg->iHeight);
-00206                 return FALSE;
-00207         }
-00208         if (pImg->uiBitsPerComponent != 1 && pImg->uiBitsPerComponent != 4 &&
-00209             pImg->uiBitsPerComponent != 8 && pImg->uiBitsPerComponent != 24) {
-00210                 DBG_DEC(pImg->uiBitsPerComponent);
-00211                 return FALSE;
-00212         }
-00213         if (iCompression != BI_RGB &&
-00214             (pImg->uiBitsPerComponent == 1 || pImg->uiBitsPerComponent == 24)) {
-00215                 return FALSE;
-00216         }
-00217         if (iCompression == BI_RLE8 && pImg->uiBitsPerComponent == 4) {
-00218                 return FALSE;
-00219         }
-00220         if (iCompression == BI_RLE4 && pImg->uiBitsPerComponent == 8) {
-00221                 return FALSE;
-00222         }
-00223 
-00224         switch (iCompression) {
-00225         case BI_RGB:
-00226                 pImg->eCompression = compression_none;
-00227                 break;
-00228         case BI_RLE4:
-00229                 pImg->eCompression = compression_rle4;
-00230                 break;
-00231         case BI_RLE8:
-00232                 pImg->eCompression = compression_rle8;
-00233                 break;
-00234         default:
-00235                 DBG_DEC(iCompression);
-00236                 return FALSE;
-00237         }
-00238 
-00239         pImg->bColorImage = bFillPaletteDIB(pFile, pImg, tHeaderSize > 12);
-00240 
-00241         if (pImg->uiBitsPerComponent <= 8) {
-00242                 pImg->iComponents = 1;
-00243         } else {
-00244                 pImg->iComponents = (int)(pImg->uiBitsPerComponent / 8);
-00245         }
-00246 
-00247         return TRUE;
-00248 } /* end of bExamineDIB */
-00249 
-00250 /*
-00251  * iNextMarker - read the next JPEG marker
-00252  */
-00253 static int
-00254 iNextMarker(FILE *pFile)
-00255 {
-00256         int     iMarker;
-00257 
-00258         do {
-00259                 do {
-00260                         iMarker = iNextByte(pFile);
-00261                 } while (iMarker != 0xff && iMarker != EOF);
-00262                 if (iMarker == EOF) {
-00263                         return EOF;
-00264                 }
-00265                 do {
-00266                         iMarker = iNextByte(pFile);
-00267                 } while (iMarker == 0xff);
-00268         } while (iMarker == 0x00);                      /* repeat if ff/00 */
-00269 
-00270         return iMarker;
-00271 } /* end of iNextMarker */
-00272 
-00273 /*
-00274  * bExamineJPEG - Examine a JPEG header
-00275  *
-00276  * return TRUE if successful, otherwise FALSE
-00277  */
-00278 static BOOL
-00279 bExamineJPEG(FILE *pFile, imagedata_type *pImg)
-00280 {
-00281         size_t  tLength;
-00282         int     iMarker, iIndex;
-00283         char    appstring[10];
-00284         BOOL    bSOFDone;
-00285 
-00286         tLength = 0;
-00287         bSOFDone = FALSE;
-00288 
-00289         /* process JPEG markers */
-00290         while (!bSOFDone && (iMarker = iNextMarker(pFile)) != (int)M_EOI) {
-00291                 switch (iMarker) {
-00292                 case EOF:
-00293                         DBG_MSG("Error: unexpected end of JPEG file");
-00294                         return FALSE;
-00295         /* The following are not officially supported in PostScript level 2 */
-00296                 case M_SOF2:
-00297                 case M_SOF3:
-00298                 case M_SOF5:
-00299                 case M_SOF6:
-00300                 case M_SOF7:
-00301                 case M_SOF9:
-00302                 case M_SOF10:
-00303                 case M_SOF11:
-00304                 case M_SOF13:
-00305                 case M_SOF14:
-00306                 case M_SOF15:
-00307                         DBG_HEX(iMarker);
-00308                         return FALSE;
-00309                 case M_SOF0:
-00310                 case M_SOF1:
-00311                         tLength = (size_t)usNextWordBE(pFile);
-00312                         pImg->uiBitsPerComponent = (UINT)iNextByte(pFile);
-00313                         pImg->iHeight = (int)usNextWordBE(pFile);
-00314                         pImg->iWidth = (int)usNextWordBE(pFile);
-00315                         pImg->iComponents = iNextByte(pFile);
-00316                         bSOFDone = TRUE;
-00317                         break;
-00318                 case M_APP14:
-00319                 /*
-00320                  * Check for Adobe application marker. It is known (per Adobe's
-00321                  * TN5116) to contain the string "Adobe" at the start of the
-00322                  * APP14 marker.
-00323                  */
-00324                         tLength = (size_t)usNextWordBE(pFile);
-00325                         if (tLength < 12) {
-00326                                 (void)tSkipBytes(pFile, tLength - 2);
-00327                         } else {
-00328                                 for (iIndex = 0; iIndex < 5; iIndex++) {
-00329                                         appstring[iIndex] =
-00330                                                         (char)iNextByte(pFile);
-00331                                 }
-00332                                 appstring[5] = '\0';
-00333                                 if (STREQ(appstring, "Adobe")) {
-00334                                         pImg->bAdobe = TRUE;
-00335                                 }
-00336                                 (void)tSkipBytes(pFile, tLength - 7);
-00337                         }
-00338                         break;
-00339                 case M_SOI:             /* ignore markers without parameters */
-00340                 case M_EOI:
-00341                 case M_TEM:
-00342                 case M_RST0:
-00343                 case M_RST1:
-00344                 case M_RST2:
-00345                 case M_RST3:
-00346                 case M_RST4:
-00347                 case M_RST5:
-00348                 case M_RST6:
-00349                 case M_RST7:
-00350                         break;
-00351                 default:                /* skip variable length markers */
-00352                         tLength = (size_t)usNextWordBE(pFile);
-00353                         (void)tSkipBytes(pFile, tLength - 2);
-00354                         break;
-00355                 }
-00356         }
-00357 
-00358         DBG_DEC(pImg->iWidth);
-00359         DBG_DEC(pImg->iHeight);
-00360         DBG_DEC(pImg->uiBitsPerComponent);
-00361         DBG_DEC(pImg->iComponents);
-00362 
-00363         /* Do some sanity checks with the parameters */
-00364         if (pImg->iHeight <= 0 ||
-00365             pImg->iWidth <= 0 ||
-00366             pImg->iComponents <= 0) {
-00367                 DBG_DEC(pImg->iHeight);
-00368                 DBG_DEC(pImg->iWidth);
-00369                 DBG_DEC(pImg->iComponents);
-00370                 return FALSE;
-00371         }
-00372 
-00373         /* Some broken JPEG files have this but they print anyway... */
-00374         if (pImg->iComponents * 3 + 8 != (int)tLength) {
-00375                 DBG_MSG("Warning: SOF marker has incorrect length - ignored");
-00376         }
-00377 
-00378         if (pImg->uiBitsPerComponent != 8) {
-00379                 DBG_DEC(pImg->uiBitsPerComponent);
-00380                 DBG_MSG("Not supported in PostScript level 2");
-00381                 return FALSE;
-00382         }
-00383 
-00384         if (pImg->iComponents != 1 &&
-00385             pImg->iComponents != 3 &&
-00386             pImg->iComponents != 4) {
-00387                 DBG_DEC(pImg->iComponents);
-00388                 return FALSE;
-00389         }
-00390 
-00391         pImg->bColorImage = pImg->iComponents >= 3;
-00392         pImg->iColorsUsed = 0;
-00393         pImg->eCompression = compression_jpeg;
-00394 
-00395         return TRUE;
-00396 } /* end of bExamineJPEG */
-00397 
-00398 /*
-00399  * bFillPalettePNG - fill the palette part of the imagesdata
-00400  *
-00401  * returns TRUE if sucessful, otherwise FALSE;
-00402  */
-00403 static BOOL
-00404 bFillPalettePNG(FILE *pFile, imagedata_type *pImg, size_t tLength)
-00405 {
-00406         int     iIndex, iEntries;
-00407 
-00408         fail(pFile == NULL);
-00409         fail(pImg == NULL);
-00410 
-00411         if (pImg->uiBitsPerComponent > 8) {
-00412                 /* No palette, image uses more than 256 colors */
-00413                 return TRUE;
-00414         }
-00415 
-00416         if (!pImg->bColorImage) {
-00417                 /* Only color images can have a palette */
-00418                 return FALSE;
-00419         }
-00420 
-00421         if (tLength % 3 != 0) {
-00422                 /* Each palette entry takes three bytes */
-00423                 DBG_DEC(tLength);
-00424                 return FALSE;
-00425         }
-00426 
-00427         iEntries = (int)(tLength / 3);
-00428         DBG_DEC(iEntries);
-00429         pImg->iColorsUsed = 1 << pImg->uiBitsPerComponent;
-00430         DBG_DEC(pImg->iColorsUsed);
-00431 
-00432         if (iEntries > 256) {
-00433                 DBG_DEC(iEntries);
-00434                 return FALSE;
-00435         }
-00436 
-00437         for (iIndex = 0; iIndex < iEntries; iIndex++) {
-00438                 pImg->aucPalette[iIndex][0] = (UCHAR)iNextByte(pFile);
-00439                 pImg->aucPalette[iIndex][1] = (UCHAR)iNextByte(pFile);
-00440                 pImg->aucPalette[iIndex][2] = (UCHAR)iNextByte(pFile);
-00441                 NO_DBG_PRINT_BLOCK(pImg->aucPalette[iIndex], 3);
-00442         }
-00443         for (;iIndex < pImg->iColorsUsed; iIndex++) {
-00444                 pImg->aucPalette[iIndex][0] = 0;
-00445                 pImg->aucPalette[iIndex][1] = 0;
-00446                 pImg->aucPalette[iIndex][2] = 0;
-00447         }
-00448 
-00449         return TRUE;
-00450 } /* end of bFillPalettePNG */
-00451 
-00452 /*
-00453  * bExaminePNG - Examine a PNG header
-00454  *
-00455  * return TRUE if successful, otherwise FALSE
-00456  */
-00457 static BOOL
-00458 bExaminePNG(FILE *pFile, imagedata_type *pImg)
-00459 {
-00460         size_t          tLength;
-00461         ULONG           ulLong1, ulLong2, ulName;
-00462         int             iIndex, iTmp;
-00463         int             iCompressionMethod, iFilterMethod, iInterlaceMethod;
-00464         int             iColor, iIncrement;
-00465         BOOL            bHasPalette, bHasAlpha;
-00466         UCHAR   aucBuf[4];
-00467 
-00468         /* Check signature */
-00469         ulLong1 = ulNextLongBE(pFile);
-00470         ulLong2 = ulNextLongBE(pFile);
-00471         if (ulLong1 != 0x89504e47UL || ulLong2 != 0x0d0a1a0aUL) {
-00472                 DBG_HEX(ulLong1);
-00473                 DBG_HEX(ulLong2);
-00474                 return FALSE;
-00475         }
-00476 
-00477         ulName = 0x00;
-00478         bHasPalette = FALSE;
-00479 
-00480         /* Examine chunks */
-00481         while (ulName != PNG_CN_IEND) {
-00482                 tLength = (size_t)ulNextLongBE(pFile);
-00483                 ulName = 0x00;
-00484                 for (iIndex = 0; iIndex < (int)elementsof(aucBuf); iIndex++) {
-00485                         aucBuf[iIndex] = (UCHAR)iNextByte(pFile);
-00486                         if (!isalpha(aucBuf[iIndex])) {
-00487                                 DBG_HEX(aucBuf[iIndex]);
-00488                                 return FALSE;
-00489                         }
-00490                         ulName <<= 8;
-00491                         ulName |= aucBuf[iIndex];
-00492                 }
-00493 
-00494                 switch (ulName) {
-00495                 case PNG_CN_IHDR:
-00496                         /* Header chunck */
-00497                         if (tLength < 13) {
-00498                                 DBG_DEC(tLength);
-00499                                 return FALSE;
-00500                         }
-00501                         pImg->iWidth = (int)ulNextLongBE(pFile);
-00502                         pImg->iHeight = (int)ulNextLongBE(pFile);
-00503                         pImg->uiBitsPerComponent = (UINT)iNextByte(pFile);
-00504                         iTmp = iNextByte(pFile);
-00505                         NO_DBG_HEX(iTmp);
-00506                         pImg->bColorImage = (iTmp & PNG_CB_COLOR) != 0;
-00507                         bHasPalette = (iTmp & PNG_CB_PALETTE) != 0;
-00508                         bHasAlpha = (iTmp & PNG_CB_ALPHA) != 0;
-00509                         if (bHasPalette && pImg->uiBitsPerComponent > 8) {
-00510                                 /* This should not happen */
-00511                                 return FALSE;
-00512                         }
-00513                         pImg->iComponents =
-00514                                 (bHasPalette || !pImg->bColorImage) ? 1 : 3;
-00515                         if (bHasAlpha) {
-00516                                 pImg->iComponents++;
-00517                         }
-00518                         iCompressionMethod = iNextByte(pFile);
-00519                         if (iCompressionMethod != 0) {
-00520                                 DBG_DEC(iCompressionMethod);
-00521                                 return FALSE;
-00522                         }
-00523                         iFilterMethod = iNextByte(pFile);
-00524                         if (iFilterMethod != 0) {
-00525                                 DBG_DEC(iFilterMethod);
-00526                                 return FALSE;
-00527                         }
-00528                         iInterlaceMethod = iNextByte(pFile);
-00529                         if (iInterlaceMethod != 0) {
-00530                                 DBG_DEC(iInterlaceMethod);
-00531                                 return FALSE;
-00532                         }
-00533                         pImg->iColorsUsed = 0;
-00534                         (void)tSkipBytes(pFile, tLength - 13 + 4);
-00535                         break;
-00536                 case PNG_CN_PLTE:
-00537                         if (!bHasPalette) {
-00538                                 return FALSE;
-00539                         }
-00540                         if (!bFillPalettePNG(pFile, pImg, tLength)) {
-00541                                 return FALSE;
-00542                         }
-00543                         (void)tSkipBytes(pFile, 4);
-00544                         break;
-00545                 default:
-00546                         (void)tSkipBytes(pFile, tLength + 4);
-00547                         break;
-00548                 }
-00549         }
-00550 
-00551         DBG_DEC(pImg->iWidth);
-00552         DBG_DEC(pImg->iHeight);
-00553         DBG_DEC(pImg->uiBitsPerComponent);
-00554         DBG_DEC(pImg->iColorsUsed);
-00555         DBG_DEC(pImg->iComponents);
-00556 
-00557         /* Do some sanity checks with the parameters */
-00558         if (pImg->iWidth <= 0 || pImg->iHeight <= 0) {
-00559                 return FALSE;
-00560         }
-00561 
-00562         if (pImg->uiBitsPerComponent != 1 && pImg->uiBitsPerComponent != 2 &&
-00563             pImg->uiBitsPerComponent != 4 && pImg->uiBitsPerComponent != 8 &&
-00564             pImg->uiBitsPerComponent != 16) {
-00565                 DBG_DEC(pImg->uiBitsPerComponent);
-00566                 return  FALSE;
-00567         }
-00568 
-00569         if (pImg->iComponents != 1 && pImg->iComponents != 3) {
-00570                 /* Not supported */
-00571                 DBG_DEC(pImg->iComponents);
-00572                 return FALSE;
-00573         }
-00574 
-00575         if (pImg->uiBitsPerComponent > 8) {
-00576                 /* Not supported */
-00577                 DBG_DEC(pImg->uiBitsPerComponent);
-00578                 return FALSE;
-00579         }
-00580 
-00581         if (pImg->iColorsUsed == 0 &&
-00582             pImg->iComponents == 1 &&
-00583             pImg->uiBitsPerComponent <= 4) {
-00584                 /*
-00585                  * No palette is supplied, but PostScript needs one in these
-00586                  * cases, so we add a default palette here
-00587                  */
-00588                 pImg->iColorsUsed = 1 << pImg->uiBitsPerComponent;
-00589                 iIncrement = 0xff / (pImg->iColorsUsed - 1);
-00590                 for (iIndex = 0, iColor = 0x00;
-00591                      iIndex < pImg->iColorsUsed;
-00592                      iIndex++, iColor += iIncrement) {
-00593                         pImg->aucPalette[iIndex][0] = (UCHAR)iColor;
-00594                         pImg->aucPalette[iIndex][1] = (UCHAR)iColor;
-00595                         pImg->aucPalette[iIndex][2] = (UCHAR)iColor;
-00596                 }
-00597                 /* Just to be sure */
-00598                 pImg->bColorImage = FALSE;
-00599         }
-00600 
-00601         pImg->eCompression = compression_zlib;
-00602 
-00603         return TRUE;
-00604 } /* end of bExaminePNG */
-00605 
-00606 /*
-00607  * bExamineWMF - Examine a WMF header
-00608  *
-00609  * return TRUE if successful, otherwise FALSE
-00610  */
-00611 static BOOL
-00612 bExamineWMF(FILE *pFile, imagedata_type *pImg)
-00613 {
-00614         ULONG   ulFileSize, ulMaxRecord, ulMagic;
-00615         USHORT  usType, usHeaderSize, usVersion, usNoObjects;
-00616 
-00617         usType = usNextWord(pFile);
-00618         usHeaderSize = usNextWord(pFile);
-00619         ulMagic = ((ULONG)usHeaderSize << 16) | (ULONG)usType;
-00620         usVersion = usNextWord(pFile);
-00621         ulFileSize = ulNextLong(pFile);
-00622         usNoObjects = usNextWord(pFile);
-00623         ulMaxRecord = ulNextLong(pFile);
-00624 
-00625         DBG_HEX(ulMagic);
-00626         DBG_DEC(usType);
-00627         DBG_DEC(usHeaderSize);
-00628         DBG_HEX(usVersion);
-00629         DBG_DEC(ulFileSize);
-00630         DBG_DEC(usNoObjects);
-00631         DBG_DEC(ulMaxRecord);
-00632 
-00633         return FALSE;
-00634 } /* end of bExamineWMF */
-00635 
-00636 #if !defined(__riscos)
-00637 /*
-00638  * vImage2Papersize - make sure the image fits on the paper
-00639  *
-00640  * This function should not be needed if Word would do a proper job
-00641  */
-00642 static void
-00643 vImage2Papersize(imagedata_type *pImg)
-00644 {
-00645         static int      iNetPageHeight = -1;
-00646         static int      iNetPageWidth = -1;
-00647         options_type    tOptions;
-00648         double  dVerFactor, dHorFactor, dFactor;
-00649 
-00650         DBG_MSG("vImage2Papersize");
-00651 
-00652         fail(pImg == NULL);
-00653 
-00654         if (iNetPageHeight < 0 || iNetPageWidth < 0) {
-00655                 /* Get the page dimensions from the options */
-00656                 vGetOptions(&tOptions);
-00657                 /* Add 999 to err on the save side */
-00658                 iNetPageHeight = tOptions.iPageHeight -
-00659                                 (lDrawUnits2MilliPoints(
-00660                                         PS_TOP_MARGIN + PS_BOTTOM_MARGIN) +
-00661                                         999) / 1000;
-00662                 iNetPageWidth = tOptions.iPageWidth -
-00663                                 (lDrawUnits2MilliPoints(
-00664                                         PS_LEFT_MARGIN + PS_RIGHT_MARGIN) +
-00665                                         999) / 1000;
-00666                 DBG_DEC(iNetPageHeight);
-00667                 DBG_DEC(iNetPageWidth);
-00668         }
-00669 
-00670         if (pImg->iVerSizeScaled < iNetPageHeight &&
-00671             pImg->iHorSizeScaled < iNetPageWidth) {
-00672                 /* The image fits on the paper */
-00673                 return;
-00674         }
-00675 
-00676         dVerFactor = (double)iNetPageHeight / (double)pImg->iVerSizeScaled;
-00677         dHorFactor = (double)iNetPageWidth / (double)pImg->iHorSizeScaled;
-00678         dFactor = min(dVerFactor, dHorFactor);
-00679         DBG_FLT(dFactor);
-00680         /* Round down, just to be on the save side */
-00681         pImg->iVerSizeScaled = (int)(pImg->iVerSizeScaled * dFactor);
-00682         pImg->iHorSizeScaled = (int)(pImg->iHorSizeScaled * dFactor);
-00683 } /* end of vImage2Papersize */
-00684 #endif /* !__riscos */
-00685 
-00686 /*
-00687  * tFind6Image - skip until the image is found
-00688  *
-00689  * Find the image in Word 6/7 files
-00690  *
-00691  * returns the new position when a image is found, otherwise -1
-00692  */
-00693 static size_t
-00694 tFind6Image(FILE *pFile, size_t tPosition, size_t tLength,
-00695         imagetype_enum *peImageType)
-00696 {
-00697         ULONG   ulMarker;
-00698         size_t  tRecordLength, tToSkip;
-00699         USHORT  usMarker;
-00700 
-00701         fail(pFile == NULL);
-00702         fail(peImageType == NULL);
-00703 
-00704         *peImageType = imagetype_is_unknown;
-00705         if (tPosition + 18 >= tLength) {
-00706                 return (size_t)-1;
-00707         }
-00708 
-00709         ulMarker = ulNextLong(pFile);
-00710         if (ulMarker != 0x00090001) {
-00711                 DBG_HEX(ulMarker);
-00712                 return (size_t)-1;
-00713         }
-00714         usMarker = usNextWord(pFile);
-00715         if (usMarker != 0x0300) {
-00716                 DBG_HEX(usMarker);
-00717                 return (size_t)-1;
-00718         }
-00719         (void)tSkipBytes(pFile, 10);
-00720         usMarker = usNextWord(pFile);
-00721         if (usMarker != 0x0000) {
-00722                 DBG_HEX(usMarker);
-00723                 return (size_t)-1;
-00724         }
-00725         tPosition += 18;
-00726 
-00727         while (tPosition + 6 <= tLength) {
-00728                 tRecordLength = (size_t)ulNextLong(pFile);
-00729                 usMarker = usNextWord(pFile);
-00730                 tPosition += 6;
-00731                 NO_DBG_DEC(tRecordLength);
-00732                 NO_DBG_HEX(usMarker);
-00733                 switch (usMarker) {
-00734                 case 0x0000:
-00735                         DBG_HEX(ulGetDataOffset(pFile));
-00736                         return (size_t)-1;
-00737                 case 0x0b41:
-00738                         DBG_MSG("DIB");
-00739                         *peImageType = imagetype_is_dib;
-00740                         tPosition += tSkipBytes(pFile, 20);
-00741                         return tPosition;
-00742                 case 0x0f43:
-00743                         DBG_MSG("DIB");
-00744                         *peImageType = imagetype_is_dib;
-00745                         tPosition += tSkipBytes(pFile, 22);
-00746                         return tPosition;
-00747                 default:
-00748                         if (tRecordLength < 3) {
-00749                                 break;
-00750                         }
-00751                         if (tRecordLength > SIZE_T_MAX / 2) {
-00752                                 /*
-00753                                  * No need to compute the number of bytes
-00754                                  * to skip
-00755                                  */
-00756                                 DBG_DEC(tRecordLength);
-00757                                 DBG_HEX(tRecordLength);
-00758                                 DBG_FIXME();
-00759                                 return (size_t)-1;
-00760                         }
-00761                         tToSkip = tRecordLength * 2 - 6;
-00762                         if (tToSkip > tLength - tPosition) {
-00763                                 /* You can't skip this number of bytes */
-00764                                 DBG_DEC(tToSkip);
-00765                                 DBG_DEC(tLength - tPosition);
-00766                                 return (size_t)-1;
-00767                         }
-00768                         tPosition += tSkipBytes(pFile, tToSkip);
-00769                         break;
-00770                 }
-00771         }
-00772 
-00773         return (size_t)-1;
-00774 } /* end of tFind6Image */
-00775 
-00776 /*
-00777  * tFind8Image - skip until the image is found
-00778  *
-00779  * Find the image in Word 8/9/10 files
-00780  *
-00781  * returns the new position when a image is found, otherwise -1
-00782  */
-00783 static size_t
-00784 tFind8Image(FILE *pFile, size_t tPosition, size_t tLength,
-00785         imagetype_enum *peImageType)
-00786 {
-00787         size_t  tRecordLength, tNameLen;
-00788         USHORT  usRecordVersion, usRecordType, usRecordInstance;
-00789         USHORT  usTmp;
-00790 
-00791         fail(pFile == NULL);
-00792         fail(peImageType == NULL);
-00793 
-00794         *peImageType = imagetype_is_unknown;
-00795         while (tPosition + 8 <= tLength) {
-00796                 usTmp = usNextWord(pFile);
-00797                 usRecordVersion = usTmp & 0x000f;
-00798                 usRecordInstance = usTmp >> 4;
-00799                 usRecordType = usNextWord(pFile);
-00800                 tRecordLength = (size_t)ulNextLong(pFile);
-00801                 tPosition += 8;
-00802                 NO_DBG_HEX(usRecordVersion);
-00803                 NO_DBG_HEX(usRecordInstance);
-00804                 NO_DBG_HEX(usRecordType);
-00805                 NO_DBG_DEC(tRecordLength);
-00806                 switch (usRecordType) {
-00807                 case 0xf000: case 0xf001: case 0xf002: case 0xf003:
-00808                 case 0xf004: case 0xf005:
-00809                         break;
-00810                 case 0xf007:
-00811                         tPosition += tSkipBytes(pFile, 33);
-00812                         tNameLen = (size_t)iNextByte(pFile);
-00813                         tPosition++;
-00814                         DBG_DEC_C(tNameLen != 0, tNameLen);
-00815                         tPosition += tSkipBytes(pFile, 2 + tNameLen * 2);
-00816                         break;
-00817                 case 0xf008:
-00818                         tPosition += tSkipBytes(pFile, 8);
-00819                         break;
-00820                 case 0xf009:
-00821                         tPosition += tSkipBytes(pFile, 16);
-00822                         break;
-00823                 case 0xf006: case 0xf00a: case 0xf00b: case 0xf00d:
-00824                 case 0xf00e: case 0xf00f: case 0xf010: case 0xf011:
-00825                 case 0xf122:
-00826                         tPosition += tSkipBytes(pFile, tRecordLength);
-00827                         break;
-00828                 case 0xf01a:
-00829                         DBG_MSG("EMF");
-00830                         *peImageType = imagetype_is_emf;
-00831                         tPosition += tSkipBytes(pFile, 50);
-00832                         if ((usRecordInstance ^ MSOBI_EMF) == 1) {
-00833                                 tPosition += tSkipBytes(pFile, 16);
-00834                         }
-00835                         return tPosition;
-00836                 case 0xf01b:
-00837                         DBG_MSG("WMF");
-00838                         *peImageType = imagetype_is_wmf;
-00839                         tPosition += tSkipBytes(pFile, 50);
-00840                         if ((usRecordInstance ^ MSOBI_WMF) == 1) {
-00841                                 tPosition += tSkipBytes(pFile, 16);
-00842                         }
-00843                         return tPosition;
-00844                 case 0xf01c:
-00845                         DBG_MSG("PICT");
-00846                         *peImageType = imagetype_is_pict;
-00847                         tPosition += tSkipBytes(pFile, 50);
-00848                         if ((usRecordInstance ^ MSOBI_PICT) == 1) {
-00849                                 tPosition += tSkipBytes(pFile, 16);
-00850                         }
-00851                         return tPosition;
-00852                 case 0xf01d:
-00853                         DBG_MSG("JPEG");
-00854                         *peImageType = imagetype_is_jpeg;
-00855                         tPosition += tSkipBytes(pFile, 17);
-00856                         if ((usRecordInstance ^ MSOBI_JPEG) == 1) {
-00857                                 tPosition += tSkipBytes(pFile, 16);
-00858                         }
-00859                         return tPosition;
-00860                 case 0xf01e:
-00861                         DBG_MSG("PNG");
-00862                         *peImageType = imagetype_is_png;
-00863                         tPosition += tSkipBytes(pFile, 17);
-00864                         if ((usRecordInstance ^ MSOBI_PNG) == 1) {
-00865                                 tPosition += tSkipBytes(pFile, 16);
-00866                         }
-00867                         return tPosition;
-00868                 case 0xf01f:
-00869                         DBG_MSG("DIB");
-00870                         /* DIB is a BMP minus its 14 byte header */
-00871                         *peImageType = imagetype_is_dib;
-00872                         tPosition += tSkipBytes(pFile, 17);
-00873                         if ((usRecordInstance ^ MSOBI_DIB) == 1) {
-00874                                 tPosition += tSkipBytes(pFile, 16);
-00875                         }
-00876                         return tPosition;
-00877                 case 0xf00c:
-00878                 default:
-00879                         DBG_HEX(usRecordType);
-00880                         DBG_DEC_C(tRecordLength % 4 != 0, tRecordLength);
-00881                         DBG_FIXME();
-00882                         return (size_t)-1;
-00883                 }
-00884         }
-00885 
-00886         return (size_t)-1;
-00887 } /* end of tFind8Image */
-00888 
-00889 /*
-00890  * eExamineImage - Examine the image
-00891  *
-00892  * Returns an indication of the amount of information found
-00893  */
-00894 image_info_enum
-00895 eExamineImage(FILE *pFile, ULONG ulFileOffsetImage, imagedata_type *pImg)
-00896 {
-00897         long    lTmp;
-00898         size_t  tWordHeaderLen, tLength, tPos;
-00899         int     iType, iHorSize, iVerSize;
-00900         USHORT  usHorScalingFactor, usVerScalingFactor;
-00901 
-00902         if (ulFileOffsetImage == FC_INVALID) {
-00903                 return image_no_information;
-00904         }
-00905         DBG_HEX(ulFileOffsetImage);
-00906 
-00907         if (!bSetDataOffset(pFile, ulFileOffsetImage)) {
-00908                 return image_no_information;
-00909         }
-00910 
-00911         tLength = (size_t)ulNextLong(pFile);
-00912         DBG_DEC(tLength);
-00913         if (tLength < 46) {
-00914                 /* Smaller than the smallest known header */
-00915                 DBG_FIXME();
-00916                 return image_no_information;
-00917         }
-00918         tWordHeaderLen = (size_t)usNextWord(pFile);
-00919         DBG_DEC(tWordHeaderLen);
-00920         fail(tWordHeaderLen != 46 &&
-00921                 tWordHeaderLen != 58 &&
-00922                 tWordHeaderLen != 68);
-00923 
-00924         if (tLength < tWordHeaderLen) {
-00925                 /* Smaller than the current header */
-00926                 return image_no_information;
-00927         }
-00928         iType = (int)usNextWord(pFile);
-00929         DBG_DEC(iType);
-00930         (void)tSkipBytes(pFile, 28 - 8);
-00931 
-00932         lTmp = lTwips2MilliPoints(usNextWord(pFile));
-00933         iHorSize = (int)(lTmp / 1000);
-00934         if (lTmp % 1000 != 0) {
-00935                 iHorSize++;
-00936         }
-00937         DBG_DEC(iHorSize);
-00938         lTmp = lTwips2MilliPoints(usNextWord(pFile));
-00939         iVerSize = (int)(lTmp / 1000);
-00940         if (lTmp % 1000 != 0) {
-00941                 iVerSize++;
-00942         }
-00943         DBG_DEC(iVerSize);
-00944 
-00945         usHorScalingFactor = usNextWord(pFile);
-00946         DBG_DEC(usHorScalingFactor);
-00947         usVerScalingFactor = usNextWord(pFile);
-00948         DBG_DEC(usVerScalingFactor);
-00949 
-00950         /* Sanity checks */
-00951         lTmp = (long)iHorSize * (long)usHorScalingFactor;
-00952         if (lTmp < 2835) {
-00953                 /* This image would be less than 1 millimeter wide */
-00954                 DBG_DEC(lTmp);
-00955                 return image_no_information;
-00956         }
-00957         lTmp = (long)iVerSize * (long)usVerScalingFactor;
-00958         if (lTmp < 2835) {
-00959                 /* This image would be less than 1 millimeter high */
-00960                 DBG_DEC(lTmp);
-00961                 return image_no_information;
-00962         }
-00963 
-00964         /* Skip the rest of the header */
-00965         (void)tSkipBytes(pFile, tWordHeaderLen - 36);
-00966         tPos = tWordHeaderLen;
-00967 
-00968         (void)memset(pImg, 0, sizeof(*pImg));
-00969 
-00970         switch (iType) {
-00971         case   7:
-00972         case   8:
-00973                 tPos = tFind6Image(pFile, tPos, tLength, &pImg->eImageType);
-00974                 if (tPos == (size_t)-1) {
-00975                         /* No image found */
-00976                         return image_no_information;
-00977                 }
-00978                 DBG_HEX(tPos);
-00979                 break;
-00980         case  94:       /* Word 6/7, no image just a pathname */
-00981                 pImg->eImageType = imagetype_is_external;
-00982                 DBG_HEX(ulFileOffsetImage + tPos);
-00983                 break;
-00984         case 100:
-00985                 tPos = tFind8Image(pFile, tPos, tLength, &pImg->eImageType);
-00986                 if (tPos == (size_t)-1) {
-00987                         /* No image found */
-00988                         return image_no_information;
-00989                 }
-00990                 DBG_HEX(tPos);
-00991                 break;
-00992         case 102:       /* Word 8/9/10, no image just a pathname or URL */
-00993                 pImg->eImageType = imagetype_is_external;
-00994                 DBG_HEX(ulFileOffsetImage + tPos);
-00995                 break;
-00996         default:
-00997                 DBG_DEC(iType);
-00998                 DBG_HEX(ulFileOffsetImage + tPos);
-00999                 DBG_FIXME();
-01000                 return image_no_information;
-01001         }
-01002 
-01003         /* Minimal information is now available */
-01004         pImg->tLength = tLength;
-01005         pImg->tPosition = tPos;
-01006         pImg->iHorSizeScaled =
-01007                 (int)(((long)iHorSize * (long)usHorScalingFactor + 500) / 1000);
-01008         pImg->iVerSizeScaled =
-01009                 (int)(((long)iVerSize * (long)usVerScalingFactor + 500) / 1000);
-01010 #if !defined(__riscos)
-01011         vImage2Papersize(pImg);
-01012 #endif /* !__riscos */
-01013 
-01014         /* Image type specific examinations */
-01015         switch (pImg->eImageType) {
-01016         case imagetype_is_dib:
-01017                 if (bExamineDIB(pFile, pImg)) {
-01018                         return image_full_information;
-01019                 }
-01020                 return image_minimal_information;
-01021         case imagetype_is_jpeg:
-01022                 if (bExamineJPEG(pFile, pImg)) {
-01023                         return image_full_information;
-01024                 }
-01025                 return image_minimal_information;
-01026         case imagetype_is_png:
-01027                 if (bExaminePNG(pFile, pImg)) {
-01028                         return image_full_information;
-01029                 }
-01030                 return image_minimal_information;
-01031         case imagetype_is_wmf:
-01032                 if (bExamineWMF(pFile, pImg)) {
-01033                         return image_full_information;
-01034                 }
-01035                 return image_minimal_information;
-01036         case imagetype_is_emf:
-01037         case imagetype_is_pict:
-01038         case imagetype_is_external:
-01039                 return image_minimal_information;
-01040         case imagetype_is_unknown:
-01041         default:
-01042                 return image_no_information;
-01043         }
-01044 } /* end of eExamineImage */
-
-
Generated by  - -doxygen 1.6.2
- - diff -r 59758314f811 -r d4524d6a4472 Symbian3/Examples/guid-6013a680-57f9-415b-8851-c4fa63356636/imgtrans_8c_source.html --- a/Symbian3/Examples/guid-6013a680-57f9-415b-8851-c4fa63356636/imgtrans_8c_source.html Fri Jun 11 15:24:34 2010 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,87 +0,0 @@ - - - - -TB9.2 Example Applications: examples/PIPS/antiword/src/imgtrans.c Source File - - - - - -

examples/PIPS/antiword/src/imgtrans.c

00001 /*
-00002  * imgtrans.c
-00003  * Copyright (C) 2000-2002 A.J. van Os; Released under GPL
-00004  *
-00005  * Description:
-00006  * Generic functions to translate Word images
-00007  */
-00008 
-00009 #include <stdio.h>
-00010 #include "antiword.h"
-00011 
-00012 
-00013 /*
-00014  * bTranslateImage - translate the image
-00015  *
-00016  * This function reads the type of the given image and and gets it translated.
-00017  *
-00018  * return TRUE when sucessful, otherwise FALSE
-00019  */
-00020 BOOL
-00021 bTranslateImage(diagram_type *pDiag, FILE *pFile, BOOL bMinimalInformation,
-00022         ULONG ulFileOffsetImage, const imagedata_type *pImg)
-00023 {
-00024         options_type    tOptions;
-00025 
-00026         DBG_MSG("bTranslateImage");
-00027 
-00028         fail(pDiag == NULL);
-00029         fail(pFile == NULL);
-00030         fail(ulFileOffsetImage == FC_INVALID);
-00031         fail(pImg == NULL);
-00032         fail(pImg->iHorSizeScaled <= 0);
-00033         fail(pImg->iVerSizeScaled <= 0);
-00034 
-00035         vGetOptions(&tOptions);
-00036         fail(tOptions.eImageLevel == level_no_images);
-00037 
-00038         if (bMinimalInformation) {
-00039                 return bAddDummyImage(pDiag, pImg);
-00040         }
-00041 
-00042         switch (pImg->eImageType) {
-00043         case imagetype_is_dib:
-00044                 return bTranslateDIB(pDiag, pFile,
-00045                                 ulFileOffsetImage + pImg->tPosition,
-00046                                 pImg);
-00047         case imagetype_is_jpeg:
-00048                 return bTranslateJPEG(pDiag, pFile,
-00049                                 ulFileOffsetImage + pImg->tPosition,
-00050                                 pImg->tLength - pImg->tPosition,
-00051                                 pImg);
-00052         case imagetype_is_png:
-00053                 if (tOptions.eImageLevel == level_ps_2) {
-00054                         return bAddDummyImage(pDiag, pImg);
-00055                 }
-00056                 return bTranslatePNG(pDiag, pFile,
-00057                                 ulFileOffsetImage + pImg->tPosition,
-00058                                 pImg->tLength - pImg->tPosition,
-00059                                 pImg);
-00060         case imagetype_is_emf:
-00061         case imagetype_is_wmf:
-00062         case imagetype_is_pict:
-00063         case imagetype_is_external:
-00064                 /* FIXME */
-00065                 return bAddDummyImage(pDiag, pImg);
-00066         case imagetype_is_unknown:
-00067         default:
-00068                 DBG_DEC(pImg->eImageType);
-00069                 return bAddDummyImage(pDiag, pImg);
-00070         }
-00071 } /* end of bTranslateImage */
-
-
Generated by  - -doxygen 1.6.2
- - diff -r 59758314f811 -r d4524d6a4472 Symbian3/Examples/guid-6013a680-57f9-415b-8851-c4fa63356636/jpeg2eps_8c_source.html --- a/Symbian3/Examples/guid-6013a680-57f9-415b-8851-c4fa63356636/jpeg2eps_8c_source.html Fri Jun 11 15:24:34 2010 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,90 +0,0 @@ - - - - -TB9.2 Example Applications: examples/PIPS/antiword/src/jpeg2eps.c Source File - - - - - -

examples/PIPS/antiword/src/jpeg2eps.c

00001 /*
-00002  * jpeg2eps.c
-00003  * Copyright (C) 2000-2002 A.J. van Os; Released under GPL
-00004  *
-00005  * Description:
-00006  * Functions to translate jpeg pictures into eps
-00007  *
-00008  */
-00009 
-00010 #include <stdio.h>
-00011 #include "antiword.h"
-00012 
-00013 #if defined(DEBUG)
-00014 static int      iPicCounter = 0;
-00015 #endif /* DEBUG */
-00016 
-00017 
-00018 #if defined(DEBUG)
-00019 /*
-00020  * vCopy2File
-00021  */
-00022 static void
-00023 vCopy2File(FILE *pFile, ULONG ulFileOffset, size_t tPictureLen)
-00024 {
-00025         FILE    *pOutFile;
-00026         size_t  tIndex;
-00027         int     iTmp;
-00028         char    szFilename[30];
-00029 
-00030         if (!bSetDataOffset(pFile, ulFileOffset)) {
-00031                 return;
-00032         }
-00033 
-00034         sprintf(szFilename, "/tmp/pic/pic%04d.jpg", ++iPicCounter);
-00035         pOutFile = fopen(szFilename, "wb");
-00036         if (pOutFile == NULL) {
-00037                 return;
-00038         }
-00039         for (tIndex = 0; tIndex < tPictureLen; tIndex++) {
-00040                 iTmp = iNextByte(pFile);
-00041                 if (putc(iTmp, pOutFile) == EOF) {
-00042                         break;
-00043                 }
-00044         }
-00045         (void)fclose(pOutFile);
-00046 } /* end of vCopy2File */
-00047 #endif /* DEBUG */
-00048 
-00049 /*
-00050  * bTranslateJPEG - translate a JPEG picture
-00051  *
-00052  * This function translates a picture from jpeg to eps
-00053  *
-00054  * return TRUE when sucessful, otherwise FALSE
-00055  */
-00056 BOOL
-00057 bTranslateJPEG(diagram_type *pDiag, FILE *pFile,
-00058         ULONG ulFileOffset, size_t tPictureLen, const imagedata_type *pImg)
-00059 {
-00060 #if defined(DEBUG)
-00061         vCopy2File(pFile, ulFileOffset, tPictureLen);
-00062 #endif /* DEBUG */
-00063 
-00064         /* Seek to start position of JPEG data */
-00065         if (!bSetDataOffset(pFile, ulFileOffset)) {
-00066                 return FALSE;
-00067         }
-00068 
-00069         vImagePrologue(pDiag, pImg);
-00070         vASCII85EncodeFile(pFile, pDiag->pOutFile, tPictureLen);
-00071         vImageEpilogue(pDiag);
-00072 
-00073         return TRUE;
-00074 } /* end of bTranslateJPEG */
-
-
Generated by  - -doxygen 1.6.2
- - diff -r 59758314f811 -r d4524d6a4472 Symbian3/Examples/guid-6013a680-57f9-415b-8851-c4fa63356636/jpeg2sprt_8c_source.html --- a/Symbian3/Examples/guid-6013a680-57f9-415b-8851-c4fa63356636/jpeg2sprt_8c_source.html Fri Jun 11 15:24:34 2010 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,116 +0,0 @@ - - - - -TB9.2 Example Applications: examples/PIPS/antiword/src/jpeg2sprt.c Source File - - - - - -

examples/PIPS/antiword/src/jpeg2sprt.c

00001 /*
-00002  * jpeg2sprt.c
-00003  * Copyright (C) 2000-2002 A.J. van Os; Released under GPL
-00004  *
-00005  * Description:
-00006  * Functions to translate jpeg pictures into sprites
-00007  */
-00008 
-00009 #include <stdio.h>
-00010 #include "antiword.h"
-00011 
-00012 #if 0 /* defined(DEBUG) */
-00013 static int iPicCounter = 0;
-00014 #endif /* DEBUG */
-00015 
-00016 
-00017 #if 0 /* defined(DEBUG) */
-00018 static void
-00019 vCopy2File(UCHAR *pucJpeg, size_t tJpegSize)
-00020 {
-00021         FILE    *pOutFile;
-00022         size_t  tIndex;
-00023         char    szFilename[30];
-00024 
-00025         sprintf(szFilename, "<Wimp$ScrapDir>.jpeg%04d", ++iPicCounter);
-00026         pOutFile = fopen(szFilename, "wb");
-00027         if (pOutFile == NULL) {
-00028                 return;
-00029         }
-00030         DBG_MSG(szFilename);
-00031         for (tIndex = 0; tIndex < tJpegSize; tIndex++) {
-00032                 if (putc(pucJpeg[tIndex], pOutFile) == EOF) {
-00033                         break;
-00034                 }
-00035         }
-00036         (void)fclose(pOutFile);
-00037         vSetFiletype(szFilename, FILETYPE_JPEG);
-00038 } /* end of vCopy2File */
-00039 #endif /* DEBUG */
-00040 
-00041 /*
-00042  * bSave2Draw - save the JPEG picture to the Draw file
-00043  *
-00044  * This function puts a JPEG picture in a Draw file
-00045  *
-00046  * return TRUE when sucessful, otherwise FALSE
-00047  */
-00048 BOOL
-00049 bSave2Draw(diagram_type *pDiag, FILE *pFile,
-00050         size_t tJpegSize, const imagedata_type *pImg)
-00051 {
-00052         UCHAR   *pucJpeg, *pucTmp;
-00053         size_t  tLen;
-00054         int     iByte;
-00055 
-00056         pucJpeg = xmalloc(tJpegSize);
-00057         for (pucTmp = pucJpeg, tLen = 0; tLen < tJpegSize; pucTmp++, tLen++) {
-00058                 iByte = iNextByte(pFile);
-00059                 if (iByte == EOF) {
-00060                         return FALSE;
-00061                 }
-00062                 *pucTmp = (UCHAR)iByte;
-00063         }
-00064 
-00065 #if 0 /* defined(DEBUG) */
-00066         vCopy2File(pucJpeg, tJpegSize);
-00067 #endif /* DEBUG */
-00068 
-00069         /* Add the JPEG to the Draw file */
-00070         vImage2Diagram(pDiag, pImg, pucJpeg, tJpegSize);
-00071 
-00072         xfree(pucJpeg);
-00073         return TRUE;
-00074 } /* end of bSave2Draw */
-00075 
-00076 /*
-00077  * bTranslateJPEG - translate a JPEG picture
-00078  *
-00079  * This function translates a picture from jpeg to sprite
-00080  *
-00081  * return TRUE when sucessful, otherwise FALSE
-00082  */
-00083 #if 0
-00084 BOOL
-00085 bTranslateJPEG(diagram_type *pDiag, FILE *pFile,
-00086         ULONG ulFileOffset, size_t tPictureLen, const imagedata_type *pImg)
-00087 {
-00088         /* Seek to start position of JPEG data */
-00089         if (!bSetDataOffset(pFile, ulFileOffset)) {
-00090                 return FALSE;
-00091         }
-00092 
-00093         if (iGetRiscOsVersion() >= 360) {
-00094                 return bSave2Draw(pDiag, pFile, tPictureLen, pImg);
-00095         }
-00096         /* JPEG is not supported until RISC OS 3.6 */
-00097         return bAddDummyImage(pDiag, pImg);
-00098 } /* end of bTranslateJPEG */
-00099 
-00100 #endif/*0*/
-
-
Generated by  - -doxygen 1.6.2
- - diff -r 59758314f811 -r d4524d6a4472 Symbian3/Examples/guid-6013a680-57f9-415b-8851-c4fa63356636/listlist_8c_source.html --- a/Symbian3/Examples/guid-6013a680-57f9-415b-8851-c4fa63356636/listlist_8c_source.html Fri Jun 11 15:24:34 2010 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,346 +0,0 @@ - - - - -TB9.2 Example Applications: examples/PIPS/antiword/src/listlist.c Source File - - - - - -

examples/PIPS/antiword/src/listlist.c

00001 /*
-00002  * listlist.c
-00003  * Copyright (C) 2002,2003 A.J. van Os; Released under GPL
-00004  *
-00005  * Description:
-00006  * Build, read and destroy a list of Word list information
-00007  *
-00008  * Note:
-00009  * This list only exists when the Word document is saved by Word 8 or later
-00010  */
-00011 
-00012 #include "antiword.h"
-00013 
-00014 /*
-00015  * Private structure to hide the way the information
-00016  * is stored from the rest of the program
-00017  */
-00018 typedef struct list_desc_tag {
-00019         list_block_type         tInfo;
-00020         ULONG                   ulListID;
-00021         USHORT                  usIstd;
-00022         UCHAR                   ucListLevel;
-00023         struct list_desc_tag    *pNext;
-00024 } list_desc_type;
-00025 
-00026 typedef struct list_value_tag {
-00027         USHORT                  usValue;
-00028         USHORT                  usListIndex;
-00029         UCHAR                   ucListLevel;
-00030         struct list_value_tag   *pNext;
-00031 } list_value_type;
-00032 
-00033 /* Variables needed to describe the LFO list (pllfo) */
-00034 static ULONG            *aulLfoList = NULL;
-00035 static USHORT           usLfoLen = 0;
-00036 /* Variables needed to write the List Information List */
-00037 static list_desc_type   *pAnchor = NULL;
-00038 static list_desc_type   *pBlockLast = NULL;
-00039 /* Variable needed for numbering new lists */
-00040 static list_value_type  *pValues = NULL;
-00041 /* Variables needed for numbering old lists */
-00042 static int      iOldListSeqNumber = 0;
-00043 static USHORT   usOldListValue = 0;
-00044 
-00045 
-00046 /*
-00047  * vDestroyListInfoList - destroy the List Information List
-00048  */
-00049 void
-00050 vDestroyListInfoList(void)
-00051 {
-00052         list_desc_type  *pCurr, *pNext;
-00053         list_value_type *pValueCurr, *pValueNext;
-00054 
-00055         DBG_MSG("vDestroyListInfoList");
-00056 
-00057         /* Free the LFO list */
-00058         usLfoLen = 0;
-00059         aulLfoList = xfree(aulLfoList);
-00060 
-00061         /* Free the List Information List */
-00062         pCurr = pAnchor;
-00063         while (pCurr != NULL) {
-00064                 pNext = pCurr->pNext;
-00065                 pCurr = xfree(pCurr);
-00066                 pCurr = pNext;
-00067         }
-00068         pAnchor = NULL;
-00069         /* Reset all control variables */
-00070         pBlockLast = NULL;
-00071 
-00072         /* Free the values list */
-00073         pValueCurr = pValues;
-00074         while (pValueCurr != NULL) {
-00075                 pValueNext = pValueCurr->pNext;
-00076                 pValueCurr = xfree(pValueCurr);
-00077                 pValueCurr = pValueNext;
-00078         }
-00079         pValues = NULL;
-00080         /* Reset the values for the old lists */
-00081         iOldListSeqNumber = 0;
-00082         usOldListValue = 0;
-00083 } /* end of vDestroyListInfoList */
-00084 
-00085 /*
-00086  * vBuildLfoList - build the LFO list (pllfo)
-00087  */
-00088 void
-00089 vBuildLfoList(const UCHAR *aucBuffer, size_t tBufLen)
-00090 {
-00091         size_t  tRecords;
-00092         int     iIndex;
-00093 
-00094         fail(aucBuffer == NULL);
-00095 
-00096         if (tBufLen < 4) {
-00097                 return;
-00098         }
-00099         tRecords = (size_t)ulGetLong(0, aucBuffer);
-00100         NO_DBG_DEC(tRecords);
-00101         if (4 + 16 * tRecords > tBufLen || tRecords >= 0x7fff) {
-00102                 /* Just a sanity check */
-00103                 DBG_DEC(tRecords);
-00104                 DBG_DEC(4 + 16 * tRecords);
-00105                 DBG_DEC(tBufLen);
-00106                 return;
-00107         }
-00108         aulLfoList = xcalloc(tRecords, sizeof(ULONG));
-00109         for (iIndex = 0; iIndex < (int)tRecords; iIndex++) {
-00110                 aulLfoList[iIndex] = ulGetLong(4 + 16 * iIndex, aucBuffer);
-00111                 NO_DBG_HEX(aulLfoList[iIndex]);
-00112         }
-00113         usLfoLen = (USHORT)tRecords;
-00114 } /* end of vBuildLfoList */
-00115 
-00116 /*
-00117  * vAdd2ListInfoList - add an element to the List Information list
-00118  */
-00119 void
-00120 vAdd2ListInfoList(ULONG ulListID, USHORT usIstd, UCHAR ucListLevel,
-00121         const list_block_type *pListBlock)
-00122 {
-00123         list_desc_type  *pListMember;
-00124 
-00125         fail(pListBlock == NULL);
-00126 
-00127         NO_DBG_HEX(ulListID);
-00128         NO_DBG_DEC(usIstd);
-00129         NO_DBG_DEC(ucListLevel);
-00130         NO_DBG_DEC(pListBlock->ulStartAt);
-00131         NO_DBG_DEC(pListBlock->bNoRestart);
-00132         NO_DBG_DEC(pListBlock->sLeftIndent);
-00133         NO_DBG_HEX(pListBlock->ucNFC);
-00134         NO_DBG_HEX(pListBlock->usListChar);
-00135 
-00136         /* Create list member */
-00137         pListMember = xmalloc(sizeof(list_desc_type));
-00138         /* Fill the list member */
-00139         pListMember->tInfo = *pListBlock;
-00140         pListMember->ulListID = ulListID;
-00141         pListMember->usIstd = usIstd;
-00142         pListMember->ucListLevel = ucListLevel;
-00143         pListMember->pNext = NULL;
-00144         /* Correct the values where needed */
-00145         if (pListMember->tInfo.ulStartAt > 0xffff) {
-00146                 DBG_DEC(pListMember->tInfo.ulStartAt);
-00147                 pListMember->tInfo.ulStartAt = 1;
-00148         }
-00149         /* Add the new member to the list */
-00150         if (pAnchor == NULL) {
-00151                 pAnchor = pListMember;
-00152         } else {
-00153                 fail(pBlockLast == NULL);
-00154                 pBlockLast->pNext = pListMember;
-00155         }
-00156         pBlockLast = pListMember;
-00157 } /* end of vAdd2ListInfoList */
-00158 
-00159 /*
-00160  * Get a matching record from the List Information List
-00161  *
-00162  * Returns NULL if no matching records is found
-00163  */
-00164 const list_block_type *
-00165 pGetListInfo(USHORT usListIndex, UCHAR ucListLevel)
-00166 {
-00167         list_desc_type  *pCurr;
-00168         list_block_type *pNearMatch;
-00169         ULONG   ulListID;
-00170 
-00171         if (usListIndex == 0) {
-00172                 return NULL;
-00173         }
-00174         if (usListIndex - 1 >= usLfoLen || ucListLevel > 8) {
-00175                 DBG_DEC(usListIndex);
-00176                 DBG_DEC(ucListLevel);
-00177                 return NULL;
-00178         }
-00179         fail(aulLfoList == NULL);
-00180         ulListID = aulLfoList[usListIndex - 1];
-00181         NO_DBG_HEX(ulListID);
-00182 
-00183         pNearMatch = NULL;
-00184         for (pCurr = pAnchor; pCurr != NULL; pCurr = pCurr->pNext) {
-00185                 if (pCurr->ulListID != ulListID) {
-00186                         /* No match */
-00187                         continue;
-00188                 }
-00189                 if (pCurr->ucListLevel == ucListLevel) {
-00190                         /* Exact match */
-00191                         return &pCurr->tInfo;
-00192                 }
-00193                 if (pCurr->ucListLevel == 0) {
-00194                         /* Near match */
-00195                         pNearMatch = &pCurr->tInfo;
-00196                 }
-00197         }
-00198         /* No exact match, use a near match if any */
-00199         return pNearMatch;
-00200 } /* end of pGetListInfo */
-00201 
-00202 /*
-00203  * Get a matching record from the List Information List
-00204  *
-00205  * Returns NULL if no matching records is found
-00206  */
-00207 const list_block_type *
-00208 pGetListInfoByIstd(USHORT usIstd)
-00209 {
-00210         list_desc_type  *pCurr;
-00211 
-00212         if (usIstd == ISTD_INVALID || usIstd == STI_NIL || usIstd == STI_USER) {
-00213                 return NULL;
-00214         }
-00215 
-00216         for (pCurr = pAnchor; pCurr != NULL; pCurr = pCurr->pNext) {
-00217                 if (pCurr->usIstd == usIstd) {
-00218                         return &pCurr->tInfo;
-00219                 }
-00220         }
-00221         return NULL;
-00222 } /* end of pGetListInfoByIstd */
-00223 
-00224 /*
-00225  * vRestartListValues - reset the less significant list levels
-00226  */
-00227 static void
-00228 vRestartListValues(USHORT usListIndex, UCHAR ucListLevel)
-00229 {
-00230         list_value_type *pPrev, *pCurr, *pNext;
-00231         int             iCounter;
-00232 
-00233         iCounter = 0;
-00234         pPrev = NULL;
-00235         pCurr = pValues;
-00236 
-00237         while (pCurr != NULL) {
-00238                 if (pCurr->usListIndex != usListIndex ||
-00239                     pCurr->ucListLevel <= ucListLevel) {
-00240                         pPrev = pCurr;
-00241                         pCurr = pCurr->pNext;
-00242                         continue;
-00243                 }
-00244                 /* Reset the level by deleting the record */
-00245                 pNext = pCurr->pNext;
-00246                 if (pPrev == NULL) {
-00247                         pValues = pNext;
-00248                 } else {
-00249                         pPrev->pNext = pNext;
-00250                 }
-00251                 DBG_DEC(pCurr->usListIndex);
-00252                 DBG_DEC(pCurr->ucListLevel);
-00253                 pCurr = xfree(pCurr);
-00254                 pCurr = pNext;
-00255                 iCounter++;
-00256         }
-00257         DBG_DEC_C(iCounter > 0, iCounter);
-00258 } /* end of vRestartListValues */
-00259 
-00260 /*
-00261  * usGetListValue - Get the current value of the given list
-00262  *
-00263  * Returns the value of the given list
-00264  */
-00265 USHORT
-00266 usGetListValue(int iListSeqNumber, int iWordVersion,
-00267         const style_block_type *pStyle)
-00268 {
-00269         list_value_type *pCurr;
-00270         USHORT          usValue;
-00271 
-00272         fail(iListSeqNumber < 0);
-00273         fail(iListSeqNumber < iOldListSeqNumber);
-00274         fail(iWordVersion < 0);
-00275         fail(pStyle == NULL);
-00276 
-00277         if (iListSeqNumber <= 0) {
-00278                 return 0;
-00279         }
-00280 
-00281         if (iWordVersion < 8) {
-00282                 /* Old style list */
-00283                 if (iListSeqNumber == iOldListSeqNumber ||
-00284                     (iListSeqNumber == iOldListSeqNumber + 1 &&
-00285                      eGetNumType(pStyle->ucNumLevel) == level_type_sequence)) {
-00286                         if (!pStyle->bNumPause) {
-00287                                 usOldListValue++;
-00288                         }
-00289                 } else {
-00290                         usOldListValue = pStyle->usStartAt;
-00291                 }
-00292                 iOldListSeqNumber = iListSeqNumber;
-00293                 return usOldListValue;
-00294         }
-00295 
-00296         /* New style list */
-00297         if (pStyle->usListIndex == 0 ||
-00298             pStyle->usListIndex - 1 >= usLfoLen ||
-00299             pStyle->ucListLevel > 8) {
-00300                 /* Out of range; no need to search */
-00301                 return 0;
-00302         }
-00303 
-00304         for (pCurr = pValues; pCurr != NULL; pCurr = pCurr->pNext) {
-00305                 if (pCurr->usListIndex == pStyle->usListIndex &&
-00306                     pCurr->ucListLevel == pStyle->ucListLevel) {
-00307                         /* Record found; increment and return the value */
-00308                         pCurr->usValue++;
-00309                         usValue = pCurr->usValue;
-00310                         if (!pStyle->bNoRestart) {
-00311                                 vRestartListValues(pStyle->usListIndex,
-00312                                                 pStyle->ucListLevel);
-00313                         }
-00314                         return usValue;
-00315                 }
-00316         }
-00317 
-00318         /* Record not found; create it and add it to the front of the list */
-00319         pCurr = xmalloc(sizeof(list_value_type));
-00320         pCurr->usValue = pStyle->usStartAt;
-00321         pCurr->usListIndex = pStyle->usListIndex;
-00322         pCurr->ucListLevel = pStyle->ucListLevel;
-00323         pCurr->pNext = pValues;
-00324         pValues = pCurr;
-00325         usValue = pCurr->usValue;
-00326         if (!pStyle->bNoRestart) {
-00327                 vRestartListValues(pStyle->usListIndex, pStyle->ucListLevel);
-00328         }
-00329         return usValue;
-00330 } /* end of usGetListValue */
-
-
Generated by  - -doxygen 1.6.2
- - diff -r 59758314f811 -r d4524d6a4472 Symbian3/Examples/guid-6013a680-57f9-415b-8851-c4fa63356636/main__ros_8c_source.html --- a/Symbian3/Examples/guid-6013a680-57f9-415b-8851-c4fa63356636/main__ros_8c_source.html Fri Jun 11 15:24:34 2010 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,536 +0,0 @@ - - - - -TB9.2 Example Applications: examples/PIPS/antiword/src/main_ros.c Source File - - - - - -

examples/PIPS/antiword/src/main_ros.c

00001 /*
-00002  * main_ros.c
-00003  *
-00004  * Released under GPL
-00005  *
-00006  * Copyright (C) 1998-2005 A.J. van Os
-00007  *
-00008  * This program is free software; you can redistribute it and/or
-00009  * modify it under the terms of the GNU General Public License
-00010  * as published by the Free Software Foundation; either version 2
-00011  * of the License, or (at your option) any later version.
-00012  *
-00013  * This program is distributed in the hope that it will be useful,
-00014  * but WITHOUT ANY WARRANTY; without even the implied warranty of
-00015  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-00016  * GNU General Public License for more details.
-00017  *
-00018  * You should have received a copy of the GNU General Public License
-00019  * along with this program; if not, write to the Free Software
-00020  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
-00021  *
-00022  * Description:
-00023  * The main program of !Antiword (RISC OS version)
-00024  */
-00025 
-00026 #include <stdio.h>
-00027 #include <stdlib.h>
-00028 #include <string.h>
-00029 #include "DeskLib:Dialog2.h"
-00030 #include "DeskLib:Error.h"
-00031 #include "DeskLib:Event.h"
-00032 #include "DeskLib:EventMsg.h"
-00033 #include "DeskLib:Handler.h"
-00034 #include "DeskLib:Menu.h"
-00035 #include "DeskLib:Resource.h"
-00036 #include "DeskLib:Screen.h"
-00037 #include "DeskLib:Template.h"
-00038 #include "DeskLib:Window.h"
-00039 #if defined(__GNUC__)
-00040 #include "flexlib:flex.h"
-00041 #endif /* __GNUC__ */
-00042 #include "version.h"
-00043 #include "antiword.h"
-00044 
-00045 
-00046 /* The name of this program */
-00047 static char     *szTask = "!Antiword";
-00048 
-00049 /* The window handle of the choices window */
-00050 static window_handle    tChoicesWindow = 0;
-00051 
-00052 /* Dummy diagram with the iconbar menu pointer */
-00053 static diagram_type     tDummyDiagram;
-00054 
-00055 /* Program information Box */
-00056 static dialog2_block    *pInfoBox = NULL;
-00057 
-00058 /* Info box fields */
-00059 #define PURPOSE_INFO_FIELD      2
-00060 #define AUTHOR_INFO_FIELD       3
-00061 #define VERSION_INFO_FIELD      4
-00062 #define STATUS_INFO_FIELD       5
-00063 
-00064 /* Iconbar menu fields */
-00065 #define ICONBAR_INFO_FIELD      0
-00066 #define ICONBAR_CHOICES_FIELD   1
-00067 #define ICONBAR_QUIT_FIELD      2
-00068 
-00069 
-00070 /*
-00071  * bBarInfo - Show iconbar information
-00072  */
-00073 static BOOL
-00074 bBarInfo(event_pollblock *pEvent, void *pvReference)
-00075 {
-00076         diagram_type    *pDiag;
-00077 
-00078         TRACE_MSG("bBarInfo");
-00079 
-00080         fail(pEvent == NULL);
-00081         fail(pEvent->type != event_SEND);
-00082         fail(pEvent->data.message.header.action != message_MENUWARN);
-00083         fail(pvReference == NULL);
-00084 
-00085         pDiag = (diagram_type *)pvReference;
-00086 
-00087         if (menu_currentopen != pDiag->pSaveMenu ||
-00088             pEvent->data.message.data.menuwarn.selection[0] != ICONBAR_INFO_FIELD) {
-00089                 return FALSE;
-00090         }
-00091 
-00092         Dialog2_OpenDialogMenuLeaf(pEvent, pInfoBox);
-00093         return TRUE;
-00094 } /* end of bBarInfo */
-00095 
-00096 /*
-00097  * vBarInfoSetText - Set the iconbar infobox text
-00098  */
-00099 static void
-00100 vBarInfoSetText(dialog2_block *pBox)
-00101 {
-00102         TRACE_MSG("vBarInfoSetText");
-00103 
-00104         fail(pBox == NULL);
-00105         fail(pBox != pInfoBox);
-00106 
-00107         Icon_SetText(pBox->window, PURPOSE_INFO_FIELD, PURPOSESTRING);
-00108         Icon_SetText(pBox->window, AUTHOR_INFO_FIELD, AUTHORSTRING);
-00109         Icon_SetText(pBox->window, VERSION_INFO_FIELD, VERSIONSTRING);
-00110         Icon_SetText(pBox->window, STATUS_INFO_FIELD, STATUSSTRING);
-00111 } /* end of vBarInfoSetText */
-00112 
-00113 /*
-00114  * bMouseButtonClick - respond to mouse button click
-00115  */
-00116 static BOOL
-00117 bMouseButtonClick(event_pollblock *pEvent, void *pvReference)
-00118 {
-00119         diagram_type    *pDiag;
-00120         menu_ptr        pMenu;
-00121         int             iPosY;
-00122 
-00123         TRACE_MSG("bMouseButtonClick");
-00124 
-00125         fail(pEvent == NULL);
-00126         fail(pEvent->type != event_CLICK);
-00127         fail(pvReference == NULL);
-00128 
-00129         pDiag = (diagram_type *)pvReference;
-00130 
-00131         if (pEvent->data.mouse.button.data.menu) {
-00132                 pMenu = pDiag->pSaveMenu;
-00133                 iPosY = (pMenu == tDummyDiagram.pSaveMenu) ?
-00134                                         -1 : pEvent->data.mouse.pos.y;
-00135                 Menu_Show(pMenu, pEvent->data.mouse.pos.x, iPosY);
-00136                 return TRUE;
-00137         }
-00138         if (pEvent->data.mouse.window == pDiag->tMainWindow &&
-00139             pEvent->data.mouse.icon == -1) {
-00140                 vMainButtonClick(&pEvent->data.mouse);
-00141                 return TRUE;
-00142         }
-00143         if (pEvent->data.mouse.window == pDiag->tScaleWindow &&
-00144             pEvent->data.mouse.icon >= 0) {
-00145                 vScaleButtonClick(&pEvent->data.mouse, pDiag);
-00146                 return TRUE;
-00147         }
-00148         return FALSE;
-00149 } /* end of bMouseButtonClick */
-00150 
-00151 /*
-00152  * bAutoRedrawWindow - the redraw is handled by the WIMP
-00153  */
-00154 static BOOL
-00155 bAutoRedrawWindow(event_pollblock *pEvent, void *pvReference)
-00156 {
-00157         return TRUE;
-00158 } /* end of bAutoRedrawWindow */
-00159 
-00160 static BOOL
-00161 bSaveSelect(event_pollblock *pEvent, void *pvReference)
-00162 {
-00163         TRACE_MSG("bSaveSelect");
-00164 
-00165         fail(pEvent == NULL);
-00166         fail(pEvent->type != event_MENU);
-00167         fail(pvReference == NULL);
-00168 
-00169         DBG_DEC(pEvent->data.selection[0]);
-00170 
-00171         switch (pEvent->data.selection[0]) {
-00172         case SAVEMENU_SCALEVIEW:
-00173                 return bScaleOpenAction(pEvent, pvReference);
-00174         case SAVEMENU_SAVEDRAW:
-00175                 return bSaveDrawfile(pEvent, pvReference);
-00176         case SAVEMENU_SAVETEXT:
-00177                 return bSaveTextfile(pEvent, pvReference);
-00178         default:
-00179                 DBG_DEC(pEvent->data.selection[0]);
-00180                 return FALSE;
-00181         }
-00182 } /* end of bSaveSelect */
-00183 
-00184 /*
-00185  * Create the window for the text from the given file
-00186  */
-00187 static diagram_type *
-00188 pCreateTextWindow(const char *szFilename)
-00189 {
-00190         diagram_type    *pDiag;
-00191 
-00192         TRACE_MSG("pCreateTextWindow");
-00193 
-00194         fail(szFilename == NULL || szFilename[0] == '\0');
-00195 
-00196         /* Create the diagram */
-00197         pDiag = pCreateDiagram(szTask+1, szFilename);
-00198         if (pDiag == NULL) {
-00199                 werr(0, "Sorry, no new diagram object");
-00200                 return NULL;
-00201         }
-00202 
-00203         /* Prepare a save menu for this diagram */
-00204         pDiag->pSaveMenu = Menu_New(szTask+1,
-00205                 ">Scale view,"
-00206                 ">Save (Drawfile)   F3,"
-00207                 ">Save (Text only) \213F3");
-00208         if (pDiag->pSaveMenu == NULL) {
-00209                 werr(1, "Sorry, no Savemenu object");
-00210         }
-00211         Menu_Warn(pDiag->pSaveMenu, SAVEMENU_SCALEVIEW,
-00212                                         TRUE, bScaleOpenAction, pDiag);
-00213         Menu_Warn(pDiag->pSaveMenu, SAVEMENU_SAVEDRAW,
-00214                                         TRUE, bSaveDrawfile, pDiag);
-00215         Menu_Warn(pDiag->pSaveMenu, SAVEMENU_SAVETEXT,
-00216                                         TRUE, bSaveTextfile, pDiag);
-00217 
-00218         /* Claim events for the main window */
-00219         Event_Claim(event_REDRAW, pDiag->tMainWindow, icon_ANY,
-00220                                         bRedrawMainWindow, pDiag);
-00221         Event_Claim(event_CLOSE, pDiag->tMainWindow, icon_ANY,
-00222                                         bDestroyDiagram, pDiag);
-00223         Event_Claim(event_CLICK, pDiag->tMainWindow, icon_ANY,
-00224                                         bMouseButtonClick, pDiag);
-00225         Event_Claim(event_KEY, pDiag->tMainWindow, icon_ANY,
-00226                                         bMainKeyPressed, pDiag);
-00227 
-00228         /* Claim events for the scale window */
-00229         Event_Claim(event_REDRAW, pDiag->tScaleWindow, icon_ANY,
-00230                                         bAutoRedrawWindow, NULL);
-00231         Event_Claim(event_CLICK, pDiag->tScaleWindow, icon_ANY,
-00232                                         bMouseButtonClick, pDiag);
-00233         Event_Claim(event_KEY, pDiag->tScaleWindow, icon_ANY,
-00234                                         bScaleKeyPressed, pDiag);
-00235 
-00236         /* Set the window title */
-00237         vSetTitle(pDiag);
-00238         return pDiag;
-00239 } /* end of pCreateTextWindow */
-00240 
-00241 /*
-00242  * vProcessFile - process one file
-00243  */
-00244 static void
-00245 vProcessFile(const char *szFilename, int iFiletype)
-00246 {
-00247         options_type    tOptions;
-00248         FILE            *pFile;
-00249         diagram_type    *pDiag;
-00250         long            lFilesize;
-00251         int             iWordVersion;
-00252 
-00253         TRACE_MSG("vProcessFile");
-00254 
-00255         fail(szFilename == NULL || szFilename[0] == '\0');
-00256 
-00257         DBG_MSG(szFilename);
-00258 
-00259         pFile = fopen(szFilename, "rb");
-00260         if (pFile == NULL) {
-00261                 werr(0, "I can't open '%s' for reading", szFilename);
-00262                 return;
-00263         }
-00264 
-00265         lFilesize = lGetFilesize(szFilename);
-00266         if (lFilesize < 0) {
-00267                 (void)fclose(pFile);
-00268                 werr(0, "I can't get the size of '%s'", szFilename);
-00269                 return;
-00270         }
-00271 
-00272         iWordVersion = iGuessVersionNumber(pFile, lFilesize);
-00273         if (iWordVersion < 0 || iWordVersion == 3) {
-00274                 if (bIsRtfFile(pFile)) {
-00275                         werr(0, "%s is not a Word Document."
-00276                                 " It is probably a Rich Text Format file",
-00277                                 szFilename);
-00278                 } if (bIsWordPerfectFile(pFile)) {
-00279                         werr(0, "%s is not a Word Document."
-00280                                 " It is probably a Word Perfect file",
-00281                                 szFilename);
-00282                 } else {
-00283                         werr(0, "%s is not a Word Document.", szFilename);
-00284                 }
-00285                 (void)fclose(pFile);
-00286                 return;
-00287         }
-00288         /* Reset any reading done during file-testing */
-00289         rewind(pFile);
-00290 
-00291         if (iFiletype != FILETYPE_MSWORD) {
-00292                 vGetOptions(&tOptions);
-00293                 if (tOptions.bAutofiletypeAllowed) {
-00294                         vSetFiletype(szFilename, FILETYPE_MSWORD);
-00295                 }
-00296         }
-00297 
-00298         pDiag = pCreateTextWindow(szFilename);
-00299         if (pDiag == NULL) {
-00300                 (void)fclose(pFile);
-00301                 return;
-00302         }
-00303 
-00304         (void)bWordDecryptor(pFile, lFilesize, pDiag);
-00305         Error_CheckFatal(Drawfile_VerifyDiagram(&pDiag->tInfo));
-00306         vShowDiagram(pDiag);
-00307         TRACE_MSG("After vShowDiagram");
-00308 
-00309         TRACE_MSG("before debug print");
-00310         DBG_HEX(pFile);
-00311         TRACE_MSG("before fclose");
-00312         (void)fclose(pFile);
-00313         TRACE_MSG("after fclose");
-00314 } /* end of vProcessFile */
-00315 
-00316 /*
-00317  * vSendAck - send an acknowledge
-00318  */
-00319 static void
-00320 vSendAck(event_pollblock *pEvent)
-00321 {
-00322         message_block   tMessage;
-00323 
-00324         TRACE_MSG("vSendAck");
-00325 
-00326         fail(pEvent == NULL);
-00327         fail(pEvent->type != event_SEND && pEvent->type != event_SENDWANTACK);
-00328         fail(pEvent->data.message.header.action != message_DATALOAD &&
-00329                 pEvent->data.message.header.action != message_DATAOPEN);
-00330 
-00331         tMessage.header.action = message_DATALOADACK;
-00332         tMessage.header.size = sizeof(tMessage);
-00333         tMessage.header.yourref = pEvent->data.message.header.myref;
-00334         Error_CheckFatal(Wimp_SendMessage(event_SEND, &tMessage,
-00335                                 pEvent->data.message.header.sender, 0));
-00336 } /* end of vSendAck */
-00337 
-00338 static BOOL
-00339 bEventMsgHandler(event_pollblock *pEvent, void *pvReference)
-00340 {
-00341         TRACE_MSG("bEventMsgHandler");
-00342 
-00343         fail(pEvent == NULL);
-00344 
-00345         switch (pEvent->type) {
-00346         case event_SEND:
-00347         case event_SENDWANTACK:
-00348                 switch (pEvent->data.message.header.action) {
-00349                 case message_CLOSEDOWN:
-00350                         exit(EXIT_SUCCESS);
-00351                         break;
-00352                 case message_DATALOAD:
-00353                 case message_DATAOPEN:
-00354                         vProcessFile(
-00355                                 pEvent->data.message.data.dataload.filename,
-00356                                 pEvent->data.message.data.dataload.filetype);
-00357                         vSendAck(pEvent);
-00358                         break;
-00359                 default:
-00360                         DBG_DEC(pEvent->data.message.header.action);
-00361                         break;
-00362                 }
-00363                 return TRUE;
-00364         default:
-00365                 DBG_DEC(pEvent->type);
-00366                 return FALSE;
-00367         }
-00368 } /* end of bEventMsgHandler */
-00369 
-00370 /*
-00371  * bMenuSelect - select from the iconbar menu
-00372  */
-00373 static BOOL
-00374 bMenuSelect(event_pollblock *pEvent, void *pvReference)
-00375 {
-00376         TRACE_MSG("bMenuSelect");
-00377 
-00378         fail(pEvent == NULL);
-00379         fail(pEvent->type != event_MENU);
-00380 
-00381         DBG_DEC(pEvent->data.selection[0]);
-00382 
-00383         switch (pEvent->data.selection[0]) {
-00384         case ICONBAR_INFO_FIELD:
-00385                 return bBarInfo(pEvent, pvReference);
-00386         case ICONBAR_CHOICES_FIELD:
-00387                 vChoicesOpenAction(tChoicesWindow);
-00388                 Window_BringToFront(tChoicesWindow);
-00389                 break;
-00390         case ICONBAR_QUIT_FIELD:
-00391                 TRACE_MSG("before exit");
-00392                 exit(EXIT_SUCCESS);
-00393                 break;
-00394         default:
-00395                 DBG_DEC(pEvent->data.selection[0]);
-00396                 break;
-00397         }
-00398         return TRUE;
-00399 } /* end of bMenuSelect */
-00400 
-00401 /*
-00402  * bMenuClick - respond to an menu click
-00403  */
-00404 static BOOL
-00405 bMenuClick(event_pollblock *pEvent, void *pvReference)
-00406 {
-00407         TRACE_MSG("bMenuClick");
-00408 
-00409         fail(pEvent == NULL);
-00410         fail(pEvent->type != event_MENU);
-00411 
-00412         if (menu_currentopen == tDummyDiagram.pSaveMenu) {
-00413                 return bMenuSelect(pEvent, pvReference);
-00414         } else if (pvReference == NULL) {
-00415                 return FALSE;
-00416         }
-00417         return bSaveSelect(pEvent, pvReference);
-00418 } /* end of bMenuClick */
-00419 
-00420 static void
-00421 vTemplates(void)
-00422 {
-00423         TRACE_MSG("vTemplates");
-00424 
-00425         Template_Initialise();
-00426         Template_LoadFile("Templates");
-00427 
-00428         tChoicesWindow = Window_Create("Choices", template_TITLEMIN);
-00429         if (tChoicesWindow == 0) {
-00430                 werr(1, "I can't find the 'Choices' template");
-00431         }
-00432 
-00433         /* Claim events for the choices window */
-00434         Event_Claim(event_REDRAW, tChoicesWindow, icon_ANY,
-00435                                         bAutoRedrawWindow, NULL);
-00436         Event_Claim(event_CLICK, tChoicesWindow, icon_ANY,
-00437                                         bChoicesMouseClick, NULL);
-00438         Event_Claim(event_KEY, tChoicesWindow, icon_ANY,
-00439                                         bChoicesKeyPressed, NULL);
-00440 } /* end of vTemplates */
-00441 
-00442 static void
-00443 vInitialise(void)
-00444 {
-00445         int     aiMessages[] = {0};
-00446         icon_handle     tBarIcon;
-00447 
-00448 
-00449         TRACE_MSG("vInitialise");
-00450 
-00451         Resource_Initialise(szTask+1);
-00452         Event_Initialise3(szTask+1, 310, aiMessages);
-00453         EventMsg_Initialise();
-00454         Screen_CacheModeInfo();
-00455 #if defined(__GNUC__)
-00456         flex_init(szTask+1, 0, 0);
-00457         flex_set_budge(1);
-00458 #endif /* __GNUC__ */
-00459         vTemplates();
-00460 
-00461         /* Prepare iconbar menu */
-00462         tDummyDiagram.tInfo.data = NULL;
-00463         tDummyDiagram.tInfo.length = 0;
-00464         tDummyDiagram.pSaveMenu = Menu_New(szTask+1, ">Info,Choices...,Quit");
-00465         if (tDummyDiagram.pSaveMenu == NULL) {
-00466                 werr(1, "Sorry, no Barmenu object");
-00467         }
-00468         pInfoBox = Dialog2_CreateDialogBlock("ProgInfo", -1, -1,
-00469                                         vBarInfoSetText, NULL, NULL);
-00470 
-00471         if (pInfoBox == NULL) {
-00472                 werr(1, "Sorry, no Infobox object");
-00473         }
-00474         Menu_Warn(tDummyDiagram.pSaveMenu, ICONBAR_INFO_FIELD,
-00475                                         TRUE, bBarInfo, &tDummyDiagram);
-00476 
-00477         /* Create an icon on the icon bar */
-00478         tBarIcon = Icon_BarIcon(szTask, iconbar_RIGHT);
-00479         Event_Claim(event_CLICK, window_ICONBAR, tBarIcon,
-00480                                         bMouseButtonClick, &tDummyDiagram);
-00481 
-00482         /* Generic claims */
-00483         Event_Claim(event_OPEN, window_ANY, icon_ANY,
-00484                                         Handler_OpenWindow, NULL);
-00485         Event_Claim(event_CLOSE, window_ANY, icon_ANY,
-00486                                         Handler_CloseWindow, NULL);
-00487         Event_Claim(event_MENU, window_ANY, icon_ANY,
-00488                                         bMenuClick, NULL);
-00489         EventMsg_Claim(message_DATALOAD, window_ICONBAR,
-00490                                         bEventMsgHandler, NULL);
-00491         EventMsg_Claim(message_MODECHANGE, window_ANY,
-00492                                         Handler_ModeChange, NULL);
-00493 } /* end of vInitialise */
-00494 
-00495 int
-00496 main(int argc, char **argv)
-00497 {
-00498         int     iFirst, iFiletype;
-00499 
-00500         TRACE_MSG("main");
-00501 
-00502         vInitialise();
-00503         iFirst = iReadOptions(argc, argv);
-00504         if (iFirst != 1) {
-00505                 return EXIT_FAILURE;
-00506         }
-00507 
-00508         if (argc > 1) {
-00509                 iFiletype = iGetFiletype(argv[1]);
-00510                 if (iFiletype < 0) {
-00511                         return EXIT_FAILURE;
-00512                 }
-00513                 vProcessFile(argv[1], iFiletype);
-00514                 TRACE_MSG("main after vProcessFile");
-00515         }
-00516 
-00517         for (;;) {
-00518                 Event_Poll();
-00519         }
-00520 } /* end of main */
-
-
Generated by  - -doxygen 1.6.2
- - diff -r 59758314f811 -r d4524d6a4472 Symbian3/Examples/guid-6013a680-57f9-415b-8851-c4fa63356636/main__u_8c_source.html --- a/Symbian3/Examples/guid-6013a680-57f9-415b-8851-c4fa63356636/main__u_8c_source.html Fri Jun 11 15:24:34 2010 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,441 +0,0 @@ - - - - -TB9.2 Example Applications: examples/PIPS/antiword/src/main_u.c Source File - - - - - -

examples/PIPS/antiword/src/main_u.c

00001 /*
-00002  * main_u.c
-00003  *
-00004  * Released under GPL
-00005  *
-00006  * Copyright (C) 1998-2004 A.J. van Os
-00007  *
-00008  * This program is free software; you can redistribute it and/or
-00009  * modify it under the terms of the GNU General Public License
-00010  * as published by the Free Software Foundation; either version 2
-00011  * of the License, or (at your option) any later version.
-00012  *
-00013  * This program is distributed in the hope that it will be useful,
-00014  * but WITHOUT ANY WARRANTY; without even the implied warranty of
-00015  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-00016  * GNU General Public License for more details.
-00017  *
-00018  * You should have received a copy of the GNU General Public License
-00019  * along with this program; if not, write to the Free Software
-00020  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
-00021  *
-00022  * Description:
-00023  * The main program of 'antiword' (Unix version)
-00024  */
-00025 #ifdef SYMBIAN
-00026 //GCCE header
-00027 //#include <staticlibinit_gcce.h>
-00028 #include <string.h>
-00029 #endif /*SYMBIAN*/
-00030 
-00031 #include <stdio.h>
-00032 #include <stdlib.h>
-00033 #if defined(__dos)
-00034 #include <fcntl.h>
-00035 #include <io.h>
-00036 #endif /* __dos */
-00037 #if defined(__CYGWIN__) || defined(__CYGMING__)
-00038 #  ifdef X_LOCALE
-00039 #    include <X11/Xlocale.h>
-00040 #  else
-00041 #    include <locale.h>
-00042 #  endif
-00043 #else
-00044 #include <locale.h>
-00045 #endif /* __CYGWIN__ || __CYGMING__ */
-00046 #if defined(N_PLAT_NLM)
-00047 #if !defined(_VA_LIST)
-00048 #include "NW-only/nw_os.h"
-00049 #endif /* !_VA_LIST */
-00050 #include "getopt.h"
-00051 #endif /* N_PLAT_NLM */
-00052 #include "version.h"
-00053 #include "antiword.h"
-00054 #include <unistd.h> 
-00055 
-00056 /* The name of this program */
-00057 static const char       *szTask = NULL;
-00058 
-00059 
-00060 static void
-00061 vUsage(void)
-00062 {
-00063         fprintf(stderr, "\tName: %s\n", szTask);
-00064         fprintf(stderr, "\tPurpose: "PURPOSESTRING"\n");
-00065         fprintf(stderr, "\tAuthor: "AUTHORSTRING"\n");
-00066         fprintf(stderr, "\tVersion: "VERSIONSTRING);
-00067 #if defined(__dos)
-00068         fprintf(stderr, VERSIONSTRING2);
-00069 #endif /* __dos */
-00070         fprintf(stderr, "\n");
-00071         fprintf(stderr, "\tStatus: "STATUSSTRING"\n");
-00072         fprintf(stderr,
-00073                 "\tUsage: %s [switches] wordfile1 [wordfile2 ...]\n", szTask);
-00074         fprintf(stderr,
-00075                 "\tSwitches: [-f|-t|-a papersize|-p papersize|-x dtd]"
-00076                 "[-m mapping][-w #][-i #][-Ls]\n");
-00077         fprintf(stderr, "\t-f formatted text output\n");
-00078         fprintf(stderr, "\t-t text output (default)\n");
-00079         fprintf(stderr, "\t-a <paper size name> Adobe PDF output\n");
-00080         fprintf(stderr, "\t-p <paper size name> PostScript output\n");
-00081         fprintf(stderr, "\t   paper size like: a4, letter or legal\n");
-00082         fprintf(stderr, "\t-x <dtd> XML output\n");
-00083         fprintf(stderr, "\t   like: db (DocBook)\n");
-00084         fprintf(stderr, "\t-m <mapping> character mapping file\n");
-00085         fprintf(stderr, "\t-w <width> in characters of text output\n");
-00086         fprintf(stderr, "\t-i <level> image level (PostScript only)\n");
-00087         fprintf(stderr, "\t-L use landscape mode (PostScript only)\n");
-00088         fprintf(stderr, "\t-r Show removed text\n");
-00089         fprintf(stderr, "\t-s Show hidden (by Word) text\n");
-00090 } /* end of vUsage */
-00091 
-00092 /*
-00093  * pStdin2TmpFile - save stdin in a temporary file
-00094  *
-00095  * returns: the pointer to the temporary file or NULL
-00096  */
-00097 static FILE *
-00098 pStdin2TmpFile(long *lFilesize)
-00099 {
-00100         FILE    *pTmpFile;
-00101         size_t  tSize;
-00102         BOOL    bFailure;
-00103         UCHAR   aucBytes[BUFSIZ];
-00104 
-00105         DBG_MSG("pStdin2TmpFile");
-00106 
-00107         fail(lFilesize == NULL);
-00108 
-00109         /* Open the temporary file */
-00110         pTmpFile = tmpfile();
-00111         if (pTmpFile == NULL) {
-00112                 return NULL;
-00113         }
-00114 
-00115 #if defined(__dos)
-00116         /* Stdin must be read as a binary stream */
-00117         setmode(fileno(stdin), O_BINARY);
-00118 #endif /* __dos */
-00119 
-00120         /* Copy stdin to the temporary file */
-00121         *lFilesize = 0;
-00122         bFailure = TRUE;
-00123         for (;;) {
-00124                 tSize = fread(aucBytes, 1, sizeof(aucBytes), stdin);
-00125                 if (tSize == 0) {
-00126                         bFailure = feof(stdin) == 0;
-00127                         break;
-00128                 }
-00129                 if (fwrite(aucBytes, 1, tSize, pTmpFile) != tSize) {
-00130                         bFailure = TRUE;
-00131                         break;
-00132                 }
-00133                 *lFilesize += (long)tSize;
-00134         }
-00135 
-00136 #if defined(__dos)
-00137         /* Switch stdin back to a text stream */
-00138         setmode(fileno(stdin), O_TEXT);
-00139 #endif /* __dos */
-00140 
-00141         /* Deal with the result of the copy action */
-00142         if (bFailure) {
-00143                 *lFilesize = 0;
-00144                 (void)fclose(pTmpFile);
-00145                 return NULL;
-00146         }
-00147         rewind(pTmpFile);
-00148         return pTmpFile;
-00149 } /* end of pStdin2TmpFile */
-00150 
-00151 /*
-00152  * bProcessFile - process a single file
-00153  *
-00154  * returns: TRUE when the given file is a supported Word file, otherwise FALSE
-00155  */
-00156 #ifndef SYMBIAN 
-00157 static BOOL
-00158 bProcessFile(const char *szFilename )
-00159 #else
-00160 static BOOL
-00161 bProcessFile(const char *szFilename, FILE *ofp)
-00162 #endif /*SYMBIAN*/
-00163 {
-00164         FILE            *pFile;
-00165         diagram_type    *pDiag;
-00166         long            lFilesize;
-00167         int             iWordVersion;
-00168         BOOL            bResult;
-00169 
-00170         fail(szFilename == NULL || szFilename[0] == '\0');
-00171 
-00172         DBG_MSG(szFilename);
-00173 
-00174         if (szFilename[0] == '-' && szFilename[1] == '\0') {
-00175                 pFile = pStdin2TmpFile(&lFilesize);
-00176                 if (pFile == NULL) {
-00177                         werr(0, "I can't save the standard input to a file");
-00178                         return FALSE;
-00179                 }
-00180         } else {
-00181                 pFile = fopen(szFilename, "rb");
-00182                 if (pFile == NULL) {
-00183                         werr(0, "I can't open '%s' for reading", szFilename);
-00184                         return FALSE;
-00185                 }
-00186 
-00187                 lFilesize = lGetFilesize(szFilename);
-00188                 if (lFilesize < 0) {
-00189                         (void)fclose(pFile);
-00190                         werr(0, "I can't get the size of '%s'", szFilename);
-00191                         return FALSE;
-00192                 }
-00193         }
-00194 
-00195         iWordVersion = iGuessVersionNumber(pFile, lFilesize);
-00196         if (iWordVersion < 0 || iWordVersion == 3) {
-00197                 if (bIsRtfFile(pFile)) {
-00198                         werr(0, "%s is not a Word Document."
-00199                                 " It is probably a Rich Text Format file",
-00200                                 szFilename);
-00201                 } if (bIsWordPerfectFile(pFile)) {
-00202                         werr(0, "%s is not a Word Document."
-00203                                 " It is probably a Word Perfect file",
-00204                                 szFilename);
-00205                 } else {
-00206 #if defined(__dos)
-00207                         werr(0, "%s is not a Word Document or the filename"
-00208                                 " is not in the 8+3 format.", szFilename);
-00209 #else
-00210                         werr(0, "%s is not a Word Document.", szFilename);
-00211 #endif /* __dos */
-00212                 }
-00213                 (void)fclose(pFile);
-00214                 return FALSE;
-00215         }
-00216         /* Reset any reading done during file testing */
-00217         rewind(pFile);
-00218         
-00219         #ifndef SYMBIAN
-00220         pDiag = pCreateDiagram(szTask, szFilename);
-00221         #else
-00222         pDiag = pCreateDiagram(szTask, szFilename, ofp );
-00223         #endif /*SYMBIAN*/
-00224         if (pDiag == NULL) {
-00225                 (void)fclose(pFile);
-00226                 return FALSE;
-00227         }
-00228 
-00229         bResult = bWordDecryptor(pFile, lFilesize, pDiag);
-00230         vDestroyDiagram(pDiag);
-00231 
-00232         (void)fclose(pFile);
-00233         return bResult;
-00234 } /* end of bProcessFile */
-00235 
-00236 
-00237 #ifdef SYMBIAN
-00238 int fillArg( char **argv, char *inpStr)
-00239 {
-00240         int count =0;
-00241         const char *search = " ";
-00242         
-00243         char *token = strtok( inpStr, search);
-00244         argv[0] = token;
-00245         count = 1;
-00246         while( token != NULL )
-00247         {
-00248                 token = strtok( NULL, search);
-00249                 argv[count++] = token;
-00250         }
-00251         return count-1;
-00252 }
-00253 #endif /*SYMBIAN*/
-00254 int
-00255 main(int argc, char **argv)
-00256 {
-00257         #ifdef SYMBIAN
-00258         FILE *ofp = NULL;
-00259         char *buf;
-00260         #endif /*SYMBIAN*/
-00261         
-00262         options_type    tOptions;
-00263         const char      *szWordfile;
-00264         int     iFirst, iIndex, iGoodCount;
-00265         BOOL    bUsage, bMultiple, bUseTXT, bUseXML;
-00266 
-00267         if (argc <= 0) {
-00268                 return EXIT_FAILURE;
-00269         }
-00270 
-00271         #ifdef SYMBIAN
-00272         //Adding HOME environment Variable explicitly
-00273         
-00274     buf = (char *)malloc(FILENAME_MAX);
-00275     // get path to the private folder
-00276     getcwd(buf, FILENAME_MAX);
-00277         #ifndef __WINS__
-00278         // acquire installation location and get the drive letter 
-00279         buf[0] = argv[0][0]; // argv[0] contains full path to exe including drive
-00280         #endif
-00281 
-00282     strcat(buf, "\\Resources\\");
-00283         if (setenv("HOME", buf, 1) != 0) {
-00284                 return EXIT_FAILURE;
-00285         }
-00286     free(buf);
-00287         #endif /*SYMBIAN*/
-00288 
-00289         szTask = szBasename(argv[0]);
-00290 
-00291         if (argc <= 1) {
-00292 #ifdef SYMBIAN
-00293                 char* inpStr = (char*) malloc(_POSIX_ARG_MAX);
-00294                 /*If there is no command-line input, Prompt for it!*/
-00295                 vUsage();
-00296                 
-00297                 fprintf(stdout, "\n\nEnter the input Command String:");
-00298                 fgets( inpStr, _POSIX_ARG_MAX, stdin );
-00299                 
-00300                 argc = fillArg( argv, inpStr);
-00301                 /* Check whether the first argument is valid or not */
-00302                 if ( strcasecmp ( "antiword", argv[0]))
-00303                 {
-00304                         fprintf(stdout, "\nInvalid command syntax, Please read the syntax properly\n\n\n");
-00305                         bUsage = TRUE;
-00306                         getchar();
-00307                 }
-00308                 else
-00309                 {
-00310                         iFirst = iReadOptions(argc, argv);
-00311                         bUsage = iFirst <= 0;
-00312                 }
-00313                 #else 
-00314                 bUsage = TRUE;
-00315                 iFirst = 1;
-00316                 free(inputStr);
-00317 #endif /*SYMBIAN*/
-00318         } else {
-00319                 iFirst = iReadOptions(argc, argv);
-00320                 bUsage = iFirst <= 0;
-00321         }
-00322         if (bUsage) {
-00323                 vUsage();
-00324                 #ifdef SYMBIAN
-00325                 getchar();
-00326                 #endif /*SYMBIAN*/
-00327                 return iFirst < 0 ? EXIT_FAILURE : EXIT_SUCCESS;
-00328         }
-00329 
-00330 #if defined(N_PLAT_NLM) && !defined(_VA_LIST)
-00331         nwinit();
-00332 #endif /* N_PLAT_NLM && !_VA_LIST */
-00333 
-00334         vGetOptions(&tOptions);
-00335 
-00336 #if !defined(__dos)
-00337         if (is_locale_utf8()) {
-00338 #if defined(__STDC_ISO_10646__)
-00339                 /*
-00340                  * If the user wants UTF-8 and the envirionment variables
-00341                  * support UTF-8, than set the locale accordingly
-00342                  */
-00343                 if (tOptions.eEncoding == encoding_utf_8) {
-00344                         if (setlocale(LC_CTYPE, "") == NULL) {
-00345                                 werr(1, "Can't set the UTF-8 locale! "
-00346                                         "Check LANG, LC_CTYPE, LC_ALL.");
-00347                         }
-00348                         DBG_MSG("The UTF-8 locale has been set");
-00349                 } else {
-00350                         (void)setlocale(LC_CTYPE, "C");
-00351                 }
-00352 #endif /* __STDC_ISO_10646__ */
-00353         } else {
-00354                 if (setlocale(LC_CTYPE, "") == NULL) {
-00355                         werr(0, "Can't set the locale! Will use defaults");
-00356                         (void)setlocale(LC_CTYPE, "C");
-00357                 }
-00358                 DBG_MSG("The locale has been set");
-00359         }
-00360 #endif /* !__dos */
-00361 
-00362         bMultiple = argc - iFirst > 1;
-00363         bUseTXT = tOptions.eConversionType == conversion_text ||
-00364                 tOptions.eConversionType == conversion_fmt_text;
-00365         bUseXML = tOptions.eConversionType == conversion_xml;
-00366         iGoodCount = 0;
-00367 
-00368 #if defined(__dos)
-00369         if (tOptions.eConversionType == conversion_pdf) {
-00370                 /* PDF must be written as a binary stream */
-00371                 setmode(fileno(stdout), O_BINARY);
-00372         }
-00373 #endif /* __dos */
-00374 
-00375         if (bUseXML) {
-00376                 fprintf(stdout,
-00377         "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"
-00378         "<!DOCTYPE %s PUBLIC \"-//OASIS//DTD DocBook XML V4.1.2//EN\"\n"
-00379         "\t\"http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd\">\n",
-00380                 bMultiple ? "set" : "book");
-00381                 if (bMultiple) {
-00382                         fprintf(stdout, "<set>\n");
-00383                 }
-00384         }
-00385 
-00386         //Output file
-00387         #ifdef SYMBIAN
-00388         ofp = fopen( argv[argc-1], "w");
-00389         if ( ofp == NULL)
-00390                 {
-00391                         printf("Unable to open the output file: %s\n",argv[argc-1]);
-00392                         exit(0);
-00393                 }
-00394         #endif /*SYMBIAN*/
-00395 
-00396         for (iIndex = iFirst; iIndex < argc-1; iIndex++) {
-00397                 if (bMultiple && bUseTXT) {
-00398                         szWordfile = szBasename(argv[iIndex]);
-00399                         fprintf(stdout, "::::::::::::::\n");
-00400                         fprintf(stdout, "%s\n", szWordfile);
-00401                         fprintf(stdout, "::::::::::::::\n");
-00402                 }
-00403                 #ifndef SYMBIAN
-00404                 if (bProcessFile(argv[iIndex])) {
-00405                 #else
-00406                 if (bProcessFile(argv[iIndex],ofp )) {
-00407                 #endif  /*SYMBIAN*/
-00408                 
-00409                         iGoodCount++;
-00410                 }
-00411         }
-00412 
-00413         if (bMultiple && bUseXML) {
-00414                 fprintf(stdout, "</set>\n");
-00415         }
-00416 
-00417         DBG_DEC(iGoodCount);
-00418         #ifdef SYMBIAN
-00419         fclose(ofp);
-00420         fprintf(stdout, "\n\nConversion is successful!!, check out this file : %s\n", argv[argc-1]);
-00421         getchar();
-00422         #endif /*SYMBIAN*/
-00423         
-00424         return iGoodCount <= 0 ? EXIT_FAILURE : EXIT_SUCCESS;
-00425 } /* end of main */
-
-
Generated by  - -doxygen 1.6.2
- - diff -r 59758314f811 -r d4524d6a4472 Symbian3/Examples/guid-6013a680-57f9-415b-8851-c4fa63356636/misc_8c_source.html --- a/Symbian3/Examples/guid-6013a680-57f9-415b-8851-c4fa63356636/misc_8c_source.html Fri Jun 11 15:24:34 2010 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,910 +0,0 @@ - - - - -TB9.2 Example Applications: examples/PIPS/antiword/src/misc.c Source File - - - - - -

examples/PIPS/antiword/src/misc.c

00001 /*
-00002  * misc.c
-00003  * Copyright (C) 1998-2005 A.J. van Os; Released under GNU GPL
-00004  *
-00005  * Description:
-00006  * Miscellaneous functions
-00007  */
-00008 
-00009 #include <stdio.h>
-00010 #include <stdlib.h>
-00011 #include <string.h>
-00012 #include <ctype.h>
-00013 #include <time.h>
-00014 #if defined(__riscos)
-00015 #include "DeskLib:SWI.h"
-00016 #else
-00017 #include <errno.h>
-00018 #include <sys/types.h>
-00019 #include <sys/stat.h>
-00020 #endif /* __riscos */
-00021 #if !defined(S_ISREG)
-00022 #define S_ISREG(x)      (((x) & S_IFMT) == S_IFREG)
-00023 #endif /* !S_ISREG */
-00024 #include "antiword.h"
-00025 #if defined(__vms)
-00026 #include <unixlib.h>
-00027 #endif
-00028 
-00029 #if !defined(__riscos)
-00030 /*
-00031  * szGetHomeDirectory - get the name of the home directory
-00032  */
-00033 const char *
-00034 szGetHomeDirectory(void)
-00035 {
-00036         const char      *szHome;
-00037 
-00038 #if defined(__vms)
-00039         szHome = decc$translate_vms(getenv("HOME"));
-00040 #elif defined(__Plan9__)
-00041         szHome = getenv("home");
-00042 #else
-00043         szHome = getenv("HOME");
-00044 #endif /* __vms */
-00045 
-00046         if (szHome == NULL || szHome[0] == '\0') {
-00047 #if defined(N_PLAT_NLM)
-00048                 szHome = "SYS:";
-00049 #elif defined(__dos)
-00050                 szHome = "C:";
-00051 #else
-00052                 werr(0, "I can't find the name of your HOME directory");
-00053                 szHome = "";
-00054 #endif /* __dos */
-00055         }
-00056         return szHome;
-00057 } /* end of szGetHomeDirectory */
-00058 
-00059 /*
-00060  * szGetAntiwordDirectory - get the name of the Antiword directory
-00061  */
-00062 const char *
-00063 szGetAntiwordDirectory(void)
-00064 {
-00065 #if defined(__vms)
-00066         return decc$translate_vms(getenv("ANTIWORDHOME"));
-00067 #else
-00068         return getenv("ANTIWORDHOME");
-00069 #endif /* __vms */
-00070 } /* end of szGetAntiwordDirectory */
-00071 #endif /* !__riscos */
-00072 
-00073 /*
-00074  * Get the size of the specified file.
-00075  * Returns -1 if the file does not exist or is not a proper file.
-00076  */
-00077 long
-00078 lGetFilesize(const char *szFilename)
-00079 {
-00080 #if defined(__riscos)
-00081         os_error        *e;
-00082         int     iType, iSize;
-00083 
-00084         e = SWI(2, 5, SWI_OS_File | XOS_Bit,
-00085                 17, szFilename,
-00086                 &iType, NULL, NULL, NULL, &iSize);
-00087         if (e != NULL) {
-00088                 werr(0, "Get Filesize error %d: %s",
-00089                         e->errnum, e->errmess);
-00090                 return -1;
-00091         }
-00092         if (iType != 1) {
-00093                 /* It's not a proper file or the file does not exist */
-00094                 return -1;
-00095         }
-00096         return (long)iSize;
-00097 #else
-00098         struct stat     tBuffer;
-00099 
-00100         errno = 0;
-00101         if (stat(szFilename, &tBuffer) != 0) {
-00102                 werr(0, "Get Filesize error %d", errno);
-00103                 return -1;
-00104         }
-00105         if (!S_ISREG(tBuffer.st_mode)) {
-00106                 /* It's not a regular file */
-00107                 return -1;
-00108         }
-00109         return (long)tBuffer.st_size;
-00110 #endif /* __riscos */
-00111 } /* end of lGetFilesize */
-00112 
-00113 #if defined(DEBUG)
-00114 void
-00115 vPrintBlock(const char  *szFile, int iLine,
-00116                 const UCHAR *aucBlock, size_t tLength)
-00117 {
-00118         int i, j;
-00119 
-00120         fail(szFile == NULL || iLine < 0 || aucBlock == NULL);
-00121 
-00122         fprintf(stderr, "%s[%3d]:\n", szFile, iLine);
-00123         for (i = 0; i < 32; i++) {
-00124                 if (16 * i >= (int)tLength) {
-00125                         return;
-00126                 }
-00127                 fprintf(stderr, "%03x: ", (unsigned int)(16 * i));
-00128                 for (j = 0; j < 16; j++) {
-00129                         if (16 * i + j < (int)tLength) {
-00130                                 fprintf(stderr, "%02x ",
-00131                                         (unsigned int)aucBlock[16 * i + j]);
-00132                         }
-00133                 }
-00134                 fprintf(stderr, "\n");
-00135         }
-00136 } /* end of vPrintBlock */
-00137 
-00138 void
-00139 vPrintUnicode(const char *szFile, int iLine, const UCHAR *aucUni, size_t tLen)
-00140 {
-00141         char    *szASCII;
-00142 
-00143         fail(tLen % 2 != 0);
-00144 
-00145         tLen /= 2;      /* Length in bytes to length in characters */
-00146         szASCII = xmalloc(tLen + 1);
-00147         (void)unincpy(szASCII, aucUni, tLen);
-00148         szASCII[tLen] = '\0';
-00149         (void)fprintf(stderr, "%s[%3d]: %.*s\n",
-00150                                 szFile, iLine, (int)tLen, szASCII);
-00151         szASCII = xfree(szASCII);
-00152 } /* end of vPrintUnicode */
-00153 
-00154 BOOL
-00155 bCheckDoubleLinkedList(output_type *pAnchor)
-00156 {
-00157         output_type     *pCurr, *pLast;
-00158         int             iInList;
-00159 
-00160         pLast = pAnchor;
-00161         iInList = 0;
-00162         for (pCurr = pAnchor; pCurr != NULL; pCurr = pCurr->pNext) {
-00163                 pLast = pCurr;
-00164                 iInList++;
-00165         }
-00166         NO_DBG_DEC(iInList);
-00167         for (pCurr = pLast; pCurr != NULL; pCurr = pCurr->pPrev) {
-00168                 pLast = pCurr;
-00169                 iInList--;
-00170         }
-00171         DBG_DEC_C(iInList != 0, iInList);
-00172         return pAnchor == pLast && iInList == 0;
-00173 } /* end of bCheckDoubleLinkedList */
-00174 #endif /* DEBUG */
-00175 
-00176 /*
-00177  * bReadBytes
-00178  * This function reads the specified number of bytes from the specified file,
-00179  * starting from the specified offset.
-00180  * Returns TRUE when successfull, otherwise FALSE
-00181  */
-00182 BOOL
-00183 bReadBytes(UCHAR *aucBytes, size_t tMemb, ULONG ulOffset, FILE *pFile)
-00184 {
-00185         fail(aucBytes == NULL || pFile == NULL || ulOffset > (ULONG)LONG_MAX);
-00186 
-00187         if (ulOffset > (ULONG)LONG_MAX) {
-00188                 return FALSE;
-00189         }
-00190         if (fseek(pFile, (long)ulOffset, SEEK_SET) != 0) {
-00191                 return FALSE;
-00192         }
-00193         if (fread(aucBytes, sizeof(UCHAR), tMemb, pFile) != tMemb) {
-00194                 return FALSE;
-00195         }
-00196         return TRUE;
-00197 } /* end of bReadBytes */
-00198 
-00199 /*
-00200  * bReadBuffer
-00201  * This function fills the specified buffer with the specified number of bytes,
-00202  * starting at the specified offset within the Big/Small Block Depot.
-00203  *
-00204  * Returns TRUE when successful, otherwise FALSE
-00205  */
-00206 BOOL
-00207 bReadBuffer(FILE *pFile, ULONG ulStartBlock,
-00208         const ULONG *aulBlockDepot, size_t tBlockDepotLen, size_t tBlockSize,
-00209         UCHAR *aucBuffer, ULONG ulOffset, size_t tToRead)
-00210 {
-00211         ULONG   ulBegin, ulIndex;
-00212         size_t  tLen;
-00213 
-00214         fail(pFile == NULL);
-00215         fail(ulStartBlock > MAX_BLOCKNUMBER && ulStartBlock != END_OF_CHAIN);
-00216         fail(aulBlockDepot == NULL);
-00217         fail(tBlockSize != BIG_BLOCK_SIZE && tBlockSize != SMALL_BLOCK_SIZE);
-00218         fail(aucBuffer == NULL);
-00219         fail(tToRead == 0);
-00220 
-00221         for (ulIndex = ulStartBlock;
-00222              ulIndex != END_OF_CHAIN && tToRead != 0;
-00223              ulIndex = aulBlockDepot[ulIndex]) {
-00224                 if (ulIndex >= (ULONG)tBlockDepotLen) {
-00225                         DBG_DEC(ulIndex);
-00226                         DBG_DEC(tBlockDepotLen);
-00227                         if (tBlockSize >= BIG_BLOCK_SIZE) {
-00228                                 werr(1, "The Big Block Depot is damaged");
-00229                         } else {
-00230                                 werr(1, "The Small Block Depot is damaged");
-00231                         }
-00232                 }
-00233                 if (ulOffset >= (ULONG)tBlockSize) {
-00234                         ulOffset -= tBlockSize;
-00235                         continue;
-00236                 }
-00237                 ulBegin = ulDepotOffset(ulIndex, tBlockSize) + ulOffset;
-00238                 tLen = min(tBlockSize - (size_t)ulOffset, tToRead);
-00239                 ulOffset = 0;
-00240                 if (!bReadBytes(aucBuffer, tLen, ulBegin, pFile)) {
-00241                         werr(0, "Read big block 0x%lx not possible", ulBegin);
-00242                         return FALSE;
-00243                 }
-00244                 aucBuffer += tLen;
-00245                 tToRead -= tLen;
-00246         }
-00247         DBG_DEC_C(tToRead != 0, tToRead);
-00248         return tToRead == 0;
-00249 } /* end of bReadBuffer */
-00250 
-00251 /*
-00252  * Convert a Word colornumber into a true color for use in a drawfile
-00253  *
-00254  * Returns the true color
-00255  */
-00256 ULONG
-00257 ulColor2Color(UCHAR ucFontColor)
-00258 {
-00259         static const ULONG      aulColorTable[] = {
-00260                 /*  0 */        0x00000000UL,   /* Automatic */
-00261                 /*  1 */        0x00000000UL,   /* Black */
-00262                 /*  2 */        0xff000000UL,   /* Blue */
-00263                 /*  3 */        0xffff0000UL,   /* Turquoise */
-00264                 /*  4 */        0x00ff0000UL,   /* Bright Green */
-00265                 /*  5 */        0xff00ff00UL,   /* Pink */
-00266                 /*  6 */        0x0000ff00UL,   /* Red */
-00267                 /*  7 */        0x00ffff00UL,   /* Yellow */
-00268                 /*  8 */        0xffffff00UL,   /* White */
-00269                 /*  9 */        0x80000000UL,   /* Dark Blue */
-00270                 /* 10 */        0x80800000UL,   /* Teal */
-00271                 /* 11 */        0x00800000UL,   /* Green */
-00272                 /* 12 */        0x80008000UL,   /* Violet */
-00273                 /* 13 */        0x00008000UL,   /* Dark Red */
-00274                 /* 14 */        0x00808000UL,   /* Dark Yellow */
-00275                 /* 15 */        0x80808000UL,   /* Gray 50% */
-00276                 /* 16 */        0xc0c0c000UL,   /* Gray 25% */
-00277         };
-00278         if ((size_t)ucFontColor >= elementsof(aulColorTable)) {
-00279                 return aulColorTable[0];
-00280         }
-00281         return aulColorTable[(int)ucFontColor];
-00282 } /* end of ulColor2Color */
-00283 
-00284 /*
-00285  * iFindSplit - find a place to split the string
-00286  *
-00287  * returns the index of the split character or -1 if no split found.
-00288  */
-00289 static int
-00290 iFindSplit(const char *szString, size_t tStringLen)
-00291 {
-00292         size_t  tSplit;
-00293 
-00294         if (tStringLen == 0) {
-00295                 return -1;
-00296         }
-00297         tSplit = tStringLen - 1;
-00298         while (tSplit >= 1) {
-00299                 if (szString[tSplit] == ' ' ||
-00300                     (szString[tSplit] == '-' && szString[tSplit - 1] != ' ')) {
-00301                         return (int)tSplit;
-00302                 }
-00303                 tSplit--;
-00304         }
-00305         return -1;
-00306 } /* end of iFindSplit */
-00307 
-00308 /*
-00309  * pSplitList - split the specified list in a printable part and a leftover part
-00310  *
-00311  * returns the pointer to the leftover part
-00312  */
-00313 output_type *
-00314 pSplitList(output_type *pAnchor)
-00315 {
-00316         output_type     *pCurr, *pLeftOver;
-00317         int             iIndex;
-00318 
-00319         fail(pAnchor == NULL);
-00320 
-00321         for (pCurr = pAnchor; pCurr->pNext != NULL; pCurr = pCurr->pNext)
-00322                 ;       /* EMPTY */
-00323         iIndex = -1;
-00324         for (; pCurr != NULL; pCurr = pCurr->pPrev) {
-00325                 iIndex = iFindSplit(pCurr->szStorage, pCurr->tNextFree);
-00326                 if (iIndex >= 0) {
-00327                         break;
-00328                 }
-00329         }
-00330 
-00331         if (pCurr == NULL || iIndex < 0) {
-00332                 /* No split, no leftover */
-00333                 return NULL;
-00334         }
-00335         /* Split over the iIndex-th character */
-00336         NO_DBG_MSG("pLeftOver");
-00337         pLeftOver = xmalloc(sizeof(*pLeftOver));
-00338         fail(pCurr->tNextFree < (size_t)iIndex);
-00339         pLeftOver->tStorageSize = pCurr->tNextFree - (size_t)iIndex;
-00340         pLeftOver->szStorage = xmalloc(pLeftOver->tStorageSize);
-00341         pLeftOver->tNextFree = pCurr->tNextFree - (size_t)iIndex - 1;
-00342         (void)strncpy(pLeftOver->szStorage,
-00343                 pCurr->szStorage + iIndex + 1, pLeftOver->tNextFree);
-00344         pLeftOver->szStorage[pLeftOver->tNextFree] = '\0';
-00345         NO_DBG_MSG(pLeftOver->szStorage);
-00346         pLeftOver->ucFontColor = pCurr->ucFontColor;
-00347         pLeftOver->usFontStyle = pCurr->usFontStyle;
-00348         pLeftOver->tFontRef = pCurr->tFontRef;
-00349         pLeftOver->usFontSize = pCurr->usFontSize;
-00350         pLeftOver->lStringWidth = lComputeStringWidth(
-00351                                         pLeftOver->szStorage,
-00352                                         pLeftOver->tNextFree,
-00353                                         pLeftOver->tFontRef,
-00354                                         pLeftOver->usFontSize);
-00355         pLeftOver->pPrev = NULL;
-00356         pLeftOver->pNext = pCurr->pNext;
-00357         if (pLeftOver->pNext != NULL) {
-00358                 pLeftOver->pNext->pPrev = pLeftOver;
-00359         }
-00360         fail(!bCheckDoubleLinkedList(pLeftOver));
-00361 
-00362         NO_DBG_MSG("pAnchor");
-00363         NO_DBG_HEX(pCurr->szStorage[iIndex]);
-00364         while (iIndex >= 0 && isspace((int)(UCHAR)pCurr->szStorage[iIndex])) {
-00365                 iIndex--;
-00366         }
-00367         pCurr->tNextFree = (size_t)iIndex + 1;
-00368         pCurr->szStorage[pCurr->tNextFree] = '\0';
-00369         NO_DBG_MSG(pCurr->szStorage);
-00370         pCurr->lStringWidth = lComputeStringWidth(
-00371                                         pCurr->szStorage,
-00372                                         pCurr->tNextFree,
-00373                                         pCurr->tFontRef,
-00374                                         pCurr->usFontSize);
-00375         pCurr->pNext = NULL;
-00376         fail(!bCheckDoubleLinkedList(pAnchor));
-00377 
-00378         return pLeftOver;
-00379 } /* end of pSplitList */
-00380 
-00381 /*
-00382  * tNumber2Roman - convert a number to Roman Numerals
-00383  *
-00384  * returns the number of characters written
-00385  */
-00386 size_t
-00387 tNumber2Roman(UINT uiNumber, BOOL bUpperCase, char *szOutput)
-00388 {
-00389         char    *outp, *p, *q;
-00390         UINT    uiNextVal, uiValue;
-00391 
-00392         fail(szOutput == NULL);
-00393 
-00394         uiNumber %= 4000;       /* Very high numbers can't be represented */
-00395         if (uiNumber == 0) {
-00396                 szOutput[0] = '\0';
-00397                 return 0;
-00398         }
-00399 
-00400         outp = szOutput;
-00401         p = bUpperCase ? "M\2D\5C\2L\5X\2V\5I" : "m\2d\5c\2l\5x\2v\5i";
-00402         uiValue = 1000;
-00403         for (;;) {
-00404                 while (uiNumber >= uiValue) {
-00405                         *outp++ = *p;
-00406                         uiNumber -= uiValue;
-00407                 }
-00408                 if (uiNumber == 0) {
-00409                         *outp = '\0';
-00410                         fail(outp < szOutput);
-00411                         return (size_t)(outp - szOutput);
-00412                 }
-00413                 q = p + 1;
-00414                 uiNextVal = uiValue / (UINT)(UCHAR)*q;
-00415                 if ((int)*q == 2) {             /* magic */
-00416                         uiNextVal /= (UINT)(UCHAR)*(q += 2);
-00417                 }
-00418                 if (uiNumber + uiNextVal >= uiValue) {
-00419                         *outp++ = *++q;
-00420                         uiNumber += uiNextVal;
-00421                 } else {
-00422                         p++;
-00423                         uiValue /= (UINT)(UCHAR)(*p++);
-00424                 }
-00425         }
-00426 } /* end of tNumber2Roman */
-00427 
-00428 /*
-00429  * iNumber2Alpha - convert a number to alphabetic "numbers"
-00430  *
-00431  * returns the number of characters written
-00432  */
-00433 size_t
-00434 tNumber2Alpha(UINT uiNumber, BOOL bUpperCase, char *szOutput)
-00435 {
-00436         char    *outp;
-00437         UINT    uiTmp;
-00438 
-00439         fail(szOutput == NULL);
-00440 
-00441         if (uiNumber == 0) {
-00442                 szOutput[0] = '\0';
-00443                 return 0;
-00444         }
-00445 
-00446         outp = szOutput;
-00447         uiTmp = (UINT)(bUpperCase ? 'A': 'a');
-00448         if (uiNumber <= 26) {
-00449                 uiNumber -= 1;
-00450                 *outp++ = (char)(uiTmp + uiNumber);
-00451         } else if (uiNumber <= 26U + 26U*26U) {
-00452                 uiNumber -= 26 + 1;
-00453                 *outp++ = (char)(uiTmp + uiNumber / 26);
-00454                 *outp++ = (char)(uiTmp + uiNumber % 26);
-00455         } else if (uiNumber <= 26U + 26U*26U + 26U*26U*26U) {
-00456                 uiNumber -= 26 + 26*26 + 1;
-00457                 *outp++ = (char)(uiTmp + uiNumber / (26*26));
-00458                 *outp++ = (char)(uiTmp + uiNumber / 26 % 26);
-00459                 *outp++ = (char)(uiTmp + uiNumber % 26);
-00460         }
-00461         *outp = '\0';
-00462         fail(outp < szOutput);
-00463         return (size_t)(outp - szOutput);
-00464 } /* end of tNumber2Alpha */
-00465 
-00466 /*
-00467  * unincpy - copy a counted Unicode string to an single-byte string
-00468  */
-00469 char *
-00470 unincpy(char *s1, const UCHAR *s2, size_t n)
-00471 {
-00472         char    *pcDest;
-00473         ULONG   ulChar;
-00474         size_t  tLen;
-00475         USHORT  usUni;
-00476 
-00477         for (pcDest = s1, tLen = 0; tLen < n; pcDest++, tLen++) {
-00478                 usUni = usGetWord(tLen * 2, s2);
-00479                 if (usUni == 0) {
-00480                         break;
-00481                 }
-00482                 ulChar = ulTranslateCharacters(usUni, 0, 8,
-00483                                 conversion_unknown, encoding_neutral, FALSE);
-00484                 if (ulChar == IGNORE_CHARACTER) {
-00485                         ulChar = (ULONG)'?';
-00486                 }
-00487                 *pcDest = (char)ulChar;
-00488         }
-00489         for (; tLen < n; tLen++) {
-00490                 *pcDest++ = '\0';
-00491         }
-00492         return s1;
-00493 } /* end of unincpy */
-00494 
-00495 /*
-00496  * unilen - calculate the length of a Unicode string
-00497  *
-00498  * returns the length in bytes
-00499  */
-00500 size_t
-00501 unilen(const UCHAR *s)
-00502 {
-00503         size_t  tLen;
-00504         USHORT  usUni;
-00505 
-00506         tLen = 0;
-00507         for (;;) {
-00508                 usUni = usGetWord(tLen, s);
-00509                 if (usUni == 0) {
-00510                         return tLen;
-00511                 }
-00512                 tLen += 2;
-00513         }
-00514 } /* end of unilen */
-00515 
-00516 /*
-00517  * szBaseName - get the basename of the specified filename
-00518  */
-00519 const char *
-00520 szBasename(const char *szFilename)
-00521 {
-00522         const char      *szTmp;
-00523 
-00524         fail(szFilename == NULL);
-00525 
-00526         if (szFilename == NULL || szFilename[0] == '\0') {
-00527                 return "null";
-00528         }
-00529 
-00530         szTmp = strrchr(szFilename, FILE_SEPARATOR[0]);
-00531         if (szTmp == NULL) {
-00532                 return szFilename;
-00533         }
-00534         return ++szTmp;
-00535 } /* end of szBasename */
-00536 
-00537 /*
-00538  * lComputeLeading - compute the leading
-00539  *
-00540  * NOTE: the fontsize is specified in half points
-00541  *
-00542  * Returns the leading in drawunits
-00543  */
-00544 long
-00545 lComputeLeading(USHORT usFontSize)
-00546 {
-00547         long    lLeading;
-00548 
-00549         lLeading = (long)usFontSize * 500L;
-00550         if (usFontSize < 18) {          /* Small text: 112% */
-00551                 lLeading *= 112;
-00552         } else if (usFontSize < 28) {   /* Normal text: 124% */
-00553                 lLeading *= 124;
-00554         } else if (usFontSize < 48) {   /* Small headlines: 104% */
-00555                 lLeading *= 104;
-00556         } else {                        /* Large headlines: 100% */
-00557                 lLeading *= 100;
-00558         }
-00559         lLeading = lMilliPoints2DrawUnits(lLeading);
-00560         lLeading += 50;
-00561         lLeading /= 100;
-00562         return lLeading;
-00563 } /* end of lComputeLeading */
-00564 
-00565 /*
-00566  * Convert a UCS character to an UTF-8 string
-00567  *
-00568  * Returns the string length of the result
-00569  */
-00570 size_t
-00571 tUcs2Utf8(ULONG ulChar, char *szResult, size_t tMaxResultLen)
-00572 {
-00573         if (szResult == NULL || tMaxResultLen == 0) {
-00574                 return 0;
-00575         }
-00576 
-00577         if (ulChar < 0x80 && tMaxResultLen >= 2) {
-00578                 szResult[0] = (char)ulChar;
-00579                 szResult[1] = '\0';
-00580                 return 1;
-00581         }
-00582         if (ulChar < 0x800 && tMaxResultLen >= 3) {
-00583                 szResult[0] = (char)(0xc0 | ulChar >> 6);
-00584                 szResult[1] = (char)(0x80 | (ulChar & 0x3f));
-00585                 szResult[2] = '\0';
-00586                 return 2;
-00587         }
-00588         if (ulChar < 0x10000 && tMaxResultLen >= 4) {
-00589                 szResult[0] = (char)(0xe0 | ulChar >> 12);
-00590                 szResult[1] = (char)(0x80 | (ulChar >> 6 & 0x3f));
-00591                 szResult[2] = (char)(0x80 | (ulChar & 0x3f));
-00592                 szResult[3] = '\0';
-00593                 return 3;
-00594         }
-00595         if (ulChar < 0x200000 && tMaxResultLen >= 5) {
-00596                 szResult[0] = (char)(0xf0 | ulChar >> 18);
-00597                 szResult[1] = (char)(0x80 | (ulChar >> 12 & 0x3f));
-00598                 szResult[2] = (char)(0x80 | (ulChar >> 6 & 0x3f));
-00599                 szResult[3] = (char)(0x80 | (ulChar & 0x3f));
-00600                 szResult[4] = '\0';
-00601                 return 4;
-00602         }
-00603         szResult[0] = '\0';
-00604         return 0;
-00605 } /* end of tUcs2Utf8 */
-00606 
-00607 /*
-00608  * vGetBulletValue - get the bullet value for the conversing type and encoding
-00609  */
-00610 void
-00611 vGetBulletValue(conversion_type eConversionType, encoding_type eEncoding,
-00612         char *szResult, size_t tMaxResultLen)
-00613 {
-00614         fail(szResult == NULL);
-00615         fail(tMaxResultLen < 2);
-00616 
-00617         if (eEncoding == encoding_utf_8) {
-00618                 (void)tUcs2Utf8(UNICODE_BULLET, szResult, tMaxResultLen);
-00619         } else {
-00620                 szResult[0] = (char)ucGetBulletCharacter(eConversionType,
-00621                                                         eEncoding);
-00622                 szResult[1] = '\0';
-00623         }
-00624 } /* end of vGetBulletValue */
-00625 
-00626 /*
-00627  * bAllZero - are all bytes zero?
-00628  */
-00629 BOOL
-00630 bAllZero(const UCHAR *aucBytes, size_t tLength)
-00631 {
-00632         size_t  tIndex;
-00633 
-00634         if (aucBytes == NULL || tLength == 0) {
-00635                 return TRUE;
-00636         }
-00637 
-00638         for (tIndex = 0; tIndex < tLength; tIndex++) {
-00639                 if (aucBytes[tIndex] != 0) {
-00640                         return FALSE;
-00641                 }
-00642         }
-00643         return TRUE;
-00644 } /* end of bAllZero */
-00645 
-00646 #if !defined(__riscos)
-00647 /*
-00648  * GetCodesetFromLocale - get the codeset from the current locale
-00649  *
-00650  * Original version: Copyright (C) 1999  Bruno Haible
-00651  * Syntax:
-00652  * language[_territory][.codeset][@modifier][+special][,[sponsor][_revision]]
-00653  *
-00654  * Returns TRUE when sucessful, otherwise FALSE
-00655  */
-00656 static BOOL
-00657 bGetCodesetFromLocale(char *szCodeset, size_t tMaxCodesetLength, BOOL *pbEuro)
-00658 {
-00659 #if !defined(__dos)
-00660         const char      *szLocale;
-00661         const char      *pcTmp;
-00662         size_t          tIndex;
-00663         char            szModifier[6];
-00664 #endif /* __dos */
-00665 
-00666         if (pbEuro != NULL) {
-00667                 *pbEuro = FALSE;        /* Until proven otherwise */
-00668         }
-00669         if (szCodeset == NULL || tMaxCodesetLength == 0) {
-00670                 return FALSE;
-00671         }
-00672 
-00673 #if defined(__dos)
-00674         if (tMaxCodesetLength < 2 + sizeof(int) * 3 + 1) {
-00675                 DBG_DEC(tMaxCodesetLength);
-00676                 DBG_DEC(2 + sizeof(int) * 3 + 1);
-00677                 return FALSE;
-00678         }
-00679         /* Get the active codepage from DOS */
-00680         sprintf(szCodeset, "cp%d", iGetCodepage());
-00681         DBG_MSG(szCodeset);
-00682 #else
-00683         /* Get the locale from the environment */
-00684         szLocale = getenv("LC_ALL");
-00685         if (szLocale == NULL || szLocale[0] == '\0') {
-00686                 szLocale = getenv("LC_CTYPE");
-00687                 if (szLocale == NULL || szLocale[0] == '\0') {
-00688                         szLocale = getenv("LANG");
-00689                 }
-00690         }
-00691         if (szLocale == NULL || szLocale[0] == '\0') {
-00692                 /* No locale, so no codeset name and no modifier */
-00693                 return FALSE;
-00694         }
-00695         DBG_MSG(szLocale);
-00696         pcTmp = strchr(szLocale, '.');
-00697         if (pcTmp == NULL) {
-00698                 /* No codeset name */
-00699                 szCodeset[0] = '\0';
-00700         } else {
-00701                 /* Copy the codeset name */
-00702                 pcTmp++;
-00703                 for (tIndex = 0; tIndex < tMaxCodesetLength; tIndex++) {
-00704                         if (*pcTmp == '@' || *pcTmp == '+' ||
-00705                             *pcTmp == ',' || *pcTmp == '_' ||
-00706                             *pcTmp == '\0') {
-00707                                 szCodeset[tIndex] = '\0';
-00708                                 break;
-00709                         }
-00710                         szCodeset[tIndex] = *pcTmp;
-00711                         pcTmp++;
-00712                 }
-00713                 szCodeset[tMaxCodesetLength - 1] = '\0';
-00714         }
-00715         if (pbEuro == NULL) {
-00716                 /* No need to get the modifier */
-00717                 return TRUE;
-00718         }
-00719         pcTmp = strchr(szLocale, '@');
-00720         if (pcTmp != NULL) {
-00721                 /* Copy the modifier */
-00722                 pcTmp++;
-00723                 for (tIndex = 0; tIndex < sizeof(szModifier); tIndex++) {
-00724                         if (*pcTmp == '+' || *pcTmp == ',' ||
-00725                             *pcTmp == '_' || *pcTmp == '\0') {
-00726                                 szModifier[tIndex] = '\0';
-00727                                 break;
-00728                         }
-00729                         szModifier[tIndex] = *pcTmp;
-00730                         pcTmp++;
-00731                 }
-00732                 szModifier[sizeof(szModifier) - 1] = '\0';
-00733                 *pbEuro = STRCEQ(szModifier, "Euro");
-00734         }
-00735 #endif /* __dos */
-00736         return TRUE;
-00737 } /* end of bGetCodesetFromLocale */
-00738 
-00739 /*
-00740  * GetNormalizedCodeset - get the normalized codeset from the current locale
-00741  *
-00742  * Returns TRUE when sucessful, otherwise FALSE
-00743  */
-00744 BOOL
-00745 bGetNormalizedCodeset(char *szCodeset, size_t tMaxCodesetLength, BOOL *pbEuro)
-00746 {
-00747         BOOL    bOnlyDigits;
-00748         const char      *pcSrc;
-00749         char    *pcDest;
-00750         char    *szTmp, *szCodesetNorm;
-00751 
-00752         if (pbEuro != NULL) {
-00753                 *pbEuro = FALSE;        /* Until proven otherwise */
-00754         }
-00755         if (szCodeset == NULL || tMaxCodesetLength < 4) {
-00756                 return FALSE;
-00757         }
-00758 
-00759         /* Get the codeset name */
-00760         szTmp = xmalloc(tMaxCodesetLength - 3);
-00761         if (!bGetCodesetFromLocale(szTmp, tMaxCodesetLength - 3, pbEuro)) {
-00762                 szTmp = xfree(szTmp);
-00763                 return FALSE;
-00764         }
-00765         /* Normalize the codeset name */
-00766         szCodesetNorm = xmalloc(tMaxCodesetLength - 3);
-00767         bOnlyDigits = TRUE;
-00768         pcDest = szCodesetNorm;
-00769         for (pcSrc = szTmp; *pcSrc != '\0'; pcSrc++) {
-00770                 if (isalnum(*pcSrc)) {
-00771                         *pcDest = tolower(*pcSrc);
-00772                         if (!isdigit(*pcDest)) {
-00773                                 bOnlyDigits = FALSE;
-00774                         }
-00775                         pcDest++;
-00776                 }
-00777         }
-00778         *pcDest = '\0';
-00779         DBG_MSG(szCodesetNorm);
-00780         /* Add "iso" when szCodesetNorm contains all digits */
-00781         if (bOnlyDigits && szCodesetNorm[0] != '\0') {
-00782                 fail(strlen(szCodesetNorm) + 3 >= tMaxCodesetLength);
-00783                 sprintf(szCodeset, "iso%s", szCodesetNorm);
-00784         } else {
-00785                 fail(strlen(szCodesetNorm) >= tMaxCodesetLength);
-00786                 strncpy(szCodeset, szCodesetNorm, pcDest - szCodesetNorm + 1);
-00787                 szCodeset[tMaxCodesetLength - 1] = '\0';
-00788         }
-00789         DBG_MSG(szCodeset);
-00790         /* Clean up and leave */
-00791         szCodesetNorm = xfree(szCodesetNorm);
-00792         szTmp = xfree(szTmp);
-00793         return TRUE;
-00794 } /* end of bGetNormalizedCodeset */
-00795 
-00796 /*
-00797  * szGetDefaultMappingFile - get the default mapping file
-00798  *
-00799  * Returns the basename of the default mapping file
-00800  */
-00801 const char *
-00802 szGetDefaultMappingFile(void)
-00803 {
-00804         static const struct {
-00805                 const char      *szCodeset;
-00806                 const char      *szMappingFile;
-00807         } atMappingFile[] = {
-00808                 { "iso88591",   MAPPING_FILE_8859_1 },
-00809                 { "iso88592",   MAPPING_FILE_8859_2 },
-00810                 { "iso88593",   "8859-3.txt" },
-00811                 { "iso88594",   "8859-4.txt" },
-00812                 { "iso88595",   "8859-5.txt" },
-00813                 { "iso88596",   MAPPING_FILE_8859_5 },
-00814                 { "iso88597",   "8859-7.txt" },
-00815                 { "iso88598",   "8859-8.txt" },
-00816                 { "iso88599",   "8859-9.txt" },
-00817                 { "iso885910",  "8859-10.txt" },
-00818                 { "iso885913",  "8859-13.txt" },
-00819                 { "iso885914",  "8859-14.txt" },
-00820                 { "iso885915",  MAPPING_FILE_8859_15 },
-00821                 { "iso885916",  "8859-16.txt" },
-00822                 { "koi8r",      MAPPING_FILE_KOI8_R },
-00823                 { "koi8u",      MAPPING_FILE_KOI8_U },
-00824                 { "utf8",       MAPPING_FILE_UTF_8 },
-00825                 { "cp437",      MAPPING_FILE_CP437 },
-00826                 { "cp850",      "cp850.txt" },
-00827                 { "cp852",      MAPPING_FILE_CP852 },
-00828                 { "cp862",      "cp862.txt" },
-00829                 { "cp864",      "cp864.txt" },
-00830                 { "cp866",      MAPPING_FILE_CP866 },
-00831                 { "cp1250",     MAPPING_FILE_CP1250 },
-00832                 { "cp1251",     MAPPING_FILE_CP1251 },
-00833                 { "cp1252",     "cp1252.txt" },
-00834         };
-00835         size_t  tIndex;
-00836         BOOL    bEuro;
-00837         char    szCodeset[20];
-00838 
-00839         szCodeset[0] = '\0';
-00840         bEuro = FALSE;
-00841         /* Get the normalized codeset name */
-00842         if (!bGetNormalizedCodeset(szCodeset, sizeof(szCodeset), &bEuro)) {
-00843                 return MAPPING_FILE_8859_1;
-00844         }
-00845         if (szCodeset[0] == '\0') {
-00846                 if (bEuro) {
-00847                         /* Default mapping file (with Euro sign) */
-00848                         return MAPPING_FILE_8859_15;
-00849                 } else {
-00850                         /* Default mapping file (without Euro sign) */
-00851                         return MAPPING_FILE_8859_1;
-00852                 }
-00853         }
-00854         /* Find the name in the table */
-00855         for (tIndex = 0; tIndex < elementsof(atMappingFile); tIndex++) {
-00856                 if (STREQ(atMappingFile[tIndex].szCodeset, szCodeset)) {
-00857                         return atMappingFile[tIndex].szMappingFile;
-00858                 }
-00859         }
-00860         /* Default default mapping file */
-00861 #if defined(__dos)
-00862         return MAPPING_FILE_CP437;
-00863 #else
-00864         return MAPPING_FILE_8859_1;
-00865 #endif /* __dos */
-00866 } /* end of szGetDefaultMappingFile */
-00867 #endif /* !__riscos */
-00868 
-00869 /*
-00870  * tConvertDTTM - convert Windows Date and Time format
-00871  *
-00872  * returns Unix time_t or -1
-00873  */
-00874 time_t
-00875 tConvertDTTM(ULONG ulDTTM)
-00876 {
-00877         struct tm       tTime;
-00878         time_t          tResult;
-00879 
-00880         if (ulDTTM == 0) {
-00881                 return (time_t)-1;
-00882         }
-00883         memset(&tTime, 0, sizeof(tTime));
-00884         tTime.tm_min = (int)(ulDTTM & 0x0000003f);
-00885         tTime.tm_hour = (int)((ulDTTM & 0x000007c0) >> 6);
-00886         tTime.tm_mday = (int)((ulDTTM & 0x0000f800) >> 11);
-00887         tTime.tm_mon = (int)((ulDTTM & 0x000f0000) >> 16);
-00888         tTime.tm_year = (int)((ulDTTM & 0x1ff00000) >> 20);
-00889         tTime.tm_isdst = -1;
-00890         tTime.tm_mon--;         /* From 01-12 to 00-11 */
-00891         tResult = mktime(&tTime);
-00892         NO_DBG_MSG(ctime(&tResult));
-00893         return tResult;
-00894 } /* end of tConvertDTTM */
-
-
Generated by  - -doxygen 1.6.2
- - diff -r 59758314f811 -r d4524d6a4472 Symbian3/Examples/guid-6013a680-57f9-415b-8851-c4fa63356636/notes_8c_source.html --- a/Symbian3/Examples/guid-6013a680-57f9-415b-8851-c4fa63356636/notes_8c_source.html Fri Jun 11 15:24:34 2010 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,892 +0,0 @@ - - - - -TB9.2 Example Applications: examples/PIPS/antiword/src/notes.c Source File - - - - - -

examples/PIPS/antiword/src/notes.c

00001 /*
-00002  * notes.c
-00003  * Copyright (C) 1998-2005 A.J. van Os; Released under GNU GPL
-00004  *
-00005  * Description:
-00006  * Functions to tell the difference between footnotes and endnotes
-00007  */
-00008 
-00009 #include "antiword.h"
-00010 
-00011 /*
-00012  * Private structures to hide the way the information
-00013  * is stored from the rest of the program
-00014  */
-00015 typedef struct footnote_local_tag {
-00016         footnote_block_type     tInfo;
-00017         ULONG                   ulCharPosStart;
-00018         ULONG                   ulCharPosNext;
-00019         BOOL                    bUseful;
-00020 } footnote_local_type;
-00021 
-00022 /* Variables needed to write the Footnote and Endnote information */
-00023 static ULONG    *aulFootnoteList = NULL;
-00024 static size_t   tFootnoteListLength = 0;
-00025 static ULONG    *aulEndnoteList = NULL;
-00026 static size_t   tEndnoteListLength = 0;
-00027 /* Variables needed to write the Footnote Text */
-00028 static footnote_local_type      *pFootnoteText = NULL;
-00029 static size_t                   tFootnoteTextLength = 0;
-00030 
-00031 
-00032 /*
-00033  * Destroy the lists with footnote and endnote information
-00034  */
-00035 void
-00036 vDestroyNotesInfoLists(void)
-00037 {
-00038         footnote_local_type     *pRecord;
-00039         size_t                  tFootnote;
-00040 
-00041         TRACE_MSG("vDestroyNotesInfoLists");
-00042 
-00043         /* Free the lists and reset all control variables */
-00044         aulEndnoteList = xfree(aulEndnoteList);
-00045         aulFootnoteList = xfree(aulFootnoteList);
-00046         tEndnoteListLength = 0;
-00047         tFootnoteListLength = 0;
-00048         for (tFootnote = 0; tFootnote < tFootnoteTextLength; tFootnote++) {
-00049                 pRecord = pFootnoteText + tFootnote;
-00050                 pRecord->tInfo.szText = xfree(pRecord->tInfo.szText);
-00051         }
-00052         pFootnoteText = xfree(pFootnoteText);
-00053         tFootnoteTextLength = 0;
-00054 } /* end of vDestroyNotesInfoLists */
-00055 
-00056 /*
-00057  * Build the list with footnote information for Word for DOS files
-00058  */
-00059 static void
-00060 vGet0FootnotesInfoAndText(FILE *pFile, const UCHAR *aucHeader)
-00061 {
-00062         footnote_local_type     *pCurr;
-00063         UCHAR   *aucBuffer;
-00064         ULONG   ulFileOffset, ulBeginOfText, ulOffset, ulBeginFootnoteInfo;
-00065         ULONG   ulCharPos, ulBeginNextBlock;
-00066         size_t  tFootnotes, tFootnoteInfoLen;
-00067         size_t  tIndex;
-00068         UCHAR   aucTmp[2];
-00069 
-00070         TRACE_MSG("vGet0FootnotesInfoAndText");
-00071 
-00072         fail(pFile == NULL || aucHeader == NULL);
-00073 
-00074         ulBeginOfText = 128;
-00075         NO_DBG_HEX(ulBeginOfText);
-00076         ulBeginFootnoteInfo =  128 * (ULONG)usGetWord(0x14, aucHeader);
-00077         DBG_HEX(ulBeginFootnoteInfo);
-00078         ulBeginNextBlock = 128 * (ULONG)usGetWord(0x16, aucHeader);
-00079         DBG_HEX(ulBeginNextBlock);
-00080 
-00081         if (ulBeginFootnoteInfo == ulBeginNextBlock) {
-00082                 DBG_MSG("No Footnotes in this document");
-00083                 return;
-00084         }
-00085 
-00086         /* Read the the number of footnotes + 1 */
-00087         if (!bReadBytes(aucTmp, 2, ulBeginFootnoteInfo, pFile)) {
-00088                 return;
-00089         }
-00090         tFootnotes = (size_t)usGetWord(0, aucTmp);
-00091         if (tFootnotes < 2) {
-00092                 DBG_MSG("No Footnotes in this document (2)");
-00093         }
-00094         DBG_DEC(tFootnotes);
-00095         tFootnoteInfoLen =  8 * tFootnotes;
-00096 
-00097         aucBuffer = xmalloc(tFootnoteInfoLen);
-00098         if (!bReadBytes(aucBuffer,
-00099                         tFootnoteInfoLen, ulBeginFootnoteInfo + 4, pFile)) {
-00100                 aucBuffer = xfree(aucBuffer);
-00101                 return;
-00102         }
-00103         DBG_PRINT_BLOCK(aucBuffer, tFootnoteInfoLen);
-00104 
-00105         /* Get footnote information */
-00106         fail(tFootnoteListLength != 0);
-00107         tFootnoteListLength = tFootnotes - 1;
-00108         fail(tFootnoteListLength == 0);
-00109 
-00110         fail(aulFootnoteList != NULL);
-00111         aulFootnoteList = xcalloc(tFootnoteListLength, sizeof(ULONG));
-00112 
-00113         for (tIndex = 0; tIndex < tFootnoteListLength; tIndex++) {
-00114                 ulOffset = ulGetLong(tIndex * 8, aucBuffer);
-00115                 DBG_HEX(ulOffset);
-00116                 ulFileOffset = ulCharPos2FileOffset(ulBeginOfText + ulOffset);
-00117                 DBG_HEX(ulFileOffset);
-00118                 aulFootnoteList[tIndex] = ulFileOffset;
-00119         }
-00120 
-00121         /* Get footnote text */
-00122         fail(tFootnoteTextLength != 0);
-00123         tFootnoteTextLength = tFootnotes - 1;
-00124         fail(tFootnoteTextLength == 0);
-00125 
-00126         fail(pFootnoteText != NULL);
-00127         pFootnoteText = xcalloc(tFootnoteTextLength,
-00128                                 sizeof(footnote_local_type));
-00129 
-00130         for (tIndex = 0; tIndex < tFootnoteTextLength; tIndex++) {
-00131                 pCurr = pFootnoteText + tIndex;
-00132                 pCurr->tInfo.szText = NULL;
-00133                 ulOffset = ulGetLong(tIndex * 8 + 4, aucBuffer);
-00134                 DBG_HEX(ulOffset);
-00135                 ulCharPos = ulBeginOfText + ulOffset;
-00136                 DBG_HEX(ulCharPos);
-00137                 DBG_HEX(ulCharPos2FileOffset(ulCharPos));
-00138                 pCurr->ulCharPosStart = ulCharPos;
-00139                 ulOffset = ulGetLong((tIndex + 1) * 8 + 4, aucBuffer);
-00140                 DBG_HEX(ulOffset);
-00141                 ulCharPos = ulBeginOfText + ulOffset;
-00142                 DBG_HEX(ulCharPos);
-00143                 DBG_HEX(ulCharPos2FileOffset(ulCharPos));
-00144                 pCurr->ulCharPosNext = ulCharPos;
-00145                 pCurr->bUseful = pCurr->ulCharPosStart != pCurr->ulCharPosNext;
-00146         }
-00147         aucBuffer = xfree(aucBuffer);
-00148 } /* end of vGet0FootnotesInfoAndText */
-00149 
-00150 /*
-00151  * Build the lists note information for Word for DOS files
-00152  */
-00153 static void
-00154 vGet0NotesInfo(FILE *pFile, const UCHAR *aucHeader)
-00155 {
-00156         TRACE_MSG("vGet0NotesInfo");
-00157 
-00158         vGet0FootnotesInfoAndText(pFile, aucHeader);
-00159         /* There are no endnotes in a Word for DOS file */
-00160 } /* end of vGet0NotesInfo */
-00161 
-00162 /*
-00163  * Build the list with footnote information for WinWord 1/2 files
-00164  */
-00165 static void
-00166 vGet2FootnotesInfo(FILE *pFile, const UCHAR *aucHeader)
-00167 {
-00168         UCHAR   *aucBuffer;
-00169         ULONG   ulFileOffset, ulBeginOfText, ulOffset, ulBeginFootnoteInfo;
-00170         size_t  tFootnoteInfoLen;
-00171         size_t  tIndex;
-00172 
-00173         TRACE_MSG("vGet2FootnotesInfo");
-00174 
-00175         fail(pFile == NULL || aucHeader == NULL);
-00176 
-00177         ulBeginOfText = ulGetLong(0x18, aucHeader); /* fcMin */
-00178         NO_DBG_HEX(ulBeginOfText);
-00179         ulBeginFootnoteInfo = ulGetLong(0x64, aucHeader); /* fcPlcffndRef */
-00180         NO_DBG_HEX(ulBeginFootnoteInfo);
-00181         tFootnoteInfoLen = (size_t)usGetWord(0x68, aucHeader); /* cbPlcffndRef */
-00182         NO_DBG_DEC(tFootnoteInfoLen);
-00183 
-00184         if (tFootnoteInfoLen < 10) {
-00185                 DBG_MSG("No Footnotes in this document");
-00186                 return;
-00187         }
-00188 
-00189         aucBuffer = xmalloc(tFootnoteInfoLen);
-00190         if (!bReadBytes(aucBuffer,
-00191                         tFootnoteInfoLen, ulBeginFootnoteInfo, pFile)) {
-00192                 aucBuffer = xfree(aucBuffer);
-00193                 return;
-00194         }
-00195         NO_DBG_PRINT_BLOCK(aucBuffer, tFootnoteInfoLen);
-00196 
-00197         fail(tFootnoteListLength != 0);
-00198         tFootnoteListLength = (tFootnoteInfoLen - 4) / 6;
-00199         fail(tFootnoteListLength == 0);
-00200 
-00201         fail(aulFootnoteList != NULL);
-00202         aulFootnoteList = xcalloc(tFootnoteListLength, sizeof(ULONG));
-00203 
-00204         for (tIndex = 0; tIndex < tFootnoteListLength; tIndex++) {
-00205                 ulOffset = ulGetLong(tIndex * 4, aucBuffer);
-00206                 NO_DBG_HEX(ulOffset);
-00207                 ulFileOffset = ulCharPos2FileOffset(ulBeginOfText + ulOffset);
-00208                 NO_DBG_HEX(ulFileOffset);
-00209                 aulFootnoteList[tIndex] = ulFileOffset;
-00210         }
-00211         aucBuffer = xfree(aucBuffer);
-00212 } /* end of vGet2FootnotesInfo */
-00213 
-00214 /*
-00215  * Build the list with footnote text information for WinWord 1/2 files
-00216  */
-00217 static void
-00218 vGet2FootnotesText(FILE *pFile, const UCHAR *aucHeader)
-00219 {
-00220         footnote_local_type     *pCurr;
-00221         UCHAR   *aucBuffer;
-00222         ULONG   ulCharPos, ulBeginOfFootnotes, ulOffset, ulBeginFootnoteText;
-00223         size_t  tFootnoteTextLen;
-00224         size_t  tIndex;
-00225 
-00226         TRACE_MSG("vGet2FootnotesText");
-00227 
-00228         fail(pFile == NULL || aucHeader == NULL);
-00229 
-00230         ulBeginOfFootnotes = ulGetLong(0x18, aucHeader); /* fcMin */
-00231         ulBeginOfFootnotes += ulGetLong(0x34, aucHeader); /* ccpText */
-00232         NO_DBG_HEX(ulBeginOfFootnotes);
-00233 
-00234         ulBeginFootnoteText = ulGetLong(0x6a, aucHeader); /* fcPlcffndTxt */
-00235         NO_DBG_HEX(ulBeginFootnoteText);
-00236         tFootnoteTextLen =
-00237                 (size_t)usGetWord(0x6e, aucHeader); /* cbPlcffndTxt */
-00238         NO_DBG_DEC(tFootnoteTextLen);
-00239 
-00240         if (tFootnoteTextLen < 12) {
-00241                 DBG_MSG("No Footnote text in this document");
-00242                 return;
-00243         }
-00244 
-00245         aucBuffer = xmalloc(tFootnoteTextLen);
-00246         if (!bReadBytes(aucBuffer,
-00247                         tFootnoteTextLen, ulBeginFootnoteText, pFile)) {
-00248                 aucBuffer = xfree(aucBuffer);
-00249                 return;
-00250         }
-00251         NO_DBG_PRINT_BLOCK(aucBuffer, tFootnoteTextLen);
-00252 
-00253         fail(tFootnoteTextLength != 0);
-00254         tFootnoteTextLength = tFootnoteTextLen / 4 - 2;
-00255         fail(tFootnoteTextLength == 0);
-00256 
-00257         fail(pFootnoteText != NULL);
-00258         pFootnoteText = xcalloc(tFootnoteTextLength,
-00259                                 sizeof(footnote_local_type));
-00260 
-00261         for (tIndex = 0; tIndex < tFootnoteTextLength; tIndex++) {
-00262                 pCurr = pFootnoteText + tIndex;
-00263                 pCurr->tInfo.szText = NULL;
-00264                 ulOffset = ulGetLong(tIndex * 4, aucBuffer);
-00265                 NO_DBG_HEX(ulOffset);
-00266                 ulCharPos = ulBeginOfFootnotes + ulOffset;
-00267                 NO_DBG_HEX(ulCharPos);
-00268                 NO_DBG_HEX(ulCharPos2FileOffset(ulCharPos));
-00269                 pCurr->ulCharPosStart = ulCharPos;
-00270                 ulOffset = ulGetLong(tIndex * 4 + 4, aucBuffer);
-00271                 NO_DBG_HEX(ulOffset);
-00272                 ulCharPos = ulBeginOfFootnotes + ulOffset;
-00273                 NO_DBG_HEX(ulCharPos);
-00274                 NO_DBG_HEX(ulCharPos2FileOffset(ulCharPos));
-00275                 pCurr->ulCharPosNext = ulCharPos;
-00276                 pCurr->bUseful = pCurr->ulCharPosStart != pCurr->ulCharPosNext;
-00277         }
-00278         aucBuffer = xfree(aucBuffer);
-00279 } /* end of vGet2FootnotesText */
-00280 
-00281 /*
-00282  * Build the lists note information for WinWord 1/2 files
-00283  */
-00284 static void
-00285 vGet2NotesInfo(FILE *pFile, const UCHAR *aucHeader)
-00286 {
-00287         TRACE_MSG("vGet2NotesInfo");
-00288 
-00289         vGet2FootnotesInfo(pFile, aucHeader);
-00290         vGet2FootnotesText(pFile, aucHeader);
-00291         /* There are no endnotes in a WinWord 1/2 file */
-00292 } /* end of vGet2NotesInfo */
-00293 
-00294 /*
-00295  * Build the list with footnote information for Word 6/7 files
-00296  */
-00297 static void
-00298 vGet6FootnotesInfo(FILE *pFile, ULONG ulStartBlock,
-00299         const ULONG *aulBBD, size_t tBBDLen,
-00300         const UCHAR *aucHeader)
-00301 {
-00302         UCHAR   *aucBuffer;
-00303         ULONG   ulFileOffset, ulBeginOfText, ulOffset, ulBeginFootnoteInfo;
-00304         size_t  tFootnoteInfoLen;
-00305         size_t  tIndex;
-00306 
-00307         TRACE_MSG("vGet6FootnotesInfo");
-00308 
-00309         fail(pFile == NULL || aucHeader == NULL);
-00310         fail(ulStartBlock > MAX_BLOCKNUMBER && ulStartBlock != END_OF_CHAIN);
-00311         fail(aulBBD == NULL);
-00312 
-00313         ulBeginOfText = ulGetLong(0x18, aucHeader); /* fcMin */
-00314         NO_DBG_HEX(ulBeginOfText);
-00315         ulBeginFootnoteInfo = ulGetLong(0x68, aucHeader); /* fcPlcffndRef */
-00316         NO_DBG_HEX(ulBeginFootnoteInfo);
-00317         tFootnoteInfoLen =
-00318                 (size_t)ulGetLong(0x6c, aucHeader); /* lcbPlcffndRef */
-00319         NO_DBG_DEC(tFootnoteInfoLen);
-00320 
-00321         if (tFootnoteInfoLen < 10) {
-00322                 DBG_MSG("No Footnotes in this document");
-00323                 return;
-00324         }
-00325 
-00326         aucBuffer = xmalloc(tFootnoteInfoLen);
-00327         if (!bReadBuffer(pFile, ulStartBlock,
-00328                         aulBBD, tBBDLen, BIG_BLOCK_SIZE,
-00329                         aucBuffer, ulBeginFootnoteInfo, tFootnoteInfoLen)) {
-00330                 aucBuffer = xfree(aucBuffer);
-00331                 return;
-00332         }
-00333         NO_DBG_PRINT_BLOCK(aucBuffer, tFootnoteInfoLen);
-00334 
-00335         fail(tFootnoteListLength != 0);
-00336         tFootnoteListLength = (tFootnoteInfoLen - 4) / 6;
-00337         fail(tFootnoteListLength == 0);
-00338 
-00339         fail(aulFootnoteList != NULL);
-00340         aulFootnoteList = xcalloc(tFootnoteListLength, sizeof(ULONG));
-00341 
-00342         for (tIndex = 0; tIndex < tFootnoteListLength; tIndex++) {
-00343                 ulOffset = ulGetLong(tIndex * 4, aucBuffer);
-00344                 NO_DBG_HEX(ulOffset);
-00345                 ulFileOffset = ulCharPos2FileOffset(ulBeginOfText + ulOffset);
-00346                 NO_DBG_HEX(ulFileOffset);
-00347                 aulFootnoteList[tIndex] = ulFileOffset;
-00348         }
-00349         aucBuffer = xfree(aucBuffer);
-00350 } /* end of vGet6FootnotesInfo */
-00351 
-00352 /*
-00353  * Build the list with footnote text information for Word 6/7 files
-00354  */
-00355 static void
-00356 vGet6FootnotesText(FILE *pFile, ULONG ulStartBlock,
-00357         const ULONG *aulBBD, size_t tBBDLen,
-00358         const UCHAR *aucHeader)
-00359 {
-00360         footnote_local_type     *pCurr;
-00361         UCHAR   *aucBuffer;
-00362         ULONG   ulCharPos, ulBeginOfFootnotes, ulOffset, ulBeginFootnoteText;
-00363         size_t  tFootnoteTextLen;
-00364         size_t  tIndex;
-00365 
-00366         TRACE_MSG("vGet6FootnotesText");
-00367 
-00368         fail(pFile == NULL || aucHeader == NULL);
-00369         fail(ulStartBlock > MAX_BLOCKNUMBER && ulStartBlock != END_OF_CHAIN);
-00370         fail(aulBBD == NULL);
-00371 
-00372         ulBeginOfFootnotes = ulGetLong(0x18, aucHeader); /* fcMin */
-00373         ulBeginOfFootnotes += ulGetLong(0x34, aucHeader); /* ccpText */
-00374         NO_DBG_HEX(ulBeginOfFootnotes);
-00375 
-00376         ulBeginFootnoteText = ulGetLong(0x70, aucHeader); /* fcPlcffndTxt */
-00377         NO_DBG_HEX(ulBeginFootnoteText);
-00378         tFootnoteTextLen =
-00379                 (size_t)ulGetLong(0x74, aucHeader); /* lcbPlcffndTxt */
-00380         NO_DBG_DEC(tFootnoteTextLen);
-00381 
-00382         if (tFootnoteTextLen < 12) {
-00383                 DBG_MSG("No Footnote text in this document");
-00384                 return;
-00385         }
-00386 
-00387         aucBuffer = xmalloc(tFootnoteTextLen);
-00388         if (!bReadBuffer(pFile, ulStartBlock,
-00389                         aulBBD, tBBDLen, BIG_BLOCK_SIZE,
-00390                         aucBuffer, ulBeginFootnoteText, tFootnoteTextLen)) {
-00391                 aucBuffer = xfree(aucBuffer);
-00392                 return;
-00393         }
-00394         NO_DBG_PRINT_BLOCK(aucBuffer, tFootnoteTextLen);
-00395 
-00396         fail(tFootnoteTextLength != 0);
-00397         tFootnoteTextLength = tFootnoteTextLen / 4 - 2;
-00398         fail(tFootnoteTextLength == 0);
-00399 
-00400         fail(pFootnoteText != NULL);
-00401         pFootnoteText = xcalloc(tFootnoteTextLength,
-00402                                 sizeof(footnote_local_type));
-00403 
-00404         for (tIndex = 0; tIndex < tFootnoteTextLength; tIndex++) {
-00405                 pCurr = pFootnoteText + tIndex;
-00406                 pCurr->tInfo.szText = NULL;
-00407                 ulOffset = ulGetLong(tIndex * 4, aucBuffer);
-00408                 NO_DBG_HEX(ulOffset);
-00409                 ulCharPos = ulBeginOfFootnotes + ulOffset;
-00410                 NO_DBG_HEX(ulCharPos);
-00411                 NO_DBG_HEX(ulCharPos2FileOffset(ulCharPos));
-00412                 pCurr->ulCharPosStart = ulCharPos;
-00413                 ulOffset = ulGetLong(tIndex * 4 + 4, aucBuffer);
-00414                 NO_DBG_HEX(ulOffset);
-00415                 ulCharPos = ulBeginOfFootnotes + ulOffset;
-00416                 NO_DBG_HEX(ulCharPos);
-00417                 NO_DBG_HEX(ulCharPos2FileOffset(ulCharPos));
-00418                 pCurr->ulCharPosNext = ulCharPos;
-00419                 pCurr->bUseful = pCurr->ulCharPosStart != pCurr->ulCharPosNext;
-00420         }
-00421         aucBuffer = xfree(aucBuffer);
-00422 } /* end of vGet6FootnotesText */
-00423 
-00424 /*
-00425  * Build the list with endnote information for Word 6/7 files
-00426  */
-00427 static void
-00428 vGet6EndnotesInfo(FILE *pFile, ULONG ulStartBlock,
-00429         const ULONG *aulBBD, size_t tBBDLen,
-00430         const UCHAR *aucHeader)
-00431 {
-00432         UCHAR   *aucBuffer;
-00433         ULONG   ulFileOffset, ulBeginOfText, ulOffset, ulBeginEndnoteInfo;
-00434         size_t  tEndnoteInfoLen;
-00435         size_t  tIndex;
-00436 
-00437         TRACE_MSG("vGet6EndnotesInfo");
-00438 
-00439         fail(pFile == NULL || aucHeader == NULL);
-00440         fail(ulStartBlock > MAX_BLOCKNUMBER && ulStartBlock != END_OF_CHAIN);
-00441         fail(aulBBD == NULL);
-00442 
-00443         ulBeginOfText = ulGetLong(0x18, aucHeader); /* fcMin */
-00444         NO_DBG_HEX(ulBeginOfText);
-00445         ulBeginEndnoteInfo = ulGetLong(0x1d2, aucHeader); /* fcPlcfendRef */
-00446         NO_DBG_HEX(ulBeginEndnoteInfo);
-00447         tEndnoteInfoLen =
-00448                 (size_t)ulGetLong(0x1d6, aucHeader); /* lcbPlcfendRef */
-00449         NO_DBG_DEC(tEndnoteInfoLen);
-00450 
-00451         if (tEndnoteInfoLen < 10) {
-00452                 DBG_MSG("No Endnotes in this document");
-00453                 return;
-00454         }
-00455 
-00456         aucBuffer = xmalloc(tEndnoteInfoLen);
-00457         if (!bReadBuffer(pFile, ulStartBlock,
-00458                         aulBBD, tBBDLen, BIG_BLOCK_SIZE,
-00459                         aucBuffer, ulBeginEndnoteInfo, tEndnoteInfoLen)) {
-00460                 aucBuffer = xfree(aucBuffer);
-00461                 return;
-00462         }
-00463         NO_DBG_PRINT_BLOCK(aucBuffer, tEndnoteInfoLen);
-00464 
-00465         fail(tEndnoteListLength != 0);
-00466         tEndnoteListLength = (tEndnoteInfoLen - 4) / 6;
-00467         fail(tEndnoteListLength == 0);
-00468 
-00469         fail(aulEndnoteList != NULL);
-00470         aulEndnoteList = xcalloc(tEndnoteListLength, sizeof(ULONG));
-00471 
-00472         for (tIndex = 0; tIndex < tEndnoteListLength; tIndex++) {
-00473                 ulOffset = ulGetLong(tIndex * 4, aucBuffer);
-00474                 NO_DBG_HEX(ulOffset);
-00475                 ulFileOffset = ulCharPos2FileOffset(ulBeginOfText + ulOffset);
-00476                 NO_DBG_HEX(ulFileOffset);
-00477                 aulEndnoteList[tIndex] = ulFileOffset;
-00478         }
-00479         aucBuffer = xfree(aucBuffer);
-00480 } /* end of vGet6EndnotesInfo */
-00481 
-00482 /*
-00483  * Build the lists note information for Word 6/7 files
-00484  */
-00485 static void
-00486 vGet6NotesInfo(FILE *pFile, ULONG ulStartBlock,
-00487         const ULONG *aulBBD, size_t tBBDLen,
-00488         const UCHAR *aucHeader)
-00489 {
-00490         TRACE_MSG("vGet6NotesInfo");
-00491 
-00492         vGet6FootnotesInfo(pFile, ulStartBlock,
-00493                         aulBBD, tBBDLen, aucHeader);
-00494         vGet6FootnotesText(pFile, ulStartBlock,
-00495                         aulBBD, tBBDLen, aucHeader);
-00496         vGet6EndnotesInfo(pFile, ulStartBlock,
-00497                         aulBBD, tBBDLen, aucHeader);
-00498 } /* end of vGet6NotesInfo */
-00499 
-00500 /*
-00501  * Build the list with footnote information for Word 8/9/10 files
-00502  */
-00503 static void
-00504 vGet8FootnotesInfo(FILE *pFile, const pps_info_type *pPPS,
-00505         const ULONG *aulBBD, size_t tBBDLen,
-00506         const ULONG *aulSBD, size_t tSBDLen,
-00507         const UCHAR *aucHeader)
-00508 {
-00509         const ULONG     *aulBlockDepot;
-00510         UCHAR   *aucBuffer;
-00511         ULONG   ulFileOffset, ulBeginOfText, ulOffset, ulBeginFootnoteInfo;
-00512         size_t  tFootnoteInfoLen, tBlockDepotLen, tBlockSize;
-00513         size_t  tIndex;
-00514 
-00515         TRACE_MSG("vGet8FootnotesInfo");
-00516 
-00517         ulBeginOfText = ulGetLong(0x18, aucHeader); /* fcMin */
-00518         NO_DBG_HEX(ulBeginOfText);
-00519         ulBeginFootnoteInfo = ulGetLong(0xaa, aucHeader); /* fcPlcffndRef */
-00520         NO_DBG_HEX(ulBeginFootnoteInfo);
-00521         tFootnoteInfoLen =
-00522                 (size_t)ulGetLong(0xae, aucHeader); /* lcbPlcffndRef */
-00523         NO_DBG_DEC(tFootnoteInfoLen);
-00524 
-00525         if (tFootnoteInfoLen < 10) {
-00526                 DBG_MSG("No Footnotes in this document");
-00527                 return;
-00528         }
-00529 
-00530         NO_DBG_DEC(pPPS->tTable.ulSB);
-00531         NO_DBG_HEX(pPPS->tTable.ulSize);
-00532         if (pPPS->tTable.ulSize == 0) {
-00533                 DBG_MSG("No footnotes information");
-00534                 return;
-00535         }
-00536 
-00537         if (pPPS->tTable.ulSize < MIN_SIZE_FOR_BBD_USE) {
-00538                 /* Use the Small Block Depot */
-00539                 aulBlockDepot = aulSBD;
-00540                 tBlockDepotLen = tSBDLen;
-00541                 tBlockSize = SMALL_BLOCK_SIZE;
-00542         } else {
-00543                 /* Use the Big Block Depot */
-00544                 aulBlockDepot = aulBBD;
-00545                 tBlockDepotLen = tBBDLen;
-00546                 tBlockSize = BIG_BLOCK_SIZE;
-00547         }
-00548         aucBuffer = xmalloc(tFootnoteInfoLen);
-00549         if (!bReadBuffer(pFile, pPPS->tTable.ulSB,
-00550                         aulBlockDepot, tBlockDepotLen, tBlockSize,
-00551                         aucBuffer, ulBeginFootnoteInfo, tFootnoteInfoLen)) {
-00552                 aucBuffer = xfree(aucBuffer);
-00553                 return;
-00554         }
-00555         NO_DBG_PRINT_BLOCK(aucBuffer, tFootnoteInfoLen);
-00556 
-00557         fail(tFootnoteListLength != 0);
-00558         tFootnoteListLength = (tFootnoteInfoLen - 4) / 6;
-00559         fail(tFootnoteListLength == 0);
-00560 
-00561         fail(aulFootnoteList != NULL);
-00562         aulFootnoteList = xcalloc(tFootnoteListLength, sizeof(ULONG));
-00563 
-00564         for (tIndex = 0; tIndex < tFootnoteListLength; tIndex++) {
-00565                 ulOffset = ulGetLong(tIndex * 4, aucBuffer);
-00566                 NO_DBG_HEX(ulOffset);
-00567                 ulFileOffset = ulCharPos2FileOffset(ulBeginOfText + ulOffset);
-00568                 NO_DBG_HEX(ulFileOffset);
-00569                 aulFootnoteList[tIndex] = ulFileOffset;
-00570         }
-00571         aucBuffer = xfree(aucBuffer);
-00572 } /* end of vGet8FootnotesInfo */
-00573 
-00574 /*
-00575  * Build the list with footnote text information for Word 8/9/10 files
-00576  */
-00577 static void
-00578 vGet8FootnotesText(FILE *pFile, const pps_info_type *pPPS,
-00579         const ULONG *aulBBD, size_t tBBDLen,
-00580         const ULONG *aulSBD, size_t tSBDLen,
-00581         const UCHAR *aucHeader)
-00582 {
-00583         footnote_local_type     *pCurr;
-00584         const ULONG     *aulBlockDepot;
-00585         UCHAR   *aucBuffer;
-00586         ULONG   ulCharPos, ulBeginOfFootnotes, ulOffset, ulBeginFootnoteText;
-00587         size_t  tFootnoteTextLen, tBlockDepotLen, tBlockSize;
-00588         size_t  tIndex;
-00589 
-00590         TRACE_MSG("vGet8FootnotesText");
-00591 
-00592         ulBeginOfFootnotes = ulGetLong(0x18, aucHeader); /* fcMin */
-00593         ulBeginOfFootnotes += ulGetLong(0x4c, aucHeader); /* ccpText */
-00594         NO_DBG_HEX(ulBeginOfFootnotes);
-00595 
-00596         ulBeginFootnoteText = ulGetLong(0xb2, aucHeader); /* fcPlcffndTxt */
-00597         NO_DBG_HEX(ulBeginFootnoteText);
-00598         tFootnoteTextLen =
-00599                 (size_t)ulGetLong(0xb6, aucHeader); /* lcbPlcffndTxt */
-00600         NO_DBG_DEC(tFootnoteTextLen);
-00601 
-00602         if (tFootnoteTextLen < 12) {
-00603                 DBG_MSG("No Footnote text in this document");
-00604                 return;
-00605         }
-00606 
-00607         NO_DBG_DEC(pPPS->tTable.ulSB);
-00608         NO_DBG_HEX(pPPS->tTable.ulSize);
-00609         if (pPPS->tTable.ulSize == 0) {
-00610                 DBG_MSG("No footnote text information");
-00611                 return;
-00612         }
-00613 
-00614         if (pPPS->tTable.ulSize < MIN_SIZE_FOR_BBD_USE) {
-00615                 /* Use the Small Block Depot */
-00616                 aulBlockDepot = aulSBD;
-00617                 tBlockDepotLen = tSBDLen;
-00618                 tBlockSize = SMALL_BLOCK_SIZE;
-00619         } else {
-00620                 /* Use the Big Block Depot */
-00621                 aulBlockDepot = aulBBD;
-00622                 tBlockDepotLen = tBBDLen;
-00623                 tBlockSize = BIG_BLOCK_SIZE;
-00624         }
-00625         aucBuffer = xmalloc(tFootnoteTextLen);
-00626         if (!bReadBuffer(pFile, pPPS->tTable.ulSB,
-00627                         aulBlockDepot, tBlockDepotLen, tBlockSize,
-00628                         aucBuffer, ulBeginFootnoteText, tFootnoteTextLen)) {
-00629                 aucBuffer = xfree(aucBuffer);
-00630                 return;
-00631         }
-00632         NO_DBG_PRINT_BLOCK(aucBuffer, tFootnoteTextLen);
-00633 
-00634         fail(tFootnoteTextLength != 0);
-00635         tFootnoteTextLength = tFootnoteTextLen / 4 - 2;
-00636         fail(tFootnoteTextLength == 0);
-00637 
-00638         fail(pFootnoteText != NULL);
-00639         pFootnoteText = xcalloc(tFootnoteTextLength,
-00640                                 sizeof(footnote_local_type));
-00641 
-00642         for (tIndex = 0; tIndex < tFootnoteTextLength; tIndex++) {
-00643                 pCurr = pFootnoteText + tIndex;
-00644                 pCurr->tInfo.szText = NULL;
-00645                 ulOffset = ulGetLong(tIndex * 4, aucBuffer);
-00646                 NO_DBG_HEX(ulOffset);
-00647                 ulCharPos = ulBeginOfFootnotes + ulOffset;
-00648                 NO_DBG_HEX(ulCharPos);
-00649                 NO_DBG_HEX(ulCharPos2FileOffset(ulCharPos));
-00650                 pCurr->ulCharPosStart = ulCharPos;
-00651                 ulOffset = ulGetLong(tIndex * 4 + 4, aucBuffer);
-00652                 NO_DBG_HEX(ulOffset);
-00653                 ulCharPos = ulBeginOfFootnotes + ulOffset;
-00654                 NO_DBG_HEX(ulCharPos);
-00655                 NO_DBG_HEX(ulCharPos2FileOffset(ulCharPos));
-00656                 pCurr->ulCharPosNext = ulCharPos;
-00657                 pCurr->bUseful = pCurr->ulCharPosStart != pCurr->ulCharPosNext;
-00658         }
-00659         aucBuffer = xfree(aucBuffer);
-00660 } /* end of vGet8FootnotesText */
-00661 
-00662 /*
-00663  * Build the list with endnote information for Word 8/9/10 files
-00664  */
-00665 static void
-00666 vGet8EndnotesInfo(FILE *pFile, const pps_info_type *pPPS,
-00667         const ULONG *aulBBD, size_t tBBDLen,
-00668         const ULONG *aulSBD, size_t tSBDLen,
-00669         const UCHAR *aucHeader)
-00670 {
-00671         const ULONG     *aulBlockDepot;
-00672         UCHAR   *aucBuffer;
-00673         ULONG   ulFileOffset, ulBeginOfText, ulOffset, ulBeginEndnoteInfo;
-00674         size_t  tEndnoteInfoLen, tBlockDepotLen, tBlockSize;
-00675         size_t  tIndex;
-00676 
-00677         TRACE_MSG("vGet8EndnotesInfo");
-00678 
-00679         ulBeginOfText = ulGetLong(0x18, aucHeader); /* fcMin */
-00680         NO_DBG_HEX(ulBeginOfText);
-00681         ulBeginEndnoteInfo = ulGetLong(0x20a, aucHeader); /* fcPlcfendRef */
-00682         NO_DBG_HEX(ulBeginEndnoteInfo);
-00683         tEndnoteInfoLen = (size_t)ulGetLong(0x20e, aucHeader); /* lcbPlcfendRef */
-00684         NO_DBG_DEC(tEndnoteInfoLen);
-00685 
-00686         if (tEndnoteInfoLen < 10) {
-00687                 DBG_MSG("No endnotes in this document");
-00688                 return;
-00689         }
-00690 
-00691         NO_DBG_DEC(pPPS->tTable.ulSB);
-00692         NO_DBG_HEX(pPPS->tTable.ulSize);
-00693         if (pPPS->tTable.ulSize == 0) {
-00694                 DBG_MSG("No endnotes information");
-00695                 return;
-00696         }
-00697 
-00698         if (pPPS->tTable.ulSize < MIN_SIZE_FOR_BBD_USE) {
-00699                 /* Use the Small Block Depot */
-00700                 aulBlockDepot = aulSBD;
-00701                 tBlockDepotLen = tSBDLen;
-00702                 tBlockSize = SMALL_BLOCK_SIZE;
-00703         } else {
-00704                 /* Use the Big Block Depot */
-00705                 aulBlockDepot = aulBBD;
-00706                 tBlockDepotLen = tBBDLen;
-00707                 tBlockSize = BIG_BLOCK_SIZE;
-00708         }
-00709         aucBuffer = xmalloc(tEndnoteInfoLen);
-00710         if (!bReadBuffer(pFile, pPPS->tTable.ulSB,
-00711                         aulBlockDepot, tBlockDepotLen, tBlockSize,
-00712                         aucBuffer, ulBeginEndnoteInfo, tEndnoteInfoLen)) {
-00713                 aucBuffer = xfree(aucBuffer);
-00714                 return;
-00715         }
-00716         NO_DBG_PRINT_BLOCK(aucBuffer, tEndnoteInfoLen);
-00717 
-00718         fail(tEndnoteListLength != 0);
-00719         tEndnoteListLength = (tEndnoteInfoLen - 4) / 6;
-00720         fail(tEndnoteListLength == 0);
-00721 
-00722         fail(aulEndnoteList != NULL);
-00723         aulEndnoteList = xcalloc(tEndnoteListLength, sizeof(ULONG));
-00724 
-00725         for (tIndex = 0; tIndex < tEndnoteListLength; tIndex++) {
-00726                 ulOffset = ulGetLong(tIndex * 4, aucBuffer);
-00727                 NO_DBG_HEX(ulOffset);
-00728                 ulFileOffset = ulCharPos2FileOffset(ulBeginOfText + ulOffset);
-00729                 NO_DBG_HEX(ulFileOffset);
-00730                 aulEndnoteList[tIndex] = ulFileOffset;
-00731         }
-00732         aucBuffer = xfree(aucBuffer);
-00733 } /* end of vGet8EndnotesInfo */
-00734 
-00735 /*
-00736  * Build the lists with footnote and endnote information for Word 8/9/10 files
-00737  */
-00738 static void
-00739 vGet8NotesInfo(FILE *pFile, const pps_info_type *pPPS,
-00740         const ULONG *aulBBD, size_t tBBDLen,
-00741         const ULONG *aulSBD, size_t tSBDLen,
-00742         const UCHAR *aucHeader)
-00743 {
-00744         TRACE_MSG("vGet8NotesInfo");
-00745 
-00746         vGet8FootnotesInfo(pFile, pPPS,
-00747                         aulBBD, tBBDLen, aulSBD, tSBDLen, aucHeader);
-00748         vGet8FootnotesText(pFile, pPPS,
-00749                         aulBBD, tBBDLen, aulSBD, tSBDLen, aucHeader);
-00750         vGet8EndnotesInfo(pFile, pPPS,
-00751                         aulBBD, tBBDLen, aulSBD, tSBDLen, aucHeader);
-00752 } /* end of vGet8NotesInfo */
-00753 
-00754 /*
-00755  * Build the lists with footnote and endnote information
-00756  */
-00757 void
-00758 vGetNotesInfo(FILE *pFile, const pps_info_type *pPPS,
-00759         const ULONG *aulBBD, size_t tBBDLen,
-00760         const ULONG *aulSBD, size_t tSBDLen,
-00761         const UCHAR *aucHeader, int iWordVersion)
-00762 {
-00763         TRACE_MSG("vGetNotesInfo");
-00764 
-00765         fail(pFile == NULL);
-00766         fail(pPPS == NULL && iWordVersion >= 6);
-00767         fail(aulBBD == NULL && tBBDLen != 0);
-00768         fail(aulSBD == NULL && tSBDLen != 0);
-00769         fail(aucHeader == NULL);
-00770 
-00771         switch (iWordVersion) {
-00772         case 0:
-00773                 vGet0NotesInfo(pFile, aucHeader);
-00774                 break;
-00775         case 1:
-00776         case 2:
-00777                 vGet2NotesInfo(pFile, aucHeader);
-00778                 break;
-00779         case 4:
-00780         case 5:
-00781                 break;
-00782         case 6:
-00783         case 7:
-00784                 vGet6NotesInfo(pFile, pPPS->tWordDocument.ulSB,
-00785                         aulBBD, tBBDLen, aucHeader);
-00786                 break;
-00787         case 8:
-00788                 vGet8NotesInfo(pFile, pPPS,
-00789                         aulBBD, tBBDLen, aulSBD, tSBDLen, aucHeader);
-00790                 break;
-00791         default:
-00792                 werr(0, "Sorry, no notes information");
-00793                 break;
-00794         }
-00795 } /* end of vGetNotesInfo */
-00796 
-00797 /*
-00798  *  vPrepareFootnoteText - prepare the footnote text
-00799  */
-00800 void
-00801 vPrepareFootnoteText(FILE *pFile)
-00802 { 
-00803         footnote_local_type     *pCurr;
-00804         size_t          tFootnote;
-00805 
-00806         fail(pFile == NULL);
-00807         fail(pFootnoteText == NULL && tFootnoteTextLength != 0);
-00808 
-00809         if (pFootnoteText == NULL || tFootnoteTextLength == 0) {
-00810                 /* No information */
-00811                 return;
-00812         }
-00813 
-00814         /* Fill text and useful-ness */
-00815         for (tFootnote = 0; tFootnote < tFootnoteTextLength; tFootnote++) {
-00816                 pCurr = pFootnoteText + tFootnote;
-00817                 pCurr->bUseful = pCurr->ulCharPosStart != pCurr->ulCharPosNext;
-00818                 if (pCurr->bUseful) {
-00819                         pCurr->tInfo.szText = szFootnoteDecryptor(pFile,
-00820                                                         pCurr->ulCharPosStart,
-00821                                                         pCurr->ulCharPosNext);
-00822                 } else {
-00823                         pCurr->tInfo.szText = NULL;
-00824                 }
-00825         }
-00826 } /* end of vPrepareFootnoteText */
-00827 
-00828 /*
-00829  * szGetFootnootText - get the text of the spefified footnote
-00830  */
-00831 const char *
-00832 szGetFootnootText(UINT uiFootnoteIndex)
-00833 {
-00834         if ((size_t)uiFootnoteIndex >= tFootnoteTextLength) {
-00835                 return NULL;
-00836         }
-00837         return pFootnoteText[uiFootnoteIndex].tInfo.szText;
-00838 } /* end of szGetFootnootText */
-00839 
-00840 /*
-00841  * Get the notetype of the note at the given fileoffset
-00842  */
-00843 notetype_enum
-00844 eGetNotetype(ULONG ulFileOffset)
-00845 {
-00846         size_t  tIndex;
-00847 
-00848         TRACE_MSG("eGetNotetype");
-00849 
-00850         fail(aulFootnoteList == NULL && tFootnoteListLength != 0);
-00851         fail(aulEndnoteList == NULL && tEndnoteListLength != 0);
-00852 
-00853         /* Go for the easy answers first */
-00854         if (tFootnoteListLength == 0 && tEndnoteListLength == 0) {
-00855                 return notetype_is_unknown;
-00856         }
-00857         if (tEndnoteListLength == 0) {
-00858                 return notetype_is_footnote;
-00859         }
-00860         if (tFootnoteListLength == 0) {
-00861                 return notetype_is_endnote;
-00862         }
-00863         /* No easy answer, so we search */
-00864         for (tIndex = 0; tIndex < tFootnoteListLength; tIndex++) {
-00865                 if (aulFootnoteList[tIndex] == ulFileOffset) {
-00866                         return notetype_is_footnote;
-00867                 }
-00868         }
-00869         for (tIndex = 0; tIndex < tEndnoteListLength; tIndex++) {
-00870                 if (aulEndnoteList[tIndex] == ulFileOffset) {
-00871                         return notetype_is_endnote;
-00872                 }
-00873         }
-00874         /* Not found */
-00875         return notetype_is_unknown;
-00876 } /* end of eGetNotetype */
-
-
Generated by  - -doxygen 1.6.2
- - diff -r 59758314f811 -r d4524d6a4472 Symbian3/Examples/guid-6013a680-57f9-415b-8851-c4fa63356636/options_8c_source.html --- a/Symbian3/Examples/guid-6013a680-57f9-415b-8851-c4fa63356636/options_8c_source.html Fri Jun 11 15:24:34 2010 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,978 +0,0 @@ - - - - -TB9.2 Example Applications: examples/PIPS/antiword/src/options.c Source File - - - - - -

examples/PIPS/antiword/src/options.c

00001 /*
-00002  * options.c
-00003  * Copyright (C) 1998-2004 A.J. van Os; Released under GNU GPL
-00004  *
-00005  * Description:
-00006  * Read and write the options
-00007  */
-00008 
-00009 #include <stdio.h>
-00010 #include <stdlib.h>
-00011 #include <string.h>
-00012 #if defined(__riscos)
-00013 #include "DeskLib:Error.h"
-00014 #include "DeskLib:Wimp.h"
-00015 #else
-00016 #include <stdlib.h>
-00017 #if defined(__dos) || defined(N_PLAT_NLM)
-00018 extern int getopt(int, char **, const char *);
-00019 #else
-00020 #include <unistd.h>
-00021 #endif /* __dos */
-00022 #endif /* __riscos */
-00023 #include "antiword.h"
-00024 
-00025 #if defined(__riscos)
-00026 #define PARAGRAPH_BREAK         "set paragraph_break=%d"
-00027 #define AUTOFILETYPE            "set autofiletype_allowed=%d"
-00028 #define USE_OUTLINEFONTS        "set use_outlinefonts=%d"
-00029 #define SHOW_IMAGES             "set show_images=%d"
-00030 #define HIDE_HIDDEN_TEXT        "set hide_hidden_text=%d"
-00031 #define SCALE_FACTOR_START      "set scale_factor_start=%d"
-00032 #else
-00033 #define LEAFNAME_SIZE           (32+1)
-00034 #endif /* __riscos */
-00035 
-00036 /* Current values for options */
-00037 static options_type     tOptionsCurr;
-00038 #if defined(__riscos)
-00039 /* Temporary values for options */
-00040 static options_type     tOptionsTemp;
-00041 #else
-00042 typedef struct papersize_tag {
-00043         char    szName[16];     /* Papersize name */
-00044         USHORT  usWidth;        /* In points */
-00045         USHORT  usHeight;       /* In points */
-00046 } papersize_type;
-00047 
-00048 static const papersize_type atPaperSizes[] = {
-00049         {       "10x14",         720,   1008    },
-00050         {       "a3",            842,   1191    },
-00051         {       "a4",            595,    842    },
-00052         {       "a5",            420,    595    },
-00053         {       "b4",            729,   1032    },
-00054         {       "b5",            516,    729    },
-00055         {       "executive",     540,    720    },
-00056         {       "folio",         612,    936    },
-00057         {       "legal",         612,   1008    },
-00058         {       "letter",        612,    792    },
-00059         {       "note",          540,    720    },
-00060         {       "quarto",        610,    780    },
-00061         {       "statement",     396,    612    },
-00062         {       "tabloid",       792,   1224    },
-00063         {       "",                0,      0    },
-00064 };
-00065 #endif /* __riscos */
-00066 /* Default values for options */
-00067 static const options_type       tOptionsDefault = {
-00068         DEFAULT_SCREEN_WIDTH,
-00069 #if defined(__riscos)
-00070         conversion_draw,
-00071 #else
-00072         conversion_text,
-00073 #endif /* __riscos */
-00074         TRUE,
-00075         TRUE,
-00076         FALSE,
-00077         encoding_latin_1,
-00078         INT_MAX,
-00079         INT_MAX,
-00080         level_default,
-00081 #if defined(__riscos)
-00082         TRUE,
-00083         DEFAULT_SCALE_FACTOR,
-00084 #endif /* __riscos */
-00085 };
-00086 
-00087 
-00088 #if !defined(__riscos)
-00089 /*
-00090  * bCorrectPapersize - see if the papersize is correct
-00091  *
-00092  * TRUE if the papersize is correct, otherwise FALSE
-00093  */
-00094 static BOOL
-00095 bCorrectPapersize(const char *szName, conversion_type eConversionType)
-00096 {
-00097         const papersize_type    *pPaperSize;
-00098 
-00099         for (pPaperSize = atPaperSizes;
-00100              pPaperSize->szName[0] != '\0';
-00101              pPaperSize++) {
-00102                 if (!STRCEQ(pPaperSize->szName,  szName)) {
-00103                         continue;
-00104                 }
-00105                 DBG_DEC(pPaperSize->usWidth);
-00106                 DBG_DEC(pPaperSize->usHeight);
-00107                 tOptionsCurr.eConversionType = eConversionType;
-00108                 tOptionsCurr.iPageHeight = (int)pPaperSize->usHeight;
-00109                 tOptionsCurr.iPageWidth = (int)pPaperSize->usWidth;
-00110                 return TRUE;
-00111         }
-00112         return FALSE;
-00113 } /* end of bCorrectPapersize */
-00114 
-00115 /*
-00116  * szCreateSuffix - create a suffix for the file
-00117  *
-00118  * Returns the suffix
-00119  */
-00120 static const char *
-00121 szCreateSuffix(const char *szLeafname)
-00122 {
-00123         const char      *pcDot;
-00124 
-00125         pcDot = strrchr(szLeafname, '.');
-00126         if (pcDot != NULL && STRCEQ(pcDot, ".txt")) {
-00127                 /* There is already a .txt suffix, no need for another one */
-00128                 return "";
-00129         }
-00130         return ".txt";
-00131 } /* end of szCreateSuffix */
-00132 
-00133 /*
-00134  * eMappingFile2Encoding - convert the mapping file to an encoding
-00135  */
-00136 static encoding_type
-00137 eMappingFile2Encoding(const char *szLeafname)
-00138 {
-00139         char    szMappingFile[LEAFNAME_SIZE+4];
-00140 
-00141         fail(szLeafname == NULL);
-00142 
-00143         if (strlen(szLeafname) + 4 >= sizeof(szMappingFile)) {
-00144                 DBG_MSG(szLeafname);
-00145                 return encoding_latin_1;
-00146         }
-00147 
-00148         sprintf(szMappingFile, "%s%s", szLeafname, szCreateSuffix(szLeafname));
-00149 
-00150         DBG_MSG(szMappingFile);
-00151 
-00152         if (STRCEQ(szMappingFile, MAPPING_FILE_UTF_8)) {
-00153                 return encoding_utf_8;
-00154         }
-00155         if (STRCEQ(szMappingFile, MAPPING_FILE_CP852) ||
-00156             STRCEQ(szMappingFile, MAPPING_FILE_CP1250) ||
-00157             STRCEQ(szMappingFile, MAPPING_FILE_8859_2)) {
-00158                 return encoding_latin_2;
-00159         }
-00160         if (STRCEQ(szMappingFile, MAPPING_FILE_KOI8_R) ||
-00161             STRCEQ(szMappingFile, MAPPING_FILE_KOI8_U) ||
-00162             STRCEQ(szMappingFile, MAPPING_FILE_CP866) ||
-00163             STRCEQ(szMappingFile, MAPPING_FILE_CP1251) ||
-00164             STRCEQ(szMappingFile, MAPPING_FILE_8859_5)) {
-00165                 return encoding_cyrillic;
-00166         }
-00167         return encoding_latin_1;
-00168 } /* end of eMappingFile2Encoding */
-00169 #endif /* !__riscos */
-00170 
-00171 /*
-00172  * pOpenCharacterMappingFile - open the mapping file
-00173  *
-00174  * Returns the file pointer or NULL
-00175  */
-00176 static FILE *
-00177 pOpenCharacterMappingFile(const char *szLeafname)
-00178 {
-00179 #if !defined(__riscos)
-00180         FILE    *pFile;
-00181         const char      *szHome, *szAntiword, *szSuffix;
-00182         size_t  tFilenameLen;
-00183         char    szMappingFile[PATH_MAX+1];
-00184 #endif /* !__riscos */
-00185 
-00186         if (szLeafname == NULL || szLeafname[0] == '\0') {
-00187                 return NULL;
-00188         }
-00189 
-00190         DBG_MSG(szLeafname);
-00191 
-00192 #if defined(__riscos)
-00193         return fopen(szLeafname, "r");
-00194 #else
-00195         /* Set the suffix */
-00196         szSuffix = szCreateSuffix(szLeafname);
-00197 
-00198         /* Set length */
-00199         tFilenameLen = strlen(szLeafname) + strlen(szSuffix);
-00200 
-00201         /* Try the environment version of the mapping file */
-00202         szAntiword = szGetAntiwordDirectory();
-00203         if (szAntiword != NULL && szAntiword[0] != '\0') {
-00204             if (strlen(szAntiword) + tFilenameLen <
-00205                 sizeof(szMappingFile) -
-00206                 sizeof(FILE_SEPARATOR)) {
-00207                         sprintf(szMappingFile,
-00208                                 "%s" FILE_SEPARATOR "%s%s",
-00209                                 szAntiword, szLeafname, szSuffix);
-00210                         DBG_MSG(szMappingFile);
-00211                         pFile = fopen(szMappingFile, "r");
-00212                         if (pFile != NULL) {
-00213                                 return pFile;
-00214                         }
-00215                 } else {
-00216                         werr(0, "Environment mappingfilename ignored");
-00217                 }
-00218         }
-00219 
-00220         /* Try the local version of the mapping file */
-00221         szHome = szGetHomeDirectory();
-00222         if (strlen(szHome) + tFilenameLen <
-00223             sizeof(szMappingFile) -
-00224             sizeof(ANTIWORD_DIR) -
-00225             2 * sizeof(FILE_SEPARATOR)) {
-00226                 #ifndef SYMBIAN
-00227                 sprintf(szMappingFile,
-00228                         "%s%s%s",
-00229                         szHome, szLeafname, szSuffix);
-00230                 #else   
-00231                 sprintf(szMappingFile,
-00232                         "%s%s%s",
-00233                         szHome, szLeafname, szSuffix);
-00234                 #endif /*SYMBIAN*/      
-00235                 DBG_MSG(szMappingFile);
-00236                 pFile = fopen(szMappingFile, "r");
-00237                 if (pFile != NULL) {
-00238                         return pFile;
-00239                 }
-00240         } else {
-00241                 werr(0, "Local mappingfilename too long, ignored");
-00242         }
-00243 
-00244         /* Try the global version of the mapping file */
-00245         if (tFilenameLen <
-00246             sizeof(szMappingFile) -
-00247             sizeof(GLOBAL_ANTIWORD_DIR) -
-00248             sizeof(FILE_SEPARATOR)) {
-00249                 sprintf(szMappingFile,
-00250                         GLOBAL_ANTIWORD_DIR FILE_SEPARATOR "%s%s",
-00251                         szLeafname, szSuffix);
-00252                 DBG_MSG(szMappingFile);
-00253                 pFile = fopen(szMappingFile, "r");
-00254                 if (pFile != NULL) {
-00255                         return pFile;
-00256                 }
-00257         } else {
-00258                 werr(0, "Global mappingfilename too long, ignored");
-00259         }
-00260         werr(0, "I can't open your mapping file (%s%s)\n"
-00261                 "It is not in '%s" FILE_SEPARATOR ANTIWORD_DIR "' nor in '"
-00262                 GLOBAL_ANTIWORD_DIR "'.", szLeafname, szSuffix, szHome);
-00263         return NULL;
-00264 #endif /* __riscos */
-00265 } /* end of pOpenCharacterMappingFile */
-00266 
-00267 /*
-00268  * vCloseCharacterMappingFile - close the mapping file
-00269  */
-00270 static void
-00271 vCloseCharacterMappingFile(FILE *pFile)
-00272 {
-00273         (void)fclose(pFile);
-00274 } /* end of pCloseCharacterMappingFile */
-00275 
-00276 
-00277 /*
-00278  * iReadOptions - read options
-00279  *
-00280  * returns:     -1: error
-00281  *               0: help
-00282  *              >0: index first file argument
-00283  */
-00284 int
-00285 iReadOptions(int argc, char **argv)
-00286 {
-00287 #if defined(__riscos)
-00288         FILE    *pFile;
-00289         const char      *szAlphabet;
-00290         int     iAlphabet;
-00291         char    szLine[81];
-00292 #else
-00293         extern  char    *optarg;
-00294         extern int      optind;
-00295         char    *pcChar, *szTmp;
-00296         int     iChar;
-00297         char    szLeafname[LEAFNAME_SIZE];
-00298 #endif /* __riscos */
-00299         FILE    *pCharacterMappingFile;
-00300         int     iTmp;
-00301         BOOL    bSuccess;
-00302 
-00303         DBG_MSG("iReadOptions");
-00304 
-00305 /* Defaults */
-00306         tOptionsCurr = tOptionsDefault;
-00307 
-00308 #if defined(__riscos)
-00309 /* Choices file */
-00310         pFile = fopen("<AntiWord$ChoicesFile>", "r");
-00311         DBG_MSG_C(pFile == NULL, "Choices file not found");
-00312         DBG_HEX_C(pFile != NULL, pFile);
-00313         if (pFile != NULL) {
-00314                 while (fgets(szLine, (int)sizeof(szLine), pFile) != NULL) {
-00315                         DBG_MSG(szLine);
-00316                         if (szLine[0] == '#' ||
-00317                             szLine[0] == '\r' ||
-00318                             szLine[0] == '\n') {
-00319                                 continue;
-00320                         }
-00321                         if (sscanf(szLine, PARAGRAPH_BREAK, &iTmp) == 1 &&
-00322                             (iTmp == 0 ||
-00323                             (iTmp >= MIN_SCREEN_WIDTH &&
-00324                              iTmp <= MAX_SCREEN_WIDTH))) {
-00325                                 tOptionsCurr.iParagraphBreak = iTmp;
-00326                                 DBG_DEC(tOptionsCurr.iParagraphBreak);
-00327                         } else if (sscanf(szLine, AUTOFILETYPE, &iTmp)
-00328                                                                 == 1) {
-00329                                 tOptionsCurr.bAutofiletypeAllowed =
-00330                                                                 iTmp != 0;
-00331                                 DBG_DEC(tOptionsCurr.bAutofiletypeAllowed);
-00332                         } else if (sscanf(szLine, USE_OUTLINEFONTS, &iTmp)
-00333                                                                 == 1) {
-00334                                 tOptionsCurr.eConversionType =
-00335                                         iTmp == 0 ?
-00336                                         conversion_text : conversion_draw;
-00337                                 DBG_DEC(tOptionsCurr.eConversionType);
-00338                         } else if (sscanf(szLine, SHOW_IMAGES, &iTmp)
-00339                                                                 == 1) {
-00340                                 tOptionsCurr.eImageLevel = iTmp != 0 ?
-00341                                         level_default : level_no_images;
-00342                         } else if (sscanf(szLine, HIDE_HIDDEN_TEXT, &iTmp)
-00343                                                                 == 1) {
-00344                                 tOptionsCurr.bHideHiddenText = iTmp != 0;
-00345                                 DBG_DEC(tOptionsCurr.bHideHiddenText);
-00346                         } else if (sscanf(szLine, SCALE_FACTOR_START, &iTmp)
-00347                                                                 == 1) {
-00348                                 if (iTmp >= MIN_SCALE_FACTOR &&
-00349                                     iTmp <= MAX_SCALE_FACTOR) {
-00350                                         tOptionsCurr.iScaleFactor = iTmp;
-00351                                         DBG_DEC(tOptionsCurr.iScaleFactor);
-00352                                 }
-00353                         }
-00354                 }
-00355                 (void)fclose(pFile);
-00356         }
-00357         iAlphabet = iReadCurrentAlphabetNumber();
-00358         switch (iAlphabet) {
-00359         case 101:       /* ISO-8859-1 aka Latin1 */
-00360                 szAlphabet = "<AntiWord$Latin1>";
-00361                 break;
-00362         case 112:       /* ISO-8859-15 aka Latin9 */
-00363                 szAlphabet = "<AntiWord$Latin9>";
-00364                 break;
-00365         default:
-00366                 werr(0, "Alphabet '%d' is not supported", iAlphabet);
-00367                 return -1;
-00368         }
-00369         pCharacterMappingFile = pOpenCharacterMappingFile(szAlphabet);
-00370         if (pCharacterMappingFile != NULL) {
-00371                 bSuccess = bReadCharacterMappingTable(pCharacterMappingFile);
-00372                 vCloseCharacterMappingFile(pCharacterMappingFile);
-00373         } else {
-00374                 bSuccess = FALSE;
-00375         }
-00376         return bSuccess ? 1 : -1;
-00377 #else
-00378 /* Environment */
-00379         
-00380         #ifdef SYMBIAN
-00381         //Adding Some environment Variable explicitly
-00382         if ( setenv("COLUMNS", "80", 1) == 0)
-00383         #endif /*SYMBIAN*/
-00384         szTmp = getenv("COLUMNS");
-00385         
-00386         if (szTmp != NULL) {
-00387                 DBG_MSG(szTmp);
-00388                 iTmp = (int)strtol(szTmp, &pcChar, 10);
-00389                 if (*pcChar == '\0') {
-00390                         iTmp -= 4;      /* This is for the edge */
-00391                         if (iTmp < MIN_SCREEN_WIDTH) {
-00392                                 iTmp = MIN_SCREEN_WIDTH;
-00393                         } else if (iTmp > MAX_SCREEN_WIDTH) {
-00394                                 iTmp = MAX_SCREEN_WIDTH;
-00395                         }
-00396                         tOptionsCurr.iParagraphBreak = iTmp;
-00397                         DBG_DEC(tOptionsCurr.iParagraphBreak);
-00398                 }
-00399         }
-00400         strncpy(szLeafname, szGetDefaultMappingFile(), sizeof(szLeafname) - 1);
-00401         szLeafname[sizeof(szLeafname) - 1] = '\0';
-00402 /* Command line */
-00403         while ((iChar = getopt(argc, argv, "La:fhi:m:p:rstw:x:")) != -1) {
-00404                 switch (iChar) {
-00405                 case 'L':
-00406                         tOptionsCurr.bUseLandscape = TRUE;
-00407                         break;
-00408                 case 'a':
-00409                         if (!bCorrectPapersize(optarg, conversion_pdf)) {
-00410                                 werr(0, "-a without a valid papersize");
-00411                                 return -1;
-00412                         }
-00413                         break;
-00414                 case 'f':
-00415                         tOptionsCurr.eConversionType = conversion_fmt_text;
-00416                         break;
-00417                 case 'h':
-00418                         return 0;
-00419                 case 'i':
-00420                         iTmp = (int)strtol(optarg, &pcChar, 10);
-00421                         if (*pcChar != '\0') {
-00422                                 break;
-00423                         }
-00424                         switch (iTmp) {
-00425                         case 0:
-00426                                 tOptionsCurr.eImageLevel = level_gs_special;
-00427                                 break;
-00428                         case 1:
-00429                                 tOptionsCurr.eImageLevel = level_no_images;
-00430                                 break;
-00431                         case 2:
-00432                                 tOptionsCurr.eImageLevel = level_ps_2;
-00433                                 break;
-00434                         case 3:
-00435                                 tOptionsCurr.eImageLevel = level_ps_3;
-00436                                 break;
-00437                         default:
-00438                                 tOptionsCurr.eImageLevel = level_default;
-00439                                 break;
-00440                         }
-00441                         DBG_DEC(tOptionsCurr.eImageLevel);
-00442                         break;
-00443                 case 'm':
-00444                         if (tOptionsCurr.eConversionType == conversion_xml) {
-00445                                 werr(0, "XML doesn't need a mapping file");
-00446                                 break;
-00447                         }
-00448                         strncpy(szLeafname, optarg, sizeof(szLeafname) - 1);
-00449                         szLeafname[sizeof(szLeafname) - 1] = '\0';
-00450                         DBG_MSG(szLeafname);
-00451                         break;
-00452                 case 'p':
-00453                         if (!bCorrectPapersize(optarg, conversion_ps)) {
-00454                                 werr(0, "-p without a valid papersize");
-00455                                 return -1;
-00456                         }
-00457                         break;
-00458                 case 'r':
-00459                         tOptionsCurr.bRemoveRemovedText = FALSE;
-00460                         break;
-00461                 case 's':
-00462                         tOptionsCurr.bHideHiddenText = FALSE;
-00463                         break;
-00464                 case 't':
-00465                         tOptionsCurr.eConversionType = conversion_text;
-00466                         break;
-00467                 case 'w':
-00468                         iTmp = (int)strtol(optarg, &pcChar, 10);
-00469                         if (*pcChar == '\0') {
-00470                                 if (iTmp != 0 && iTmp < MIN_SCREEN_WIDTH) {
-00471                                         iTmp = MIN_SCREEN_WIDTH;
-00472                                 } else if (iTmp > MAX_SCREEN_WIDTH) {
-00473                                         iTmp = MAX_SCREEN_WIDTH;
-00474                                 }
-00475                                 tOptionsCurr.iParagraphBreak = iTmp;
-00476                                 DBG_DEC(tOptionsCurr.iParagraphBreak);
-00477                         }
-00478                         break;
-00479                 case 'x':
-00480                         if (STREQ(optarg, "db")) {
-00481                                 tOptionsCurr.iParagraphBreak = 0;
-00482                                 tOptionsCurr.eConversionType = conversion_xml;
-00483                                 strcpy(szLeafname, MAPPING_FILE_UTF_8);
-00484                         } else {
-00485                                 werr(0, "-x %s is not supported", optarg);
-00486                                 return -1;
-00487                         }
-00488                         break;
-00489                 default:
-00490                         return -1;
-00491                 }
-00492         }
-00493 
-00494         tOptionsCurr.eEncoding = eMappingFile2Encoding(szLeafname);
-00495         DBG_DEC(tOptionsCurr.eEncoding);
-00496 
-00497         if (tOptionsCurr.eConversionType == conversion_ps &&
-00498             tOptionsCurr.eEncoding == encoding_utf_8) {
-00499                 werr(0,
-00500                 "The combination PostScript and UTF-8 is not supported");
-00501                 return -1;
-00502         }
-00503 
-00504         if (tOptionsCurr.eConversionType == conversion_pdf &&
-00505             tOptionsCurr.eEncoding == encoding_utf_8) {
-00506                 werr(0,
-00507                 "The combination PDF and UTF-8 is not supported");
-00508                 return -1;
-00509         }
-00510 
-00511         if (tOptionsCurr.eConversionType == conversion_pdf &&
-00512             tOptionsCurr.eEncoding == encoding_cyrillic) {
-00513                 werr(0,
-00514                 "The combination PDF and Cyrillic is not supported");
-00515                 return -1;
-00516         }
-00517 
-00518         if (tOptionsCurr.eConversionType == conversion_ps ||
-00519             tOptionsCurr.eConversionType == conversion_pdf) {
-00520                 /* PostScript or PDF mode */
-00521                 if (tOptionsCurr.bUseLandscape) {
-00522                         /* Swap the page height and width */
-00523                         iTmp = tOptionsCurr.iPageHeight;
-00524                         tOptionsCurr.iPageHeight = tOptionsCurr.iPageWidth;
-00525                         tOptionsCurr.iPageWidth = iTmp;
-00526                 }
-00527                 /* The paragraph break depends on the width of the paper */
-00528                 tOptionsCurr.iParagraphBreak = iMilliPoints2Char(
-00529                         (long)tOptionsCurr.iPageWidth * 1000 -
-00530                         lDrawUnits2MilliPoints(
-00531                                 PS_LEFT_MARGIN + PS_RIGHT_MARGIN));
-00532                 DBG_DEC(tOptionsCurr.iParagraphBreak);
-00533         }
-00534 
-00535         pCharacterMappingFile = pOpenCharacterMappingFile(szLeafname);
-00536         if (pCharacterMappingFile != NULL) {
-00537                 bSuccess = bReadCharacterMappingTable(pCharacterMappingFile);
-00538                 vCloseCharacterMappingFile(pCharacterMappingFile);
-00539         } else {
-00540                 bSuccess = FALSE;
-00541         }
-00542         return bSuccess ? optind : -1;
-00543 #endif /* __riscos */
-00544 } /* end of iReadOptions */
-00545 
-00546 /*
-00547  * vGetOptions - get a copy of the current option values
-00548  */
-00549 void
-00550 vGetOptions(options_type *pOptions)
-00551 {
-00552         fail(pOptions == NULL);
-00553 
-00554         *pOptions = tOptionsCurr;
-00555 } /* end of vGetOptions */
-00556 
-00557 #if defined(__riscos)
-00558 /*
-00559  * vWriteOptions - write the current options to the Options file
-00560  */
-00561 static void
-00562 vWriteOptions(void)
-00563 {
-00564         FILE    *pFile;
-00565         char    *szOptionsFile;
-00566 
-00567         TRACE_MSG("vWriteOptions");
-00568 
-00569         szOptionsFile = getenv("AntiWord$ChoicesSave");
-00570         if (szOptionsFile == NULL) {
-00571                 werr(0, "Warning: Name of the Choices file not found");
-00572                 return;
-00573         }
-00574         if (!bMakeDirectory(szOptionsFile)) {
-00575                 werr(0,
-00576                 "Warning: I can't make a directory for the Choices file");
-00577                 return;
-00578         }
-00579         pFile = fopen(szOptionsFile, "w");
-00580         if (pFile == NULL) {
-00581                 werr(0, "Warning: I can't write the Choices file");
-00582                 return;
-00583         }
-00584         (void)fprintf(pFile, PARAGRAPH_BREAK"\n",
-00585                 tOptionsCurr.iParagraphBreak);
-00586         (void)fprintf(pFile, AUTOFILETYPE"\n",
-00587                 tOptionsCurr.bAutofiletypeAllowed);
-00588         (void)fprintf(pFile, USE_OUTLINEFONTS"\n",
-00589                 tOptionsCurr.eConversionType == conversion_text ? 0 : 1);
-00590         (void)fprintf(pFile, SHOW_IMAGES"\n",
-00591                 tOptionsCurr.eImageLevel == level_no_images ? 0 : 1);
-00592         (void)fprintf(pFile, HIDE_HIDDEN_TEXT"\n",
-00593                 tOptionsCurr.bHideHiddenText);
-00594         (void)fprintf(pFile, SCALE_FACTOR_START"\n",
-00595                 tOptionsCurr.iScaleFactor);
-00596         (void)fclose(pFile);
-00597 } /* end of vWriteOptions */
-00598 
-00599 /*
-00600  * vChoicesOpenAction - action to be taken when the Choices window opens
-00601  */
-00602 void
-00603 vChoicesOpenAction(window_handle tWindow)
-00604 {
-00605         TRACE_MSG("vChoicesOpenAction");
-00606 
-00607         tOptionsTemp = tOptionsCurr;
-00608         if (tOptionsTemp.iParagraphBreak == 0) {
-00609                 vUpdateRadioButton(tWindow, CHOICES_BREAK_BUTTON, FALSE);
-00610                 vUpdateRadioButton(tWindow, CHOICES_NO_BREAK_BUTTON, TRUE);
-00611                 vUpdateWriteableNumber(tWindow, CHOICES_BREAK_WRITEABLE,
-00612                                         DEFAULT_SCREEN_WIDTH);
-00613         } else {
-00614                 vUpdateRadioButton(tWindow, CHOICES_BREAK_BUTTON, TRUE);
-00615                 vUpdateRadioButton(tWindow, CHOICES_NO_BREAK_BUTTON, FALSE);
-00616                 vUpdateWriteableNumber(tWindow,
-00617                         CHOICES_BREAK_WRITEABLE,
-00618                         tOptionsTemp.iParagraphBreak);
-00619         }
-00620         vUpdateRadioButton(tWindow, CHOICES_AUTOFILETYPE_BUTTON,
-00621                                         tOptionsTemp.bAutofiletypeAllowed);
-00622         vUpdateRadioButton(tWindow, CHOICES_HIDDEN_TEXT_BUTTON,
-00623                                         tOptionsTemp.bHideHiddenText);
-00624         if (tOptionsTemp.eConversionType == conversion_draw) {
-00625                 vUpdateRadioButton(tWindow,
-00626                         CHOICES_WITH_IMAGES_BUTTON,
-00627                         tOptionsTemp.eImageLevel != level_no_images);
-00628                 vUpdateRadioButton(tWindow,
-00629                         CHOICES_NO_IMAGES_BUTTON,
-00630                         tOptionsTemp.eImageLevel == level_no_images);
-00631                 vUpdateRadioButton(tWindow,
-00632                         CHOICES_TEXTONLY_BUTTON, FALSE);
-00633         } else {
-00634                 vUpdateRadioButton(tWindow,
-00635                         CHOICES_WITH_IMAGES_BUTTON, FALSE);
-00636                 vUpdateRadioButton(tWindow,
-00637                         CHOICES_NO_IMAGES_BUTTON, FALSE);
-00638                 vUpdateRadioButton(tWindow,
-00639                         CHOICES_TEXTONLY_BUTTON, TRUE);
-00640         }
-00641         vUpdateWriteableNumber(tWindow,
-00642                 CHOICES_SCALE_WRITEABLE, tOptionsTemp.iScaleFactor);
-00643         TRACE_MSG("end of vChoicesOpenAction");
-00644 } /* end of vChoicesOpenAction */
-00645 
-00646 /*
-00647  * vDefaultButtonAction - action when the default button is clicked
-00648  */
-00649 static void
-00650 vDefaultButtonAction(window_handle tWindow)
-00651 {
-00652         TRACE_MSG("vDefaultButtonAction");
-00653 
-00654         tOptionsTemp = tOptionsDefault;
-00655         vUpdateRadioButton(tWindow, CHOICES_BREAK_BUTTON, TRUE);
-00656         vUpdateRadioButton(tWindow, CHOICES_NO_BREAK_BUTTON, FALSE);
-00657         vUpdateWriteableNumber(tWindow, CHOICES_BREAK_WRITEABLE,
-00658                         tOptionsTemp.iParagraphBreak);
-00659         vUpdateRadioButton(tWindow, CHOICES_AUTOFILETYPE_BUTTON,
-00660                         tOptionsTemp.bAutofiletypeAllowed);
-00661         vUpdateRadioButton(tWindow, CHOICES_HIDDEN_TEXT_BUTTON,
-00662                         tOptionsTemp.bHideHiddenText);
-00663         vUpdateRadioButton(tWindow, CHOICES_WITH_IMAGES_BUTTON,
-00664                         tOptionsTemp.eConversionType == conversion_draw &&
-00665                         tOptionsTemp.eImageLevel != level_no_images);
-00666         vUpdateRadioButton(tWindow, CHOICES_NO_IMAGES_BUTTON,
-00667                         tOptionsTemp.eConversionType == conversion_draw &&
-00668                         tOptionsTemp.eImageLevel == level_no_images);
-00669         vUpdateRadioButton(tWindow, CHOICES_TEXTONLY_BUTTON,
-00670                         tOptionsTemp.eConversionType == conversion_text);
-00671         vUpdateWriteableNumber(tWindow, CHOICES_SCALE_WRITEABLE,
-00672                         tOptionsTemp.iScaleFactor);
-00673 } /* end of vDefaultButtonAction */
-00674 
-00675 /*
-00676  * vApplyButtonAction - action to be taken when the OK button is clicked
-00677  */
-00678 static void
-00679 vApplyButtonAction(void)
-00680 {
-00681         TRACE_MSG("vApplyButtonAction");
-00682 
-00683         tOptionsCurr = tOptionsTemp;
-00684 } /* end of vApplyButtonAction */
-00685 
-00686 /*
-00687  * vSaveButtonAction - action to be taken when the save button is clicked
-00688  */
-00689 static void
-00690 vSaveButtonAction(void)
-00691 {
-00692         TRACE_MSG("vSaveButtonAction");
-00693 
-00694         vApplyButtonAction();
-00695         vWriteOptions();
-00696 } /* end of vSaveButtonAction */
-00697 
-00698 /*
-00699  * vSetParagraphBreak - set the paragraph break to the given number
-00700  */
-00701 static void
-00702 vSetParagraphBreak(window_handle tWindow, int iNumber)
-00703 {
-00704         tOptionsTemp.iParagraphBreak = iNumber;
-00705         if (tOptionsTemp.iParagraphBreak == 0) {
-00706                 return;
-00707         }
-00708         vUpdateWriteableNumber(tWindow,
-00709                         CHOICES_BREAK_WRITEABLE,
-00710                         tOptionsTemp.iParagraphBreak);
-00711 } /* end of vSetParagraphBreak */
-00712 
-00713 /*
-00714  * vChangeParagraphBreak - change the paragraph break with the given number
-00715  */
-00716 static void
-00717 vChangeParagraphBreak(window_handle tWindow, int iNumber)
-00718 {
-00719         int     iTmp;
-00720 
-00721         iTmp = tOptionsTemp.iParagraphBreak + iNumber;
-00722         if (iTmp < MIN_SCREEN_WIDTH || iTmp > MAX_SCREEN_WIDTH) {
-00723                 /* Ignore */
-00724                 return;
-00725         }
-00726         tOptionsTemp.iParagraphBreak = iTmp;
-00727         vUpdateWriteableNumber(tWindow,
-00728                         CHOICES_BREAK_WRITEABLE,
-00729                         tOptionsTemp.iParagraphBreak);
-00730 } /* end of vChangeParagraphBreak */
-00731 
-00732 /*
-00733  * vChangeAutofiletype - invert the permission to autofiletype
-00734  */
-00735 static void
-00736 vChangeAutofiletype(window_handle tWindow)
-00737 {
-00738         tOptionsTemp.bAutofiletypeAllowed =
-00739                                 !tOptionsTemp.bAutofiletypeAllowed;
-00740         vUpdateRadioButton(tWindow,
-00741                         CHOICES_AUTOFILETYPE_BUTTON,
-00742                         tOptionsTemp.bAutofiletypeAllowed);
-00743 } /* end of vChangeAutofiletype */
-00744 
-00745 /*
-00746  * vChangeHiddenText - invert the hide/show hidden text
-00747  */
-00748 static void
-00749 vChangeHiddenText(window_handle tWindow)
-00750 {
-00751         tOptionsTemp.bHideHiddenText = !tOptionsTemp.bHideHiddenText;
-00752         vUpdateRadioButton(tWindow,
-00753                         CHOICES_HIDDEN_TEXT_BUTTON,
-00754                         tOptionsTemp.bHideHiddenText);
-00755 } /* end of vChangeHiddenText */
-00756 
-00757 /*
-00758  * vUseFontsImages - use outline fonts, show images
-00759  */
-00760 static void
-00761 vUseFontsImages(BOOL bUseOutlineFonts, BOOL bShowImages)
-00762 {
-00763         tOptionsTemp.eConversionType =
-00764                 bUseOutlineFonts ? conversion_draw : conversion_text;
-00765         tOptionsTemp.eImageLevel =
-00766                 bUseOutlineFonts && bShowImages ?
-00767                 level_default : level_no_images;
-00768 } /* end of vUseFontsImages */
-00769 
-00770 /*
-00771  * vSetScaleFactor - set the scale factor to the given number
-00772  */
-00773 static void
-00774 vSetScaleFactor(window_handle tWindow, int iNumber)
-00775 {
-00776         tOptionsTemp.iScaleFactor = iNumber;
-00777         vUpdateWriteableNumber(tWindow,
-00778                         CHOICES_SCALE_WRITEABLE,
-00779                         tOptionsTemp.iScaleFactor);
-00780 } /* end of vSetScaleFactor */
-00781 
-00782 /*
-00783  * vChangeScaleFactor - change the scale factor with the given number
-00784  */
-00785 static void
-00786 vChangeScaleFactor(window_handle tWindow, int iNumber)
-00787 {
-00788         int     iTmp;
-00789 
-00790         iTmp = tOptionsTemp.iScaleFactor + iNumber;
-00791         if (iTmp < MIN_SCALE_FACTOR || iTmp > MAX_SCALE_FACTOR) {
-00792                 /* Ignore */
-00793                 return;
-00794         }
-00795         tOptionsTemp.iScaleFactor = iTmp;
-00796         vUpdateWriteableNumber(tWindow,
-00797                         CHOICES_SCALE_WRITEABLE,
-00798                         tOptionsTemp.iScaleFactor);
-00799 } /* end of vChangeScaleFactor */
-00800 
-00801 /*
-00802  * bChoicesMouseClick - handle a mouse click in the Choices window
-00803  */
-00804 BOOL
-00805 bChoicesMouseClick(event_pollblock *pEvent, void *pvReference)
-00806 {
-00807         icon_handle     tAction;
-00808         mouse_block     *pMouse;
-00809         BOOL            bCloseWindow;
-00810 
-00811         TRACE_MSG("bChoicesMouseClick");
-00812 
-00813         fail(pEvent == NULL);
-00814         fail(pEvent->type != event_CLICK);
-00815 
-00816         pMouse = &pEvent->data.mouse;
-00817         if (!pMouse->button.data.select && !pMouse->button.data.adjust) {
-00818                 /* Not handled here */
-00819                 DBG_HEX(pMouse->button.value);
-00820                 return FALSE;
-00821         }
-00822 
-00823         /* Which action should be taken */
-00824         tAction = pMouse->icon;
-00825         if (pMouse->button.data.adjust) {
-00826                 /* The adjust button reverses the direction */
-00827                 switch (pMouse->icon) {
-00828                 case CHOICES_BREAK_UP_BUTTON:
-00829                         tAction = CHOICES_BREAK_DOWN_BUTTON;
-00830                         break;
-00831                 case CHOICES_BREAK_DOWN_BUTTON:
-00832                         tAction = CHOICES_BREAK_UP_BUTTON;
-00833                         break;
-00834                 case CHOICES_SCALE_UP_BUTTON:
-00835                         tAction = CHOICES_SCALE_DOWN_BUTTON;
-00836                         break;
-00837                 case CHOICES_SCALE_DOWN_BUTTON:
-00838                         tAction = CHOICES_SCALE_UP_BUTTON;
-00839                         break;
-00840                 default:
-00841                         break;
-00842                 }
-00843         }
-00844 
-00845         /* Actions */
-00846         bCloseWindow = FALSE;
-00847         switch (tAction) {
-00848         case CHOICES_DEFAULT_BUTTON:
-00849                 vDefaultButtonAction(pMouse->window);
-00850                 break;
-00851         case CHOICES_SAVE_BUTTON:
-00852                 vSaveButtonAction();
-00853                 break;
-00854         case CHOICES_CANCEL_BUTTON:
-00855                 bCloseWindow = TRUE;
-00856                 break;
-00857         case CHOICES_APPLY_BUTTON:
-00858                 vApplyButtonAction();
-00859                 bCloseWindow = TRUE;
-00860                 break;
-00861         case CHOICES_BREAK_BUTTON:
-00862                 vSetParagraphBreak(pMouse->window, DEFAULT_SCREEN_WIDTH);
-00863                 break;
-00864         case CHOICES_BREAK_UP_BUTTON:
-00865                 vChangeParagraphBreak(pMouse->window, 1);
-00866                 break;
-00867         case CHOICES_BREAK_DOWN_BUTTON:
-00868                 vChangeParagraphBreak(pMouse->window, -1);
-00869                 break;
-00870         case CHOICES_NO_BREAK_BUTTON:
-00871                 vSetParagraphBreak(pMouse->window, 0);
-00872                 break;
-00873         case CHOICES_AUTOFILETYPE_BUTTON:
-00874                 vChangeAutofiletype(pMouse->window);
-00875                 break;
-00876         case CHOICES_HIDDEN_TEXT_BUTTON:
-00877                 vChangeHiddenText(pMouse->window);
-00878                 break;
-00879         case CHOICES_WITH_IMAGES_BUTTON:
-00880                 vUseFontsImages(TRUE, TRUE);
-00881                 break;
-00882         case CHOICES_NO_IMAGES_BUTTON:
-00883                 vUseFontsImages(TRUE, FALSE);
-00884                 break;
-00885         case CHOICES_TEXTONLY_BUTTON:
-00886                 vUseFontsImages(FALSE, FALSE);
-00887                 break;
-00888         case CHOICES_SCALE_UP_BUTTON:
-00889                 vChangeScaleFactor(pMouse->window, 5);
-00890                 break;
-00891         case CHOICES_SCALE_DOWN_BUTTON:
-00892                 vChangeScaleFactor(pMouse->window, -5);
-00893                 break;
-00894         default:
-00895                 DBG_DEC(pMouse->icon);
-00896                 break;
-00897         }
-00898         if (bCloseWindow) {
-00899                 Error_CheckFatal(Wimp_CloseWindow(pMouse->window));
-00900         }
-00901         return TRUE;
-00902 } /* end of bChoicesMouseClick */
-00903 
-00904 /*
-00905  * bChoicesKeyPressed - handle a key in the Choices window
-00906  */
-00907 BOOL
-00908 bChoicesKeyPressed(event_pollblock *pEvent, void *pvReference)
-00909 {
-00910         icon_block      tIcon;
-00911         caret_block     *pCaret;
-00912         char            *pcChar;
-00913         int             iNumber;
-00914 
-00915         DBG_MSG("bChoicesKeyPressed");
-00916 
-00917         fail(pEvent == NULL);
-00918         fail(pEvent->type != event_KEY);
-00919 
-00920         if (pEvent->data.key.code != '\r') {
-00921                 Error_CheckFatal(Wimp_ProcessKey(pEvent->data.key.code));
-00922                 return TRUE;
-00923         }
-00924 
-00925         pCaret = &pEvent->data.key.caret;
-00926 
-00927         Error_CheckFatal(Wimp_GetIconState(pCaret->window, pCaret->icon, &tIcon));
-00928         if (!tIcon.flags.data.text || !tIcon.flags.data.indirected) {
-00929                 werr(1, "Icon %d must be indirected text", (int)pCaret->icon);
-00930         }
-00931         iNumber = (int)strtol(tIcon.data.indirecttext.buffer, &pcChar, 10);
-00932 
-00933         switch(pCaret->icon) {
-00934         case CHOICES_BREAK_WRITEABLE:
-00935                 if (*pcChar != '\0' && *pcChar != '\r') {
-00936                         DBG_DEC(*pcChar);
-00937                         iNumber = DEFAULT_SCREEN_WIDTH;
-00938                 } else if (iNumber < MIN_SCREEN_WIDTH) {
-00939                         iNumber = MIN_SCREEN_WIDTH;
-00940                 } else if (iNumber > MAX_SCREEN_WIDTH) {
-00941                         iNumber = MAX_SCREEN_WIDTH;
-00942                 }
-00943                 vSetParagraphBreak(pCaret->window, iNumber);
-00944                 break;
-00945         case CHOICES_SCALE_WRITEABLE:
-00946                 if (*pcChar != '\0' && *pcChar != '\r') {
-00947                         DBG_DEC(*pcChar);
-00948                         iNumber = DEFAULT_SCALE_FACTOR;
-00949                 } else if (iNumber < MIN_SCALE_FACTOR) {
-00950                         iNumber = MIN_SCALE_FACTOR;
-00951                 } else if (iNumber > MAX_SCALE_FACTOR) {
-00952                         iNumber = MAX_SCALE_FACTOR;
-00953                 }
-00954                 vSetScaleFactor(pCaret->window, iNumber);
-00955                 break;
-00956         default:
-00957                 DBG_DEC(pCaret->icon);
-00958                 break;
-00959         }
-00960         return TRUE;
-00961 } /* end of bChoicesKeyPressed */
-00962 #endif /* __riscos */
-
-
Generated by  - -doxygen 1.6.2
- - diff -r 59758314f811 -r d4524d6a4472 Symbian3/Examples/guid-6013a680-57f9-415b-8851-c4fa63356636/out2window_8c_source.html --- a/Symbian3/Examples/guid-6013a680-57f9-415b-8851-c4fa63356636/out2window_8c_source.html Fri Jun 11 15:24:34 2010 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,784 +0,0 @@ - - - - -TB9.2 Example Applications: examples/PIPS/antiword/src/out2window.c Source File - - - - - -

examples/PIPS/antiword/src/out2window.c

00001 /*
-00002  * out2window.c
-00003  * Copyright (C) 1998-2005 A.J. van Os; Released under GPL
-00004  *
-00005  * Description:
-00006  * Output to a text window
-00007  */
-00008 
-00009 #include <string.h>
-00010 #include <stdlib.h>
-00011 #include <ctype.h>
-00012 #include "antiword.h"
-00013 
-00014 /* Used for numbering the chapters */
-00015 static unsigned int     auiHdrCounter[9];
-00016 
-00017 
-00018 /*
-00019  * vString2Diagram - put a string into a diagram
-00020  */
-00021 static void
-00022 vString2Diagram(diagram_type *pDiag, output_type *pAnchor)
-00023 {
-00024         output_type     *pOutput;
-00025         long            lWidth;
-00026         USHORT          usMaxFontSize;
-00027 
-00028         TRACE_MSG("vString2Diagram");
-00029 
-00030         fail(pDiag == NULL);
-00031         fail(pAnchor == NULL);
-00032 
-00033         /* Compute the maximum fontsize in this string */
-00034         usMaxFontSize = MIN_FONT_SIZE;
-00035         for (pOutput = pAnchor; pOutput != NULL; pOutput = pOutput->pNext) {
-00036                 if (pOutput->usFontSize > usMaxFontSize) {
-00037                         usMaxFontSize = pOutput->usFontSize;
-00038                 }
-00039         }
-00040 
-00041         /* Goto the next line */
-00042         vMove2NextLine(pDiag, pAnchor->tFontRef, usMaxFontSize);
-00043 
-00044         /* Output all substrings */
-00045         for (pOutput = pAnchor; pOutput != NULL; pOutput = pOutput->pNext) {
-00046                 lWidth = lMilliPoints2DrawUnits(pOutput->lStringWidth);
-00047                 vSubstring2Diagram(pDiag, pOutput->szStorage,
-00048                         pOutput->tNextFree, lWidth, pOutput->ucFontColor,
-00049                         pOutput->usFontStyle, pOutput->tFontRef,
-00050                         pOutput->usFontSize, usMaxFontSize);
-00051         }
-00052 
-00053         /* Goto the start of the line */
-00054         pDiag->lXleft = 0;
-00055         TRACE_MSG("leaving vString2Diagram");
-00056 } /* end of vString2Diagram */
-00057 
-00058 /*
-00059  * vSetLeftIndentation - set the left indentation of the specified diagram
-00060  */
-00061 void
-00062 vSetLeftIndentation(diagram_type *pDiag, long lLeftIndentation)
-00063 {
-00064         long    lX;
-00065 
-00066         TRACE_MSG("vSetLeftIndentation");
-00067 
-00068         fail(pDiag == NULL);
-00069         fail(lLeftIndentation < 0);
-00070 
-00071         lX = lMilliPoints2DrawUnits(lLeftIndentation);
-00072         if (lX > 0) {
-00073                 pDiag->lXleft = lX;
-00074         } else {
-00075                 pDiag->lXleft = 0;
-00076         }
-00077 } /* end of vSetLeftIndentation */
-00078 
-00079 /*
-00080  * lComputeNetWidth - compute the net string width
-00081  */
-00082 static long
-00083 lComputeNetWidth(output_type *pAnchor)
-00084 {
-00085         output_type     *pTmp;
-00086         long            lNetWidth;
-00087 
-00088         TRACE_MSG("lComputeNetWidth");
-00089 
-00090         fail(pAnchor == NULL);
-00091 
-00092         /* Step 1: Count all but the last sub-string */
-00093         lNetWidth = 0;
-00094         for (pTmp = pAnchor; pTmp->pNext != NULL; pTmp = pTmp->pNext) {
-00095                 fail(pTmp->lStringWidth < 0);
-00096                 lNetWidth += pTmp->lStringWidth;
-00097         }
-00098         fail(pTmp == NULL);
-00099         fail(pTmp->pNext != NULL);
-00100 
-00101         /* Step 2: remove the white-space from the end of the string */
-00102         while (pTmp->tNextFree != 0 &&
-00103                isspace((int)(UCHAR)pTmp->szStorage[pTmp->tNextFree - 1])) {
-00104                 pTmp->szStorage[pTmp->tNextFree - 1] = '\0';
-00105                 pTmp->tNextFree--;
-00106                 NO_DBG_DEC(pTmp->lStringWidth);
-00107                 pTmp->lStringWidth = lComputeStringWidth(
-00108                                                 pTmp->szStorage,
-00109                                                 pTmp->tNextFree,
-00110                                                 pTmp->tFontRef,
-00111                                                 pTmp->usFontSize);
-00112                 NO_DBG_DEC(pTmp->lStringWidth);
-00113         }
-00114 
-00115         /* Step 3: Count the last sub-string */
-00116         lNetWidth += pTmp->lStringWidth;
-00117         return lNetWidth;
-00118 } /* end of lComputeNetWidth */
-00119 
-00120 /*
-00121  * iComputeHoles - compute number of holes
-00122  * (A hole is a number of whitespace characters followed by a
-00123  *  non-whitespace character)
-00124  */
-00125 static int
-00126 iComputeHoles(output_type *pAnchor)
-00127 {
-00128         output_type     *pTmp;
-00129         size_t  tIndex;
-00130         int     iCounter;
-00131         BOOL    bWasSpace, bIsSpace;
-00132 
-00133         TRACE_MSG("iComputeHoles");
-00134 
-00135         fail(pAnchor == NULL);
-00136 
-00137         iCounter = 0;
-00138         bIsSpace = FALSE;
-00139         /* Count the holes */
-00140         for (pTmp = pAnchor; pTmp != NULL; pTmp = pTmp->pNext) {
-00141                 fail(pTmp->tNextFree != strlen(pTmp->szStorage));
-00142                 for (tIndex = 0; tIndex <= pTmp->tNextFree; tIndex++) {
-00143                         bWasSpace = bIsSpace;
-00144                         bIsSpace = isspace((int)(UCHAR)pTmp->szStorage[tIndex]);
-00145                         if (bWasSpace && !bIsSpace) {
-00146                                 iCounter++;
-00147                         }
-00148                 }
-00149         }
-00150         return iCounter;
-00151 } /* end of iComputeHoles */
-00152 
-00153 /*
-00154  * vAlign2Window - Align a string and insert it into the text
-00155  */
-00156 void
-00157 vAlign2Window(diagram_type *pDiag, output_type *pAnchor,
-00158         long lScreenWidth, UCHAR ucAlignment)
-00159 {
-00160         long    lNetWidth, lLeftIndentation;
-00161 
-00162         TRACE_MSG("vAlign2Window");
-00163 
-00164         fail(pDiag == NULL || pAnchor == NULL);
-00165         fail(lScreenWidth < lChar2MilliPoints(MIN_SCREEN_WIDTH));
-00166 
-00167         lNetWidth = lComputeNetWidth(pAnchor);
-00168 
-00169         if (lScreenWidth > lChar2MilliPoints(MAX_SCREEN_WIDTH) ||
-00170             lNetWidth <= 0) {
-00171                 /*
-00172                  * Screenwidth is "infinite", so no alignment is possible
-00173                  * Don't bother to align an empty line
-00174                  */
-00175                 vString2Diagram(pDiag, pAnchor);
-00176                 TRACE_MSG("leaving vAlign2Window #1");
-00177                 return;
-00178         }
-00179 
-00180         switch (ucAlignment) {
-00181         case ALIGNMENT_CENTER:
-00182                 lLeftIndentation = (lScreenWidth - lNetWidth) / 2;
-00183                 DBG_DEC_C(lLeftIndentation < 0, lLeftIndentation);
-00184                 if (lLeftIndentation > 0) {
-00185                         vSetLeftIndentation(pDiag, lLeftIndentation);
-00186                 }
-00187                 break;
-00188         case ALIGNMENT_RIGHT:
-00189                 lLeftIndentation = lScreenWidth - lNetWidth;
-00190                 DBG_DEC_C(lLeftIndentation < 0, lLeftIndentation);
-00191                 if (lLeftIndentation > 0) {
-00192                         vSetLeftIndentation(pDiag, lLeftIndentation);
-00193                 }
-00194                 break;
-00195         case ALIGNMENT_JUSTIFY:
-00196         case ALIGNMENT_LEFT:
-00197         default:
-00198                 break;
-00199         }
-00200         vString2Diagram(pDiag, pAnchor);
-00201         TRACE_MSG("leaving vAlign2Window #2");
-00202 } /* end of vAlign2Window */
-00203 
-00204 /*
-00205  * vJustify2Window - Justify a string and insert it into the text
-00206  */
-00207 void
-00208 vJustify2Window(diagram_type *pDiag, output_type *pAnchor,
-00209         long lScreenWidth, long lRightIndentation, UCHAR ucAlignment)
-00210 {
-00211         output_type     *pTmp;
-00212         char    *pcNew, *pcOld, *szStorage;
-00213         long    lNetWidth, lSpaceWidth, lToAdd;
-00214         int     iFillerLen, iHoles;
-00215 
-00216         TRACE_MSG("vJustify2Window");
-00217 
-00218         fail(pDiag == NULL || pAnchor == NULL);
-00219         fail(lScreenWidth < MIN_SCREEN_WIDTH);
-00220         fail(lRightIndentation > 0);
-00221 
-00222         if (ucAlignment != ALIGNMENT_JUSTIFY) {
-00223                 vAlign2Window(pDiag, pAnchor, lScreenWidth, ucAlignment);
-00224                 return;
-00225         }
-00226 
-00227         lNetWidth = lComputeNetWidth(pAnchor);
-00228 
-00229         if (lScreenWidth > lChar2MilliPoints(MAX_SCREEN_WIDTH) ||
-00230             lNetWidth <= 0) {
-00231                 /*
-00232                  * Screenwidth is "infinite", so justify is not possible
-00233                  * Don't bother to justify an empty line
-00234                  */
-00235                 vString2Diagram(pDiag, pAnchor);
-00236                 TRACE_MSG("leaving vJustify2Window #1");
-00237                 return;
-00238         }
-00239 
-00240         /* Justify */
-00241         fail(ucAlignment != ALIGNMENT_JUSTIFY);
-00242         lSpaceWidth = lComputeStringWidth(" ", 1,
-00243                                 pAnchor->tFontRef, pAnchor->usFontSize);
-00244         lToAdd = lScreenWidth -
-00245                         lNetWidth -
-00246                         lDrawUnits2MilliPoints(pDiag->lXleft) +
-00247                         lRightIndentation;
-00248 #if defined(DEBUG)
-00249         if (lToAdd / lSpaceWidth < -1) {
-00250                 DBG_DEC(lSpaceWidth);
-00251                 DBG_DEC(lToAdd);
-00252                 DBG_DEC(lScreenWidth);
-00253                 DBG_DEC(lNetWidth);
-00254                 DBG_DEC(lDrawUnits2MilliPoints(pDiag->lXleft));
-00255                 DBG_DEC(pDiag->lXleft);
-00256                 DBG_DEC(lRightIndentation);
-00257         }
-00258 #endif /* DEBUG */
-00259         lToAdd /= lSpaceWidth;
-00260         DBG_DEC_C(lToAdd < 0, lToAdd);
-00261         if (lToAdd <= 0) {
-00262                 vString2Diagram(pDiag, pAnchor);
-00263                 TRACE_MSG("leaving vJustify2Window #2");
-00264                 return;
-00265         }
-00266 
-00267         /* Justify by adding spaces */
-00268         iHoles = iComputeHoles(pAnchor);
-00269         for (pTmp = pAnchor; pTmp != NULL; pTmp = pTmp->pNext) {
-00270                 fail(pTmp->tNextFree != strlen(pTmp->szStorage));
-00271                 fail(lToAdd < 0);
-00272                 szStorage = xmalloc(pTmp->tNextFree + (size_t)lToAdd + 1);
-00273                 pcNew = szStorage;
-00274                 for (pcOld = pTmp->szStorage; *pcOld != '\0'; pcOld++) {
-00275                         *pcNew++ = *pcOld;
-00276                         if (*pcOld == ' ' &&
-00277                             *(pcOld + 1) != ' ' &&
-00278                             iHoles > 0) {
-00279                                 iFillerLen = (int)(lToAdd / iHoles);
-00280                                 lToAdd -= iFillerLen;
-00281                                 iHoles--;
-00282                                 for (; iFillerLen > 0; iFillerLen--) {
-00283                                         *pcNew++ = ' ';
-00284                                 }
-00285                         }
-00286                 }
-00287                 *pcNew = '\0';
-00288                 pTmp->szStorage = xfree(pTmp->szStorage);
-00289                 pTmp->szStorage = szStorage;
-00290                 pTmp->tStorageSize = pTmp->tNextFree + (size_t)lToAdd + 1;
-00291                 pTmp->lStringWidth +=
-00292                         (pcNew - szStorage - (long)pTmp->tNextFree) *
-00293                         lSpaceWidth;
-00294                 fail(pcNew < szStorage);
-00295                 pTmp->tNextFree = (size_t)(pcNew - szStorage);
-00296                 fail(pTmp->tNextFree != strlen(pTmp->szStorage));
-00297         }
-00298         DBG_DEC_C(lToAdd != 0, lToAdd);
-00299         vString2Diagram(pDiag, pAnchor);
-00300         TRACE_MSG("leaving vJustify2Window #3");
-00301 } /* end of vJustify2Window */
-00302 
-00303 /*
-00304  * vResetStyles - reset the style information variables
-00305  */
-00306 void
-00307 vResetStyles(void)
-00308 {
-00309         TRACE_MSG("vResetStyles");
-00310 
-00311         (void)memset(auiHdrCounter, 0, sizeof(auiHdrCounter));
-00312 } /* end of vResetStyles */
-00313 
-00314 /*
-00315  * tStyle2Window - Add the style characters to the line
-00316  *
-00317  * Returns the length of the resulting string
-00318  */
-00319 size_t
-00320 tStyle2Window(char *szLine, size_t tLineSize, const style_block_type *pStyle,
-00321         const section_block_type *pSection)
-00322 {
-00323         char    *pcTxt;
-00324         size_t  tIndex, tStyleIndex;
-00325         BOOL    bNeedPrevLvl;
-00326         level_type_enum eNumType;
-00327         UCHAR   ucNFC;
-00328 
-00329         TRACE_MSG("tStyle2Window");
-00330 
-00331         fail(szLine == NULL || pStyle == NULL || pSection == NULL);
-00332 
-00333         if (pStyle->usIstd == 0 || pStyle->usIstd > 9) {
-00334                 szLine[0] = '\0';
-00335                 return 0;
-00336         }
-00337 
-00338         /* Set the numbers */
-00339         tStyleIndex = (size_t)pStyle->usIstd - 1;
-00340         for (tIndex = 0; tIndex < 9; tIndex++) {
-00341                 if (tIndex == tStyleIndex) {
-00342                         auiHdrCounter[tIndex]++;
-00343                 } else if (tIndex > tStyleIndex) {
-00344                         auiHdrCounter[tIndex] = 0;
-00345                 } else if (auiHdrCounter[tIndex] == 0) {
-00346                         auiHdrCounter[tIndex] = 1;
-00347                 }
-00348         }
-00349 
-00350         eNumType = eGetNumType(pStyle->ucNumLevel);
-00351         if (eNumType != level_type_outline) {
-00352                 szLine[0] = '\0';
-00353                 return 0;
-00354         }
-00355 
-00356         /* Print the numbers */
-00357         pcTxt = szLine;
-00358         bNeedPrevLvl = (pSection->usNeedPrevLvl & BIT(tStyleIndex)) != 0;
-00359         for (tIndex = 0; tIndex <= tStyleIndex; tIndex++) {
-00360                 if (tIndex == tStyleIndex ||
-00361                     (bNeedPrevLvl && tIndex < tStyleIndex)) {
-00362                         if (pcTxt - szLine >= tLineSize - 25) {
-00363                                 /* Prevent a possible buffer overflow */
-00364                                 DBG_DEC(pcTxt - szLine);
-00365                                 DBG_DEC(tLineSize - 25);
-00366                                 DBG_FIXME();
-00367                                 szLine[0] = '\0';
-00368                                 return 0;
-00369                         }
-00370                         ucNFC = pSection->aucNFC[tIndex];
-00371                         switch(ucNFC) {
-00372                         case LIST_ARABIC_NUM:
-00373                         case LIST_NUMBER_TXT:
-00374                         case LIST_ORDINAL_TXT:
-00375                                 pcTxt += sprintf(pcTxt, "%u",
-00376                                         auiHdrCounter[tIndex]);
-00377                                 break;
-00378                         case LIST_UPPER_ROMAN:
-00379                         case LIST_LOWER_ROMAN:
-00380                                 pcTxt += tNumber2Roman(
-00381                                         auiHdrCounter[tIndex],
-00382                                         ucNFC == LIST_UPPER_ROMAN,
-00383                                         pcTxt);
-00384                                 break;
-00385                         case LIST_UPPER_ALPHA:
-00386                         case LIST_LOWER_ALPHA:
-00387                                 pcTxt += tNumber2Alpha(
-00388                                         auiHdrCounter[tIndex],
-00389                                         ucNFC == LIST_UPPER_ALPHA,
-00390                                         pcTxt);
-00391                                 break;
-00392                         case LIST_OUTLINE_NUM:
-00393                                 pcTxt += sprintf(pcTxt, "%02u",
-00394                                         auiHdrCounter[tIndex]);
-00395                                 break;
-00396                         default:
-00397                                 DBG_DEC(ucNFC);
-00398                                 DBG_FIXME();
-00399                                 pcTxt += sprintf(pcTxt, "%u",
-00400                                         auiHdrCounter[tIndex]);
-00401                                 break;
-00402                         }
-00403                         if (tIndex < tStyleIndex) {
-00404                                 *pcTxt++ = '.';
-00405                         } else if (tIndex == tStyleIndex) {
-00406                                 *pcTxt++ = ' ';
-00407                         }
-00408                 }
-00409         }
-00410         *pcTxt = '\0';
-00411         NO_DBG_MSG_C((int)pStyle->usIstd >= 1 &&
-00412                 (int)pStyle->usIstd <= 9 &&
-00413                 eNumType != level_type_none &&
-00414                 eNumType != level_type_outline, szLine);
-00415         NO_DBG_MSG_C(szLine[0] != '\0', szLine);
-00416         fail(pcTxt < szLine);
-00417         return (size_t)(pcTxt - szLine);
-00418 } /* end of tStyle2Window */
-00419 
-00420 /*
-00421  * vRemoveRowEnd - remove the end of table row indicator
-00422  *
-00423  * Remove the double TABLE_SEPARATOR characters from the end of the string.
-00424  * Special: remove the TABLE_SEPARATOR, 0x0a sequence
-00425  */
-00426 static void
-00427 vRemoveRowEnd(char *szRowTxt)
-00428 {
-00429         int     iLastIndex;
-00430 
-00431         TRACE_MSG("vRemoveRowEnd");
-00432 
-00433         fail(szRowTxt == NULL || szRowTxt[0] == '\0');
-00434 
-00435         iLastIndex = (int)strlen(szRowTxt) - 1;
-00436 
-00437         if (szRowTxt[iLastIndex] == TABLE_SEPARATOR ||
-00438             szRowTxt[iLastIndex] == (char)0x0a) {
-00439                 szRowTxt[iLastIndex] = '\0';
-00440                 iLastIndex--;
-00441         } else {
-00442                 DBG_HEX(szRowTxt[iLastIndex]);
-00443         }
-00444 
-00445         if (iLastIndex >= 0 && szRowTxt[iLastIndex] == (char)0x0a) {
-00446                 szRowTxt[iLastIndex] = '\0';
-00447                 iLastIndex--;
-00448         }
-00449 
-00450         if (iLastIndex >= 0 && szRowTxt[iLastIndex] == TABLE_SEPARATOR) {
-00451                 szRowTxt[iLastIndex] = '\0';
-00452                 return;
-00453         }
-00454 
-00455         DBG_DEC(iLastIndex);
-00456         DBG_HEX(szRowTxt[iLastIndex]);
-00457         DBG_MSG(szRowTxt);
-00458 } /* end of vRemoveRowEnd */
-00459 
-00460 /*
-00461  * tComputeStringLengthMax - max string length in relation to max column width
-00462  *
-00463  * Return the maximum string length
-00464  */
-00465 static size_t
-00466 tComputeStringLengthMax(const char *szString, size_t tColumnWidthMax)
-00467 {
-00468         const char      *pcTmp;
-00469         size_t  tLengthMax, tLenPrev, tLen, tWidth;
-00470 
-00471         TRACE_MSG("tComputeStringLengthMax");
-00472 
-00473         fail(szString == NULL);
-00474         fail(tColumnWidthMax == 0);
-00475 
-00476         pcTmp = strchr(szString, '\n');
-00477         if (pcTmp != NULL) {
-00478                 tLengthMax = (size_t)(pcTmp - szString + 1);
-00479         } else {
-00480                 tLengthMax = strlen(szString);
-00481         }
-00482         if (tLengthMax == 0) {
-00483                 return 0;
-00484         }
-00485 
-00486         tLen = 0;
-00487         tWidth = 0;
-00488         for (;;) {
-00489                 tLenPrev = tLen;
-00490                 tLen += tGetCharacterLength(szString + tLen);
-00491                 DBG_DEC_C(tLen > tLengthMax, tLen);
-00492                 DBG_DEC_C(tLen > tLengthMax, tLengthMax);
-00493                 fail(tLen > tLengthMax);
-00494                 tWidth = tCountColumns(szString, tLen);
-00495                 if (tWidth > tColumnWidthMax) {
-00496                         return tLenPrev;
-00497                 }
-00498                 if (tLen >= tLengthMax) {
-00499                         return tLengthMax;
-00500                 }
-00501         }
-00502 } /* end of tComputeStringLengthMax */
-00503 
-00504 /*
-00505  * tGetBreakingPoint - get the number of bytes that fit the column
-00506  *
-00507  * Returns the number of bytes that fit the column
-00508  */
-00509 static size_t
-00510 tGetBreakingPoint(const char *szString,
-00511         size_t tLen, size_t tWidth, size_t tColumnWidthMax)
-00512 {
-00513         int     iIndex;
-00514 
-00515         TRACE_MSG("tGetBreakingPoint");
-00516 
-00517         fail(szString == NULL);
-00518         fail(tLen > strlen(szString));
-00519         fail(tWidth > tColumnWidthMax);
-00520 
-00521         if (tWidth < tColumnWidthMax ||
-00522             (tWidth == tColumnWidthMax &&
-00523              (szString[tLen] == ' ' ||
-00524               szString[tLen] == '\n' ||
-00525               szString[tLen] == '\0'))) {
-00526                 /* The string already fits, do nothing */
-00527                 return tLen;
-00528         }
-00529         /* Search for a breaking point */
-00530         for (iIndex = (int)tLen - 1; iIndex >= 0; iIndex--) {
-00531                 if (szString[iIndex] == ' ') {
-00532                         return (size_t)iIndex;
-00533                 }
-00534         }
-00535         /* No breaking point found, just fill the column */
-00536         return tLen;
-00537 } /* end of tGetBreakingPoint */
-00538 
-00539 /*
-00540  * tComputeColumnWidthMax - compute the maximum column width
-00541  */
-00542 static size_t
-00543 tComputeColumnWidthMax(short sWidth, long lCharWidth, double dFactor)
-00544 {
-00545         size_t  tColumnWidthMax;
-00546 
-00547         TRACE_MSG("tComputeColumnWidthMax");
-00548 
-00549         fail(sWidth < 0);
-00550         fail(lCharWidth <= 0);
-00551         fail(dFactor <= 0.0);
-00552 
-00553         tColumnWidthMax = (size_t)(
-00554                 (lTwips2MilliPoints(sWidth) * dFactor + lCharWidth / 2.0) /
-00555                  lCharWidth);
-00556         if (tColumnWidthMax == 0) {
-00557                 /* Minimum column width */
-00558                 return 1;
-00559         }
-00560         if (tColumnWidthMax > 1) {
-00561                 /* Make room for the TABLE_SEPARATOR_CHAR */
-00562                 tColumnWidthMax--;
-00563         }
-00564         NO_DBG_DEC(tColumnWidthMax);
-00565         return tColumnWidthMax;
-00566 } /* end of tComputeColumnWidthMax */
-00567 
-00568 /*
-00569  * vTableRow2Window - put a table row into a diagram
-00570  */
-00571 void
-00572 vTableRow2Window(diagram_type *pDiag, output_type *pOutput,
-00573         const row_block_type *pRowInfo,
-00574         conversion_type eConversionType, int iParagraphBreak)
-00575 {
-00576         output_type     tRow;
-00577         char    *aszColTxt[TABLE_COLUMN_MAX];
-00578         char    *szLine, *pcTxt;
-00579         double  dMagnify;
-00580         long    lCharWidthLarge, lCharWidthSmall;
-00581         size_t  tColumnWidthTotal, atColumnWidthMax[TABLE_COLUMN_MAX];
-00582         size_t  tSize, tColumnWidthMax, tWidth, tLen;
-00583         int     iIndex, iNbrOfColumns, iTmp;
-00584         BOOL    bNotReady;
-00585 
-00586         TRACE_MSG("vTableRow2Window");
-00587 
-00588         fail(pDiag == NULL || pOutput == NULL || pRowInfo == NULL);
-00589         fail(pOutput->szStorage == NULL);
-00590         fail(pOutput->pNext != NULL);
-00591         fail(iParagraphBreak < 0);
-00592 
-00593         /* Character sizes */
-00594         lCharWidthLarge = lComputeStringWidth("W", 1,
-00595                                 pOutput->tFontRef, pOutput->usFontSize);
-00596         NO_DBG_DEC(lCharWidthLarge);
-00597         lCharWidthSmall = lComputeStringWidth("i", 1,
-00598                                 pOutput->tFontRef, pOutput->usFontSize);
-00599         NO_DBG_DEC(lCharWidthSmall);
-00600         /* For the time being: use a fixed width font */
-00601         fail(lCharWidthLarge != lCharWidthSmall);
-00602 
-00603         vRemoveRowEnd(pOutput->szStorage);
-00604 
-00605         /* Split the row text into a set of column texts */
-00606         aszColTxt[0] = pOutput->szStorage;
-00607         for (iNbrOfColumns = 1;
-00608              iNbrOfColumns < TABLE_COLUMN_MAX;
-00609              iNbrOfColumns++) {
-00610                 aszColTxt[iNbrOfColumns] =
-00611                                 strchr(aszColTxt[iNbrOfColumns - 1],
-00612                                         TABLE_SEPARATOR);
-00613                 if (aszColTxt[iNbrOfColumns] == NULL) {
-00614                         break;
-00615                 }
-00616                 *aszColTxt[iNbrOfColumns] = '\0';
-00617                 aszColTxt[iNbrOfColumns]++;
-00618                 NO_DBG_DEC(iNbrOfColumns);
-00619                 NO_DBG_MSG(aszColTxt[iNbrOfColumns]);
-00620         }
-00621 
-00622         /* Work around a bug in Word */
-00623         while (iNbrOfColumns > (int)pRowInfo->ucNumberOfColumns &&
-00624                pRowInfo->asColumnWidth[iNbrOfColumns] == 0) {
-00625                 iNbrOfColumns--;
-00626         }
-00627 
-00628         DBG_DEC_C(iNbrOfColumns != (int)pRowInfo->ucNumberOfColumns,
-00629                 iNbrOfColumns);
-00630         DBG_DEC_C(iNbrOfColumns != (int)pRowInfo->ucNumberOfColumns,
-00631                 pRowInfo->ucNumberOfColumns);
-00632         if (iNbrOfColumns != (int)pRowInfo->ucNumberOfColumns) {
-00633                 werr(0, "Skipping an unmatched table row");
-00634                 return;
-00635         }
-00636 
-00637 #if defined(__FULL_TEXT_SEARCH)
-00638         /* No table formatting: use for full-text search (untested) */
-00639         for (iIndex = 0; iIndex < iNbrOfColumns; iIndex++) {
-00640                 fprintf(pDiag->pOutFile, "%s\n" , aszColTxt[iIndex]);
-00641         }
-00642 #else
-00643         if (bAddTableRow(pDiag, aszColTxt, iNbrOfColumns,
-00644                         pRowInfo->asColumnWidth, pRowInfo->ucBorderInfo)) {
-00645                 /* All work has been done */
-00646                 return;
-00647         }
-00648 
-00649         /* Fill the table with maximum column widths */
-00650         if (eConversionType == conversion_text ||
-00651             eConversionType == conversion_fmt_text) {
-00652                 if (iParagraphBreak == 0 ||
-00653                     iParagraphBreak >= MAX_SCREEN_WIDTH) {
-00654                         dMagnify = (double)MAX_SCREEN_WIDTH;
-00655                 } else if (iParagraphBreak <= MIN_SCREEN_WIDTH) {
-00656                         dMagnify = (double)MIN_SCREEN_WIDTH;
-00657                 } else {
-00658                         dMagnify = (double)iParagraphBreak;
-00659                 }
-00660                 dMagnify /= (double)DEFAULT_SCREEN_WIDTH;
-00661                 DBG_FLT_C(dMagnify < 0.99 || dMagnify > 1.01, dMagnify);
-00662         } else {
-00663                 dMagnify = 1.0;
-00664         }
-00665         tColumnWidthTotal = 0;
-00666         for (iIndex = 0; iIndex < iNbrOfColumns; iIndex++) {
-00667                 atColumnWidthMax[iIndex] = tComputeColumnWidthMax(
-00668                                         pRowInfo->asColumnWidth[iIndex],
-00669                                         lCharWidthLarge,
-00670                                         dMagnify);
-00671                 tColumnWidthTotal += atColumnWidthMax[iIndex];
-00672         }
-00673 
-00674         /*
-00675          * Get enough space for the row.
-00676          * Worst case: three bytes per UTF-8 character
-00677          */
-00678         tSize = 3 * (1 + tColumnWidthTotal + (size_t)iNbrOfColumns + 3);
-00679         szLine = xmalloc(tSize);
-00680 
-00681         do {
-00682                 /* Print one line of a table row */
-00683                 bNotReady = FALSE;
-00684                 pcTxt = szLine;
-00685                 *pcTxt++ = TABLE_SEPARATOR_CHAR;
-00686                 for (iIndex = 0; iIndex < iNbrOfColumns; iIndex++) {
-00687                         tColumnWidthMax = atColumnWidthMax[iIndex];
-00688                         if (aszColTxt[iIndex] == NULL) {
-00689                                 /* Add an empty column */
-00690                                 for (iTmp = 0;
-00691                                      iTmp < (int)tColumnWidthMax;
-00692                                      iTmp++) {
-00693                                         *pcTxt++ = (char)FILLER_CHAR;
-00694                                 }
-00695                                 *pcTxt++ = TABLE_SEPARATOR_CHAR;
-00696                                 *pcTxt = '\0';
-00697                                 continue;
-00698                         }
-00699                         /* Compute the length and width of the column text */
-00700                         tLen = tComputeStringLengthMax(
-00701                                         aszColTxt[iIndex], tColumnWidthMax);
-00702                         NO_DBG_DEC(tLen);
-00703                         while (tLen != 0 &&
-00704                                         (aszColTxt[iIndex][tLen - 1] == '\n' ||
-00705                                          aszColTxt[iIndex][tLen - 1] == ' ')) {
-00706                                 aszColTxt[iIndex][tLen - 1] = ' ';
-00707                                 tLen--;
-00708                         }
-00709                         tWidth = tCountColumns(aszColTxt[iIndex], tLen);
-00710                         fail(tWidth > tColumnWidthMax);
-00711                         tLen = tGetBreakingPoint(aszColTxt[iIndex],
-00712                                         tLen, tWidth, tColumnWidthMax);
-00713                         tWidth = tCountColumns(aszColTxt[iIndex], tLen);
-00714                         if (tLen == 0 && *aszColTxt[iIndex] == '\0') {
-00715                                 /* No text at all */
-00716                                 aszColTxt[iIndex] = NULL;
-00717                         } else {
-00718                                 /* Add the text */
-00719                                 pcTxt += sprintf(pcTxt,
-00720                                         "%.*s", (int)tLen, aszColTxt[iIndex]);
-00721                                 if (tLen == 0 && *aszColTxt[iIndex] != ' ') {
-00722                                         tLen = tGetCharacterLength(
-00723                                                         aszColTxt[iIndex]);
-00724                                         DBG_CHR(*aszColTxt[iIndex]);
-00725                                         DBG_FIXME();
-00726                                         fail(tLen == 0);
-00727                                 }
-00728                                 aszColTxt[iIndex] += tLen;
-00729                                 while (*aszColTxt[iIndex] == ' ') {
-00730                                         aszColTxt[iIndex]++;
-00731                                 }
-00732                                 if (*aszColTxt[iIndex] == '\0') {
-00733                                         /* This row is now complete */
-00734                                         aszColTxt[iIndex] = NULL;
-00735                                 } else {
-00736                                         /* This row needs more lines */
-00737                                         bNotReady = TRUE;
-00738                                 }
-00739                         }
-00740                         /* Fill up the rest */
-00741                         for (iTmp = 0;
-00742                              iTmp < (int)tColumnWidthMax - (int)tWidth;
-00743                              iTmp++) {
-00744                                 *pcTxt++ = (char)FILLER_CHAR;
-00745                         }
-00746                         /* End of column */
-00747                         *pcTxt++ = TABLE_SEPARATOR_CHAR;
-00748                         *pcTxt = '\0';
-00749                 }
-00750                 /* Output the table row line */
-00751                 *pcTxt = '\0';
-00752                 tRow = *pOutput;
-00753                 tRow.szStorage = szLine;
-00754                 fail(pcTxt < szLine);
-00755                 tRow.tNextFree = (size_t)(pcTxt - szLine);
-00756                 tRow.lStringWidth = lComputeStringWidth(
-00757                                         tRow.szStorage,
-00758                                         tRow.tNextFree,
-00759                                         tRow.tFontRef,
-00760                                         tRow.usFontSize);
-00761                 vString2Diagram(pDiag, &tRow);
-00762                 TRACE_MSG("after vString2Diagram in vTableRow2Window");
-00763         } while (bNotReady);
-00764         /* Clean up before you leave */
-00765         szLine = xfree(szLine);
-00766         TRACE_MSG("leaving vTableRow2Window");
-00767 #endif /* __FULL_TEXT_SEARCH */
-00768 } /* end of vTableRow2Window */
-
-
Generated by  - -doxygen 1.6.2
- - diff -r 59758314f811 -r d4524d6a4472 Symbian3/Examples/guid-6013a680-57f9-415b-8851-c4fa63356636/output_8c_source.html --- a/Symbian3/Examples/guid-6013a680-57f9-415b-8851-c4fa63356636/output_8c_source.html Fri Jun 11 15:24:34 2010 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,559 +0,0 @@ - - - - -TB9.2 Example Applications: examples/PIPS/antiword/src/output.c Source File - - - - - -

examples/PIPS/antiword/src/output.c

00001 /*
-00002  * output.c
-00003  * Copyright (C) 2002-2004 A.J. van Os; Released under GNU GPL
-00004  *
-00005  * Description:
-00006  * Generic output generating functions
-00007  */
-00008 
-00009 #include "antiword.h"
-00010 
-00011 static conversion_type  eConversionType = conversion_unknown;
-00012 static encoding_type    eEncoding = encoding_neutral;
-00013 
-00014 
-00015 /*
-00016  * vPrologue1 - get options and call a specific initialization
-00017  */
-00018 static void
-00019 vPrologue1(diagram_type *pDiag, const char *szTask, const char *szFilename)
-00020 {
-00021         options_type    tOptions;
-00022 
-00023         fail(pDiag == NULL);
-00024         fail(szTask == NULL || szTask[0] == '\0');
-00025 
-00026         vGetOptions(&tOptions);
-00027         eConversionType = tOptions.eConversionType;
-00028         eEncoding = tOptions.eEncoding;
-00029 
-00030         switch (eConversionType) {
-00031         case conversion_text:
-00032                 vPrologueTXT(pDiag, &tOptions);
-00033                 break;
-00034         case conversion_fmt_text:
-00035                 vPrologueFMT(pDiag, &tOptions);
-00036                 break;
-00037         case conversion_ps:
-00038                 vProloguePS(pDiag, szTask, szFilename, &tOptions);
-00039                 break;
-00040         case conversion_xml:
-00041                 vPrologueXML(pDiag, &tOptions);
-00042                 break;
-00043         case conversion_pdf:
-00044                 vProloguePDF(pDiag, szTask, &tOptions);
-00045                 break;
-00046         default:
-00047                 DBG_DEC(eConversionType);
-00048                 break;
-00049         }
-00050 } /* end of vPrologue1 */
-00051 
-00052 /*
-00053  * vEpilogue - clean up after everything is done
-00054  */
-00055 static void
-00056 vEpilogue(diagram_type *pDiag)
-00057 {
-00058         switch (eConversionType) {
-00059         case conversion_text:
-00060         case conversion_fmt_text:
-00061                 vEpilogueTXT(pDiag->pOutFile);
-00062                 break;
-00063         case conversion_ps:
-00064                 vEpiloguePS(pDiag);
-00065                 break;
-00066         case conversion_xml:
-00067                 vEpilogueXML(pDiag);
-00068                 break;
-00069         case conversion_pdf:
-00070                 vEpiloguePDF(pDiag);
-00071                 break;
-00072         default:
-00073                 DBG_DEC(eConversionType);
-00074                 break;
-00075         }
-00076 } /* end of vEpilogue */
-00077 
-00078 /*
-00079  * vImagePrologue - perform image initialization
-00080  */
-00081 void
-00082 vImagePrologue(diagram_type *pDiag, const imagedata_type *pImg)
-00083 {
-00084         switch (eConversionType) {
-00085         case conversion_text:
-00086         case conversion_fmt_text:
-00087                 break;
-00088         case conversion_ps:
-00089                 vImageProloguePS(pDiag, pImg);
-00090                 break;
-00091         case conversion_xml:
-00092                 break;
-00093         case conversion_pdf:
-00094                 vImageProloguePDF(pDiag, pImg);
-00095                 break;
-00096         default:
-00097                 DBG_DEC(eConversionType);
-00098                 break;
-00099         }
-00100 } /* end of vImagePrologue */
-00101 
-00102 /*
-00103  * vImageEpilogue - clean up an image
-00104  */
-00105 void
-00106 vImageEpilogue(diagram_type *pDiag)
-00107 {
-00108         switch (eConversionType) {
-00109         case conversion_text:
-00110         case conversion_fmt_text:
-00111                 break;
-00112         case conversion_ps:
-00113                 vImageEpiloguePS(pDiag);
-00114                 break;
-00115         case conversion_xml:
-00116                 break;
-00117         case conversion_pdf:
-00118                 vImageEpiloguePDF(pDiag);
-00119                 break;
-00120         default:
-00121                 DBG_DEC(eConversionType);
-00122                 break;
-00123         }
-00124 } /* end of vImageEpilogue */
-00125 
-00126 /*
-00127  * bAddDummyImage - add a dummy image
-00128  *
-00129  * return TRUE when successful, otherwise FALSE
-00130  */
-00131 BOOL
-00132 bAddDummyImage(diagram_type *pDiag, const imagedata_type *pImg)
-00133 {
-00134         switch (eConversionType) {
-00135         case conversion_text:
-00136         case conversion_fmt_text:
-00137                 return FALSE;
-00138         case conversion_ps:
-00139                 return bAddDummyImagePS(pDiag, pImg);
-00140         case conversion_xml:
-00141                 return FALSE;
-00142         case conversion_pdf:
-00143                 return bAddDummyImagePDF(pDiag, pImg);
-00144         default:
-00145                 DBG_DEC(eConversionType);
-00146                 return FALSE;
-00147         }
-00148 } /* end of bAddDummyImage */
-00149 
-00150 /*
-00151  * pCreateDiagram - create and initialize a diagram
-00152  *
-00153  * remark: does not return if the diagram can't be created
-00154  */
-00155 FILE *fp;
-00156 diagram_type *
-00157 pCreateDiagram(const char *szTask, const char *szFilename, FILE *ofp)
-00158 {
-00159         diagram_type    *pDiag;
-00160 
-00161         fail(szTask == NULL || szTask[0] == '\0');
-00162         DBG_MSG("pCreateDiagram");
-00163 
-00164         /* Get the necessary memory */
-00165         pDiag = xmalloc(sizeof(diagram_type));
-00166         /* Initialization */
-00167         #ifndef SYMBIAN
-00168         pDiag->pOutFile = stdout;
-00169         #else
-00170         pDiag->pOutFile = /*stdout*/ofp;
-00171         #endif /*SYMBIAN*/
-00172         vPrologue1(pDiag, szTask, szFilename);
-00173         /* Return success */
-00174         return pDiag;
-00175 } /* end of pCreateDiagram */
-00176 
-00177 /*
-00178  * vDestroyDiagram - remove a diagram by freeing the memory it uses
-00179  */
-00180 void
-00181 vDestroyDiagram(diagram_type *pDiag)
-00182 {
-00183         DBG_MSG("vDestroyDiagram");
-00184 
-00185         fail(pDiag == NULL);
-00186 
-00187         if (pDiag == NULL) {
-00188                 return;
-00189         }
-00190         vEpilogue(pDiag);
-00191         pDiag = xfree(pDiag);
-00192 } /* end of vDestroyDiagram */
-00193 
-00194 /*
-00195  * vPrologue2 - call a specific initialization
-00196  */
-00197 void
-00198 vPrologue2(diagram_type *pDiag, int iWordVersion)
-00199 {
-00200         switch (eConversionType) {
-00201         case conversion_text:
-00202         case conversion_fmt_text:
-00203                 break;
-00204         case conversion_ps:
-00205                 vAddFontsPS(pDiag);
-00206                 break;
-00207         case conversion_xml:
-00208                 vCreateBookIntro(pDiag, iWordVersion);
-00209                 break;
-00210         case conversion_pdf:
-00211                 vCreateInfoDictionary(pDiag, iWordVersion);
-00212                 vAddFontsPDF(pDiag);
-00213                 break;
-00214         default:
-00215                 DBG_DEC(eConversionType);
-00216                 break;
-00217         }
-00218 } /* end of vPrologue2 */
-00219 
-00220 /*
-00221  * vMove2NextLine - move to the next line
-00222  */
-00223 void
-00224 vMove2NextLine(diagram_type *pDiag, drawfile_fontref tFontRef,
-00225         USHORT usFontSize)
-00226 {
-00227         fail(pDiag == NULL);
-00228         fail(pDiag->pOutFile == NULL);
-00229         fail(usFontSize < MIN_FONT_SIZE || usFontSize > MAX_FONT_SIZE);
-00230 
-00231         switch (eConversionType) {
-00232         case conversion_text:
-00233         case conversion_fmt_text:
-00234                 vMove2NextLineTXT(pDiag);
-00235                 break;
-00236         case conversion_ps:
-00237                 vMove2NextLinePS(pDiag, usFontSize);
-00238                 break;
-00239         case conversion_xml:
-00240                 vMove2NextLineXML(pDiag);
-00241                 break;
-00242         case conversion_pdf:
-00243                 vMove2NextLinePDF(pDiag, usFontSize);
-00244                 break;
-00245         default:
-00246                 DBG_DEC(eConversionType);
-00247                 break;
-00248         }
-00249 } /* end of vMove2NextLine */
-00250 
-00251 /*
-00252  * vSubstring2Diagram - put a sub string into a diagram
-00253  */
-00254 void
-00255 vSubstring2Diagram(diagram_type *pDiag,
-00256         char *szString, size_t tStringLength, long lStringWidth,
-00257         UCHAR ucFontColor, USHORT usFontstyle, drawfile_fontref tFontRef,
-00258         USHORT usFontSize, USHORT usMaxFontSize)
-00259 {
-00260         switch (eConversionType) {
-00261         case conversion_text:
-00262                 vSubstringTXT(pDiag, szString, tStringLength, lStringWidth);
-00263                 break;
-00264         case conversion_fmt_text:
-00265                 vSubstringFMT(pDiag, szString, tStringLength, lStringWidth,
-00266                                 usFontstyle);
-00267                 break;
-00268         case conversion_ps:
-00269                 vSubstringPS(pDiag, szString, tStringLength, lStringWidth,
-00270                                 ucFontColor, usFontstyle, tFontRef,
-00271                                 usFontSize, usMaxFontSize);
-00272                 break;
-00273         case conversion_xml:
-00274                 vSubstringXML(pDiag, szString, tStringLength, lStringWidth,
-00275                                 usFontstyle);
-00276                 break;
-00277         case conversion_pdf:
-00278                 vSubstringPDF(pDiag, szString, tStringLength, lStringWidth,
-00279                                 ucFontColor, usFontstyle, tFontRef,
-00280                                 usFontSize, usMaxFontSize);
-00281                 break;
-00282         default:
-00283                 DBG_DEC(eConversionType);
-00284                 break;
-00285         }
-00286         pDiag->lXleft += lStringWidth;
-00287 } /* end of vSubstring2Diagram */
-00288 
-00289 /*
-00290  * Create a start of paragraph (phase 1)
-00291  * Before indentation, list numbering, bullets etc.
-00292  */
-00293 void
-00294 vStartOfParagraph1(diagram_type *pDiag, long lBeforeIndentation)
-00295 {
-00296         fail(pDiag == NULL);
-00297 
-00298         switch (eConversionType) {
-00299         case conversion_text:
-00300         case conversion_fmt_text:
-00301                 vStartOfParagraphTXT(pDiag, lBeforeIndentation);
-00302                 break;
-00303         case conversion_ps:
-00304                 vStartOfParagraphPS(pDiag, lBeforeIndentation);
-00305                 break;
-00306         case conversion_xml:
-00307                 break;
-00308         case conversion_pdf:
-00309                 vStartOfParagraphPDF(pDiag, lBeforeIndentation);
-00310                 break;
-00311         default:
-00312                 DBG_DEC(eConversionType);
-00313                 break;
-00314         }
-00315 } /* end of vStartOfParagraph1 */
-00316 
-00317 /*
-00318  * Create a start of paragraph (phase 2)
-00319  * After indentation, list numbering, bullets etc.
-00320  */
-00321 void
-00322 vStartOfParagraph2(diagram_type *pDiag)
-00323 {
-00324         fail(pDiag == NULL);
-00325 
-00326         switch (eConversionType) {
-00327         case conversion_text:
-00328         case conversion_fmt_text:
-00329                 break;
-00330         case conversion_ps:
-00331                 break;
-00332         case conversion_xml:
-00333                 vStartOfParagraphXML(pDiag, 1);
-00334                 break;
-00335         case conversion_pdf:
-00336                 break;
-00337         default:
-00338                 DBG_DEC(eConversionType);
-00339                 break;
-00340         }
-00341 } /* end of vStartOfParagraph2 */
-00342 
-00343 /*
-00344  * Create an end of paragraph
-00345  */
-00346 void
-00347 vEndOfParagraph(diagram_type *pDiag,
-00348         drawfile_fontref tFontRef, USHORT usFontSize, long lAfterIndentation)
-00349 {
-00350         fail(pDiag == NULL);
-00351         fail(pDiag->pOutFile == NULL);
-00352         fail(usFontSize < MIN_FONT_SIZE || usFontSize > MAX_FONT_SIZE);
-00353         fail(lAfterIndentation < 0);
-00354 
-00355         switch (eConversionType) {
-00356         case conversion_text:
-00357         case conversion_fmt_text:
-00358                 vEndOfParagraphTXT(pDiag, lAfterIndentation);
-00359                 break;
-00360         case conversion_ps:
-00361                 vEndOfParagraphPS(pDiag, usFontSize, lAfterIndentation);
-00362                 break;
-00363         case conversion_xml:
-00364                 vEndOfParagraphXML(pDiag, 1);
-00365                 break;
-00366         case conversion_pdf:
-00367                 vEndOfParagraphPDF(pDiag, usFontSize, lAfterIndentation);
-00368                 break;
-00369         default:
-00370                 DBG_DEC(eConversionType);
-00371                 break;
-00372         }
-00373 } /* end of vEndOfParagraph */
-00374 
-00375 /*
-00376  * Create an end of page
-00377  */
-00378 void
-00379 vEndOfPage(diagram_type *pDiag, long lAfterIndentation, BOOL bNewSection)
-00380 {
-00381         switch (eConversionType) {
-00382         case conversion_text:
-00383         case conversion_fmt_text:
-00384                 vEndOfPageTXT(pDiag, lAfterIndentation);
-00385                 break;
-00386         case conversion_ps:
-00387                 vEndOfPagePS(pDiag, bNewSection);
-00388                 break;
-00389         case conversion_xml:
-00390                 vEndOfPageXML(pDiag);
-00391                 break;
-00392         case conversion_pdf:
-00393                 vEndOfPagePDF(pDiag, bNewSection);
-00394                 break;
-00395         default:
-00396                 DBG_DEC(eConversionType);
-00397                 break;
-00398         }
-00399 } /* end of vEndOfPage */
-00400 
-00401 /*
-00402  * vSetHeaders - set the headers
-00403  */
-00404 void
-00405 vSetHeaders(diagram_type *pDiag, USHORT usIstd)
-00406 {
-00407         switch (eConversionType) {
-00408         case conversion_text:
-00409         case conversion_fmt_text:
-00410                 break;
-00411         case conversion_ps:
-00412                 break;
-00413         case conversion_xml:
-00414                 vSetHeadersXML(pDiag, usIstd);
-00415                 break;
-00416         case conversion_pdf:
-00417                 break;
-00418         default:
-00419                 DBG_DEC(eConversionType);
-00420                 break;
-00421         }
-00422 } /* end of vSetHeaders */
-00423 
-00424 /*
-00425  * Create a start of list
-00426  */
-00427 void
-00428 vStartOfList(diagram_type *pDiag, UCHAR ucNFC, BOOL bIsEndOfTable)
-00429 {
-00430         switch (eConversionType) {
-00431         case conversion_text:
-00432         case conversion_fmt_text:
-00433                 break;
-00434         case conversion_ps:
-00435                 break;
-00436         case conversion_xml:
-00437                 vStartOfListXML(pDiag, ucNFC, bIsEndOfTable);
-00438                 break;
-00439         case conversion_pdf:
-00440                 break;
-00441         default:
-00442                 DBG_DEC(eConversionType);
-00443                 break;
-00444         }
-00445 } /* end of vStartOfList */
-00446 
-00447 /*
-00448  * Create an end of list
-00449  */
-00450 void
-00451 vEndOfList(diagram_type *pDiag)
-00452 {
-00453         switch (eConversionType) {
-00454         case conversion_text:
-00455         case conversion_fmt_text:
-00456                 break;
-00457         case conversion_ps:
-00458                 break;
-00459         case conversion_xml:
-00460                 vEndOfListXML(pDiag);
-00461                 break;
-00462         case conversion_pdf:
-00463                 break;
-00464         default:
-00465                 DBG_DEC(eConversionType);
-00466                 break;
-00467         }
-00468 } /* end of vEndOfList */
-00469 
-00470 /*
-00471  * Create a start of a list item
-00472  */
-00473 void
-00474 vStartOfListItem(diagram_type *pDiag, BOOL bNoMarks)
-00475 {
-00476         switch (eConversionType) {
-00477         case conversion_text:
-00478         case conversion_fmt_text:
-00479                 break;
-00480         case conversion_ps:
-00481                 break;
-00482         case conversion_xml:
-00483                 vStartOfListItemXML(pDiag, bNoMarks);
-00484                 break;
-00485         case conversion_pdf:
-00486                 break;
-00487         default:
-00488                 DBG_DEC(eConversionType);
-00489                 break;
-00490         }
-00491 } /* end of vStartOfListItem */
-00492 
-00493 /*
-00494  * Create an end of a table
-00495  */
-00496 void
-00497 vEndOfTable(diagram_type *pDiag)
-00498 {
-00499         switch (eConversionType) {
-00500         case conversion_text:
-00501         case conversion_fmt_text:
-00502                 break;
-00503         case conversion_ps:
-00504                 break;
-00505         case conversion_xml:
-00506                 vEndOfTableXML(pDiag);
-00507                 break;
-00508         case conversion_pdf:
-00509                 break;
-00510         default:
-00511                 DBG_DEC(eConversionType);
-00512                 break;
-00513         }
-00514 } /* end of vEndOfTable */
-00515 
-00516 /*
-00517  * Add a table row
-00518  *
-00519  * Returns TRUE when conversion type is XML
-00520  */
-00521 BOOL
-00522 bAddTableRow(diagram_type *pDiag, char **aszColTxt,
-00523         int iNbrOfColumns, const short *asColumnWidth, UCHAR ucBorderInfo)
-00524 {
-00525         switch (eConversionType) {
-00526         case conversion_text:
-00527         case conversion_fmt_text:
-00528                 break;
-00529         case conversion_ps:
-00530                 break;
-00531         case conversion_xml:
-00532                 vAddTableRowXML(pDiag, aszColTxt,
-00533                                 iNbrOfColumns, asColumnWidth,
-00534                                 ucBorderInfo);
-00535                 return TRUE;
-00536         case conversion_pdf:
-00537                 break;
-00538         default:
-00539                 DBG_DEC(eConversionType);
-00540                 break;
-00541         }
-00542         return FALSE;
-00543 } /* end of bAddTableRow */
-
-
Generated by  - -doxygen 1.6.2
- - diff -r 59758314f811 -r d4524d6a4472 Symbian3/Examples/guid-6013a680-57f9-415b-8851-c4fa63356636/pdf_8c_source.html --- a/Symbian3/Examples/guid-6013a680-57f9-415b-8851-c4fa63356636/pdf_8c_source.html Fri Jun 11 15:24:34 2010 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1164 +0,0 @@ - - - - -TB9.2 Example Applications: examples/PIPS/antiword/src/pdf.c Source File - - - - - -

examples/PIPS/antiword/src/pdf.c

00001 /*
-00002  * pdf.c
-00003  * Copyright (C) 2003-2005 A.J. van Os; Released under GNU GPL
-00004  *
-00005  * Description:
-00006  * Functions to deal with the Adobe Portable Document Format (pdf)
-00007  *
-00008  */
-00009 
-00010 #include <stdarg.h>
-00011 #include <string.h>
-00012 #include "version.h"
-00013 #include "antiword.h"
-00014 
-00015 
-00016 /* Constants for the file positions */
-00017 #define INITIAL_LOCATION_SIZE   20
-00018 #define INITIAL_PAGEOBJECT_SIZE  5
-00019 #if defined(DEBUG)
-00020 #define EXTENSION_ARRAY_SIZE    10
-00021 #else
-00022 #define EXTENSION_ARRAY_SIZE    30
-00023 #endif /* DEBUG */
-00024 
-00025 /* The character set */
-00026 static encoding_type    eEncoding = encoding_neutral;
-00027 /* Current creator for a PDF header */
-00028 static const char       *szProducer = NULL;
-00029 /* The height and width of a PDF page (in DrawUnits) */
-00030 static long             lPageHeight = LONG_MAX;
-00031 static long             lPageWidth = LONG_MAX;
-00032 /* The height of the footer on the current page (in DrawUnits) */
-00033 static long             lFooterHeight = 0;
-00034 /* Inside a footer (to prevent an infinite loop when the footer is too big) */
-00035 static BOOL             bInFtrSpace = FALSE;
-00036 /* Current font information */
-00037 static drawfile_fontref tFontRefCurr = (drawfile_fontref)-1;
-00038 static USHORT           usFontSizeCurr = 0;
-00039 static int              iFontColorCurr = -1;
-00040 /* Current vertical position information */
-00041 static long             lYtopCurr = -1;
-00042 /* Image counter */
-00043 static int              iImageCount = 0;
-00044 /* Section index */
-00045 static int              iSectionIndex = 0;
-00046 /* Are we on the first page of the section? */
-00047 static BOOL             bFirstInSection = TRUE;
-00048 /* File positions */
-00049 static long             lFilePosition = 0;
-00050 static long             *alLocation = NULL;
-00051 static size_t           tLocations = 0;
-00052 static int              iMaxLocationNumber = 0;
-00053 /* File position at the start of a page */
-00054 static long             lStreamStart = -1;
-00055 /* Page objects */
-00056 static int              *aiPageObject = NULL;
-00057 static int              iPageCount = 0;
-00058 static size_t           tMaxPageObjects = 0;
-00059 /* Current object number */
-00060 /* 1 = root; 2 = info; 3 = pages; 4 = encoding; 5-16 = fonts; 17 = resources */
-00061 static int              iObjectNumberCurr = 17;
-00062 
-00063 static void             vMoveTo(diagram_type *, long);
-00064 
-00065 static const struct {
-00066         const char      *szPDFname;
-00067         const char      *szPSname;
-00068 } atFontname[] = {
-00069         { "Courier",                    FONT_MONOSPACED_PLAIN },
-00070         { "Courier-Bold",               FONT_MONOSPACED_BOLD },
-00071         { "Courier-Oblique",            FONT_MONOSPACED_ITALIC },
-00072         { "Courier-BoldOblique",        FONT_MONOSPACED_BOLDITALIC },
-00073         { "Helvetica",                  FONT_SANS_SERIF_PLAIN },
-00074         { "Helvetica-Bold",             FONT_SANS_SERIF_BOLD },
-00075         { "Helvetica-Oblique",          FONT_SANS_SERIF_ITALIC },
-00076         { "Helvetica-BoldOblique",      FONT_SANS_SERIF_BOLDITALIC },
-00077         { "Times-Roman",                FONT_SERIF_PLAIN },
-00078         { "Times-Bold",                 FONT_SERIF_BOLD },
-00079         { "Times-Italic",               FONT_SERIF_ITALIC },
-00080         { "Times-BoldItalic",           FONT_SERIF_BOLDITALIC },
-00081 };
-00082 
-00083 static const char *iso_8859_1[] = {
-00084 "128 /Euro",
-00085 "140 /ellipsis /trademark /perthousand /bullet",
-00086 "    /quoteleft /quoteright /guilsinglleft /guilsinglright",
-00087 "    /quotedblleft /quotedblright /quotedblbase /endash /emdash",
-00088 "    /minus /OE /oe /dagger /daggerdbl /fi /fl",
-00089 "160 /space /exclamdown /cent /sterling /currency",
-00090 "    /yen /brokenbar /section /dieresis /copyright",
-00091 "    /ordfeminine /guillemotleft /logicalnot /hyphen /registered",
-00092 "    /macron /degree /plusminus /twosuperior /threesuperior",
-00093 "    /acute /mu /paragraph /periodcentered /cedilla",
-00094 "    /onesuperior /ordmasculine /guillemotright /onequarter",
-00095 "    /onehalf /threequarters /questiondown /Agrave /Aacute",
-00096 "    /Acircumflex /Atilde /Adieresis /Aring /AE /Ccedilla",
-00097 "    /Egrave /Eacute /Ecircumflex /Edieresis /Igrave /Iacute",
-00098 "    /Icircumflex /Idieresis /Eth /Ntilde /Ograve /Oacute",
-00099 "    /Ocircumflex /Otilde /Odieresis /multiply /Oslash",
-00100 "    /Ugrave /Uacute /Ucircumflex /Udieresis /Yacute /Thorn",
-00101 "    /germandbls /agrave /aacute /acircumflex /atilde",
-00102 "    /adieresis /aring /ae /ccedilla /egrave /eacute",
-00103 "    /ecircumflex /edieresis /igrave /iacute /icircumflex",
-00104 "    /idieresis /eth /ntilde /ograve /oacute /ocircumflex",
-00105 "    /otilde /odieresis /divide /oslash /ugrave /uacute",
-00106 "    /ucircumflex /udieresis /yacute /thorn /ydieresis",
-00107 };
-00108 
-00109 static const char *iso_8859_2[] = {
-00110 "160 /space /Aogonek /breve /Lslash /currency /Lcaron",
-00111 "    /Sacute /section /dieresis /Scaron /Scommaaccent",
-00112 "    /Tcaron /Zacute /hyphen /Zcaron /Zdotaccent /degree",
-00113 "    /aogonek /ogonek /lslash /acute /lcaron /sacute",
-00114 "    /caron /cedilla /scaron /scommaaccent /tcaron",
-00115 "    /zacute /hungarumlaut /zcaron /zdotaccent /Racute",
-00116 "    /Aacute /Acircumflex /Abreve /Adieresis /Lacute",
-00117 "    /Cacute /Ccedilla /Ccaron /Eacute /Eogonek",
-00118 "    /Edieresis /Ecaron /Iacute /Icircumflex /Dcaron",
-00119 "    /.notdef /Nacute /Ncaron /Oacute /Ocircumflex",
-00120 "    /Ohungarumlaut /Odieresis /multiply /Rcaron /Uring",
-00121 "    /Uacute /Uhungarumlaut /Udieresis /Yacute /Tcommaaccent",
-00122 "    /germandbls /racute /aacute /acircumflex /abreve",
-00123 "    /adieresis /lacute /cacute /ccedilla /ccaron /eacute",
-00124 "    /eogonek /edieresis /ecaron /iacute /icircumflex",
-00125 "    /dcaron /.notdef /nacute /ncaron /oacute /ocircumflex",
-00126 "    /ohungarumlaut /odieresis /divide /rcaron /uring",
-00127 "    /uacute /uhungarumlaut /udieresis /yacute /tcommaaccent",
-00128 "    /dotaccent",
-00129 };
-00130 
-00131 
-00132 /*
-00133  * tGetFontIndex - get the font index
-00134  */
-00135 static size_t
-00136 tGetFontIndex(drawfile_fontref tFontRef)
-00137 {
-00138         const char      *szFontname;
-00139         size_t          tIndex;
-00140 
-00141         /* Get the font name */
-00142         szFontname = szGetFontname(tFontRef);
-00143         fail(szFontname == NULL);
-00144         if (szFontname == NULL) {
-00145                 return 0;
-00146         }
-00147 
-00148         /* Find the name in the table */
-00149         for (tIndex = 0; tIndex < elementsof(atFontname); tIndex++) {
-00150                 if (STRCEQ(atFontname[tIndex].szPSname, szFontname)) {
-00151                         return tIndex;
-00152                 }
-00153         }
-00154         /* Not found */
-00155         DBG_DEC(tFontRef);
-00156         DBG_MSG(szFontname);
-00157         return 0;
-00158 } /* end of tGetFontIndex */
-00159 
-00160 /*
-00161  * vSetLocation - store the location of objects
-00162  */
-00163 static void
-00164 vSetLocation(int iLocationNumber)
-00165 {
-00166         fail(iLocationNumber <= 0);
-00167 
-00168         if ((size_t)iLocationNumber >= tLocations) {
-00169                 /* Extend and set to zero */
-00170                 tLocations += EXTENSION_ARRAY_SIZE;
-00171                 alLocation = xrealloc(alLocation, tLocations * sizeof(long));
-00172                 memset(alLocation + tLocations - EXTENSION_ARRAY_SIZE,
-00173                         0,
-00174                         EXTENSION_ARRAY_SIZE * sizeof(long));
-00175                 DBG_DEC(tLocations);
-00176         }
-00177         if (iLocationNumber > iMaxLocationNumber) {
-00178                 iMaxLocationNumber = iLocationNumber;
-00179         }
-00180 
-00181         DBG_DEC_C((size_t)iLocationNumber >= tLocations, iLocationNumber);
-00182         DBG_DEC_C((size_t)iLocationNumber >= tLocations, tLocations);
-00183         fail((size_t)iLocationNumber >= tLocations);
-00184 
-00185         alLocation[iLocationNumber] = lFilePosition;
-00186 } /* end of vSetLocation */
-00187 
-00188 /*
-00189  * vFillNextPageObject - fil the next page object with the current object number
-00190  */
-00191 static void
-00192 vFillNextPageObject(void)
-00193 {
-00194         iPageCount++;
-00195         if ((size_t)iPageCount >= tMaxPageObjects) {
-00196                 /* Extend the array */
-00197                 tMaxPageObjects += EXTENSION_ARRAY_SIZE;
-00198                 aiPageObject = xrealloc(aiPageObject,
-00199                                         tMaxPageObjects * sizeof(int));
-00200                 DBG_DEC(tMaxPageObjects);
-00201         }
-00202         aiPageObject[iPageCount] = iObjectNumberCurr;
-00203 } /* end of vFillNextPageObject */
-00204 
-00205 /*
-00206  * vFPprintf - printf and update the fileposition
-00207  *
-00208  * called with arguments like fprintf(3)
-00209  */
-00210 static void
-00211 vFPprintf(FILE *pOutFile, const char *szFormat, ...)
-00212 {
-00213         va_list tArg;
-00214 
-00215         va_start(tArg, szFormat);
-00216         lFilePosition += vfprintf(pOutFile, szFormat, tArg);
-00217         va_end(tArg);
-00218 } /* end of vFPprintf */
-00219 
-00220 /*
-00221  * vCreateInfoDictionary - create the document information dictionary
-00222  */
-00223 void
-00224 vCreateInfoDictionary(diagram_type *pDiag, int iWordVersion)
-00225 {
-00226         FILE    *pOutFile;
-00227         const char      *szTitle, *szAuthor, *szSubject, *szCreator;
-00228         const char      *szCreationDate, *szModDate;
-00229 
-00230         fail(pDiag == NULL);
-00231         fail(pDiag->pOutFile == NULL);
-00232         fail(iWordVersion < 0);
-00233         fail(szProducer == NULL || szProducer[0] == '\0');
-00234 
-00235         szTitle = szGetTitle();
-00236         szAuthor = szGetAuthor();
-00237         szSubject = szGetSubject();
-00238         szCreationDate = szGetCreationDate();
-00239         szModDate = szGetModDate();
-00240 
-00241         switch (iWordVersion) {
-00242         case 0: szCreator = "Word for DOS"; break;
-00243         case 1: szCreator = "WinWord 1.x"; break;
-00244         case 2: szCreator = "WinWord 2.0"; break;
-00245         case 4: szCreator = "MacWord 4"; break;
-00246         case 5: szCreator = "MacWord 5"; break;
-00247         case 6: szCreator = "Word 6"; break;
-00248         case 7: szCreator = "Word 7/95"; break;
-00249         case 8: szCreator = "Word 97 or later"; break;
-00250         default: szCreator = NULL; break;
-00251         }
-00252 
-00253         pOutFile = pDiag->pOutFile;
-00254 
-00255         vSetLocation(2);
-00256         vFPprintf(pOutFile, "2 0 obj\n");
-00257         vFPprintf(pOutFile, "<<\n");
-00258         if (szTitle != NULL && szTitle[0] != '\0') {
-00259                 vFPprintf(pOutFile, "/Title (%s)\n", szTitle);
-00260         }
-00261         if (szAuthor != NULL && szAuthor[0] != '\0') {
-00262                 vFPprintf(pOutFile, "/Author (%s)\n", szAuthor);
-00263         }
-00264         if (szSubject != NULL && szSubject[0] != '\0') {
-00265                 vFPprintf(pOutFile, "/Subject (%s)\n", szSubject);
-00266         }
-00267         if (szCreator != NULL && szCreator[0] != '\0') {
-00268                 vFPprintf(pOutFile, "/Creator (%s)\n", szCreator);
-00269         }
-00270         vFPprintf(pOutFile, "/Producer (%s %s)\n", szProducer, VERSIONSTRING);
-00271         if (szCreationDate != NULL && szCreationDate[0] != '\0') {
-00272                 vFPprintf(pOutFile, "/CreationDate (%s)\n", szCreationDate);
-00273         }
-00274         if (szModDate != NULL && szModDate[0] != '\0') {
-00275                 vFPprintf(pOutFile, "/ModDate (%s)\n", szModDate);
-00276         }
-00277         vFPprintf(pOutFile, ">>\n");
-00278         vFPprintf(pOutFile, "endobj\n");
-00279 } /* end of vCreateInfoDictionary */
-00280 
-00281 /*
-00282  * vAddHdrFtr - add a header or footer
-00283  */
-00284 static void
-00285 vAddHdrFtr(diagram_type *pDiag, const hdrftr_block_type *pHdrFtrInfo)
-00286 {
-00287         output_type     *pStart, *pPrev, *pNext;
-00288 
-00289         fail(pDiag == NULL);
-00290         fail(pHdrFtrInfo == NULL);
-00291 
-00292         vStartOfParagraphPDF(pDiag, 0);
-00293         pStart = pHdrFtrInfo->pText;
-00294         while (pStart != NULL) {
-00295                 pNext = pStart;
-00296                 while (pNext != NULL &&
-00297                        (pNext->tNextFree != 1 ||
-00298                         (pNext->szStorage[0] != PAR_END &&
-00299                          pNext->szStorage[0] != HARD_RETURN))) {
-00300                         pNext = pNext->pNext;
-00301                 }
-00302                 if (pNext == NULL) {
-00303                         if (bOutputContainsText(pStart)) {
-00304                                 vAlign2Window(pDiag, pStart,
-00305                                         lChar2MilliPoints(DEFAULT_SCREEN_WIDTH),
-00306                                         ALIGNMENT_LEFT);
-00307                         } else {
-00308                                 vMove2NextLinePDF(pDiag, pStart->usFontSize);
-00309                         }
-00310                         break;
-00311                 }
-00312                 fail(pNext->tNextFree != 1);
-00313                 fail(pNext->szStorage[0] != PAR_END &&
-00314                         pNext->szStorage[0] != HARD_RETURN);
-00315 
-00316                 if (pStart != pNext) {
-00317                         /* There is something to print */
-00318                         pPrev = pNext->pPrev;
-00319                         fail(pPrev->pNext != pNext);
-00320                         /* Cut the chain */
-00321                         pPrev->pNext = NULL;
-00322                         if (bOutputContainsText(pStart)) {
-00323                                 /* Print it */
-00324                                 vAlign2Window(pDiag, pStart,
-00325                                         lChar2MilliPoints(DEFAULT_SCREEN_WIDTH),
-00326                                         ALIGNMENT_LEFT);
-00327                         } else {
-00328                                 /* Just an empty line */
-00329                                 vMove2NextLinePDF(pDiag, pStart->usFontSize);
-00330                         }
-00331                         /* Repair the chain */
-00332                         pPrev->pNext = pNext;
-00333                 }
-00334                 if (pNext->szStorage[0] == PAR_END) {
-00335                         vEndOfParagraphPDF(pDiag, pNext->usFontSize,
-00336                                         (long)pNext->usFontSize * 200);
-00337                 }
-00338                 pStart = pNext->pNext;
-00339         }
-00340 } /* end of vAddHdrFtr */
-00341 
-00342 /*
-00343  * vAddHeader - add a page header
-00344  */
-00345 static void
-00346 vAddHeader(diagram_type *pDiag)
-00347 {
-00348         const hdrftr_block_type *pHdrInfo;
-00349         const hdrftr_block_type *pFtrInfo;
-00350 
-00351         fail(pDiag == NULL);
-00352 
-00353         NO_DBG_MSG("vAddHeader");
-00354 
-00355         pHdrInfo = pGetHdrFtrInfo(iSectionIndex, TRUE,
-00356                                         odd(iPageCount), bFirstInSection);
-00357         pFtrInfo = pGetHdrFtrInfo(iSectionIndex, FALSE,
-00358                                         odd(iPageCount), bFirstInSection);
-00359         /* Set the height of the footer of this page */
-00360         lFooterHeight = pFtrInfo == NULL ? 0 : pFtrInfo->lHeight;
-00361         fail(lFooterHeight < 0);
-00362 
-00363         if (pHdrInfo == NULL ||
-00364             pHdrInfo->pText == NULL ||
-00365             pHdrInfo->lHeight <= 0) {
-00366                 fail(pHdrInfo != NULL && pHdrInfo->lHeight < 0);
-00367                 fail(pHdrInfo != NULL &&
-00368                         pHdrInfo->pText != NULL &&
-00369                         pHdrInfo->lHeight == 0);
-00370                 return;
-00371         }
-00372 
-00373         vAddHdrFtr(pDiag, pHdrInfo);
-00374 
-00375         DBG_DEC_C(pHdrInfo->lHeight !=
-00376                 lPageHeight - PS_TOP_MARGIN - pDiag->lYtop,
-00377                 pHdrInfo->lHeight);
-00378         DBG_DEC_C(pHdrInfo->lHeight !=
-00379                 lPageHeight - PS_TOP_MARGIN - pDiag->lYtop,
-00380                 lPageHeight - PS_TOP_MARGIN - pDiag->lYtop);
-00381 } /* end of vAddHeader */
-00382 
-00383 /*
-00384  * vAddFooter - add a page footer
-00385  */
-00386 static void
-00387 vAddFooter(diagram_type *pDiag)
-00388 {
-00389         const hdrftr_block_type *pFtrInfo;
-00390 
-00391         fail(pDiag == NULL);
-00392 
-00393         NO_DBG_MSG("vAddFooter");
-00394 
-00395         pFtrInfo = pGetHdrFtrInfo(iSectionIndex, FALSE,
-00396                                         odd(iPageCount), bFirstInSection);
-00397         bFirstInSection = FALSE;
-00398         if (pFtrInfo == NULL ||
-00399             pFtrInfo->pText == NULL ||
-00400             pFtrInfo->lHeight <= 0) {
-00401                 fail(pFtrInfo != NULL && pFtrInfo->lHeight < 0);
-00402                 fail(pFtrInfo != NULL &&
-00403                         pFtrInfo->pText != NULL &&
-00404                         pFtrInfo->lHeight == 0);
-00405                 return;
-00406         }
-00407 
-00408         bInFtrSpace = TRUE;
-00409 
-00410         DBG_DEC_C(pFtrInfo->lHeight != lFooterHeight, pFtrInfo->lHeight);
-00411         DBG_DEC_C(pFtrInfo->lHeight != lFooterHeight, lFooterHeight);
-00412         DBG_DEC_C(pDiag->lYtop < lFooterHeight + PS_BOTTOM_MARGIN,
-00413                         pDiag->lYtop);
-00414         DBG_DEC_C(pDiag->lYtop < lFooterHeight + PS_BOTTOM_MARGIN,
-00415                         lFooterHeight + PS_BOTTOM_MARGIN);
-00416 
-00417         if (pDiag->lYtop > lFooterHeight + PS_BOTTOM_MARGIN) {
-00418                 /* Move down to the start of the footer */
-00419                 pDiag->lYtop = lFooterHeight + PS_BOTTOM_MARGIN;
-00420                 vMoveTo(pDiag, 0);
-00421         } else if (pDiag->lYtop < lFooterHeight + PS_BOTTOM_MARGIN / 2) {
-00422                 DBG_FIXME();
-00423                 /*
-00424                  * Move up to the start of the footer, to prevent moving
-00425                  * of the bottom edge of the paper
-00426                  */
-00427                 pDiag->lYtop = lFooterHeight + PS_BOTTOM_MARGIN;
-00428                 vMoveTo(pDiag, 0);
-00429         }
-00430 
-00431         DBG_FLT_C(pDiag->lYtop < lFooterHeight + PS_BOTTOM_MARGIN,
-00432         dDrawUnits2Points(lFooterHeight + PS_BOTTOM_MARGIN - pDiag->lYtop));
-00433 
-00434         vAddHdrFtr(pDiag, pFtrInfo);
-00435         bInFtrSpace = FALSE;
-00436 } /* end of vAddFooter */
-00437 
-00438 /*
-00439  * vEndPageObject - end the current page object
-00440  */
-00441 static void
-00442 vEndPageObject(FILE *pOutFile)
-00443 {
-00444         long    lStreamEnd;
-00445 
-00446         if (lStreamStart < 0) {
-00447                 /* There is no current page object */
-00448                 return;
-00449         }
-00450 
-00451         vFPprintf(pOutFile, "ET\n");
-00452         lStreamEnd = lFilePosition;
-00453         vFPprintf(pOutFile, "endstream\n");
-00454         vFPprintf(pOutFile, "endobj\n");
-00455 
-00456         iObjectNumberCurr++;
-00457         vSetLocation(iObjectNumberCurr);
-00458         vFPprintf(pOutFile, "%d 0 obj\n", iObjectNumberCurr);
-00459         vFPprintf(pOutFile, "%lu\n", lStreamEnd - lStreamStart);
-00460         vFPprintf(pOutFile, "endobj\n");
-00461 } /* end of vEndPageObject */
-00462 
-00463 /*
-00464  * vMove2NextPage - move to the start of the next page
-00465  */
-00466 static void
-00467 vMove2NextPage(diagram_type *pDiag, BOOL bNewSection)
-00468 {
-00469         FILE    *pOutFile;
-00470 
-00471         fail(pDiag == NULL);
-00472         fail(pDiag->pOutFile == NULL);
-00473 
-00474         pOutFile = pDiag->pOutFile;
-00475 
-00476         vAddFooter(pDiag);
-00477         /* End the old page object */
-00478         vEndPageObject(pOutFile);
-00479         if (bNewSection) {
-00480                 iSectionIndex++;
-00481                 bFirstInSection = TRUE;
-00482         }
-00483 
-00484         /* Start the new page object */
-00485         iObjectNumberCurr++;
-00486         vSetLocation(iObjectNumberCurr);
-00487         vFillNextPageObject();
-00488         vFPprintf(pOutFile, "%d 0 obj\n", iObjectNumberCurr);
-00489         vFPprintf(pOutFile, "<<\n");
-00490         vFPprintf(pOutFile, "/Type /Page\n");
-00491         vFPprintf(pOutFile, "/Parent 3 0 R\n");
-00492         vFPprintf(pOutFile, "/Resources 17 0 R\n");
-00493         vFPprintf(pOutFile, "/Contents %d 0 R\n", iObjectNumberCurr + 1);
-00494         vFPprintf(pOutFile, ">>\n");
-00495         vFPprintf(pOutFile, "endobj\n");
-00496 
-00497         /* Start the new text object */
-00498         iObjectNumberCurr++;
-00499         vSetLocation(iObjectNumberCurr);
-00500         vFPprintf(pOutFile, "%d 0 obj\n", iObjectNumberCurr);
-00501         vFPprintf(pOutFile, "<<\n");
-00502         vFPprintf(pOutFile, "/Length %d 0 R\n", iObjectNumberCurr + 1);
-00503         vFPprintf(pOutFile, ">>\n");
-00504         vFPprintf(pOutFile, "stream\n");
-00505         lStreamStart = lFilePosition;
-00506         vFPprintf(pOutFile, "BT\n");
-00507 
-00508         /* Set variables to their start of page values */
-00509         pDiag->lYtop = lPageHeight - PS_TOP_MARGIN;
-00510         tFontRefCurr = (drawfile_fontref)-1;
-00511         usFontSizeCurr = 0;
-00512         iFontColorCurr = -1;
-00513         lYtopCurr = -1;
-00514         vAddHeader(pDiag);
-00515 } /* end of vMove2NextPage */
-00516 
-00517 /*
-00518  * vMoveTo - move to the specified X,Y coordinates
-00519  *
-00520  * Move the current position of the specified diagram to its X,Y coordinates,
-00521  * start on a new page if needed
-00522  */
-00523 static void
-00524 vMoveTo(diagram_type *pDiag, long lLastVerticalMovement)
-00525 {
-00526         fail(pDiag == NULL);
-00527         fail(pDiag->pOutFile == NULL);
-00528 
-00529         if (pDiag->lYtop <= lFooterHeight + PS_BOTTOM_MARGIN && !bInFtrSpace) {
-00530                 vMove2NextPage(pDiag, FALSE);
-00531                 /* Repeat the last vertical movement on the new page */
-00532                 pDiag->lYtop -= lLastVerticalMovement;
-00533         }
-00534 
-00535         fail(pDiag->lYtop < lFooterHeight + PS_BOTTOM_MARGIN && !bInFtrSpace);
-00536         DBG_DEC_C(pDiag->lYtop < PS_BOTTOM_MARGIN, pDiag->lYtop);
-00537         fail(pDiag->lYtop < PS_BOTTOM_MARGIN / 3);
-00538 
-00539         if (pDiag->lYtop != lYtopCurr) {
-00540                 vFPprintf(pDiag->pOutFile, "1 0 0 1 %.2f %.2f Tm\n",
-00541                         dDrawUnits2Points(pDiag->lXleft + PS_LEFT_MARGIN),
-00542                         dDrawUnits2Points(pDiag->lYtop));
-00543                 lYtopCurr = pDiag->lYtop;
-00544         }
-00545 } /* end of vMoveTo */
-00546 
-00547 /*
-00548  * vProloguePDF - set options and perform the PDF initialization
-00549  */
-00550 void
-00551 vProloguePDF(diagram_type *pDiag,
-00552         const char *szTask, const options_type *pOptions)
-00553 {
-00554         FILE    *pOutFile;
-00555 
-00556         fail(pDiag == NULL);
-00557         fail(pDiag->pOutFile == NULL);
-00558         fail(pOptions == NULL);
-00559 
-00560         pOutFile = pDiag->pOutFile;
-00561 
-00562         eEncoding = pOptions->eEncoding;
-00563 
-00564         /* Create an empty location array */
-00565         tLocations = INITIAL_LOCATION_SIZE;
-00566         alLocation = xcalloc(tLocations, sizeof(long));
-00567 
-00568         /* Create an empty pageobject array */
-00569         tMaxPageObjects = INITIAL_PAGEOBJECT_SIZE;
-00570         aiPageObject = xcalloc(tMaxPageObjects, sizeof(int));
-00571 
-00572         if (pOptions->iPageHeight == INT_MAX) {
-00573                 lPageHeight = LONG_MAX;
-00574         } else {
-00575                 lPageHeight = lPoints2DrawUnits(pOptions->iPageHeight);
-00576         }
-00577         DBG_DEC(lPageHeight);
-00578         if (pOptions->iPageWidth == INT_MAX) {
-00579                 lPageWidth = LONG_MAX;
-00580         } else {
-00581                 lPageWidth = lPoints2DrawUnits(pOptions->iPageWidth);
-00582         }
-00583         DBG_DEC(lPageWidth);
-00584         lFooterHeight = 0;
-00585         bInFtrSpace = FALSE;
-00586 
-00587         tFontRefCurr = (drawfile_fontref)-1;
-00588         usFontSizeCurr = 0;
-00589         iFontColorCurr = -1;
-00590         lYtopCurr = -1;
-00591         iPageCount = 0;
-00592         iImageCount = 0;
-00593         iSectionIndex = 0;
-00594         bFirstInSection = TRUE;
-00595         lFilePosition = 0;
-00596         iMaxLocationNumber = 0;
-00597         lStreamStart = -1;
-00598         iObjectNumberCurr = 17;
-00599         pDiag->lXleft = 0;
-00600         pDiag->lYtop = 0;
-00601 
-00602         szProducer = szTask;
-00603 
-00604         vFPprintf(pOutFile, "%%PDF-1.3\n");
-00605         vFPprintf(pOutFile, "%%%c%c%c%c\n", 0xe2, 0xe3, 0xcf, 0xd3);
-00606 
-00607         /* Root catalog */
-00608         vSetLocation(1);
-00609         vFPprintf(pOutFile, "1 0 obj\n");
-00610         vFPprintf(pOutFile, "<<\n");
-00611         vFPprintf(pOutFile, "/Type /Catalog\n");
-00612         vFPprintf(pOutFile, "/Pages 3 0 R\n");
-00613         vFPprintf(pOutFile, ">>\n");
-00614         vFPprintf(pOutFile, "endobj\n");
-00615 } /* end of vProloguePDF */
-00616 
-00617 /*
-00618  * vEpiloguePDF - clean up after everything is done
-00619  */
-00620 void
-00621 vEpiloguePDF(diagram_type *pDiag)
-00622 {
-00623         FILE    *pOutFile;
-00624         long    lXref;
-00625         int     iIndex;
-00626 
-00627         fail(pDiag == NULL);
-00628         fail(pDiag->pOutFile == NULL);
-00629 
-00630         pOutFile = pDiag->pOutFile;
-00631 
-00632         vAddFooter(pDiag);
-00633         /* End the old page object */
-00634         vEndPageObject(pOutFile);
-00635 
-00636         vSetLocation(3);
-00637         vFPprintf(pOutFile, "3 0 obj\n");
-00638         vFPprintf(pOutFile, "<<\n");
-00639         vFPprintf(pOutFile, "/Type /Pages\n");
-00640         vFPprintf(pOutFile, "/Count %d\n", iPageCount);
-00641         vFPprintf(pOutFile, "/MediaBox [ 0 0 %.0f %.0f ]\n",
-00642                         dDrawUnits2Points(lPageWidth),
-00643                         dDrawUnits2Points(lPageHeight));
-00644         vFPprintf(pOutFile, "/Kids [ ");
-00645         for (iIndex = 1; iIndex <= iPageCount; iIndex++) {
-00646                 vFPprintf(pOutFile, "\t%d 0 R\n", aiPageObject[iIndex]);
-00647         }
-00648         vFPprintf(pOutFile, "]\n");
-00649         vFPprintf(pOutFile, ">>\n");
-00650         vFPprintf(pOutFile, "endobj\n");
-00651 
-00652         lXref = lFilePosition;
-00653 
-00654         vFPprintf(pOutFile, "xref\n");
-00655         vFPprintf(pOutFile, "0 %d\n", iMaxLocationNumber + 1);
-00656         vFPprintf(pOutFile, "0000000000 65535 f \n");
-00657         for (iIndex = 1; iIndex <= iMaxLocationNumber; iIndex++) {
-00658                 vFPprintf(pOutFile, "%.10ld 00000 n \n", alLocation[iIndex]);
-00659         }
-00660 
-00661         vFPprintf(pOutFile, "trailer\n");
-00662         vFPprintf(pOutFile, "<<\n");
-00663         vFPprintf(pOutFile, "/Size %d\n", iMaxLocationNumber + 1);
-00664         vFPprintf(pOutFile, "/Root 1 0 R\n");
-00665         vFPprintf(pOutFile, "/Info 2 0 R\n");
-00666         vFPprintf(pOutFile, ">>\n");
-00667 
-00668         vFPprintf(pOutFile, "startxref\n");
-00669         vFPprintf(pOutFile, "%ld\n", lXref);
-00670         vFPprintf(pOutFile, "%%%%EOF\n");
-00671 
-00672         szProducer = NULL;
-00673         aiPageObject = xfree(aiPageObject);
-00674         alLocation = xfree(alLocation);
-00675 } /* end of vEpiloguePDF */
-00676 
-00677 /*
-00678  * vPrintPalette - print a pdf color space (palette)
-00679  */
-00680 static void
-00681 vPrintPalette(FILE *pOutFile, const imagedata_type *pImg)
-00682 {
-00683         int     iIndex;
-00684 
-00685         fail(pOutFile == NULL);
-00686         fail(pImg == NULL);
-00687         fail(pImg->iColorsUsed < 2);
-00688         fail(pImg->iColorsUsed > 256);
-00689 
-00690         vFPprintf(pOutFile, "\t/ColorSpace [ /Indexed\n");
-00691         vFPprintf(pOutFile, "\t/Device%s %d\n",
-00692                 pImg->bColorImage ? "RGB" : "Gray", pImg->iColorsUsed - 1);
-00693         vFPprintf(pOutFile, "<");
-00694         for (iIndex = 0; iIndex < pImg->iColorsUsed; iIndex++) {
-00695                 vFPprintf(pOutFile, "%02x",
-00696                                 (unsigned int)pImg->aucPalette[iIndex][0]);
-00697                 if (pImg->bColorImage) {
-00698                         vFPprintf(pOutFile, "%02x%02x",
-00699                                 (unsigned int)pImg->aucPalette[iIndex][1],
-00700                                 (unsigned int)pImg->aucPalette[iIndex][2]);
-00701                 }
-00702                 if (iIndex % 8 == 7) {
-00703                         vFPprintf(pOutFile, "\n");
-00704                 } else {
-00705                         vFPprintf(pOutFile, " ");
-00706                 }
-00707         }
-00708         vFPprintf(pOutFile, "> ]\n");
-00709 } /* end of vPrintPalette */
-00710 
-00711 /*
-00712  * vImageProloguePDF - perform the image initialization
-00713  */
-00714 void
-00715 vImageProloguePDF(diagram_type *pDiag, const imagedata_type *pImg)
-00716 {
-00717         FILE    *pOutFile;
-00718 
-00719         fail(pDiag == NULL);
-00720         fail(pDiag->pOutFile == NULL);
-00721         fail(pImg == NULL);
-00722 
-00723         if (pImg->iVerSizeScaled <= 0 || pImg->iHorSizeScaled <= 0) {
-00724                 return;
-00725         }
-00726 
-00727         iImageCount++;
-00728 
-00729         DBG_DEC_C(pDiag->lXleft != 0, pDiag->lXleft);
-00730 
-00731         pDiag->lYtop -= lPoints2DrawUnits(pImg->iVerSizeScaled);
-00732         vMoveTo(pDiag, lPoints2DrawUnits(pImg->iVerSizeScaled));
-00733 
-00734         pOutFile = pDiag->pOutFile;
-00735 
-00736         vFPprintf(pOutFile, "ET\n");
-00737         vFPprintf(pOutFile, "q %% Image %03d\n", iImageCount);
-00738         if (pImg->eImageType == imagetype_is_dib) {
-00739                 /* Scanning from left to right and bottom to top */
-00740                 vFPprintf(pOutFile, "%d 0 0 %d %.2f %.2f cm\n",
-00741                         pImg->iHorSizeScaled, -pImg->iVerSizeScaled,
-00742                         dDrawUnits2Points(pDiag->lXleft + PS_LEFT_MARGIN),
-00743                         dDrawUnits2Points(pDiag->lYtop) + pImg->iVerSizeScaled);
-00744         } else {
-00745                 /* Scanning from left to right and top to bottom */
-00746                 vFPprintf(pOutFile, "%d 0 0 %d %.2f %.2f cm\n",
-00747                         pImg->iHorSizeScaled, pImg->iVerSizeScaled,
-00748                         dDrawUnits2Points(pDiag->lXleft + PS_LEFT_MARGIN),
-00749                         dDrawUnits2Points(pDiag->lYtop));
-00750         }
-00751         vFPprintf(pOutFile, "BI\n");
-00752         vFPprintf(pOutFile, "\t/Width %d\n", pImg->iWidth);
-00753         vFPprintf(pOutFile, "\t/Height %d\n", pImg->iHeight);
-00754         switch (pImg->eImageType) {
-00755         case imagetype_is_jpeg:
-00756                 switch (pImg->iComponents) {
-00757                 case 1:
-00758                         vFPprintf(pOutFile, "\t/ColorSpace /DeviceGray\n");
-00759                         break;
-00760                 case 3:
-00761                         vFPprintf(pOutFile, "\t/ColorSpace /DeviceRGB\n");
-00762                         break;
-00763                 case 4:
-00764                         vFPprintf(pOutFile, "\t/ColorSpace /DeviceCMYK\n");
-00765                         if (pImg->bAdobe) {
-00766                                 /*
-00767                                  * Adobe-conforming CMYK file
-00768                                  * applying workaround for color inversion
-00769                                  */
-00770                                 vFPprintf(pOutFile,
-00771                                         "\t/Decode [1 0 1 0 1 0 1 0]\n");
-00772                         }
-00773                         break;
-00774                 default:
-00775                         DBG_DEC(pImg->iComponents);
-00776                         break;
-00777                 }
-00778                 vFPprintf(pOutFile, "\t/BitsPerComponent 8\n");
-00779                 vFPprintf(pOutFile,
-00780                         "\t/Filter [ /ASCII85Decode /DCTDecode ]\n");
-00781                 break;
-00782         case imagetype_is_png:
-00783                 if (pImg->iComponents == 3 || pImg->iComponents == 4) {
-00784                         vFPprintf(pOutFile, "\t/ColorSpace /DeviceRGB\n");
-00785                         vFPprintf(pOutFile, "\t/BitsPerComponent 8\n");
-00786                 } else if (pImg->iColorsUsed > 0) {
-00787                         vPrintPalette(pOutFile, pImg);
-00788                         fail(pImg->uiBitsPerComponent > 8);
-00789                         vFPprintf(pOutFile, "\t/BitsPerComponent %u\n",
-00790                                         pImg->uiBitsPerComponent);
-00791                 } else {
-00792                         vFPprintf(pOutFile, "\t/ColorSpace /DeviceGray\n");
-00793                         vFPprintf(pOutFile, "\t/BitsPerComponent 8\n");
-00794                 }
-00795                 vFPprintf(pOutFile,
-00796                         "\t/Filter [ /ASCII85Decode /FlateDecode ]\n");
-00797                 vFPprintf(pOutFile, "\t/DecodeParms [ null <<\n");
-00798                 vFPprintf(pOutFile, "\t\t/Predictor 10\n");
-00799                 vFPprintf(pOutFile, "\t\t/Colors %d\n", pImg->iComponents);
-00800                 vFPprintf(pOutFile, "\t\t/BitsPerComponent %u\n",
-00801                                                 pImg->uiBitsPerComponent);
-00802                 vFPprintf(pOutFile, "\t\t/Columns %d\n", pImg->iWidth);
-00803                 vFPprintf(pOutFile, "\t\t>> ]\n");
-00804                 break;
-00805         case imagetype_is_dib:
-00806                 if (pImg->uiBitsPerComponent <= 8) {
-00807                         vPrintPalette(pOutFile, pImg);
-00808                 } else {
-00809                         vFPprintf(pOutFile, "\t/ColorSpace /DeviceRGB\n");
-00810                 }
-00811                 vFPprintf(pOutFile, "\t/BitsPerComponent 8\n");
-00812                 vFPprintf(pOutFile, "\t/Filter /ASCII85Decode\n");
-00813                 break;
-00814         default:
-00815                 vFPprintf(pOutFile, "\t/ColorSpace /Device%s\n",
-00816                         pImg->bColorImage ? "RGB" : "Gray");
-00817                 vFPprintf(pOutFile, "\t/BitsPerComponent 8\n");
-00818                 vFPprintf(pOutFile, "\t/Filter /ASCIIHexDecode\n");
-00819                 break;
-00820         }
-00821         vFPprintf(pOutFile, "ID\n");
-00822 } /* end of vImageProloguePDF */
-00823 
-00824 /*
-00825  * vImageEpiloguePDF - clean up after the image
-00826  */
-00827 void
-00828 vImageEpiloguePDF(diagram_type *pDiag)
-00829 {
-00830         FILE    *pOutFile;
-00831 
-00832         fail(pDiag == NULL);
-00833         fail(pDiag->pOutFile == NULL);
-00834 
-00835         pOutFile = pDiag->pOutFile;
-00836 
-00837         /* Correction for the image bytes */
-00838         lFilePosition = ftell(pOutFile);
-00839 
-00840         vFPprintf(pOutFile, "EI\n");
-00841         vFPprintf(pOutFile, "Q\n");
-00842         vFPprintf(pOutFile, "BT\n");
-00843 
-00844         pDiag->lXleft = 0;
-00845 } /* end of vImageEpiloguePDF */
-00846 
-00847 /*
-00848  * bAddDummyImagePDF - add a dummy image
-00849  *
-00850  * return TRUE when successful, otherwise FALSE
-00851  */
-00852 BOOL
-00853 bAddDummyImagePDF(diagram_type *pDiag, const imagedata_type *pImg)
-00854 {
-00855         FILE    *pOutFile;
-00856 
-00857         fail(pDiag == NULL);
-00858         fail(pDiag->pOutFile == NULL);
-00859         fail(pImg == NULL);
-00860 
-00861         if (pImg->iVerSizeScaled <= 0 || pImg->iHorSizeScaled <= 0) {
-00862                 return FALSE;
-00863         }
-00864 
-00865         iImageCount++;
-00866 
-00867         DBG_DEC_C(pDiag->lXleft != 0, pDiag->lXleft);
-00868 
-00869         pDiag->lYtop -= lPoints2DrawUnits(pImg->iVerSizeScaled);
-00870         vMoveTo(pDiag, lPoints2DrawUnits(pImg->iVerSizeScaled));
-00871 
-00872         pOutFile = pDiag->pOutFile;
-00873 
-00874         vFPprintf(pOutFile, "ET\n");
-00875         vFPprintf(pOutFile, "q %% Image %03d\n", iImageCount);
-00876         vFPprintf(pOutFile, "\t1.0 w\n");
-00877         vFPprintf(pOutFile, "\t0.3 G\n");
-00878         vFPprintf(pOutFile, "\t%.2f %.2f %d %d re\n",
-00879                         dDrawUnits2Points(pDiag->lXleft + PS_LEFT_MARGIN),
-00880                         dDrawUnits2Points(pDiag->lYtop),
-00881                         pImg->iHorSizeScaled,
-00882                         pImg->iVerSizeScaled);
-00883         vFPprintf(pOutFile, "\tS\n");
-00884         vFPprintf(pOutFile, "Q\n");
-00885         vFPprintf(pOutFile, "BT\n");
-00886 
-00887         pDiag->lXleft = 0;
-00888 
-00889         return TRUE;
-00890 } /* end of bAddDummyImagePDF */
-00891 
-00892 /*
-00893  * vAddFontsPDF - add the font information
-00894  */
-00895 void
-00896 vAddFontsPDF(diagram_type *pDiag)
-00897 {
-00898         FILE    *pOutFile;
-00899         size_t  tIndex;
-00900 
-00901         fail(pDiag == NULL);
-00902         fail(pDiag->pOutFile == NULL);
-00903 
-00904         pOutFile = pDiag->pOutFile;
-00905 
-00906         /* The font encoding */
-00907         vSetLocation(4);
-00908         vFPprintf(pOutFile, "4 0 obj\n");
-00909         vFPprintf(pOutFile, "<<\n");
-00910         vFPprintf(pOutFile, "/Type /Encoding\n");
-00911         vFPprintf(pOutFile, "/BaseEncoding /StandardEncoding\n");
-00912         vFPprintf(pOutFile, "/Differences [\n");
-00913         switch (eEncoding) {
-00914         case encoding_latin_1:
-00915                 for (tIndex = 0;
-00916                      tIndex < elementsof(iso_8859_1);
-00917                      tIndex++) {
-00918                         vFPprintf(pOutFile, "%s\n", iso_8859_1[tIndex]);
-00919                 }
-00920                 break;
-00921         case encoding_latin_2:
-00922                 for (tIndex = 0;
-00923                      tIndex < elementsof(iso_8859_2);
-00924                      tIndex++) {
-00925                         vFPprintf(pOutFile, "%s\n", iso_8859_2[tIndex]);
-00926                 }
-00927                 break;
-00928         case encoding_cyrillic:
-00929                 werr(1,
-00930                 "The combination PDF and Cyrillic is not supported");
-00931                 break;
-00932         case encoding_utf_8:
-00933                 werr(1,
-00934                 "The combination PDF and UTF-8 is not supported");
-00935                 break;
-00936         default:
-00937                 DBG_DEC(eEncoding);
-00938                 break;
-00939         }
-00940         vFPprintf(pOutFile, "]\n");
-00941         vFPprintf(pOutFile, ">>\n");
-00942         vFPprintf(pOutFile, "endobj\n");
-00943 
-00944         /* Twelve of the standard type 1 fonts */
-00945         for (tIndex = 0; tIndex < 12; tIndex++) {
-00946                 vSetLocation(5 + tIndex);
-00947                 vFPprintf(pOutFile, "%u 0 obj\n", 5 + tIndex);
-00948                 vFPprintf(pOutFile, "<<\n");
-00949                 vFPprintf(pOutFile, "/Type /Font\n");
-00950                 vFPprintf(pOutFile, "/Subtype /Type1\n");
-00951                 vFPprintf(pOutFile, "/Name /F%u\n", 1 + tIndex);
-00952                 vFPprintf(pOutFile, "/BaseFont /%s\n",
-00953                                                 atFontname[tIndex].szPDFname);
-00954                 vFPprintf(pOutFile, "/Encoding 4 0 R\n");
-00955                 vFPprintf(pOutFile, ">>\n");
-00956                 vFPprintf(pOutFile, "endobj\n");
-00957         }
-00958 
-00959         /* The Resources */
-00960         vSetLocation(17);
-00961         vFPprintf(pOutFile, "17 0 obj\n");
-00962         vFPprintf(pOutFile, "<<\n");
-00963         vFPprintf(pOutFile, "/ProcSet [ /PDF /Text ]\n");
-00964         vFPprintf(pOutFile, "/Font <<\n");
-00965         for (tIndex = 0; tIndex < 12; tIndex++) {
-00966                 vFPprintf(pOutFile, "\t/F%u %u 0 R\n", 1 + tIndex, 5 + tIndex);
-00967         }
-00968         vFPprintf(pOutFile, "\t>>\n");
-00969         vFPprintf(pOutFile, ">>\n");
-00970         vFPprintf(pOutFile, "endobj\n");
-00971         vAddHeader(pDiag);
-00972 } /* end of vAddFontsPDF */
-00973 
-00974 /*
-00975  * vPrintPDF - print a PDF string
-00976  */
-00977 static void
-00978 vPrintPDF(FILE *pFile, const char *szString, size_t tStringLength,
-00979         USHORT usFontstyle)
-00980 {
-00981         const UCHAR     *aucBytes;
-00982         double  dMove;
-00983         size_t  tCount;
-00984 
-00985         fail(szString == NULL);
-00986 
-00987         if (szString == NULL || szString[0] == '\0' || tStringLength == 0) {
-00988                 return;
-00989         }
-00990         DBG_DEC_C(usFontSizeCurr < MIN_FONT_SIZE, usFontSizeCurr);
-00991 
-00992         dMove = 0.0;
-00993 
-00994         /* Up for superscript */
-00995         if (bIsSuperscript(usFontstyle) && usFontSizeCurr != 0) {
-00996                 dMove = (double)((usFontSizeCurr + 1) / 2) * 0.375;
-00997                 vFPprintf(pFile, "%.2f Ts\n", dMove);
-00998         }
-00999 
-01000         /* Down for subscript */
-01001         if (bIsSubscript(usFontstyle) && usFontSizeCurr != 0) {
-01002                 dMove = (double)usFontSizeCurr * 0.125;
-01003                 vFPprintf(pFile, "%.2f Ts\n", -dMove);
-01004         }
-01005 
-01006         /* Generate and print the PDF output */
-01007         aucBytes = (UCHAR *)szString;
-01008         vFPprintf(pFile, "(");
-01009         for (tCount = 0; tCount < tStringLength ; tCount++) {
-01010                 switch (aucBytes[tCount]) {
-01011                 case '(':
-01012                 case ')':
-01013                 case '\\':
-01014                         vFPprintf(pFile, "\\%c", szString[tCount]);
-01015                         break;
-01016                 default:
-01017                         if (aucBytes[tCount] < 0x20 ||
-01018                             aucBytes[tCount] == 0x7f ||
-01019                             (aucBytes[tCount] >= 0x81 &&
-01020                              aucBytes[tCount] < 0x8c)) {
-01021                                 DBG_HEX(aucBytes[tCount]);
-01022                                 vFPprintf(pFile, " ");
-01023                         } else if (aucBytes[tCount] >= 0x80) {
-01024                                 vFPprintf(pFile, "\\%03o",
-01025                                                 (UINT)aucBytes[tCount]);
-01026                         } else {
-01027                                 vFPprintf(pFile, "%c", szString[tCount]);
-01028                         }
-01029                         break;
-01030                 }
-01031         }
-01032         vFPprintf(pFile, ") Tj\n");
-01033 
-01034         /* Undo the superscript/subscript move */
-01035         if (dMove != 0.0) {
-01036                 vFPprintf(pFile, "0 Ts\n");
-01037         }
-01038 } /* end of vPrintPDF */
-01039 
-01040 /*
-01041  * vSetColor - move to the specified color
-01042  */
-01043 static void
-01044 vSetColor(FILE *pFile, UCHAR ucFontColor)
-01045 {
-01046         ULONG   ulTmp, ulRed, ulGreen, ulBlue;
-01047 
-01048         ulTmp = ulColor2Color(ucFontColor);
-01049         ulRed   = (ulTmp & 0x0000ff00) >> 8;
-01050         ulGreen = (ulTmp & 0x00ff0000) >> 16;
-01051         ulBlue  = (ulTmp & 0xff000000) >> 24;
-01052         vFPprintf(pFile, "%.3f %.3f %.3f rg\n",
-01053                         ulRed / 255.0, ulGreen / 255.0, ulBlue / 255.0);
-01054 } /* end of vSetColor */
-01055 
-01056 /*
-01057  * vMove2NextLinePDF - move to the next line
-01058  */
-01059 void
-01060 vMove2NextLinePDF(diagram_type *pDiag, USHORT usFontSize)
-01061 {
-01062         fail(pDiag == NULL);
-01063         fail(usFontSize < MIN_FONT_SIZE || usFontSize > MAX_FONT_SIZE);
-01064 
-01065         pDiag->lYtop -= lComputeLeading(usFontSize);
-01066 } /* end of vMove2NextLinePDF */
-01067 
-01068 /*
-01069  * vSubstringPDF - print a sub string
-01070  */
-01071 void
-01072 vSubstringPDF(diagram_type *pDiag,
-01073         char *szString, size_t tStringLength, long lStringWidth,
-01074         UCHAR ucFontColor, USHORT usFontstyle, drawfile_fontref tFontRef,
-01075         USHORT usFontSize, USHORT usMaxFontSize)
-01076 {
-01077         size_t  tFontIndex;
-01078 
-01079         fail(pDiag == NULL || szString == NULL);
-01080         fail(pDiag->pOutFile == NULL);
-01081         fail(pDiag->lXleft < 0);
-01082         fail(tStringLength != strlen(szString));
-01083         fail(usFontSize < MIN_FONT_SIZE || usFontSize > MAX_FONT_SIZE);
-01084         fail(usMaxFontSize < MIN_FONT_SIZE || usMaxFontSize > MAX_FONT_SIZE);
-01085         fail(usFontSize > usMaxFontSize);
-01086 
-01087         if (szString[0] == '\0' || tStringLength == 0) {
-01088                 return;
-01089         }
-01090 
-01091         vMoveTo(pDiag, lComputeLeading(usMaxFontSize));
-01092         if (tFontRef != tFontRefCurr || usFontSize != usFontSizeCurr) {
-01093                 tFontIndex = tGetFontIndex(tFontRef);
-01094                 vFPprintf(pDiag->pOutFile, "/F%u %.1f Tf\n",
-01095                          1 + tFontIndex, (double)usFontSize / 2.0);
-01096                 tFontRefCurr = tFontRef;
-01097                 usFontSizeCurr = usFontSize;
-01098         }
-01099         if ((int)ucFontColor != iFontColorCurr) {
-01100                 vSetColor(pDiag->pOutFile, ucFontColor);
-01101                 iFontColorCurr = (int)ucFontColor;
-01102         }
-01103         vPrintPDF(pDiag->pOutFile, szString, tStringLength, usFontstyle);
-01104         pDiag->lXleft += lStringWidth;
-01105 } /* end of vSubstringPDF */
-01106 
-01107 /*
-01108  * Create an start of paragraph by moving the y-top mark
-01109  */
-01110 void
-01111 vStartOfParagraphPDF(diagram_type *pDiag, long lBeforeIndentation)
-01112 {
-01113         fail(pDiag == NULL);
-01114         fail(lBeforeIndentation < 0);
-01115 
-01116         pDiag->lXleft = 0;
-01117         pDiag->lYtop -= lMilliPoints2DrawUnits(lBeforeIndentation);
-01118 } /* end of vStartOfParagraphPDF */
-01119 
-01120 /*
-01121  * Create an end of paragraph by moving the y-top mark
-01122  */
-01123 void
-01124 vEndOfParagraphPDF(diagram_type *pDiag,
-01125         USHORT usFontSize, long lAfterIndentation)
-01126 {
-01127         fail(pDiag == NULL);
-01128         fail(pDiag->pOutFile == NULL);
-01129         fail(usFontSize < MIN_FONT_SIZE || usFontSize > MAX_FONT_SIZE);
-01130         fail(lAfterIndentation < 0);
-01131 
-01132         if (pDiag->lXleft > 0) {
-01133                 /* To the start of the line */
-01134                 vMove2NextLinePDF(pDiag, usFontSize);
-01135         }
-01136 
-01137         pDiag->lXleft = 0;
-01138         pDiag->lYtop -= lMilliPoints2DrawUnits(lAfterIndentation);
-01139 } /* end of vEndOfParagraphPDF */
-01140 
-01141 /*
-01142  * Create an end of page
-01143  */
-01144 void
-01145 vEndOfPagePDF(diagram_type *pDiag, BOOL bNewSection)
-01146 {
-01147         vMove2NextPage(pDiag, bNewSection);
-01148 } /* end of vEndOfPagePDF */
-
-
Generated by  - -doxygen 1.6.2
- - diff -r 59758314f811 -r d4524d6a4472 Symbian3/Examples/guid-6013a680-57f9-415b-8851-c4fa63356636/pictlist_8c_source.html --- a/Symbian3/Examples/guid-6013a680-57f9-415b-8851-c4fa63356636/pictlist_8c_source.html Fri Jun 11 15:24:34 2010 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,125 +0,0 @@ - - - - -TB9.2 Example Applications: examples/PIPS/antiword/src/pictlist.c Source File - - - - - -

examples/PIPS/antiword/src/pictlist.c

00001 /*
-00002  * pictlist.c
-00003  * Copyright (C) 2000-2004 A.J. van Os; Released under GNU GPL
-00004  *
-00005  * Description:
-00006  * Build, read and destroy a list of Word picture information
-00007  */
-00008 
-00009 #include <stdlib.h>
-00010 #include "antiword.h"
-00011 
-00012 
-00013 /*
-00014  * Private structure to hide the way the information
-00015  * is stored from the rest of the program
-00016  */
-00017 typedef struct picture_mem_tag {
-00018         picture_block_type      tInfo;
-00019         struct picture_mem_tag *pNext;
-00020 } picture_mem_type;
-00021 
-00022 /* Variables needed to write the Picture Information List */
-00023 static picture_mem_type *pAnchor = NULL;
-00024 static picture_mem_type *pPictureLast = NULL;
-00025 
-00026 
-00027 /*
-00028  * vDestroyPictInfoList - destroy the Picture Information List
-00029  */
-00030 void
-00031 vDestroyPictInfoList(void)
-00032 {
-00033         picture_mem_type        *pCurr, *pNext;
-00034 
-00035         DBG_MSG("vDestroyPictInfoList");
-00036 
-00037         /* Free the Picture Information List */
-00038         pCurr = pAnchor;
-00039         while (pCurr != NULL) {
-00040                 pNext = pCurr->pNext;
-00041                 pCurr = xfree(pCurr);
-00042                 pCurr = pNext;
-00043         }
-00044         pAnchor = NULL;
-00045         /* Reset all control variables */
-00046         pPictureLast = NULL;
-00047 } /* end of vDestroyPictInfoList */
-00048 
-00049 /*
-00050  * vAdd2PictInfoList - Add an element to the Picture Information List
-00051  */
-00052 void
-00053 vAdd2PictInfoList(const picture_block_type *pPictureBlock)
-00054 {
-00055         picture_mem_type        *pListMember;
-00056 
-00057         fail(pPictureBlock == NULL);
-00058 
-00059         NO_DBG_MSG("bAdd2PictInfoList");
-00060 
-00061         if (pPictureBlock->ulFileOffset == FC_INVALID) {
-00062                 /*
-00063                  * This offset is really past the end of the file,
-00064                  * so don't waste any memory by storing it.
-00065                  */
-00066                 return;
-00067         }
-00068         if (pPictureBlock->ulFileOffsetPicture == FC_INVALID) {
-00069                 /*
-00070                  * The place where this picture is supposed to be stored
-00071                  * doesn't exist.
-00072                  */
-00073                 return;
-00074         }
-00075 
-00076         NO_DBG_HEX(pPictureBlock->ulFileOffset);
-00077         NO_DBG_HEX(pPictureBlock->ulFileOffsetPicture);
-00078         NO_DBG_HEX(pPictureBlock->ulPictureOffset);
-00079 
-00080         /* Create list member */
-00081         pListMember = xmalloc(sizeof(picture_mem_type));
-00082         /* Fill the list member */
-00083         pListMember->tInfo = *pPictureBlock;
-00084         pListMember->pNext = NULL;
-00085         /* Add the new member to the list */
-00086         if (pAnchor == NULL) {
-00087                 pAnchor = pListMember;
-00088         } else {
-00089                 fail(pPictureLast == NULL);
-00090                 pPictureLast->pNext = pListMember;
-00091         }
-00092         pPictureLast = pListMember;
-00093 } /* end of vAdd2PictInfoList */
-00094 
-00095 /*
-00096  * Get the info with the given file offset from the Picture Information List
-00097  */
-00098 ULONG
-00099 ulGetPictInfoListItem(ULONG ulFileOffset)
-00100 {
-00101         picture_mem_type        *pCurr;
-00102 
-00103         for (pCurr = pAnchor; pCurr != NULL; pCurr = pCurr->pNext) {
-00104                 if (pCurr->tInfo.ulFileOffset == ulFileOffset) {
-00105                         return pCurr->tInfo.ulFileOffsetPicture;
-00106                 }
-00107         }
-00108         return FC_INVALID;
-00109 } /* end of ulGetPictInfoListItem */
-
-
Generated by  - -doxygen 1.6.2
- - diff -r 59758314f811 -r d4524d6a4472 Symbian3/Examples/guid-6013a680-57f9-415b-8851-c4fa63356636/png2eps_8c_source.html --- a/Symbian3/Examples/guid-6013a680-57f9-415b-8851-c4fa63356636/png2eps_8c_source.html Fri Jun 11 15:24:34 2010 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,207 +0,0 @@ - - - - -TB9.2 Example Applications: examples/PIPS/antiword/src/png2eps.c Source File - - - - - -

examples/PIPS/antiword/src/png2eps.c

00001 /*
-00002  * png2eps.c
-00003  * Copyright (C) 2000-2002 A.J. van Os; Released under GPL
-00004  *
-00005  * Description:
-00006  * Functions to translate png images into eps
-00007  *
-00008  */
-00009 
-00010 #include <stdio.h>
-00011 #include <ctype.h>
-00012 #include "antiword.h"
-00013 
-00014 #if defined(DEBUG)
-00015 static int      iPicCounter = 0;
-00016 #endif /* DEBUG */
-00017 
-00018 
-00019 /*
-00020  * tSkipToData - skip until a IDAT chunk is found
-00021  *
-00022  * returns the length of the pixeldata or -1 in case of error
-00023  */
-00024 static size_t
-00025 tSkipToData(FILE *pFile, size_t tMaxBytes, size_t *ptSkipped)
-00026 {
-00027         ULONG   ulName, ulTmp;
-00028         size_t  tDataLength, tToSkip;
-00029         int     iCounter;
-00030 
-00031         fail(pFile == NULL);
-00032         fail(ptSkipped == NULL);
-00033 
-00034         /* Examine chunks */
-00035         while (*ptSkipped + 8 < tMaxBytes) {
-00036                 tDataLength = (size_t)ulNextLongBE(pFile);
-00037                 DBG_DEC(tDataLength);
-00038                 *ptSkipped += 4;
-00039 
-00040                 ulName = 0x00;
-00041                 for (iCounter = 0; iCounter < 4; iCounter++) {
-00042                         ulTmp = (ULONG)iNextByte(pFile);
-00043                         if (!isalpha((int)ulTmp)) {
-00044                                 DBG_HEX(ulTmp);
-00045                                 return (size_t)-1;
-00046                         }
-00047                         ulName <<= 8;
-00048                         ulName |= ulTmp;
-00049                 }
-00050                 DBG_HEX(ulName);
-00051                 *ptSkipped += 4;
-00052 
-00053                 if (ulName == PNG_CN_IEND) {
-00054                         break;
-00055                 }
-00056                 if (ulName == PNG_CN_IDAT) {
-00057                         return tDataLength;
-00058                 }
-00059 
-00060                 tToSkip = tDataLength + 4;
-00061                 if (tToSkip >= tMaxBytes - *ptSkipped) {
-00062                         DBG_DEC(tToSkip);
-00063                         DBG_DEC(tMaxBytes - *ptSkipped);
-00064                         return (size_t)-1;
-00065                 }
-00066                 (void)tSkipBytes(pFile, tToSkip);
-00067                 *ptSkipped += tToSkip;
-00068         }
-00069 
-00070         return (size_t)-1;
-00071 } /* end of iSkipToData */
-00072 
-00073 /*
-00074  * iFindFirstPixelData - find the first pixeldata if a PNG image
-00075  *
-00076  * returns the length of the pixeldata or -1 in case of error
-00077  */
-00078 static size_t
-00079 tFindFirstPixelData(FILE *pFile, size_t tMaxBytes, size_t *ptSkipped)
-00080 {
-00081         fail(pFile == NULL);
-00082         fail(tMaxBytes == 0);
-00083         fail(ptSkipped == NULL);
-00084 
-00085         if (tMaxBytes < 8) {
-00086                 DBG_DEC(tMaxBytes);
-00087                 return (size_t)-1;
-00088         }
-00089 
-00090         /* Skip over the PNG signature */
-00091         (void)tSkipBytes(pFile, 8);
-00092         *ptSkipped = 8;
-00093 
-00094         return tSkipToData(pFile, tMaxBytes, ptSkipped);
-00095 } /* end of iFindFirstPixelData */
-00096 
-00097 /*
-00098  * tFindNextPixelData - find the next pixeldata if a PNG image
-00099  *
-00100  * returns the length of the pixeldata or -1 in case of error
-00101  */
-00102 static size_t
-00103 tFindNextPixelData(FILE *pFile, size_t tMaxBytes, size_t *ptSkipped)
-00104 {
-00105         fail(pFile == NULL);
-00106         fail(tMaxBytes == 0);
-00107         fail(ptSkipped == NULL);
-00108 
-00109         if (tMaxBytes < 4) {
-00110                 DBG_DEC(tMaxBytes);
-00111                 return (size_t)-1;
-00112         }
-00113 
-00114         /* Skip over the crc */
-00115         (void)tSkipBytes(pFile, 4);
-00116         *ptSkipped = 4;
-00117 
-00118         return tSkipToData(pFile, tMaxBytes, ptSkipped);
-00119 } /* end of tFindNextPixelData */
-00120 
-00121 #if defined(DEBUG)
-00122 /*
-00123  * vCopy2File
-00124  */
-00125 static void
-00126 vCopy2File(FILE *pFile, ULONG ulFileOffset, size_t tPictureLen)
-00127 {
-00128         FILE    *pOutFile;
-00129         size_t  tIndex;
-00130         int     iTmp;
-00131         char    szFilename[30];
-00132 
-00133         if (!bSetDataOffset(pFile, ulFileOffset)) {
-00134                 return;
-00135         }
-00136 
-00137         sprintf(szFilename, "/tmp/pic/pic%04d.png", ++iPicCounter);
-00138         pOutFile = fopen(szFilename, "wb");
-00139         if (pOutFile == NULL) {
-00140                 return;
-00141         }
-00142         for (tIndex = 0; tIndex < tPictureLen; tIndex++) {
-00143                 iTmp = iNextByte(pFile);
-00144                 if (putc(iTmp, pOutFile) == EOF) {
-00145                         break;
-00146                 }
-00147         }
-00148         (void)fclose(pOutFile);
-00149 } /* end of vCopy2File */
-00150 #endif /* DEBUG */
-00151 
-00152 /*
-00153  * bTranslatePNG - translate a PNG image
-00154  *
-00155  * This function translates an image from png to eps
-00156  *
-00157  * return TRUE when sucessful, otherwise FALSE
-00158  */
-00159 BOOL
-00160 bTranslatePNG(diagram_type *pDiag, FILE *pFile,
-00161         ULONG ulFileOffset, size_t tPictureLen, const imagedata_type *pImg)
-00162 {
-00163         size_t  tMaxBytes, tDataLength, tSkipped;
-00164 
-00165 #if defined(DEBUG)
-00166         vCopy2File(pFile, ulFileOffset, tPictureLen);
-00167 #endif /* DEBUG */
-00168 
-00169         /* Seek to start position of PNG data */
-00170         if (!bSetDataOffset(pFile, ulFileOffset)) {
-00171                 return FALSE;
-00172         }
-00173 
-00174         tMaxBytes = tPictureLen;
-00175         tDataLength = tFindFirstPixelData(pFile, tMaxBytes, &tSkipped);
-00176         if (tDataLength == (size_t)-1) {
-00177                 return FALSE;
-00178         }
-00179 
-00180         vImagePrologue(pDiag, pImg);
-00181         do {
-00182                 tMaxBytes -= tSkipped;
-00183                 vASCII85EncodeArray(pFile, pDiag->pOutFile, tDataLength);
-00184                 tMaxBytes -= tDataLength;
-00185                 tDataLength = tFindNextPixelData(pFile, tMaxBytes, &tSkipped);
-00186         } while (tDataLength != (size_t)-1);
-00187         vASCII85EncodeByte(pDiag->pOutFile, EOF);
-00188         vImageEpilogue(pDiag);
-00189 
-00190         return TRUE;
-00191 } /* end of bTranslatePNG */
-
-
Generated by  - -doxygen 1.6.2
- - diff -r 59758314f811 -r d4524d6a4472 Symbian3/Examples/guid-6013a680-57f9-415b-8851-c4fa63356636/png2sprt_8c_source.html --- a/Symbian3/Examples/guid-6013a680-57f9-415b-8851-c4fa63356636/png2sprt_8c_source.html Fri Jun 11 15:24:34 2010 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,44 +0,0 @@ - - - - -TB9.2 Example Applications: examples/PIPS/antiword/src/png2sprt.c Source File - - - - - -

examples/PIPS/antiword/src/png2sprt.c

00001 /*
-00002  * png2sprt.c
-00003  * Copyright (C) 2000 A.J. van Os; Released under GPL
-00004  *
-00005  * Description:
-00006  * Functions to translate png pictures into sprites
-00007  */
-00008 
-00009 #include <stdio.h>
-00010 #include "antiword.h"
-00011 
-00012 
-00013 /*
-00014  * bTranslatePNG - translate a PNG picture
-00015  *
-00016  * This function translates a picture from png to sprite
-00017  *
-00018  * return TRUE when sucessful, otherwise FALSE
-00019  */
-00020 #ifndef SYMBIAN
-00021 BOOL
-00022 bTranslatePNG(diagram_type *pDiag, FILE *pFile,
-00023         ULONG ulFileOffset, size_t tPictureLen, const imagedata_type *pImg)
-00024 {
-00025         /* PNG is not supported yet */
-00026         return bAddDummyImage(pDiag, pImg);
-00027 } /* end of bTranslatePNG */
-00028 #endif
-
-
Generated by  - -doxygen 1.6.2
- - diff -r 59758314f811 -r d4524d6a4472 Symbian3/Examples/guid-6013a680-57f9-415b-8851-c4fa63356636/postscript_8c_source.html --- a/Symbian3/Examples/guid-6013a680-57f9-415b-8851-c4fa63356636/postscript_8c_source.html Fri Jun 11 15:24:34 2010 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1187 +0,0 @@ - - - - -TB9.2 Example Applications: examples/PIPS/antiword/src/postscript.c Source File - - - - - -

examples/PIPS/antiword/src/postscript.c

00001 /*
-00002  * postscript.c
-00003  * Copyright (C) 1999-2005 A.J. van Os; Released under GNU GPL
-00004  *
-00005  * Description:
-00006  * Functions to deal with the PostScript format
-00007  *
-00008  *================================================================
-00009  * The function vImagePrologue is based on:
-00010  * jpeg2ps - convert JPEG compressed images to PostScript Level 2
-00011  * Copyright (C) 1994-99 Thomas Merz (tm@muc.de)
-00012  *================================================================
-00013  * The credit should go to him, but all the bugs are mine.
-00014  */
-00015 
-00016 #include <stdlib.h>
-00017 #include <errno.h>
-00018 #include <time.h>
-00019 #include <string.h>
-00020 #include "version.h"
-00021 #include "antiword.h"
-00022 
-00023 /* The character set */
-00024 static encoding_type    eEncoding = encoding_neutral;
-00025 /* The image level */
-00026 static image_level_enum eImageLevel = level_default;
-00027 /* The output must use landscape orientation */
-00028 static BOOL             bUseLandscape = FALSE;
-00029 /* The height and width of a PostScript page (in DrawUnits) */
-00030 static long             lPageHeight = LONG_MAX;
-00031 static long             lPageWidth = LONG_MAX;
-00032 /* The height of the footer on the current page (in DrawUnits) */
-00033 static long             lFooterHeight = 0;
-00034 /* Inside a footer (to prevent an infinite loop when the footer is too big) */
-00035 static BOOL             bInFtrSpace = FALSE;
-00036 /* Current time for a PS header */
-00037 static const char       *szCreationDate = NULL;
-00038 /* Current creator for a PS header */
-00039 static const char       *szCreator = NULL;
-00040 /* Current font information */
-00041 static drawfile_fontref tFontRefCurr = (drawfile_fontref)-1;
-00042 static USHORT           usFontSizeCurr = 0;
-00043 static int              iFontColorCurr = -1;
-00044 /* Current vertical position information */
-00045 static long             lYtopCurr = -1;
-00046 /* PostScript page counter */
-00047 static int              iPageCount = 0;
-00048 /* Image counter */
-00049 static int              iImageCount = 0;
-00050 /* Section index */
-00051 static int              iSectionIndex = 0;
-00052 /* Are we on the first page of the section? */
-00053 static BOOL             bFirstInSection = TRUE;
-00054 
-00055 static void             vMoveTo(diagram_type *, long);
-00056 
-00057 static const char *iso_8859_1_data[] = {
-00058 "/newcodes      % ISO-8859-1 character encodings",
-00059 "[",
-00060 "140/ellipsis 141/trademark 142/perthousand 143/bullet",
-00061 "144/quoteleft 145/quoteright 146/guilsinglleft 147/guilsinglright",
-00062 "148/quotedblleft 149/quotedblright 150/quotedblbase 151/endash 152/emdash",
-00063 "153/minus 154/OE 155/oe 156/dagger 157/daggerdbl 158/fi 159/fl",
-00064 "160/space 161/exclamdown 162/cent 163/sterling 164/currency",
-00065 "165/yen 166/brokenbar 167/section 168/dieresis 169/copyright",
-00066 "170/ordfeminine 171/guillemotleft 172/logicalnot 173/hyphen 174/registered",
-00067 "175/macron 176/degree 177/plusminus 178/twosuperior 179/threesuperior",
-00068 "180/acute 181/mu 182/paragraph 183/periodcentered 184/cedilla",
-00069 "185/onesuperior 186/ordmasculine 187/guillemotright 188/onequarter",
-00070 "189/onehalf 190/threequarters 191/questiondown 192/Agrave 193/Aacute",
-00071 "194/Acircumflex 195/Atilde 196/Adieresis 197/Aring 198/AE 199/Ccedilla",
-00072 "200/Egrave 201/Eacute 202/Ecircumflex 203/Edieresis 204/Igrave 205/Iacute",
-00073 "206/Icircumflex 207/Idieresis 208/Eth 209/Ntilde 210/Ograve 211/Oacute",
-00074 "212/Ocircumflex 213/Otilde 214/Odieresis 215/multiply 216/Oslash",
-00075 "217/Ugrave 218/Uacute 219/Ucircumflex 220/Udieresis 221/Yacute 222/Thorn",
-00076 "223/germandbls 224/agrave 225/aacute 226/acircumflex 227/atilde",
-00077 "228/adieresis 229/aring 230/ae 231/ccedilla 232/egrave 233/eacute",
-00078 "234/ecircumflex 235/edieresis 236/igrave 237/iacute 238/icircumflex",
-00079 "239/idieresis 240/eth 241/ntilde 242/ograve 243/oacute 244/ocircumflex",
-00080 "245/otilde 246/odieresis 247/divide 248/oslash 249/ugrave 250/uacute",
-00081 "251/ucircumflex 252/udieresis 253/yacute 254/thorn 255/ydieresis",
-00082 "] bind def",
-00083 "",
-00084 "/reencdict 12 dict def",
-00085 "",
-00086 };
-00087 
-00088 static const char *iso_8859_2_data[] = {
-00089 "/newcodes      % ISO-8859-2 character encodings",
-00090 "[",
-00091 "160/space 161/Aogonek 162/breve 163/Lslash 164/currency 165/Lcaron",
-00092 "166/Sacute 167/section 168/dieresis 169/Scaron 170/Scommaaccent",
-00093 "171/Tcaron 172/Zacute 173/hyphen 174/Zcaron 175/Zdotaccent 176/degree",
-00094 "177/aogonek 178/ogonek 179/lslash 180/acute 181/lcaron 182/sacute",
-00095 "183/caron 184/cedilla 185/scaron 186/scommaaccent 187/tcaron",
-00096 "188/zacute 189/hungarumlaut 190/zcaron 191/zdotaccent 192/Racute",
-00097 "193/Aacute 194/Acircumflex 195/Abreve 196/Adieresis 197/Lacute",
-00098 "198/Cacute 199/Ccedilla 200/Ccaron 201/Eacute 202/Eogonek",
-00099 "203/Edieresis 204/Ecaron 205/Iacute 206/Icircumflex 207/Dcaron",
-00100 "208/Dcroat 209/Nacute 210/Ncaron 211/Oacute 212/Ocircumflex",
-00101 "213/Ohungarumlaut 214/Odieresis 215/multiply 216/Rcaron 217/Uring",
-00102 "218/Uacute 219/Uhungarumlaut 220/Udieresis 221/Yacute 222/Tcommaaccent",
-00103 "223/germandbls 224/racute 225/aacute 226/acircumflex 227/abreve",
-00104 "228/adieresis 229/lacute 230/cacute 231/ccedilla 232/ccaron 233/eacute",
-00105 "234/eogonek 235/edieresis 236/ecaron 237/iacute 238/icircumflex",
-00106 "239/dcaron 240/dcroat 241/nacute 242/ncaron 243/oacute 244/ocircumflex",
-00107 "245/ohungarumlaut 246/odieresis 247/divide 248/rcaron 249/uring",
-00108 "250/uacute 251/uhungarumlaut 252/udieresis 253/yacute 254/tcommaaccent",
-00109 "255/dotaccent",
-00110 "] bind def",
-00111 "",
-00112 "/reencdict 12 dict def",
-00113 "",
-00114 };
-00115 
-00116 static const char *iso_8859_5_data[] = {
-00117 "/newcodes      % ISO-8859-5 character encodings",
-00118 "[",
-00119 "160/space     161/afii10023 162/afii10051 163/afii10052 164/afii10053",
-00120 "165/afii10054 166/afii10055 167/afii10056 168/afii10057 169/afii10058",
-00121 "170/afii10059 171/afii10060 172/afii10061 173/hyphen    174/afii10062",
-00122 "175/afii10145 176/afii10017 177/afii10018 178/afii10019 179/afii10020",
-00123 "180/afii10021 181/afii10022 182/afii10024 183/afii10025 184/afii10026",
-00124 "185/afii10027 186/afii10028 187/afii10029 188/afii10030 189/afii10031",
-00125 "190/afii10032 191/afii10033 192/afii10034 193/afii10035 194/afii10036",
-00126 "195/afii10037 196/afii10038 197/afii10039 198/afii10040 199/afii10041",
-00127 "200/afii10042 201/afii10043 202/afii10044 203/afii10045 204/afii10046",
-00128 "205/afii10047 206/afii10048 207/afii10049 208/afii10065 209/afii10066",
-00129 "210/afii10067 211/afii10068 212/afii10069 213/afii10070 214/afii10072",
-00130 "215/afii10073 216/afii10074 217/afii10075 218/afii10076 219/afii10077",
-00131 "220/afii10078 221/afii10079 222/afii10080 223/afii10081 224/afii10082",
-00132 "225/afii10083 226/afii10084 227/afii10085 228/afii10086 229/afii10087",
-00133 "230/afii10088 231/afii10089 232/afii10090 233/afii10091 234/afii10092",
-00134 "235/afii10093 236/afii10094 237/afii10095 238/afii10096 239/afii10097",
-00135 "240/afii61352 241/afii10071 242/afii10099 243/afii10100 244/afii10101",
-00136 "245/afii10102 246/afii10103 247/afii10104 248/afii10105 249/afii10106",
-00137 "250/afii10107 251/afii10108 252/afii10109 253/section   254/afii10110",
-00138 "255/afii10193",
-00139 "] bind def",
-00140 "",
-00141 "/reencdict 12 dict def",
-00142 "",
-00143 };
-00144 
-00145 static const char *iso_8859_x_func[] = {
-00146 "% change fonts using ISO-8859-x characters",
-00147 "/ChgFnt                % size psname natname => font",
-00148 "{",
-00149 "       dup FontDirectory exch known            % is re-encoded name known?",
-00150 "       { exch pop }                            % yes, get rid of long name",
-00151 "       { dup 3 1 roll ReEncode } ifelse        % no, re-encode it",
-00152 "       findfont exch scalefont setfont",
-00153 "} bind def",
-00154 "",
-00155 "/ReEncode",
-00156 "{",
-00157 "reencdict begin",
-00158 "       /newname exch def",
-00159 "       /basename exch def",
-00160 "       /basedict basename findfont def",
-00161 "       /newfont basedict maxlength dict def",
-00162 "       basedict",
-00163 "       { exch dup /FID ne",
-00164 "               { dup /Encoding eq",
-00165 "                       { exch dup length array copy newfont 3 1 roll put }",
-00166 "                       { exch newfont 3 1 roll put } ifelse",
-00167 "               }",
-00168 "               { pop pop } ifelse",
-00169 "       } forall",
-00170 "       newfont /FontName newname put",
-00171 "       newcodes aload pop newcodes length 2 idiv",
-00172 "       { newfont /Encoding get 3 1 roll put } repeat",
-00173 "       newname newfont definefont pop",
-00174 "end",
-00175 "} bind def",
-00176 "",
-00177 };
-00178 
-00179 static const char *misc_func[] = {
-00180 "% draw a line and show the string",
-00181 "/LineShow      % string linewidth movement",
-00182 "{",
-00183 "       gsave",
-00184 "               0 exch rmoveto",
-00185 "               setlinewidth",
-00186 "               dup",
-00187 "               stringwidth pop",
-00188 "               0 rlineto stroke",
-00189 "       grestore",
-00190 "       show",
-00191 "} bind def",
-00192 "",
-00193 "% begin an EPS file (level 2 and up)",
-00194 "/BeginEPSF",
-00195 "{",
-00196 "       /b4_Inc_state save def",
-00197 "       /dict_count countdictstack def",
-00198 "       /op_count count 1 sub def",
-00199 "       userdict begin",
-00200 "               /showpage { } def",
-00201 "               0 setgray 0 setlinecap",
-00202 "               1 setlinewidth 0 setlinejoin",
-00203 "               10 setmiterlimit [ ] 0 setdash newpath",
-00204 "               false setstrokeadjust false setoverprint",
-00205 "} bind def",
-00206 "",
-00207 "% end an EPS file",
-00208 "/EndEPSF {",
-00209 "       count op_count sub { pop } repeat",
-00210 "       countdictstack dict_count sub { end } repeat",
-00211 "       b4_Inc_state restore",
-00212 "} bind def",
-00213 "",
-00214 };
-00215 
-00216 
-00217 /*
-00218  * vAddPageSetup - add the page setup
-00219  */
-00220 static void
-00221 vAddPageSetup(FILE *pOutFile)
-00222 {
-00223         if (bUseLandscape) {
-00224                 fprintf(pOutFile, "%%%%BeginPageSetup\n");
-00225                 fprintf(pOutFile, "90 rotate\n");
-00226                 fprintf(pOutFile, "0.00 %.2f translate\n",
-00227                                         -dDrawUnits2Points(lPageHeight));
-00228                 fprintf(pOutFile, "%%%%EndPageSetup\n");
-00229         }
-00230 } /* end of vAddPageSetup */
-00231 
-00232 /*
-00233  * vAddHdrFtr - add a header or footer
-00234  */
-00235 static void
-00236 vAddHdrFtr(diagram_type *pDiag, const hdrftr_block_type *pHdrFtrInfo)
-00237 {
-00238         output_type     *pStart, *pPrev, *pNext;
-00239 
-00240         fail(pDiag == NULL);
-00241         fail(pHdrFtrInfo == NULL);
-00242 
-00243         vStartOfParagraphPS(pDiag, 0);
-00244         pStart = pHdrFtrInfo->pText;
-00245         while (pStart != NULL) {
-00246                 pNext = pStart;
-00247                 while (pNext != NULL &&
-00248                        (pNext->tNextFree != 1 ||
-00249                         (pNext->szStorage[0] != PAR_END &&
-00250                          pNext->szStorage[0] != HARD_RETURN))) {
-00251                         pNext = pNext->pNext;
-00252                 }
-00253                 if (pNext == NULL) {
-00254                         if (bOutputContainsText(pStart)) {
-00255                                 vAlign2Window(pDiag, pStart,
-00256                                         lChar2MilliPoints(DEFAULT_SCREEN_WIDTH),
-00257                                         ALIGNMENT_LEFT);
-00258                         } else {
-00259                                 vMove2NextLinePS(pDiag, pStart->usFontSize);
-00260                         }
-00261                         break;
-00262                 }
-00263                 fail(pNext->tNextFree != 1);
-00264                 fail(pNext->szStorage[0] != PAR_END &&
-00265                         pNext->szStorage[0] != HARD_RETURN);
-00266 
-00267                 if (pStart != pNext) {
-00268                         /* There is something to print */
-00269                         pPrev = pNext->pPrev;
-00270                         fail(pPrev->pNext != pNext);
-00271                         /* Cut the chain */
-00272                         pPrev->pNext = NULL;
-00273                         if (bOutputContainsText(pStart)) {
-00274                                 /* Print it */
-00275                                 vAlign2Window(pDiag, pStart,
-00276                                         lChar2MilliPoints(DEFAULT_SCREEN_WIDTH),
-00277                                         ALIGNMENT_LEFT);
-00278                         } else {
-00279                                 /* Just an empty line */
-00280                                 vMove2NextLinePS(pDiag, pStart->usFontSize);
-00281                         }
-00282                         /* Repair the chain */
-00283                         pPrev->pNext = pNext;
-00284                 }
-00285                 if (pNext->szStorage[0] == PAR_END) {
-00286                         vEndOfParagraphPS(pDiag, pNext->usFontSize,
-00287                                         (long)pNext->usFontSize * 200);
-00288                 }
-00289                 pStart = pNext->pNext;
-00290         }
-00291 } /* end of vAddHdrFtr */
-00292 
-00293 /*
-00294  * vAddHeader - add a page header
-00295  */
-00296 static void
-00297 vAddHeader(diagram_type *pDiag)
-00298 {
-00299         const hdrftr_block_type *pHdrInfo;
-00300         const hdrftr_block_type *pFtrInfo;
-00301 
-00302         fail(pDiag == NULL);
-00303 
-00304         NO_DBG_MSG("vAddHeader");
-00305 
-00306         pHdrInfo = pGetHdrFtrInfo(iSectionIndex, TRUE,
-00307                                         odd(iPageCount), bFirstInSection);
-00308         pFtrInfo = pGetHdrFtrInfo(iSectionIndex, FALSE,
-00309                                         odd(iPageCount), bFirstInSection);
-00310         /* Set the height of the footer of this page */
-00311         lFooterHeight = pFtrInfo == NULL ? 0 : pFtrInfo->lHeight;
-00312         fail(lFooterHeight < 0);
-00313 
-00314         if (pHdrInfo == NULL ||
-00315             pHdrInfo->pText == NULL ||
-00316             pHdrInfo->lHeight <= 0) {
-00317                 fail(pHdrInfo != NULL && pHdrInfo->lHeight < 0);
-00318                 fail(pHdrInfo != NULL &&
-00319                         pHdrInfo->pText != NULL &&
-00320                         pHdrInfo->lHeight == 0);
-00321                 return;
-00322         }
-00323 
-00324         vAddHdrFtr(pDiag, pHdrInfo);
-00325 
-00326         DBG_DEC_C(pHdrInfo->lHeight !=
-00327                 lPageHeight - PS_TOP_MARGIN - pDiag->lYtop,
-00328                 pHdrInfo->lHeight);
-00329         DBG_DEC_C(pHdrInfo->lHeight !=
-00330                 lPageHeight - PS_TOP_MARGIN - pDiag->lYtop,
-00331                 lPageHeight - PS_TOP_MARGIN - pDiag->lYtop);
-00332 
-00333 #if 0 /* defined(DEBUG) */
-00334         fprintf(pDiag->pOutFile,
-00335         "(HEADER: FileOffset 0x%04lx-0x%04lx; Height %ld-%ld) show\n",
-00336                 ulCharPos2FileOffset(pHdrInfo->ulCharPosStart),
-00337                 ulCharPos2FileOffset(pHdrInfo->ulCharPosNext),
-00338                 pHdrInfo->lHeight,
-00339                 lPageHeight - PS_TOP_MARGIN - pDiag->lYtop);
-00340 #endif
-00341 } /* end of vAddHeader */
-00342 
-00343 /*
-00344  * vAddFooter - add a page footer
-00345  */
-00346 static void
-00347 vAddFooter(diagram_type *pDiag)
-00348 {
-00349         const hdrftr_block_type *pFtrInfo;
-00350 
-00351         fail(pDiag == NULL);
-00352 
-00353         NO_DBG_MSG("vAddFooter");
-00354         pFtrInfo = pGetHdrFtrInfo(iSectionIndex, FALSE,
-00355                                         odd(iPageCount), bFirstInSection);
-00356         bFirstInSection = FALSE;
-00357         if (pFtrInfo == NULL ||
-00358             pFtrInfo->pText == NULL ||
-00359             pFtrInfo->lHeight <= 0) {
-00360                 fail(pFtrInfo != NULL && pFtrInfo->lHeight < 0);
-00361                 fail(pFtrInfo != NULL &&
-00362                         pFtrInfo->pText != NULL &&
-00363                         pFtrInfo->lHeight == 0);
-00364                 return;
-00365         }
-00366 
-00367         bInFtrSpace = TRUE;
-00368 
-00369         DBG_DEC_C(pFtrInfo->lHeight != lFooterHeight, pFtrInfo->lHeight);
-00370         DBG_DEC_C(pFtrInfo->lHeight != lFooterHeight, lFooterHeight);
-00371         DBG_DEC_C(pDiag->lYtop < lFooterHeight + PS_BOTTOM_MARGIN,
-00372                         pDiag->lYtop);
-00373         DBG_DEC_C(pDiag->lYtop < lFooterHeight + PS_BOTTOM_MARGIN,
-00374                         lFooterHeight + PS_BOTTOM_MARGIN);
-00375 
-00376         if (pDiag->lYtop > lFooterHeight + PS_BOTTOM_MARGIN) {
-00377                 /* Move down to the start of the footer */
-00378                 pDiag->lYtop = lFooterHeight + PS_BOTTOM_MARGIN;
-00379                 vMoveTo(pDiag, 0);
-00380         } else if (pDiag->lYtop < lFooterHeight + PS_BOTTOM_MARGIN / 2) {
-00381                 DBG_FIXME();
-00382                 /*
-00383                  * Move up to the start of the footer, to prevent moving
-00384                  * of the bottom edge of the paper
-00385                  */
-00386                 pDiag->lYtop = lFooterHeight + PS_BOTTOM_MARGIN;
-00387                 vMoveTo(pDiag, 0);
-00388         }
-00389 
-00390         DBG_FLT_C(pDiag->lYtop < lFooterHeight + PS_BOTTOM_MARGIN,
-00391         dDrawUnits2Points(lFooterHeight + PS_BOTTOM_MARGIN - pDiag->lYtop));
-00392 
-00393 #if 0 /* defined(DEBUG) */
-00394         fprintf(pDiag->pOutFile,
-00395         "(FOOTER: FileOffset 0x%04lx-0x%04lx; Bottom %ld-%ld) show\n",
-00396                 ulCharPos2FileOffset(pFtrInfo->ulCharPosStart),
-00397                 ulCharPos2FileOffset(pFtrInfo->ulCharPosNext),
-00398                 pDiag->lYtop,
-00399                 pFtrInfo->lHeight + PS_BOTTOM_MARGIN);
-00400 #endif
-00401         vAddHdrFtr(pDiag, pFtrInfo);
-00402         bInFtrSpace = FALSE;
-00403 } /* end of vAddFooter */
-00404 
-00405 /*
-00406  * vMove2NextPage - move to the start of the next page
-00407  */
-00408 static void
-00409 vMove2NextPage(diagram_type *pDiag, BOOL bNewSection)
-00410 {
-00411         fail(pDiag == NULL);
-00412 
-00413         vAddFooter(pDiag);
-00414         fprintf(pDiag->pOutFile, "showpage\n");
-00415         iPageCount++;
-00416         fprintf(pDiag->pOutFile, "%%%%Page: %d %d\n", iPageCount, iPageCount);
-00417         if (bNewSection) {
-00418                 iSectionIndex++;
-00419                 bFirstInSection = TRUE;
-00420         }
-00421         vAddPageSetup(pDiag->pOutFile);
-00422         pDiag->lYtop = lPageHeight - PS_TOP_MARGIN;
-00423         lYtopCurr = -1;
-00424         vAddHeader(pDiag);
-00425 } /* end of vMove2NextPage */
-00426 
-00427 /*
-00428  * vMoveTo - move to the specified X,Y coordinates
-00429  *
-00430  * Move the current position of the specified diagram to its X,Y coordinates,
-00431  * start on a new page if needed
-00432  */
-00433 static void
-00434 vMoveTo(diagram_type *pDiag, long lLastVerticalMovement)
-00435 {
-00436         fail(pDiag == NULL);
-00437         fail(pDiag->pOutFile == NULL);
-00438 
-00439         if (pDiag->lYtop <= lFooterHeight + PS_BOTTOM_MARGIN && !bInFtrSpace) {
-00440                 vMove2NextPage(pDiag, FALSE);
-00441                 /* Repeat the last vertical movement on the new page */
-00442                 pDiag->lYtop -= lLastVerticalMovement;
-00443         }
-00444 
-00445         fail(pDiag->lYtop < lFooterHeight + PS_BOTTOM_MARGIN && !bInFtrSpace);
-00446         DBG_DEC_C(pDiag->lYtop < PS_BOTTOM_MARGIN, pDiag->lYtop);
-00447         fail(pDiag->lYtop < PS_BOTTOM_MARGIN / 3);
-00448 
-00449         if (pDiag->lYtop != lYtopCurr) {
-00450                 fprintf(pDiag->pOutFile, "%.2f %.2f moveto\n",
-00451                         dDrawUnits2Points(pDiag->lXleft + PS_LEFT_MARGIN),
-00452                         dDrawUnits2Points(pDiag->lYtop));
-00453                 lYtopCurr = pDiag->lYtop;
-00454         }
-00455 } /* end of vMoveTo */
-00456 
-00457 /*
-00458  * vProloguePS - set options and perform the PostScript initialization
-00459  */
-00460 void
-00461 vProloguePS(diagram_type *pDiag,
-00462         const char *szTask, const char *szFilename,
-00463         const options_type *pOptions)
-00464 {
-00465         FILE    *pOutFile;
-00466         const char      *szTmp;
-00467         time_t  tTime;
-00468 
-00469         fail(pDiag == NULL);
-00470         fail(pDiag->pOutFile == NULL);
-00471         fail(szTask == NULL || szTask[0] == '\0');
-00472         fail(pOptions == NULL);
-00473 
-00474         pOutFile = pDiag->pOutFile;
-00475 
-00476         bUseLandscape = pOptions->bUseLandscape;
-00477         eEncoding = pOptions->eEncoding;
-00478         eImageLevel = pOptions->eImageLevel;
-00479 
-00480         if (pOptions->iPageHeight == INT_MAX) {
-00481                 lPageHeight = LONG_MAX;
-00482         } else {
-00483                 lPageHeight = lPoints2DrawUnits(pOptions->iPageHeight);
-00484         }
-00485         DBG_DEC(lPageHeight);
-00486         if (pOptions->iPageWidth == INT_MAX) {
-00487                 lPageWidth = LONG_MAX;
-00488         } else {
-00489                 lPageWidth = lPoints2DrawUnits(pOptions->iPageWidth);
-00490         }
-00491         DBG_DEC(lPageWidth);
-00492         lFooterHeight = 0;
-00493         bInFtrSpace = FALSE;
-00494 
-00495         tFontRefCurr = (drawfile_fontref)-1;
-00496         usFontSizeCurr = 0;
-00497         iFontColorCurr = -1;
-00498         lYtopCurr = -1;
-00499         iPageCount = 0;
-00500         iImageCount = 0;
-00501         iSectionIndex = 0;
-00502         bFirstInSection = TRUE;
-00503         pDiag->lXleft = 0;
-00504         pDiag->lYtop = lPageHeight - PS_TOP_MARGIN;
-00505 
-00506         szCreator = szTask;
-00507 
-00508         fprintf(pOutFile, "%%!PS-Adobe-2.0\n");
-00509         fprintf(pOutFile, "%%%%Title: %s\n", szBasename(szFilename));
-00510         fprintf(pOutFile, "%%%%Creator: %s %s\n", szCreator, VERSIONSTRING);
-00511         szTmp = getenv("LOGNAME");
-00512         if (szTmp == NULL || szTmp[0] == '\0') {
-00513                 szTmp = getenv("USER");
-00514                 if (szTmp == NULL || szTmp[0] == '\0') {
-00515                         szTmp = "unknown";
-00516                 }
-00517         }
-00518         fprintf(pOutFile, "%%%%For: %.50s\n", szTmp);
-00519         errno = 0;
-00520         tTime = time(NULL);
-00521         if (tTime == (time_t)-1 && errno != 0) {
-00522                 szCreationDate = NULL;
-00523         } else {
-00524                 szCreationDate = ctime(&tTime);
-00525         }
-00526         if (szCreationDate == NULL || szCreationDate[0] == '\0') {
-00527                 szCreationDate = "unknown\n";
-00528         }
-00529         fprintf(pOutFile, "%%%%CreationDate: %s", szCreationDate);
-00530         if (bUseLandscape) {
-00531                 fprintf(pOutFile, "%%%%Orientation: Landscape\n");
-00532                 fprintf(pOutFile, "%%%%BoundingBox: 0 0 %.0f %.0f\n",
-00533                                 dDrawUnits2Points(lPageHeight),
-00534                                 dDrawUnits2Points(lPageWidth));
-00535         } else {
-00536                 fprintf(pOutFile, "%%%%Orientation: Portrait\n");
-00537                 fprintf(pOutFile, "%%%%BoundingBox: 0 0 %.0f %.0f\n",
-00538                                 dDrawUnits2Points(lPageWidth),
-00539                                 dDrawUnits2Points(lPageHeight));
-00540         }
-00541 } /* end of vProloguePS */
-00542 
-00543 /*
-00544  * vEpiloguePS - clean up after everything is done
-00545  */
-00546 void
-00547 vEpiloguePS(diagram_type *pDiag)
-00548 {
-00549         fail(pDiag == NULL);
-00550         fail(pDiag->pOutFile == NULL);
-00551 
-00552         if (pDiag->lYtop < lPageHeight - PS_TOP_MARGIN) {
-00553                 vAddFooter(pDiag);
-00554                 fprintf(pDiag->pOutFile, "showpage\n");
-00555         }
-00556         fprintf(pDiag->pOutFile, "%%%%Trailer\n");
-00557         fprintf(pDiag->pOutFile, "%%%%Pages: %d\n", iPageCount);
-00558         fprintf(pDiag->pOutFile, "%%%%EOF\n");
-00559         szCreationDate = NULL;
-00560         szCreator = NULL;
-00561 } /* end of vEpiloguePS */
-00562 
-00563 /*
-00564  * vPrintPalette - print a postscript palette
-00565  */
-00566 static void
-00567 vPrintPalette(FILE *pOutFile, const imagedata_type *pImg)
-00568 {
-00569         int     iIndex;
-00570 
-00571         fail(pOutFile == NULL);
-00572         fail(pImg == NULL);
-00573         fail(pImg->iColorsUsed < 2);
-00574         fail(pImg->iColorsUsed > 256);
-00575 
-00576         fprintf(pOutFile, "[ /Indexed\n");
-00577         fprintf(pOutFile, "\t/Device%s %d\n",
-00578                 pImg->bColorImage ? "RGB" : "Gray", pImg->iColorsUsed - 1);
-00579         fprintf(pOutFile, "<");
-00580         for (iIndex = 0; iIndex < pImg->iColorsUsed; iIndex++) {
-00581                 fprintf(pOutFile, "%02x",
-00582                                 (unsigned int)pImg->aucPalette[iIndex][0]);
-00583                 if (pImg->bColorImage) {
-00584                         fprintf(pOutFile, "%02x%02x",
-00585                                 (unsigned int)pImg->aucPalette[iIndex][1],
-00586                                 (unsigned int)pImg->aucPalette[iIndex][2]);
-00587                 }
-00588                 if (iIndex % 8 == 7) {
-00589                         fprintf(pOutFile, "\n");
-00590                 } else {
-00591                         fprintf(pOutFile, " ");
-00592                 }
-00593         }
-00594         fprintf(pOutFile, ">\n");
-00595         fprintf(pOutFile, "] setcolorspace\n");
-00596 } /* end of vPrintPalette */
-00597 
-00598 /*
-00599  * vImageProloguePS - perform the Encapsulated PostScript initialization
-00600  */
-00601 void
-00602 vImageProloguePS(diagram_type *pDiag, const imagedata_type *pImg)
-00603 {
-00604         FILE    *pOutFile;
-00605 
-00606         fail(pDiag == NULL);
-00607         fail(pDiag->pOutFile == NULL);
-00608         fail(pImg == NULL);
-00609 
-00610         if (pImg->iVerSizeScaled <= 0 || pImg->iHorSizeScaled <= 0) {
-00611                 return;
-00612         }
-00613 
-00614         fail(szCreationDate == NULL);
-00615         fail(szCreator == NULL);
-00616         fail(eImageLevel == level_no_images);
-00617 
-00618         iImageCount++;
-00619 
-00620         DBG_DEC_C(pDiag->lXleft != 0, pDiag->lXleft);
-00621 
-00622         pDiag->lYtop -= lPoints2DrawUnits(pImg->iVerSizeScaled);
-00623         vMoveTo(pDiag, lPoints2DrawUnits(pImg->iVerSizeScaled));
-00624 
-00625         pOutFile = pDiag->pOutFile;
-00626 
-00627         fprintf(pOutFile, "BeginEPSF\n");
-00628         fprintf(pOutFile, "%%%%BeginDocument: image%03d.eps\n", iImageCount);
-00629         fprintf(pOutFile, "%%!PS-Adobe-2.0 EPSF-2.0\n");
-00630         fprintf(pOutFile, "%%%%Creator: %s %s\n", szCreator, VERSIONSTRING);
-00631         fprintf(pOutFile, "%%%%Title: Image %03d\n", iImageCount);
-00632         fprintf(pOutFile, "%%%%CreationDate: %s", szCreationDate);
-00633         fprintf(pOutFile, "%%%%BoundingBox: 0 0 %d %d\n",
-00634                                 pImg->iHorSizeScaled, pImg->iVerSizeScaled);
-00635         fprintf(pOutFile, "%%%%DocumentData: Clean7Bit\n");
-00636         fprintf(pOutFile, "%%%%LanguageLevel: 2\n");
-00637         fprintf(pOutFile, "%%%%EndComments\n");
-00638         fprintf(pOutFile, "%%%%BeginProlog\n");
-00639         fprintf(pOutFile, "%%%%EndProlog\n");
-00640         fprintf(pOutFile, "%%%%Page: 1 1\n");
-00641 
-00642         fprintf(pOutFile, "save\n");
-00643 
-00644         switch (pImg->eImageType) {
-00645         case imagetype_is_jpeg:
-00646                 fprintf(pOutFile, "/Data1 currentfile ");
-00647                 fprintf(pOutFile, "/ASCII85Decode filter def\n");
-00648                 fprintf(pOutFile, "/Data Data1 << ");
-00649                 fprintf(pOutFile, ">> /DCTDecode filter def\n");
-00650                 switch (pImg->iComponents) {
-00651                 case 1:
-00652                         fprintf(pOutFile, "/DeviceGray setcolorspace\n");
-00653                         break;
-00654                 case 3:
-00655                         fprintf(pOutFile, "/DeviceRGB setcolorspace\n");
-00656                         break;
-00657                 case 4:
-00658                         fprintf(pOutFile, "/DeviceCMYK setcolorspace\n");
-00659                         break;
-00660                 default:
-00661                         DBG_DEC(pImg->iComponents);
-00662                         break;
-00663                 }
-00664                 break;
-00665         case imagetype_is_png:
-00666                 if (eImageLevel == level_gs_special) {
-00667                         fprintf(pOutFile,
-00668                         "/Data2 currentfile /ASCII85Decode filter def\n");
-00669                         fprintf(pOutFile,
-00670                         "/Data1 Data2 << >> /FlateDecode filter def\n");
-00671                         fprintf(pOutFile, "/Data Data1 <<\n");
-00672                         fprintf(pOutFile, "\t/Colors %d\n", pImg->iComponents);
-00673                         fprintf(pOutFile, "\t/BitsPerComponent %u\n",
-00674                                                 pImg->uiBitsPerComponent);
-00675                         fprintf(pOutFile, "\t/Columns %d\n", pImg->iWidth);
-00676                         fprintf(pOutFile,
-00677                                 ">> /PNGPredictorDecode filter def\n");
-00678                 } else {
-00679                         fprintf(pOutFile,
-00680                         "/Data1 currentfile /ASCII85Decode filter def\n");
-00681                         fprintf(pOutFile,
-00682                         "/Data Data1 << >> /FlateDecode filter def\n");
-00683                 }
-00684                 if (pImg->iComponents == 3 || pImg->iComponents == 4) {
-00685                         fprintf(pOutFile, "/DeviceRGB setcolorspace\n");
-00686                 } else if (pImg->iColorsUsed > 0) {
-00687                         vPrintPalette(pOutFile, pImg);
-00688                 } else {
-00689                         fprintf(pOutFile, "/DeviceGray setcolorspace\n");
-00690                 }
-00691                 break;
-00692         case imagetype_is_dib:
-00693                 fprintf(pOutFile, "/Data currentfile ");
-00694                 fprintf(pOutFile, "/ASCII85Decode filter def\n");
-00695                 if (pImg->uiBitsPerComponent <= 8) {
-00696                         vPrintPalette(pOutFile, pImg);
-00697                 } else {
-00698                         fprintf(pOutFile, "/DeviceRGB setcolorspace\n");
-00699                 }
-00700                 break;
-00701         default:
-00702                 fprintf(pOutFile, "/Data currentfile ");
-00703                 fprintf(pOutFile, "/ASCIIHexDecode filter def\n");
-00704                 fprintf(pOutFile, "/Device%s setcolorspace\n",
-00705                         pImg->bColorImage ? "RGB" : "Gray");
-00706                 break;
-00707         }
-00708 
-00709         /* Translate to lower left corner of image */
-00710         fprintf(pOutFile, "%.2f %.2f translate\n",
-00711                         dDrawUnits2Points(pDiag->lXleft + PS_LEFT_MARGIN),
-00712                         dDrawUnits2Points(pDiag->lYtop));
-00713 
-00714         fprintf(pOutFile, "%d %d scale\n",
-00715                                 pImg->iHorSizeScaled, pImg->iVerSizeScaled);
-00716 
-00717         fprintf(pOutFile, "{ <<\n");
-00718         fprintf(pOutFile, "\t/ImageType 1\n");
-00719         fprintf(pOutFile, "\t/Width %d\n", pImg->iWidth);
-00720         fprintf(pOutFile, "\t/Height %d\n", pImg->iHeight);
-00721         if (pImg->eImageType == imagetype_is_dib) {
-00722                 /* Scanning from left to right and bottom to top */
-00723                 fprintf(pOutFile, "\t/ImageMatrix [ %d 0 0 %d 0 0 ]\n",
-00724                         pImg->iWidth, pImg->iHeight);
-00725         } else {
-00726                 /* Scanning from left to right and top to bottom */
-00727                 fprintf(pOutFile, "\t/ImageMatrix [ %d 0 0 %d 0 %d ]\n",
-00728                         pImg->iWidth, -pImg->iHeight, pImg->iHeight);
-00729         }
-00730         fprintf(pOutFile, "\t/DataSource Data\n");
-00731 
-00732         switch (pImg->eImageType) {
-00733         case imagetype_is_jpeg:
-00734                 fprintf(pOutFile, "\t/BitsPerComponent 8\n");
-00735                 switch (pImg->iComponents) {
-00736                 case 1:
-00737                         fprintf(pOutFile, "\t/Decode [0 1]\n");
-00738                         break;
-00739                 case 3:
-00740                         fprintf(pOutFile, "\t/Decode [0 1 0 1 0 1]\n");
-00741                         break;
-00742                 case 4:
-00743                         if (pImg->bAdobe) {
-00744                                 /*
-00745                                  * Adobe-conforming CMYK file
-00746                                  * applying workaround for color inversion
-00747                                  */
-00748                                 fprintf(pOutFile,
-00749                                         "\t/Decode [1 0 1 0 1 0 1 0]\n");
-00750                         } else {
-00751                                 fprintf(pOutFile,
-00752                                         "\t/Decode [0 1 0 1 0 1 0 1]\n");
-00753                         }
-00754                         break;
-00755                 default:
-00756                         DBG_DEC(pImg->iComponents);
-00757                         break;
-00758                 }
-00759                 break;
-00760         case imagetype_is_png:
-00761                 if (pImg->iComponents == 3) {
-00762                         fprintf(pOutFile, "\t/BitsPerComponent 8\n");
-00763                         fprintf(pOutFile, "\t/Decode [0 1 0 1 0 1]\n");
-00764                 } else if (pImg->iColorsUsed > 0) {
-00765                         fail(pImg->uiBitsPerComponent > 8);
-00766                         fprintf(pOutFile, "\t/BitsPerComponent %u\n",
-00767                                         pImg->uiBitsPerComponent);
-00768                         fprintf(pOutFile, "\t/Decode [0 %d]\n",
-00769                                         (1 << pImg->uiBitsPerComponent) - 1);
-00770                 } else {
-00771                         fprintf(pOutFile, "\t/BitsPerComponent 8\n");
-00772                         fprintf(pOutFile, "\t/Decode [0 1]\n");
-00773                 }
-00774                 break;
-00775         case imagetype_is_dib:
-00776                 fprintf(pOutFile, "\t/BitsPerComponent 8\n");
-00777                 if (pImg->uiBitsPerComponent <= 8) {
-00778                         fprintf(pOutFile, "\t/Decode [0 255]\n");
-00779                 } else {
-00780                         fprintf(pOutFile, "\t/Decode [0 1 0 1 0 1]\n");
-00781                 }
-00782                 break;
-00783         default:
-00784                 fprintf(pOutFile, "\t/BitsPerComponent 8\n");
-00785                 if (pImg->bColorImage) {
-00786                         fprintf(pOutFile, "\t/Decode [0 1 0 1 0 1]\n");
-00787                 } else {
-00788                         fprintf(pOutFile, "\t/Decode [0 1]\n");
-00789                 }
-00790                 break;
-00791         }
-00792 
-00793         fprintf(pOutFile, "  >> image\n");
-00794         fprintf(pOutFile, "  Data closefile\n");
-00795         fprintf(pOutFile, "  showpage\n");
-00796         fprintf(pOutFile, "  restore\n");
-00797         fprintf(pOutFile, "} exec\n");
-00798 } /* end of vImageProloguePS */
-00799 
-00800 /*
-00801  * vImageEpiloguePS - clean up after Encapsulated PostScript
-00802  */
-00803 void
-00804 vImageEpiloguePS(diagram_type *pDiag)
-00805 {
-00806         FILE    *pOutFile;
-00807 
-00808         fail(pDiag == NULL);
-00809         fail(pDiag->pOutFile == NULL);
-00810 
-00811         pOutFile = pDiag->pOutFile;
-00812 
-00813         fprintf(pOutFile, "%%%%EOF\n");
-00814         fprintf(pOutFile, "%%%%EndDocument\n");
-00815         fprintf(pOutFile, "EndEPSF\n");
-00816 
-00817         pDiag->lXleft = 0;
-00818 } /* end of vImageEpiloguePS */
-00819 
-00820 /*
-00821  * bAddDummyImagePS - add a dummy image
-00822  *
-00823  * return TRUE when successful, otherwise FALSE
-00824  */
-00825 BOOL
-00826 bAddDummyImagePS(diagram_type *pDiag, const imagedata_type *pImg)
-00827 {
-00828         FILE    *pOutFile;
-00829 
-00830         fail(pDiag == NULL);
-00831         fail(pDiag->pOutFile == NULL);
-00832         fail(pImg == NULL);
-00833 
-00834         if (pImg->iVerSizeScaled <= 0 || pImg->iHorSizeScaled <= 0) {
-00835                 return FALSE;
-00836         }
-00837 
-00838         iImageCount++;
-00839 
-00840         DBG_DEC_C(pDiag->lXleft != 0, pDiag->lXleft);
-00841 
-00842         pDiag->lYtop -= lPoints2DrawUnits(pImg->iVerSizeScaled);
-00843         vMoveTo(pDiag, lPoints2DrawUnits(pImg->iVerSizeScaled));
-00844 
-00845         pOutFile = pDiag->pOutFile;
-00846 
-00847         fprintf(pOutFile, "gsave %% Image %03d\n", iImageCount);
-00848         fprintf(pOutFile, "\tnewpath\n");
-00849         fprintf(pOutFile, "\t%.2f %.2f moveto\n",
-00850                         dDrawUnits2Points(pDiag->lXleft + PS_LEFT_MARGIN),
-00851                         dDrawUnits2Points(pDiag->lYtop));
-00852         fprintf(pOutFile, "\t1.0 setlinewidth\n");
-00853         fprintf(pOutFile, "\t0.3 setgray\n");
-00854         fprintf(pOutFile, "\t0 %d rlineto\n", pImg->iVerSizeScaled);
-00855         fprintf(pOutFile, "\t%d 0 rlineto\n", pImg->iHorSizeScaled);
-00856         fprintf(pOutFile, "\t0 %d rlineto\n", -pImg->iVerSizeScaled);
-00857         fprintf(pOutFile, "\tclosepath\n");
-00858         fprintf(pOutFile, "\tstroke\n");
-00859         fprintf(pOutFile, "grestore\n");
-00860 
-00861         pDiag->lXleft = 0;
-00862 
-00863         return TRUE;
-00864 } /* end of bAddDummyImagePS */
-00865 
-00866 /*
-00867  * vAddFontsPS - add the list of fonts and complete the prologue
-00868  */
-00869 void
-00870 vAddFontsPS(diagram_type *pDiag)
-00871 {
-00872         FILE    *pOutFile;
-00873         const font_table_type *pTmp, *pTmp2;
-00874         size_t  tIndex;
-00875         int     iLineLen, iOurFontnameLen;
-00876         BOOL    bFound;
-00877 
-00878         fail(pDiag == NULL);
-00879         fail(pDiag->pOutFile == NULL);
-00880 
-00881         pOutFile = pDiag->pOutFile;
-00882         iLineLen = fprintf(pOutFile, "%%%%DocumentFonts:");
-00883 
-00884         if (tGetFontTableLength() == 0) {
-00885                 iLineLen += fprintf(pOutFile, " Courier");
-00886         } else {
-00887                 pTmp = NULL;
-00888                 while ((pTmp = pGetNextFontTableRecord(pTmp)) != NULL) {
-00889                         /* Print the document fonts */
-00890                         bFound = FALSE;
-00891                         pTmp2 = NULL;
-00892                         while ((pTmp2 = pGetNextFontTableRecord(pTmp2))
-00893                                         != NULL && pTmp2 < pTmp) {
-00894                                 bFound = STREQ(pTmp2->szOurFontname,
-00895                                                 pTmp->szOurFontname);
-00896                                 if (bFound) {
-00897                                         break;
-00898                                 }
-00899                         }
-00900                         iOurFontnameLen = (int)strlen(pTmp->szOurFontname);
-00901                         if (bFound || iOurFontnameLen <= 0) {
-00902                                 continue;
-00903                         }
-00904                         if (iLineLen + iOurFontnameLen > 76) {
-00905                                 fprintf(pOutFile, "\n%%%%+");
-00906                                 iLineLen = 3;
-00907                         }
-00908                         iLineLen += fprintf(pOutFile,
-00909                                         " %s", pTmp->szOurFontname);
-00910                 }
-00911         }
-00912         fprintf(pOutFile, "\n");
-00913         fprintf(pOutFile, "%%%%Pages: (atend)\n");
-00914         fprintf(pOutFile, "%%%%EndComments\n");
-00915         fprintf(pOutFile, "%%%%BeginProlog\n");
-00916 
-00917         switch (eEncoding) {
-00918         case encoding_latin_1:
-00919                 for (tIndex = 0;
-00920                      tIndex < elementsof(iso_8859_1_data);
-00921                      tIndex++) {
-00922                         fprintf(pOutFile, "%s\n", iso_8859_1_data[tIndex]);
-00923                 }
-00924                 fprintf(pOutFile, "\n");
-00925                 for (tIndex = 0;
-00926                      tIndex < elementsof(iso_8859_x_func);
-00927                      tIndex++) {
-00928                         fprintf(pOutFile, "%s\n", iso_8859_x_func[tIndex]);
-00929                 }
-00930                 break;
-00931         case encoding_latin_2:
-00932                 for (tIndex = 0;
-00933                      tIndex < elementsof(iso_8859_2_data);
-00934                      tIndex++) {
-00935                         fprintf(pOutFile, "%s\n", iso_8859_2_data[tIndex]);
-00936                 }
-00937                 fprintf(pOutFile, "\n");
-00938                 for (tIndex = 0;
-00939                      tIndex < elementsof(iso_8859_x_func);
-00940                      tIndex++) {
-00941                         fprintf(pOutFile, "%s\n", iso_8859_x_func[tIndex]);
-00942                 }
-00943                 break;
-00944         case encoding_cyrillic:
-00945                 for (tIndex = 0;
-00946                      tIndex < elementsof(iso_8859_5_data);
-00947                      tIndex++) {
-00948                         fprintf(pOutFile, "%s\n", iso_8859_5_data[tIndex]);
-00949                 }
-00950                 fprintf(pOutFile, "\n");
-00951                 for (tIndex = 0;
-00952                      tIndex < elementsof(iso_8859_x_func);
-00953                      tIndex++) {
-00954                         fprintf(pOutFile, "%s\n", iso_8859_x_func[tIndex]);
-00955                 }
-00956                 break;
-00957         case encoding_utf_8:
-00958                 werr(1,
-00959                 "The combination PostScript and UTF-8 is not supported");
-00960                 break;
-00961         default:
-00962                 DBG_DEC(eEncoding);
-00963                 break;
-00964         }
-00965 
-00966         /* The rest of the functions */
-00967         for (tIndex = 0; tIndex < elementsof(misc_func); tIndex++) {
-00968                 fprintf(pOutFile, "%s\n", misc_func[tIndex]);
-00969         }
-00970         fprintf(pOutFile, "%%%%EndProlog\n");
-00971         iPageCount = 1;
-00972         fprintf(pDiag->pOutFile, "%%%%Page: %d %d\n", iPageCount, iPageCount);
-00973         vAddPageSetup(pDiag->pOutFile);
-00974         vAddHeader(pDiag);
-00975 } /* end of vAddFontsPS */
-00976 
-00977 /*
-00978  * vPrintPS - print a PostScript string
-00979  */
-00980 static void
-00981 vPrintPS(FILE *pFile, const char *szString, size_t tStringLength,
-00982                 USHORT usFontstyle)
-00983 {
-00984         double          dSuperscriptMove, dSubscriptMove;
-00985         const UCHAR     *ucBytes;
-00986         size_t          tCount;
-00987 
-00988         fail(szString == NULL);
-00989 
-00990         if (szString == NULL || szString[0] == '\0' || tStringLength == 0) {
-00991                 return;
-00992         }
-00993         DBG_DEC_C(usFontSizeCurr < MIN_FONT_SIZE, usFontSizeCurr);
-00994 
-00995         dSuperscriptMove = 0.0;
-00996         dSubscriptMove = 0.0;
-00997 
-00998         /* Up for superscript */
-00999         if (bIsSuperscript(usFontstyle) && usFontSizeCurr != 0) {
-01000                 dSuperscriptMove = (double)((usFontSizeCurr + 1) / 2) * 0.375;
-01001                 fprintf(pFile, "0 %.2f rmoveto\n", dSuperscriptMove);
-01002         }
-01003 
-01004         /* Down for subscript */
-01005         if (bIsSubscript(usFontstyle) && usFontSizeCurr != 0) {
-01006                 dSubscriptMove = (double)usFontSizeCurr * 0.125;
-01007                 fprintf(pFile, "0 %.2f rmoveto\n", -dSubscriptMove);
-01008         }
-01009 
-01010         /* Generate and print the PostScript output */
-01011         ucBytes = (UCHAR *)szString;
-01012         (void)putc('(', pFile);
-01013         for (tCount = 0; tCount < tStringLength ; tCount++) {
-01014                 switch (ucBytes[tCount]) {
-01015                 case '(':
-01016                 case ')':
-01017                 case '\\':
-01018                         (void)putc('\\', pFile);
-01019                         (void)putc(szString[tCount], pFile);
-01020                         break;
-01021                 default:
-01022                         if (ucBytes[tCount] < 0x20 ||
-01023                             (ucBytes[tCount] >= 0x7f &&
-01024                              ucBytes[tCount] < 0x8c)) {
-01025                                 DBG_HEX(ucBytes[tCount]);
-01026                                 (void)putc(' ', pFile);
-01027                         } else if (ucBytes[tCount] >= 0x80) {
-01028                                 fprintf(pFile, "\\%03o", (UINT)ucBytes[tCount]);
-01029                         } else {
-01030                                 (void)putc(szString[tCount], pFile);
-01031                         }
-01032                         break;
-01033                 }
-01034         }
-01035         fprintf(pFile, ") ");
-01036         if ((bIsStrike(usFontstyle) || bIsMarkDel(usFontstyle)) &&
-01037                         usFontSizeCurr != 0) {
-01038                 fprintf(pFile, "%.2f %.2f LineShow\n",
-01039                         (double)usFontSizeCurr * 0.02,
-01040                         (double)usFontSizeCurr * 0.12);
-01041         } else if (bIsUnderline(usFontstyle) && usFontSizeCurr != 0) {
-01042                 fprintf(pFile, "%.2f %.2f LineShow\n",
-01043                         (double)usFontSizeCurr * 0.02,
-01044                         (double)usFontSizeCurr * -0.06);
-01045         } else {
-01046                 fprintf(pFile, "show\n");
-01047         }
-01048 
-01049         /* Undo the superscript move */
-01050         if (bIsSuperscript(usFontstyle) && usFontSizeCurr != 0) {
-01051                 fprintf(pFile, "0 %.2f rmoveto\n", -dSuperscriptMove);
-01052         }
-01053 
-01054         /* Undo the subscript move */
-01055         if (bIsSubscript(usFontstyle) && usFontSizeCurr != 0) {
-01056                 fprintf(pFile, "0 %.2f rmoveto\n", dSubscriptMove);
-01057         }
-01058 } /* end of vPrintPS */
-01059 
-01060 /*
-01061  * vSetColor - move to the specified color
-01062  */
-01063 static void
-01064 vSetColor(FILE *pFile, UCHAR ucFontColor)
-01065 {
-01066         ULONG   ulTmp, ulRed, ulGreen, ulBlue;
-01067 
-01068         ulTmp = ulColor2Color(ucFontColor);
-01069         ulRed   = (ulTmp & 0x0000ff00) >> 8;
-01070         ulGreen = (ulTmp & 0x00ff0000) >> 16;
-01071         ulBlue  = (ulTmp & 0xff000000) >> 24;
-01072         fprintf(pFile, "%.3f %.3f %.3f setrgbcolor\n",
-01073                                 ulRed / 255.0, ulGreen / 255.0, ulBlue / 255.0);
-01074 } /* end of vSetColor */
-01075 
-01076 /*
-01077  * vMove2NextLinePS - move to the next line
-01078  */
-01079 void
-01080 vMove2NextLinePS(diagram_type *pDiag, USHORT usFontSize)
-01081 {
-01082         fail(pDiag == NULL);
-01083         fail(usFontSize < MIN_FONT_SIZE || usFontSize > MAX_FONT_SIZE);
-01084 
-01085         pDiag->lYtop -= lComputeLeading(usFontSize);
-01086 } /* end of vMove2NextLinePS */
-01087 
-01088 /*
-01089  * vSubstringPS - print a sub string
-01090  */
-01091 void
-01092 vSubstringPS(diagram_type *pDiag,
-01093         char *szString, size_t tStringLength, long lStringWidth,
-01094         UCHAR ucFontColor, USHORT usFontstyle, drawfile_fontref tFontRef,
-01095         USHORT usFontSize, USHORT usMaxFontSize)
-01096 {
-01097         const char      *szOurFontname;
-01098 
-01099         fail(pDiag == NULL || szString == NULL);
-01100         fail(pDiag->pOutFile == NULL);
-01101         fail(pDiag->lXleft < 0);
-01102         fail(tStringLength != strlen(szString));
-01103         fail(usFontSize < MIN_FONT_SIZE || usFontSize > MAX_FONT_SIZE);
-01104         fail(usMaxFontSize < MIN_FONT_SIZE || usMaxFontSize > MAX_FONT_SIZE);
-01105         fail(usFontSize > usMaxFontSize);
-01106 
-01107         if (szString[0] == '\0' || tStringLength == 0) {
-01108                 return;
-01109         }
-01110 
-01111         if (tFontRef != tFontRefCurr || usFontSize != usFontSizeCurr) {
-01112                 szOurFontname = szGetFontname(tFontRef);
-01113                 fail(szOurFontname == NULL);
-01114                 fprintf(pDiag->pOutFile,
-01115                         "%.1f /%s /%s-ISO-8859-x ChgFnt\n",
-01116                         (double)usFontSize / 2.0,
-01117                         szOurFontname, szOurFontname);
-01118                 tFontRefCurr = tFontRef;
-01119                 usFontSizeCurr = usFontSize;
-01120         }
-01121         if ((int)ucFontColor != iFontColorCurr) {
-01122                 vSetColor(pDiag->pOutFile, ucFontColor);
-01123                 iFontColorCurr = (int)ucFontColor;
-01124         }
-01125         vMoveTo(pDiag, lComputeLeading(usMaxFontSize));
-01126         vPrintPS(pDiag->pOutFile, szString, tStringLength, usFontstyle);
-01127         pDiag->lXleft += lStringWidth;
-01128 } /* end of vSubstringPS */
-01129 
-01130 /*
-01131  * Create an start of paragraph by moving the y-top mark
-01132  */
-01133 void
-01134 vStartOfParagraphPS(diagram_type *pDiag, long lBeforeIndentation)
-01135 {
-01136         fail(pDiag == NULL);
-01137         fail(lBeforeIndentation < 0);
-01138 
-01139         pDiag->lXleft = 0;
-01140         pDiag->lYtop -= lMilliPoints2DrawUnits(lBeforeIndentation);
-01141 } /* end of vStartOfParagraphPS */
-01142 
-01143 /*
-01144  * Create an end of paragraph by moving the y-top mark
-01145  */
-01146 void
-01147 vEndOfParagraphPS(diagram_type *pDiag,
-01148         USHORT usFontSize, long lAfterIndentation)
-01149 {
-01150         fail(pDiag == NULL);
-01151         fail(pDiag->pOutFile == NULL);
-01152         fail(usFontSize < MIN_FONT_SIZE || usFontSize > MAX_FONT_SIZE);
-01153         fail(lAfterIndentation < 0);
-01154 
-01155         if (pDiag->lXleft > 0) {
-01156                 /* To the start of the line */
-01157                 vMove2NextLinePS(pDiag, usFontSize);
-01158         }
-01159 
-01160         pDiag->lXleft = 0;
-01161         pDiag->lYtop -= lMilliPoints2DrawUnits(lAfterIndentation);
-01162 } /* end of vEndOfParagraphPS */
-01163 
-01164 /*
-01165  * Create an end of page
-01166  */
-01167 void
-01168 vEndOfPagePS(diagram_type *pDiag, BOOL bNewSection)
-01169 {
-01170         vMove2NextPage(pDiag, bNewSection);
-01171 } /* end of vEndOfPagePS */
-
-
Generated by  - -doxygen 1.6.2
- - diff -r 59758314f811 -r d4524d6a4472 Symbian3/Examples/guid-6013a680-57f9-415b-8851-c4fa63356636/prop0_8c_source.html --- a/Symbian3/Examples/guid-6013a680-57f9-415b-8851-c4fa63356636/prop0_8c_source.html Fri Jun 11 15:24:34 2010 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,505 +0,0 @@ - - - - -TB9.2 Example Applications: examples/PIPS/antiword/src/prop0.c Source File - - - - - -

examples/PIPS/antiword/src/prop0.c

00001 /*
-00002  * prop0.c
-00003  * Copyright (C) 2002-2004 A.J. van Os; Released under GNU GPL
-00004  *
-00005  * Description:
-00006  * Read the property information from a Word for DOS file
-00007  */
-00008 
-00009 #include <string.h>
-00010 #include <time.h>
-00011 #include "antiword.h"
-00012 
-00013 
-00014 /*
-00015  * tConvertDosDate - convert DOS date format
-00016  *
-00017  * returns Unix time_t or -1
-00018  */
-00019 static time_t
-00020 tConvertDosDate(const char *szDosDate)
-00021 {
-00022         struct tm       tTime;
-00023         const char      *pcTmp;
-00024         time_t          tResult;
-00025 
-00026         memset(&tTime, 0, sizeof(tTime));
-00027         pcTmp = szDosDate;
-00028         /* Get the month */
-00029         if (!isdigit(*pcTmp)) {
-00030                 return (time_t)-1;
-00031         }
-00032         tTime.tm_mon = (int)(*pcTmp - '0');
-00033         pcTmp++;
-00034         if (isdigit(*pcTmp)) {
-00035                 tTime.tm_mon *= 10;
-00036                 tTime.tm_mon += (int)(*pcTmp - '0');
-00037                 pcTmp++;
-00038         }
-00039         /* Get the first separater */
-00040         if (isalnum(*pcTmp)) {
-00041                 return (time_t)-1;
-00042         }
-00043         pcTmp++;
-00044         /* Get the day */
-00045         if (!isdigit(*pcTmp)) {
-00046                 return (time_t)-1;
-00047         }
-00048         tTime.tm_mday = (int)(*pcTmp - '0');
-00049         pcTmp++;
-00050         if (isdigit(*pcTmp)) {
-00051                 tTime.tm_mday *= 10;
-00052                 tTime.tm_mday += (int)(*pcTmp - '0');
-00053                 pcTmp++;
-00054         }
-00055         /* Get the second separater */
-00056         if (isalnum(*pcTmp)) {
-00057                 return (time_t)-1;
-00058         }
-00059         pcTmp++;
-00060         /* Get the year */
-00061         if (!isdigit(*pcTmp)) {
-00062                 return (time_t)-1;
-00063         }
-00064         tTime.tm_year = (int)(*pcTmp - '0');
-00065         pcTmp++;
-00066         if (isdigit(*pcTmp)) {
-00067                 tTime.tm_year *= 10;
-00068                 tTime.tm_year += (int)(*pcTmp - '0');
-00069                 pcTmp++;
-00070         }
-00071         /* Check the values */
-00072         if (tTime.tm_mon == 0 || tTime.tm_mday == 0 || tTime.tm_mday > 31) {
-00073                 return (time_t)-1;
-00074         }
-00075         /* Correct the values */
-00076         tTime.tm_mon--;         /* From 01-12 to 00-11 */
-00077         if (tTime.tm_year < 80) {
-00078                 tTime.tm_year += 100;   /* 00 means 2000 is 100 */
-00079         }
-00080         tTime.tm_isdst = -1;
-00081         tResult = mktime(&tTime);
-00082         NO_DBG_MSG(ctime(&tResult));
-00083         return tResult;
-00084 } /* end of tConvertDosDate */
-00085 
-00086 /*
-00087  * Build the lists with Document Property Information for Word for DOS files
-00088  */
-00089 void
-00090 vGet0DopInfo(FILE *pFile, const UCHAR *aucHeader)
-00091 {
-00092         document_block_type     tDocument;
-00093         UCHAR   *aucBuffer;
-00094         ULONG   ulBeginSumdInfo, ulBeginNextBlock;
-00095         size_t  tLen;
-00096         USHORT  usOffset;
-00097 
-00098         tDocument.ucHdrFtrSpecification = 0;
-00099         tDocument.usDefaultTabWidth = usGetWord(0x70, aucHeader); /* dxaTab */
-00100         tDocument.tCreateDate = (time_t)-1;
-00101         tDocument.tRevisedDate = (time_t)-1;
-00102 
-00103         ulBeginSumdInfo = 128 * (ULONG)usGetWord(0x1c, aucHeader);
-00104         DBG_HEX(ulBeginSumdInfo);
-00105         ulBeginNextBlock = 128 * (ULONG)usGetWord(0x6a, aucHeader);
-00106         DBG_HEX(ulBeginNextBlock);
-00107 
-00108         if (ulBeginSumdInfo < ulBeginNextBlock && ulBeginNextBlock != 0) {
-00109                 /* There is a summary information block */
-00110                 tLen = (size_t)(ulBeginNextBlock - ulBeginSumdInfo);
-00111                 aucBuffer = xmalloc(tLen);
-00112                 /* Read the summary information block */
-00113                 if (bReadBytes(aucBuffer, tLen, ulBeginSumdInfo, pFile)) {
-00114                         usOffset = usGetWord(12, aucBuffer);
-00115                         if (aucBuffer[usOffset] != 0) {
-00116                                 NO_DBG_STRN(aucBuffer + usOffset, 8);
-00117                                 tDocument.tRevisedDate =
-00118                                 tConvertDosDate((char *)aucBuffer + usOffset);
-00119                         }
-00120                         usOffset = usGetWord(14, aucBuffer);
-00121                         if (aucBuffer[usOffset] != 0) {
-00122                                 NO_DBG_STRN(aucBuffer + usOffset, 8);
-00123                                 tDocument.tCreateDate =
-00124                                 tConvertDosDate((char *)aucBuffer + usOffset);
-00125                         }
-00126                 }
-00127                 aucBuffer = xfree(aucBuffer);
-00128         }
-00129         vCreateDocumentInfoList(&tDocument);
-00130 } /* end of vGet0DopInfo */
-00131 
-00132 /*
-00133  * Fill the section information block with information
-00134  * from a Word for DOS file.
-00135  */
-00136 static void
-00137 vGet0SectionInfo(const UCHAR *aucGrpprl, size_t tBytes,
-00138                 section_block_type *pSection)
-00139 {
-00140         USHORT  usCcol;
-00141         UCHAR   ucTmp;
-00142 
-00143         fail(aucGrpprl == NULL || pSection == NULL);
-00144 
-00145         if (tBytes < 2) {
-00146                 return;
-00147         }
-00148         /* bkc */
-00149         ucTmp = ucGetByte(1, aucGrpprl);
-00150         DBG_HEX(ucTmp);
-00151         ucTmp &= 0x07;
-00152         DBG_HEX(ucTmp);
-00153         pSection->bNewPage = ucTmp != 0 && ucTmp != 1;
-00154         if (tBytes < 18) {
-00155                 return;
-00156         }
-00157         /* ccolM1 */
-00158         usCcol = (USHORT)ucGetByte(17, aucGrpprl);
-00159         DBG_DEC(usCcol);
-00160 } /* end of vGet0SectionInfo */
-00161 
-00162 /*
-00163  * Build the lists with Section Property Information for Word for DOS files
-00164  */
-00165 void
-00166 vGet0SepInfo(FILE *pFile, const UCHAR *aucHeader)
-00167 {
-00168         section_block_type      tSection;
-00169         UCHAR   *aucBuffer;
-00170         ULONG   ulBeginOfText, ulTextOffset, ulBeginSectInfo;
-00171         ULONG   ulCharPos, ulSectPage, ulBeginNextBlock;
-00172         size_t  tSectInfoLen, tIndex, tSections, tBytes;
-00173         UCHAR   aucTmp[2], aucFpage[35];
-00174 
-00175         fail(pFile == NULL || aucHeader == NULL);
-00176 
-00177         ulBeginOfText = 128;
-00178         NO_DBG_HEX(ulBeginOfText);
-00179         ulBeginSectInfo = 128 * (ULONG)usGetWord(0x18, aucHeader);
-00180         DBG_HEX(ulBeginSectInfo);
-00181         ulBeginNextBlock = 128 * (ULONG)usGetWord(0x1a, aucHeader);
-00182         DBG_HEX(ulBeginNextBlock);
-00183         if (ulBeginSectInfo == ulBeginNextBlock) {
-00184                 /* There is no section information block */
-00185                 return;
-00186         }
-00187 
-00188         /* Get the the number of sections */
-00189         if (!bReadBytes(aucTmp, 2, ulBeginSectInfo, pFile)) {
-00190                 return;
-00191         }
-00192         tSections = (size_t)usGetWord(0, aucTmp);
-00193         NO_DBG_DEC(tSections);
-00194 
-00195         /* Read the Section Descriptors */
-00196         tSectInfoLen = 10 * tSections;
-00197         NO_DBG_DEC(tSectInfoLen);
-00198         aucBuffer = xmalloc(tSectInfoLen);
-00199         if (!bReadBytes(aucBuffer, tSectInfoLen, ulBeginSectInfo + 4, pFile)) {
-00200                 aucBuffer = xfree(aucBuffer);
-00201                 return;
-00202         }
-00203         NO_DBG_PRINT_BLOCK(aucBuffer, tSectInfoLen);
-00204 
-00205         /* Read the Section Properties */
-00206         for (tIndex = 0; tIndex < tSections; tIndex++) {
-00207                 ulTextOffset = ulGetLong(10 * tIndex, aucBuffer);
-00208                 NO_DBG_HEX(ulTextOffset);
-00209                 ulCharPos = ulBeginOfText + ulTextOffset;
-00210                 NO_DBG_HEX(ulTextOffset);
-00211                 ulSectPage = ulGetLong(10 * tIndex + 6, aucBuffer);
-00212                 NO_DBG_HEX(ulSectPage);
-00213                 if (ulSectPage == FC_INVALID ||         /* Must use defaults */
-00214                     ulSectPage < 128 ||                 /* Should not happen */
-00215                     ulSectPage >= ulBeginSectInfo) {    /* Should not happen */
-00216                         DBG_HEX_C(ulSectPage != FC_INVALID, ulSectPage);
-00217                         vDefault2SectionInfoList(ulCharPos);
-00218                         continue;
-00219                 }
-00220                 /* Get the number of bytes to read */
-00221                 if (!bReadBytes(aucTmp, 1, ulSectPage, pFile)) {
-00222                         continue;
-00223                 }
-00224                 tBytes = 1 + (size_t)ucGetByte(0, aucTmp);
-00225                 NO_DBG_DEC(tBytes);
-00226                 if (tBytes > sizeof(aucFpage)) {
-00227                         DBG_DEC(tBytes);
-00228                         tBytes = sizeof(aucFpage);
-00229                 }
-00230                 /* Read the bytes */
-00231                 if (!bReadBytes(aucFpage, tBytes, ulSectPage, pFile)) {
-00232                         continue;
-00233                 }
-00234                 NO_DBG_PRINT_BLOCK(aucFpage, tBytes);
-00235                 /* Process the bytes */
-00236                 vGetDefaultSection(&tSection);
-00237                 vGet0SectionInfo(aucFpage + 1, tBytes - 1, &tSection);
-00238                 vAdd2SectionInfoList(&tSection, ulCharPos);
-00239         }
-00240         /* Clean up before you leave */
-00241         aucBuffer = xfree(aucBuffer);
-00242 } /* end of vGet0SepInfo */
-00243 
-00244 /*
-00245  * Fill the style information block with information
-00246  * from a Word for DOS file.
-00247  */
-00248 static void
-00249 vGet0StyleInfo(int iFodo, const UCHAR *aucGrpprl, style_block_type *pStyle)
-00250 {
-00251         int     iBytes;
-00252         UCHAR   ucTmp;
-00253 
-00254         fail(iFodo <= 0 || aucGrpprl == NULL || pStyle == NULL);
-00255 
-00256         pStyle->usIstdNext = ISTD_NORMAL;
-00257 
-00258         iBytes = (int)ucGetByte(iFodo, aucGrpprl);
-00259         if (iBytes < 1) {
-00260                 return;
-00261         }
-00262         /* stc if styled */
-00263         ucTmp = ucGetByte(iFodo + 1, aucGrpprl);
-00264         if ((ucTmp & BIT(0)) != 0) {
-00265                 ucTmp >>= 1;
-00266                 if (ucTmp >= 88 && ucTmp <= 94) {
-00267                         /* Header levels 1 through 7 */
-00268                         pStyle->usIstd = ucTmp - 87;
-00269                         pStyle->ucNumLevel = 1;
-00270                 }
-00271         }
-00272         if (iBytes < 2) {
-00273                 return;
-00274         }
-00275         /* jc */
-00276         ucTmp = ucGetByte(iFodo + 2, aucGrpprl);
-00277         pStyle->ucAlignment = ucTmp & 0x02;
-00278         if (iBytes < 3) {
-00279                 return;
-00280         }
-00281         /* stc */
-00282         ucTmp = ucGetByte(iFodo + 3, aucGrpprl);
-00283         ucTmp &= 0x7f;
-00284         if (ucTmp >= 88 && ucTmp <= 94) {
-00285                 /* Header levels 1 through 7 */
-00286                 pStyle->usIstd = ucTmp - 87;
-00287                 pStyle->ucNumLevel = 1;
-00288         }
-00289         if (iBytes < 6) {
-00290                 return;
-00291         }
-00292         /* dxaRight */
-00293         pStyle->sRightIndent = (short)usGetWord(iFodo + 5, aucGrpprl);
-00294         NO_DBG_DEC(pStyle->sRightIndent);
-00295         if (iBytes < 8) {
-00296                 return;
-00297         }
-00298         /* dxaLeft */
-00299         pStyle->sLeftIndent = (short)usGetWord(iFodo + 7, aucGrpprl);
-00300         NO_DBG_DEC(pStyle->sLeftIndent);
-00301         if (iBytes < 10) {
-00302                 return;
-00303         }
-00304         /* dxaLeft1 */
-00305         pStyle->sLeftIndent1 = (short)usGetWord(iFodo + 9, aucGrpprl);
-00306         NO_DBG_DEC(pStyle->sLeftIndent1);
-00307         if (iBytes < 14) {
-00308                 return;
-00309         }
-00310         /* dyaBefore */
-00311         pStyle->usBeforeIndent = usGetWord(iFodo + 13, aucGrpprl);
-00312         NO_DBG_DEC(pStyle->usBeforeIndent);
-00313         if (iBytes < 16) {
-00314                 return;
-00315         }
-00316         /* dyaAfter */
-00317         pStyle->usAfterIndent = usGetWord(iFodo + 15, aucGrpprl);
-00318         NO_DBG_DEC(pStyle->usAfterIndent);
-00319 } /* end of vGet0StyleInfo */
-00320 
-00321 /*
-00322  * Build the lists with Paragraph Information for Word for DOS files
-00323  */
-00324 void
-00325 vGet0PapInfo(FILE *pFile, const UCHAR *aucHeader)
-00326 {
-00327         style_block_type        tStyle;
-00328         ULONG   ulBeginParfInfo, ulCharPos, ulCharPosNext;
-00329         int     iIndex, iRun, iFodo;
-00330         UCHAR   aucFpage[128];
-00331 
-00332         fail(pFile == NULL || aucHeader == NULL);
-00333 
-00334         ulBeginParfInfo = 128 * (ULONG)usGetWord(0x12, aucHeader);
-00335         NO_DBG_HEX(ulBeginParfInfo);
-00336 
-00337         do {
-00338                 if (!bReadBytes(aucFpage, 128, ulBeginParfInfo, pFile)) {
-00339                         return;
-00340                 }
-00341                 NO_DBG_PRINT_BLOCK(aucFpage, 128);
-00342                 ulCharPosNext = ulGetLong(0, aucFpage);
-00343                 iRun = (int)ucGetByte(0x7f, aucFpage);
-00344                 NO_DBG_DEC(iRun);
-00345                 for (iIndex = 0; iIndex < iRun; iIndex++) {
-00346                         iFodo = (int)usGetWord(6 * iIndex + 8, aucFpage);
-00347                         if (iFodo <= 0 || iFodo > 0x79) {
-00348                                 DBG_DEC_C(iFodo != (int)0xffff, iFodo);
-00349                                 continue;
-00350                         }
-00351                         vFillStyleFromStylesheet(0, &tStyle);
-00352                         vGet0StyleInfo(iFodo, aucFpage + 4, &tStyle);
-00353                         ulCharPos = ulCharPosNext;
-00354                         ulCharPosNext = ulGetLong(6 * iIndex + 4, aucFpage);
-00355                         tStyle.ulFileOffset = ulCharPos;
-00356                         vAdd2StyleInfoList(&tStyle);
-00357                 }
-00358                 ulBeginParfInfo += 128;
-00359         } while (ulCharPosNext == ulBeginParfInfo);
-00360 } /* end of vGet0PapInfo */
-00361 
-00362 /*
-00363  * Fill the font information block with information
-00364  * from a Word for DOS file.
-00365  */
-00366 static void
-00367 vGet0FontInfo(int iFodo, const UCHAR *aucGrpprl, font_block_type *pFont)
-00368 {
-00369         int     iBytes;
-00370         UCHAR   ucTmp;
-00371 
-00372         fail(iFodo <= 0 || aucGrpprl == NULL || pFont == NULL);
-00373 
-00374         iBytes = (int)ucGetByte(iFodo, aucGrpprl);
-00375         if (iBytes < 2) {
-00376                 return;
-00377         }
-00378         /* fBold, fItalic, cFtc */
-00379         ucTmp = ucGetByte(iFodo + 2, aucGrpprl);
-00380         if ((ucTmp & BIT(0)) != 0) {
-00381                 pFont->usFontStyle |= FONT_BOLD;
-00382         }
-00383         if ((ucTmp & BIT(1)) != 0) {
-00384                 pFont->usFontStyle |= FONT_ITALIC;
-00385         }
-00386         pFont->ucFontNumber = ucTmp >> 2;
-00387         NO_DBG_DEC(pFont->ucFontNumber);
-00388         if (iBytes < 3) {
-00389                 return;
-00390         }
-00391         /* cHps */
-00392         pFont->usFontSize = (USHORT)ucGetByte(iFodo + 3, aucGrpprl);
-00393         NO_DBG_DEC(pFont->usFontSize);
-00394         if (iBytes < 4) {
-00395                 return;
-00396         }
-00397         /* cKul, fStrike, fCaps, fSmallCaps, fVanish */
-00398         ucTmp = ucGetByte(iFodo + 4, aucGrpprl);
-00399         if ((ucTmp & BIT(0)) != 0 || (ucTmp & BIT(2)) != 0) {
-00400                 pFont->usFontStyle |= FONT_UNDERLINE;
-00401         }
-00402         if ((ucTmp & BIT(1)) != 0) {
-00403                 pFont->usFontStyle |= FONT_STRIKE;
-00404         }
-00405         if ((ucTmp & BIT(4)) != 0) {
-00406                 pFont->usFontStyle |= FONT_CAPITALS;
-00407         }
-00408         if ((ucTmp & BIT(5)) != 0) {
-00409                 pFont->usFontStyle |= FONT_SMALL_CAPITALS;
-00410         }
-00411         if ((ucTmp & BIT(7)) != 0) {
-00412                 pFont->usFontStyle |= FONT_HIDDEN;
-00413         }
-00414         DBG_HEX(pFont->usFontStyle);
-00415         if (iBytes < 6) {
-00416                 return;
-00417         }
-00418         /* cIss */
-00419         ucTmp = ucGetByte(iFodo + 6, aucGrpprl);
-00420         if (ucTmp != 0) {
-00421                 if (ucTmp < 128) {
-00422                         pFont->usFontStyle |= FONT_SUPERSCRIPT;
-00423                         DBG_MSG("Superscript");
-00424                 } else {
-00425                         pFont->usFontStyle |= FONT_SUBSCRIPT;
-00426                         DBG_MSG("Subscript");
-00427                 }
-00428         }
-00429         if (iBytes < 7) {
-00430                 return;
-00431         }
-00432         /* cIco */
-00433         ucTmp = ucGetByte(iFodo + 7, aucGrpprl);
-00434         switch (ucTmp & 0x07) {
-00435         case 0: pFont->ucFontColor = FONT_COLOR_BLACK; break;
-00436         case 1: pFont->ucFontColor = FONT_COLOR_RED; break;
-00437         case 2: pFont->ucFontColor = FONT_COLOR_GREEN; break;
-00438         case 3: pFont->ucFontColor = FONT_COLOR_BLUE; break;
-00439         case 4: pFont->ucFontColor = FONT_COLOR_CYAN; break;
-00440         case 5: pFont->ucFontColor = FONT_COLOR_MAGENTA; break;
-00441         case 6: pFont->ucFontColor = FONT_COLOR_YELLOW; break;
-00442         case 7: pFont->ucFontColor = FONT_COLOR_WHITE; break;
-00443         default:pFont->ucFontColor = FONT_COLOR_BLACK; break;
-00444         }
-00445         NO_DBG_DEC(pFont->ucFontColor);
-00446 } /* end of vGet0FontInfo */
-00447 
-00448 /*
-00449  * Build the lists with Character Information for Word for DOS files
-00450  */
-00451 void
-00452 vGet0ChrInfo(FILE *pFile, const UCHAR *aucHeader)
-00453 {
-00454         font_block_type         tFont;
-00455         ULONG   ulBeginCharInfo, ulCharPos, ulCharPosNext;
-00456         int     iIndex, iRun, iFodo;
-00457         UCHAR   aucFpage[128];
-00458 
-00459         fail(pFile == NULL || aucHeader == NULL);
-00460 
-00461         ulBeginCharInfo = ulGetLong(0x0e, aucHeader);
-00462         NO_DBG_HEX(ulBeginCharInfo);
-00463         ulBeginCharInfo = ROUND128(ulBeginCharInfo);
-00464         NO_DBG_HEX(ulBeginCharInfo);
-00465 
-00466         do {
-00467                 if (!bReadBytes(aucFpage, 128, ulBeginCharInfo, pFile)) {
-00468                         return;
-00469                 }
-00470                 NO_DBG_PRINT_BLOCK(aucFpage, 128);
-00471                 ulCharPosNext = ulGetLong(0, aucFpage);
-00472                 iRun = (int)ucGetByte(0x7f, aucFpage);
-00473                 NO_DBG_DEC(iRun);
-00474                 for (iIndex = 0; iIndex < iRun; iIndex++) {
-00475                         iFodo = (int)usGetWord(6 * iIndex + 8, aucFpage);
-00476                         if (iFodo <= 0 || iFodo > 0x79) {
-00477                                 DBG_DEC_C(iFodo != (int)0xffff, iFodo);
-00478                                 continue;
-00479                         }
-00480                         vFillFontFromStylesheet(0, &tFont);
-00481                         vGet0FontInfo(iFodo, aucFpage + 4, &tFont);
-00482                         ulCharPos = ulCharPosNext;
-00483                         ulCharPosNext = ulGetLong(6 * iIndex + 4, aucFpage);
-00484                         tFont.ulFileOffset = ulCharPos;
-00485                         vAdd2FontInfoList(&tFont);
-00486                 }
-00487                 ulBeginCharInfo += 128;
-00488         } while (ulCharPosNext == ulBeginCharInfo);
-00489 } /* end of vGet0ChrInfo */
-
-
Generated by  - -doxygen 1.6.2
- - diff -r 59758314f811 -r d4524d6a4472 Symbian3/Examples/guid-6013a680-57f9-415b-8851-c4fa63356636/prop2_8c_source.html --- a/Symbian3/Examples/guid-6013a680-57f9-415b-8851-c4fa63356636/prop2_8c_source.html Fri Jun 11 15:24:34 2010 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1083 +0,0 @@ - - - - -TB9.2 Example Applications: examples/PIPS/antiword/src/prop2.c Source File - - - - - -

examples/PIPS/antiword/src/prop2.c

00001 /*
-00002  * prop2.c
-00003  * Copyright (C) 2002-2005 A.J. van Os; Released under GPL
-00004  *
-00005  * Description:
-00006  * Read the property information from a WinWord 1 or 2 file
-00007  */
-00008 
-00009 #include <string.h>
-00010 #include "antiword.h"
-00011 
-00012 
-00013 #define MAX_FILESIZE            0x2000000UL     /* 32 Mb */
-00014 
-00015 /*
-00016  * iGet2InfoLength - the length of the information for WinWord 1/2 files
-00017  */
-00018 static int
-00019 iGet2InfoLength(int iByteNbr, const UCHAR *aucGrpprl)
-00020 {
-00021         int     iTmp, iDel, iAdd;
-00022 
-00023         switch (ucGetByte(iByteNbr, aucGrpprl)) {
-00024         case   3: case  15: case  78: case 152: case 154: case 155:
-00025                 return 2 + (int)ucGetByte(iByteNbr + 1, aucGrpprl);
-00026         case  16: case  17: case  18: case  19: case  21: case  22: case  26:
-00027         case  27: case  28: case  30: case  31: case  32: case  33: case  34:
-00028         case  35: case  36: case  38: case  39: case  40: case  41: case  42:
-00029         case  43: case  45: case  46: case  47: case  48: case  49: case  68:
-00030         case  71: case  72: case  82: case  83: case  96: case  97: case  98:
-00031         case  99: case 115: case 116: case 119: case 120: case 123: case 124:
-00032         case 129: case 130: case 131: case 132: case 135: case 136: case 139:
-00033         case 140: case 141: case 142: case 143: case 144: case 145: case 146:
-00034         case 147: case 148: case 153: case 159: case 161: case 162:
-00035                 return 1 + 2;
-00036         case  23:
-00037                 iTmp = (int)ucGetByte(iByteNbr + 1, aucGrpprl);
-00038                 if (iTmp == 255) {
-00039                         iDel = (int)ucGetByte(iByteNbr + 2, aucGrpprl);
-00040                         iAdd = (int)ucGetByte(
-00041                                         iByteNbr + 3 + iDel * 4, aucGrpprl);
-00042                         iTmp = 2 + iDel * 4 + iAdd * 3;
-00043                 }
-00044                 return 2 + iTmp;
-00045         case  70:
-00046                 return 1 + 3;
-00047         case  95:
-00048                 return 1 + 13;
-00049         case 157: case 163:
-00050                 return 1 + 5;
-00051         case 158: case 160: case 164:
-00052                 return 1 + 4;
-00053         default:
-00054                 return 1 + 1;
-00055         }
-00056 } /* end of iGet2InfoLength */
-00057 
-00058 /*
-00059  * Build the lists with Document Property Information for WinWord 1/2 files
-00060  */
-00061 void
-00062 vGet2DopInfo(FILE *pFile, const UCHAR *aucHeader)
-00063 {
-00064         document_block_type     tDocument;
-00065         UCHAR   *aucBuffer;
-00066         ULONG   ulBeginDocpInfo, ulTmp;
-00067         size_t  tDocpInfoLen;
-00068         USHORT  usTmp;
-00069 
-00070         ulBeginDocpInfo = ulGetLong(0x112, aucHeader); /* fcDop */
-00071         DBG_HEX(ulBeginDocpInfo);
-00072         tDocpInfoLen = (size_t)usGetWord(0x116, aucHeader); /* cbDop */
-00073         DBG_DEC(tDocpInfoLen);
-00074         if (tDocpInfoLen < 28) {
-00075                 DBG_MSG("No Document information");
-00076                 return;
-00077         }
-00078 
-00079         aucBuffer = xmalloc(tDocpInfoLen);
-00080         if (!bReadBytes(aucBuffer, tDocpInfoLen, ulBeginDocpInfo, pFile)) {
-00081                 aucBuffer = xfree(aucBuffer);
-00082                 return;
-00083         }
-00084 
-00085         usTmp = usGetWord(0x00, aucBuffer);
-00086         tDocument.ucHdrFtrSpecification = (UCHAR)(usTmp >> 8); /* grpfIhdt */
-00087         tDocument.usDefaultTabWidth = usGetWord(0x0a, aucBuffer); /* dxaTab */
-00088         ulTmp = ulGetLong(0x14, aucBuffer); /* dttmCreated */
-00089         tDocument.tCreateDate = tConvertDTTM(ulTmp);
-00090         ulTmp = ulGetLong(0x18, aucBuffer); /* dttmRevised */
-00091         tDocument.tRevisedDate = tConvertDTTM(ulTmp);
-00092         vCreateDocumentInfoList(&tDocument);
-00093 
-00094         aucBuffer = xfree(aucBuffer);
-00095 } /* end of vGet2DopInfo */
-00096 
-00097 /*
-00098  * Fill the section information block with information
-00099  * from a WinWord 1/2 file.
-00100  */
-00101 static void
-00102 vGet2SectionInfo(const UCHAR *aucGrpprl, size_t tBytes,
-00103                 section_block_type *pSection)
-00104 {
-00105         int     iFodoOff, iInfoLen;
-00106         USHORT  usCcol;
-00107         UCHAR   ucTmp;
-00108 
-00109         fail(aucGrpprl == NULL || pSection == NULL);
-00110 
-00111         iFodoOff = 0;
-00112         while (tBytes >= (size_t)iFodoOff + 1) {
-00113                 switch (ucGetByte(iFodoOff, aucGrpprl)) {
-00114                 case 117:       /* bkc */
-00115                         ucTmp = ucGetByte(iFodoOff + 1, aucGrpprl);
-00116                         DBG_DEC(ucTmp);
-00117                         pSection->bNewPage = ucTmp != 0 && ucTmp != 1;
-00118                         break;
-00119                 case 119:       /* ccolM1 */
-00120                         usCcol = 1 + usGetWord(iFodoOff + 1, aucGrpprl);
-00121                         DBG_DEC(usCcol);
-00122                         break;
-00123                 case 128:       /* grpfIhdt */
-00124                         pSection->ucHdrFtrSpecification =
-00125                                         ucGetByte(iFodoOff + 1, aucGrpprl);
-00126                         break;
-00127                 default:
-00128                         break;
-00129                 }
-00130                 iInfoLen = iGet2InfoLength(iFodoOff, aucGrpprl);
-00131                 fail(iInfoLen <= 0);
-00132                 iFodoOff += iInfoLen;
-00133         }
-00134 } /* end of vGet2SectionInfo */
-00135 
-00136 /*
-00137  * Build the lists with Section Property Information for WinWord 1/2 files
-00138  */
-00139 void
-00140 vGet2SepInfo(FILE *pFile, const UCHAR *aucHeader)
-00141 {
-00142         section_block_type      tSection;
-00143         ULONG   *aulSectPage, *aulCharPos;
-00144         UCHAR   *aucBuffer, *aucFpage;
-00145         ULONG   ulBeginOfText, ulTextOffset, ulBeginSectInfo;
-00146         size_t  tSectInfoLen, tIndex, tOffset, tLen, tBytes;
-00147         UCHAR   aucTmp[1];
-00148 
-00149         fail(pFile == NULL || aucHeader == NULL);
-00150 
-00151         ulBeginOfText = ulGetLong(0x18, aucHeader); /* fcMin */
-00152         NO_DBG_HEX(ulBeginOfText);
-00153         ulBeginSectInfo = ulGetLong(0x7c, aucHeader); /* fcPlcfsed */
-00154         DBG_HEX(ulBeginSectInfo);
-00155         tSectInfoLen = (size_t)usGetWord(0x80, aucHeader); /* cbPlcfsed */
-00156         DBG_DEC(tSectInfoLen);
-00157         if (tSectInfoLen < 4) {
-00158                 DBG_DEC(tSectInfoLen);
-00159                 return;
-00160         }
-00161 
-00162         aucBuffer = xmalloc(tSectInfoLen);
-00163         if (!bReadBytes(aucBuffer, tSectInfoLen, ulBeginSectInfo, pFile)) {
-00164                 aucBuffer = xfree(aucBuffer);
-00165                 return;
-00166         }
-00167         NO_DBG_PRINT_BLOCK(aucBuffer, tSectInfoLen);
-00168 
-00169         /* Read the Section Descriptors */
-00170         tLen = (tSectInfoLen - 4) / 10;
-00171         /* Save the section offsets */
-00172         aulCharPos = xcalloc(tLen, sizeof(ULONG));
-00173         for (tIndex = 0, tOffset = 0;
-00174              tIndex < tLen;
-00175              tIndex++, tOffset += 4) {
-00176                 ulTextOffset = ulGetLong(tOffset, aucBuffer);
-00177                 NO_DBG_HEX(ulTextOffset);
-00178                 aulCharPos[tIndex] = ulBeginOfText + ulTextOffset;
-00179                 NO_DBG_HEX(aulCharPos[tIndex]);
-00180         }
-00181         /* Save the Sepx offsets */
-00182         aulSectPage = xcalloc(tLen, sizeof(ULONG));
-00183         for (tIndex = 0, tOffset = (tLen + 1) * 4;
-00184              tIndex < tLen;
-00185              tIndex++, tOffset += 6) {
-00186                 aulSectPage[tIndex] = ulGetLong(tOffset + 2, aucBuffer);
-00187                 NO_DBG_HEX(aulSectPage[tIndex]); /* fcSepx */
-00188         }
-00189         aucBuffer = xfree(aucBuffer);
-00190 
-00191         /* Read the Section Properties */
-00192         for (tIndex = 0; tIndex < tLen; tIndex++) {
-00193                 if (aulSectPage[tIndex] == FC_INVALID) {
-00194                         vDefault2SectionInfoList(aulCharPos[tIndex]);
-00195                         continue;
-00196                 }
-00197                 /* Get the number of bytes to read */
-00198                 if (!bReadBytes(aucTmp, 1, aulSectPage[tIndex], pFile)) {
-00199                         continue;
-00200                 }
-00201                 tBytes = 1 + (size_t)ucGetByte(0, aucTmp);
-00202                 NO_DBG_DEC(tBytes);
-00203                 /* Read the bytes */
-00204                 aucFpage = xmalloc(tBytes);
-00205                 if (!bReadBytes(aucFpage, tBytes, aulSectPage[tIndex], pFile)) {
-00206                         aucFpage = xfree(aucFpage);
-00207                         continue;
-00208                 }
-00209                 NO_DBG_PRINT_BLOCK(aucFpage, tBytes);
-00210                 /* Process the bytes */
-00211                 vGetDefaultSection(&tSection);
-00212                 vGet2SectionInfo(aucFpage + 1, tBytes - 1, &tSection);
-00213                 vAdd2SectionInfoList(&tSection, aulCharPos[tIndex]);
-00214                 aucFpage = xfree(aucFpage);
-00215         }
-00216         aulCharPos = xfree(aulCharPos);
-00217         aulSectPage = xfree(aulSectPage);
-00218 } /* end of vGet2SepInfo */
-00219 
-00220 /*
-00221  * Build the list with Header/Footer Information for WinWord 1/2 files
-00222  */
-00223 void
-00224 vGet2HdrFtrInfo(FILE *pFile, const UCHAR *aucHeader)
-00225 {
-00226         ULONG   *aulCharPos;
-00227         UCHAR   *aucBuffer;
-00228         ULONG   ulHdrFtrOffset, ulBeginHdrFtrInfo;
-00229         size_t  tHdrFtrInfoLen, tIndex, tOffset, tLen;
-00230 
-00231         fail(pFile == NULL || aucHeader == NULL);
-00232 
-00233         ulBeginHdrFtrInfo = ulGetLong(0x9a, aucHeader); /* fcPlcfhdd */
-00234         NO_DBG_HEX(ulBeginHdrFtrInfo);
-00235         tHdrFtrInfoLen = (size_t)usGetWord(0x9e, aucHeader); /* cbPlcfhdd */
-00236         NO_DBG_DEC(tHdrFtrInfoLen);
-00237         if (tHdrFtrInfoLen < 8) {
-00238                 DBG_DEC_C(tHdrFtrInfoLen != 0, tHdrFtrInfoLen);
-00239                 return;
-00240         }
-00241 
-00242         aucBuffer = xmalloc(tHdrFtrInfoLen);
-00243         if (!bReadBytes(aucBuffer, tHdrFtrInfoLen, ulBeginHdrFtrInfo, pFile)) {
-00244                 aucBuffer = xfree(aucBuffer);
-00245                 return;
-00246         }
-00247         NO_DBG_PRINT_BLOCK(aucBuffer, tHdrFtrInfoLen);
-00248 
-00249         tLen = tHdrFtrInfoLen / 4 - 1;
-00250         /* Save the header/footer offsets */
-00251         aulCharPos = xcalloc(tLen, sizeof(ULONG));
-00252         for (tIndex = 0, tOffset = 0;
-00253              tIndex < tLen;
-00254              tIndex++, tOffset += 4) {
-00255                 ulHdrFtrOffset = ulGetLong(tOffset, aucBuffer);
-00256                 NO_DBG_HEX(ulHdrFtrOffset);
-00257                 aulCharPos[tIndex] = ulHdrFtrOffset2CharPos(ulHdrFtrOffset);
-00258                 NO_DBG_HEX(aulCharPos[tIndex]);
-00259         }
-00260         vCreat2HdrFtrInfoList(aulCharPos, tLen);
-00261         aulCharPos = xfree(aulCharPos);
-00262         aucBuffer = xfree(aucBuffer);
-00263 } /* end of vGet2HdrFtrInfo */
-00264 
-00265 /*
-00266  * Translate the rowinfo to a member of the row_info enumeration
-00267  */
-00268 row_info_enum
-00269 eGet2RowInfo(int iFodo,
-00270         const UCHAR *aucGrpprl, int iBytes, row_block_type *pRow)
-00271 {
-00272         int     iFodoOff, iInfoLen;
-00273         int     iIndex, iSize, iCol;
-00274         int     iPosCurr, iPosPrev;
-00275         USHORT  usTmp;
-00276         BOOL    bFound24_0, bFound24_1, bFound25_0, bFound25_1, bFound154;
-00277 
-00278         fail(iFodo < 0 || aucGrpprl == NULL || pRow == NULL);
-00279 
-00280         iFodoOff = 0;
-00281         bFound24_0 = FALSE;
-00282         bFound24_1 = FALSE;
-00283         bFound25_0 = FALSE;
-00284         bFound25_1 = FALSE;
-00285         bFound154 = FALSE;
-00286         while (iBytes >= iFodoOff + 1) {
-00287                 iInfoLen = 0;
-00288                 switch (ucGetByte(iFodo + iFodoOff, aucGrpprl)) {
-00289                 case  24:       /* fIntable */
-00290                         if (odd(ucGetByte(iFodo + iFodoOff + 1, aucGrpprl))) {
-00291                                 bFound24_1 = TRUE;
-00292                         } else {
-00293                                 bFound24_0 = TRUE;
-00294                         }
-00295                         break;
-00296                 case  25:       /* fTtp */
-00297                         if (odd(ucGetByte(iFodo + iFodoOff + 1, aucGrpprl))) {
-00298                                 bFound25_1 = TRUE;
-00299                         } else {
-00300                                 bFound25_0 = TRUE;
-00301                         }
-00302                         break;
-00303                 case 30:        /* brcTop10 */
-00304                         usTmp = usGetWord(iFodo + iFodoOff + 1, aucGrpprl);
-00305                         usTmp &= 0x01ff;
-00306                         NO_DBG_DEC(usTmp >> 6);
-00307                         if (usTmp == 0) {
-00308                                 pRow->ucBorderInfo &= ~TABLE_BORDER_TOP;
-00309                         } else {
-00310                                 pRow->ucBorderInfo |= TABLE_BORDER_TOP;
-00311                         }
-00312                         break;
-00313                 case 31:        /* brcLeft10 */
-00314                         usTmp = usGetWord(iFodo + iFodoOff + 1, aucGrpprl);
-00315                         usTmp &= 0x01ff;
-00316                         NO_DBG_DEC(usTmp >> 6);
-00317                         if (usTmp == 0) {
-00318                                 pRow->ucBorderInfo &= ~TABLE_BORDER_LEFT;
-00319                         } else {
-00320                                 pRow->ucBorderInfo |= TABLE_BORDER_LEFT;
-00321                         }
-00322                         break;
-00323                 case 32:        /* brcBottom10 */
-00324                         usTmp = usGetWord(iFodo + iFodoOff + 1, aucGrpprl);
-00325                         usTmp &= 0x01ff;
-00326                         NO_DBG_DEC(usTmp >> 6);
-00327                         if (usTmp == 0) {
-00328                                 pRow->ucBorderInfo &= ~TABLE_BORDER_BOTTOM;
-00329                         } else {
-00330                                 pRow->ucBorderInfo |= TABLE_BORDER_BOTTOM;
-00331                         }
-00332                         break;
-00333                 case 33:        /* brcRight10 */
-00334                         usTmp = usGetWord(iFodo + iFodoOff + 1, aucGrpprl);
-00335                         usTmp &= 0x01ff;
-00336                         NO_DBG_DEC(usTmp >> 6);
-00337                         if (usTmp == 0) {
-00338                                 pRow->ucBorderInfo &= ~TABLE_BORDER_RIGHT;
-00339                         } else {
-00340                                 pRow->ucBorderInfo |= TABLE_BORDER_RIGHT;
-00341                         }
-00342                         break;
-00343                 case 38:        /* brcTop */
-00344                         usTmp = usGetWord(iFodo + iFodoOff + 1, aucGrpprl);
-00345                         usTmp &= 0x0018;
-00346                         NO_DBG_DEC(usTmp >> 3);
-00347                         if (usTmp == 0) {
-00348                                 pRow->ucBorderInfo &= ~TABLE_BORDER_TOP;
-00349                         } else {
-00350                                 pRow->ucBorderInfo |= TABLE_BORDER_TOP;
-00351                         }
-00352                         break;
-00353                 case 39:        /* brcLeft */
-00354                         usTmp = usGetWord(iFodo + iFodoOff + 1, aucGrpprl);
-00355                         usTmp &= 0x0018;
-00356                         NO_DBG_DEC(usTmp >> 3);
-00357                         if (usTmp == 0) {
-00358                                 pRow->ucBorderInfo &= ~TABLE_BORDER_LEFT;
-00359                         } else {
-00360                                 pRow->ucBorderInfo |= TABLE_BORDER_LEFT;
-00361                         }
-00362                         break;
-00363                 case 40:        /* brcBottom */
-00364                         usTmp = usGetWord(iFodo + iFodoOff + 1, aucGrpprl);
-00365                         usTmp &= 0x0018;
-00366                         NO_DBG_DEC(usTmp >> 3);
-00367                         if (usTmp == 0) {
-00368                                 pRow->ucBorderInfo &= ~TABLE_BORDER_BOTTOM;
-00369                         } else {
-00370                                 pRow->ucBorderInfo |= TABLE_BORDER_BOTTOM;
-00371                         }
-00372                         break;
-00373                 case 41:        /* brcRight */
-00374                         usTmp = usGetWord(iFodo + iFodoOff + 1, aucGrpprl);
-00375                         usTmp &= 0x0018;
-00376                         NO_DBG_DEC(usTmp >> 3);
-00377                         if (usTmp == 0) {
-00378                                 pRow->ucBorderInfo &= ~TABLE_BORDER_RIGHT;
-00379                         } else {
-00380                                 pRow->ucBorderInfo |= TABLE_BORDER_RIGHT;
-00381                         }
-00382                         break;
-00383                 case 152:       /* cDefTable10 */
-00384                 case 154:       /* cDefTable */
-00385                         iSize = (int)usGetWord(iFodo + iFodoOff + 1, aucGrpprl);
-00386                         if (iSize < 6 || iBytes < iFodoOff + 7) {
-00387                                 DBG_DEC(iSize);
-00388                                 DBG_DEC(iBytes);
-00389                                 DBG_DEC(iFodoOff);
-00390                                 iInfoLen = 1;
-00391                                 break;
-00392                         }
-00393                         iCol = (int)ucGetByte(iFodo + iFodoOff + 3, aucGrpprl);
-00394                         if (iCol < 1 ||
-00395                             iBytes < iFodoOff + 3 + (iCol + 1) * 2) {
-00396                                 DBG_DEC(iCol);
-00397                                 DBG_DEC(iBytes);
-00398                                 DBG_DEC(iFodoOff);
-00399                                 DBG_DEC(ucGetByte(iFodo + iFodoOff, aucGrpprl));
-00400                                 iInfoLen = 1;
-00401                                 break;
-00402                         }
-00403                         if (iCol >= (int)elementsof(pRow->asColumnWidth)) {
-00404                                 DBG_DEC(iCol);
-00405                                 werr(1, "The number of columns is corrupt");
-00406                         }
-00407                         pRow->ucNumberOfColumns = (UCHAR)iCol;
-00408                         iPosPrev = (int)(short)usGetWord(
-00409                                         iFodo + iFodoOff + 4,
-00410                                         aucGrpprl);
-00411                         for (iIndex = 0; iIndex < iCol; iIndex++) {
-00412                                 iPosCurr = (int)(short)usGetWord(
-00413                                         iFodo + iFodoOff + 6 + iIndex * 2,
-00414                                         aucGrpprl);
-00415                                 pRow->asColumnWidth[iIndex] =
-00416                                                 (short)(iPosCurr - iPosPrev);
-00417                                 iPosPrev = iPosCurr;
-00418                         }
-00419                         bFound154 = TRUE;
-00420                         break;
-00421                 default:
-00422                         break;
-00423                 }
-00424                 if (iInfoLen <= 0) {
-00425                         iInfoLen =
-00426                                 iGet2InfoLength(iFodo + iFodoOff, aucGrpprl);
-00427                         fail(iInfoLen <= 0);
-00428                 }
-00429                 iFodoOff += iInfoLen;
-00430         }
-00431         if (bFound24_1 && bFound25_1 && bFound154) {
-00432                 return found_end_of_row;
-00433         }
-00434         if (bFound24_0 && bFound25_0 && !bFound154) {
-00435                 return found_not_end_of_row;
-00436         }
-00437         if (bFound24_1) {
-00438                 return found_a_cell;
-00439         }
-00440         if (bFound24_0) {
-00441                 return found_not_a_cell;
-00442         }
-00443         return found_nothing;
-00444 } /* end of eGet2RowInfo */
-00445 
-00446 /*
-00447  * Fill the style information block with information
-00448  * from a WinWord 1/2 file.
-00449  */
-00450 void
-00451 vGet2StyleInfo(int iFodo,
-00452         const UCHAR *aucGrpprl, int iBytes, style_block_type *pStyle)
-00453 {
-00454         int     iFodoOff, iInfoLen;
-00455         int     iTmp, iDel, iAdd;
-00456         short   sTmp;
-00457         UCHAR   ucTmp;
-00458 
-00459         fail(iFodo < 0 || aucGrpprl == NULL || pStyle == NULL);
-00460 
-00461         NO_DBG_DEC(pStyle->usIstd);
-00462 
-00463         iFodoOff = 0;
-00464         while (iBytes >= iFodoOff + 1) {
-00465                 iInfoLen = 0;
-00466                 switch (ucGetByte(iFodo + iFodoOff, aucGrpprl)) {
-00467                 case   2:       /* istd */
-00468                         sTmp = (short)ucGetByte(
-00469                                         iFodo + iFodoOff + 1, aucGrpprl);
-00470                         NO_DBG_DEC(sTmp);
-00471                         break;
-00472                 case   5:       /* jc */
-00473                         pStyle->ucAlignment = ucGetByte(
-00474                                         iFodo + iFodoOff + 1, aucGrpprl);
-00475                         break;
-00476                 case  12:       /* nfcSeqNumb */
-00477                         pStyle->ucNFC = ucGetByte(
-00478                                         iFodo + iFodoOff + 1, aucGrpprl);
-00479                         break;
-00480                 case  13:       /* nLvlAnm */
-00481                         ucTmp = ucGetByte(iFodo + iFodoOff + 1, aucGrpprl);
-00482                         pStyle->ucNumLevel = ucTmp;
-00483                         pStyle->bNumPause =
-00484                                 eGetNumType(ucTmp) == level_type_pause;
-00485                         break;
-00486                 case  15:       /* ChgTabsPapx */
-00487                 case  23:       /* ChgTabs */
-00488                         iTmp = (int)ucGetByte(iFodo + iFodoOff + 1, aucGrpprl);
-00489                         if (iTmp < 2) {
-00490                                 iInfoLen = 1;
-00491                                 break;
-00492                         }
-00493                         NO_DBG_DEC(iTmp);
-00494                         iDel = (int)ucGetByte(iFodo + iFodoOff + 2, aucGrpprl);
-00495                         if (iTmp < 2 + 2 * iDel) {
-00496                                 iInfoLen = 1;
-00497                                 break;
-00498                         }
-00499                         NO_DBG_DEC(iDel);
-00500                         iAdd = (int)ucGetByte(
-00501                                 iFodo + iFodoOff + 3 + 2 * iDel, aucGrpprl);
-00502                         if (iTmp < 2 + 2 * iDel + 2 * iAdd) {
-00503                                 iInfoLen = 1;
-00504                                 break;
-00505                         }
-00506                         NO_DBG_DEC(iAdd);
-00507                         break;
-00508                 case  16:       /* dxaRight */
-00509                         pStyle->sRightIndent = (short)usGetWord(
-00510                                         iFodo + iFodoOff + 1, aucGrpprl);
-00511                         NO_DBG_DEC(pStyle->sRightIndent);
-00512                         break;
-00513                 case  17:       /* dxaLeft */
-00514                         pStyle->sLeftIndent = (short)usGetWord(
-00515                                         iFodo + iFodoOff + 1, aucGrpprl);
-00516                         NO_DBG_DEC(pStyle->sLeftIndent);
-00517                         break;
-00518                 case  18:       /* Nest dxaLeft */
-00519                         sTmp = (short)usGetWord(
-00520                                         iFodo + iFodoOff + 1, aucGrpprl);
-00521                         pStyle->sLeftIndent += sTmp;
-00522                         if (pStyle->sLeftIndent < 0) {
-00523                                 pStyle->sLeftIndent = 0;
-00524                         }
-00525                         NO_DBG_DEC(sTmp);
-00526                         NO_DBG_DEC(pStyle->sLeftIndent);
-00527                         break;
-00528                 case  19:       /* dxaLeft1 */
-00529                         pStyle->sLeftIndent1 = (short)usGetWord(
-00530                                         iFodo + iFodoOff + 1, aucGrpprl);
-00531                         NO_DBG_DEC(pStyle->sLeftIndent1);
-00532                         break;
-00533                 case  21:       /* dyaBefore */
-00534                         pStyle->usBeforeIndent = usGetWord(
-00535                                         iFodo + iFodoOff + 1, aucGrpprl);
-00536                         NO_DBG_DEC(pStyle->usBeforeIndent);
-00537                         break;
-00538                 case  22:       /* dyaAfter */
-00539                         pStyle->usAfterIndent = usGetWord(
-00540                                         iFodo + iFodoOff + 1, aucGrpprl);
-00541                         NO_DBG_DEC(pStyle->usAfterIndent);
-00542                         break;
-00543                 default:
-00544                         break;
-00545                 }
-00546                 if (iInfoLen <= 0) {
-00547                         iInfoLen =
-00548                                 iGet2InfoLength(iFodo + iFodoOff, aucGrpprl);
-00549                         fail(iInfoLen <= 0);
-00550                 }
-00551                 iFodoOff += iInfoLen;
-00552         }
-00553 } /* end of vGet2StyleInfo */
-00554 
-00555 /*
-00556  * Build the lists with Paragraph Information for WinWord 1/2 files
-00557  */
-00558 void
-00559 vGet2PapInfo(FILE *pFile, const UCHAR *aucHeader)
-00560 {
-00561         row_block_type          tRow;
-00562         style_block_type        tStyle;
-00563         USHORT  *ausParfPage;
-00564         UCHAR   *aucBuffer;
-00565         ULONG   ulCharPos, ulCharPosFirst, ulCharPosLast;
-00566         ULONG   ulBeginParfInfo;
-00567         size_t  tParfInfoLen, tParfPageNum, tOffset, tSize, tLenOld, tLen;
-00568         int     iIndex, iIndex2, iRun, iFodo, iLen;
-00569         row_info_enum   eRowInfo;
-00570         USHORT  usParfFirstPage, usCount, usIstd;
-00571         UCHAR   ucStc;
-00572         UCHAR   aucFpage[BIG_BLOCK_SIZE];
-00573 
-00574         fail(pFile == NULL || aucHeader == NULL);
-00575 
-00576         ulBeginParfInfo = ulGetLong(0xa6, aucHeader); /* fcPlcfbtePapx */
-00577         NO_DBG_HEX(ulBeginParfInfo);
-00578         tParfInfoLen = (size_t)usGetWord(0xaa, aucHeader); /* cbPlcfbtePapx */
-00579         NO_DBG_DEC(tParfInfoLen);
-00580         if (tParfInfoLen < 4) {
-00581                 DBG_DEC(tParfInfoLen);
-00582                 return;
-00583         }
-00584 
-00585         aucBuffer = xmalloc(tParfInfoLen);
-00586         if (!bReadBytes(aucBuffer, tParfInfoLen, ulBeginParfInfo, pFile)) {
-00587                 aucBuffer = xfree(aucBuffer);
-00588                 return;
-00589         }
-00590         NO_DBG_PRINT_BLOCK(aucBuffer, tParfInfoLen);
-00591 
-00592         tLen = (tParfInfoLen - 4) / 6;
-00593         ausParfPage = xcalloc(tLen, sizeof(USHORT));
-00594         for (iIndex = 0, tOffset = (tLen + 1) * 4;
-00595              iIndex < (int)tLen;
-00596              iIndex++, tOffset += 2) {
-00597                 ausParfPage[iIndex] = usGetWord(tOffset, aucBuffer);
-00598                 NO_DBG_DEC(ausParfPage[iIndex]);
-00599         }
-00600         DBG_HEX(ulGetLong(0, aucBuffer));
-00601         aucBuffer = xfree(aucBuffer);
-00602         tParfPageNum = (size_t)usGetWord(0x144, aucHeader); /* cpnBtePap */
-00603         DBG_DEC(tParfPageNum);
-00604         if (tLen < tParfPageNum) {
-00605                 /* Replace ParfPage by a longer version */
-00606                 tLenOld = tLen;
-00607                 usParfFirstPage = usGetWord(0x140, aucHeader); /* pnPapFirst */
-00608                 DBG_DEC(usParfFirstPage);
-00609                 tLen += tParfPageNum - 1;
-00610                 tSize = tLen * sizeof(USHORT);
-00611                 ausParfPage = xrealloc(ausParfPage, tSize);
-00612                 /* Add new values */
-00613                 usCount = usParfFirstPage + 1;
-00614                 for (iIndex = (int)tLenOld; iIndex < (int)tLen; iIndex++) {
-00615                         ausParfPage[iIndex] = usCount;
-00616                         NO_DBG_DEC(ausParfPage[iIndex]);
-00617                         usCount++;
-00618                 }
-00619         }
-00620 
-00621         (void)memset(&tRow, 0, sizeof(tRow));
-00622         ulCharPosFirst = CP_INVALID;
-00623         for (iIndex = 0; iIndex < (int)tLen; iIndex++) {
-00624                 if (!bReadBytes(aucFpage, BIG_BLOCK_SIZE,
-00625                                 (ULONG)ausParfPage[iIndex] * BIG_BLOCK_SIZE,
-00626                                 pFile)) {
-00627                         break;
-00628                 }
-00629                 NO_DBG_PRINT_BLOCK(aucFpage, BIG_BLOCK_SIZE);
-00630                 iRun = (int)ucGetByte(0x1ff, aucFpage);
-00631                 NO_DBG_DEC(iRun);
-00632                 for (iIndex2 = 0; iIndex2 < iRun; iIndex2++) {
-00633                         if ((iRun + 1) * 4 + iIndex2 * 1 >= BIG_BLOCK_SIZE) {
-00634                                 break;
-00635                         }
-00636                         NO_DBG_HEX(ulGetLong(iIndex2 * 4, aucFpage));
-00637                         iFodo = 2 * (int)ucGetByte(
-00638                                 (iRun + 1) * 4 + iIndex2 * 1, aucFpage);
-00639                         if (iFodo <= 0) {
-00640                                 continue;
-00641                         }
-00642 
-00643                         iLen = 2 * (int)ucGetByte(iFodo, aucFpage);
-00644 
-00645                         ucStc = ucGetByte(iFodo + 1, aucFpage);
-00646                         usIstd = usStc2istd(ucStc);
-00647 
-00648                         vFillStyleFromStylesheet(usIstd, &tStyle);
-00649                         vGet2StyleInfo(iFodo, aucFpage + 8, iLen - 8, &tStyle);
-00650                         ulCharPos = ulGetLong(iIndex2 * 4, aucFpage);
-00651                         NO_DBG_HEX(ulCharPos);
-00652                         tStyle.ulFileOffset = ulCharPos;
-00653                         vAdd2StyleInfoList(&tStyle);
-00654 
-00655                         eRowInfo = eGet2RowInfo(iFodo,
-00656                                         aucFpage + 8, iLen - 8, &tRow);
-00657 
-00658                         switch(eRowInfo) {
-00659                         case found_a_cell:
-00660                                 if (ulCharPosFirst != CP_INVALID) {
-00661                                         break;
-00662                                 }
-00663                                 ulCharPosFirst = ulGetLong(
-00664                                                 iIndex2 * 4, aucFpage);
-00665                                 NO_DBG_HEX(ulCharPosFirst);
-00666                                 tRow.ulCharPosStart = ulCharPosFirst;
-00667                                 tRow.ulFileOffsetStart = ulCharPosFirst;
-00668                                 break;
-00669                         case found_end_of_row:
-00670                                 ulCharPosLast = ulGetLong(
-00671                                                 iIndex2 * 4, aucFpage);
-00672                                 NO_DBG_HEX(ulCharPosLast);
-00673                                 tRow.ulCharPosEnd = ulCharPosLast;
-00674                                 /* Add 1 for compatiblity with Word 6 and up */
-00675                                 tRow.ulFileOffsetEnd = ulCharPosLast + 1;
-00676                                 vAdd2RowInfoList(&tRow);
-00677                                 (void)memset(&tRow, 0, sizeof(tRow));
-00678                                 ulCharPosFirst = CP_INVALID;
-00679                                 break;
-00680                         case found_nothing:
-00681                                 break;
-00682                         default:
-00683                                 DBG_DEC(eRowInfo);
-00684                                 break;
-00685                         }
-00686                 }
-00687         }
-00688         ausParfPage = xfree(ausParfPage);
-00689 } /* end of vGet2PapInfo */
-00690 
-00691 /*
-00692  * Fill the font information block with information
-00693  * from a WinWord 1 file.
-00694  */
-00695 void
-00696 vGet1FontInfo(int iFodo,
-00697         const UCHAR *aucGrpprl, size_t tBytes, font_block_type *pFont)
-00698 {
-00699         BOOL    bIcoChange, bFtcChange, bHpsChange, bKulChange;
-00700         USHORT  usTmp;
-00701         UCHAR   ucTmp;
-00702         UCHAR   aucChpx[12];
-00703 
-00704         fail(iFodo < 0 || aucGrpprl == NULL || pFont == NULL);
-00705 
-00706         if (tBytes > sizeof(aucChpx)) {
-00707                 NO_DBG_PRINT_BLOCK(aucGrpprl + iFodo, tBytes);
-00708                 return;
-00709         }
-00710 
-00711         /* Build the CHPX structure */
-00712         (void)memset(aucChpx, 0, sizeof(aucChpx));
-00713         (void)memcpy(aucChpx, aucGrpprl + iFodo, min(tBytes, sizeof(aucChpx)));
-00714 
-00715         usTmp = usGetWord(0, aucChpx);
-00716         if ((usTmp & BIT(0)) != 0) {
-00717                 pFont->usFontStyle ^= FONT_BOLD;
-00718         }
-00719         if ((usTmp & BIT(1)) != 0) {
-00720                 pFont->usFontStyle ^= FONT_ITALIC;
-00721         }
-00722         if ((usTmp & BIT(2)) != 0) {
-00723                 pFont->usFontStyle ^= FONT_STRIKE;
-00724         }
-00725         if ((usTmp & BIT(5)) != 0) {
-00726                 pFont->usFontStyle ^= FONT_SMALL_CAPITALS;
-00727         }
-00728         if ((usTmp & BIT(6)) != 0) {
-00729                 pFont->usFontStyle ^= FONT_CAPITALS;
-00730         }
-00731         if ((usTmp & BIT(7)) != 0) {
-00732                 pFont->usFontStyle ^= FONT_HIDDEN;
-00733         }
-00734 
-00735         ucTmp = ucGetByte(5, aucChpx);
-00736         if (ucTmp != 0) {
-00737                 if (ucTmp < 128) {
-00738                         pFont->usFontStyle |= FONT_SUPERSCRIPT;
-00739                         DBG_MSG("Superscript");
-00740                 } else {
-00741                         pFont->usFontStyle |= FONT_SUBSCRIPT;
-00742                         DBG_MSG("Subscript");
-00743                 }
-00744         }
-00745 
-00746         bIcoChange = (usTmp & BIT(10)) != 0;
-00747         bFtcChange = (usTmp & BIT(11)) != 0;
-00748         bHpsChange = (usTmp & BIT(12)) != 0;
-00749         bKulChange = (usTmp & BIT(13)) != 0;
-00750 
-00751         if (bFtcChange) {
-00752                 usTmp = usGetWord(2, aucChpx);
-00753                 if (usTmp <= (USHORT)UCHAR_MAX) {
-00754                         pFont->ucFontNumber = (UCHAR)usTmp;
-00755                 } else {
-00756                         pFont->ucFontNumber = 0;
-00757                 }
-00758         }
-00759 
-00760         if (bHpsChange) {
-00761                 pFont->usFontSize = (USHORT)ucGetByte(4, aucChpx);
-00762         }
-00763 
-00764         if (bIcoChange || bKulChange) {
-00765                 usTmp = usGetWord(6, aucChpx);
-00766                 if (bIcoChange) {
-00767                         pFont->ucFontColor = (UCHAR)((usTmp & 0x0f00) >> 8);
-00768                         if (pFont->ucFontColor <= 7) {
-00769                                 /* Add 1 for compatibility with Word 2 and up */
-00770                                 pFont->ucFontColor++;
-00771                         } else {
-00772                                 DBG_DEC(pFont->ucFontColor);
-00773                                 pFont->ucFontColor = 0;
-00774                         }
-00775                 }
-00776                 if (bKulChange) {
-00777                         usTmp = (usTmp & 0x7000) >> 12;
-00778                         DBG_DEC_C(usTmp > 4, usTmp);
-00779                         if (usTmp == 0) {
-00780                                 pFont->usFontStyle &= ~FONT_UNDERLINE;
-00781                         } else {
-00782                                 pFont->usFontStyle |= FONT_UNDERLINE;
-00783                         }
-00784                 }
-00785         }
-00786 } /* end of vGet1FontInfo */
-00787 
-00788 /*
-00789  * Fill the font information block with information
-00790  * from a WinWord 1/2 file.
-00791  */
-00792 void
-00793 vGet2FontInfo(int iFodo,
-00794         const UCHAR *aucGrpprl, size_t tBytes, font_block_type *pFont)
-00795 {
-00796         BOOL    bIcoChange, bFtcChange, bHpsChange, bKulChange;
-00797         USHORT  usTmp;
-00798         UCHAR   ucTmp;
-00799         UCHAR   aucChpx[18];
-00800 
-00801         fail(iFodo < 0 || aucGrpprl == NULL || pFont == NULL);
-00802 
-00803         if (tBytes > sizeof(aucChpx)) {
-00804                 NO_DBG_PRINT_BLOCK(aucGrpprl + iFodo, tBytes);
-00805                 return;
-00806         }
-00807 
-00808         /* Build the CHPX structure */
-00809         (void)memset(aucChpx, 0, sizeof(aucChpx));
-00810         (void)memcpy(aucChpx, aucGrpprl + iFodo, min(tBytes, sizeof(aucChpx)));
-00811 
-00812         usTmp = usGetWord(0, aucChpx);
-00813         if ((usTmp & BIT(0)) != 0) {
-00814                 pFont->usFontStyle ^= FONT_BOLD;
-00815         }
-00816         if ((usTmp & BIT(1)) != 0) {
-00817                 pFont->usFontStyle ^= FONT_ITALIC;
-00818         }
-00819         if (usTmp & BIT(3)) {
-00820                 pFont->usFontStyle ^= FONT_MARKDEL;
-00821         }
-00822         if ((usTmp & BIT(5)) != 0) {
-00823                 pFont->usFontStyle ^= FONT_SMALL_CAPITALS;
-00824         }
-00825         if ((usTmp & BIT(6)) != 0) {
-00826                 pFont->usFontStyle ^= FONT_CAPITALS;
-00827         }
-00828         if ((usTmp & BIT(7)) != 0) {
-00829                 pFont->usFontStyle ^= FONT_HIDDEN;
-00830         }
-00831         if (usTmp & BIT(10)) {
-00832                 pFont->usFontStyle ^= FONT_STRIKE;
-00833         }
-00834 
-00835         ucTmp = ucGetByte(10, aucChpx);
-00836         DBG_MSG_C(ucTmp != 0 && ucTmp < 128, "Superscript");
-00837         DBG_MSG_C(ucTmp >= 128, "Subscript");
-00838 
-00839         usTmp = usGetWord(2, aucChpx);
-00840         if (usTmp == 0) {
-00841                 /* No changes, nothing to do */
-00842                 return;
-00843         }
-00844 
-00845         bIcoChange = (usTmp & BIT(0)) != 0;
-00846         bFtcChange = (usTmp & BIT(1)) != 0;
-00847         bHpsChange = (usTmp & BIT(2)) != 0;
-00848         bKulChange = (usTmp & BIT(3)) != 0;
-00849 
-00850         if (bFtcChange) {
-00851                 usTmp = usGetWord(4, aucChpx);
-00852                 if (usTmp <= (USHORT)UCHAR_MAX) {
-00853                         pFont->ucFontNumber = (UCHAR)usTmp;
-00854                 } else {
-00855                         pFont->ucFontNumber = 0;
-00856                 }
-00857         }
-00858 
-00859         if (bHpsChange) {
-00860                 pFont->usFontSize = usGetWord(6, aucChpx);
-00861         }
-00862 
-00863         if (bIcoChange || bKulChange) {
-00864                 ucTmp = ucGetByte(9, aucChpx);
-00865                 if (bIcoChange) {
-00866                         pFont->ucFontColor = ucTmp & 0x1f;
-00867                         if (pFont->ucFontColor > 16) {
-00868                                 DBG_DEC(pFont->ucFontColor);
-00869                                 pFont->ucFontColor = 0;
-00870                         }
-00871                 }
-00872                 if (bKulChange) {
-00873                         ucTmp = (ucTmp & 0xe0) >> 5;
-00874                         DBG_DEC_C(ucTmp > 4, ucTmp);
-00875                         if (ucTmp == 0) {
-00876                                 pFont->usFontStyle &= ~FONT_UNDERLINE;
-00877                         } else {
-00878                                 pFont->usFontStyle |= FONT_UNDERLINE;
-00879                         }
-00880                 }
-00881         }
-00882 } /* end of vGet2FontInfo */
-00883 
-00884 /*
-00885  * Fill the picture information block with information from a WinWord 1 file.
-00886  * Returns TRUE when successful, otherwise FALSE
-00887  */
-00888 static BOOL
-00889 bGet1PicInfo(int iFodo,
-00890         const UCHAR *aucGrpprl, size_t tBytes, picture_block_type *pPicture)
-00891 {
-00892         ULONG   ulTmp;
-00893         UCHAR   aucChpx[12];
-00894 
-00895         fail(iFodo < 0 || aucGrpprl == NULL || pPicture == NULL);
-00896 
-00897         if (tBytes > sizeof(aucChpx)) {
-00898                 NO_DBG_PRINT_BLOCK(aucGrpprl + iFodo, tBytes);
-00899                 tBytes = sizeof(aucChpx);
-00900         }
-00901 
-00902         /* Build the CHPX structure */
-00903         (void)memset(aucChpx, 0, sizeof(aucChpx));
-00904         (void)memcpy(aucChpx, aucGrpprl + iFodo, min(tBytes, sizeof(aucChpx)));
-00905 
-00906         ulTmp = ulGetLong(8, aucChpx);
-00907         if (ulTmp != 0 && ulTmp < MAX_FILESIZE) {
-00908                 pPicture->ulPictureOffset = ulTmp;
-00909                 DBG_HEX(pPicture->ulPictureOffset);
-00910                 return TRUE;
-00911         }
-00912         return FALSE;
-00913 } /* end of bGet1PicInfo */
-00914 
-00915 /*
-00916  * Fill the picture information block with information from a WinWord 2 file.
-00917  * Returns TRUE when successful, otherwise FALSE
-00918  */
-00919 static BOOL
-00920 bGet2PicInfo(int iFodo,
-00921         const UCHAR *aucGrpprl, size_t tBytes, picture_block_type *pPicture)
-00922 {
-00923         ULONG   ulTmp;
-00924         UCHAR   aucChpx[18];
-00925 
-00926         fail(iFodo < 0 || aucGrpprl == NULL || pPicture == NULL);
-00927 
-00928         if (tBytes > sizeof(aucChpx)) {
-00929                 NO_DBG_PRINT_BLOCK(aucGrpprl + iFodo, tBytes);
-00930                 tBytes = sizeof(aucChpx);
-00931         }
-00932 
-00933         /* Build the CHPX structure */
-00934         (void)memset(aucChpx, 0, sizeof(aucChpx));
-00935         (void)memcpy(aucChpx, aucGrpprl + iFodo, min(tBytes, sizeof(aucChpx)));
-00936 
-00937         ulTmp = ulGetLong(14, aucChpx);
-00938         if (ulTmp != 0 && ulTmp < MAX_FILESIZE) {
-00939                 pPicture->ulPictureOffset = ulTmp;
-00940                 DBG_HEX(pPicture->ulPictureOffset);
-00941                 DBG_DEC(tBytes);
-00942                 return TRUE;
-00943         }
-00944         return FALSE;
-00945 } /* end of bGet2PicInfo */
-00946 
-00947 /*
-00948  * Build the lists with Character Information for WinWord 1/2 files
-00949  */
-00950 void
-00951 vGet2ChrInfo(FILE *pFile, int iWordVersion, const UCHAR *aucHeader)
-00952 {
-00953         font_block_type         tFont;
-00954         picture_block_type      tPicture;
-00955         USHORT  *ausCharPage;
-00956         UCHAR   *aucBuffer;
-00957         ULONG   ulFileOffset, ulCharPos, ulBeginCharInfo;
-00958         size_t  tCharInfoLen, tOffset, tSize, tChrLen, tCharPageNum;
-00959         size_t  tLenOld, tLen;
-00960         int     iIndex, iIndex2, iRun, iFodo;
-00961         BOOL    bSuccess1, bSuccess2;
-00962         USHORT  usCharFirstPage, usCount, usIstd;
-00963         UCHAR   aucFpage[BIG_BLOCK_SIZE];
-00964 
-00965         fail(pFile == NULL || aucHeader == NULL);
-00966         fail(iWordVersion != 1 && iWordVersion != 2);
-00967 
-00968         ulBeginCharInfo = ulGetLong(0xa0, aucHeader); /* fcPlcfbteChpx */
-00969         DBG_HEX(ulBeginCharInfo);
-00970         tCharInfoLen = (size_t)usGetWord(0xa4, aucHeader); /* cbPlcfbteChpx */
-00971         DBG_DEC(tCharInfoLen);
-00972         if (tCharInfoLen < 4) {
-00973                 DBG_DEC(tCharInfoLen);
-00974                 return;
-00975         }
-00976 
-00977         aucBuffer = xmalloc(tCharInfoLen);
-00978         if (!bReadBytes(aucBuffer, tCharInfoLen, ulBeginCharInfo, pFile)) {
-00979                 aucBuffer = xfree(aucBuffer);
-00980                 return;
-00981         }
-00982         NO_DBG_PRINT_BLOCK(aucBuffer, tCharInfoLen);
-00983 
-00984         tLen = (tCharInfoLen - 4) / 6;
-00985         ausCharPage = xcalloc(tLen, sizeof(USHORT));
-00986         for (iIndex = 0, tOffset = (tLen + 1) * 4;
-00987              iIndex < (int)tLen;
-00988              iIndex++, tOffset += 2) {
-00989                 ausCharPage[iIndex] = usGetWord(tOffset, aucBuffer);
-00990                 NO_DBG_DEC(ausCharPage[iIndex]);
-00991         }
-00992         DBG_HEX(ulGetLong(0, aucBuffer));
-00993         aucBuffer = xfree(aucBuffer);
-00994         tCharPageNum = (size_t)usGetWord(0x142, aucHeader); /* cpnBteChp */
-00995         DBG_DEC(tCharPageNum);
-00996         if (tLen < tCharPageNum) {
-00997                 /* Replace CharPage by a longer version */
-00998                 tLenOld = tLen;
-00999                 usCharFirstPage = usGetWord(0x13e, aucHeader); /* pnChrFirst */
-01000                 NO_DBG_DEC(usCharFirstPage);
-01001                 tLen += tCharPageNum - 1;
-01002                 tSize = tLen * sizeof(USHORT);
-01003                 ausCharPage = xrealloc(ausCharPage, tSize);
-01004                 /* Add new values */
-01005                 usCount = usCharFirstPage + 1;
-01006                 for (iIndex = (int)tLenOld; iIndex < (int)tLen; iIndex++) {
-01007                         ausCharPage[iIndex] = usCount;
-01008                         NO_DBG_DEC(ausCharPage[iIndex]);
-01009                         usCount++;
-01010                 }
-01011         }
-01012 
-01013         for (iIndex = 0; iIndex < (int)tLen; iIndex++) {
-01014                 if (!bReadBytes(aucFpage, BIG_BLOCK_SIZE,
-01015                                 (ULONG)ausCharPage[iIndex] * BIG_BLOCK_SIZE,
-01016                                 pFile)) {
-01017                         break;
-01018                 }
-01019                 NO_DBG_PRINT_BLOCK(aucFpage, BIG_BLOCK_SIZE);
-01020                 iRun = (int)ucGetByte(0x1ff, aucFpage);
-01021                 NO_DBG_DEC(iRun);
-01022                 for (iIndex2 = 0; iIndex2 < iRun; iIndex2++) {
-01023                         if ((iRun + 1) * 4 + iIndex2 >= BIG_BLOCK_SIZE) {
-01024                                 break;
-01025                         }
-01026                         ulCharPos = ulGetLong(iIndex2 * 4, aucFpage);
-01027                         ulFileOffset = ulCharPos;
-01028                         iFodo = 2 * (int)ucGetByte(
-01029                                 (iRun + 1) * 4 + iIndex2, aucFpage);
-01030 
-01031                         tChrLen = (size_t)ucGetByte(iFodo, aucFpage);
-01032 
-01033                         usIstd = usGetIstd(ulFileOffset);
-01034                         vFillFontFromStylesheet(usIstd, &tFont);
-01035                         if (iFodo != 0) {
-01036                                 if (iWordVersion == 1) {
-01037                                         vGet1FontInfo(iFodo,
-01038                                                 aucFpage + 1, tChrLen, &tFont);
-01039                                 } else if (iWordVersion == 2) {
-01040                                         vGet2FontInfo(iFodo,
-01041                                                 aucFpage + 1, tChrLen, &tFont);
-01042                                 }
-01043                         }
-01044                         tFont.ulFileOffset = ulFileOffset;
-01045                         vAdd2FontInfoList(&tFont);
-01046 
-01047                         if (iFodo <= 0) {
-01048                                 continue;
-01049                         }
-01050 
-01051                         (void)memset(&tPicture, 0, sizeof(tPicture));
-01052                         bSuccess1 = iWordVersion == 1 &&
-01053                                         bGet1PicInfo(iFodo, aucFpage + 1,
-01054                                                 tChrLen, &tPicture);
-01055                         bSuccess2 = iWordVersion == 2 &&
-01056                                         bGet2PicInfo(iFodo, aucFpage + 1,
-01057                                                 tChrLen, &tPicture);
-01058                         if (bSuccess1 || bSuccess2) {
-01059                                 tPicture.ulFileOffset = ulFileOffset;
-01060                                 tPicture.ulFileOffsetPicture =
-01061                                                 tPicture.ulPictureOffset;
-01062                                 vAdd2PictInfoList(&tPicture);
-01063                         }
-01064                 }
-01065         }
-01066         ausCharPage = xfree(ausCharPage);
-01067 } /* end of vGet2ChrInfo */
-
-
Generated by  - -doxygen 1.6.2
- - diff -r 59758314f811 -r d4524d6a4472 Symbian3/Examples/guid-6013a680-57f9-415b-8851-c4fa63356636/prop6_8c_source.html --- a/Symbian3/Examples/guid-6013a680-57f9-415b-8851-c4fa63356636/prop6_8c_source.html Fri Jun 11 15:24:34 2010 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1157 +0,0 @@ - - - - -TB9.2 Example Applications: examples/PIPS/antiword/src/prop6.c Source File - - - - - -

examples/PIPS/antiword/src/prop6.c

00001 /*
-00002  * prop6.c
-00003  * Copyright (C) 1998-2005 A.J. van Os; Released under GPL
-00004  *
-00005  * Description:
-00006  * Read the property information from a MS Word 6 or 7 file
-00007  */
-00008 
-00009 #include <stdlib.h>
-00010 #include <string.h>
-00011 #include "antiword.h"
-00012 
-00013 
-00014 /*
-00015  * iGet6InfoLength - the length of the information for Word 6/7 files
-00016  */
-00017 static int
-00018 iGet6InfoLength(int iByteNbr, const UCHAR *aucGrpprl)
-00019 {
-00020         int     iTmp, iDel, iAdd;
-00021 
-00022         switch (ucGetByte(iByteNbr, aucGrpprl)) {
-00023         case   2: case  16: case  17: case  18: case  19: case  21: case  22:
-00024         case  26: case  27: case  28: case  30: case  31: case  32: case  33:
-00025         case  34: case  35: case  36: case  38: case  39: case  40: case  41:
-00026         case  42: case  43: case  45: case  46: case  47: case  48: case  49:
-00027         case  69: case  72: case  80: case  93: case  96: case  97: case  99:
-00028         case 101: case 105: case 106: case 107: case 109: case 110: case 121:
-00029         case 122: case 123: case 124: case 140: case 141: case 144: case 145:
-00030         case 148: case 149: case 154: case 155: case 156: case 157: case 160:
-00031         case 161: case 164: case 165: case 166: case 167: case 168: case 169:
-00032         case 170: case 171: case 182: case 183: case 184: case 189: case 195:
-00033         case 197: case 198:
-00034                 return 1 + 2;
-00035         case   3: case  12: case  15: case  81: case 103: case 108: case 188:
-00036         case 190: case 191:
-00037                 return 2 + (int)ucGetByte(iByteNbr + 1, aucGrpprl);
-00038         case  20: case  70: case  74: case 192: case 194: case 196: case 200:
-00039                 return 1 + 4;
-00040         case  23:
-00041                 iTmp = (int)ucGetByte(iByteNbr + 1, aucGrpprl);
-00042                 if (iTmp == 255) {
-00043                         iDel = (int)ucGetByte(iByteNbr + 2, aucGrpprl);
-00044                         iAdd = (int)ucGetByte(
-00045                                         iByteNbr + 3 + iDel * 4, aucGrpprl);
-00046                         iTmp = 2 + iDel * 4 + iAdd * 3;
-00047                 }
-00048                 return 2 + iTmp;
-00049         case  68: case 193: case 199:
-00050                 return 1 + 5;
-00051         case  73: case  95: case 136: case 137:
-00052                 return 1 + 3;
-00053         case 120: case 187:
-00054                 return 1 + 12;
-00055         default:
-00056                 return 1 + 1;
-00057         }
-00058 } /* end of iGet6InfoLength */
-00059 
-00060 /*
-00061  * Build the lists with Document Property Information for Word 6/7 files
-00062  */
-00063 void
-00064 vGet6DopInfo(FILE *pFile, ULONG ulStartBlock,
-00065         const ULONG *aulBBD, size_t tBBDLen,
-00066         const UCHAR *aucHeader)
-00067 {
-00068         document_block_type     tDocument;
-00069         UCHAR   *aucBuffer;
-00070         ULONG   ulBeginDocpInfo, ulTmp;
-00071         size_t  tDocpInfoLen;
-00072         USHORT  usTmp;
-00073 
-00074         ulBeginDocpInfo = ulGetLong(0x150, aucHeader); /* fcDop */
-00075         DBG_HEX(ulBeginDocpInfo);
-00076         tDocpInfoLen = (size_t)ulGetLong(0x154, aucHeader); /* lcbDop */
-00077         DBG_DEC(tDocpInfoLen);
-00078         if (tDocpInfoLen < 28) {
-00079                 DBG_MSG("No Document information");
-00080                 return;
-00081         }
-00082 
-00083         aucBuffer = xmalloc(tDocpInfoLen);
-00084         if (!bReadBuffer(pFile, ulStartBlock,
-00085                         aulBBD, tBBDLen, BIG_BLOCK_SIZE,
-00086                         aucBuffer, ulBeginDocpInfo, tDocpInfoLen)) {
-00087                 aucBuffer = xfree(aucBuffer);
-00088                 return;
-00089         }
-00090 
-00091         usTmp = usGetWord(0x00, aucBuffer);
-00092         tDocument.ucHdrFtrSpecification = (UCHAR)(usTmp >> 8); /* grpfIhdt */
-00093         tDocument.usDefaultTabWidth = usGetWord(0x0a, aucBuffer); /* dxaTab */
-00094         ulTmp = ulGetLong(0x14, aucBuffer); /* dttmCreated */
-00095         tDocument.tCreateDate = tConvertDTTM(ulTmp);
-00096         ulTmp = ulGetLong(0x18, aucBuffer); /* dttmRevised */
-00097         tDocument.tRevisedDate = tConvertDTTM(ulTmp);
-00098         vCreateDocumentInfoList(&tDocument);
-00099 
-00100         aucBuffer = xfree(aucBuffer);
-00101 } /* end of vGet6DopInfo */
-00102 
-00103 /*
-00104  * Fill the section information block with information
-00105  * from a Word 6/7 file.
-00106  */
-00107 static void
-00108 vGet6SectionInfo(const UCHAR *aucGrpprl, size_t tBytes,
-00109                 section_block_type *pSection)
-00110 {
-00111         UINT    uiIndex;
-00112         int     iFodoOff, iInfoLen, iSize, iTmp;
-00113         USHORT  usCcol;
-00114         UCHAR   ucTmp;
-00115 
-00116         fail(aucGrpprl == NULL || pSection == NULL);
-00117 
-00118         iFodoOff = 0;
-00119         while (tBytes >= (size_t)iFodoOff + 1) {
-00120                 iInfoLen = 0;
-00121                 switch (ucGetByte(iFodoOff, aucGrpprl)) {
-00122                 case 133:       /* olstAnm */
-00123                         iSize = (int)ucGetByte(iFodoOff + 1, aucGrpprl);
-00124                         DBG_DEC_C(iSize != 212, iSize);
-00125                         for (uiIndex = 0, iTmp = iFodoOff + 2;
-00126                              uiIndex < 9 && iTmp < iFodoOff + 2 + iSize - 15;
-00127                              uiIndex++, iTmp += 16) {
-00128                                 pSection->aucNFC[uiIndex] =
-00129                                                 ucGetByte(iTmp, aucGrpprl);
-00130                                 NO_DBG_DEC(pSection->aucNFC[uiIndex]);
-00131                                 ucTmp = ucGetByte(iTmp + 3, aucGrpprl);
-00132                                 NO_DBG_HEX(ucTmp);
-00133                                 if ((ucTmp & BIT(2)) != 0) {
-00134                                         pSection->usNeedPrevLvl |=
-00135                                                         (USHORT)BIT(uiIndex);
-00136                                 }
-00137                                 if ((ucTmp & BIT(3)) != 0) {
-00138                                         pSection->usHangingIndent |=
-00139                                                         (USHORT)BIT(uiIndex);
-00140                                 }
-00141                         }
-00142                         DBG_HEX(pSection->usNeedPrevLvl);
-00143                         DBG_HEX(pSection->usHangingIndent);
-00144                         break;
-00145                 case 142:       /* bkc */
-00146                         ucTmp = ucGetByte(iFodoOff + 1, aucGrpprl);
-00147                         DBG_DEC(ucTmp);
-00148                         pSection->bNewPage = ucTmp != 0 && ucTmp != 1;
-00149                         break;
-00150                 case 144:       /* ccolM1 */
-00151                         usCcol = 1 + usGetWord(iFodoOff + 1, aucGrpprl);
-00152                         DBG_DEC(usCcol);
-00153                         break;
-00154                 case 153:       /* grpfIhdt */
-00155                         pSection->ucHdrFtrSpecification =
-00156                                         ucGetByte(iFodoOff + 1, aucGrpprl);
-00157                         break;
-00158                 default:
-00159                         break;
-00160                 }
-00161                 if (iInfoLen <= 0) {
-00162                         iInfoLen = iGet6InfoLength(iFodoOff, aucGrpprl);
-00163                         fail(iInfoLen <= 0);
-00164                 }
-00165                 iFodoOff += iInfoLen;
-00166         }
-00167 } /* end of vGet6SectionInfo */
-00168 
-00169 /*
-00170  * Build the lists with Section Property Information for Word 6/7 files
-00171  */
-00172 void
-00173 vGet6SepInfo(FILE *pFile, ULONG ulStartBlock,
-00174         const ULONG *aulBBD, size_t tBBDLen,
-00175         const UCHAR *aucHeader)
-00176 {
-00177         section_block_type      tSection;
-00178         ULONG           *aulSectPage, *aulCharPos;
-00179         UCHAR   *aucBuffer, *aucFpage;
-00180         ULONG   ulBeginOfText, ulTextOffset, ulBeginSectInfo;
-00181         size_t  tSectInfoLen, tIndex, tOffset, tLen, tBytes;
-00182         UCHAR   aucTmp[2];
-00183 
-00184         fail(pFile == NULL || aucHeader == NULL);
-00185         fail(ulStartBlock > MAX_BLOCKNUMBER && ulStartBlock != END_OF_CHAIN);
-00186         fail(aulBBD == NULL);
-00187 
-00188         ulBeginOfText = ulGetLong(0x18, aucHeader); /* fcMin */
-00189         NO_DBG_HEX(ulBeginOfText);
-00190         ulBeginSectInfo = ulGetLong(0x88, aucHeader); /* fcPlcfsed */
-00191         DBG_HEX(ulBeginSectInfo);
-00192         tSectInfoLen = (size_t)ulGetLong(0x8c, aucHeader); /* lcbPlcfsed */
-00193         DBG_DEC(tSectInfoLen);
-00194         if (tSectInfoLen < 4) {
-00195                 DBG_DEC(tSectInfoLen);
-00196                 return;
-00197         }
-00198 
-00199         aucBuffer = xmalloc(tSectInfoLen);
-00200         if (!bReadBuffer(pFile, ulStartBlock,
-00201                         aulBBD, tBBDLen, BIG_BLOCK_SIZE,
-00202                         aucBuffer, ulBeginSectInfo, tSectInfoLen)) {
-00203                 aucBuffer = xfree(aucBuffer);
-00204                 return;
-00205         }
-00206         NO_DBG_PRINT_BLOCK(aucBuffer, tSectInfoLen);
-00207 
-00208         /* Read the Section Descriptors */
-00209         tLen = (tSectInfoLen - 4) / 16;
-00210         /* Save the section offsets */
-00211         aulCharPos = xcalloc(tLen, sizeof(ULONG));
-00212         for (tIndex = 0, tOffset = 0; tIndex < tLen; tIndex++, tOffset += 4) {
-00213                 ulTextOffset = ulGetLong(tOffset, aucBuffer);
-00214                 NO_DBG_HEX(ulTextOffset);
-00215                 aulCharPos[tIndex] = ulBeginOfText + ulTextOffset;
-00216                 NO_DBG_HEX(aulCharPos[tIndex]);
-00217         }
-00218         /* Save the Sepx offsets */
-00219         aulSectPage = xcalloc(tLen, sizeof(ULONG));
-00220         for (tIndex = 0, tOffset = (tLen + 1) * 4;
-00221              tIndex < tLen;
-00222              tIndex++, tOffset += 12) {
-00223                 aulSectPage[tIndex] = ulGetLong(tOffset + 2, aucBuffer);
-00224                 NO_DBG_HEX(aulSectPage[tIndex]); /* fcSepx */
-00225         }
-00226         aucBuffer = xfree(aucBuffer);
-00227 
-00228         /* Read the Section Properties */
-00229         for (tIndex = 0; tIndex < tLen; tIndex++) {
-00230                 if (aulSectPage[tIndex] == FC_INVALID) {
-00231                         vDefault2SectionInfoList(aulCharPos[tIndex]);
-00232                         continue;
-00233                 }
-00234                 /* Get the number of bytes to read */
-00235                 if (!bReadBuffer(pFile, ulStartBlock,
-00236                                 aulBBD, tBBDLen, BIG_BLOCK_SIZE,
-00237                                 aucTmp, aulSectPage[tIndex], 2)) {
-00238                         continue;
-00239                 }
-00240                 tBytes = 2 + (size_t)usGetWord(0, aucTmp);
-00241                 NO_DBG_DEC(tBytes);
-00242                 /* Read the bytes */
-00243                 aucFpage = xmalloc(tBytes);
-00244                 if (!bReadBuffer(pFile, ulStartBlock,
-00245                                 aulBBD, tBBDLen, BIG_BLOCK_SIZE,
-00246                                 aucFpage, aulSectPage[tIndex], tBytes)) {
-00247                         aucFpage = xfree(aucFpage);
-00248                         continue;
-00249                 }
-00250                 NO_DBG_PRINT_BLOCK(aucFpage, tBytes);
-00251                 /* Process the bytes */
-00252                 vGetDefaultSection(&tSection);
-00253                 vGet6SectionInfo(aucFpage + 2, tBytes - 2, &tSection);
-00254                 vAdd2SectionInfoList(&tSection, aulCharPos[tIndex]);
-00255                 aucFpage = xfree(aucFpage);
-00256         }
-00257         aulCharPos = xfree(aulCharPos);
-00258         aulSectPage = xfree(aulSectPage);
-00259 } /* end of vGet6SepInfo */
-00260 
-00261 /*
-00262  * Build the list with Header/Footer Information for Word 6/7 files
-00263  */
-00264 void
-00265 vGet6HdrFtrInfo(FILE *pFile, ULONG ulStartBlock,
-00266         const ULONG *aulBBD, size_t tBBDLen,
-00267         const UCHAR *aucHeader)
-00268 {
-00269         ULONG   *aulCharPos;
-00270         UCHAR   *aucBuffer;
-00271         ULONG   ulHdrFtrOffset, ulBeginHdrFtrInfo;
-00272         size_t  tHdrFtrInfoLen, tIndex, tOffset, tLen;
-00273 
-00274         fail(pFile == NULL || aucHeader == NULL);
-00275         fail(ulStartBlock > MAX_BLOCKNUMBER && ulStartBlock != END_OF_CHAIN);
-00276         fail(aulBBD == NULL);
-00277 
-00278         ulBeginHdrFtrInfo = ulGetLong(0xb0, aucHeader); /* fcPlcfhdd */
-00279         NO_DBG_HEX(ulBeginHdrFtrInfo);
-00280         tHdrFtrInfoLen = (size_t)ulGetLong(0xb4, aucHeader); /* lcbPlcfhdd */
-00281         NO_DBG_DEC(tHdrFtrInfoLen);
-00282         if (tHdrFtrInfoLen < 8) {
-00283                 DBG_DEC_C(tHdrFtrInfoLen != 0, tHdrFtrInfoLen);
-00284                 return;
-00285         }
-00286 
-00287         aucBuffer = xmalloc(tHdrFtrInfoLen);
-00288         if (!bReadBuffer(pFile, ulStartBlock,
-00289                         aulBBD, tBBDLen, BIG_BLOCK_SIZE,
-00290                         aucBuffer, ulBeginHdrFtrInfo, tHdrFtrInfoLen)) {
-00291                 aucBuffer = xfree(aucBuffer);
-00292                 return;
-00293         }
-00294         NO_DBG_PRINT_BLOCK(aucBuffer, tHdrFtrInfoLen);
-00295 
-00296         tLen = tHdrFtrInfoLen / 4 - 1;
-00297         /* Save the header/footer offsets */
-00298         aulCharPos = xcalloc(tLen, sizeof(ULONG));
-00299         for (tIndex = 0, tOffset = 0;
-00300              tIndex < tLen;
-00301              tIndex++, tOffset += 4) {
-00302                 ulHdrFtrOffset = ulGetLong(tOffset, aucBuffer);
-00303                 NO_DBG_HEX(ulHdrFtrOffset);
-00304                 aulCharPos[tIndex] = ulHdrFtrOffset2CharPos(ulHdrFtrOffset);
-00305                 NO_DBG_HEX(aulCharPos[tIndex]);
-00306         }
-00307         vCreat6HdrFtrInfoList(aulCharPos, tLen);
-00308         aulCharPos = xfree(aulCharPos);
-00309         aucBuffer = xfree(aucBuffer);
-00310 } /* end of vGet6HdrFtrInfo */
-00311 
-00312 /*
-00313  * Translate the rowinfo to a member of the row_info enumeration
-00314  */
-00315 row_info_enum
-00316 eGet6RowInfo(int iFodo,
-00317         const UCHAR *aucGrpprl, int iBytes, row_block_type *pRow)
-00318 {
-00319         int     iFodoOff, iInfoLen;
-00320         int     iIndex, iSize, iCol;
-00321         int     iPosCurr, iPosPrev;
-00322         USHORT  usTmp;
-00323         BOOL    bFound24_0, bFound24_1, bFound25_0, bFound25_1, bFound190;
-00324 
-00325         fail(iFodo < 0 || aucGrpprl == NULL || pRow == NULL);
-00326 
-00327         iFodoOff = 0;
-00328         bFound24_0 = FALSE;
-00329         bFound24_1 = FALSE;
-00330         bFound25_0 = FALSE;
-00331         bFound25_1 = FALSE;
-00332         bFound190 = FALSE;
-00333         while (iBytes >= iFodoOff + 1) {
-00334                 iInfoLen = 0;
-00335                 switch (ucGetByte(iFodo + iFodoOff, aucGrpprl)) {
-00336                 case  24:       /* fInTable */
-00337                         if (odd(ucGetByte(iFodo + iFodoOff + 1, aucGrpprl))) {
-00338                                 bFound24_1 = TRUE;
-00339                         } else {
-00340                                 bFound24_0 = TRUE;
-00341                         }
-00342                         break;
-00343                 case  25:       /* fTtp */
-00344                         if (odd(ucGetByte(iFodo + iFodoOff + 1, aucGrpprl))) {
-00345                                 bFound25_1 = TRUE;
-00346                         } else {
-00347                                 bFound25_0 = TRUE;
-00348                         }
-00349                         break;
-00350                 case 38:        /* brcTop */
-00351                         usTmp = usGetWord(iFodo + iFodoOff + 1, aucGrpprl);
-00352                         usTmp &= 0x0018;
-00353                         NO_DBG_DEC(usTmp >> 3);
-00354                         if (usTmp == 0) {
-00355                                 pRow->ucBorderInfo &= ~TABLE_BORDER_TOP;
-00356                         } else {
-00357                                 pRow->ucBorderInfo |= TABLE_BORDER_TOP;
-00358                         }
-00359                         break;
-00360                 case 39:        /* brcLeft */
-00361                         usTmp = usGetWord(iFodo + iFodoOff + 1, aucGrpprl);
-00362                         usTmp &= 0x0018;
-00363                         NO_DBG_DEC(usTmp >> 3);
-00364                         if (usTmp == 0) {
-00365                                 pRow->ucBorderInfo &= ~TABLE_BORDER_LEFT;
-00366                         } else {
-00367                                 pRow->ucBorderInfo |= TABLE_BORDER_LEFT;
-00368                         }
-00369                         break;
-00370                 case 40:        /* brcBottom */
-00371                         usTmp = usGetWord(iFodo + iFodoOff + 1, aucGrpprl);
-00372                         usTmp &= 0x0018;
-00373                         NO_DBG_DEC(usTmp >> 3);
-00374                         if (usTmp == 0) {
-00375                                 pRow->ucBorderInfo &= ~TABLE_BORDER_BOTTOM;
-00376                         } else {
-00377                                 pRow->ucBorderInfo |= TABLE_BORDER_BOTTOM;
-00378                         }
-00379                         break;
-00380                 case 41:        /* brcRight */
-00381                         usTmp = usGetWord(iFodo + iFodoOff + 1, aucGrpprl);
-00382                         usTmp &= 0x0018;
-00383                         NO_DBG_DEC(usTmp >> 3);
-00384                         if (usTmp == 0) {
-00385                                 pRow->ucBorderInfo &= ~TABLE_BORDER_RIGHT;
-00386                         } else {
-00387                                 pRow->ucBorderInfo |= TABLE_BORDER_RIGHT;
-00388                         }
-00389                         break;
-00390                 case 188:       /* cDefTable10 */
-00391                         DBG_MSG("188: sprmTDefTable10");
-00392                         iSize = (int)usGetWord(iFodo + iFodoOff + 1, aucGrpprl);
-00393                         DBG_DEC(iSize);
-00394                         break;
-00395                 case 190:       /* cDefTable */
-00396                         iSize = (int)usGetWord(iFodo + iFodoOff + 1, aucGrpprl);
-00397                         if (iSize < 6 || iBytes < iFodoOff + 7) {
-00398                                 DBG_DEC(iSize);
-00399                                 DBG_DEC(iFodoOff);
-00400                                 iInfoLen = 1;
-00401                                 break;
-00402                         }
-00403                         iCol = (int)ucGetByte(iFodo + iFodoOff + 3, aucGrpprl);
-00404                         if (iCol < 1 ||
-00405                             iBytes < iFodoOff + 3 + (iCol + 1) * 2) {
-00406                                 DBG_DEC(iCol);
-00407                                 DBG_DEC(iFodoOff);
-00408                                 iInfoLen = 1;
-00409                                 break;
-00410                         }
-00411                         if (iCol >= (int)elementsof(pRow->asColumnWidth)) {
-00412                                 DBG_DEC(iCol);
-00413                                 werr(1, "The number of columns is corrupt");
-00414                         }
-00415                         pRow->ucNumberOfColumns = (UCHAR)iCol;
-00416                         iPosPrev = (int)(short)usGetWord(
-00417                                         iFodo + iFodoOff + 4,
-00418                                         aucGrpprl);
-00419                         for (iIndex = 0; iIndex < iCol; iIndex++) {
-00420                                 iPosCurr = (int)(short)usGetWord(
-00421                                         iFodo + iFodoOff + 6 + iIndex * 2,
-00422                                         aucGrpprl);
-00423                                 pRow->asColumnWidth[iIndex] =
-00424                                                 (short)(iPosCurr - iPosPrev);
-00425                                 iPosPrev = iPosCurr;
-00426                         }
-00427                         bFound190 = TRUE;
-00428                         break;
-00429                 default:
-00430                         break;
-00431                 }
-00432                 if (iInfoLen <= 0) {
-00433                         iInfoLen =
-00434                                 iGet6InfoLength(iFodo + iFodoOff, aucGrpprl);
-00435                         fail(iInfoLen <= 0);
-00436                 }
-00437                 iFodoOff += iInfoLen;
-00438         }
-00439 
-00440         if (bFound25_1 && bFound190) {
-00441                 return found_end_of_row;
-00442         }
-00443         if (bFound25_0 && !bFound190) {
-00444                 return found_not_end_of_row;
-00445         }
-00446         if (bFound24_1) {
-00447                 return found_a_cell;
-00448         }
-00449         if (bFound24_0) {
-00450                 return found_not_a_cell;
-00451         }
-00452         return found_nothing;
-00453 } /* end of eGet6RowInfo */
-00454 
-00455 /*
-00456  * Fill the style information block with information
-00457  * from a Word 6/7 file.
-00458  */
-00459 void
-00460 vGet6StyleInfo(int iFodo,
-00461         const UCHAR *aucGrpprl, int iBytes, style_block_type *pStyle)
-00462 {
-00463         int     iFodoOff, iInfoLen;
-00464         int     iTmp, iDel, iAdd, iBefore;
-00465         short   sTmp;
-00466         UCHAR   ucTmp;
-00467 
-00468         fail(iFodo < 0 || aucGrpprl == NULL || pStyle == NULL);
-00469 
-00470         NO_DBG_DEC(pStyle->usIstd);
-00471 
-00472         iFodoOff = 0;
-00473         while (iBytes >= iFodoOff + 1) {
-00474                 iInfoLen = 0;
-00475                 switch (ucGetByte(iFodo + iFodoOff, aucGrpprl)) {
-00476                 case   2:       /* istd */
-00477                         sTmp = (short)ucGetByte(
-00478                                         iFodo + iFodoOff + 1, aucGrpprl);
-00479                         NO_DBG_DEC(sTmp);
-00480                         break;
-00481                 case   5:       /* jc */
-00482                         pStyle->ucAlignment = ucGetByte(
-00483                                         iFodo + iFodoOff + 1, aucGrpprl);
-00484                         break;
-00485                 case  12:       /* anld */
-00486                         iTmp = (int)ucGetByte(
-00487                                         iFodo + iFodoOff + 1, aucGrpprl);
-00488                         DBG_DEC_C(iTmp < 52, iTmp);
-00489                         if (iTmp >= 1) {
-00490                                 pStyle->ucNFC = ucGetByte(
-00491                                         iFodo + iFodoOff + 2, aucGrpprl);
-00492                         }
-00493                         if (pStyle->ucNFC != LIST_BULLETS && iTmp >= 2) {
-00494                                 iBefore = (int)ucGetByte(
-00495                                         iFodo + iFodoOff + 3, aucGrpprl);
-00496                         } else {
-00497                                 iBefore = 0;
-00498                         }
-00499                         if (iTmp >= 12) {
-00500                                 pStyle->usStartAt = usGetWord(
-00501                                         iFodo + iFodoOff + 12, aucGrpprl);
-00502                         }
-00503                         if (iTmp >= iBefore + 21) {
-00504                                 pStyle->usListChar = (USHORT)ucGetByte(
-00505                                         iFodo + iFodoOff + iBefore + 22,
-00506                                         aucGrpprl);
-00507                                 NO_DBG_HEX(pStyle->usListChar);
-00508                         }
-00509                         break;
-00510                 case  13:       /* nLvlAnm */
-00511                         ucTmp = ucGetByte(iFodo + iFodoOff + 1, aucGrpprl);
-00512                         pStyle->ucNumLevel = ucTmp;
-00513                         pStyle->bNumPause =
-00514                                 eGetNumType(ucTmp) == level_type_pause;
-00515                         break;
-00516                 case  15:       /* ChgTabsPapx */
-00517                 case  23:       /* ChgTabs */
-00518                         iTmp = (int)ucGetByte(iFodo + iFodoOff + 1, aucGrpprl);
-00519                         if (iTmp < 2) {
-00520                                 iInfoLen = 1;
-00521                                 break;
-00522                         }
-00523                         NO_DBG_DEC(iTmp);
-00524                         iDel = (int)ucGetByte(iFodo + iFodoOff + 2, aucGrpprl);
-00525                         if (iTmp < 2 + 2 * iDel) {
-00526                                 iInfoLen = 1;
-00527                                 break;
-00528                         }
-00529                         NO_DBG_DEC(iDel);
-00530                         iAdd = (int)ucGetByte(
-00531                                 iFodo + iFodoOff + 3 + 2 * iDel, aucGrpprl);
-00532                         if (iTmp < 2 + 2 * iDel + 2 * iAdd) {
-00533                                 iInfoLen = 1;
-00534                                 break;
-00535                         }
-00536                         NO_DBG_DEC(iAdd);
-00537                         break;
-00538                 case  16:       /* dxaRight */
-00539                         pStyle->sRightIndent = (short)usGetWord(
-00540                                         iFodo + iFodoOff + 1, aucGrpprl);
-00541                         NO_DBG_DEC(pStyle->sRightIndent);
-00542                         break;
-00543                 case  17:       /* dxaLeft */
-00544                         pStyle->sLeftIndent = (short)usGetWord(
-00545                                         iFodo + iFodoOff + 1, aucGrpprl);
-00546                         NO_DBG_DEC(pStyle->sLeftIndent);
-00547                         break;
-00548                 case  18:       /* Nest dxaLeft */
-00549                         sTmp = (short)usGetWord(
-00550                                         iFodo + iFodoOff + 1, aucGrpprl);
-00551                         pStyle->sLeftIndent += sTmp;
-00552                         if (pStyle->sLeftIndent < 0) {
-00553                                 pStyle->sLeftIndent = 0;
-00554                         }
-00555                         NO_DBG_DEC(sTmp);
-00556                         NO_DBG_DEC(pStyle->sLeftIndent);
-00557                         break;
-00558                 case  19:       /* dxaLeft1 */
-00559                         pStyle->sLeftIndent1 = (short)usGetWord(
-00560                                         iFodo + iFodoOff + 1, aucGrpprl);
-00561                         NO_DBG_DEC(pStyle->sLeftIndent1);
-00562                         break;
-00563                 case  21:       /* dyaBefore */
-00564                         pStyle->usBeforeIndent = usGetWord(
-00565                                         iFodo + iFodoOff + 1, aucGrpprl);
-00566                         NO_DBG_DEC(pStyle->usBeforeIndent);
-00567                         break;
-00568                 case  22:       /* dyaAfter */
-00569                         pStyle->usAfterIndent = usGetWord(
-00570                                         iFodo + iFodoOff + 1, aucGrpprl);
-00571                         NO_DBG_DEC(pStyle->usAfterIndent);
-00572                         break;
-00573                 default:
-00574                         break;
-00575                 }
-00576                 if (iInfoLen <= 0) {
-00577                         iInfoLen =
-00578                                 iGet6InfoLength(iFodo + iFodoOff, aucGrpprl);
-00579                         fail(iInfoLen <= 0);
-00580                 }
-00581                 iFodoOff += iInfoLen;
-00582         }
-00583 } /* end of vGet6StyleInfo */
-00584 
-00585 /*
-00586  * Build the lists with Paragraph Information for Word 6/7 files
-00587  */
-00588 void
-00589 vGet6PapInfo(FILE *pFile, ULONG ulStartBlock,
-00590         const ULONG *aulBBD, size_t tBBDLen,
-00591         const UCHAR *aucHeader)
-00592 {
-00593         row_block_type          tRow;
-00594         style_block_type        tStyle;
-00595         USHORT  *ausParfPage;
-00596         UCHAR   *aucBuffer;
-00597         ULONG   ulCharPos, ulCharPosFirst, ulCharPosLast;
-00598         ULONG   ulBeginParfInfo;
-00599         size_t  tParfInfoLen, tParfPageNum, tOffset, tSize, tLenOld, tLen;
-00600         size_t  tIndex, tIndex2, tRun;
-00601         int     iFodo, iLen;
-00602         row_info_enum   eRowInfo;
-00603         USHORT  usParfFirstPage, usCount, usIstd;
-00604         UCHAR   aucFpage[BIG_BLOCK_SIZE];
-00605 
-00606         fail(pFile == NULL || aucHeader == NULL);
-00607         fail(ulStartBlock > MAX_BLOCKNUMBER && ulStartBlock != END_OF_CHAIN);
-00608         fail(aulBBD == NULL);
-00609 
-00610         ulBeginParfInfo = ulGetLong(0xc0, aucHeader); /* fcPlcfbtePapx */
-00611         NO_DBG_HEX(ulBeginParfInfo);
-00612         tParfInfoLen = (size_t)ulGetLong(0xc4, aucHeader); /* lcbPlcfbtePapx */
-00613         NO_DBG_DEC(tParfInfoLen);
-00614         if (tParfInfoLen < 4) {
-00615                 DBG_DEC(tParfInfoLen);
-00616                 return;
-00617         }
-00618 
-00619         aucBuffer = xmalloc(tParfInfoLen);
-00620         if (!bReadBuffer(pFile, ulStartBlock,
-00621                         aulBBD, tBBDLen, BIG_BLOCK_SIZE,
-00622                         aucBuffer, ulBeginParfInfo, tParfInfoLen)) {
-00623                 aucBuffer = xfree(aucBuffer);
-00624                 return;
-00625         }
-00626         NO_DBG_PRINT_BLOCK(aucBuffer, tParfInfoLen);
-00627 
-00628         tLen = (tParfInfoLen - 4) / 6;
-00629         ausParfPage = xcalloc(tLen, sizeof(USHORT));
-00630         for (tIndex = 0, tOffset = (tLen + 1) * 4;
-00631              tIndex < tLen;
-00632              tIndex++, tOffset += 2) {
-00633                  ausParfPage[tIndex] = usGetWord(tOffset, aucBuffer);
-00634                  NO_DBG_DEC(ausParfPage[tIndex]);
-00635         }
-00636         DBG_HEX(ulGetLong(0, aucBuffer));
-00637         aucBuffer = xfree(aucBuffer);
-00638         tParfPageNum = (size_t)usGetWord(0x190, aucHeader); /* cpnBtePap */
-00639         DBG_DEC(tParfPageNum);
-00640         if (tLen < tParfPageNum) {
-00641                 /* Replace ParfPage by a longer version */
-00642                 tLenOld = tLen;
-00643                 usParfFirstPage = usGetWord(0x18c, aucHeader); /* pnPapFirst */
-00644                 DBG_DEC(usParfFirstPage);
-00645                 tLen += tParfPageNum - 1;
-00646                 tSize = tLen * sizeof(USHORT);
-00647                 ausParfPage = xrealloc(ausParfPage, tSize);
-00648                 /* Add new values */
-00649                 usCount = usParfFirstPage + 1;
-00650                 for (tIndex = tLenOld; tIndex < tLen; tIndex++) {
-00651                         ausParfPage[tIndex] = usCount;
-00652                         NO_DBG_DEC(ausParfPage[tIndex]);
-00653                         usCount++;
-00654                 }
-00655         }
-00656 
-00657         (void)memset(&tRow, 0, sizeof(tRow));
-00658         ulCharPosFirst = CP_INVALID;
-00659         for (tIndex = 0; tIndex < tLen; tIndex++) {
-00660                 if (!bReadBuffer(pFile, ulStartBlock,
-00661                                 aulBBD, tBBDLen, BIG_BLOCK_SIZE,
-00662                                 aucFpage,
-00663                                 (ULONG)ausParfPage[tIndex] * BIG_BLOCK_SIZE,
-00664                                 BIG_BLOCK_SIZE)) {
-00665                         break;
-00666                 }
-00667                 tRun = (size_t)ucGetByte(0x1ff, aucFpage);
-00668                 NO_DBG_DEC(tRun);
-00669                 for (tIndex2 = 0; tIndex2 < tRun; tIndex2++) {
-00670                         NO_DBG_HEX(ulGetLong(tIndex2 * 4, aucFpage));
-00671                         iFodo = 2 * (int)ucGetByte(
-00672                                 (tRun + 1) * 4 + tIndex2 * 7, aucFpage);
-00673                         if (iFodo <= 0) {
-00674                                 continue;
-00675                         }
-00676 
-00677                         iLen = 2 * (int)ucGetByte(iFodo, aucFpage);
-00678 
-00679                         usIstd = (USHORT)ucGetByte(iFodo + 1, aucFpage);
-00680                         vFillStyleFromStylesheet(usIstd, &tStyle);
-00681                         vGet6StyleInfo(iFodo, aucFpage + 3, iLen - 3, &tStyle);
-00682                         ulCharPos = ulGetLong(tIndex2 * 4, aucFpage);
-00683                         NO_DBG_HEX(ulCharPos);
-00684                         tStyle.ulFileOffset = ulCharPos2FileOffsetX(
-00685                                 ulCharPos, &tStyle.eListID);
-00686                         vAdd2StyleInfoList(&tStyle);
-00687 
-00688                         eRowInfo = eGet6RowInfo(iFodo,
-00689                                         aucFpage + 3, iLen - 3, &tRow);
-00690                         switch(eRowInfo) {
-00691                         case found_a_cell:
-00692                                 if (ulCharPosFirst != CP_INVALID) {
-00693                                         break;
-00694                                 }
-00695                                 ulCharPosFirst = ulGetLong(
-00696                                                 tIndex2 * 4, aucFpage);
-00697                                 NO_DBG_HEX(ulCharPosFirst);
-00698                                 tRow.ulCharPosStart = ulCharPosFirst;
-00699                                 tRow.ulFileOffsetStart =
-00700                                         ulCharPos2FileOffset(ulCharPosFirst);
-00701                                 DBG_HEX_C(tRow.ulFileOffsetStart == FC_INVALID,
-00702                                                         ulCharPosFirst);
-00703                                 break;
-00704                         case found_end_of_row:
-00705                                 ulCharPosLast = ulGetLong(
-00706                                                 tIndex2 * 4, aucFpage);
-00707                                 NO_DBG_HEX(ulCharPosLast);
-00708                                 tRow.ulCharPosEnd = ulCharPosLast;
-00709                                 tRow.ulFileOffsetEnd =
-00710                                         ulCharPos2FileOffset(ulCharPosLast);
-00711                                 DBG_HEX_C(tRow.ulFileOffsetEnd == FC_INVALID,
-00712                                                         ulCharPosLast);
-00713                                 vAdd2RowInfoList(&tRow);
-00714                                 (void)memset(&tRow, 0, sizeof(tRow));
-00715                                 ulCharPosFirst = CP_INVALID;
-00716                                 break;
-00717                         case found_nothing:
-00718                                 break;
-00719                         default:
-00720                                 DBG_DEC(eRowInfo);
-00721                                 break;
-00722                         }
-00723                 }
-00724         }
-00725         ausParfPage = xfree(ausParfPage);
-00726 } /* end of vGet6PapInfo */
-00727 
-00728 /*
-00729  * Fill the font information block with information
-00730  * from a Word 6/7 file.
-00731  * Returns TRUE when successful, otherwise FALSE
-00732  */
-00733 void
-00734 vGet6FontInfo(int iFodo, USHORT usIstd,
-00735         const UCHAR *aucGrpprl, int iBytes, font_block_type *pFont)
-00736 {
-00737         long    lTmp;
-00738         int     iFodoOff, iInfoLen;
-00739         USHORT  usTmp;
-00740         UCHAR   ucTmp;
-00741 
-00742         TRACE_MSG("vGet6FontInfo");
-00743 
-00744         fail(iFodo < 0 || aucGrpprl == NULL || pFont == NULL);
-00745 
-00746         iFodoOff = 0;
-00747         while (iBytes >= iFodoOff + 1) {
-00748                 switch (ucGetByte(iFodo + iFodoOff, aucGrpprl)) {
-00749                 case  65:       /* fRMarkDel */
-00750                         ucTmp = ucGetByte(iFodo + iFodoOff + 1, aucGrpprl);
-00751                         if (ucTmp == 0) {
-00752                                 pFont->usFontStyle &= ~FONT_MARKDEL;
-00753                         } else {
-00754                                 pFont->usFontStyle |= FONT_MARKDEL;
-00755                         }
-00756                         break;
-00757                 case  80:       /* cIstd */
-00758                         usTmp = usGetWord(iFodo + iFodoOff + 1, aucGrpprl);
-00759                         NO_DBG_DEC(usTmp);
-00760                         break;
-00761                 case  82:       /* cDefault */
-00762                         pFont->usFontStyle &= FONT_HIDDEN;
-00763                         pFont->ucFontColor = FONT_COLOR_DEFAULT;
-00764                         break;
-00765                 case  83:       /* cPlain */
-00766                         DBG_MSG("83: cPlain");
-00767                         vFillFontFromStylesheet(usIstd, pFont);
-00768                         break;
-00769                 case  85:       /* fBold */
-00770                         ucTmp = ucGetByte(iFodo + iFodoOff + 1, aucGrpprl);
-00771                         switch (ucTmp) {
-00772                         case   0:       /* Unset */
-00773                                 pFont->usFontStyle &= ~FONT_BOLD;
-00774                                 break;
-00775                         case   1:       /* Set */
-00776                                 pFont->usFontStyle |= FONT_BOLD;
-00777                                 break;
-00778                         case 128:       /* Unchanged */
-00779                                 break;
-00780                         case 129:       /* Negation */
-00781                                 pFont->usFontStyle ^= FONT_BOLD;
-00782                                 break;
-00783                         default:
-00784                                 DBG_DEC(ucTmp);
-00785                                 DBG_FIXME();
-00786                                 break;
-00787                         }
-00788                         break;
-00789                 case  86:       /* fItalic */
-00790                         ucTmp = ucGetByte(iFodo + iFodoOff + 1, aucGrpprl);
-00791                         switch (ucTmp) {
-00792                         case   0:       /* Unset */
-00793                                 pFont->usFontStyle &= ~FONT_ITALIC;
-00794                                 break;
-00795                         case   1:       /* Set */
-00796                                 pFont->usFontStyle |= FONT_ITALIC;
-00797                                 break;
-00798                         case 128:       /* Unchanged */
-00799                                 break;
-00800                         case 129:       /* Negation */
-00801                                 pFont->usFontStyle ^= FONT_ITALIC;
-00802                                 break;
-00803                         default:
-00804                                 DBG_DEC(ucTmp);
-00805                                 DBG_FIXME();
-00806                                 break;
-00807                         }
-00808                         break;
-00809                 case  87:       /* fStrike */
-00810                         ucTmp = ucGetByte(iFodo + iFodoOff + 1, aucGrpprl);
-00811                         switch (ucTmp) {
-00812                         case   0:       /* Unset */
-00813                                 pFont->usFontStyle &= ~FONT_STRIKE;
-00814                                 break;
-00815                         case   1:       /* Set */
-00816                                 pFont->usFontStyle |= FONT_STRIKE;
-00817                                 break;
-00818                         case 128:       /* Unchanged */
-00819                                 break;
-00820                         case 129:       /* Negation */
-00821                                 pFont->usFontStyle ^= FONT_STRIKE;
-00822                                 break;
-00823                         default:
-00824                                 DBG_DEC(ucTmp);
-00825                                 DBG_FIXME();
-00826                                 break;
-00827                         }
-00828                         break;
-00829                 case  90:       /* fSmallCaps */
-00830                         ucTmp = ucGetByte(iFodo + iFodoOff + 1, aucGrpprl);
-00831                         switch (ucTmp) {
-00832                         case   0:       /* Unset */
-00833                                 pFont->usFontStyle &= ~FONT_SMALL_CAPITALS;
-00834                                 break;
-00835                         case   1:       /* Set */
-00836                                 pFont->usFontStyle |= FONT_SMALL_CAPITALS;
-00837                                 break;
-00838                         case 128:       /* Unchanged */
-00839                                 break;
-00840                         case 129:       /* Negation */
-00841                                 pFont->usFontStyle ^= FONT_SMALL_CAPITALS;
-00842                                 break;
-00843                         default:
-00844                                 DBG_DEC(ucTmp);
-00845                                 DBG_FIXME();
-00846                                 break;
-00847                         }
-00848                         break;
-00849                 case  91:       /* fCaps */
-00850                         ucTmp = ucGetByte(iFodo + iFodoOff + 1, aucGrpprl);
-00851                         switch (ucTmp) {
-00852                         case   0:       /* Unset */
-00853                                 pFont->usFontStyle &= ~FONT_CAPITALS;
-00854                                 break;
-00855                         case   1:       /* Set */
-00856                                 pFont->usFontStyle |= FONT_CAPITALS;
-00857                                 break;
-00858                         case 128:       /* Unchanged */
-00859                                 break;
-00860                         case 129:       /* Negation */
-00861                                 pFont->usFontStyle ^= FONT_CAPITALS;
-00862                                 break;
-00863                         default:
-00864                                 DBG_DEC(ucTmp);
-00865                                 DBG_FIXME();
-00866                                 break;
-00867                         }
-00868                         break;
-00869                 case  92:       /* fVanish */
-00870                         ucTmp = ucGetByte(iFodo + iFodoOff + 1, aucGrpprl);
-00871                         switch (ucTmp) {
-00872                         case   0:       /* Unset */
-00873                                 pFont->usFontStyle &= ~FONT_HIDDEN;
-00874                                 break;
-00875                         case   1:       /* Set */
-00876                                 pFont->usFontStyle |= FONT_HIDDEN;
-00877                                 break;
-00878                         case 128:       /* Unchanged */
-00879                                 break;
-00880                         case 129:       /* Negation */
-00881                                 pFont->usFontStyle ^= FONT_HIDDEN;
-00882                                 break;
-00883                         default:
-00884                                 DBG_DEC(ucTmp);
-00885                                 DBG_FIXME();
-00886                                 break;
-00887                         }
-00888                         break;
-00889                 case  93:       /* cFtc */
-00890                         usTmp = usGetWord(iFodo + iFodoOff + 1, aucGrpprl);
-00891                         if (usTmp <= (USHORT)UCHAR_MAX) {
-00892                                 pFont->ucFontNumber = (UCHAR)usTmp;
-00893                         } else {
-00894                                 DBG_DEC(usTmp);
-00895                                 DBG_FIXME();
-00896                                 pFont->ucFontNumber = 0;
-00897                         }
-00898                         break;
-00899                 case  94:       /* cKul */
-00900                         ucTmp = ucGetByte(iFodo + iFodoOff + 1, aucGrpprl);
-00901                         if (ucTmp == 0 || ucTmp == 5) {
-00902                                 pFont->usFontStyle &= ~FONT_UNDERLINE;
-00903                         } else {
-00904                                 NO_DBG_MSG("Underline text");
-00905                                 pFont->usFontStyle |= FONT_UNDERLINE;
-00906                                 if (ucTmp == 6) {
-00907                                         DBG_MSG("Bold text");
-00908                                         pFont->usFontStyle |= FONT_BOLD;
-00909                                 }
-00910                         }
-00911                         break;
-00912                 case  95:       /* cHps, cHpsPos */
-00913                         ucTmp = ucGetByte(iFodo + iFodoOff + 1, aucGrpprl);
-00914                         DBG_DEC(ucTmp);
-00915                         if (ucTmp != 0) {
-00916                                 pFont->usFontSize = (USHORT)ucTmp;
-00917                         }
-00918                         ucTmp = ucGetByte(iFodo + iFodoOff + 2, aucGrpprl);
-00919                         DBG_DEC(ucTmp);
-00920                         break;
-00921                 case  98:       /* cIco */
-00922                         pFont->ucFontColor =
-00923                                 ucGetByte(iFodo + iFodoOff + 1, aucGrpprl);
-00924                         break;
-00925                 case  99:       /* cHps */
-00926                         pFont->usFontSize =
-00927                                 usGetWord(iFodo + iFodoOff + 1, aucGrpprl);
-00928                         break;
-00929                 case 100:       /* cHpsInc */
-00930                         DBG_MSG("100: sprmCHpsInc");
-00931                         ucTmp = ucGetByte(iFodo + iFodoOff + 1, aucGrpprl);
-00932                         DBG_DEC(ucTmp);
-00933                         break;
-00934                 case 103:       /* cMajority */
-00935                         DBG_MSG("103: sprmCMajority");
-00936                         break;
-00937                 case 104:       /* cIss */
-00938                         ucTmp = ucGetByte(iFodo + iFodoOff + 1, aucGrpprl);
-00939                         ucTmp &= 0x07;
-00940                         if (ucTmp == 1) {
-00941                                 pFont->usFontStyle |= FONT_SUPERSCRIPT;
-00942                                 NO_DBG_MSG("Superscript");
-00943                         } else if (ucTmp == 2) {
-00944                                 pFont->usFontStyle |= FONT_SUBSCRIPT;
-00945                                 NO_DBG_MSG("Subscript");
-00946                         }
-00947                         break;
-00948                 case 106:       /* cHpsInc1 */
-00949                         usTmp = usGetWord(iFodo + iFodoOff + 1, aucGrpprl);
-00950                         lTmp = (long)pFont->usFontSize + (long)usTmp;
-00951                         if (lTmp < 8) {
-00952                                 pFont->usFontSize = 8;
-00953                         } else if (lTmp > 32766) {
-00954                                 pFont->usFontSize = 32766;
-00955                         } else {
-00956                                 pFont->usFontSize = (USHORT)lTmp;
-00957                         }
-00958                         break;
-00959                 case 108:       /* cMajority50 */
-00960                         DBG_MSG("108: sprmCMajority50");
-00961                         break;
-00962                 case 109:       /* cHpsMul */
-00963                         DBG_MSG("109: sprmCHpsMul");
-00964                         usTmp = usGetWord(iFodo + iFodoOff + 1, aucGrpprl);
-00965                         DBG_DEC(usTmp);
-00966                         break;
-00967                 default:
-00968                         break;
-00969                 }
-00970                 iInfoLen = iGet6InfoLength(iFodo + iFodoOff, aucGrpprl);
-00971                 fail(iInfoLen <= 0);
-00972                 iFodoOff += iInfoLen;
-00973         }
-00974 } /* end of vGet6FontInfo */
-00975 
-00976 /*
-00977  * Fill the picture information block with information
-00978  * from a Word 6/7 file.
-00979  * Returns TRUE when successful, otherwise FALSE
-00980  */
-00981 static BOOL
-00982 bGet6PicInfo(int iFodo,
-00983         const UCHAR *aucGrpprl, int iBytes, picture_block_type *pPicture)
-00984 {
-00985         int     iFodoOff, iInfoLen;
-00986         BOOL    bFound;
-00987         UCHAR   ucTmp;
-00988 
-00989         TRACE_MSG("vGet6PicInfo");
-00990 
-00991         fail(iFodo < 0 || aucGrpprl == NULL || pPicture == NULL);
-00992 
-00993         iFodoOff = 0;
-00994         bFound = FALSE;
-00995         while (iBytes >= iFodoOff + 1) {
-00996                 switch (ucGetByte(iFodo + iFodoOff, aucGrpprl)) {
-00997                 case  68:       /* fcPic */
-00998                         pPicture->ulPictureOffset = ulGetLong(
-00999                                         iFodo + iFodoOff + 2, aucGrpprl);
-01000                         bFound = TRUE;
-01001                         break;
-01002 #if 0
-01003                 case  71:       /* fData */
-01004                         ucTmp = ucGetByte(iFodo + iFodoOff + 1, aucGrpprl);
-01005                         if (ucTmp == 0x01) {
-01006                                 /* Not a picture, but a form field */
-01007                                 return FALSE;
-01008                         }
-01009                         DBG_DEC_C(ucTmp != 0, ucTmp);
-01010                         break;
-01011 #endif
-01012                 case  75:       /* fOle2 */
-01013                         ucTmp = ucGetByte(iFodo + iFodoOff + 1, aucGrpprl);
-01014                         if (ucTmp == 0x01) {
-01015                                 /* Not a picture, but an OLE object */
-01016                                 return FALSE;
-01017                         }
-01018                         DBG_DEC_C(ucTmp != 0, ucTmp);
-01019                         break;
-01020                 default:
-01021                         break;
-01022                 }
-01023                 iInfoLen = iGet6InfoLength(iFodo + iFodoOff, aucGrpprl);
-01024                 fail(iInfoLen <= 0);
-01025                 iFodoOff += iInfoLen;
-01026         }
-01027         return bFound;
-01028 } /* end of bGet6PicInfo */
-01029 
-01030 /*
-01031  * Build the lists with Character Information for Word 6/7 files
-01032  */
-01033 void
-01034 vGet6ChrInfo(FILE *pFile, ULONG ulStartBlock,
-01035         const ULONG *aulBBD, size_t tBBDLen, const UCHAR *aucHeader)
-01036 {
-01037         font_block_type         tFont;
-01038         picture_block_type      tPicture;
-01039         USHORT  *ausCharPage;
-01040         UCHAR   *aucBuffer;
-01041         ULONG   ulFileOffset, ulCharPos, ulBeginCharInfo;
-01042         size_t  tCharInfoLen, tOffset, tSize, tLenOld, tLen, tCharPageNum;
-01043         size_t  tIndex, tIndex2, tRun;
-01044         int     iFodo, iLen;
-01045         USHORT  usCharFirstPage, usCount, usIstd;
-01046         UCHAR   aucFpage[BIG_BLOCK_SIZE];
-01047 
-01048         fail(pFile == NULL || aucHeader == NULL);
-01049         fail(ulStartBlock > MAX_BLOCKNUMBER && ulStartBlock != END_OF_CHAIN);
-01050         fail(aulBBD == NULL);
-01051 
-01052         ulBeginCharInfo = ulGetLong(0xb8, aucHeader); /* fcPlcfbteChpx */
-01053         NO_DBG_HEX(lBeginCharInfo);
-01054         tCharInfoLen = (size_t)ulGetLong(0xbc, aucHeader); /* lcbPlcfbteChpx */
-01055         NO_DBG_DEC(tCharInfoLen);
-01056         if (tCharInfoLen < 4) {
-01057                 DBG_DEC(tCharInfoLen);
-01058                 return;
-01059         }
-01060 
-01061         aucBuffer = xmalloc(tCharInfoLen);
-01062         if (!bReadBuffer(pFile, ulStartBlock,
-01063                         aulBBD, tBBDLen, BIG_BLOCK_SIZE,
-01064                         aucBuffer, ulBeginCharInfo, tCharInfoLen)) {
-01065                 aucBuffer = xfree(aucBuffer);
-01066                 return;
-01067         }
-01068 
-01069         tLen = (tCharInfoLen - 4) / 6;
-01070         ausCharPage = xcalloc(tLen, sizeof(USHORT));
-01071         for (tIndex = 0, tOffset = (tLen + 1) * 4;
-01072              tIndex < tLen;
-01073              tIndex++, tOffset += 2) {
-01074                  ausCharPage[tIndex] = usGetWord(tOffset, aucBuffer);
-01075                  NO_DBG_DEC(ausCharPage[tIndex]);
-01076         }
-01077         DBG_HEX(ulGetLong(0, aucBuffer));
-01078         aucBuffer = xfree(aucBuffer);
-01079         tCharPageNum = (size_t)usGetWord(0x18e, aucHeader); /* cpnBteChp */
-01080         DBG_DEC(tCharPageNum);
-01081         if (tLen < tCharPageNum) {
-01082                 /* Replace CharPage by a longer version */
-01083                 tLenOld = tLen;
-01084                 usCharFirstPage = usGetWord(0x18a, aucHeader); /* pnChrFirst */
-01085                 DBG_DEC(usCharFirstPage);
-01086                 tLen += tCharPageNum - 1;
-01087                 tSize = tLen * sizeof(USHORT);
-01088                 ausCharPage = xrealloc(ausCharPage, tSize);
-01089                 /* Add new values */
-01090                 usCount = usCharFirstPage + 1;
-01091                 for (tIndex = tLenOld; tIndex < tLen; tIndex++) {
-01092                         ausCharPage[tIndex] = usCount;
-01093                         NO_DBG_DEC(ausCharPage[tIndex]);
-01094                         usCount++;
-01095                 }
-01096         }
-01097 
-01098         for (tIndex = 0; tIndex < tLen; tIndex++) {
-01099                 if (!bReadBuffer(pFile, ulStartBlock,
-01100                                 aulBBD, tBBDLen, BIG_BLOCK_SIZE,
-01101                                 aucFpage,
-01102                                 (ULONG)ausCharPage[tIndex] * BIG_BLOCK_SIZE,
-01103                                 BIG_BLOCK_SIZE)) {
-01104                         break;
-01105                 }
-01106                 tRun = (size_t)ucGetByte(0x1ff, aucFpage);
-01107                 NO_DBG_DEC(tRun);
-01108                 for (tIndex2 = 0; tIndex2 < tRun; tIndex2++) {
-01109                         ulCharPos = ulGetLong(tIndex2 * 4, aucFpage);
-01110                         ulFileOffset = ulCharPos2FileOffset(ulCharPos);
-01111                         iFodo = 2 * (int)ucGetByte(
-01112                                 (tRun + 1) * 4 + tIndex2, aucFpage);
-01113 
-01114                         iLen = (int)ucGetByte(iFodo, aucFpage);
-01115 
-01116                         usIstd = usGetIstd(ulFileOffset);
-01117                         vFillFontFromStylesheet(usIstd, &tFont);
-01118                         if (iFodo != 0) {
-01119                                 vGet6FontInfo(iFodo, usIstd,
-01120                                         aucFpage + 1, iLen - 1, &tFont);
-01121                         }
-01122                         tFont.ulFileOffset = ulFileOffset;
-01123                         vAdd2FontInfoList(&tFont);
-01124 
-01125                         if (iFodo <= 0) {
-01126                                 continue;
-01127                         }
-01128 
-01129                         (void)memset(&tPicture, 0, sizeof(tPicture));
-01130                         if (bGet6PicInfo(iFodo, aucFpage + 1,
-01131                                                 iLen - 1, &tPicture)) {
-01132                                 tPicture.ulFileOffset = ulFileOffset;
-01133                                 tPicture.ulFileOffsetPicture =
-01134                                         ulDataPos2FileOffset(
-01135                                                 tPicture.ulPictureOffset);
-01136                                 vAdd2PictInfoList(&tPicture);
-01137                         }
-01138                 }
-01139         }
-01140         ausCharPage = xfree(ausCharPage);
-01141 } /* end of vGet6ChrInfo */
-
-
Generated by  - -doxygen 1.6.2
- - diff -r 59758314f811 -r d4524d6a4472 Symbian3/Examples/guid-6013a680-57f9-415b-8851-c4fa63356636/prop8_8c_source.html --- a/Symbian3/Examples/guid-6013a680-57f9-415b-8851-c4fa63356636/prop8_8c_source.html Fri Jun 11 15:24:34 2010 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1512 +0,0 @@ - - - - -TB9.2 Example Applications: examples/PIPS/antiword/src/prop8.c Source File - - - - - -

examples/PIPS/antiword/src/prop8.c

00001 /*
-00002  * prop8.c
-00003  * Copyright (C) 1998-2005 A.J. van Os; Released under GNU GPL
-00004  *
-00005  * Description:
-00006  * Read the property information from a MS Word 8, 9,10 or 11 file
-00007  *
-00008  * Word  8 is better known as Word 97 or as Word 98 for Mac
-00009  * Word  9 is better known as Word 2000 or as Word 2001 for Mac
-00010  * Word 10 is better known as Word 2002 or as Word XP
-00011  * Word 11 is better known as Word 2003
-00012  */
-00013 
-00014 #include <stdlib.h>
-00015 #include <string.h>
-00016 #include "antiword.h"
-00017 
-00018 #define DEFAULT_LISTCHAR        0x002e  /* A full stop */
-00019 
-00020 
-00021 /*
-00022  * iGet8InfoLength - the length of the information for Word 8/9/10/11 files
-00023  */
-00024 static int
-00025 iGet8InfoLength(int iByteNbr, const UCHAR *aucGrpprl)
-00026 {
-00027         int     iTmp, iDel, iAdd;
-00028         USHORT  usOpCode;
-00029 
-00030         usOpCode = usGetWord(iByteNbr, aucGrpprl);
-00031 
-00032         switch (usOpCode & 0xe000) {
-00033         case 0x0000: case 0x2000:
-00034                 return 3;
-00035         case 0x4000: case 0x8000: case 0xa000:
-00036                 return 4;
-00037         case 0xe000:
-00038                 return 5;
-00039         case 0x6000:
-00040                 return 6;
-00041         case 0xc000:
-00042                 iTmp = (int)ucGetByte(iByteNbr + 2, aucGrpprl);
-00043                 if (usOpCode == 0xc615 && iTmp == 255) {
-00044                         iDel = (int)ucGetByte(iByteNbr + 3, aucGrpprl);
-00045                         iAdd = (int)ucGetByte(
-00046                                         iByteNbr + 4 + iDel * 4, aucGrpprl);
-00047                         iTmp = 2 + iDel * 4 + iAdd * 3;
-00048                 }
-00049                 return 3 + iTmp;
-00050         default:
-00051                 DBG_HEX(usOpCode);
-00052                 DBG_FIXME();
-00053                 return 1;
-00054         }
-00055 } /* end of iGet8InfoLength */
-00056 
-00057 /*
-00058  * aucFillInfoBuffer - fill the information buffer
-00059  *
-00060  * Returns the information buffer when successful, otherwise NULL
-00061  */
-00062 static UCHAR *
-00063 aucFillInfoBuffer(FILE *pFile, const pps_type *pTable,
-00064         const ULONG *aulBBD, size_t tBBDLen,
-00065         const ULONG *aulSBD, size_t tSBDLen,
-00066         ULONG ulBeginInfo, size_t tInfoLen)
-00067 {
-00068         const ULONG     *aulBlockDepot;
-00069         UCHAR   *aucBuffer;
-00070         size_t  tBlockDepotLen, tBlockSize;
-00071 
-00072         fail(pFile == NULL || pTable == NULL);
-00073         fail(aulBBD == NULL || aulSBD == NULL);
-00074         fail(tInfoLen == 0);
-00075 
-00076         NO_DBG_DEC(pTable->ulSB);
-00077         NO_DBG_HEX(pTable->ulSize);
-00078         if (pTable->ulSize == 0) {
-00079                 DBG_MSG("No information");
-00080                 return NULL;
-00081         }
-00082 
-00083         if (pTable->ulSize < MIN_SIZE_FOR_BBD_USE) {
-00084                 /* Use the Small Block Depot */
-00085                 aulBlockDepot = aulSBD;
-00086                 tBlockDepotLen = tSBDLen;
-00087                 tBlockSize = SMALL_BLOCK_SIZE;
-00088         } else {
-00089                 /* Use the Big Block Depot */
-00090                 aulBlockDepot = aulBBD;
-00091                 tBlockDepotLen = tBBDLen;
-00092                 tBlockSize = BIG_BLOCK_SIZE;
-00093         }
-00094         aucBuffer = xmalloc(tInfoLen);
-00095         if (!bReadBuffer(pFile, pTable->ulSB,
-00096                         aulBlockDepot, tBlockDepotLen, tBlockSize,
-00097                         aucBuffer, ulBeginInfo, tInfoLen)) {
-00098                 aucBuffer = xfree(aucBuffer);
-00099                 return NULL;
-00100         }
-00101         return aucBuffer;
-00102 } /* end of aucFillInfoBuffer */
-00103 
-00104 /*
-00105  * Build the lists with Document Property Information for Word 8/9/10/11 files
-00106  */
-00107 void
-00108 vGet8DopInfo(FILE *pFile, const pps_type *pTable,
-00109         const ULONG *aulBBD, size_t tBBDLen,
-00110         const ULONG *aulSBD, size_t tSBDLen,
-00111         const UCHAR *aucHeader)
-00112 {
-00113         document_block_type     tDocument;
-00114         UCHAR   *aucBuffer;
-00115         ULONG   ulBeginDocpInfo, ulTmp;
-00116         size_t  tDocpInfoLen;
-00117         USHORT  usTmp;
-00118 
-00119         fail(pFile == NULL || pTable == NULL || aucHeader == NULL);
-00120         fail(aulBBD == NULL || aulSBD == NULL);
-00121 
-00122         ulBeginDocpInfo = ulGetLong(0x192, aucHeader); /* fcDop */
-00123         NO_DBG_HEX(ulBeginSectInfo);
-00124         tDocpInfoLen = (size_t)ulGetLong(0x196, aucHeader); /* lcbDop */
-00125         NO_DBG_DEC(tSectInfoLen);
-00126         if (tDocpInfoLen < 28) {
-00127                 DBG_MSG("No Document information");
-00128                 return;
-00129         }
-00130 
-00131         aucBuffer = aucFillInfoBuffer(pFile, pTable,
-00132                         aulBBD, tBBDLen, aulSBD, tSBDLen,
-00133                         ulBeginDocpInfo, tDocpInfoLen);
-00134         if (aucBuffer == NULL) {
-00135                 return;
-00136         }
-00137 
-00138         usTmp = usGetWord(0x00, aucBuffer);
-00139         tDocument.ucHdrFtrSpecification = (UCHAR)(usTmp >> 8); /* grpfIhdt */
-00140         tDocument.usDefaultTabWidth = usGetWord(0x0a, aucBuffer); /* dxaTab */
-00141         ulTmp = ulGetLong(0x14, aucBuffer); /* dttmCreated */
-00142         tDocument.tCreateDate = tConvertDTTM(ulTmp);
-00143         ulTmp = ulGetLong(0x18, aucBuffer); /* dttmRevised */
-00144         tDocument.tRevisedDate = tConvertDTTM(ulTmp);
-00145         vCreateDocumentInfoList(&tDocument);
-00146 
-00147         aucBuffer = xfree(aucBuffer);
-00148 } /* end of vGet8DopInfo */
-00149 
-00150 /*
-00151  * Fill the section information block with information
-00152  * from a Word 8/9/10/11 file.
-00153  */
-00154 static void
-00155 vGet8SectionInfo(const UCHAR *aucGrpprl, size_t tBytes,
-00156                 section_block_type *pSection)
-00157 {
-00158         UINT    uiIndex;
-00159         int     iFodoOff, iInfoLen, iSize, iTmp;
-00160         USHORT  usCcol;
-00161         UCHAR   ucTmp;
-00162 
-00163         fail(aucGrpprl == NULL || pSection == NULL);
-00164 
-00165         iFodoOff = 0;
-00166         while (tBytes >= (size_t)iFodoOff + 2) {
-00167                 iInfoLen = 0;
-00168                 switch (usGetWord(iFodoOff, aucGrpprl)) {
-00169                 case 0x3009:    /* bkc */
-00170                         ucTmp = ucGetByte(iFodoOff + 2, aucGrpprl);
-00171                         DBG_DEC(ucTmp);
-00172                         pSection->bNewPage = ucTmp != 0 && ucTmp != 1;
-00173                         break;
-00174                 case 0x3014:    /* grpfIhdt */
-00175                         pSection->ucHdrFtrSpecification =
-00176                                         ucGetByte(iFodoOff + 2, aucGrpprl);
-00177                         break;
-00178                 case 0x500b:    /* ccolM1 */
-00179                         usCcol = 1 + usGetWord(iFodoOff + 2, aucGrpprl);
-00180                         DBG_DEC(usCcol);
-00181                         break;
-00182                 case 0xd202:    /* olstAnm */
-00183                         iSize = (int)ucGetByte(iFodoOff + 2, aucGrpprl);
-00184                         DBG_DEC_C(iSize != 212, iSize);
-00185                         for (uiIndex = 0, iTmp = iFodoOff + 3;
-00186                              uiIndex < 9 && iTmp < iFodoOff + 3 + iSize - 15;
-00187                              uiIndex++, iTmp += 16) {
-00188                                 pSection->aucNFC[uiIndex] =
-00189                                                 ucGetByte(iTmp, aucGrpprl);
-00190                                 DBG_DEC(pSection->aucNFC[uiIndex]);
-00191                                 ucTmp = ucGetByte(iTmp + 3, aucGrpprl);
-00192                                 DBG_HEX(ucTmp);
-00193                                 if ((ucTmp & BIT(2)) != 0) {
-00194                                         pSection->usNeedPrevLvl |=
-00195                                                         (USHORT)BIT(uiIndex);
-00196                                 }
-00197                                 if ((ucTmp & BIT(3)) != 0) {
-00198                                         pSection->usHangingIndent |=
-00199                                                         (USHORT)BIT(uiIndex);
-00200                                 }
-00201                         }
-00202                         DBG_HEX(pSection->usNeedPrevLvl);
-00203                         DBG_HEX(pSection->usHangingIndent);
-00204                         break;
-00205                 default:
-00206                         break;
-00207                 }
-00208                 if (iInfoLen <= 0) {
-00209                         iInfoLen = iGet8InfoLength(iFodoOff, aucGrpprl);
-00210                         fail(iInfoLen <= 0);
-00211                 }
-00212                 iFodoOff += iInfoLen;
-00213         }
-00214 } /* end of vGet8SectionInfo */
-00215 
-00216 /*
-00217  * Build the lists with Section Property Information for Word 8/9/10/11 files
-00218  */
-00219 void
-00220 vGet8SepInfo(FILE *pFile, const pps_info_type *pPPS,
-00221         const ULONG *aulBBD, size_t tBBDLen,
-00222         const ULONG *aulSBD, size_t tSBDLen,
-00223         const UCHAR *aucHeader)
-00224 {
-00225         section_block_type      tSection;
-00226         ULONG   *aulSectPage, *aulCharPos;
-00227         UCHAR   *aucBuffer, *aucFpage;
-00228         ULONG   ulBeginOfText, ulTextOffset, ulBeginSectInfo;
-00229         size_t  tSectInfoLen, tIndex, tOffset, tLen, tBytes;
-00230         UCHAR   aucTmp[2];
-00231 
-00232         fail(pFile == NULL || pPPS == NULL || aucHeader == NULL);
-00233         fail(aulBBD == NULL || aulSBD == NULL);
-00234 
-00235         ulBeginOfText = ulGetLong(0x18, aucHeader); /* fcMin */
-00236         NO_DBG_HEX(ulBeginOfText);
-00237         ulBeginSectInfo = ulGetLong(0xca, aucHeader); /* fcPlcfsed */
-00238         NO_DBG_HEX(ulBeginSectInfo);
-00239         tSectInfoLen = (size_t)ulGetLong(0xce, aucHeader); /* lcbPlcfsed */
-00240         NO_DBG_DEC(tSectInfoLen);
-00241         if (tSectInfoLen < 4) {
-00242                 DBG_DEC(tSectInfoLen);
-00243                 return;
-00244         }
-00245 
-00246         aucBuffer = aucFillInfoBuffer(pFile, &pPPS->tTable,
-00247                         aulBBD, tBBDLen, aulSBD, tSBDLen,
-00248                         ulBeginSectInfo, tSectInfoLen);
-00249         if (aucBuffer == NULL) {
-00250                 return;
-00251         }
-00252         NO_DBG_PRINT_BLOCK(aucBuffer, tSectInfoLen);
-00253 
-00254         /* Read the Section Descriptors */
-00255         tLen = (tSectInfoLen - 4) / 16;
-00256         /* Save the section offsets */
-00257         aulCharPos = xcalloc(tLen, sizeof(ULONG));
-00258         for (tIndex = 0, tOffset = 0;
-00259              tIndex < tLen;
-00260              tIndex++, tOffset += 4) {
-00261                 ulTextOffset = ulGetLong(tOffset, aucBuffer);
-00262                 NO_DBG_HEX(ulTextOffset);
-00263                 aulCharPos[tIndex] = ulBeginOfText + ulTextOffset;
-00264                 NO_DBG_HEX(aulCharPos[tIndex]);
-00265         }
-00266         /* Save the Sepx offsets */
-00267         aulSectPage = xcalloc(tLen, sizeof(ULONG));
-00268         for (tIndex = 0, tOffset = (tLen + 1) * 4;
-00269              tIndex < tLen;
-00270              tIndex++, tOffset += 12) {
-00271                  aulSectPage[tIndex] = ulGetLong(tOffset + 2, aucBuffer);
-00272                  NO_DBG_HEX(aulSectPage[tIndex]); /* fcSepx */
-00273         }
-00274         aucBuffer = xfree(aucBuffer);
-00275 
-00276         /* Read the Section Properties */
-00277         for (tIndex = 0; tIndex < tLen; tIndex++) {
-00278                 if (aulSectPage[tIndex] == FC_INVALID) {
-00279                         vDefault2SectionInfoList(aulCharPos[tIndex]);
-00280                         continue;
-00281                 }
-00282                 /* Get the number of bytes to read */
-00283                 if (!bReadBuffer(pFile, pPPS->tWordDocument.ulSB,
-00284                                 aulBBD, tBBDLen, BIG_BLOCK_SIZE,
-00285                                 aucTmp, aulSectPage[tIndex], 2)) {
-00286                         continue;
-00287                 }
-00288                 tBytes = 2 + (size_t)usGetWord(0, aucTmp);
-00289                 NO_DBG_DEC(tBytes);
-00290                 /* Read the bytes */
-00291                 aucFpage = xmalloc(tBytes);
-00292                 if (!bReadBuffer(pFile, pPPS->tWordDocument.ulSB,
-00293                                 aulBBD, tBBDLen, BIG_BLOCK_SIZE,
-00294                                 aucFpage, aulSectPage[tIndex], tBytes)) {
-00295                         aucFpage = xfree(aucFpage);
-00296                         continue;
-00297                 }
-00298                 NO_DBG_PRINT_BLOCK(aucFpage, tBytes);
-00299                 /* Process the bytes */
-00300                 vGetDefaultSection(&tSection);
-00301                 vGet8SectionInfo(aucFpage + 2, tBytes - 2, &tSection);
-00302                 vAdd2SectionInfoList(&tSection, aulCharPos[tIndex]);
-00303                 aucFpage = xfree(aucFpage);
-00304         }
-00305         aulCharPos = xfree(aulCharPos);
-00306         aulSectPage = xfree(aulSectPage);
-00307 } /* end of vGet8SepInfo */
-00308 
-00309 /*
-00310  * Build the list with Header/Footer Information for Word 8/9/10/11 files
-00311  */
-00312 void
-00313 vGet8HdrFtrInfo(FILE *pFile, const pps_type *pTable,
-00314         const ULONG *aulBBD, size_t tBBDLen,
-00315         const ULONG *aulSBD, size_t tSBDLen,
-00316         const UCHAR *aucHeader)
-00317 {
-00318         ULONG   *aulCharPos;
-00319         UCHAR   *aucBuffer;
-00320         ULONG   ulHdrFtrOffset, ulBeginHdrFtrInfo;
-00321         size_t  tHdrFtrInfoLen, tIndex, tOffset, tLen;
-00322 
-00323         fail(pFile == NULL || pTable == NULL || aucHeader == NULL);
-00324         fail(aulBBD == NULL || aulSBD == NULL);
-00325 
-00326         ulBeginHdrFtrInfo = ulGetLong(0xf2, aucHeader); /* fcPlcfhdd */
-00327         NO_DBG_HEX(ulBeginHdrFtrInfo);
-00328         tHdrFtrInfoLen = (size_t)ulGetLong(0xf6, aucHeader); /* lcbPlcfhdd */
-00329         NO_DBG_DEC(tHdrFtrInfoLen);
-00330         if (tHdrFtrInfoLen < 8) {
-00331                 DBG_DEC_C(tHdrFtrInfoLen != 0, tHdrFtrInfoLen);
-00332                 return;
-00333         }
-00334 
-00335         aucBuffer = aucFillInfoBuffer(pFile, pTable,
-00336                         aulBBD, tBBDLen, aulSBD, tSBDLen,
-00337                         ulBeginHdrFtrInfo, tHdrFtrInfoLen);
-00338         if (aucBuffer == NULL) {
-00339                 return;
-00340         }
-00341         NO_DBG_PRINT_BLOCK(aucBuffer, tHdrFtrInfoLen);
-00342 
-00343         tLen = tHdrFtrInfoLen / 4 - 1;
-00344         DBG_DEC_C(tLen % 12 != 1 && tLen % 12 != 7, tLen);
-00345         /* Save the header/footer offsets */
-00346         aulCharPos = xcalloc(tLen, sizeof(ULONG));
-00347         for (tIndex = 0, tOffset = 0;
-00348              tIndex < tLen;
-00349              tIndex++, tOffset += 4) {
-00350                 ulHdrFtrOffset = ulGetLong(tOffset, aucBuffer);
-00351                 NO_DBG_HEX(ulHdrFtrOffset);
-00352                 aulCharPos[tIndex] = ulHdrFtrOffset2CharPos(ulHdrFtrOffset);
-00353                 NO_DBG_HEX(aulCharPos[tIndex]);
-00354         }
-00355         vCreat8HdrFtrInfoList(aulCharPos, tLen);
-00356         /* Clean up and leave */
-00357         aulCharPos = xfree(aulCharPos);
-00358         aucBuffer = xfree(aucBuffer);
-00359 } /* end of vGet8HdrFtrInfo */
-00360 
-00361 /*
-00362  * Translate the rowinfo to a member of the row_info enumeration
-00363  */
-00364 row_info_enum
-00365 eGet8RowInfo(int iFodo,
-00366         const UCHAR *aucGrpprl, int iBytes, row_block_type *pRow)
-00367 {
-00368         int     iFodoOff, iInfoLen;
-00369         int     iIndex, iSize, iCol;
-00370         int     iPosCurr, iPosPrev;
-00371         USHORT  usTmp;
-00372         BOOL    bFound2416_0, bFound2416_1, bFound2417_0, bFound2417_1;
-00373         BOOL    bFound244b_0, bFound244b_1, bFound244c_0, bFound244c_1;
-00374         BOOL    bFoundd608;
-00375 
-00376         fail(iFodo < 0 || aucGrpprl == NULL || pRow == NULL);
-00377 
-00378         iFodoOff = 0;
-00379         bFound2416_0 = FALSE;
-00380         bFound2416_1 = FALSE;
-00381         bFound2417_0 = FALSE;
-00382         bFound2417_1 = FALSE;
-00383         bFound244b_0 = FALSE;
-00384         bFound244b_1 = FALSE;
-00385         bFound244c_0 = FALSE;
-00386         bFound244c_1 = FALSE;
-00387         bFoundd608 = FALSE;
-00388         while (iBytes >= iFodoOff + 2) {
-00389                 iInfoLen = 0;
-00390                 switch (usGetWord(iFodo + iFodoOff, aucGrpprl)) {
-00391                 case 0x2416:    /* fInTable */
-00392                         if (odd(ucGetByte(iFodo + iFodoOff + 2, aucGrpprl))) {
-00393                                 bFound2416_1 = TRUE;
-00394                         } else {
-00395                                 bFound2416_0 = TRUE;
-00396                         }
-00397                         break;
-00398                 case 0x2417:    /* fTtp */
-00399                         if (odd(ucGetByte(iFodo + iFodoOff + 2, aucGrpprl))) {
-00400                                 bFound2417_1 = TRUE;
-00401                         } else {
-00402                                 bFound2417_0 = TRUE;
-00403                         }
-00404                         break;
-00405                 case 0x244b:    /* sub-table fInTable */
-00406                         if (odd(ucGetByte(iFodo + iFodoOff + 2, aucGrpprl))) {
-00407                                 bFound244b_1 = TRUE;
-00408                         } else {
-00409                                 bFound244b_0 = TRUE;
-00410                         }
-00411                         break;
-00412                 case 0x244c:    /* sub-table fTtp */
-00413                         if (odd(ucGetByte(iFodo + iFodoOff + 2, aucGrpprl))) {
-00414                                 bFound244c_1 = TRUE;
-00415                         } else {
-00416                                 bFound244c_0 = TRUE;
-00417                         }
-00418                         break;
-00419                 case 0x6424:    /* brcTop */
-00420                         usTmp = usGetWord(iFodo + iFodoOff + 2, aucGrpprl);
-00421                         usTmp &= 0xff00;
-00422                         NO_DBG_DEC(usTmp >> 8);
-00423                         if (usTmp == 0) {
-00424                                 pRow->ucBorderInfo &= ~TABLE_BORDER_TOP;
-00425                         } else {
-00426                                 pRow->ucBorderInfo |= TABLE_BORDER_TOP;
-00427                         }
-00428                         break;
-00429                 case 0x6425:    /* brcLeft */
-00430                         usTmp = usGetWord(iFodo + iFodoOff + 2, aucGrpprl);
-00431                         usTmp &= 0xff00;
-00432                         NO_DBG_DEC(usTmp >> 8);
-00433                         if (usTmp == 0) {
-00434                                 pRow->ucBorderInfo &= ~TABLE_BORDER_LEFT;
-00435                         } else {
-00436                                 pRow->ucBorderInfo |= TABLE_BORDER_LEFT;
-00437                         }
-00438                         break;
-00439                 case 0x6426:    /* brcBottom */
-00440                         usTmp = usGetWord(iFodo + iFodoOff + 2, aucGrpprl);
-00441                         usTmp &= 0xff00;
-00442                         NO_DBG_DEC(usTmp >> 8);
-00443                         if (usTmp == 0) {
-00444                                 pRow->ucBorderInfo &= ~TABLE_BORDER_BOTTOM;
-00445                         } else {
-00446                                 pRow->ucBorderInfo |= TABLE_BORDER_BOTTOM;
-00447                         }
-00448                         break;
-00449                 case 0x6427:    /* brcRight */
-00450                         usTmp = usGetWord(iFodo + iFodoOff + 2, aucGrpprl);
-00451                         usTmp &= 0xff00;
-00452                         NO_DBG_DEC(usTmp >> 8);
-00453                         if (usTmp == 0) {
-00454                                 pRow->ucBorderInfo &= ~TABLE_BORDER_RIGHT;
-00455                         } else {
-00456                                 pRow->ucBorderInfo |= TABLE_BORDER_RIGHT;
-00457                         }
-00458                         break;
-00459                 case 0xd606:    /* cDefTable10 */
-00460                         DBG_MSG("0xd606: sprmTDefTable10");
-00461                         iSize = (int)usGetWord(iFodo + iFodoOff + 2, aucGrpprl);
-00462                         DBG_DEC(iSize);
-00463                         break;
-00464                 case 0xd608:    /* cDefTable */
-00465                         iSize = (int)usGetWord(iFodo + iFodoOff + 2, aucGrpprl);
-00466                         if (iSize < 6 || iBytes < iFodoOff + 8) {
-00467                                 DBG_DEC(iSize);
-00468                                 DBG_DEC(iFodoOff);
-00469                                 iInfoLen = 2;
-00470                                 break;
-00471                         }
-00472                         iCol = (int)ucGetByte(iFodo + iFodoOff + 4, aucGrpprl);
-00473                         if (iCol < 1 ||
-00474                             iBytes < iFodoOff + 4 + (iCol + 1) * 2) {
-00475                                 DBG_DEC(iCol);
-00476                                 DBG_DEC(iFodoOff);
-00477                                 iInfoLen = 2;
-00478                                 break;
-00479                         }
-00480                         if (iCol >= (int)elementsof(pRow->asColumnWidth)) {
-00481                                 DBG_DEC(iCol);
-00482                                 werr(1, "The number of columns is corrupt");
-00483                         }
-00484                         pRow->ucNumberOfColumns = (UCHAR)iCol;
-00485                         iPosPrev = (int)(short)usGetWord(
-00486                                         iFodo + iFodoOff + 5,
-00487                                         aucGrpprl);
-00488                         for (iIndex = 0; iIndex < iCol; iIndex++) {
-00489                                 iPosCurr = (int)(short)usGetWord(
-00490                                         iFodo + iFodoOff + 7 + iIndex * 2,
-00491                                         aucGrpprl);
-00492                                 pRow->asColumnWidth[iIndex] =
-00493                                                 (short)(iPosCurr - iPosPrev);
-00494                                 iPosPrev = iPosCurr;
-00495                         }
-00496                         bFoundd608 = TRUE;
-00497                         break;
-00498                 default:
-00499                         break;
-00500                 }
-00501                 if (iInfoLen <= 0) {
-00502                         iInfoLen =
-00503                                 iGet8InfoLength(iFodo + iFodoOff, aucGrpprl);
-00504                         fail(iInfoLen <= 0);
-00505                 }
-00506                 iFodoOff += iInfoLen;
-00507         }
-00508 
-00509         if (bFound2417_1 && bFoundd608) {
-00510                 return found_end_of_row;
-00511         }
-00512         if (bFound2417_0 && !bFoundd608) {
-00513                 return found_not_end_of_row;
-00514         }
-00515         if (bFound2416_1 || bFound244b_1) {
-00516                 return found_a_cell;
-00517         }
-00518         if (bFound2416_0 || bFound244b_0) {
-00519                 return found_not_a_cell;
-00520         }
-00521         return found_nothing;
-00522 } /* end of eGet8RowInfo */
-00523 
-00524 /*
-00525  * Fill the style information block with information
-00526  * from a Word 8/9/10/11 file.
-00527  */
-00528 void
-00529 vGet8StyleInfo(int iFodo,
-00530         const UCHAR *aucGrpprl, int iBytes, style_block_type *pStyle)
-00531 {
-00532         list_block_type tList6;
-00533         const list_block_type   *pList;
-00534         int     iFodoOff, iInfoLen;
-00535         int     iTmp, iDel, iAdd, iBefore;
-00536         USHORT  usOpCode, usTmp;
-00537         short   sTmp;
-00538 
-00539         fail(iFodo < 0 || aucGrpprl == NULL || pStyle == NULL);
-00540 
-00541         NO_DBG_DEC_C(pStyle->usListIndex != 0, pStyle->usIstd);
-00542         NO_DBG_DEC_C(pStyle->usListIndex != 0, pStyle->usListIndex);
-00543 
-00544         (void)memset(&tList6, 0, sizeof(tList6));
-00545 
-00546         iFodoOff = 0;
-00547         while (iBytes >= iFodoOff + 2) {
-00548                 iInfoLen = 0;
-00549                 usOpCode = usGetWord(iFodo + iFodoOff, aucGrpprl);
-00550                 switch (usOpCode) {
-00551                 case 0x2403:    /* jc */
-00552                         pStyle->ucAlignment = ucGetByte(
-00553                                         iFodo + iFodoOff + 2, aucGrpprl);
-00554                         break;
-00555                 case 0x260a:    /* ilvl */
-00556                         pStyle->ucListLevel =
-00557                                 ucGetByte(iFodo + iFodoOff + 2, aucGrpprl);
-00558                         NO_DBG_DEC(pStyle->ucListLevel);
-00559                         pStyle->ucNumLevel = pStyle->ucListLevel;
-00560                         break;
-00561                 case 0x4600:    /* istd */
-00562                         usTmp = usGetWord(iFodo + iFodoOff + 2, aucGrpprl);
-00563                         NO_DBG_DEC(usTmp);
-00564                         break;
-00565                 case 0x460b:    /* ilfo */
-00566                         pStyle->usListIndex =
-00567                                 usGetWord(iFodo + iFodoOff + 2, aucGrpprl);
-00568                         NO_DBG_DEC(pStyle->usListIndex);
-00569                         break;
-00570                 case 0x4610: /* Nest dxaLeft */
-00571                         sTmp = (short)usGetWord(
-00572                                         iFodo + iFodoOff + 2, aucGrpprl);
-00573                         pStyle->sLeftIndent += sTmp;
-00574                         if (pStyle->sLeftIndent < 0) {
-00575                                 pStyle->sLeftIndent = 0;
-00576                         }
-00577                         DBG_DEC(sTmp);
-00578                         DBG_DEC(pStyle->sLeftIndent);
-00579                         break;
-00580                 case 0xc60d:    /* ChgTabsPapx */
-00581                 case 0xc615:    /* ChgTabs */
-00582                         iTmp = (int)ucGetByte(iFodo + iFodoOff + 2, aucGrpprl);
-00583                         if (iTmp < 2) {
-00584                                 iInfoLen = 1;
-00585                                 break;
-00586                         }
-00587                         NO_DBG_DEC(iTmp);
-00588                         iDel = (int)ucGetByte(iFodo + iFodoOff + 3, aucGrpprl);
-00589                         if (iTmp < 2 + 2 * iDel) {
-00590                                 iInfoLen = 1;
-00591                                 break;
-00592                         }
-00593                         NO_DBG_DEC(iDel);
-00594                         iAdd = (int)ucGetByte(
-00595                                 iFodo + iFodoOff + 4 + 2 * iDel, aucGrpprl);
-00596                         if (iTmp < 2 + 2 * iDel + 2 * iAdd) {
-00597                                 iInfoLen = 1;
-00598                                 break;
-00599                         }
-00600                         NO_DBG_DEC(iAdd);
-00601                         break;
-00602                 case 0x840e:    /* dxaRight */
-00603                         pStyle->sRightIndent = (short)usGetWord(
-00604                                         iFodo + iFodoOff + 2, aucGrpprl);
-00605                         NO_DBG_DEC(pStyle->sRightIndent);
-00606                         break;
-00607                 case 0x840f:    /* dxaLeft */
-00608                         pStyle->sLeftIndent = (short)usGetWord(
-00609                                         iFodo + iFodoOff + 2, aucGrpprl);
-00610                         NO_DBG_DEC(pStyle->sLeftIndent);
-00611                         break;
-00612                 case 0x8411:    /* dxaLeft1 */
-00613                         pStyle->sLeftIndent1 = (short)usGetWord(
-00614                                         iFodo + iFodoOff + 2, aucGrpprl);
-00615                         NO_DBG_DEC(pStyle->sLeftIndent1);
-00616                         break;
-00617                 case 0xa413:    /* dyaBefore */
-00618                         pStyle->usBeforeIndent = usGetWord(
-00619                                         iFodo + iFodoOff + 2, aucGrpprl);
-00620                         NO_DBG_DEC(pStyle->usBeforeIndent);
-00621                         break;
-00622                 case 0xa414:    /* dyaAfter */
-00623                         pStyle->usAfterIndent = usGetWord(
-00624                                         iFodo + iFodoOff + 2, aucGrpprl);
-00625                         NO_DBG_DEC(pStyle->usAfterIndent);
-00626                         break;
-00627                 case 0xc63e:    /* anld */
-00628                         iTmp = (int)ucGetByte(
-00629                                         iFodo + iFodoOff + 2, aucGrpprl);
-00630                         DBG_DEC_C(iTmp < 84, iTmp);
-00631                         if (iTmp >= 1) {
-00632                                 tList6.ucNFC = ucGetByte(
-00633                                         iFodo + iFodoOff + 3, aucGrpprl);
-00634                         }
-00635                         if (tList6.ucNFC != LIST_BULLETS && iTmp >= 2) {
-00636                                 iBefore = (int)ucGetByte(
-00637                                         iFodo + iFodoOff + 4, aucGrpprl);
-00638                         } else {
-00639                                 iBefore = 0;
-00640                         }
-00641                         if (iTmp >= 12) {
-00642                                 tList6.ulStartAt = (ULONG)usGetWord(
-00643                                         iFodo + iFodoOff + 13, aucGrpprl);
-00644                         }
-00645                         if (iTmp >= iBefore + 22) {
-00646                                 tList6.usListChar = usGetWord(
-00647                                         iFodo + iFodoOff + iBefore + 23,
-00648                                         aucGrpprl);
-00649                                 DBG_HEX(tList6.usListChar);
-00650                         }
-00651                         break;
-00652                 default:
-00653                         NO_DBG_HEX(usOpCode);
-00654                         break;
-00655                 }
-00656                 if (iInfoLen <= 0) {
-00657                         iInfoLen =
-00658                                 iGet8InfoLength(iFodo + iFodoOff, aucGrpprl);
-00659                         fail(iInfoLen <= 0);
-00660                 }
-00661                 iFodoOff += iInfoLen;
-00662         }
-00663 
-00664         if (pStyle->usListIndex == 2047) {
-00665                 /* Old style list */
-00666                 pStyle->usStartAt = (USHORT)tList6.ulStartAt;
-00667                 pStyle->usListChar = tList6.usListChar;
-00668                 pStyle->ucNFC = tList6.ucNFC;
-00669         } else {
-00670                 /* New style list */
-00671                 pList = pGetListInfo(pStyle->usListIndex, pStyle->ucListLevel);
-00672                 if (pList != NULL) {
-00673                         pStyle->bNoRestart = pList->bNoRestart;
-00674                         fail(pList->ulStartAt > (ULONG)USHRT_MAX);
-00675                         pStyle->usStartAt = (USHORT)pList->ulStartAt;
-00676                         pStyle->usListChar = pList->usListChar;
-00677                         pStyle->ucNFC = pList->ucNFC;
-00678                         if (pStyle->sLeftIndent <= 0) {
-00679                                 pStyle->sLeftIndent = pList->sLeftIndent;
-00680                         }
-00681                 }
-00682         }
-00683 } /* end of vGet8StyleInfo */
-00684 
-00685 /*
-00686  * Get the left indentation value from the style information block
-00687  *
-00688  * Returns the value when found, otherwise 0
-00689  */
-00690 static short
-00691 sGetLeftIndent(const UCHAR *aucGrpprl, size_t tBytes)
-00692 {
-00693         int     iOffset, iInfoLen;
-00694         USHORT  usOpCode, usTmp;
-00695 
-00696         fail(aucGrpprl == NULL);
-00697 
-00698         iOffset = 0;
-00699         while (tBytes >= (size_t)iOffset + 4) {
-00700                 usOpCode = usGetWord(iOffset, aucGrpprl);
-00701                 if (usOpCode == 0x840f) {       /* dxaLeft */
-00702                         usTmp = usGetWord(iOffset + 2, aucGrpprl);
-00703                         if (usTmp <= 0x7fff) {
-00704                                 NO_DBG_DEC(usTmp);
-00705                                 return (short)usTmp;
-00706                         }
-00707                 }
-00708                 iInfoLen = iGet8InfoLength(iOffset, aucGrpprl);
-00709                 fail(iInfoLen <= 0);
-00710                 iOffset += iInfoLen;
-00711         }
-00712         return 0;
-00713 } /* end of sGetLeftIndent */
-00714 
-00715 /*
-00716  * Build the list with List Information for Word 8/9/10/11 files
-00717  */
-00718 void
-00719 vGet8LstInfo(FILE *pFile, const pps_info_type *pPPS,
-00720         const ULONG *aulBBD, size_t tBBDLen,
-00721         const ULONG *aulSBD, size_t tSBDLen,
-00722         const UCHAR *aucHeader)
-00723 {
-00724         list_block_type tList;
-00725         const ULONG     *aulBlockDepot;
-00726         UCHAR   *aucLfoInfo, *aucLstfInfo, *aucPapx, *aucXString;
-00727         ULONG   ulBeginLfoInfo, ulBeginLstfInfo, ulBeginLvlfInfo;
-00728         ULONG   ulListID, ulStart;
-00729         size_t  tBlockDepotLen, tBlockSize;
-00730         size_t  tLfoInfoLen, tLstfInfoLen, tPapxLen, tXstLen, tOff;
-00731         size_t  tLstfRecords, tStart, tIndex;
-00732         int     iNums;
-00733         USHORT  usIstd;
-00734         UCHAR   ucTmp, ucListLevel, ucMaxLevel, ucChpxLen;
-00735         UCHAR   aucLvlfInfo[28], aucXst[2];
-00736 
-00737         fail(pFile == NULL || pPPS == NULL || aucHeader == NULL);
-00738         fail(aulBBD == NULL || aulSBD == NULL);
-00739 
-00740         NO_DBG_DEC(pPPS->tTable.ulSB);
-00741         NO_DBG_HEX(pPPS->tTable.ulSize);
-00742         if (pPPS->tTable.ulSize == 0) {
-00743                 DBG_MSG("No list information");
-00744                 return;
-00745         }
-00746 
-00747         if (pPPS->tTable.ulSize < MIN_SIZE_FOR_BBD_USE) {
-00748                 /* Use the Small Block Depot */
-00749                 aulBlockDepot = aulSBD;
-00750                 tBlockDepotLen = tSBDLen;
-00751                 tBlockSize = SMALL_BLOCK_SIZE;
-00752         } else {
-00753                 /* Use the Big Block Depot */
-00754                 aulBlockDepot = aulBBD;
-00755                 tBlockDepotLen = tBBDLen;
-00756                 tBlockSize = BIG_BLOCK_SIZE;
-00757         }
-00758 
-00759         /* LFO (List Format Override) */
-00760         ulBeginLfoInfo = ulGetLong(0x2ea, aucHeader); /* fcPlfLfo */
-00761         DBG_HEX(ulBeginLfoInfo);
-00762         tLfoInfoLen = (size_t)ulGetLong(0x2ee, aucHeader); /* lcbPlfLfo */
-00763         DBG_DEC(tLfoInfoLen);
-00764         if (tLfoInfoLen == 0) {
-00765                 DBG_MSG("No lists in this document");
-00766                 return;
-00767         }
-00768 
-00769         aucLfoInfo = xmalloc(tLfoInfoLen);
-00770         if (!bReadBuffer(pFile, pPPS->tTable.ulSB,
-00771                         aulBlockDepot, tBlockDepotLen, tBlockSize,
-00772                         aucLfoInfo, ulBeginLfoInfo, tLfoInfoLen)) {
-00773                 aucLfoInfo = xfree(aucLfoInfo);
-00774                 return;
-00775         }
-00776         NO_DBG_PRINT_BLOCK(aucLfoInfo, tLfoInfoLen);
-00777         vBuildLfoList(aucLfoInfo, tLfoInfoLen);
-00778         aucLfoInfo = xfree(aucLfoInfo);
-00779 
-00780         /* LSTF (LiST data on File) */
-00781         ulBeginLstfInfo = ulGetLong(0x2e2, aucHeader); /* fcPlcfLst */
-00782         DBG_HEX(ulBeginLstfInfo);
-00783         tLstfInfoLen = (size_t)ulGetLong(0x2e6, aucHeader); /* lcbPlcfLst */
-00784         DBG_DEC(tLstfInfoLen);
-00785         if (tLstfInfoLen == 0) {
-00786                 DBG_MSG("No list data on file");
-00787                 return;
-00788         }
-00789 
-00790         aucLstfInfo = xmalloc(tLstfInfoLen);
-00791         if (!bReadBuffer(pFile, pPPS->tTable.ulSB,
-00792                         aulBlockDepot, tBlockDepotLen, tBlockSize,
-00793                         aucLstfInfo, ulBeginLstfInfo, tLstfInfoLen)) {
-00794                 aucLstfInfo = xfree(aucLstfInfo);
-00795                 return;
-00796         }
-00797         NO_DBG_PRINT_BLOCK(aucLstfInfo, tLstfInfoLen);
-00798 
-00799         tLstfRecords = (size_t)usGetWord(0, aucLstfInfo);
-00800         if (2 + tLstfRecords * 28 < tLstfInfoLen) {
-00801                 DBG_DEC(2 + tLstfRecords * 28);
-00802                 DBG_DEC(tLstfInfoLen);
-00803                 aucLstfInfo = xfree(aucLstfInfo);
-00804                 return;
-00805         }
-00806 
-00807         /* LVLF (List leVeL on File) */
-00808         ulBeginLvlfInfo = ulBeginLstfInfo + tLstfInfoLen;
-00809         DBG_HEX(ulBeginLvlfInfo);
-00810 
-00811         aucXString = NULL;
-00812         ulStart = ulBeginLvlfInfo;
-00813 
-00814         for (tIndex = 0, tStart = 2;
-00815              tIndex < tLstfRecords;
-00816              tIndex++, tStart += 28) {
-00817                 ulListID = ulGetLong(tStart, aucLstfInfo);
-00818                 NO_DBG_HEX(ulListID);
-00819                 ucTmp = ucGetByte(tStart + 26, aucLstfInfo);
-00820                 ucMaxLevel = odd(ucTmp) ? 1 : 9;
-00821                 for (ucListLevel = 0; ucListLevel < ucMaxLevel; ucListLevel++) {
-00822                         fail(aucXString != NULL);
-00823                         usIstd = usGetWord(
-00824                                         tStart + 8 + 2 * (size_t)ucListLevel,
-00825                                         aucLstfInfo);
-00826                         DBG_DEC_C(usIstd != STI_NIL, usIstd);
-00827                         NO_DBG_HEX(ulStart);
-00828                         (void)memset(&tList, 0, sizeof(tList));
-00829                         /* Read the lvlf (List leVeL on File) */
-00830                         if (!bReadBuffer(pFile, pPPS->tTable.ulSB,
-00831                                         aulBlockDepot, tBlockDepotLen,
-00832                                         tBlockSize, aucLvlfInfo,
-00833                                         ulStart, sizeof(aucLvlfInfo))) {
-00834                                 aucLstfInfo = xfree(aucLstfInfo);
-00835                                 return;
-00836                         }
-00837                         NO_DBG_PRINT_BLOCK(aucLvlfInfo, sizeof(aucLvlfInfo));
-00838                         if (bAllZero(aucLvlfInfo, sizeof(aucLvlfInfo))) {
-00839                                 tList.ulStartAt = 1;
-00840                                 tList.ucNFC = 0x00;
-00841                                 tList.bNoRestart = FALSE;
-00842                         } else {
-00843                                 tList.ulStartAt = ulGetLong(0, aucLvlfInfo);
-00844                                 tList.ucNFC = ucGetByte(4, aucLvlfInfo);
-00845                                 ucTmp = ucGetByte(5, aucLvlfInfo);
-00846                                 tList.bNoRestart = (ucTmp & BIT(3)) != 0;
-00847                                 DBG_MSG_C((ucTmp & BIT(4)) != 0 &&
-00848                                         (ucTmp & BIT(6)) != 0, "Found one");
-00849                         }
-00850                         ulStart += sizeof(aucLvlfInfo);
-00851                         tPapxLen = (size_t)ucGetByte(25, aucLvlfInfo);
-00852                         if (tPapxLen != 0) {
-00853                                 aucPapx = xmalloc(tPapxLen);
-00854                                 /* Read the Papx */
-00855                                 if (!bReadBuffer(pFile, pPPS->tTable.ulSB,
-00856                                                 aulBlockDepot, tBlockDepotLen,
-00857                                                 tBlockSize, aucPapx,
-00858                                                 ulStart, tPapxLen)) {
-00859                                         aucPapx = xfree(aucPapx);
-00860                                         aucLstfInfo = xfree(aucLstfInfo);
-00861                                         return;
-00862                                 }
-00863                                 NO_DBG_PRINT_BLOCK(aucPapx, tPapxLen);
-00864                                 tList.sLeftIndent =
-00865                                         sGetLeftIndent(aucPapx, tPapxLen);
-00866                                 aucPapx = xfree(aucPapx);
-00867                         }
-00868                         ulStart += tPapxLen;
-00869                         ucChpxLen = ucGetByte(24, aucLvlfInfo);
-00870                         ulStart += (ULONG)ucChpxLen;
-00871                         /* Read the length of the XString */
-00872                         if (!bReadBuffer(pFile, pPPS->tTable.ulSB,
-00873                                         aulBlockDepot, tBlockDepotLen,
-00874                                         tBlockSize, aucXst,
-00875                                         ulStart, sizeof(aucXst))) {
-00876                                 aucLstfInfo = xfree(aucLstfInfo);
-00877                                 return;
-00878                         }
-00879                         NO_DBG_PRINT_BLOCK(aucXst, sizeof(aucXst));
-00880                         tXstLen = (size_t)usGetWord(0, aucXst);
-00881                         ulStart += sizeof(aucXst);
-00882                         if (tXstLen == 0) {
-00883                                 tList.usListChar = DEFAULT_LISTCHAR;
-00884                                 vAdd2ListInfoList(ulListID,
-00885                                                 usIstd,
-00886                                                 ucListLevel,
-00887                                                 &tList);
-00888                                 continue;
-00889                         }
-00890                         tXstLen *= 2;   /* Length in chars to length in bytes */
-00891                         aucXString = xmalloc(tXstLen);
-00892                         /* Read the XString */
-00893                         if (!bReadBuffer(pFile, pPPS->tTable.ulSB,
-00894                                         aulBlockDepot, tBlockDepotLen,
-00895                                         tBlockSize, aucXString,
-00896                                         ulStart, tXstLen)) {
-00897                                 aucXString = xfree(aucXString);
-00898                                 aucLstfInfo = xfree(aucLstfInfo);
-00899                                 return;
-00900                         }
-00901                         NO_DBG_PRINT_BLOCK(aucXString, tXstLen);
-00902                         tOff = 0;
-00903                         for (iNums = 6; iNums < 15; iNums++) {
-00904                                 ucTmp = ucGetByte(iNums, aucLvlfInfo);
-00905                                 if (ucTmp == 0) {
-00906                                         break;
-00907                                 }
-00908                                 tOff = (size_t)ucTmp;
-00909                         }
-00910                         tOff *= 2;      /* Offset in chars to offset in bytes */
-00911                         NO_DBG_DEC(tOff);
-00912                         if (tList.ucNFC == LIST_SPECIAL ||
-00913                             tList.ucNFC == LIST_SPECIAL2 ||
-00914                             tList.ucNFC == LIST_BULLETS) {
-00915                                 tList.usListChar = usGetWord(0, aucXString);
-00916                         } else if (tOff != 0 && tOff < tXstLen) {
-00917                                 tList.usListChar = usGetWord(tOff, aucXString);
-00918                         } else {
-00919                                 tList.usListChar = DEFAULT_LISTCHAR;
-00920                         }
-00921                         vAdd2ListInfoList(ulListID,
-00922                                         usIstd,
-00923                                         ucListLevel,
-00924                                         &tList);
-00925                         ulStart += tXstLen;
-00926                         aucXString = xfree(aucXString);
-00927                 }
-00928         }
-00929         aucLstfInfo = xfree(aucLstfInfo);
-00930 } /* end of vGet8LstInfo */
-00931 
-00932 /*
-00933  * Build the lists with Paragraph Information for Word 8/9/10/11 files
-00934  */
-00935 void
-00936 vGet8PapInfo(FILE *pFile, const pps_info_type *pPPS,
-00937         const ULONG *aulBBD, size_t tBBDLen,
-00938         const ULONG *aulSBD, size_t tSBDLen,
-00939         const UCHAR *aucHeader)
-00940 {
-00941         row_block_type          tRow;
-00942         style_block_type        tStyle;
-00943         ULONG           *aulParfPage;
-00944         UCHAR   *aucBuffer;
-00945         ULONG   ulCharPos, ulCharPosFirst, ulCharPosLast;
-00946         ULONG   ulBeginParfInfo;
-00947         size_t  tParfInfoLen, tOffset, tLen;
-00948         int     iIndex, iIndex2, iRun, iFodo, iLen;
-00949         row_info_enum   eRowInfo;
-00950         USHORT  usIstd;
-00951         UCHAR   aucFpage[BIG_BLOCK_SIZE];
-00952 
-00953         fail(pFile == NULL || pPPS == NULL || aucHeader == NULL);
-00954         fail(aulBBD == NULL || aulSBD == NULL);
-00955 
-00956         ulBeginParfInfo = ulGetLong(0x102, aucHeader); /* fcPlcfbtePapx */
-00957         NO_DBG_HEX(ulBeginParfInfo);
-00958         tParfInfoLen = (size_t)ulGetLong(0x106, aucHeader); /* lcbPlcfbtePapx */
-00959         NO_DBG_DEC(tParfInfoLen);
-00960         if (tParfInfoLen < 4) {
-00961                 DBG_DEC(tParfInfoLen);
-00962                 return;
-00963         }
-00964 
-00965         aucBuffer = aucFillInfoBuffer(pFile, &pPPS->tTable,
-00966                         aulBBD, tBBDLen, aulSBD, tSBDLen,
-00967                         ulBeginParfInfo, tParfInfoLen);
-00968         if (aucBuffer == NULL) {
-00969                 return;
-00970         }
-00971         NO_DBG_PRINT_BLOCK(aucBuffer, tParfInfoLen);
-00972 
-00973         tLen = (tParfInfoLen / 4 - 1) / 2;
-00974         aulParfPage = xcalloc(tLen, sizeof(ULONG));
-00975         for (iIndex = 0, tOffset = (tLen + 1) * 4;
-00976              iIndex < (int)tLen;
-00977              iIndex++, tOffset += 4) {
-00978                  aulParfPage[iIndex] = ulGetLong(tOffset, aucBuffer);
-00979                  NO_DBG_DEC(aulParfPage[iIndex]);
-00980         }
-00981         DBG_HEX(ulGetLong(0, aucBuffer));
-00982         aucBuffer = xfree(aucBuffer);
-00983         NO_DBG_PRINT_BLOCK(aucHeader, HEADER_SIZE);
-00984 
-00985         (void)memset(&tRow, 0, sizeof(tRow));
-00986         ulCharPosFirst = CP_INVALID;
-00987         for (iIndex = 0; iIndex < (int)tLen; iIndex++) {
-00988                 fail(aulParfPage[iIndex] > ULONG_MAX / BIG_BLOCK_SIZE);
-00989                 if (!bReadBuffer(pFile, pPPS->tWordDocument.ulSB,
-00990                                 aulBBD, tBBDLen, BIG_BLOCK_SIZE,
-00991                                 aucFpage,
-00992                                 aulParfPage[iIndex] * BIG_BLOCK_SIZE,
-00993                                 BIG_BLOCK_SIZE)) {
-00994                         break;
-00995                 }
-00996                 NO_DBG_PRINT_BLOCK(aucFpage, BIG_BLOCK_SIZE);
-00997                 iRun = (int)ucGetByte(0x1ff, aucFpage);
-00998                 NO_DBG_DEC(iRun);
-00999                 for (iIndex2 = 0; iIndex2 < iRun; iIndex2++) {
-01000                         NO_DBG_HEX(ulGetLong(iIndex2 * 4, aucFpage));
-01001                         iFodo = 2 * (int)ucGetByte(
-01002                                 (iRun + 1) * 4 + iIndex2 * 13, aucFpage);
-01003                         if (iFodo <= 0) {
-01004                                 continue;
-01005                         }
-01006 
-01007                         iLen = 2 * (int)ucGetByte(iFodo, aucFpage);
-01008                         if (iLen == 0) {
-01009                                 iFodo++;
-01010                                 iLen = 2 * (int)ucGetByte(iFodo, aucFpage);
-01011                         }
-01012 
-01013                         usIstd = usGetWord(iFodo + 1, aucFpage);
-01014                         vFillStyleFromStylesheet(usIstd, &tStyle);
-01015                         vGet8StyleInfo(iFodo, aucFpage + 3, iLen - 3, &tStyle);
-01016                         ulCharPos = ulGetLong(iIndex2 * 4, aucFpage);
-01017                         NO_DBG_HEX(ulCharPos);
-01018                         tStyle.ulFileOffset = ulCharPos2FileOffsetX(
-01019                                                 ulCharPos, &tStyle.eListID);
-01020                         vAdd2StyleInfoList(&tStyle);
-01021 
-01022                         eRowInfo = eGet8RowInfo(iFodo,
-01023                                         aucFpage + 3, iLen - 3, &tRow);
-01024                         switch (eRowInfo) {
-01025                         case found_a_cell:
-01026                                 if (ulCharPosFirst != CP_INVALID) {
-01027                                         break;
-01028                                 }
-01029                                 ulCharPosFirst = ulGetLong(
-01030                                                 iIndex2 * 4, aucFpage);
-01031                                 NO_DBG_HEX(ulCharPosFirst);
-01032                                 tRow.ulCharPosStart = ulCharPosFirst;
-01033                                 tRow.ulFileOffsetStart =
-01034                                         ulCharPos2FileOffset(ulCharPosFirst);
-01035                                 NO_DBG_HEX_C(
-01036                                         tRow.ulFileOffsetStart == FC_INVALID,
-01037                                         ulCharPosFirst);
-01038                                 break;
-01039                         case found_end_of_row:
-01040                                 ulCharPosLast = ulGetLong(
-01041                                                 iIndex2 * 4, aucFpage);
-01042                                 NO_DBG_HEX(ulCharPosLast);
-01043                                 tRow.ulCharPosEnd = ulCharPosLast;
-01044                                 tRow.ulFileOffsetEnd =
-01045                                         ulCharPos2FileOffset(ulCharPosLast);
-01046                                 NO_DBG_HEX_C(tRow.ulFileOffsetEnd == FC_INVALID,
-01047                                                         ulCharPosLast);
-01048                                 vAdd2RowInfoList(&tRow);
-01049                                 (void)memset(&tRow, 0, sizeof(tRow));
-01050                                 ulCharPosFirst = CP_INVALID;
-01051                                 break;
-01052                         case found_nothing:
-01053                                 break;
-01054                         default:
-01055                                 DBG_DEC(eRowInfo);
-01056                                 break;
-01057                         }
-01058                 }
-01059         }
-01060         aulParfPage = xfree(aulParfPage);
-01061 } /* end of vGet8PapInfo */
-01062 
-01063 /*
-01064  * Fill the font information block with information
-01065  * from a Word 8/9/10/11 file.
-01066  */
-01067 void
-01068 vGet8FontInfo(int iFodo, USHORT usIstd,
-01069         const UCHAR *aucGrpprl, int iBytes, font_block_type *pFont)
-01070 {
-01071         long    lTmp;
-01072         int     iFodoOff, iInfoLen;
-01073         USHORT  usFtc0, usFtc1, usFtc2, usTmp;
-01074         UCHAR   ucTmp;
-01075 
-01076         fail(iFodo < 0 || aucGrpprl == NULL || pFont == NULL);
-01077 
-01078         usFtc0 = USHRT_MAX;
-01079         usFtc1 = USHRT_MAX;
-01080         usFtc2 = USHRT_MAX;
-01081 
-01082         iFodoOff = 0;
-01083         while (iBytes >= iFodoOff + 2) {
-01084                 switch (usGetWord(iFodo + iFodoOff, aucGrpprl)) {
-01085                 case 0x0800:    /* fRMarkDel */
-01086                         ucTmp = ucGetByte(iFodo + iFodoOff + 2, aucGrpprl);
-01087                         if (ucTmp == 0) {
-01088                                 pFont->usFontStyle &= ~FONT_MARKDEL;
-01089                         } else {
-01090                                 pFont->usFontStyle |= FONT_MARKDEL;
-01091                         }
-01092                         break;
-01093                 case 0x0835:    /* fBold */
-01094                         ucTmp = ucGetByte(iFodo + iFodoOff + 2, aucGrpprl);
-01095                         switch (ucTmp) {
-01096                         case   0:       /* Unset */
-01097                                 pFont->usFontStyle &= ~FONT_BOLD;
-01098                                 break;
-01099                         case   1:       /* Set */
-01100                                 pFont->usFontStyle |= FONT_BOLD;
-01101                                 break;
-01102                         case 128:       /* Unchanged */
-01103                                 break;
-01104                         case 129:       /* Negation */
-01105                                 pFont->usFontStyle ^= FONT_BOLD;
-01106                                 break;
-01107                         default:
-01108                                 DBG_DEC(ucTmp);
-01109                                 DBG_FIXME();
-01110                                 break;
-01111                         }
-01112                         break;
-01113                 case 0x0836:    /* fItalic */
-01114                         ucTmp = ucGetByte(iFodo + iFodoOff + 2, aucGrpprl);
-01115                         switch (ucTmp) {
-01116                         case   0:       /* Unset */
-01117                                 pFont->usFontStyle &= ~FONT_ITALIC;
-01118                                 break;
-01119                         case   1:       /* Set */
-01120                                 pFont->usFontStyle |= FONT_ITALIC;
-01121                                 break;
-01122                         case 128:       /* Unchanged */
-01123                                 break;
-01124                         case 129:       /* Negation */
-01125                                 pFont->usFontStyle ^= FONT_ITALIC;
-01126                                 break;
-01127                         default:
-01128                                 DBG_DEC(ucTmp);
-01129                                 DBG_FIXME();
-01130                                 break;
-01131                         }
-01132                         break;
-01133                 case 0x0837:    /* fStrike */
-01134                         ucTmp = ucGetByte(iFodo + iFodoOff + 2, aucGrpprl);
-01135                         switch (ucTmp) {
-01136                         case   0:       /* Unset */
-01137                                 pFont->usFontStyle &= ~FONT_STRIKE;
-01138                                 break;
-01139                         case   1:       /* Set */
-01140                                 pFont->usFontStyle |= FONT_STRIKE;
-01141                                 break;
-01142                         case 128:       /* Unchanged */
-01143                                 break;
-01144                         case 129:       /* Negation */
-01145                                 pFont->usFontStyle ^= FONT_STRIKE;
-01146                                 break;
-01147                         default:
-01148                                 DBG_DEC(ucTmp);
-01149                                 DBG_FIXME();
-01150                                 break;
-01151                         }
-01152                         break;
-01153                 case 0x083a:    /* fSmallCaps */
-01154                         ucTmp = ucGetByte(iFodo + iFodoOff + 2, aucGrpprl);
-01155                         switch (ucTmp) {
-01156                         case   0:       /* Unset */
-01157                                 pFont->usFontStyle &= ~FONT_SMALL_CAPITALS;
-01158                                 break;
-01159                         case   1:       /* Set */
-01160                                 pFont->usFontStyle |= FONT_SMALL_CAPITALS;
-01161                                 break;
-01162                         case 128:       /* Unchanged */
-01163                                 break;
-01164                         case 129:       /* Negation */
-01165                                 pFont->usFontStyle ^= FONT_SMALL_CAPITALS;
-01166                                 break;
-01167                         default:
-01168                                 DBG_DEC(ucTmp);
-01169                                 DBG_FIXME();
-01170                                 break;
-01171                         }
-01172                         break;
-01173                 case 0x083b:    /* fCaps */
-01174                         ucTmp = ucGetByte(iFodo + iFodoOff + 2, aucGrpprl);
-01175                         switch (ucTmp) {
-01176                         case   0:       /* Unset */
-01177                                 pFont->usFontStyle &= ~FONT_CAPITALS;
-01178                                 break;
-01179                         case   1:       /* Set */
-01180                                 pFont->usFontStyle |= FONT_CAPITALS;
-01181                                 break;
-01182                         case 128:       /* Unchanged */
-01183                                 break;
-01184                         case 129:       /* Negation */
-01185                                 pFont->usFontStyle ^= FONT_CAPITALS;
-01186                                 break;
-01187                         default:
-01188                                 DBG_DEC(ucTmp);
-01189                                 DBG_FIXME();
-01190                                 break;
-01191                         }
-01192                         break;
-01193                 case 0x083c:    /* fVanish */
-01194                         ucTmp = ucGetByte(iFodo + iFodoOff + 2, aucGrpprl);
-01195                         switch (ucTmp) {
-01196                         case   0:       /* Unset */
-01197                                 pFont->usFontStyle &= ~FONT_HIDDEN;
-01198                                 break;
-01199                         case   1:       /* Set */
-01200                                 pFont->usFontStyle |= FONT_HIDDEN;
-01201                                 break;
-01202                         case 128:       /* Unchanged */
-01203                                 break;
-01204                         case 129:       /* Negation */
-01205                                 pFont->usFontStyle ^= FONT_HIDDEN;
-01206                                 break;
-01207                         default:
-01208                                 DBG_DEC(ucTmp);
-01209                                 DBG_FIXME();
-01210                                 break;
-01211                         }
-01212                         break;
-01213                 case 0x2a32:    /* cDefault */
-01214                         pFont->usFontStyle &= FONT_HIDDEN;
-01215                         pFont->ucFontColor = FONT_COLOR_DEFAULT;
-01216                         break;
-01217                 case 0x2a33:    /* cPlain */
-01218                         DBG_MSG("2a33: cPlain");
-01219                         vFillFontFromStylesheet(usIstd, pFont);
-01220                         break;
-01221                 case 0x2a3e:    /* cKul */
-01222                         ucTmp = ucGetByte(iFodo + iFodoOff + 2, aucGrpprl);
-01223                         if (ucTmp == 0 || ucTmp == 5) {
-01224                                 pFont->usFontStyle &= ~FONT_UNDERLINE;
-01225                         } else {
-01226                                 NO_DBG_MSG("Underline text");
-01227                                 pFont->usFontStyle |= FONT_UNDERLINE;
-01228                                 if (ucTmp == 6) {
-01229                                         DBG_MSG("Bold text");
-01230                                         pFont->usFontStyle |= FONT_BOLD;
-01231                                 }
-01232                         }
-01233                         break;
-01234                 case 0x2a42:    /* cIco */
-01235                         pFont->ucFontColor =
-01236                                 ucGetByte(iFodo + iFodoOff + 2, aucGrpprl);
-01237                         NO_DBG_DEC(pFont->ucFontColor);
-01238                         break;
-01239                 case 0x2a44:    /* cHpsInc */
-01240                         DBG_MSG("0x2a44: sprmCHpsInc");
-01241                         ucTmp = ucGetByte(iFodo + iFodoOff + 2, aucGrpprl);
-01242                         DBG_DEC(ucTmp);
-01243                         break;
-01244                 case 0x2a48:    /* cIss */
-01245                         ucTmp = ucGetByte(iFodo + iFodoOff + 2, aucGrpprl);
-01246                         ucTmp &= 0x07;
-01247                         if (ucTmp == 1) {
-01248                                 pFont->usFontStyle |= FONT_SUPERSCRIPT;
-01249                                 NO_DBG_MSG("Superscript");
-01250                         } else if (ucTmp == 2) {
-01251                                 pFont->usFontStyle |= FONT_SUBSCRIPT;
-01252                                 NO_DBG_MSG("Subscript");
-01253                         }
-01254                         break;
-01255                 case 0x4a30:    /* cIstd */
-01256                         usTmp = usGetWord(iFodo + iFodoOff + 2, aucGrpprl);
-01257                         NO_DBG_DEC(usTmp);
-01258                         break;
-01259                 case 0x4a43:    /* cHps */
-01260                         pFont->usFontSize =
-01261                                 usGetWord(iFodo + iFodoOff + 2, aucGrpprl);
-01262                         NO_DBG_DEC(pFont->usFontSize);
-01263                         break;
-01264                 case 0x4a4d:    /* cHpsMul */
-01265                         DBG_MSG("0x4a4d: sprmCHpsMul");
-01266                         usTmp = usGetWord(iFodo + iFodoOff + 2, aucGrpprl);
-01267                         DBG_DEC(usTmp);
-01268                         break;
-01269                 case 0x4a4f:    /* cFtc0 */
-01270                         usFtc0 = usGetWord(iFodo + iFodoOff + 2, aucGrpprl);
-01271                         break;
-01272                 case 0x4a50:    /* cFtc1 */
-01273                         usFtc1 = usGetWord(iFodo + iFodoOff + 2, aucGrpprl);
-01274                         break;
-01275                 case 0x4a51:    /* cFtc2 */
-01276                         usFtc2 = usGetWord(iFodo + iFodoOff + 2, aucGrpprl);
-01277                         break;
-01278                 case 0xca47:    /* cMajority */
-01279                         DBG_MSG("0xca47: sprmCMajority");
-01280                         break;
-01281                 case 0xca4a:    /* cHpsInc1 */
-01282                         usTmp = usGetWord(iFodo + iFodoOff + 2, aucGrpprl);
-01283                         lTmp = (long)pFont->usFontSize + (long)usTmp;
-01284                         if (lTmp < 8) {
-01285                                 pFont->usFontSize = 8;
-01286                         } else if (lTmp > 32766) {
-01287                                 pFont->usFontSize = 32766;
-01288                         } else {
-01289                                 pFont->usFontSize = (USHORT)lTmp;
-01290                         }
-01291                         break;
-01292                 case 0xca4c:    /* cMajority50 */
-01293                         DBG_MSG("0xca4c: sprmCMajority50");
-01294                         break;
-01295                 case 0xea3f:    /* cHps, cHpsPos */
-01296                         ucTmp = ucGetByte(iFodo + iFodoOff + 2, aucGrpprl);
-01297                         DBG_DEC(ucTmp);
-01298                         if (ucTmp != 0) {
-01299                                 pFont->usFontSize = (USHORT)ucTmp;
-01300                         }
-01301                         ucTmp = ucGetByte(iFodo + iFodoOff + 3, aucGrpprl);
-01302                         DBG_DEC(ucTmp);
-01303                         break;
-01304                 default:
-01305                         break;
-01306                 }
-01307                 iInfoLen = iGet8InfoLength(iFodo + iFodoOff, aucGrpprl);
-01308                 fail(iInfoLen <= 0);
-01309                 iFodoOff += iInfoLen;
-01310         }
-01311 
-01312         /* Combine the Ftc's to a FontNumber */
-01313         NO_DBG_DEC_C(usFtc0 != USHRT_MAX, usFtc0);
-01314         NO_DBG_DEC_C(usFtc2 != USHRT_MAX, usFtc2);
-01315         NO_DBG_DEC_C(usFtc1 != USHRT_MAX, usFtc1);
-01316         if (usFtc0 <= 0x7fff) {
-01317                 if (usFtc0 <= (USHORT)UCHAR_MAX) {
-01318                         pFont->ucFontNumber = (UCHAR)usFtc0;
-01319                 } else {
-01320                         DBG_DEC(usFtc0);
-01321                         DBG_FIXME();
-01322                         pFont->ucFontNumber = 0;
-01323                 }
-01324         } else if (usFtc2 <= 0x7fff) {
-01325                 if (usFtc2 <= (USHORT)UCHAR_MAX) {
-01326                         pFont->ucFontNumber = (UCHAR)usFtc2;
-01327                 } else {
-01328                         DBG_DEC(usFtc2);
-01329                         DBG_FIXME();
-01330                         pFont->ucFontNumber = 0;
-01331                 }
-01332         } else if (usFtc1 <= 0x7fff) {
-01333                 if (usFtc1 <= (USHORT)UCHAR_MAX) {
-01334                         pFont->ucFontNumber = (UCHAR)usFtc1;
-01335                 } else {
-01336                         DBG_DEC(usFtc1);
-01337                         DBG_FIXME();
-01338                         pFont->ucFontNumber = 0;
-01339                 }
-01340         }
-01341 } /* end of vGet8FontInfo */
-01342 
-01343 /*
-01344  * Fill the picture information block with information
-01345  * from a Word 8/9/10/11 file.
-01346  * Returns TRUE when successful, otherwise FALSE
-01347  */
-01348 static BOOL
-01349 bGet8PicInfo(int iFodo,
-01350         const UCHAR *aucGrpprl, int iBytes, picture_block_type *pPicture)
-01351 {
-01352         ULONG   ulTmp;
-01353         int     iFodoOff, iInfoLen;
-01354         BOOL    bFound;
-01355         UCHAR   ucTmp;
-01356 
-01357         fail(iFodo <= 0 || aucGrpprl == NULL || pPicture == NULL);
-01358 
-01359         iFodoOff = 0;
-01360         bFound = FALSE;
-01361         while (iBytes >= iFodoOff + 2) {
-01362                 switch (usGetWord(iFodo + iFodoOff, aucGrpprl)) {
-01363 #if 0
-01364                 case 0x0806:    /* fData */
-01365                         ucTmp = ucGetByte(iFodo + iFodoOff + 2, aucGrpprl);
-01366                         if (ucTmp == 0x01) {
-01367                                 /* Not a picture, but a form field */
-01368                                 return FALSE;
-01369                         }
-01370                         DBG_DEC_C(ucTmp != 0, ucTmp);
-01371                         break;
-01372 #endif
-01373                 case 0x080a:    /* fOle2 */
-01374                         ucTmp = ucGetByte(iFodo + iFodoOff + 2, aucGrpprl);
-01375                         if (ucTmp == 0x01) {
-01376                                 /* Not a picture, but an OLE object */
-01377                                 return FALSE;
-01378                         }
-01379                         DBG_DEC_C(ucTmp != 0, ucTmp);
-01380                         break;
-01381                 case 0x680e:    /* fcObj */
-01382                         ulTmp = ulGetLong(iFodo + iFodoOff + 2, aucGrpprl);
-01383                         DBG_HEX(ulTmp);
-01384                         break;
-01385                 case 0x6a03:    /* fcPic */
-01386                         pPicture->ulPictureOffset = ulGetLong(
-01387                                         iFodo + iFodoOff + 2, aucGrpprl);
-01388                         bFound = TRUE;
-01389                         break;
-01390                 default:
-01391                         break;
-01392                 }
-01393                 iInfoLen = iGet8InfoLength(iFodo + iFodoOff, aucGrpprl);
-01394                 fail(iInfoLen <= 0);
-01395                 iFodoOff += iInfoLen;
-01396         }
-01397         return bFound;
-01398 } /* end of bGet8PicInfo */
-01399 
-01400 /*
-01401  * Build the lists with Character Information for Word 8/9/10/11 files
-01402  */
-01403 void
-01404 vGet8ChrInfo(FILE *pFile, const pps_info_type *pPPS,
-01405         const ULONG *aulBBD, size_t tBBDLen,
-01406         const ULONG *aulSBD, size_t tSBDLen,
-01407         const UCHAR *aucHeader)
-01408 {
-01409         font_block_type         tFont;
-01410         picture_block_type      tPicture;
-01411         ULONG           *aulCharPage;
-01412         UCHAR   *aucBuffer;
-01413         ULONG   ulFileOffset, ulCharPos, ulBeginCharInfo;
-01414         size_t  tCharInfoLen, tOffset, tLen;
-01415         int     iIndex, iIndex2, iRun, iFodo, iLen;
-01416         USHORT  usIstd;
-01417         UCHAR   aucFpage[BIG_BLOCK_SIZE];
-01418 
-01419         fail(pFile == NULL || pPPS == NULL || aucHeader == NULL);
-01420         fail(aulBBD == NULL || aulSBD == NULL);
-01421 
-01422         ulBeginCharInfo = ulGetLong(0xfa, aucHeader); /* fcPlcfbteChpx */
-01423         NO_DBG_HEX(ulBeginCharInfo);
-01424         tCharInfoLen = (size_t)ulGetLong(0xfe, aucHeader); /* lcbPlcfbteChpx */
-01425         NO_DBG_DEC(tCharInfoLen);
-01426         if (tCharInfoLen < 4) {
-01427                 DBG_DEC(tCharInfoLen);
-01428                 return;
-01429         }
-01430 
-01431         aucBuffer = aucFillInfoBuffer(pFile, &pPPS->tTable,
-01432                         aulBBD, tBBDLen, aulSBD, tSBDLen,
-01433                         ulBeginCharInfo, tCharInfoLen);
-01434         if (aucBuffer == NULL) {
-01435                 return;
-01436         }
-01437         NO_DBG_PRINT_BLOCK(aucBuffer, tCharInfoLen);
-01438 
-01439         tLen = (tCharInfoLen / 4 - 1) / 2;
-01440         aulCharPage = xcalloc(tLen, sizeof(ULONG));
-01441         for (iIndex = 0, tOffset = (tLen + 1) * 4;
-01442              iIndex < (int)tLen;
-01443              iIndex++, tOffset += 4) {
-01444                  aulCharPage[iIndex] = ulGetLong(tOffset, aucBuffer);
-01445                  NO_DBG_DEC(aulCharPage[iIndex]);
-01446         }
-01447         DBG_HEX(ulGetLong(0, aucBuffer));
-01448         aucBuffer = xfree(aucBuffer);
-01449         NO_DBG_PRINT_BLOCK(aucHeader, HEADER_SIZE);
-01450 
-01451         for (iIndex = 0; iIndex < (int)tLen; iIndex++) {
-01452                 fail(aulCharPage[iIndex] > ULONG_MAX / BIG_BLOCK_SIZE);
-01453                 if (!bReadBuffer(pFile, pPPS->tWordDocument.ulSB,
-01454                                 aulBBD, tBBDLen, BIG_BLOCK_SIZE,
-01455                                 aucFpage,
-01456                                 aulCharPage[iIndex] * BIG_BLOCK_SIZE,
-01457                                 BIG_BLOCK_SIZE)) {
-01458                         break;
-01459                 }
-01460                 NO_DBG_PRINT_BLOCK(aucFpage, BIG_BLOCK_SIZE);
-01461                 iRun = (int)ucGetByte(0x1ff, aucFpage);
-01462                 NO_DBG_DEC(iRun);
-01463                 for (iIndex2 = 0; iIndex2 < iRun; iIndex2++) {
-01464                         ulCharPos = ulGetLong(iIndex2 * 4, aucFpage);
-01465                         ulFileOffset = ulCharPos2FileOffset(ulCharPos);
-01466                         iFodo = 2 * (int)ucGetByte(
-01467                                 (iRun + 1) * 4 + iIndex2, aucFpage);
-01468 
-01469                         iLen = (int)ucGetByte(iFodo, aucFpage);
-01470 
-01471                         usIstd = usGetIstd(ulFileOffset);
-01472                         vFillFontFromStylesheet(usIstd, &tFont);
-01473                         if (iFodo != 0) {
-01474                                 vGet8FontInfo(iFodo, usIstd,
-01475                                         aucFpage + 1, iLen - 1, &tFont);
-01476                         }
-01477                         tFont.ulFileOffset = ulFileOffset;
-01478                         vAdd2FontInfoList(&tFont);
-01479 
-01480                         if (iFodo <= 0) {
-01481                                 continue;
-01482                         }
-01483 
-01484                         (void)memset(&tPicture, 0, sizeof(tPicture));
-01485                         if (bGet8PicInfo(iFodo, aucFpage + 1,
-01486                                                 iLen - 1, &tPicture)) {
-01487                                 tPicture.ulFileOffset = ulFileOffset;
-01488                                 tPicture.ulFileOffsetPicture =
-01489                                         ulDataPos2FileOffset(
-01490                                                 tPicture.ulPictureOffset);
-01491                                 vAdd2PictInfoList(&tPicture);
-01492                         }
-01493                 }
-01494         }
-01495         aulCharPage = xfree(aulCharPage);
-01496 } /* end of vGet8ChrInfo */
-
-
Generated by  - -doxygen 1.6.2
- - diff -r 59758314f811 -r d4524d6a4472 Symbian3/Examples/guid-6013a680-57f9-415b-8851-c4fa63356636/properties_8c_source.html --- a/Symbian3/Examples/guid-6013a680-57f9-415b-8851-c4fa63356636/properties_8c_source.html Fri Jun 11 15:24:34 2010 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,214 +0,0 @@ - - - - -TB9.2 Example Applications: examples/PIPS/antiword/src/properties.c Source File - - - - - -

examples/PIPS/antiword/src/properties.c

00001 /*
-00002  * properties.c
-00003  * Copyright (C) 1998-2005 A.J. van Os; Released under GNU GPL
-00004  *
-00005  * Description:
-00006  * Read the properties information from a MS Word file
-00007  */
-00008 
-00009 #include <stdlib.h>
-00010 #include <string.h>
-00011 #include "antiword.h"
-00012 
-00013 
-00014 /*
-00015  * Build the lists with Property Information
-00016  */
-00017 void
-00018 vGetPropertyInfo(FILE *pFile, const pps_info_type *pPPS,
-00019         const ULONG *aulBBD, size_t tBBDLen,
-00020         const ULONG *aulSBD, size_t tSBDLen,
-00021         const UCHAR *aucHeader, int iWordVersion)
-00022 {
-00023         options_type    tOptions;
-00024 
-00025         TRACE_MSG("vGetPropertyInfo");
-00026 
-00027         fail(pFile == NULL);
-00028         fail(pPPS == NULL && iWordVersion >= 6);
-00029         fail(aulBBD == NULL && tBBDLen != 0);
-00030         fail(aulSBD == NULL && tSBDLen != 0);
-00031         fail(aucHeader == NULL);
-00032 
-00033         /* Get the options */
-00034         vGetOptions(&tOptions);
-00035 
-00036         /* Get the property information per Word version */
-00037         switch (iWordVersion) {
-00038         case 0:
-00039                 vGet0DopInfo(pFile, aucHeader);
-00040                 vGet0SepInfo(pFile, aucHeader);
-00041                 vGet0PapInfo(pFile, aucHeader);
-00042                 if (tOptions.eConversionType == conversion_draw ||
-00043                     tOptions.eConversionType == conversion_ps ||
-00044                     tOptions.eConversionType == conversion_xml ||
-00045                     tOptions.eConversionType == conversion_fmt_text ||
-00046                     tOptions.eConversionType == conversion_pdf) {
-00047                         vGet0ChrInfo(pFile, aucHeader);
-00048                 }
-00049                 if (tOptions.eConversionType == conversion_draw ||
-00050                     tOptions.eConversionType == conversion_ps ||
-00051                     tOptions.eConversionType == conversion_pdf) {
-00052                         vCreate0FontTable();
-00053                 }
-00054                 vSet0SummaryInfo(pFile, aucHeader);
-00055                 break;
-00056         case 1:
-00057         case 2:
-00058                 vGet2Stylesheet(pFile, iWordVersion, aucHeader);
-00059                 vGet2DopInfo(pFile, aucHeader);
-00060                 vGet2SepInfo(pFile, aucHeader);
-00061                 vGet2PapInfo(pFile, aucHeader);
-00062                 if (tOptions.eConversionType == conversion_ps ||
-00063                     tOptions.eConversionType == conversion_pdf) {
-00064                         vGet2HdrFtrInfo(pFile, aucHeader);
-00065                 }
-00066                 if (tOptions.eConversionType == conversion_draw ||
-00067                     tOptions.eConversionType == conversion_ps ||
-00068                     tOptions.eConversionType == conversion_xml ||
-00069                     tOptions.eConversionType == conversion_fmt_text ||
-00070                     tOptions.eConversionType == conversion_pdf) {
-00071                         vGet2ChrInfo(pFile, iWordVersion, aucHeader);
-00072                 }
-00073                 if (tOptions.eConversionType == conversion_draw ||
-00074                     tOptions.eConversionType == conversion_ps ||
-00075                     tOptions.eConversionType == conversion_pdf) {
-00076                         vCreate2FontTable(pFile, iWordVersion, aucHeader);
-00077                 }
-00078                 vSet2SummaryInfo(pFile, iWordVersion, aucHeader);
-00079                 break;
-00080         case 4:
-00081         case 5:
-00082                 break;
-00083         case 6:
-00084         case 7:
-00085                 vGet6Stylesheet(pFile, pPPS->tWordDocument.ulSB,
-00086                         aulBBD, tBBDLen, aucHeader);
-00087                 vGet6DopInfo(pFile, pPPS->tWordDocument.ulSB,
-00088                         aulBBD, tBBDLen, aucHeader);
-00089                 vGet6SepInfo(pFile, pPPS->tWordDocument.ulSB,
-00090                         aulBBD, tBBDLen, aucHeader);
-00091                 vGet6PapInfo(pFile, pPPS->tWordDocument.ulSB,
-00092                         aulBBD, tBBDLen, aucHeader);
-00093                 if (tOptions.eConversionType == conversion_ps ||
-00094                     tOptions.eConversionType == conversion_pdf) {
-00095                         vGet6HdrFtrInfo(pFile, pPPS->tWordDocument.ulSB,
-00096                                 aulBBD, tBBDLen, aucHeader);
-00097                 }
-00098                 if (tOptions.eConversionType == conversion_draw ||
-00099                     tOptions.eConversionType == conversion_ps ||
-00100                     tOptions.eConversionType == conversion_xml ||
-00101                     tOptions.eConversionType == conversion_fmt_text ||
-00102                     tOptions.eConversionType == conversion_pdf) {
-00103                         vGet6ChrInfo(pFile, pPPS->tWordDocument.ulSB,
-00104                                 aulBBD, tBBDLen, aucHeader);
-00105                 }
-00106                 if (tOptions.eConversionType == conversion_draw ||
-00107                     tOptions.eConversionType == conversion_ps ||
-00108                     tOptions.eConversionType == conversion_pdf) {
-00109                         vCreate6FontTable(pFile, pPPS->tWordDocument.ulSB,
-00110                                 aulBBD, tBBDLen, aucHeader);
-00111                 }
-00112                 vSet6SummaryInfo(pFile, pPPS,
-00113                         aulBBD, tBBDLen, aulSBD, tSBDLen, aucHeader);
-00114                 break;
-00115         case 8:
-00116                 vGet8LstInfo(pFile, pPPS,
-00117                         aulBBD, tBBDLen, aulSBD, tSBDLen, aucHeader);
-00118                 vGet8Stylesheet(pFile, pPPS,
-00119                         aulBBD, tBBDLen, aulSBD, tSBDLen, aucHeader);
-00120                 vGet8DopInfo(pFile, &pPPS->tTable,
-00121                         aulBBD, tBBDLen, aulSBD, tSBDLen, aucHeader);
-00122                 vGet8SepInfo(pFile, pPPS,
-00123                         aulBBD, tBBDLen, aulSBD, tSBDLen, aucHeader);
-00124                 vGet8PapInfo(pFile, pPPS,
-00125                         aulBBD, tBBDLen, aulSBD, tSBDLen, aucHeader);
-00126                 if (tOptions.eConversionType == conversion_ps ||
-00127                     tOptions.eConversionType == conversion_pdf) {
-00128                         vGet8HdrFtrInfo(pFile, &pPPS->tTable,
-00129                                 aulBBD, tBBDLen, aulSBD, tSBDLen, aucHeader);
-00130                 }
-00131                 if (tOptions.eConversionType == conversion_draw ||
-00132                     tOptions.eConversionType == conversion_ps ||
-00133                     tOptions.eConversionType == conversion_xml ||
-00134                     tOptions.eConversionType == conversion_fmt_text ||
-00135                     tOptions.eConversionType == conversion_pdf) {
-00136                         vGet8ChrInfo(pFile, pPPS,
-00137                                 aulBBD, tBBDLen, aulSBD, tSBDLen, aucHeader);
-00138                 }
-00139                 if (tOptions.eConversionType == conversion_draw ||
-00140                     tOptions.eConversionType == conversion_ps ||
-00141                     tOptions.eConversionType == conversion_pdf) {
-00142                         vCreate8FontTable(pFile, pPPS,
-00143                                 aulBBD, tBBDLen, aulSBD, tSBDLen, aucHeader);
-00144                 }
-00145                 vSet8SummaryInfo(pFile, pPPS,
-00146                         aulBBD, tBBDLen, aulSBD, tSBDLen, aucHeader);
-00147                 break;
-00148         default:
-00149                 DBG_DEC(iWordVersion);
-00150                 DBG_FIXME();
-00151                 werr(0, "Sorry, no property information");
-00152                 break;
-00153         }
-00154 
-00155         /* Temporarily: Correct the font table */
-00156         vCorrectFontTable(tOptions.eConversionType, tOptions.eEncoding);
-00157 } /* end of vGetPropertyInfo */
-00158 
-00159 /*
-00160  * ePropMod2RowInfo - Turn the Property Modifier into row information
-00161  *
-00162  * Returns: the row information
-00163  */
-00164 row_info_enum
-00165 ePropMod2RowInfo(USHORT usPropMod, int iWordVersion)
-00166 {
-00167         row_block_type  tRow;
-00168         const UCHAR     *aucPropMod;
-00169         int     iLen;
-00170 
-00171         TRACE_MSG("ePropMod2RowInfo");
-00172 
-00173         aucPropMod = aucReadPropModListItem(usPropMod);
-00174         if (aucPropMod == NULL) {
-00175                 return found_nothing;
-00176         }
-00177         iLen = (int)usGetWord(0, aucPropMod);
-00178 
-00179         switch (iWordVersion) {
-00180         case 0:
-00181                 return found_nothing;
-00182         case 1:
-00183         case 2:
-00184                 return eGet2RowInfo(0, aucPropMod + 2, iLen, &tRow);
-00185         case 4:
-00186         case 5:
-00187                 return found_nothing;
-00188         case 6:
-00189         case 7:
-00190                 return eGet6RowInfo(0, aucPropMod + 2, iLen, &tRow);
-00191         case 8:
-00192                 return eGet8RowInfo(0, aucPropMod + 2, iLen, &tRow);
-00193         default:
-00194                 DBG_DEC(iWordVersion);
-00195                 DBG_FIXME();
-00196                 return found_nothing;
-00197         }
-00198 } /* end of ePropMod2RowInfo */
-
-
Generated by  - -doxygen 1.6.2
- - diff -r 59758314f811 -r d4524d6a4472 Symbian3/Examples/guid-6013a680-57f9-415b-8851-c4fa63356636/propmod_8c_source.html --- a/Symbian3/Examples/guid-6013a680-57f9-415b-8851-c4fa63356636/propmod_8c_source.html Fri Jun 11 15:24:34 2010 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,126 +0,0 @@ - - - - -TB9.2 Example Applications: examples/PIPS/antiword/src/propmod.c Source File - - - - - -

examples/PIPS/antiword/src/propmod.c

00001 /*
-00002  * propmod.c
-00003  * Copyright (C) 2001-2003 A.J. van Os; Released under GPL
-00004  *
-00005  * Description:
-00006  * Build, read and destroy a list (array) of Word property modifiers
-00007  */
-00008 
-00009 #include <stdio.h>
-00010 #include <string.h>
-00011 #include "antiword.h"
-00012 
-00013 #if defined(DEBUG)
-00014 #define ELEMENTS_TO_ADD  3
-00015 #else
-00016 #define ELEMENTS_TO_ADD 30
-00017 #endif /* DEBUG */
-00018 
-00019 /* Variables needed to write the property modifier list */
-00020 static UCHAR    **ppAnchor = NULL;
-00021 static size_t   tNextFree = 0;
-00022 static size_t   tMaxElements = 0;
-00023 
-00024 
-00025 /*
-00026  * vDestroyPropModList - destroy the property modifier list
-00027  */
-00028 void
-00029 vDestroyPropModList(void)
-00030 {
-00031         size_t  tIndex;
-00032 
-00033         DBG_MSG("vDestroyPropModList");
-00034 
-00035         /* Free all the elements of the list */
-00036         for (tIndex = 0; tIndex < tNextFree; tIndex++) {
-00037                 ppAnchor[tIndex] = xfree(ppAnchor[tIndex]);
-00038         }
-00039         /* Free the list itself */
-00040         ppAnchor = xfree(ppAnchor);
-00041         /* Reset all control variables */
-00042         tNextFree = 0;
-00043         tMaxElements = 0;
-00044 } /* end of vDestroyPropModList */
-00045 
-00046 /*
-00047  * vAdd2PropModList - add an element to the property modifier list
-00048  */
-00049 void
-00050 vAdd2PropModList(const UCHAR *aucPropMod)
-00051 {
-00052         size_t  tSize, tLen;
-00053 
-00054         fail(aucPropMod == NULL);
-00055 
-00056         NO_DBG_MSG("vAdd2PropModList");
-00057 
-00058         if (tNextFree >= tMaxElements) {
-00059                 tMaxElements += ELEMENTS_TO_ADD;
-00060                 tSize = tMaxElements * sizeof(UCHAR **);
-00061                 ppAnchor = xrealloc(ppAnchor, tSize);
-00062         }
-00063         NO_DBG_DEC(tNextFree);
-00064 
-00065         tLen = 2 + (size_t)usGetWord(0, aucPropMod);
-00066         NO_DBG_HEX(tLen);
-00067         NO_DBG_PRINT_BLOCK(pucPropMod, tLen);
-00068         ppAnchor[tNextFree] = xmalloc(tLen);
-00069         memcpy(ppAnchor[tNextFree], aucPropMod, tLen);
-00070         tNextFree++;
-00071 } /* end of vAdd2PropModList */
-00072 
-00073 /*
-00074  * aucReadPropModListItem - get an item of the property modifier list
-00075  */
-00076 const UCHAR *
-00077 aucReadPropModListItem(USHORT usPropMod)
-00078 {
-00079         static UCHAR    aucBuffer[4];
-00080         size_t  tIndex;
-00081 
-00082         if (usPropMod == IGNORE_PROPMOD) {
-00083                 /* This Properties Modifier must be ignored */
-00084                 return NULL;
-00085         }
-00086 
-00087         if (!odd(usPropMod)) {
-00088                 /* Variant 1: The information is in the input ifself */
-00089                 aucBuffer[0] = 2;
-00090                 aucBuffer[1] = 0;
-00091                 aucBuffer[2] = (UCHAR)((usPropMod & 0x00fe) >> 1);
-00092                 aucBuffer[3] = (UCHAR)((usPropMod & 0xff00) >> 8);
-00093                 return aucBuffer;
-00094         }
-00095 
-00096         if (ppAnchor == NULL) {
-00097                 /* No information available */
-00098                 return NULL;
-00099         }
-00100 
-00101         /* Variant 2: The input contains an index */
-00102         tIndex = (size_t)(usPropMod >> 1);
-00103         if (tIndex >= tNextFree) {
-00104                 DBG_HEX(usPropMod);
-00105                 DBG_DEC(tIndex);
-00106                 DBG_DEC(tNextFree);
-00107                 return NULL;
-00108         }
-00109         return ppAnchor[tIndex];
-00110 } /* end of aucGetPropModListItem */
-
-
Generated by  - -doxygen 1.6.2
- - diff -r 59758314f811 -r d4524d6a4472 Symbian3/Examples/guid-6013a680-57f9-415b-8851-c4fa63356636/riscos_8c_source.html --- a/Symbian3/Examples/guid-6013a680-57f9-415b-8851-c4fa63356636/riscos_8c_source.html Fri Jun 11 15:24:34 2010 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,267 +0,0 @@ - - - - -TB9.2 Example Applications: examples/PIPS/antiword/src/riscos.c Source File - - - - - -

examples/PIPS/antiword/src/riscos.c

00001 /*
-00002  * riscos.c
-00003  * Copyright (C) 2001,2002 A.J. van Os; Released under GPL
-00004  *
-00005  * Description:
-00006  * RISC OS only functions
-00007  */
-00008 
-00009 #include <string.h>
-00010 #include <stdlib.h>
-00011 #include <stdarg.h>
-00012 #include "DeskLib:Error.h"
-00013 #include "DeskLib:SWI.h"
-00014 #include "antiword.h"
-00015 
-00016 #if !defined(DrawFile_Render)
-00017 #define DrawFile_Render         0x045540
-00018 #endif /* !DrawFile_Render */
-00019 #if !defined(JPEG_Info)
-00020 #define JPEG_Info               0x049980
-00021 #endif /* !JPEG_Info */
-00022 
-00023 /*
-00024  * werr - write an error message and exit if needed
-00025  */
-00026 void
-00027 werr(int iFatal, const char *szFormat, ...)
-00028 {
-00029         va_list tArg;
-00030 
-00031         va_start(tArg, szFormat);
-00032         Error_Report(iFatal, (char *)szFormat, tArg);
-00033         va_end(tArg);
-00034         switch (iFatal) {
-00035         case 0:         /* The message is just a warning, so no exit */
-00036                 return;
-00037         case 1:         /* Fatal error with a standard exit */
-00038                 exit(EXIT_FAILURE);
-00039         default:        /* Fatal error with a non-standard exit */
-00040                 exit(iFatal);
-00041         }
-00042 } /* end of werr */
-00043 
-00044 /*
-00045  * iGetFiletype
-00046  * This function will get the filetype of the given file.
-00047  * returns the filetype.
-00048  */
-00049 int
-00050 iGetFiletype(const char *szFilename)
-00051 {
-00052         os_error        *e;
-00053         int             iType;
-00054 
-00055         fail(szFilename == NULL || szFilename[0] == '\0');
-00056 
-00057         e = SWI(2, 7, SWI_OS_File | XOS_Bit,
-00058                 23, szFilename,
-00059                 NULL, NULL, NULL, NULL, NULL, NULL, &iType);
-00060         if (e == NULL) {
-00061                 return iType;
-00062         }
-00063         werr(0, "Get Filetype error %d: %s", e->errnum, e->errmess);
-00064         return -1;
-00065 } /* end of iGetFiletype */
-00066 
-00067 /*
-00068  * vSetFiletype
-00069  * This procedure will set the filetype of the given file to the given
-00070  * type.
-00071  */
-00072 void
-00073 vSetFiletype(const char *szFilename, int iFiletype)
-00074 {
-00075         os_error        *e;
-00076 
-00077         fail(szFilename == NULL || szFilename[0] == '\0');
-00078 
-00079         if (iFiletype < 0x000 || iFiletype > 0xfff) {
-00080                 return;
-00081         }
-00082         e = SWI(3, 0, SWI_OS_File | XOS_Bit,
-00083                 18, szFilename, iFiletype);
-00084         if (e != NULL) {
-00085                 switch (e->errnum) {
-00086                 case 0x000113:  /* ROM */
-00087                 case 0x0104e1:  /* Read-only floppy DOSFS */
-00088                 case 0x0108c9:  /* Read-only floppy ADFS */
-00089                 case 0x013803:  /* Read-only ArcFS */
-00090                 case 0x80344a:  /* CD-ROM */
-00091                         break;
-00092                 default:
-00093                         werr(0, "Set Filetype error %d: %s",
-00094                                 e->errnum, e->errmess);
-00095                         break;
-00096                 }
-00097         }
-00098 } /* end of vSetFileType */
-00099 
-00100 /*
-00101  * Check if the directory part of the given file exists, make the directory
-00102  * if it does not exist yet.
-00103  * Returns TRUE in case of success, otherwise FALSE.
-00104  */
-00105 BOOL
-00106 bMakeDirectory(const char *szFilename)
-00107 {
-00108         os_error        *e;
-00109         char    *pcLastDot;
-00110         int     iObjectType;
-00111         char    szDirectory[PATH_MAX+1];
-00112 
-00113         DBG_MSG("bMakeDirectory");
-00114         fail(szFilename == NULL || szFilename[0] == '\0');
-00115         DBG_MSG(szFilename);
-00116 
-00117         if (strlen(szFilename) >= sizeof(szDirectory)) {
-00118                 DBG_DEC(strlen(szFilename));
-00119                 return FALSE;
-00120         }
-00121         strcpy(szDirectory, szFilename);
-00122         pcLastDot = strrchr(szDirectory, '.');
-00123         if (pcLastDot == NULL) {
-00124                 /* No directory equals current directory */
-00125                 DBG_MSG("No directory part given");
-00126                 return TRUE;
-00127         }
-00128         *pcLastDot = '\0';
-00129         DBG_MSG(szDirectory);
-00130         /* Check if the name exists */
-00131         e = SWI(2, 1, SWI_OS_File | XOS_Bit,
-00132                 17, szDirectory,
-00133                 &iObjectType);
-00134         if (e != NULL) {
-00135                 werr(0, "Directory check %d: %s", e->errnum, e->errmess);
-00136                 return FALSE;
-00137         }
-00138         if (iObjectType == 2) {
-00139                 /* The name exists and it is a directory */
-00140                 DBG_MSG("The directory already exists");
-00141                 return TRUE;
-00142         }
-00143         if (iObjectType != 0) {
-00144                 /* The name exists and it is not a directory */
-00145                 DBG_DEC(iObjectType);
-00146                 return FALSE;
-00147         }
-00148         /* The name does not exist, make the directory */
-00149         e = SWI(5, 0, SWI_OS_File | XOS_Bit,
-00150                 8, szDirectory, 0, 0, 0);
-00151         if (e != NULL) {
-00152                 werr(0, "I can't make a directory %d: %s",
-00153                         e->errnum, e->errmess);
-00154                 return FALSE;
-00155         }
-00156         return TRUE;
-00157 } /* end of bMakeDirectory */
-00158 
-00159 /*
-00160  * iReadCurrentAlphabetNumber
-00161  * This function reads the current Alphabet number.
-00162  * Returns the current Alphabet number when successful, otherwise -1
-00163  */
-00164 int
-00165 iReadCurrentAlphabetNumber(void)
-00166 {
-00167         os_error        *e;
-00168         int             iAlphabetNumber;
-00169 
-00170         e = SWI(2, 2, SWI_OS_Byte | XOS_Bit,
-00171                 71, 127,
-00172                 NULL, &iAlphabetNumber);
-00173         if (e == NULL) {
-00174                 return iAlphabetNumber;
-00175         }
-00176         werr(0, "Read alphabet error %d: %s", e->errnum, e->errmess);
-00177         return -1;
-00178 } /* end of iReadCurrentAlphabetNumber */
-00179 
-00180 /*
-00181  * iGetRiscOsVersion - get the RISC OS version number
-00182  *
-00183  * returns the RISC OS version * 100
-00184  */
-00185 int
-00186 iGetRiscOsVersion(void)
-00187 {
-00188         os_error        *e;
-00189         int             iVersion;
-00190 
-00191         e = SWI(3, 2, SWI_OS_Byte | XOS_Bit,
-00192                 129, 0, 0xff,
-00193                 NULL, &iVersion);
-00194         if (e != NULL) {
-00195                 werr(0, "Read RISC OS version error %d: %s",
-00196                         e->errnum, e->errmess);
-00197                 return 0;
-00198         }
-00199         switch (iVersion) {
-00200         case 0xa0:      /* Arthur 1.20 */
-00201                 return 120;
-00202         case 0xa1:      /* RISC OS 2.00 */
-00203                 return 200;
-00204         case 0xa2:      /* RISC OS 2.01 */
-00205                 return 201;
-00206         case 0xa3:      /* RISC OS 3.00 */
-00207                 return 300;
-00208         case 0xa4:      /* RISC OS 3.1x */
-00209                 return 310;
-00210         case 0xa5:      /* RISC OS 3.50 */
-00211                 return 350;
-00212         case 0xa6:      /* RISC OS 3.60 */
-00213                 return 360;
-00214         case 0xa7:      /* RISC OS 3.7x */
-00215                 return 370;
-00216         case 0xa8:      /* RISC OS 4.0x */
-00217                 return 400;
-00218         default:
-00219                 if (iVersion >= 0xa9 && iVersion <= 0xaf) {
-00220                         /* RISC OS 4.10 and up */
-00221                         return 410;
-00222                 }
-00223                 /* Unknown version */
-00224                 return 0;
-00225         }
-00226 } /* end of iGetRiscOsVersion */
-00227 
-00228 #if defined(DEBUG)
-00229 BOOL
-00230 bGetJpegInfo(UCHAR *pucJpeg, size_t tJpegSize)
-00231 {
-00232         os_error        *e;
-00233         int     iReg0, iReg4, iReg5;
-00234 
-00235         e = SWI(3, 6, JPEG_Info | XOS_Bit,
-00236                 0x00, pucJpeg, tJpegSize,
-00237                 &iReg0, NULL, NULL, NULL, &iReg4, &iReg5);
-00238         if (e == NULL) {
-00239                 if (iReg0 & BIT(2)) {
-00240                         DBG_MSG("Pixel density is a simple ratio");
-00241                 } else {
-00242                         DBG_MSG("Pixel density is in dpi");
-00243                 }
-00244                 DBG_DEC(iReg4);
-00245                 DBG_DEC(iReg5);
-00246                 return TRUE;
-00247         }
-00248         werr(0, "JPEG Info error %d: %s", e->errnum, e->errmess);
-00249         return FALSE;
-00250 } /* end of bGetJpegInfo */
-00251 #endif /* DEBUG */
-
-
Generated by  - -doxygen 1.6.2
- - diff -r 59758314f811 -r d4524d6a4472 Symbian3/Examples/guid-6013a680-57f9-415b-8851-c4fa63356636/rowlist_8c_source.html --- a/Symbian3/Examples/guid-6013a680-57f9-415b-8851-c4fa63356636/rowlist_8c_source.html Fri Jun 11 15:24:34 2010 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,133 +0,0 @@ - - - - -TB9.2 Example Applications: examples/PIPS/antiword/src/rowlist.c Source File - - - - - -

examples/PIPS/antiword/src/rowlist.c

00001 /*
-00002  * rowlist.c
-00003  * Copyright (C) 1998-2004 A.J. van Os; Released under GPL
-00004  *
-00005  * Description:
-00006  * Build, read and destroy a list of Word table-row information
-00007  */
-00008 
-00009 #include <stdlib.h>
-00010 #include <string.h>
-00011 #include "antiword.h"
-00012 
-00013 /*
-00014  * Private structure to hide the way the information
-00015  * is stored from the rest of the program
-00016  */
-00017 typedef struct row_desc_tag {
-00018         row_block_type          tInfo;
-00019         struct row_desc_tag     *pNext;
-00020 } row_desc_type;
-00021 
-00022 /* Variables needed to write the Row Information List */
-00023 static row_desc_type    *pAnchor = NULL;
-00024 static row_desc_type    *pRowLast = NULL;
-00025 /* Variable needed to read the Row Information List */
-00026 static row_desc_type    *pRowCurrent = NULL;
-00027 
-00028 
-00029 /*
-00030  * vDestroyRowInfoList - destroy the Row Information List
-00031  */
-00032 void
-00033 vDestroyRowInfoList(void)
-00034 {
-00035         row_desc_type   *pCurr, *pNext;
-00036 
-00037         DBG_MSG("vDestroyRowInfoList");
-00038 
-00039         /* Free the Row Information List */
-00040         pCurr = pAnchor;
-00041         while (pCurr != NULL) {
-00042                 pNext = pCurr->pNext;
-00043                 pCurr = xfree(pCurr);
-00044                 pCurr = pNext;
-00045         }
-00046         pAnchor = NULL;
-00047         /* Reset all control variables */
-00048         pRowLast = NULL;
-00049         pRowCurrent = NULL;
-00050 } /* end of vDestroyRowInfoList */
-00051 
-00052 /*
-00053  * vAdd2RowInfoList - Add an element to the Row Information List
-00054  */
-00055 void
-00056 vAdd2RowInfoList(const row_block_type *pRowBlock)
-00057 {
-00058         row_desc_type   *pListMember;
-00059         short           *psTmp;
-00060         int             iIndex;
-00061 
-00062         fail(pRowBlock == NULL);
-00063 
-00064         if (pRowBlock->ulFileOffsetStart == FC_INVALID ||
-00065             pRowBlock->ulFileOffsetEnd == FC_INVALID ||
-00066             pRowBlock->ulFileOffsetStart == pRowBlock->ulFileOffsetEnd) {
-00067                 DBG_HEX_C(pRowBlock->ulFileOffsetStart != FC_INVALID,
-00068                         pRowBlock->ulFileOffsetStart);
-00069                 DBG_HEX_C(pRowBlock->ulFileOffsetEnd != FC_INVALID,
-00070                         pRowBlock->ulFileOffsetEnd);
-00071                 return;
-00072         }
-00073 
-00074         NO_DBG_HEX(pRowBlock->ulFileOffsetStart);
-00075         NO_DBG_HEX(pRowBlock->ulFileOffsetEnd);
-00076         NO_DBG_DEC(pRowBlock->ucNumberOfColumns);
-00077 
-00078         /* Create the new list member */
-00079         pListMember = xmalloc(sizeof(row_desc_type));
-00080         /* Fill the new list member */
-00081         pListMember->tInfo = *pRowBlock;
-00082         pListMember->pNext = NULL;
-00083         /* Correct the values where needed */
-00084         for (iIndex = 0, psTmp = pListMember->tInfo.asColumnWidth;
-00085              iIndex < (int)pListMember->tInfo.ucNumberOfColumns;
-00086              iIndex++, psTmp++) {
-00087                 if (*psTmp < 0) {
-00088                         *psTmp = 0;
-00089                         DBG_MSG("The column width was negative");
-00090                 }
-00091         }
-00092         /* Add the new member to the list */
-00093         if (pAnchor == NULL) {
-00094                 pAnchor = pListMember;
-00095                 pRowCurrent = pListMember;
-00096         } else {
-00097                 fail(pRowLast == NULL);
-00098                 pRowLast->pNext = pListMember;
-00099         }
-00100         pRowLast = pListMember;
-00101 } /* end of vAdd2RowInfoList */
-00102 
-00103 /*
-00104  * Get the next item in the Row Information List
-00105  */
-00106 const row_block_type *
-00107 pGetNextRowInfoListItem(void)
-00108 {
-00109         const row_block_type    *pItem;
-00110 
-00111         if (pRowCurrent == NULL) {
-00112                 return NULL;
-00113         }
-00114         pItem = &pRowCurrent->tInfo;
-00115         pRowCurrent = pRowCurrent->pNext;
-00116         return pItem;
-00117 } /* end of pGetNextRowInfoListItem */
-
-
Generated by  - -doxygen 1.6.2
- - diff -r 59758314f811 -r d4524d6a4472 Symbian3/Examples/guid-6013a680-57f9-415b-8851-c4fa63356636/saveas_8c_source.html --- a/Symbian3/Examples/guid-6013a680-57f9-415b-8851-c4fa63356636/saveas_8c_source.html Fri Jun 11 15:24:34 2010 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,403 +0,0 @@ - - - - -TB9.2 Example Applications: examples/PIPS/antiword/src/saveas.c Source File - - - - - -

examples/PIPS/antiword/src/saveas.c

00001 /*
-00002  * saveas.c
-00003  * Copyright (C) 1998-2001 A.J. van Os; Released under GPL
-00004  *
-00005  * Description:
-00006  * Functions to save the results as a textfile or a drawfile
-00007  */
-00008 
-00009 #include <stdio.h>
-00010 #include <string.h>
-00011 #include "DeskLib:Menu.h"
-00012 #include "DeskLib:Save.h"
-00013 #include "DeskLib:Template.h"
-00014 #include "DeskLib:Window.h"
-00015 #include "drawfile.h"
-00016 #include "antiword.h"
-00017 
-00018 /* The window handle of the save window */
-00019 static window_handle    tSaveWindow = 0;
-00020 
-00021 /* Xfer_send box fields */
-00022 #define DRAG_SPRITE     3
-00023 #define OK_BUTTON       0
-00024 #define CANCEL_BUTTON   (-1)
-00025 #define FILENAME_ICON   2
-00026 
-00027 
-00028 /*
-00029  * saveas - a wrapper around Save_InitSaveWindowhandler
-00030  */
-00031 static void
-00032 saveas(int iFileType, char *szOutfile, size_t tEstSize,
-00033         save_filesaver save_function, void *pvReference)
-00034 {
-00035         TRACE_MSG("saveas");
-00036 
-00037         if (tSaveWindow == 0) {
-00038                 tSaveWindow = Window_Create("xfer_send", template_TITLEMIN);
-00039         }
-00040         Icon_SetText(tSaveWindow, FILENAME_ICON, szOutfile);
-00041         Window_Show(tSaveWindow, open_UNDERPOINTER);
-00042         (void)Save_InitSaveWindowHandler(tSaveWindow, FALSE, TRUE, TRUE,
-00043                 DRAG_SPRITE, OK_BUTTON, CANCEL_BUTTON, FILENAME_ICON,
-00044                 save_function, NULL, NULL, tEstSize, iFileType, pvReference);
-00045 } /* end of saveas */
-00046 
-00047 static BOOL
-00048 bWrite2File(void *pvBytes, size_t tSize, FILE *pFile, const char *szFilename)
-00049 {
-00050         if (fwrite(pvBytes, sizeof(char), tSize, pFile) != tSize) {
-00051                 werr(0, "I can't write to '%s'", szFilename);
-00052                 return FALSE;
-00053         }
-00054         return TRUE;
-00055 } /* end of bWrite2File */
-00056 
-00057 /*
-00058  * bText2File - Save the generated draw file to a Text file
-00059  */
-00060 static BOOL
-00061 bText2File(char *szFilename, void *pvHandle)
-00062 {
-00063         FILE    *pFile;
-00064         diagram_type    *pDiag;
-00065         drawfile_object *pObj;
-00066         drawfile_text   *pText;
-00067         const char      *pcTmp;
-00068         int     iToGo, iX, iYtopPrev, iHeight, iLines;
-00069         BOOL    bFirst, bIndent, bSuccess;
-00070 
-00071         TRACE_MSG("bText2File");
-00072 
-00073         fail(szFilename == NULL || szFilename[0] == '\0');
-00074         fail(pvHandle == NULL);
-00075 
-00076         DBG_MSG(szFilename);
-00077 
-00078         pDiag = (diagram_type *)pvHandle;
-00079         pFile = fopen(szFilename, "w");
-00080         if (pFile == NULL) {
-00081                 werr(0, "I can't open '%s' for writing", szFilename);
-00082                 return FALSE;
-00083         }
-00084         bFirst = TRUE;
-00085         iYtopPrev = 0;
-00086         iHeight = (int)lWord2DrawUnits20(DEFAULT_FONT_SIZE);
-00087         bSuccess = TRUE;
-00088         fail(pDiag->tInfo.length < offsetof(drawfile_diagram, objects));
-00089         iToGo = pDiag->tInfo.length - offsetof(drawfile_diagram, objects);
-00090         DBG_DEC(iToGo);
-00091         pcTmp = (const char *)pDiag->tInfo.data +
-00092                                 offsetof(drawfile_diagram, objects);
-00093         while (iToGo > 0 && bSuccess) {
-00094                 pObj = (drawfile_object *)pcTmp;
-00095                 switch (pObj->type) {
-00096                 case drawfile_TYPE_TEXT:
-00097                         pText = &pObj->data.text;
-00098                         /* Compute the number of lines */
-00099                         iLines = (iYtopPrev - pText->bbox.max.y +
-00100                                         iHeight / 2) / iHeight;
-00101                         DBG_DEC_C(iLines < 0, iYtopPrev);
-00102                         DBG_DEC_C(iLines < 0, pText->bbox.max.y);
-00103                         fail(iLines < 0);
-00104                         bIndent = iLines > 0 || bFirst;
-00105                         bFirst = FALSE;
-00106                         /* Print the newlines */
-00107                         while (iLines > 0 && bSuccess) {
-00108                                 bSuccess = bWrite2File("\n",
-00109                                         1, pFile, szFilename);
-00110                                 iLines--;
-00111                         }
-00112                         /* Print the indentation */
-00113                         if (bIndent && bSuccess) {
-00114                                 for (iX = Drawfile_ScreenToDraw(8);
-00115                                      iX <= pText->bbox.min.x && bSuccess;
-00116                                      iX += Drawfile_ScreenToDraw(16)) {
-00117                                         bSuccess = bWrite2File(" ",
-00118                                                 1, pFile, szFilename);
-00119                                 }
-00120                         }
-00121                         if (!bSuccess) {
-00122                                 break;
-00123                         }
-00124                         /* Print the text object */
-00125                         bSuccess = bWrite2File(pText->text,
-00126                                 strlen(pText->text), pFile, szFilename);
-00127                         /* Setup for the next object */
-00128                         iYtopPrev = pText->bbox.max.y;
-00129                         iHeight = pText->bbox.max.y - pText->bbox.min.y;
-00130                         break;
-00131                 case drawfile_TYPE_FONT_TABLE:
-00132                 case drawfile_TYPE_PATH:
-00133                 case drawfile_TYPE_SPRITE:
-00134                 case drawfile_TYPE_JPEG:
-00135                         /* These are not relevant in a textfile */
-00136                         break;
-00137                 default:
-00138                         DBG_DEC(pObj->type);
-00139                         bSuccess = FALSE;
-00140                         break;
-00141                 }
-00142                 pcTmp += pObj->size;
-00143                 iToGo -= pObj->size;
-00144         }
-00145         DBG_DEC_C(iToGo != 0, iToGo);
-00146         if (bSuccess) {
-00147                 bSuccess = bWrite2File("\n", 1, pFile, szFilename);
-00148         }
-00149         (void)fclose(pFile);
-00150         if (bSuccess) {
-00151                 vSetFiletype(szFilename, FILETYPE_TEXT);
-00152         } else {
-00153                 (void)remove(szFilename);
-00154                 werr(0, "Unable to save textfile '%s'", szFilename);
-00155         }
-00156         return bSuccess;
-00157 } /* end of bText2File */
-00158 
-00159 /*
-00160  * bSaveTextfile - save the diagram as a text file
-00161  */
-00162 BOOL
-00163 bSaveTextfile(event_pollblock *pEvent, void *pvReference)
-00164 {
-00165         diagram_type    *pDiag;
-00166         size_t  tRecLen, tNbrRecs, tEstSize;
-00167 
-00168         TRACE_MSG("bSaveTextfile");
-00169 
-00170         fail(pEvent == NULL);
-00171         fail(pvReference == NULL);
-00172 
-00173         pDiag = (diagram_type *)pvReference;
-00174 
-00175         switch (pEvent->type) {
-00176         case event_SEND:        /* From a menu */
-00177                 fail(pEvent->data.message.header.action != message_MENUWARN);
-00178                 if (menu_currentopen != pDiag->pSaveMenu ||
-00179                     pEvent->data.message.data.menuwarn.selection[0] !=
-00180                                                         SAVEMENU_SAVETEXT) {
-00181                         return FALSE;
-00182                 }
-00183                 break;
-00184         case event_KEY:         /* From a key short cut */
-00185                 if (pEvent->data.key.caret.window != pDiag->tMainWindow) {
-00186                         return FALSE;
-00187                 }
-00188                 break;
-00189         default:
-00190                 DBG_DEC(pEvent->type);
-00191                 return FALSE;
-00192         }
-00193 
-00194         tRecLen = sizeof(drawfile_text) + DEFAULT_SCREEN_WIDTH * 2 / 3;
-00195         tNbrRecs = pDiag->tInfo.length / tRecLen + 1;
-00196         tEstSize = tNbrRecs * DEFAULT_SCREEN_WIDTH * 2 / 3;
-00197         DBG_DEC(tEstSize);
-00198 
-00199         saveas(FILETYPE_TEXT, "WordText", tEstSize, bText2File, pDiag);
-00200         return TRUE;
-00201 } /* end of bSaveTextfile */
-00202 
-00203 /*
-00204  * bDraw2File - Save the generated draw file to a Draw file
-00205  *
-00206  * Remark: This is not a simple copy action. The origin of the
-00207  * coordinates (0,0) must move from the top-left corner to the
-00208  * bottom-left corner.
-00209  */
-00210 static BOOL
-00211 bDraw2File(char *szFilename, void *pvHandle)
-00212 {
-00213         FILE            *pFile;
-00214         diagram_type    *pDiagram;
-00215         wimp_box        *pBbox;
-00216         drawfile_object *pObj;
-00217         drawfile_text   *pText;
-00218         drawfile_path   *pPath;
-00219         drawfile_sprite *pSprite;
-00220         drawfile_jpeg   *pJpeg;
-00221         int     *piPath;
-00222         char    *pcTmp;
-00223         int     iYadd, iToGo, iSize;
-00224         BOOL    bSuccess;
-00225 
-00226         TRACE_MSG("bDraw2File");
-00227 
-00228         fail(szFilename == NULL || szFilename[0] == '\0');
-00229         fail(pvHandle == NULL);
-00230 
-00231         NO_DBG_MSG(szFilename);
-00232 
-00233         pDiagram = (diagram_type *)pvHandle;
-00234         pFile = fopen(szFilename, "wb");
-00235         if (pFile == NULL) {
-00236                 werr(0, "I can't open '%s' for writing", szFilename);
-00237                 return FALSE;
-00238         }
-00239         iToGo = pDiagram->tInfo.length;
-00240         DBG_DEC(iToGo);
-00241         pcTmp = pDiagram->tInfo.data;
-00242         bSuccess = bWrite2File(pcTmp,
-00243                         offsetof(drawfile_diagram, bbox), pFile, szFilename);
-00244         if (bSuccess) {
-00245                 pcTmp += offsetof(drawfile_diagram, bbox);
-00246                 iToGo -= offsetof(drawfile_diagram, bbox);
-00247                 pBbox = (wimp_box *)pcTmp;
-00248                 iYadd = -pBbox->min.y;
-00249                 pBbox->min.y += iYadd;
-00250                 pBbox->max.y += iYadd;
-00251                 bSuccess = bWrite2File(pcTmp,
-00252                                 sizeof(*pBbox), pFile, szFilename);
-00253                 iToGo -= sizeof(*pBbox);
-00254                 DBG_DEC(iToGo);
-00255                 pcTmp += sizeof(*pBbox);
-00256         } else {
-00257                 iYadd = 0;
-00258         }
-00259         while (iToGo > 0 && bSuccess) {
-00260                 pObj = (drawfile_object *)pcTmp;
-00261                 iSize = pObj->size;
-00262                 switch (pObj->type) {
-00263                 case drawfile_TYPE_FONT_TABLE:
-00264                         bSuccess = bWrite2File(pcTmp,
-00265                                         iSize, pFile, szFilename);
-00266                         pcTmp += iSize;
-00267                         iToGo -= iSize;
-00268                         break;
-00269                 case drawfile_TYPE_TEXT:
-00270                         pText = &pObj->data.text;
-00271                         /* First correct the coordinates */
-00272                         pText->bbox.min.y += iYadd;
-00273                         pText->bbox.max.y += iYadd;
-00274                         pText->base.y += iYadd;
-00275                         /* Now write the information to file */
-00276                         bSuccess = bWrite2File(pcTmp,
-00277                                         iSize, pFile, szFilename);
-00278                         pcTmp += pObj->size;
-00279                         iToGo -= pObj->size;
-00280                         break;
-00281                 case drawfile_TYPE_PATH:
-00282                         pPath = &pObj->data.path;
-00283                         /* First correct the coordinates */
-00284                         pPath->bbox.min.y += iYadd;
-00285                         pPath->bbox.max.y += iYadd;
-00286                         /* Now write the information to file */
-00287                         bSuccess = bWrite2File(pPath,
-00288                                 sizeof(*pPath), pFile, szFilename);
-00289                         pcTmp += sizeof(*pPath);
-00290                         iSize = pObj->size - sizeof(*pPath);
-00291                         fail(iSize < 14 * sizeof(int));
-00292                         /* Second correct the path coordinates */
-00293                         piPath = xmalloc(iSize);
-00294                         memcpy(piPath, pcTmp, iSize);
-00295                         piPath[ 2] += iYadd;
-00296                         piPath[ 5] += iYadd;
-00297                         piPath[ 8] += iYadd;
-00298                         piPath[11] += iYadd;
-00299                         if (bSuccess) {
-00300                                 bSuccess = bWrite2File(piPath,
-00301                                         iSize, pFile, szFilename);
-00302                                 pcTmp += iSize;
-00303                         }
-00304                         piPath = xfree(piPath);
-00305                         iToGo -= pObj->size;
-00306                         break;
-00307                 case drawfile_TYPE_SPRITE:
-00308                         pSprite = &pObj->data.sprite;
-00309                         /* First correct the coordinates */
-00310                         pSprite->bbox.min.y += iYadd;
-00311                         pSprite->bbox.max.y += iYadd;
-00312                         /* Now write the information to file */
-00313                         bSuccess = bWrite2File(pcTmp,
-00314                                         iSize, pFile, szFilename);
-00315                         pcTmp += pObj->size;
-00316                         iToGo -= pObj->size;
-00317                         break;
-00318                 case drawfile_TYPE_JPEG:
-00319                         pJpeg = &pObj->data.jpeg;
-00320                         /* First correct the coordinates */
-00321                         pJpeg->bbox.min.y += iYadd;
-00322                         pJpeg->bbox.max.y += iYadd;
-00323                         pJpeg->trfm.entries[2][1] += iYadd;
-00324                         /* Now write the information to file */
-00325                         bSuccess = bWrite2File(pcTmp,
-00326                                         iSize, pFile, szFilename);
-00327                         pcTmp += pObj->size;
-00328                         iToGo -= pObj->size;
-00329                         break;
-00330                 default:
-00331                         DBG_DEC(pObj->type);
-00332                         bSuccess = FALSE;
-00333                         break;
-00334                 }
-00335         }
-00336         DBG_DEC_C(iToGo != 0, iToGo);
-00337         (void)fclose(pFile);
-00338         if (bSuccess) {
-00339                 vSetFiletype(szFilename, FILETYPE_DRAW);
-00340         } else {
-00341                 (void)remove(szFilename);
-00342                 werr(0, "Unable to save drawfile '%s'", szFilename);
-00343         }
-00344         return bSuccess;
-00345 } /* end of bDraw2File */
-00346 
-00347 /*
-00348  * bSaveDrawfile - save the diagram as a draw file
-00349  */
-00350 BOOL
-00351 bSaveDrawfile(event_pollblock *pEvent, void *pvReference)
-00352 {
-00353         diagram_type    *pDiag;
-00354         size_t          tEstSize;
-00355 
-00356         TRACE_MSG("bSaveDrawfile");
-00357 
-00358         fail(pEvent == NULL);
-00359         fail(pvReference == NULL);
-00360 
-00361         pDiag = (diagram_type *)pvReference;
-00362 
-00363         switch (pEvent->type) {
-00364         case event_SEND:        /* From a menu */
-00365                 fail(pEvent->data.message.header.action != message_MENUWARN);
-00366                 if (menu_currentopen != pDiag->pSaveMenu ||
-00367                     pEvent->data.message.data.menuwarn.selection[0] !=
-00368                                                         SAVEMENU_SAVEDRAW) {
-00369                         return FALSE;
-00370                 }
-00371                 break;
-00372         case event_KEY:         /* From a key short cut */
-00373                 if (pEvent->data.key.caret.window != pDiag->tMainWindow) {
-00374                         return FALSE;
-00375                 }
-00376                 break;
-00377         default:
-00378                 DBG_DEC(pEvent->type);
-00379                 return FALSE;
-00380         }
-00381 
-00382         tEstSize = pDiag->tInfo.length;
-00383         DBG_DEC(tEstSize);
-00384 
-00385         saveas(FILETYPE_DRAW, "WordDraw", tEstSize, bDraw2File, pDiag);
-00386         return TRUE;
-00387 } /* end of bSaveDrawfile */
-
-
Generated by  - -doxygen 1.6.2
- - diff -r 59758314f811 -r d4524d6a4472 Symbian3/Examples/guid-6013a680-57f9-415b-8851-c4fa63356636/sectlist_8c_source.html --- a/Symbian3/Examples/guid-6013a680-57f9-415b-8851-c4fa63356636/sectlist_8c_source.html Fri Jun 11 15:24:34 2010 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,181 +0,0 @@ - - - - -TB9.2 Example Applications: examples/PIPS/antiword/src/sectlist.c Source File - - - - - -

examples/PIPS/antiword/src/sectlist.c

00001 /*
-00002  * sectlist.c
-00003  * Copyright (C) 2001-2004 A.J. van Os; Released under GNU GPL
-00004  *
-00005  * Description:
-00006  * Build, read and destroy list(s) of Word section information
-00007  */
-00008 
-00009 #include <stddef.h>
-00010 #include <string.h>
-00011 #include "antiword.h"
-00012 
-00013 
-00014 /*
-00015  * Private structure to hide the way the information
-00016  * is stored from the rest of the program
-00017  */
-00018 typedef struct section_mem_tag {
-00019         section_block_type      tInfo;
-00020         ULONG                   ulCharPos;
-00021         struct section_mem_tag  *pNext;
-00022 } section_mem_type;
-00023 
-00024 /* Variables needed to write the Section Information List */
-00025 static section_mem_type *pAnchor = NULL;
-00026 static section_mem_type *pSectionLast = NULL;
-00027 
-00028 
-00029 /*
-00030  * vDestroySectionInfoList - destroy the Section Information List
-00031  */
-00032 void
-00033 vDestroySectionInfoList(void)
-00034 {
-00035         section_mem_type        *pCurr, *pNext;
-00036 
-00037         DBG_MSG("vDestroySectionInfoList");
-00038 
-00039         /* Free the Section Information List */
-00040         pCurr = pAnchor;
-00041         while (pCurr != NULL) {
-00042                 pNext = pCurr->pNext;
-00043                 pCurr = xfree(pCurr);
-00044                 pCurr = pNext;
-00045         }
-00046         pAnchor = NULL;
-00047         /* Reset all control variables */
-00048         pSectionLast = NULL;
-00049 } /* end of vDestroySectionInfoList */
-00050 
-00051 /*
-00052  * vAdd2SectionInfoList - Add an element to the Section Information List
-00053  */
-00054 void
-00055 vAdd2SectionInfoList(const section_block_type *pSection, ULONG ulCharPos)
-00056 {
-00057         section_mem_type        *pListMember;
-00058 
-00059         fail(pSection == NULL);
-00060 
-00061         /* Create list member */
-00062         pListMember = xmalloc(sizeof(section_mem_type));
-00063         /* Fill the list member */
-00064         pListMember->tInfo = *pSection;
-00065         pListMember->ulCharPos = ulCharPos;
-00066         pListMember->pNext = NULL;
-00067         /* Add the new member to the list */
-00068         if (pAnchor == NULL) {
-00069                 pAnchor = pListMember;
-00070         } else {
-00071                 fail(pSectionLast == NULL);
-00072                 pSectionLast->pNext = pListMember;
-00073         }
-00074         pSectionLast = pListMember;
-00075 } /* vAdd2SectionInfoList */
-00076 
-00077 /*
-00078  * vGetDefaultSection - fill the section struct with default values
-00079  */
-00080 void
-00081 vGetDefaultSection(section_block_type *pSection)
-00082 {
-00083         (void)memset(pSection, 0, sizeof(*pSection));
-00084         pSection->bNewPage = TRUE;
-00085 } /* end of vGetDefaultSection */
-00086 
-00087 /*
-00088  * vDefault2SectionInfoList - Add a default to the Section Information List
-00089  */
-00090 void
-00091 vDefault2SectionInfoList(ULONG ulCharPos)
-00092 {
-00093         section_block_type      tSection;
-00094 
-00095         vGetDefaultSection(&tSection);
-00096         vAdd2SectionInfoList(&tSection, ulCharPos);
-00097 } /* end of vDefault2SectionInfoList */
-00098 
-00099 /*
-00100  * pGetSectionInfo - get the section information
-00101  */
-00102 const section_block_type *
-00103 pGetSectionInfo(const section_block_type *pOld, ULONG ulCharPos)
-00104 {
-00105         const section_mem_type  *pCurr;
-00106 
-00107         if (pOld == NULL || ulCharPos == 0) {
-00108                 if (pAnchor == NULL) {
-00109                         /* There are no records, make one */
-00110                         vDefault2SectionInfoList(0);
-00111                         fail(pAnchor == NULL);
-00112                 }
-00113                 /* The first record */
-00114                 NO_DBG_MSG("First record");
-00115                 return &pAnchor->tInfo;
-00116         }
-00117 
-00118         NO_DBG_HEX(ulCharPos);
-00119         for (pCurr = pAnchor; pCurr != NULL; pCurr = pCurr->pNext) {
-00120                 NO_DBG_HEX(pCurr->ulCharPos);
-00121                 if (ulCharPos == pCurr->ulCharPos ||
-00122                     ulCharPos + 1 == pCurr->ulCharPos) {
-00123                         NO_DBG_HEX(pCurr->ulCharPos);
-00124                         return &pCurr->tInfo;
-00125                 }
-00126         }
-00127         return pOld;
-00128 } /* end of pGetSectionInfo */
-00129 
-00130 /*
-00131  * tGetNumberOfSections - get the number of sections
-00132  */
-00133 size_t
-00134 tGetNumberOfSections(void)
-00135 {
-00136         const section_mem_type  *pCurr;
-00137         size_t  tCounter;
-00138 
-00139         for (tCounter = 0, pCurr = pAnchor;
-00140              pCurr != NULL;
-00141              tCounter++, pCurr = pCurr->pNext)
-00142                 ;       /* Empty */
-00143         return tCounter;
-00144 } /* end of tGetNumberOfSections */
-00145 
-00146 /*
-00147  * ucGetSepHdrFtrSpecification - get the Heder/footer specification
-00148  */
-00149 UCHAR
-00150 ucGetSepHdrFtrSpecification(size_t tSectionNumber)
-00151 {
-00152         const section_mem_type  *pCurr;
-00153         size_t  tIndex;
-00154 
-00155         for (tIndex = 0, pCurr = pAnchor;
-00156              tIndex < tSectionNumber && pCurr != NULL;
-00157              tIndex++, pCurr = pCurr->pNext)
-00158                 ;       /* Empty */
-00159         if (pCurr == NULL) {
-00160                 DBG_DEC(tSectionNumber);
-00161                 DBG_FIXME();
-00162                 return 0x00;
-00163         }
-00164         return pCurr->tInfo.ucHdrFtrSpecification;
-00165 } /* end of ucGetSepHdrFtrSpecification */
-
-
Generated by  - -doxygen 1.6.2
- - diff -r 59758314f811 -r d4524d6a4472 Symbian3/Examples/guid-6013a680-57f9-415b-8851-c4fa63356636/startup_8c_source.html --- a/Symbian3/Examples/guid-6013a680-57f9-415b-8851-c4fa63356636/startup_8c_source.html Fri Jun 11 15:24:34 2010 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,161 +0,0 @@ - - - - -TB9.2 Example Applications: examples/PIPS/antiword/src/startup.c Source File - - - - - -

examples/PIPS/antiword/src/startup.c

00001 /*
-00002  * startup.c
-00003  * Copyright (C) 1998-2001 A.J. van Os; Released under GPL
-00004  *
-00005  * Description:
-00006  * Try to force a single startup of !Antiword
-00007  */
-00008 
-00009 #include <stdlib.h>
-00010 #include <string.h>
-00011 #include <ctype.h>
-00012 #include "DeskLib:Error.h"
-00013 #include "DeskLib:Event.h"
-00014 #include "DeskLib:SWI.h"
-00015 #include "antiword.h"
-00016 
-00017 
-00018 #if !defined(TaskManager_EnumerateTasks)
-00019 #define TaskManager_EnumerateTasks      0x042681
-00020 #endif /* TaskManager_EnumerateTasks */
-00021 
-00022 /*
-00023  * bIsMatch - decide whether the two strings match
-00024  *
-00025  * like strcmp, but this one ignores case
-00026  */
-00027 static BOOL
-00028 bIsMatch(const char *szStr1, const char *szStr2)
-00029 {
-00030         const char      *pcTmp1, *pcTmp2;
-00031 
-00032         for (pcTmp1 = szStr1, pcTmp2 = szStr2;
-00033              *pcTmp1 != '\0';
-00034              pcTmp1++, pcTmp2++) {
-00035                 if (toupper(*pcTmp1) != toupper(*pcTmp2)) {
-00036                         return FALSE;
-00037                 }
-00038         }
-00039         return *pcTmp2 == '\0';
-00040 } /* end of bIsMatch */
-00041 
-00042 /*
-00043  * tGetTaskHandle - get the task handle of the given task
-00044  *
-00045  * returns the task handle when found, otherwise 0
-00046  */
-00047 static task_handle
-00048 tGetTaskHandle(const char *szTaskname)
-00049 {
-00050         const char      *pcTmp;
-00051         int     iReg0, iIndex;
-00052         int     aiBuffer[4];
-00053         char    szTmp[21];
-00054 
-00055         iReg0 = 0;
-00056         do {
-00057                 /* Get info on the next task */
-00058                 Error_CheckFatal(SWI(3, 1, TaskManager_EnumerateTasks | XOS_Bit,
-00059                         iReg0, aiBuffer, sizeof(aiBuffer), &iReg0));
-00060                 /* Copy the (control character terminated) task name */
-00061                 for (iIndex = 0, pcTmp = (const char *)aiBuffer[1];
-00062                      iIndex < elementsof(szTmp);
-00063                      iIndex++, pcTmp++) {
-00064                         if (iscntrl(*pcTmp)) {
-00065                                 szTmp[iIndex] = '\0';
-00066                                 break;
-00067                         }
-00068                         szTmp[iIndex] = *pcTmp;
-00069                 }
-00070                 szTmp[elementsof(szTmp) - 1] = '\0';
-00071                 if (bIsMatch(szTmp, szTaskname)) {
-00072                         /* Task found */
-00073                         return (task_handle)aiBuffer[0];
-00074                 }
-00075         } while (iReg0 >= 0);
-00076 
-00077         /* Task not found */
-00078         return 0;
-00079 } /* end of tGetTaskHandle */
-00080 
-00081 int
-00082 main(int argc, char **argv)
-00083 {
-00084         message_block   tMsg;
-00085         task_handle     tTaskHandle;
-00086         size_t  tArgLen;
-00087         int     aiMessages[] = {0};
-00088         char    szCommand[512];
-00089 
-00090         Event_Initialise3("StartUp", 310, aiMessages);
-00091 
-00092         if (argc > 1) {
-00093                 tArgLen = strlen(argv[1]);
-00094         } else {
-00095                 tArgLen = 0;
-00096         }
-00097         if (tArgLen >= sizeof(tMsg.data.dataload.filename)) {
-00098                 werr(1, "Input filename too long");
-00099                 return EXIT_FAILURE;
-00100         }
-00101 
-00102         tTaskHandle = tGetTaskHandle("antiword");
-00103 
-00104         if (tTaskHandle == 0) {
-00105                 /* Antiword is not active */
-00106                 strcpy(szCommand, "chain:<Antiword$Dir>.!Antiword");
-00107                 if (argc > 1) {
-00108                         strcat(szCommand, " ");
-00109                         strcat(szCommand, argv[1]);
-00110                 }
-00111 #if defined(DEBUG)
-00112                 strcat(szCommand, " ");
-00113                 strcat(szCommand, "2><Antiword$Dir>.Debug");
-00114 #endif /* DEBUG */
-00115                 system(szCommand);
-00116                 /* If we reach here something has gone wrong */
-00117                 return EXIT_FAILURE;
-00118         }
-00119 
-00120         /* Antiword is active */
-00121         if (argc > 1) {
-00122                 /*
-00123                  * Send the argument to Antiword by imitating a
-00124                  * drag-and-drop to Antiword's iconbar icon
-00125                  */
-00126                 memset(&tMsg, 0, sizeof(tMsg));
-00127                 tMsg.header.size = ROUND4(offsetof(message_block, data) +
-00128                                         offsetof(message_dataload, filename) +
-00129                                         1 + tArgLen);
-00130                 tMsg.header.yourref = 0;
-00131                 tMsg.header.action = message_DATALOAD;
-00132                 tMsg.data.dataload.window = window_ICONBAR;
-00133                 tMsg.data.dataload.icon = -1;
-00134                 tMsg.data.dataload.size = 0;
-00135                 tMsg.data.dataload.filetype = FILETYPE_MSWORD;
-00136                 strcpy(tMsg.data.dataload.filename, argv[1]);
-00137                 Error_CheckFatal(Wimp_SendMessage(event_SEND,
-00138                                                 &tMsg, tTaskHandle, 0));
-00139                 return EXIT_SUCCESS;
-00140         } else {
-00141                 /* Give an error message and return */
-00142                 werr(1, "Antiword is already running");
-00143                 return EXIT_FAILURE;
-00144         }
-00145 } /* end of main */
-
-
Generated by  - -doxygen 1.6.2
- - diff -r 59758314f811 -r d4524d6a4472 Symbian3/Examples/guid-6013a680-57f9-415b-8851-c4fa63356636/stylelist_8c_source.html --- a/Symbian3/Examples/guid-6013a680-57f9-415b-8851-c4fa63356636/stylelist_8c_source.html Fri Jun 11 15:24:34 2010 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,503 +0,0 @@ - - - - -TB9.2 Example Applications: examples/PIPS/antiword/src/stylelist.c Source File - - - - - -

examples/PIPS/antiword/src/stylelist.c

00001 /*
-00002  * stylelist.c
-00003  * Copyright (C) 1998-2005 A.J. van Os; Released under GNU GPL
-00004  *
-00005  * Description:
-00006  * Build, read and destroy a list of Word style information
-00007  */
-00008 
-00009 #include <stdlib.h>
-00010 #include <stddef.h>
-00011 #include <ctype.h>
-00012 #include "antiword.h"
-00013 
-00014 
-00015 /*
-00016  * Private structure to hide the way the information
-00017  * is stored from the rest of the program
-00018  */
-00019 typedef struct style_mem_tag {
-00020         style_block_type        tInfo;
-00021         ULONG                   ulSequenceNumber;
-00022         struct style_mem_tag    *pNext;
-00023 } style_mem_type;
-00024 
-00025 /* Variables needed to write the Style Information List */
-00026 static style_mem_type   *pAnchor = NULL;
-00027 static style_mem_type   *pStyleLast = NULL;
-00028 /* The type of conversion */
-00029 static conversion_type  eConversionType = conversion_unknown;
-00030 /* The character set encoding */
-00031 static encoding_type    eEncoding = encoding_neutral;
-00032 /* Values for efficiency reasons */
-00033 static const style_mem_type     *pMidPtr = NULL;
-00034 static BOOL             bMoveMidPtr = FALSE;
-00035 static BOOL             bInSequence = TRUE;
-00036 
-00037 
-00038 /*
-00039  * vDestroyStyleInfoList - destroy the Style Information List
-00040  */
-00041 void
-00042 vDestroyStyleInfoList(void)
-00043 {
-00044         style_mem_type  *pCurr, *pNext;
-00045 
-00046         DBG_MSG("vDestroyStyleInfoList");
-00047 
-00048         /* Free the Style Information List */
-00049         pCurr = pAnchor;
-00050         while (pCurr != NULL) {
-00051                 pNext = pCurr->pNext;
-00052                 pCurr = xfree(pCurr);
-00053                 pCurr = pNext;
-00054         }
-00055         pAnchor = NULL;
-00056         /* Reset all control variables */
-00057         pStyleLast = NULL;
-00058         pMidPtr = NULL;
-00059         bMoveMidPtr = FALSE;
-00060         bInSequence = TRUE;
-00061 } /* end of vDestroyStyleInfoList */
-00062 
-00063 /*
-00064  * vConvertListCharacter - convert the list character
-00065  */
-00066 static void
-00067 vConvertListCharacter(UCHAR ucNFC, USHORT usListChar, char *szListChar)
-00068 {
-00069         options_type    tOptions;
-00070         size_t  tLen;
-00071 
-00072         fail(szListChar == NULL);
-00073         fail(szListChar[0] != '\0');
-00074 
-00075         if (usListChar < 0x80 && isprint((int)usListChar)) {
-00076                 DBG_CHR_C(isalnum((int)usListChar), usListChar);
-00077                 szListChar[0] = (char)usListChar;
-00078                 szListChar[1] = '\0';
-00079                 return;
-00080         }
-00081 
-00082         if (ucNFC != LIST_SPECIAL &&
-00083             ucNFC != LIST_SPECIAL2 &&
-00084             ucNFC != LIST_BULLETS) {
-00085                 szListChar[0] = '.';
-00086                 szListChar[1] = '\0';
-00087                 return;
-00088         }
-00089 
-00090         if (eConversionType == conversion_unknown ||
-00091             eEncoding == encoding_neutral) {
-00092                 vGetOptions(&tOptions);
-00093                 eConversionType = tOptions.eConversionType;
-00094                 eEncoding = tOptions.eEncoding;
-00095         }
-00096 
-00097         switch (usListChar) {
-00098         case 0x0000: case 0x00b7: case 0x00fe: case  0xf021: case 0xf043:
-00099         case 0xf06c: case 0xf093: case 0xf0b7:
-00100                 usListChar = 0x2022;    /* BULLET */
-00101                 break;
-00102         case 0x0096: case 0xf02d:
-00103                 usListChar = 0x2013;    /* EN DASH */
-00104                 break;
-00105         case 0x00a8:
-00106                 usListChar = 0x2666;    /* BLACK DIAMOND SUIT */
-00107                 break;
-00108         case 0x00de:
-00109                 usListChar = 0x21d2;    /* RIGHTWARDS DOUBLE ARROW */
-00110                 break;
-00111         case 0x00e0: case 0xf074:
-00112                 usListChar = 0x25ca;    /* LOZENGE */
-00113                 break;
-00114         case 0x00e1:
-00115                 usListChar = 0x2329;    /* LEFT ANGLE BRACKET */
-00116                 break;
-00117         case 0xf020:
-00118                 usListChar = 0x0020;    /* SPACE */
-00119                 break;
-00120         case 0xf041:
-00121                 usListChar = 0x270c;    /* VICTORY HAND */
-00122                 break;
-00123         case 0xf066:
-00124                 usListChar = 0x03d5;    /* GREEK PHI SYMBOL */
-00125                 break;
-00126         case 0xf06e:
-00127                 usListChar = 0x25a0;    /* BLACK SQUARE */
-00128                 break;
-00129         case 0xf06f: case 0xf070: case 0xf0a8:
-00130                 usListChar = 0x25a1;    /* WHITE SQUARE */
-00131                 break;
-00132         case 0xf071:
-00133                 usListChar = 0x2751;    /* LOWER RIGHT SHADOWED WHITE SQUARE */
-00134                 break;
-00135         case 0xf075: case 0xf077:
-00136                 usListChar = 0x25c6;    /* BLACK DIAMOND */
-00137                 break;
-00138         case 0xf076:
-00139                 usListChar = 0x2756;    /* BLACK DIAMOND MINUS WHITE X */
-00140                 break;
-00141         case 0xf0a7:
-00142                 usListChar = 0x25aa;    /* BLACK SMALL SQUARE */
-00143                 break;
-00144         case 0xf0d8:
-00145                 usListChar = 0x27a2;    /* RIGHTWARDS ARROWHEAD */
-00146                 break;
-00147         case 0xf0e5:
-00148                 usListChar = 0x2199;    /* SOUTH WEST ARROW */
-00149                 break;
-00150         case 0xf0f0:
-00151                 usListChar = 0x21e8;    /* RIGHTWARDS WHITE ARROW */
-00152                 break;
-00153         case 0xf0fc:
-00154                 usListChar = 0x2713;    /* CHECK MARK */
-00155                 break;
-00156         default:
-00157                 if ((usListChar >= 0xe000 && usListChar < 0xf900) ||
-00158                     (usListChar < 0x80 && !isprint((int)usListChar))) {
-00159                         /*
-00160                          * All remaining private area characters and all
-00161                          * remaining non-printable ASCII characters to their
-00162                          * default bullet character
-00163                          */
-00164                         DBG_HEX(usListChar);
-00165                         DBG_FIXME();
-00166                         if (ucNFC == LIST_SPECIAL || ucNFC == LIST_SPECIAL2) {
-00167                                 usListChar = 0x2190;    /* LEFTWARDS ARROW */
-00168                         } else {
-00169                                 usListChar = 0x2022;    /* BULLET */
-00170                         }
-00171                 }
-00172                 break;
-00173         }
-00174 
-00175         if (eEncoding == encoding_utf_8) {
-00176                 tLen = tUcs2Utf8(usListChar, szListChar, 4);
-00177                 szListChar[tLen] = '\0';
-00178         } else {
-00179                 switch (usListChar) {
-00180                 case 0x03d5: case 0x25a1: case 0x25c6: case 0x25ca:
-00181                 case 0x2751:
-00182                         szListChar[0] = 'o';
-00183                         break;
-00184                 case 0x2013: case 0x2500:
-00185                         szListChar[0] = '-';
-00186                         break;
-00187                 case 0x2190: case 0x2199: case 0x2329:
-00188                         szListChar[0] = '<';
-00189                         break;
-00190                 case 0x21d2:
-00191                         szListChar[0] = '=';
-00192                         break;
-00193                 case 0x21e8: case 0x27a2:
-00194                         szListChar[0] = '>';
-00195                         break;
-00196                 case 0x25a0: case 0x25aa:
-00197                         szListChar[0] = '.';
-00198                         break;
-00199                 case 0x2666:
-00200                         szListChar[0] = OUR_DIAMOND;
-00201                         break;
-00202                 case 0x270c:
-00203                         szListChar[0] = 'x';
-00204                         break;
-00205                 case 0x2713:
-00206                         szListChar[0] = 'V';
-00207                         break;
-00208                 case 0x2756:
-00209                         szListChar[0] = '*';
-00210                         break;
-00211                 case 0x2022:
-00212                 default:
-00213                         vGetBulletValue(eConversionType, eEncoding,
-00214                                         szListChar, 2);
-00215                         break;
-00216                 }
-00217                 tLen = 1;
-00218         }
-00219         szListChar[tLen] = '\0';
-00220 } /* end of vConvertListCharacter */
-00221 
-00222 /*
-00223  * eGetNumType - get the level type from the given level number
-00224  *
-00225  * Returns the level type
-00226  */
-00227 level_type_enum
-00228 eGetNumType(UCHAR ucNumLevel)
-00229 {
-00230         switch (ucNumLevel) {
-00231         case  1: case  2: case  3: case  4: case  5:
-00232         case  6: case  7: case  8: case  9:
-00233                 return level_type_outline;
-00234         case 10:
-00235                 return level_type_numbering;
-00236         case 11:
-00237                 return level_type_sequence;
-00238         case 12:
-00239                 return level_type_pause;
-00240         default:
-00241                 return level_type_none;
-00242         }
-00243 } /* end of eGetNumType */
-00244 
-00245 /*
-00246  * vCorrectStyleValues - correct style values that Antiword can't use
-00247  */
-00248 void
-00249 vCorrectStyleValues(style_block_type *pStyleBlock)
-00250 {
-00251         if (pStyleBlock->usBeforeIndent > 0x7fff) {
-00252                 pStyleBlock->usBeforeIndent = 0;
-00253         } else if (pStyleBlock->usBeforeIndent > 2160) {
-00254                 /* 2160 twips = 1.5 inches or 38.1 mm */
-00255                 DBG_DEC(pStyleBlock->usBeforeIndent);
-00256                 pStyleBlock->usBeforeIndent = 2160;
-00257         }
-00258         if (pStyleBlock->usIstd >= 1 &&
-00259             pStyleBlock->usIstd <= 9 &&
-00260             pStyleBlock->usBeforeIndent < HEADING_GAP) {
-00261                 NO_DBG_DEC(pStyleBlock->usBeforeIndent);
-00262                 pStyleBlock->usBeforeIndent = HEADING_GAP;
-00263         }
-00264 
-00265         if (pStyleBlock->usAfterIndent > 0x7fff) {
-00266                 pStyleBlock->usAfterIndent = 0;
-00267         } else if (pStyleBlock->usAfterIndent > 2160) {
-00268                 /* 2160 twips = 1.5 inches or 38.1 mm */
-00269                 DBG_DEC(pStyleBlock->usAfterIndent);
-00270                 pStyleBlock->usAfterIndent = 2160;
-00271         }
-00272         if (pStyleBlock->usIstd >= 1 &&
-00273             pStyleBlock->usIstd <= 9 &&
-00274             pStyleBlock->usAfterIndent < HEADING_GAP) {
-00275                 NO_DBG_DEC(pStyleBlock->usAfterIndent);
-00276                 pStyleBlock->usAfterIndent = HEADING_GAP;
-00277         }
-00278 
-00279         if (pStyleBlock->sLeftIndent < 0) {
-00280                 pStyleBlock->sLeftIndent = 0;
-00281         }
-00282         if (pStyleBlock->sRightIndent > 0) {
-00283                 pStyleBlock->sRightIndent = 0;
-00284         }
-00285         vConvertListCharacter(pStyleBlock->ucNFC,
-00286                         pStyleBlock->usListChar,
-00287                         pStyleBlock->szListChar);
-00288 } /* end of vCorrectStyleValues */
-00289 
-00290 /*
-00291  * vAdd2StyleInfoList - Add an element to the Style Information List
-00292  */
-00293 void
-00294 vAdd2StyleInfoList(const style_block_type *pStyleBlock)
-00295 {
-00296         style_mem_type  *pListMember;
-00297 
-00298         fail(pStyleBlock == NULL);
-00299 
-00300         NO_DBG_MSG("bAdd2StyleInfoList");
-00301 
-00302         if (pStyleBlock->ulFileOffset == FC_INVALID) {
-00303                 NO_DBG_DEC(pStyleBlock->usIstd);
-00304                 return;
-00305         }
-00306 
-00307         NO_DBG_HEX(pStyleBlock->ulFileOffset);
-00308         NO_DBG_DEC_C(pStyleBlock->sLeftIndent != 0,
-00309                                         pStyleBlock->sLeftIndent);
-00310         NO_DBG_DEC_C(pStyleBlock->sRightIndent != 0,
-00311                                         pStyleBlock->sRightIndent);
-00312         NO_DBG_DEC_C(pStyleBlock->bNumPause, pStyleBlock->bNumPause);
-00313         NO_DBG_DEC_C(pStyleBlock->usIstd != 0, pStyleBlock->usIstd);
-00314         NO_DBG_DEC_C(pStyleBlock->usStartAt != 1, pStyleBlock->usStartAt);
-00315         NO_DBG_DEC_C(pStyleBlock->usAfterIndent != 0,
-00316                                         pStyleBlock->usAfterIndent);
-00317         NO_DBG_DEC_C(pStyleBlock->ucAlignment != 0, pStyleBlock->ucAlignment);
-00318         NO_DBG_DEC(pStyleBlock->ucNFC);
-00319         NO_DBG_HEX(pStyleBlock->usListChar);
-00320 
-00321         if (pStyleLast != NULL &&
-00322             pStyleLast->tInfo.ulFileOffset == pStyleBlock->ulFileOffset) {
-00323                 /*
-00324                  * If two consecutive styles share the same
-00325                  * offset, remember only the last style
-00326                  */
-00327                 fail(pStyleLast->pNext != NULL);
-00328                 pStyleLast->tInfo = *pStyleBlock;
-00329                 /* Correct the values where needed */
-00330                 vCorrectStyleValues(&pStyleLast->tInfo);
-00331                 return;
-00332         }
-00333 
-00334         /* Create list member */
-00335         pListMember = xmalloc(sizeof(style_mem_type));
-00336         /* Fill the list member */
-00337         pListMember->tInfo = *pStyleBlock;
-00338         pListMember->pNext = NULL;
-00339         /* Add the sequence number */
-00340         pListMember->ulSequenceNumber =
-00341                         ulGetSeqNumber(pListMember->tInfo.ulFileOffset);
-00342         /* Correct the values where needed */
-00343         vCorrectStyleValues(&pListMember->tInfo);
-00344         /* Add the new member to the list */
-00345         if (pAnchor == NULL) {
-00346                 pAnchor = pListMember;
-00347                 /* For efficiency */
-00348                 pMidPtr = pAnchor;
-00349                 bMoveMidPtr = FALSE;
-00350                 bInSequence = TRUE;
-00351         } else {
-00352                 fail(pStyleLast == NULL);
-00353                 pStyleLast->pNext = pListMember;
-00354                 /* For efficiency */
-00355                 if (bMoveMidPtr) {
-00356                         pMidPtr = pMidPtr->pNext;
-00357                         bMoveMidPtr = FALSE;
-00358                 } else {
-00359                         bMoveMidPtr = TRUE;
-00360                 }
-00361                 if (bInSequence) {
-00362                         bInSequence = pListMember->ulSequenceNumber >
-00363                                         pStyleLast->ulSequenceNumber;
-00364                 }
-00365         }
-00366         pStyleLast = pListMember;
-00367 } /* end of vAdd2StyleInfoList */
-00368 
-00369 /*
-00370  * Get the record that follows the given recored in the Style Information List
-00371  */
-00372 const style_block_type *
-00373 pGetNextStyleInfoListItem(const style_block_type *pCurr)
-00374 {
-00375         const style_mem_type    *pRecord;
-00376         size_t  tOffset;
-00377 
-00378         if (pCurr == NULL) {
-00379                 if (pAnchor == NULL) {
-00380                         /* There are no records */
-00381                         return NULL;
-00382                 }
-00383                 /* The first record is the only one without a predecessor */
-00384                 return &pAnchor->tInfo;
-00385         }
-00386         tOffset = offsetof(style_mem_type, tInfo);
-00387         /* Many casts to prevent alignment warnings */
-00388         pRecord = (style_mem_type *)(void *)((char *)pCurr - tOffset);
-00389         fail(pCurr != &pRecord->tInfo);
-00390         if (pRecord->pNext == NULL) {
-00391                 /* The last record has no successor */
-00392                 return NULL;
-00393         }
-00394         return &pRecord->pNext->tInfo;
-00395 } /* end of pGetNextStyleInfoListItem */
-00396 
-00397 /*
-00398  * Get the next text style
-00399  */
-00400 const style_block_type *
-00401 pGetNextTextStyle(const style_block_type *pCurr)
-00402 {
-00403         const style_block_type  *pRecord;
-00404 
-00405         pRecord = pCurr;
-00406         do {
-00407                 pRecord = pGetNextStyleInfoListItem(pRecord);
-00408         } while (pRecord != NULL &&
-00409                  (pRecord->eListID == hdrftr_list ||
-00410                   pRecord->eListID == macro_list ||
-00411                   pRecord->eListID == annotation_list));
-00412         return pRecord;
-00413 } /* end of pGetNextTextStyle */
-00414 
-00415 /*
-00416  * usGetIstd - get the istd that belongs to the given file offset
-00417  */
-00418 USHORT
-00419 usGetIstd(ULONG ulFileOffset)
-00420 {
-00421         const style_mem_type    *pCurr, *pBest, *pStart;
-00422         ULONG   ulSeq, ulBest;
-00423 
-00424         ulSeq = ulGetSeqNumber(ulFileOffset);
-00425         if (ulSeq == FC_INVALID) {
-00426                 return ISTD_NORMAL;
-00427         }
-00428         NO_DBG_HEX(ulFileOffset);
-00429         NO_DBG_DEC(ulSeq);
-00430 
-00431         if (bInSequence &&
-00432             pMidPtr != NULL &&
-00433             ulSeq > pMidPtr->ulSequenceNumber) {
-00434                 /* The istd is in the second half of the chained list */
-00435                 pStart = pMidPtr;
-00436         } else {
-00437                 pStart = pAnchor;
-00438         }
-00439 
-00440         pBest = NULL;
-00441         ulBest = 0;
-00442         for (pCurr = pStart; pCurr != NULL; pCurr = pCurr->pNext) {
-00443                 if (pCurr->ulSequenceNumber != FC_INVALID &&
-00444                     (pBest == NULL || pCurr->ulSequenceNumber > ulBest) &&
-00445                     pCurr->ulSequenceNumber <= ulSeq) {
-00446                         pBest = pCurr;
-00447                         ulBest = pCurr->ulSequenceNumber;
-00448                 }
-00449                 if (bInSequence && pCurr->ulSequenceNumber > ulSeq) {
-00450                         break;
-00451                 }
-00452         }
-00453         NO_DBG_DEC(ulBest);
-00454 
-00455         if (pBest == NULL) {
-00456                 return ISTD_NORMAL;
-00457         }
-00458 
-00459         NO_DBG_DEC(pBest->tInfo.usIstd);
-00460         return pBest->tInfo.usIstd;
-00461 } /* end of usGetIstd */
-00462 
-00463 /*
-00464  * bStyleImpliesList - does style info implies being part of a list
-00465  *
-00466  * Decide whether the style information implies that the given paragraph is
-00467  * part of a list
-00468  *
-00469  * Returns TRUE when the paragraph is part of a list, otherwise FALSE
-00470  */
-00471 BOOL
-00472 bStyleImpliesList(const style_block_type *pStyle, int iWordVersion)
-00473 {
-00474         fail(pStyle == NULL);
-00475         fail(iWordVersion < 0);
-00476 
-00477         if (pStyle->usIstd >= 1 && pStyle->usIstd <= 9) {
-00478                 /* These are heading levels */
-00479                 return FALSE;
-00480         }
-00481         if (iWordVersion < 8) {
-00482                 /* Check for old style lists */
-00483                 return pStyle->ucNumLevel != 0;
-00484         }
-00485         /* Check for new style lists */
-00486         return pStyle->usListIndex != 0;
-00487 } /* end of bStyleImpliesList */
-
-
Generated by  - -doxygen 1.6.2
- - diff -r 59758314f811 -r d4524d6a4472 Symbian3/Examples/guid-6013a680-57f9-415b-8851-c4fa63356636/stylesheet_8c_source.html --- a/Symbian3/Examples/guid-6013a680-57f9-415b-8851-c4fa63356636/stylesheet_8c_source.html Fri Jun 11 15:24:34 2010 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,854 +0,0 @@ - - - - -TB9.2 Example Applications: examples/PIPS/antiword/src/stylesheet.c Source File - - - - - -

examples/PIPS/antiword/src/stylesheet.c

00001 /*
-00002  * stylesheet.c
-00003  * Copyright (C) 2001-2004 A.J. van Os; Released under GNU GPL
-00004  *
-00005  * Description:
-00006  * Build, read and destroy a list of stylesheet information
-00007  *
-00008  */
-00009 
-00010 #include <string.h>
-00011 #include "antiword.h"
-00012 
-00013 
-00014 #define SGC_PAP         1
-00015 #define SGC_CHP         2
-00016 
-00017 /* Variables needed to describe the stylesheet list */
-00018 static style_block_type *atStyleInfo = NULL;
-00019 static font_block_type  *atFontInfo = NULL;
-00020 static BOOL             *abFilled = NULL;
-00021 static size_t           tStdCount = 0;
-00022 
-00023 
-00024 /*
-00025  * vDestroyStylesheetList - destroy the stylesheet list
-00026  */
-00027 void
-00028 vDestroyStylesheetList(void)
-00029 {
-00030         DBG_MSG("vDestroyStylesheetList");
-00031 
-00032         tStdCount = 0;
-00033         atStyleInfo = xfree(atStyleInfo);
-00034         atFontInfo = xfree(atFontInfo);
-00035         abFilled = xfree(abFilled);
-00036 } /* end of vDestroyStylesheetList */
-00037 
-00038 /*
-00039  * vGetDefaultStyle - fill the style struct with default values
-00040  */
-00041 static void
-00042 vGetDefaultStyle(style_block_type *pStyle)
-00043 {
-00044         (void)memset(pStyle, 0, sizeof(*pStyle));
-00045         pStyle->usIstd = ISTD_INVALID;
-00046         pStyle->usIstdNext = ISTD_INVALID;
-00047         pStyle->usStartAt = 1;
-00048         pStyle->ucListLevel = 9;
-00049 } /* end of vGetDefaultStyle */
-00050 
-00051 /*
-00052  * vGetDefaultFont - fill the font struct with default values
-00053  */
-00054 static void
-00055 vGetDefaultFont(font_block_type *pFont, USHORT usDefaultFontNumber)
-00056 {
-00057         (void)memset(pFont, 0, sizeof(*pFont));
-00058         pFont->usFontSize = DEFAULT_FONT_SIZE;
-00059         if (usDefaultFontNumber <= (USHORT)UCHAR_MAX) {
-00060                 pFont->ucFontNumber = (UCHAR)usDefaultFontNumber;
-00061         } else {
-00062                 DBG_DEC(usDefaultFontNumber);
-00063                 DBG_FIXME();
-00064                 pFont->ucFontNumber = 0;
-00065         }
-00066 } /* end of vGetDefaultFont */
-00067 
-00068 /*
-00069  * iGetStyleIndex - get the index of the record with the specified istd
-00070  *
-00071  * returns the index when found, otherwise -1
-00072  */
-00073 static int
-00074 iGetStyleIndex(USHORT usIstd)
-00075 {
-00076         int     iIndex;
-00077 
-00078         fail(abFilled == NULL);
-00079 
-00080         if (usIstd == ISTD_INVALID || abFilled == NULL) {
-00081                 return -1;
-00082         }
-00083 
-00084         for (iIndex = 0; iIndex < (int)tStdCount; iIndex++) {
-00085                 if (abFilled[iIndex] && atStyleInfo[iIndex].usIstd == usIstd) {
-00086                         /* The record is filled and the istd matches */
-00087                         return iIndex;
-00088                 }
-00089         }
-00090         return -1;
-00091 } /* end of iGetStyleIndex */
-00092 
-00093 /*
-00094  * Get a build-in style for Winword 1/2
-00095  */
-00096 static void
-00097 vGetBuildinStyle(UCHAR ucStc, style_block_type *pStyle)
-00098 {
-00099         fail(pStyle == NULL);
-00100 
-00101         /* Start with de defaults */
-00102         vGetDefaultStyle(pStyle);
-00103 
-00104         /* Add the build-in style info */
-00105         switch (ucStc) {
-00106         case 246:
-00107         case 247:
-00108         case 248:
-00109         case 249:
-00110         case 250:
-00111         case 255:
-00112                 pStyle->sLeftIndent = 720;
-00113                 break;
-00114         case 251:
-00115         case 252:
-00116                 pStyle->sLeftIndent = 360;
-00117                 break;
-00118         case 253:
-00119                 pStyle->usBeforeIndent = 120;
-00120                 break;
-00121         case 254:
-00122                 pStyle->usBeforeIndent = 240;
-00123                 break;
-00124         default:
-00125                 if (ucStc >= 233 && ucStc <= 239) {
-00126                         pStyle->sLeftIndent = (239 - (short)ucStc) * 360;
-00127                 }
-00128                 if (ucStc >= 225 && ucStc <= 232) {
-00129                         pStyle->sLeftIndent = (232 - (short)ucStc) * 720;
-00130                         pStyle->sRightIndent = 720;
-00131                 }
-00132                 break;
-00133         }
-00134 } /* end of vGetBuildinStyle */
-00135 
-00136 /*
-00137  * Get a build-in fontstyle for Winword 1/2
-00138  */
-00139 static void
-00140 vGetBuildinFont(UCHAR ucStc, font_block_type *pFont)
-00141 {
-00142         fail(pFont == NULL);
-00143 
-00144         /* Start with de defaults */
-00145         vGetDefaultFont(pFont, 0);
-00146 
-00147         /* Add the build-in fontstyle info */
-00148         switch (ucStc) {
-00149         case 223:
-00150         case 244:
-00151                 pFont->usFontSize = 16;
-00152                 break;
-00153         case 246:
-00154         case 247:
-00155         case 248:
-00156                 pFont->usFontStyle |= FONT_ITALIC;
-00157                 break;
-00158         case 249:
-00159                 pFont->usFontStyle |= FONT_UNDERLINE;
-00160                 break;
-00161         case 250:
-00162                 pFont->usFontStyle |= FONT_BOLD;
-00163                 break;
-00164         case 251:
-00165                 pFont->usFontStyle |= FONT_UNDERLINE;
-00166                 pFont->usFontSize = 24;
-00167                 break;
-00168         case 252:
-00169                 pFont->usFontStyle |= FONT_BOLD;
-00170                 pFont->usFontSize = 24;
-00171                 break;
-00172         case 253:
-00173                 pFont->ucFontNumber = 2;
-00174                 pFont->usFontStyle |= FONT_BOLD;
-00175                 pFont->usFontSize = 24;
-00176                 break;
-00177         case 254:
-00178                 pFont->ucFontNumber = 2;
-00179                 pFont->usFontStyle |= (FONT_BOLD|FONT_UNDERLINE);
-00180                 pFont->usFontSize = 24;
-00181                 break;
-00182         default:
-00183                 break;
-00184         }
-00185 } /* end of vGetBuildinFont */
-00186 
-00187 /*
-00188  * Convert a stylecode (stc) as used by WinWord 1/2 into a styleindex (istd)
-00189  * as used by Word 6 and up
-00190  */
-00191 USHORT
-00192 usStc2istd(UCHAR ucStc)
-00193 {
-00194         /* Old nil style to new nil style */
-00195         if (ucStc == 222) {
-00196                 return STI_NIL;
-00197         }
-00198 
-00199         /* Heading 1 through 9 must become istd 1 through 9 */
-00200         /* so 254 through 246 must become 1 through 9 and vice versa */
-00201         if ((ucStc >= 1 && ucStc <= 9) ||
-00202             (ucStc >= 246 && ucStc <= 254)) {
-00203                 return 255 - (USHORT)ucStc;
-00204         }
-00205         return (USHORT)ucStc;
-00206 } /* end of usStd2istd */
-00207 
-00208 /*
-00209  * Build the lists with Stylesheet Information for WinWord 1/2 files
-00210  */
-00211 void
-00212 vGet2Stylesheet(FILE *pFile, int iWordVersion, const UCHAR *aucHeader)
-00213 {
-00214         style_block_type        *pStyle;
-00215         font_block_type         *pFont;
-00216         UCHAR   *aucBuffer;
-00217         ULONG   ulBeginStshInfo;
-00218         size_t  tStshInfoLen, tName, tChpx, tPapx, tMaxIndex;
-00219         int     iStIndex, iChpxIndex, iPapxIndex, iSt, iChpx, iPapx;
-00220         int     iStd, iIndex, iBaseStyleIndex, iCounter;
-00221         USHORT  usBaseStyle;
-00222         UCHAR   ucStc, ucStcNext, ucStcBase;
-00223 
-00224         fail(pFile == NULL || aucHeader == NULL);
-00225         fail(iWordVersion != 1 && iWordVersion != 2);
-00226 
-00227         ulBeginStshInfo = ulGetLong(0x5e, aucHeader); /* fcStshf */
-00228         NO_DBG_HEX(ulBeginStshInfo);
-00229         tStshInfoLen = (size_t)usGetWord(0x62, aucHeader); /* cbStshf */
-00230         NO_DBG_DEC(tStshInfoLen);
-00231 
-00232         aucBuffer = xmalloc(tStshInfoLen);
-00233         if (!bReadBytes(aucBuffer, tStshInfoLen, ulBeginStshInfo, pFile)) {
-00234                 aucBuffer = xfree(aucBuffer);
-00235                 return;
-00236         }
-00237         NO_DBG_PRINT_BLOCK(aucBuffer, tStshInfoLen);
-00238 
-00239         fail(2 > tStshInfoLen);
-00240         iStd = (int)usGetWord(0, aucBuffer);
-00241 
-00242         fail(2 + 2 > tStshInfoLen);
-00243         tName = (size_t)usGetWord(2, aucBuffer);
-00244 
-00245         fail(2 + tName + 2 > tStshInfoLen);
-00246         tChpx = (size_t)usGetWord(2 + tName, aucBuffer);
-00247 
-00248         fail(2 + tName + tChpx + 2 > tStshInfoLen);
-00249         tPapx = (size_t)usGetWord(2 + tName + tChpx, aucBuffer);
-00250 
-00251         fail(2 + tName + tChpx + tPapx + 2 > tStshInfoLen);
-00252         tStdCount = (size_t)usGetWord(2 + tName + tChpx + tPapx, aucBuffer);
-00253 
-00254         NO_DBG_HEX(tStdCount);
-00255 
-00256         atStyleInfo = xcalloc(tStdCount, sizeof(style_block_type));
-00257         atFontInfo = xcalloc(tStdCount, sizeof(font_block_type));
-00258         abFilled = xcalloc(tStdCount, sizeof(BOOL));
-00259 
-00260         do {
-00261                 iCounter = 0;
-00262                 iStIndex = 2 + 2;
-00263                 iChpxIndex = 2 + (int)tName + 2;
-00264                 iPapxIndex = 2 + (int)tName + (int)tChpx + 2;
-00265                 tMaxIndex = 2 + tName + tChpx + tPapx + 2;
-00266                 /* Read the styles one-by-one */
-00267                 for (iIndex = 0; iIndex < (int)tStdCount; iIndex++) {
-00268                         pStyle = &atStyleInfo[iIndex];
-00269                         pFont = &atFontInfo[iIndex];
-00270                         iSt = (int)ucGetByte(iStIndex, aucBuffer);
-00271                         iChpx = (int)ucGetByte(iChpxIndex, aucBuffer);
-00272                         iPapx = (int)ucGetByte(iPapxIndex, aucBuffer);
-00273                         NO_DBG_HEX(iSt);
-00274                         NO_DBG_HEX(iChpx);
-00275                         NO_DBG_HEX(iPapx);
-00276                         if (iSt == 0xff || tMaxIndex + 1 >= tStshInfoLen) {
-00277                                 /* Undefined style or no information */
-00278                                 iStIndex++;
-00279                                 iChpxIndex++;
-00280                                 iPapxIndex++;
-00281                                 tMaxIndex += 2;
-00282                                 if (!abFilled[iIndex]) {
-00283                                         DBG_HEX_C(iChpx != 0xff, iChpx);
-00284                                         DBG_HEX_C(iPapx != 0xff, iPapx);
-00285                                         vGetDefaultStyle(pStyle);
-00286                                         vGetDefaultFont(pFont, 0);
-00287                                         abFilled[iIndex] = TRUE;
-00288                                 }
-00289                                 continue;
-00290                         }
-00291 
-00292                         NO_DBG_STRN(aucBuffer + iStIndex + 1, iSt);
-00293                         iStIndex += iSt + 1;
-00294 
-00295                         ucStcNext = ucGetByte(tMaxIndex, aucBuffer);
-00296                         ucStcBase = ucGetByte(tMaxIndex + 1, aucBuffer);
-00297                         ucStc = (UCHAR)((iIndex - iStd) & 0xff);
-00298                         NO_DBG_DEC(ucStc);
-00299 
-00300                         if (iChpx == 0xff || iPapx == 0xff) {
-00301                                 /* Use a build-in style */
-00302                                 iChpxIndex++;
-00303                                 iPapxIndex++;
-00304                                 tMaxIndex += 2;
-00305                                 if (!abFilled[iIndex]) {
-00306                                         DBG_HEX_C(iChpx != 0xff, iChpx);
-00307                                         DBG_HEX_C(iPapx != 0xff, iPapx);
-00308                                         vGetBuildinStyle(ucStc, pStyle);
-00309                                         pStyle->usIstd = usStc2istd(ucStc);
-00310                                         pStyle->usIstdNext =
-00311                                                         usStc2istd(ucStcNext);
-00312                                         vGetBuildinFont(ucStc, pFont);
-00313                                         abFilled[iIndex] = TRUE;
-00314                                 }
-00315                                 continue;
-00316                         }
-00317 
-00318                         if (abFilled[iIndex]) {
-00319                                 /* This record has already been filled */
-00320                                 iChpxIndex += iChpx + 1;
-00321                                 iPapxIndex += iPapx + 1;
-00322                                 tMaxIndex += 2;
-00323                                 continue;
-00324                         }
-00325 
-00326                         usBaseStyle = usStc2istd(ucStcBase);
-00327 
-00328                         if (usBaseStyle == STI_NIL) {
-00329                                 /* Based on the Nil style */
-00330                                 vGetDefaultStyle(pStyle);
-00331                                 vGetDefaultFont(pFont, 0);
-00332                         } else {
-00333                                 iBaseStyleIndex = iGetStyleIndex(usBaseStyle);
-00334                                 NO_DBG_DEC(iBaseStyleIndex);
-00335                                 if (iBaseStyleIndex < 0) {
-00336                                         /* This style is not known yet */
-00337                                         iChpxIndex += iChpx + 1;
-00338                                         iPapxIndex += iPapx + 1;
-00339                                         tMaxIndex += 2;
-00340                                         continue;
-00341                                 }
-00342                                 fail(iBaseStyleIndex >= (int)tStdCount);
-00343                                 fail(!abFilled[iBaseStyleIndex]);
-00344                                 /* Based on the specified base style */
-00345                                 *pStyle = atStyleInfo[iBaseStyleIndex];
-00346                                 *pFont = atFontInfo[iBaseStyleIndex];
-00347                         }
-00348                         pStyle->usIstd = usStc2istd(ucStc);
-00349                         pStyle->usIstdNext = usStc2istd(ucStcNext);
-00350 
-00351                         abFilled[iIndex] = TRUE;
-00352                         iCounter++;
-00353 
-00354                         /* Add the changes if any */
-00355                         switch (iChpx) {
-00356                         case 0x00:
-00357                         case 0xff:
-00358                                 iChpxIndex++;
-00359                                 break;
-00360                         default:
-00361                                 NO_DBG_PRINT_BLOCK(aucBuffer + iChpxIndex + 1,
-00362                                                 iChpx);
-00363                                 if (iWordVersion == 1) {
-00364                                         vGet1FontInfo(0,
-00365                                                 aucBuffer + iChpxIndex + 1,
-00366                                                 (size_t)iChpx, pFont);
-00367                                 } else {
-00368                                         vGet2FontInfo(0,
-00369                                                 aucBuffer + iChpxIndex + 1,
-00370                                                 (size_t)iChpx, pFont);
-00371                                 }
-00372                                 iChpxIndex += iChpx + 1;
-00373                                 break;
-00374                         }
-00375 
-00376                         switch (iPapx) {
-00377                         case 0x00:
-00378                         case 0xff:
-00379                                 iPapxIndex++;
-00380                                 break;
-00381                         default:
-00382                                 NO_DBG_PRINT_BLOCK(aucBuffer + iPapxIndex + 8,
-00383                                                 iPapx - 7);
-00384                                 vGet2StyleInfo(0, aucBuffer + iPapxIndex + 8,
-00385                                                 iPapx - 7, pStyle);
-00386                                 iPapxIndex += iPapx + 1;
-00387                                 break;
-00388                         }
-00389                         tMaxIndex += 2;
-00390 
-00391                 }
-00392                 NO_DBG_DEC(iCounter);
-00393         } while (iCounter > 0);
-00394 
-00395         /* Fill records that are still empty */
-00396         for (iIndex = 0; iIndex < (int)tStdCount; iIndex++) {
-00397                 if (!abFilled[iIndex]) {
-00398                         NO_DBG_DEC(iIndex);
-00399                         vGetDefaultStyle(&atStyleInfo[iIndex]);
-00400                         vGetDefaultFont(&atFontInfo[iIndex], 0);
-00401                 }
-00402         }
-00403 
-00404         /* Clean up before you leave */
-00405         abFilled = xfree(abFilled);
-00406         aucBuffer = xfree(aucBuffer);
-00407 } /* end of vGet2Stylesheet */
-00408 
-00409 /*
-00410  * Build the lists with Stylesheet Information for Word 6/7 files
-00411  */
-00412 void
-00413 vGet6Stylesheet(FILE *pFile, ULONG ulStartBlock,
-00414         const ULONG *aulBBD, size_t tBBDLen, const UCHAR *aucHeader)
-00415 {
-00416         style_block_type        *pStyle;
-00417         font_block_type         *pFont;
-00418         UCHAR   *aucBuffer;
-00419         ULONG   ulBeginStshInfo;
-00420         size_t  tStshInfoLen, tOffset, tStdLen, tStdBaseInFile;
-00421         size_t  tPos, tNameLen, tUpxLen;
-00422         int     iIndex, iBaseStyleIndex, iCounter;
-00423         USHORT  usTmp, usUpxCount, usStyleType, usBaseStyle;
-00424         USHORT  usFtcStandardChpStsh;
-00425 
-00426         fail(pFile == NULL || aucHeader == NULL);
-00427         fail(ulStartBlock > MAX_BLOCKNUMBER && ulStartBlock != END_OF_CHAIN);
-00428         fail(aulBBD == NULL);
-00429 
-00430         ulBeginStshInfo = ulGetLong(0x60, aucHeader); /* fcStshf */
-00431         NO_DBG_HEX(ulBeginStshInfo);
-00432         tStshInfoLen = (size_t)ulGetLong(0x64, aucHeader); /* lcbStshf */
-00433         NO_DBG_DEC(tStshInfoLen);
-00434 
-00435         aucBuffer = xmalloc(tStshInfoLen);
-00436         if (!bReadBuffer(pFile, ulStartBlock,
-00437                         aulBBD, tBBDLen, BIG_BLOCK_SIZE,
-00438                         aucBuffer, ulBeginStshInfo, tStshInfoLen)) {
-00439                 aucBuffer = xfree(aucBuffer);
-00440                 return;
-00441         }
-00442         NO_DBG_PRINT_BLOCK(aucBuffer, tStshInfoLen);
-00443 
-00444         tStdCount = (size_t)usGetWord(2, aucBuffer);
-00445         NO_DBG_DEC(tStdCount);
-00446         tStdBaseInFile = (size_t)usGetWord(4, aucBuffer);
-00447         usFtcStandardChpStsh = usGetWord(14, aucBuffer);
-00448         NO_DBG_DEC(usFtcStandardChpStsh);
-00449 
-00450         atStyleInfo = xcalloc(tStdCount, sizeof(style_block_type));
-00451         atFontInfo = xcalloc(tStdCount, sizeof(font_block_type));
-00452         abFilled = xcalloc(tStdCount, sizeof(BOOL));
-00453 
-00454         do {
-00455                 iCounter = 0;
-00456                 /* Read the styles one-by-one */
-00457                 for (iIndex = 0, tOffset = 2 + (size_t)usGetWord(0, aucBuffer);
-00458                      iIndex < (int)tStdCount;
-00459                      iIndex++, tOffset += 2 + tStdLen) {
-00460                         NO_DBG_DEC(tOffset);
-00461                         tStdLen = (size_t)usGetWord(tOffset, aucBuffer);
-00462                         NO_DBG_DEC(tStdLen);
-00463                         if (abFilled[iIndex]) {
-00464                                 /* This record has already been filled */
-00465                                 continue;
-00466                         }
-00467                         pStyle = &atStyleInfo[iIndex];
-00468                         pFont = &atFontInfo[iIndex];
-00469                         if (tStdLen == 0) {
-00470                                 /* Empty record */
-00471                                 vGetDefaultStyle(pStyle);
-00472                                 vGetDefaultFont(pFont, usFtcStandardChpStsh);
-00473                                 abFilled[iIndex] = TRUE;
-00474                                 continue;
-00475                         }
-00476                         usTmp = usGetWord(tOffset + 4, aucBuffer);
-00477                         usStyleType = usTmp % 16;
-00478                         usBaseStyle = usTmp / 16;
-00479                         NO_DBG_DEC(usStyleType);
-00480                         NO_DBG_DEC(usBaseStyle);
-00481                         if (usBaseStyle == STI_NIL || usBaseStyle == STI_USER) {
-00482                                 /* Based on the Nil style */
-00483                                 vGetDefaultStyle(pStyle);
-00484                                 vGetDefaultFont(pFont, usFtcStandardChpStsh);
-00485                         } else {
-00486                                 iBaseStyleIndex = iGetStyleIndex(usBaseStyle);
-00487                                 NO_DBG_DEC(iBaseStyleIndex);
-00488                                 if (iBaseStyleIndex < 0) {
-00489                                         /* This base style is not known yet */
-00490                                         continue;
-00491                                 }
-00492                                 fail(iBaseStyleIndex >= (int)tStdCount);
-00493                                 fail(!abFilled[iBaseStyleIndex]);
-00494                                 /* Based on the specified base style */
-00495                                 *pStyle = atStyleInfo[iBaseStyleIndex];
-00496                                 pStyle->usIstd = ISTD_INVALID;
-00497                                 *pFont = atFontInfo[iBaseStyleIndex];
-00498                         }
-00499                         abFilled[iIndex] = TRUE;
-00500                         iCounter++;
-00501                         /* STD */
-00502                         usTmp = usGetWord(tOffset + 6, aucBuffer);
-00503                         usUpxCount = usTmp % 16;
-00504                         pStyle->usIstdNext = usTmp / 16;;
-00505                         NO_DBG_DEC(usUpxCount);
-00506                         tPos = 2 + tStdBaseInFile;
-00507                         NO_DBG_DEC(tPos);
-00508                         tNameLen = (size_t)ucGetByte(tOffset + tPos, aucBuffer);
-00509                         NO_DBG_DEC(tNameLen);
-00510                         NO_DBG_STRN(aucBuffer + tOffset + tPos + 1, tNameLen);
-00511                         tNameLen++;     /* Include the ASCII NULL character */
-00512                         tPos += 1 + tNameLen;
-00513                         if (odd(tPos)) {
-00514                                 tPos++;
-00515                         }
-00516                         NO_DBG_DEC(tPos);
-00517                         if (tPos >= tStdLen) {
-00518                                 continue;
-00519                         }
-00520                         tUpxLen = (size_t)usGetWord(tOffset + tPos, aucBuffer);
-00521                         NO_DBG_DEC(tUpxLen);
-00522                         if (tPos + tUpxLen > tStdLen) {
-00523                                 /* UPX length too large to be a record */
-00524                                 DBG_DEC_C(tPos + tUpxLen > tStdLen,
-00525                                                 tPos + tUpxLen);
-00526                                 continue;
-00527                         }
-00528                         if (usStyleType == SGC_PAP && usUpxCount >= 1) {
-00529                                 if (tUpxLen >= 2) {
-00530                                         NO_DBG_PRINT_BLOCK(
-00531                                                 aucBuffer + tOffset + tPos + 2,
-00532                                                 tUpxLen);
-00533                                         pStyle->usIstd = usGetWord(
-00534                                                 tOffset + tPos + 2, aucBuffer);
-00535                                         NO_DBG_DEC(pStyle->usIstd);
-00536                                         NO_DBG_DEC(pStyle->usIstdNext);
-00537                                         vGet6StyleInfo(0,
-00538                                                 aucBuffer + tOffset + tPos + 4,
-00539                                                 tUpxLen - 2, pStyle);
-00540                                         NO_DBG_DEC(pStyle->sLeftIndent);
-00541                                         NO_DBG_DEC(pStyle->sRightIndent);
-00542                                         NO_DBG_HEX(pStyle->ucAlignment);
-00543                                 }
-00544                                 tPos += 2 + tUpxLen;
-00545                                 if (odd(tPos)) {
-00546                                         tPos++;
-00547                                 }
-00548                                 NO_DBG_DEC(tPos);
-00549                                 tUpxLen = (size_t)usGetWord(
-00550                                                 tOffset + tPos, aucBuffer);
-00551                                 NO_DBG_DEC(tUpxLen);
-00552                         }
-00553                         if (tUpxLen == 0 || tPos + tUpxLen > tStdLen) {
-00554                                 /* Too small or too large to be a record */
-00555                                 DBG_DEC_C(tPos + tUpxLen > tStdLen,
-00556                                                         tPos + tUpxLen);
-00557                                 continue;
-00558                         }
-00559                         if ((usStyleType == SGC_PAP && usUpxCount >= 2) ||
-00560                             (usStyleType == SGC_CHP && usUpxCount >= 1)) {
-00561                                 NO_DBG_PRINT_BLOCK(
-00562                                                 aucBuffer + tOffset + tPos + 2,
-00563                                                 tUpxLen);
-00564                                 vGet6FontInfo(0, ISTD_INVALID,
-00565                                                 aucBuffer + tOffset + tPos + 2,
-00566                                                 (int)tUpxLen, pFont);
-00567                                 NO_DBG_DEC(pFont->usFontSize);
-00568                                 NO_DBG_DEC(pFont->ucFontcolor);
-00569                                 NO_DBG_HEX(pFont->usFontStyle);
-00570                         }
-00571                 }
-00572                 NO_DBG_DEC(iCounter);
-00573         } while (iCounter > 0);
-00574 
-00575         /* Fill records that are still empty */
-00576         for (iIndex = 0; iIndex < (int)tStdCount; iIndex++) {
-00577                 if (!abFilled[iIndex]) {
-00578                         NO_DBG_DEC(iIndex);
-00579                         vGetDefaultStyle(&atStyleInfo[iIndex]);
-00580                         vGetDefaultFont(&atFontInfo[iIndex],
-00581                                         usFtcStandardChpStsh);
-00582                 }
-00583         }
-00584 
-00585         /* Clean up before you leave */
-00586         abFilled = xfree(abFilled);
-00587         aucBuffer = xfree(aucBuffer);
-00588 } /* end of vGet6Stylesheet */
-00589 
-00590 /*
-00591  * Build the lists with Stylesheet Information for Word 8/9/10 files
-00592  */
-00593 void
-00594 vGet8Stylesheet(FILE *pFile, const pps_info_type *pPPS,
-00595         const ULONG *aulBBD, size_t tBBDLen,
-00596         const ULONG *aulSBD, size_t tSBDLen,
-00597         const UCHAR *aucHeader)
-00598 {
-00599         style_block_type        *pStyle;
-00600         font_block_type         *pFont;
-00601         const ULONG     *aulBlockDepot;
-00602         UCHAR   *aucBuffer;
-00603         ULONG   ulBeginStshInfo;
-00604         size_t  tStshInfoLen, tBlockDepotLen, tOffset, tStdLen, tStdBaseInFile;
-00605         size_t  tBlockSize, tPos, tNameLen, tUpxLen;
-00606         int     iIndex, iBaseStyleIndex, iCounter;
-00607         USHORT  usTmp, usUpxCount, usStyleType, usBaseStyle;
-00608         USHORT  usFtcStandardChpStsh;
-00609 
-00610         fail(pFile == NULL || pPPS == NULL || aucHeader == NULL);
-00611         fail(aulBBD == NULL || aulSBD == NULL);
-00612 
-00613         ulBeginStshInfo = ulGetLong(0xa2, aucHeader); /* fcStshf */
-00614         NO_DBG_HEX(ulBeginStshInfo);
-00615         tStshInfoLen = (size_t)ulGetLong(0xa6, aucHeader); /* lcbStshf */
-00616         NO_DBG_DEC(tStshInfoLen);
-00617 
-00618         NO_DBG_DEC(pPPS->tTable.ulSB);
-00619         NO_DBG_HEX(pPPS->tTable.ulSize);
-00620         if (pPPS->tTable.ulSize == 0) {
-00621                 DBG_MSG("No stylesheet information");
-00622                 return;
-00623         }
-00624 
-00625         if (pPPS->tTable.ulSize < MIN_SIZE_FOR_BBD_USE) {
-00626                 /* Use the Small Block Depot */
-00627                 aulBlockDepot = aulSBD;
-00628                 tBlockDepotLen = tSBDLen;
-00629                 tBlockSize = SMALL_BLOCK_SIZE;
-00630         } else {
-00631                 /* Use the Big Block Depot */
-00632                 aulBlockDepot = aulBBD;
-00633                 tBlockDepotLen = tBBDLen;
-00634                 tBlockSize = BIG_BLOCK_SIZE;
-00635         }
-00636         aucBuffer = xmalloc(tStshInfoLen);
-00637         if (!bReadBuffer(pFile, pPPS->tTable.ulSB,
-00638                         aulBlockDepot, tBlockDepotLen, tBlockSize,
-00639                         aucBuffer, ulBeginStshInfo, tStshInfoLen)) {
-00640                 aucBuffer = xfree(aucBuffer);
-00641                 return;
-00642         }
-00643         NO_DBG_PRINT_BLOCK(aucBuffer, tStshInfoLen);
-00644 
-00645         tStdCount = (size_t)usGetWord(2, aucBuffer);
-00646         NO_DBG_DEC(tStdCount);
-00647         tStdBaseInFile = (size_t)usGetWord(4, aucBuffer);
-00648         usFtcStandardChpStsh = usGetWord(14, aucBuffer);
-00649         NO_DBG_DEC(usFtcStandardChpStsh);
-00650 
-00651         atStyleInfo = xcalloc(tStdCount, sizeof(style_block_type));
-00652         atFontInfo = xcalloc(tStdCount, sizeof(font_block_type));
-00653         abFilled = xcalloc(tStdCount, sizeof(BOOL));
-00654 
-00655         do {
-00656                 iCounter = 0;
-00657                 /* Read the styles one-by-one */
-00658                 for (iIndex = 0, tOffset = 2 + (size_t)usGetWord(0, aucBuffer);
-00659                      iIndex < (int)tStdCount;
-00660                      iIndex++, tOffset += 2 + tStdLen) {
-00661                         NO_DBG_DEC(tOffset);
-00662                         tStdLen = (size_t)usGetWord(tOffset, aucBuffer);
-00663                         NO_DBG_DEC(tStdLen);
-00664                         if (abFilled[iIndex]) {
-00665                                 /* This record has already been filled */
-00666                                 continue;
-00667                         }
-00668                         pStyle = &atStyleInfo[iIndex];
-00669                         pFont = &atFontInfo[iIndex];
-00670                         if (tStdLen == 0) {
-00671                                 /* Empty record */
-00672                                 vGetDefaultStyle(pStyle);
-00673                                 vGetDefaultFont(pFont, usFtcStandardChpStsh);
-00674                                 abFilled[iIndex] = TRUE;
-00675                                 continue;
-00676                         }
-00677                         usTmp = usGetWord(tOffset + 4, aucBuffer);
-00678                         usStyleType = usTmp % 16;
-00679                         usBaseStyle = usTmp / 16;
-00680                         NO_DBG_DEC(usStyleType);
-00681                         NO_DBG_DEC(usBaseStyle);
-00682                         if (usBaseStyle == STI_NIL || usBaseStyle == STI_USER) {
-00683                                 /* Based on the Nil style */
-00684                                 vGetDefaultStyle(pStyle);
-00685                                 vGetDefaultFont(pFont, usFtcStandardChpStsh);
-00686                         } else {
-00687                                 iBaseStyleIndex = iGetStyleIndex(usBaseStyle);
-00688                                 NO_DBG_DEC(iBaseStyleIndex);
-00689                                 if (iBaseStyleIndex < 0) {
-00690                                         /* This base style is not known yet */
-00691                                         continue;
-00692                                 }
-00693                                 fail(iBaseStyleIndex >= (int)tStdCount);
-00694                                 fail(!abFilled[iBaseStyleIndex]);
-00695                                 /* Based on the specified base style */
-00696                                 *pStyle = atStyleInfo[iBaseStyleIndex];
-00697                                 pStyle->usIstd = ISTD_INVALID;
-00698                                 *pFont = atFontInfo[iBaseStyleIndex];
-00699                         }
-00700                         abFilled[iIndex] = TRUE;
-00701                         iCounter++;
-00702                         /* STD */
-00703                         usTmp = usGetWord(tOffset + 6, aucBuffer);
-00704                         usUpxCount = usTmp % 16;
-00705                         pStyle->usIstdNext = usTmp / 16;
-00706                         NO_DBG_DEC(usUpxCount);
-00707                         tPos = 2 + tStdBaseInFile;
-00708                         NO_DBG_DEC(tPos);
-00709                         tNameLen = (size_t)usGetWord(tOffset + tPos, aucBuffer);
-00710                         NO_DBG_DEC(tNameLen);
-00711                         tNameLen *= 2;  /* From Unicode characters to bytes */
-00712                         NO_DBG_UNICODE_N(aucBuffer + tOffset + tPos + 2,
-00713                                         tNameLen);
-00714                         tNameLen += 2;  /* Include the Unicode NULL character */
-00715                         tPos += 2 + tNameLen;
-00716                         if (odd(tPos)) {
-00717                                 tPos++;
-00718                         }
-00719                         NO_DBG_DEC(tPos);
-00720                         if (tPos >= tStdLen) {
-00721                                 continue;
-00722                         }
-00723                         tUpxLen = (size_t)usGetWord(tOffset + tPos, aucBuffer);
-00724                         NO_DBG_DEC(tUpxLen);
-00725                         if (tPos + tUpxLen > tStdLen) {
-00726                                 /* UPX length too large to be a record */
-00727                                 DBG_DEC_C(tPos + tUpxLen > tStdLen,
-00728                                                 tPos + tUpxLen);
-00729                                 continue;
-00730                         }
-00731                         if (usStyleType == SGC_PAP && usUpxCount >= 1) {
-00732                                 if (tUpxLen >= 2) {
-00733                                         NO_DBG_PRINT_BLOCK(
-00734                                                 aucBuffer + tOffset + tPos + 2,
-00735                                                 tUpxLen);
-00736                                         pStyle->usIstd = usGetWord(
-00737                                                 tOffset + tPos + 2, aucBuffer);
-00738                                         NO_DBG_DEC(pStyle->usIstd);
-00739                                         NO_DBG_DEC(pStyle->usIstdNext);
-00740                                         vGet8StyleInfo(0,
-00741                                                 aucBuffer + tOffset + tPos + 4,
-00742                                                 tUpxLen - 2, pStyle);
-00743                                         NO_DBG_DEC(pStyle->sLeftIndent);
-00744                                         NO_DBG_DEC(pStyle->sRightIndent);
-00745                                         NO_DBG_HEX(pStyle->ucAlignment);
-00746                                 }
-00747                                 tPos += 2 + tUpxLen;
-00748                                 if (odd(tPos)) {
-00749                                         tPos++;
-00750                                 }
-00751                                 NO_DBG_DEC(tPos);
-00752                                 tUpxLen = (size_t)usGetWord(
-00753                                                 tOffset + tPos, aucBuffer);
-00754                                 NO_DBG_DEC(tUpxLen);
-00755                         }
-00756                         if (tUpxLen == 0 || tPos + tUpxLen > tStdLen) {
-00757                                 /* Too small or too large to be a record */
-00758                                 DBG_DEC_C(tPos + tUpxLen > tStdLen,
-00759                                                         tPos + tUpxLen);
-00760                                 continue;
-00761                         }
-00762                         if ((usStyleType == SGC_PAP && usUpxCount >= 2) ||
-00763                             (usStyleType == SGC_CHP && usUpxCount >= 1)) {
-00764                                 NO_DBG_PRINT_BLOCK(
-00765                                                 aucBuffer + tOffset + tPos + 2,
-00766                                                 tUpxLen);
-00767                                 vGet8FontInfo(0, ISTD_INVALID,
-00768                                                 aucBuffer + tOffset + tPos + 2,
-00769                                                 (int)tUpxLen, pFont);
-00770                                 NO_DBG_DEC(pFont->usFontSize);
-00771                                 NO_DBG_DEC(pFont->ucFontcolor);
-00772                                 NO_DBG_HEX(pFont->usFontStyle);
-00773                         }
-00774                 }
-00775                 NO_DBG_DEC(iCounter);
-00776         } while (iCounter > 0);
-00777 
-00778         /* Fill records that are still empty */
-00779         for (iIndex = 0; iIndex < (int)tStdCount; iIndex++) {
-00780                 if (!abFilled[iIndex]) {
-00781                         NO_DBG_DEC(iIndex);
-00782                         vGetDefaultStyle(&atStyleInfo[iIndex]);
-00783                         vGetDefaultFont(&atFontInfo[iIndex],
-00784                                         usFtcStandardChpStsh);
-00785                 }
-00786         }
-00787 
-00788         /* Clean up before you leave */
-00789         abFilled = xfree(abFilled);
-00790         aucBuffer = xfree(aucBuffer);
-00791 } /* end of vGet8Stylesheet */
-00792 
-00793 /*
-00794  * vFillStyleFromStylesheet - fill a style struct with stylesheet info
-00795  */
-00796 void
-00797 vFillStyleFromStylesheet(USHORT usIstd, style_block_type *pStyle)
-00798 {
-00799         int     iIndex;
-00800 
-00801         fail(pStyle == NULL);
-00802 
-00803         if (usIstd != ISTD_INVALID && usIstd != STI_NIL && usIstd != STI_USER) {
-00804                 for (iIndex = 0; iIndex < (int)tStdCount; iIndex++) {
-00805                         if (atStyleInfo[iIndex].usIstd == usIstd) {
-00806                                 /* Right index found; return style */
-00807                                 *pStyle = atStyleInfo[iIndex];
-00808                                 return;
-00809                         }
-00810                 }
-00811         }
-00812 
-00813         vGetDefaultStyle(pStyle);
-00814         pStyle->usIstd = usIstd;
-00815 } /* end of vFillStyleFromStylesheet */
-00816 
-00817 /*
-00818  * vFillFontFromStylesheet - fill a font struct with stylesheet info
-00819  */
-00820 void
-00821 vFillFontFromStylesheet(USHORT usIstd, font_block_type *pFont)
-00822 {
-00823         int     iIndex;
-00824 
-00825         fail(pFont == NULL);
-00826 
-00827         if (usIstd != ISTD_INVALID && usIstd != STI_NIL && usIstd != STI_USER) {
-00828                 for (iIndex = 0; iIndex < (int)tStdCount; iIndex++) {
-00829                         if (atStyleInfo[iIndex].usIstd == usIstd) {
-00830                                 /* Right index found; return font */
-00831                                 *pFont = atFontInfo[iIndex];
-00832                                 return;
-00833                         }
-00834                 }
-00835         }
-00836 
-00837         vGetDefaultFont(pFont, 0);
-00838 } /* end of vFillFontFromStylesheet */
-
-
Generated by  - -doxygen 1.6.2
- - diff -r 59758314f811 -r d4524d6a4472 Symbian3/Examples/guid-6013a680-57f9-415b-8851-c4fa63356636/summary_8c_source.html --- a/Symbian3/Examples/guid-6013a680-57f9-415b-8851-c4fa63356636/summary_8c_source.html Fri Jun 11 15:24:34 2010 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,904 +0,0 @@ - - - - -TB9.2 Example Applications: examples/PIPS/antiword/src/summary.c Source File - - - - - -

examples/PIPS/antiword/src/summary.c

00001 /*
-00002  * summary.c
-00003  * Copyright (C) 2002-2005 A.J. van Os; Released under GNU GPL
-00004  *
-00005  * Description:
-00006  * Read the summary information of a Word document
-00007  */
-00008 
-00009 #include <time.h>
-00010 #include <string.h>
-00011 #include "antiword.h"
-00012 
-00013 #define P_HEADER_SZ             28
-00014 #define P_SECTIONLIST_SZ        20
-00015 #define P_LENGTH_SZ              4
-00016 #define P_SECTION_MAX_SZ        (2 * P_SECTIONLIST_SZ + P_LENGTH_SZ)
-00017 #define P_SECTION_SZ(x)         ((x) * P_SECTIONLIST_SZ + P_LENGTH_SZ)
-00018 
-00019 #define PID_TITLE                2
-00020 #define PID_SUBJECT              3
-00021 #define PID_AUTHOR               4
-00022 #define PID_CREATE_DTM          12
-00023 #define PID_LASTSAVE_DTM        13
-00024 #define PID_APPNAME             18
-00025 
-00026 #define PIDD_MANAGER            14
-00027 #define PIDD_COMPANY            15
-00028 
-00029 #define VT_LPSTR                30
-00030 #define VT_FILETIME             64
-00031 
-00032 #define TIME_OFFSET_HI          0x019db1de
-00033 #define TIME_OFFSET_LO          0xd53e8000
-00034 
-00035 static char     *szTitle = NULL;
-00036 static char     *szSubject = NULL;
-00037 static char     *szAuthor = NULL;
-00038 static time_t   tCreateDtm = (time_t)-1;
-00039 static time_t   tLastSaveDtm= (time_t)-1;
-00040 static char     *szAppName = NULL;
-00041 static char     *szManager = NULL;
-00042 static char     *szCompany = NULL;
-00043 static USHORT   usLid = (USHORT)-1;
-00044 
-00045 
-00046 /*
-00047  * vDestroySummaryInfo - destroy the summary information
-00048  */
-00049 void
-00050 vDestroySummaryInfo(void)
-00051 {
-00052         TRACE_MSG("vDestroySummaryInfo");
-00053 
-00054         szTitle = xfree(szTitle);
-00055         szSubject = xfree(szSubject);
-00056         szAuthor = xfree(szAuthor);
-00057         tCreateDtm = (time_t)-1;
-00058         tLastSaveDtm = (time_t)-1;
-00059         szAppName = xfree(szAppName);
-00060         szManager = xfree(szManager);
-00061         szCompany = xfree(szCompany);
-00062         usLid = (USHORT)-1;
-00063 } /* end of vDestroySummaryInfo */
-00064 
-00065 /*
-00066  * tConvertDosDate - convert DOS date format
-00067  *
-00068  * returns Unix time_t or -1
-00069  */
-00070 static time_t
-00071 tConvertDosDate(const char *szDosDate)
-00072 {
-00073         struct tm       tTime;
-00074         const char      *pcTmp;
-00075         time_t          tResult;
-00076 
-00077         memset(&tTime, 0, sizeof(tTime));
-00078         pcTmp = szDosDate;
-00079         /* Get the month */
-00080         if (!isdigit(*pcTmp)) {
-00081                 return (time_t)-1;
-00082         }
-00083         tTime.tm_mon = (int)(*pcTmp - '0');
-00084         pcTmp++;
-00085         if (isdigit(*pcTmp)) {
-00086                 tTime.tm_mon *= 10;
-00087                 tTime.tm_mon += (int)(*pcTmp - '0');
-00088                 pcTmp++;
-00089         }
-00090         /* Get the first separater */
-00091         if (isalnum(*pcTmp)) {
-00092                 return (time_t)-1;
-00093         }
-00094         pcTmp++;
-00095         /* Get the day */
-00096         if (!isdigit(*pcTmp)) {
-00097                 return (time_t)-1;
-00098         }
-00099         tTime.tm_mday = (int)(*pcTmp - '0');
-00100         pcTmp++;
-00101         if (isdigit(*pcTmp)) {
-00102                 tTime.tm_mday *= 10;
-00103                 tTime.tm_mday += (int)(*pcTmp - '0');
-00104                 pcTmp++;
-00105         }
-00106         /* Get the second separater */
-00107         if (isalnum(*pcTmp)) {
-00108                 return (time_t)-1;
-00109         }
-00110         pcTmp++;
-00111         /* Get the year */
-00112         if (!isdigit(*pcTmp)) {
-00113                 return (time_t)-1;
-00114         }
-00115         tTime.tm_year = (int)(*pcTmp - '0');
-00116         pcTmp++;
-00117         if (isdigit(*pcTmp)) {
-00118                 tTime.tm_year *= 10;
-00119                 tTime.tm_year += (int)(*pcTmp - '0');
-00120                 pcTmp++;
-00121         }
-00122         /* Check the values */
-00123         if (tTime.tm_mon == 0 || tTime.tm_mday == 0 || tTime.tm_mday > 31) {
-00124                 return (time_t)-1;
-00125         }
-00126         /* Correct the values */
-00127         tTime.tm_mon--;         /* From 01-12 to 00-11 */
-00128         if (tTime.tm_year < 80) {
-00129                 tTime.tm_year += 100;   /* 00 means 2000 is 100 */
-00130         }
-00131         tTime.tm_isdst = -1;
-00132         tResult = mktime(&tTime);
-00133         NO_DBG_MSG(ctime(&tResult));
-00134         return tResult;
-00135 } /* end of tConvertDosDate */
-00136 
-00137 /*
-00138  * szLpstr - get a zero terminate string property
-00139  */
-00140 static char *
-00141 szLpstr(ULONG ulOffset, const UCHAR *aucBuffer)
-00142 {
-00143         char    *szStart, *szResult, *szTmp;
-00144         size_t  tSize;
-00145 
-00146         tSize = (size_t)ulGetLong(ulOffset + 4, aucBuffer);
-00147         NO_DBG_DEC(tSize);
-00148         if (tSize == 0) {
-00149                 return NULL;
-00150         }
-00151         /* Remove white space from the start of the string */
-00152         szStart = (char *)aucBuffer + ulOffset + 8;
-00153         NO_DBG_MSG(szStart);
-00154         fail(strlen(szStart) >= tSize);
-00155         while (isspace(*szStart)) {
-00156                 szStart++;
-00157         }
-00158         if (szStart[0] == '\0') {
-00159                 return NULL;
-00160         }
-00161         szResult = xstrdup(szStart);
-00162         /* Remove white space from the end of the string */
-00163         szTmp = szResult + strlen(szResult) - 1;
-00164         while (isspace(*szTmp)) {
-00165                 *szTmp = '\0';
-00166                 szTmp--;
-00167         }
-00168         NO_DBG_MSG(szResult);
-00169         return szResult;
-00170 } /* end of szLpstr */
-00171 
-00172 /*
-00173  * tFiletime - get a filetime property
-00174  */
-00175 static time_t
-00176 tFiletime(ULONG ulOffset, const UCHAR *aucBuffer)
-00177 {
-00178         double  dHi, dLo, dTmp;
-00179         ULONG   ulHi, ulLo;
-00180         time_t  tResult;
-00181 
-00182         ulLo = ulGetLong(ulOffset + 4, aucBuffer);
-00183         ulHi = ulGetLong(ulOffset + 8, aucBuffer);
-00184         NO_DBG_HEX(ulHi);
-00185         NO_DBG_HEX(ulLo);
-00186 
-00187         /* Move the starting point from 01 Jan 1601 to 01 Jan 1970 */
-00188         dHi = (double)ulHi - (double)TIME_OFFSET_HI;
-00189         dLo = (double)ulLo - (double)TIME_OFFSET_LO;
-00190         NO_DBG_FLT(dHi);
-00191         NO_DBG_FLT(dLo);
-00192 
-00193         /* Combine the values and divide by 10^7 to get seconds */
-00194         dTmp  = dLo / 10000000.0;       /* 10^7 */
-00195         dTmp += dHi * 429.4967926;      /* 2^32 / 10^7 */
-00196         NO_DBG_FLT(dTmp);
-00197 
-00198         /* Make a time_t */
-00199         if (dTmp - 0.5 < TIME_T_MIN || dTmp + 0.5 > TIME_T_MAX) {
-00200                 return (time_t)-1;
-00201         }
-00202         tResult = dTmp < 0.0 ? (time_t)(dTmp - 0.5) : (time_t)(dTmp + 0.5);
-00203         NO_DBG_MSG(ctime(&tResult));
-00204         return tResult;
-00205 } /* end of tFiletime */
-00206 
-00207 /*
-00208  * vAnalyseSummaryInfo - analyse the summary information
-00209  */
-00210 static void
-00211 vAnalyseSummaryInfo(const UCHAR *aucBuffer)
-00212 {
-00213         ULONG   ulOffset;
-00214         size_t  tIndex, tCount, tPropID, tPropType;
-00215 
-00216         tCount = (size_t)ulGetLong(4, aucBuffer);
-00217         DBG_DEC(tCount);
-00218         for (tIndex = 0; tIndex < tCount; tIndex++) {
-00219                 tPropID = (size_t)ulGetLong(8 + tIndex * 8, aucBuffer);
-00220                 ulOffset = ulGetLong(12 + tIndex * 8, aucBuffer);
-00221                 NO_DBG_DEC(tPropID);
-00222                 NO_DBG_HEX(ulOffset);
-00223                 tPropType = (size_t)ulGetLong(ulOffset, aucBuffer);
-00224                 NO_DBG_DEC(tPropType);
-00225                 switch (tPropID) {
-00226                 case PID_TITLE:
-00227                         if (tPropType == VT_LPSTR && szTitle == NULL) {
-00228                                 szTitle = szLpstr(ulOffset, aucBuffer);
-00229                         }
-00230                         break;
-00231                 case PID_SUBJECT:
-00232                         if (tPropType == VT_LPSTR && szSubject == NULL) {
-00233                                 szSubject = szLpstr(ulOffset, aucBuffer);
-00234                         }
-00235                         break;
-00236                 case PID_AUTHOR:
-00237                         if (tPropType == VT_LPSTR && szAuthor == NULL) {
-00238                                 szAuthor = szLpstr(ulOffset, aucBuffer);
-00239                         }
-00240                         break;
-00241                 case PID_CREATE_DTM:
-00242                         if (tPropType == VT_FILETIME &&
-00243                             tCreateDtm == (time_t)-1) {
-00244                                 tCreateDtm = tFiletime(ulOffset, aucBuffer);
-00245                         }
-00246                         break;
-00247                 case PID_LASTSAVE_DTM:
-00248                         if (tPropType == VT_FILETIME &&
-00249                             tLastSaveDtm == (time_t)-1) {
-00250                                 tLastSaveDtm = tFiletime(ulOffset, aucBuffer);
-00251                         }
-00252                         break;
-00253                 case PID_APPNAME:
-00254                         if (tPropType == VT_LPSTR && szAppName == NULL) {
-00255                                 szAppName = szLpstr(ulOffset, aucBuffer);
-00256                         }
-00257                         break;
-00258                 default:
-00259                         break;
-00260                 }
-00261         }
-00262 } /* end of vAnalyseSummaryInfo */
-00263 
-00264 /*
-00265  * vAnalyseDocumentSummaryInfo - analyse the document summary information
-00266  */
-00267 static void
-00268 vAnalyseDocumentSummaryInfo(const UCHAR *aucBuffer)
-00269 {
-00270         ULONG   ulOffset;
-00271         size_t  tIndex, tCount, tPropID, tPropType;
-00272 
-00273         tCount = (size_t)ulGetLong(4, aucBuffer);
-00274         DBG_DEC(tCount);
-00275         for (tIndex = 0; tIndex < tCount; tIndex++) {
-00276                 tPropID = (size_t)ulGetLong(8 + tIndex * 8, aucBuffer);
-00277                 ulOffset = ulGetLong(12 + tIndex * 8, aucBuffer);
-00278                 NO_DBG_DEC(tPropID);
-00279                 NO_DBG_HEX(ulOffset);
-00280                 tPropType = (size_t)ulGetLong(ulOffset, aucBuffer);
-00281                 NO_DBG_DEC(tPropType);
-00282                 switch (tPropID) {
-00283                 case PIDD_MANAGER:
-00284                         if (tPropType == VT_LPSTR && szManager == NULL) {
-00285                                 szManager = szLpstr(ulOffset, aucBuffer);
-00286                         }
-00287                         break;
-00288                 case PIDD_COMPANY:
-00289                         if (tPropType == VT_LPSTR && szCompany == NULL) {
-00290                                 szCompany = szLpstr(ulOffset, aucBuffer);
-00291                         }
-00292                         break;
-00293                 default:
-00294                         break;
-00295                 }
-00296         }
-00297 } /* end of vAnalyseDocumentSummaryInfo */
-00298 
-00299 /*
-00300  * pucAnalyseSummaryInfoHeader-
-00301  */
-00302 static UCHAR *
-00303 pucAnalyseSummaryInfoHeader(FILE *pFile,
-00304         ULONG ulStartBlock, ULONG ulSize,
-00305         const ULONG *aulBBD, size_t tBBDLen,
-00306         const ULONG *aulSBD, size_t tSBDLen)
-00307 {
-00308         const ULONG     *aulBlockDepot;
-00309         UCHAR   *aucBuffer;
-00310         size_t  tBlockDepotLen, tBlockSize, tSectionCount, tLength;
-00311         ULONG   ulTmp, ulOffset;
-00312         USHORT  usLittleEndian, usEmpty, usOS, usVersion;
-00313         UCHAR   aucHdr[P_HEADER_SZ], aucSecLst[P_SECTION_MAX_SZ];
-00314 
-00315         if (ulSize < MIN_SIZE_FOR_BBD_USE) {
-00316                 /* Use the Small Block Depot */
-00317                 aulBlockDepot = aulSBD;
-00318                 tBlockDepotLen = tSBDLen;
-00319                 tBlockSize = SMALL_BLOCK_SIZE;
-00320         } else {
-00321                 /* Use the Big Block Depot */
-00322                 aulBlockDepot = aulBBD;
-00323                 tBlockDepotLen = tBBDLen;
-00324                 tBlockSize = BIG_BLOCK_SIZE;
-00325         }
-00326 
-00327         if (tBlockDepotLen == 0) {
-00328                 DBG_MSG("The Block Depot length is zero");
-00329                 return NULL;
-00330         }
-00331 
-00332         /* Read the Summery Information header */
-00333         if (!bReadBuffer(pFile, ulStartBlock,
-00334                         aulBlockDepot, tBlockDepotLen, tBlockSize,
-00335                         aucHdr, 0, P_HEADER_SZ)) {
-00336                 return NULL;
-00337         }
-00338         NO_DBG_PRINT_BLOCK(aucHdr, P_HEADER_SZ);
-00339 
-00340         /* Analyse the Summery Information header */
-00341         usLittleEndian =  usGetWord(0, aucHdr);
-00342         if (usLittleEndian != 0xfffe) {
-00343                 DBG_HEX(usLittleEndian);
-00344                 DBG_MSG_C(usLittleEndian == 0xfeff, "Big endian");
-00345                 return NULL;
-00346         }
-00347         usEmpty =  usGetWord(2, aucHdr);
-00348         if (usEmpty != 0x0000) {
-00349                 DBG_DEC(usEmpty);
-00350                 return NULL;
-00351         }
-00352         ulTmp = ulGetLong(4, aucHdr);
-00353         DBG_HEX(ulTmp);
-00354         usOS = (USHORT)(ulTmp >> 16);
-00355         usVersion = (USHORT)(ulTmp & 0xffff);
-00356         switch (usOS) {
-00357         case 0:
-00358                 DBG_MSG("Win16");
-00359                 DBG_HEX(usVersion);
-00360                 break;
-00361         case 1:
-00362                 DBG_MSG("MacOS");
-00363                 DBG_HEX(usVersion);
-00364                 break;
-00365         case 2:
-00366                 DBG_MSG("Win32");
-00367                 DBG_HEX(usVersion);
-00368                 break;
-00369         default:
-00370                 DBG_DEC(usOS);
-00371                 DBG_HEX(usVersion);
-00372                 break;
-00373         }
-00374         tSectionCount = (size_t)ulGetLong(24, aucHdr);
-00375         DBG_DEC_C(tSectionCount != 1 && tSectionCount != 2, tSectionCount);
-00376         if (tSectionCount != 1 && tSectionCount != 2) {
-00377                 return NULL;
-00378         }
-00379 
-00380         /* Read the Summery Information Section Lists */
-00381         if (!bReadBuffer(pFile, ulStartBlock,
-00382                         aulBlockDepot, tBlockDepotLen, tBlockSize,
-00383                         aucSecLst, P_HEADER_SZ, P_SECTION_SZ(tSectionCount))) {
-00384                 return NULL;
-00385         }
-00386         NO_DBG_PRINT_BLOCK(aucSecLst, P_SECTION_SZ(tSectionCount));
-00387 
-00388         ulTmp = ulGetLong(0, aucSecLst);
-00389         DBG_HEX(ulTmp);
-00390         ulTmp = ulGetLong(4, aucSecLst);
-00391         DBG_HEX(ulTmp);
-00392         ulTmp = ulGetLong(8, aucSecLst);
-00393         DBG_HEX(ulTmp);
-00394         ulTmp = ulGetLong(12, aucSecLst);
-00395         DBG_HEX(ulTmp);
-00396         ulOffset = ulGetLong(16, aucSecLst);
-00397         DBG_DEC_C(ulOffset != P_HEADER_SZ + P_SECTIONLIST_SZ &&
-00398                 ulOffset != P_HEADER_SZ + 2 * P_SECTIONLIST_SZ,
-00399                 ulOffset);
-00400         fail(ulOffset != P_HEADER_SZ + P_SECTIONLIST_SZ &&
-00401                 ulOffset != P_HEADER_SZ + 2 * P_SECTIONLIST_SZ);
-00402         tLength =
-00403                 (size_t)ulGetLong(tSectionCount * P_SECTIONLIST_SZ, aucSecLst);
-00404         NO_DBG_HEX(tLength);
-00405         fail(ulOffset + tLength > ulSize);
-00406 
-00407         /* Read the Summery Information */
-00408         aucBuffer = xmalloc(tLength);
-00409         if (!bReadBuffer(pFile, ulStartBlock,
-00410                         aulBlockDepot, tBlockDepotLen, tBlockSize,
-00411                         aucBuffer, ulOffset, tLength)) {
-00412                 aucBuffer = xfree(aucBuffer);
-00413                 return NULL;
-00414         }
-00415         NO_DBG_PRINT_BLOCK(aucBuffer, tLength);
-00416         return aucBuffer;
-00417 } /* end of pucAnalyseSummaryInfoHeader */
-00418 
-00419 /*
-00420  * vSet0SummaryInfo - set summary information from a Word for DOS file
-00421  */
-00422 void
-00423 vSet0SummaryInfo(FILE *pFile, const UCHAR *aucHeader)
-00424 {
-00425         UCHAR   *aucBuffer;
-00426         ULONG   ulBeginSumdInfo, ulBeginNextBlock;
-00427         size_t  tLen;
-00428         USHORT  usCodepage, usOffset;
-00429 
-00430         TRACE_MSG("vSet0SummaryInfo");
-00431 
-00432         fail(pFile == NULL || aucHeader == NULL);
-00433 
-00434         /* First check the header */
-00435         usCodepage = usGetWord(0x7e, aucHeader);
-00436         DBG_DEC(usCodepage);
-00437         switch (usCodepage) {
-00438         case 850: usLid = 0x0809; break; /* Latin1 -> British English */
-00439         case 862: usLid = 0x040d; break; /* Hebrew */
-00440         case 866: usLid = 0x0419; break; /* Russian */
-00441         case 0:
-00442         case 437:
-00443         default: usLid = 0x0409; break; /* ASCII -> American English */
-00444         }
-00445 
-00446         /* Second check the summary information block */
-00447         ulBeginSumdInfo = 128 * (ULONG)usGetWord(0x1c, aucHeader);
-00448         DBG_HEX(ulBeginSumdInfo);
-00449         ulBeginNextBlock = 128 * (ULONG)usGetWord(0x6a, aucHeader);
-00450         DBG_HEX(ulBeginNextBlock);
-00451 
-00452         if (ulBeginSumdInfo >= ulBeginNextBlock || ulBeginNextBlock == 0) {
-00453                 /* There is no summary information block */
-00454                 return;
-00455         }
-00456         tLen = (size_t)(ulBeginNextBlock - ulBeginSumdInfo);
-00457         aucBuffer = xmalloc(tLen);
-00458         /* Read the summary information block */
-00459         if (!bReadBytes(aucBuffer, tLen, ulBeginSumdInfo, pFile)) {
-00460                 return;
-00461         }
-00462         usOffset = usGetWord(0, aucBuffer);
-00463         if (aucBuffer[usOffset] != 0) {
-00464                 NO_DBG_MSG(aucBuffer + usOffset);
-00465                 szTitle = xstrdup((char *)aucBuffer + usOffset);
-00466         }
-00467         usOffset = usGetWord(2, aucBuffer);
-00468         if (aucBuffer[usOffset] != 0) {
-00469                 NO_DBG_MSG(aucBuffer + usOffset);
-00470                 szAuthor = xstrdup((char *)aucBuffer + usOffset);
-00471         }
-00472         usOffset = usGetWord(12, aucBuffer);
-00473         if (aucBuffer[usOffset] != 0) {
-00474                 NO_DBG_STRN(aucBuffer + usOffset, 8);
-00475                 tLastSaveDtm = tConvertDosDate((char *)aucBuffer + usOffset);
-00476         }
-00477         usOffset = usGetWord(14, aucBuffer);
-00478         if (aucBuffer[usOffset] != 0) {
-00479                 NO_DBG_STRN(aucBuffer + usOffset, 8);
-00480                 tCreateDtm = tConvertDosDate((char *)aucBuffer + usOffset);
-00481         }
-00482         aucBuffer = xfree(aucBuffer);
-00483 } /* end of vSet0SummaryInfo */
-00484 
-00485 /*
-00486  * vSet2SummaryInfo - set summary information from a WinWord 1/2 file
-00487  */
-00488 void
-00489 vSet2SummaryInfo(FILE *pFile, int iWordVersion, const UCHAR *aucHeader)
-00490 {
-00491         UCHAR   *aucBuffer;
-00492         ULONG   ulBeginSumdInfo, ulBeginDocpInfo, ulTmp;
-00493         size_t  tSumdInfoLen, tDocpInfoLen, tLen, tCounter, tStart;
-00494 
-00495         TRACE_MSG("vSet2SummaryInfo");
-00496 
-00497         fail(pFile == NULL || aucHeader == NULL);
-00498         fail(iWordVersion != 1 && iWordVersion != 2);
-00499 
-00500         /* First check the header */
-00501         usLid = usGetWord(0x06, aucHeader); /* Language IDentification */
-00502         DBG_HEX(usLid);
-00503         if (usLid < 999 && iWordVersion == 1) {
-00504                 switch (usLid) {
-00505                 case   1: usLid = 0x0409; break;        /* American English */
-00506                 case   2: usLid = 0x0c0c; break;        /* Canadian French */
-00507                 case  31: usLid = 0x0413; break;        /* Dutch */
-00508                 case  33: usLid = 0x040c; break;        /* French */
-00509                 case  34: usLid = 0x040a; break;        /* Spanish */
-00510                 case  36: usLid = 0x040e; break;        /* Hungarian */
-00511                 case  39: usLid = 0x0410; break;        /* Italian */
-00512                 case  44: usLid = 0x0809; break;        /* British English */
-00513                 case  45: usLid = 0x0406; break;        /* Danish */
-00514                 case  46: usLid = 0x041f; break;        /* Swedish */
-00515                 case  47: usLid = 0x0414; break;        /* Norwegian */
-00516                 case  48: usLid = 0x0415; break;        /* Polish */
-00517                 case  49: usLid = 0x0407; break;        /* German */
-00518                 case 351: usLid = 0x0816; break;        /* Portuguese */
-00519                 case 358: usLid = 0x040b; break;        /* Finnish */
-00520                 default:
-00521                         DBG_DEC(usLid);
-00522                         DBG_FIXME();
-00523                         usLid = 0x0409;         /* American English */
-00524                         break;
-00525                 }
-00526         }
-00527 
-00528         if (iWordVersion != 2) {
-00529                 /* Unknown where to find the associated strings */
-00530                 return;
-00531         }
-00532 
-00533         /* Second check the associated strings */
-00534         ulBeginSumdInfo = ulGetLong(0x118, aucHeader); /* fcSttbfAssoc */
-00535         DBG_HEX(ulBeginSumdInfo);
-00536         tSumdInfoLen = (size_t)usGetWord(0x11c, aucHeader); /* cbSttbfAssoc */
-00537         DBG_DEC(tSumdInfoLen);
-00538 
-00539         if (tSumdInfoLen == 0) {
-00540                 /* There is no summary information */
-00541                 return;
-00542         }
-00543 
-00544         aucBuffer = xmalloc(tSumdInfoLen);
-00545         if (!bReadBytes(aucBuffer, tSumdInfoLen, ulBeginSumdInfo, pFile)) {
-00546                 aucBuffer = xfree(aucBuffer);
-00547                 return;
-00548         }
-00549         NO_DBG_PRINT_BLOCK(aucBuffer, tSumdInfoLen);
-00550         tLen = (size_t)ucGetByte(0, aucBuffer);
-00551         DBG_DEC_C(tSumdInfoLen != tLen, tSumdInfoLen);
-00552         DBG_DEC_C(tSumdInfoLen != tLen, tLen);
-00553         tStart = 1;
-00554         for (tCounter = 0; tCounter < 17; tCounter++) {
-00555                 if (tStart >= tSumdInfoLen) {
-00556                         break;
-00557                 }
-00558                 tLen = (size_t)ucGetByte(tStart, aucBuffer);
-00559                 if (tLen != 0) {
-00560                         NO_DBG_DEC(tCounter);
-00561                         NO_DBG_STRN(aucBuffer + tStart + 1, tLen);
-00562                         switch (tCounter) {
-00563                         case 3:
-00564                                 szTitle = xmalloc(tLen + 1);
-00565                                 strncpy(szTitle,
-00566                                         (char *)aucBuffer + tStart + 1, tLen);
-00567                                 szTitle[tLen] = '\0';
-00568                                 break;
-00569                         case 4:
-00570                                 szSubject = xmalloc(tLen + 1);
-00571                                 strncpy(szSubject,
-00572                                         (char *)aucBuffer + tStart + 1, tLen);
-00573                                 szSubject[tLen] = '\0';
-00574                                 break;
-00575                         case 7:
-00576                                 szAuthor = xmalloc(tLen + 1);
-00577                                 strncpy(szAuthor,
-00578                                         (char *)aucBuffer + tStart + 1, tLen);
-00579                                 szAuthor[tLen] = '\0';
-00580                                 break;
-00581                         default:
-00582                                 break;
-00583                         }
-00584                 }
-00585                 tStart += tLen + 1;
-00586         }
-00587         aucBuffer = xfree(aucBuffer);
-00588 
-00589         /* Third check the document properties */
-00590         ulBeginDocpInfo = ulGetLong(0x112, aucHeader); /* fcDop */
-00591         DBG_HEX(ulBeginDocpInfo);
-00592         tDocpInfoLen = (size_t)usGetWord(0x116, aucHeader); /* cbDop */
-00593         DBG_DEC(tDocpInfoLen);
-00594         if (tDocpInfoLen < 12) {
-00595                 return;
-00596         }
-00597 
-00598         aucBuffer = xmalloc(tDocpInfoLen);
-00599         if (!bReadBytes(aucBuffer, tDocpInfoLen, ulBeginDocpInfo, pFile)) {
-00600                 aucBuffer = xfree(aucBuffer);
-00601                 return;
-00602         }
-00603         ulTmp = ulGetLong(0x14, aucBuffer); /* dttmCreated */
-00604         tCreateDtm = tConvertDTTM(ulTmp);
-00605         ulTmp = ulGetLong(0x18, aucBuffer); /* dttmRevised */
-00606         tLastSaveDtm = tConvertDTTM(ulTmp);
-00607         aucBuffer = xfree(aucBuffer);
-00608 } /* end of vSet2SummaryInfo */
-00609 
-00610 /*
-00611  * vSetSummaryInfoOLE - set summary information from a Word 6+ file
-00612  */
-00613 static void
-00614 vSetSummaryInfoOLE(FILE *pFile, const pps_info_type *pPPS,
-00615         const ULONG *aulBBD, size_t tBBDLen,
-00616         const ULONG *aulSBD, size_t tSBDLen)
-00617 {
-00618         UCHAR   *pucBuffer;
-00619 
-00620         fail(pFile == NULL || pPPS == NULL);
-00621         fail(aulBBD == NULL || aulSBD == NULL);
-00622 
-00623         /* Summary Information */
-00624         pucBuffer = pucAnalyseSummaryInfoHeader(pFile,
-00625                 pPPS->tSummaryInfo.ulSB, pPPS->tSummaryInfo.ulSize,
-00626                 aulBBD, tBBDLen, aulSBD, tSBDLen);
-00627         if (pucBuffer != NULL) {
-00628                 vAnalyseSummaryInfo(pucBuffer);
-00629                 pucBuffer = xfree(pucBuffer);
-00630         }
-00631 
-00632         /* Document Summary Information */
-00633         pucBuffer = pucAnalyseSummaryInfoHeader(pFile,
-00634                 pPPS->tDocSummaryInfo.ulSB, pPPS->tDocSummaryInfo.ulSize,
-00635                 aulBBD, tBBDLen, aulSBD, tSBDLen);
-00636         if (pucBuffer != NULL) {
-00637                 vAnalyseDocumentSummaryInfo(pucBuffer);
-00638                 pucBuffer = xfree(pucBuffer);
-00639         }
-00640 } /* end of vSetSummaryInfoOLE */
-00641 
-00642 /*
-00643  * vSet6SummaryInfo - set summary information from a Word 6/7 file
-00644  */
-00645 void
-00646 vSet6SummaryInfo(FILE *pFile, const pps_info_type *pPPS,
-00647         const ULONG *aulBBD, size_t tBBDLen,
-00648         const ULONG *aulSBD, size_t tSBDLen,
-00649         const UCHAR *aucHeader)
-00650 {
-00651         TRACE_MSG("vSet6SummaryInfo");
-00652 
-00653         /* Header Information */
-00654         usLid = usGetWord(0x06, aucHeader); /* Language IDentification */
-00655         DBG_HEX(usLid);
-00656 
-00657         /* Summery Information */
-00658         vSetSummaryInfoOLE(pFile, pPPS, aulBBD, tBBDLen, aulSBD, tSBDLen);
-00659 } /* end of vSet6SummaryInfo */
-00660 
-00661 /*
-00662  * vSet8SummaryInfo - set summary information a Word 8/9/10 file
-00663  */
-00664 void
-00665 vSet8SummaryInfo(FILE *pFile, const pps_info_type *pPPS,
-00666         const ULONG *aulBBD, size_t tBBDLen,
-00667         const ULONG *aulSBD, size_t tSBDLen,
-00668         const UCHAR *aucHeader)
-00669 {
-00670         USHORT  usTmp;
-00671 
-00672         TRACE_MSG("vSet8SummaryInfo");
-00673 
-00674         /* Header Information */
-00675         usTmp = usGetWord(0x0a, aucHeader);
-00676         if (usTmp & BIT(14)) {
-00677                 /* Language IDentification Far East */
-00678                 usLid = usGetWord(0x3c, aucHeader);
-00679         } else {
-00680                 /* Language IDentification */
-00681                 usLid = usGetWord(0x06, aucHeader);
-00682         }
-00683         DBG_HEX(usLid);
-00684 
-00685         /* Summery Information */
-00686         vSetSummaryInfoOLE(pFile, pPPS, aulBBD, tBBDLen, aulSBD, tSBDLen);
-00687 } /* end of vSet8SummaryInfo */
-00688 
-00689 /*
-00690  * szGetTitle - get the title field
-00691  */
-00692 const char *
-00693 szGetTitle(void)
-00694 {
-00695         return szTitle;
-00696 } /* end of szGetTitle */
-00697 
-00698 /*
-00699  * szGetSubject - get the subject field
-00700  */
-00701 const char *
-00702 szGetSubject(void)
-00703 {
-00704         return szSubject;
-00705 } /* end of szGetSubject */
-00706 
-00707 /*
-00708  * szGetAuthor - get the author field
-00709  */
-00710 const char *
-00711 szGetAuthor(void)
-00712 {
-00713         return szAuthor;
-00714 } /* end of szGetAuthor */
-00715 
-00716 /*
-00717  * szGetLastSaveDtm - get the last save date field
-00718  */
-00719 const char *
-00720 szGetLastSaveDtm(void)
-00721 {
-00722         static char     szTime[12];
-00723         struct tm       *pTime;
-00724 
-00725         if (tLastSaveDtm == (time_t)-1) {
-00726                 return NULL;
-00727         }
-00728         pTime = localtime(&tLastSaveDtm);
-00729         if (pTime == NULL) {
-00730                 return NULL;
-00731         }
-00732         sprintf(szTime, "%04d-%02d-%02d",
-00733                 pTime->tm_year + 1900, pTime->tm_mon + 1, pTime->tm_mday);
-00734         return szTime;
-00735 } /* end of szGetLastSaveDtm */
-00736 
-00737 /*
-00738  * szGetModDate - get the last save date field
-00739  */
-00740 const char *
-00741 szGetModDate(void)
-00742 {
-00743         static char     szTime[20];
-00744         struct tm       *pTime;
-00745 
-00746         if (tLastSaveDtm == (time_t)-1) {
-00747                 return NULL;
-00748         }
-00749         pTime = localtime(&tLastSaveDtm);
-00750         if (pTime == NULL) {
-00751                 return NULL;
-00752         }
-00753         sprintf(szTime, "D:%04d%02d%02d%02d%02d",
-00754                 pTime->tm_year + 1900, pTime->tm_mon + 1, pTime->tm_mday,
-00755                 pTime->tm_hour, pTime->tm_min);
-00756         return szTime;
-00757 } /* end of szGetModDate */
-00758 
-00759 /*
-00760  * szGetCreationDate - get the last save date field
-00761  */
-00762 const char *
-00763 szGetCreationDate(void)
-00764 {
-00765         static char     szTime[20];
-00766         struct tm       *pTime;
-00767 
-00768         if (tCreateDtm == (time_t)-1) {
-00769                 return NULL;
-00770         }
-00771         pTime = localtime(&tCreateDtm);
-00772         if (pTime == NULL) {
-00773                 return NULL;
-00774         }
-00775         sprintf(szTime, "D:%04d%02d%02d%02d%02d",
-00776                 pTime->tm_year + 1900, pTime->tm_mon + 1, pTime->tm_mday,
-00777                 pTime->tm_hour, pTime->tm_min);
-00778         return szTime;
-00779 } /* end of szGetCreationDate */
-00780 
-00781 /*
-00782  * szGetCompany - get the company field
-00783  */
-00784 const char *
-00785 szGetCompany(void)
-00786 {
-00787         return szCompany;
-00788 } /* end of szGetCompany */
-00789 
-00790 /*
-00791  * szGetLanguage - get de language field
-00792  */
-00793 const char *
-00794 szGetLanguage(void)
-00795 {
-00796         if (usLid == (USHORT)-1) {
-00797                 /* No Language IDentification */
-00798                 return NULL;
-00799         }
-00800         if (usLid < 999) {
-00801                 /* This is a Locale, not a Language IDentification */
-00802                 DBG_DEC(usLid);
-00803                 return NULL;
-00804         }
-00805 
-00806         /* Exceptions to the general rule */
-00807         switch (usLid) {
-00808         case 0x0404: return "zh_TW"; /* Traditional Chinese */
-00809         case 0x0804: return "zh_CN"; /* Simplified Chinese */
-00810         case 0x0c04: return "zh_HK"; /* Hong Kong Chinese */
-00811         case 0x1004: return "zh_SG"; /* Singapore Chinese */
-00812         case 0x0807: return "de_CH"; /* Swiss German */
-00813         case 0x0409: return "en_US"; /* American English */
-00814         case 0x0809: return "en_GB"; /* British English */
-00815         case 0x0c09: return "en_AU"; /* Australian English */
-00816         case 0x080a: return "es_MX"; /* Mexican Spanish */
-00817         case 0x080c: return "fr_BE"; /* Belgian French */
-00818         case 0x0c0c: return "fr_CA"; /* Canadian French */
-00819         case 0x100c: return "fr_CH"; /* Swiss French */
-00820         case 0x0810: return "it_CH"; /* Swiss Italian */
-00821         case 0x0813: return "nl_BE"; /* Belgian Dutch */
-00822         case 0x0416: return "pt_BR"; /* Brazilian Portuguese */
-00823         case 0x081a:
-00824         case 0x0c1a: return "sr";    /* Serbian */
-00825         case 0x081d: return "sv_FI"; /* Finland Swedish */
-00826         default:
-00827                 break;
-00828         }
-00829 
-00830         /* The general rule */
-00831         switch (usLid & 0x00ff) {
-00832         case 0x01: return "ar"; /* Arabic */
-00833         case 0x02: return "bg"; /* Bulgarian */
-00834         case 0x03: return "ca"; /* Catalan */
-00835         case 0x04: return "zh"; /* Chinese */
-00836         case 0x05: return "cs"; /* Czech */
-00837         case 0x06: return "da"; /* Danish */
-00838         case 0x07: return "de"; /* German */
-00839         case 0x08: return "el"; /* Greek */
-00840         case 0x09: return "en"; /* English */
-00841         case 0x0a: return "es"; /* Spanish */
-00842         case 0x0b: return "fi"; /* Finnish */
-00843         case 0x0c: return "fr"; /* French */
-00844         case 0x0d: return "he"; /* Hebrew */
-00845         case 0x0e: return "hu"; /* Hungarian */
-00846         case 0x0f: return "is"; /* Icelandic */
-00847         case 0x10: return "it"; /* Italian */
-00848         case 0x11: return "ja"; /* Japanese */
-00849         case 0x12: return "ko"; /* Korean */
-00850         case 0x13: return "nl"; /* Dutch */
-00851         case 0x14: return "no"; /* Norwegian */
-00852         case 0x15: return "pl"; /* Polish */
-00853         case 0x16: return "pt"; /* Portuguese */
-00854         case 0x17: return "rm"; /* Rhaeto-Romance */
-00855         case 0x18: return "ro"; /* Romanian */
-00856         case 0x19: return "ru"; /* Russian */
-00857         case 0x1a: return "hr"; /* Croatian */
-00858         case 0x1b: return "sk"; /* Slovak */
-00859         case 0x1c: return "sq"; /* Albanian */
-00860         case 0x1d: return "sv"; /* Swedish */
-00861         case 0x1e: return "th"; /* Thai */
-00862         case 0x1f: return "tr"; /* Turkish */
-00863         case 0x20: return "ur"; /* Urdu */
-00864         case 0x21: return "id"; /* Indonesian */
-00865         case 0x22: return "uk"; /* Ukrainian */
-00866         case 0x23: return "be"; /* Belarusian */
-00867         case 0x24: return "sl"; /* Slovenian */
-00868         case 0x25: return "et"; /* Estonian */
-00869         case 0x26: return "lv"; /* Latvian */
-00870         case 0x27: return "lt"; /* Lithuanian */
-00871         case 0x29: return "fa"; /* Farsi */
-00872         case 0x2a: return "vi"; /* Viet Nam */
-00873         case 0x2b: return "hy"; /* Armenian */
-00874         case 0x2c: return "az"; /* Azeri */
-00875         case 0x2d: return "eu"; /* Basque */
-00876         case 0x2f: return "mk"; /* Macedonian */
-00877         case 0x36: return "af"; /* Afrikaans */
-00878         case 0x37: return "ka"; /* Georgian */
-00879         case 0x38: return "fo"; /* Faeroese */
-00880         case 0x39: return "hi"; /* Hindi */
-00881         case 0x3e: return "ms"; /* Malay */
-00882         case 0x3f: return "kk"; /* Kazakh */
-00883         default:
-00884                 DBG_HEX(usLid);
-00885                 DBG_FIXME();
-00886                 return NULL;
-00887         }
-00888 } /* end of szGetLanguage */
-
-
Generated by  - -doxygen 1.6.2
- - 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
- - diff -r 59758314f811 -r d4524d6a4472 Symbian3/Examples/guid-6013a680-57f9-415b-8851-c4fa63356636/text_8c_source.html --- a/Symbian3/Examples/guid-6013a680-57f9-415b-8851-c4fa63356636/text_8c_source.html Fri Jun 11 15:24:34 2010 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,198 +0,0 @@ - - - - -TB9.2 Example Applications: examples/PIPS/antiword/src/text.c Source File - - - - - -

examples/PIPS/antiword/src/text.c

00001 /*
-00002  * text.c
-00003  * Copyright (C) 1999-2004 A.J. van Os; Released under GNU GPL
-00004  *
-00005  * Description:
-00006  * Functions to deal with the Text format
-00007  *
-00008  */
-00009 
-00010 #include <string.h>
-00011 #include "antiword.h"
-00012 
-00013 /* The character set */
-00014 static encoding_type    eEncoding = encoding_neutral;
-00015 /* Current vertical position information */
-00016 static long             lYtopCurr = 0;
-00017 /* Local representation of the non-breaking space */
-00018 static UCHAR            ucNbsp = 0;
-00019 
-00020 
-00021 /*
-00022  * vPrologueTXT - set options and perform the Text initialization
-00023  */
-00024 void
-00025 vPrologueTXT(diagram_type *pDiag, const options_type *pOptions)
-00026 {
-00027         fail(pDiag == NULL);
-00028         fail(pOptions == NULL);
-00029 
-00030         eEncoding = pOptions->eEncoding;
-00031         pDiag->lXleft = 0;
-00032         pDiag->lYtop = 0;
-00033         lYtopCurr = 0;
-00034 } /* end of vPrologueTXT */
-00035 
-00036 /*
-00037  * vEpilogueTXT - clean up after everything is done
-00038  */
-00039 void
-00040 vEpilogueTXT(FILE *pOutFile)
-00041 {
-00042         fail(pOutFile == NULL);
-00043 
-00044         fprintf(pOutFile, "\n");
-00045 } /* end of vEpilogueTXT */
-00046 
-00047 /*
-00048  * vPrintTXT - print a Text string
-00049  */
-00050 static void
-00051 vPrintTXT(FILE *pFile, const char *szString, size_t tStringLength)
-00052 {
-00053         const UCHAR     *ucBytes;
-00054         size_t          tCount;
-00055 
-00056         fail(szString == NULL);
-00057 
-00058         if (szString == NULL || szString[0] == '\0' || tStringLength == 0) {
-00059                 return;
-00060         }
-00061 
-00062         if (eEncoding == encoding_utf_8) {
-00063                 fprintf(pFile, "%.*s", (int)tStringLength, szString);
-00064                 return;
-00065         }
-00066 
-00067         if (ucNbsp == 0) {
-00068                 ucNbsp = ucGetNbspCharacter();
-00069                 DBG_HEX_C(ucNbsp != 0xa0, ucNbsp);
-00070         }
-00071 
-00072         ucBytes = (UCHAR *)szString;
-00073         for (tCount = 0; tCount < tStringLength ; tCount++) {
-00074                 if (ucBytes[tCount] == ucNbsp) {
-00075                         (void)putc(' ', pFile);
-00076                 } else {
-00077                         (void)putc(szString[tCount], pFile);
-00078                 }
-00079         }
-00080 } /* end of vPrintTXT */
-00081 
-00082 /*
-00083  * vMoveTo - move to the given X,Y coordinates
-00084  *
-00085  * Move the current position of the given diagram to its X,Y coordinates,
-00086  * start on a new page if needed
-00087  */
-00088 static void
-00089 vMoveTo(diagram_type *pDiag)
-00090 {
-00091         int     iCount, iNbr;
-00092 
-00093         fail(pDiag == NULL);
-00094         fail(pDiag->pOutFile == NULL);
-00095 
-00096         if (pDiag->lYtop != lYtopCurr) {
-00097                 iNbr = iDrawUnits2Char(pDiag->lXleft);
-00098                 for (iCount = 0; iCount < iNbr; iCount++) {
-00099                         (void)putc(FILLER_CHAR, pDiag->pOutFile);
-00100                 }
-00101                 lYtopCurr = pDiag->lYtop;
-00102         }
-00103 } /* end of vMoveTo */
-00104 
-00105 /*
-00106  * vMove2NextLineTXT - move to the next line
-00107  */
-00108 void
-00109 vMove2NextLineTXT(diagram_type *pDiag)
-00110 {
-00111         fail(pDiag == NULL);
-00112         fail(pDiag->pOutFile == NULL);
-00113 
-00114         pDiag->lYtop++;
-00115         (void)fprintf(pDiag->pOutFile, "\n");
-00116 } /* end of vMove2NextLineTXT */
-00117 
-00118 /*
-00119  * vSubstringTXT - print a sub string
-00120  */
-00121 void
-00122 vSubstringTXT(diagram_type *pDiag,
-00123         const char *szString, size_t tStringLength, long lStringWidth)
-00124 {
-00125         fail(pDiag == NULL || szString == NULL);
-00126         fail(pDiag->pOutFile == NULL);
-00127         fail(pDiag->lXleft < 0);
-00128         fail(tStringLength != strlen(szString));
-00129 
-00130         if (szString[0] == '\0' || tStringLength == 0) {
-00131                 return;
-00132         }
-00133 
-00134         vMoveTo(pDiag);
-00135         vPrintTXT(pDiag->pOutFile, szString, tStringLength);
-00136         pDiag->lXleft += lStringWidth;
-00137 } /* end of vSubstringTXT */
-00138 
-00139 /*
-00140  * Create an start of paragraph by moving the y-top mark
-00141  */
-00142 void
-00143 vStartOfParagraphTXT(diagram_type *pDiag, long lBeforeIndentation)
-00144 {
-00145         fail(pDiag == NULL);
-00146         fail(lBeforeIndentation < 0);
-00147 
-00148         if (lBeforeIndentation >= lTwips2MilliPoints(HEADING_GAP)) {
-00149                 /* A large gap is replaced by an empty line */
-00150                 vMove2NextLineTXT(pDiag);
-00151         }
-00152 } /* end of vStartOfParagraphTXT */
-00153 
-00154 /*
-00155  * Create an end of paragraph by moving the y-top mark
-00156  */
-00157 void
-00158 vEndOfParagraphTXT(diagram_type *pDiag, long lAfterIndentation)
-00159 {
-00160         fail(pDiag == NULL);
-00161         fail(pDiag->pOutFile == NULL);
-00162         fail(lAfterIndentation < 0);
-00163 
-00164         if (pDiag->lXleft > 0) {
-00165                 /* To the start of the line */
-00166                 vMove2NextLineTXT(pDiag);
-00167         }
-00168 
-00169         if (lAfterIndentation >= lTwips2MilliPoints(HEADING_GAP)) {
-00170                 /* A large gap is replaced by an empty line */
-00171                 vMove2NextLineTXT(pDiag);
-00172         }
-00173 } /* end of vEndOfParagraphTXT */
-00174 
-00175 /*
-00176  * Create an end of page
-00177  */
-00178 void
-00179 vEndOfPageTXT(diagram_type *pDiag, long lAfterIndentation)
-00180 {
-00181         vEndOfParagraphTXT(pDiag, lAfterIndentation);
-00182 } /* end of vEndOfPageTXT */
-
-
Generated by  - -doxygen 1.6.2
- - diff -r 59758314f811 -r d4524d6a4472 Symbian3/Examples/guid-6013a680-57f9-415b-8851-c4fa63356636/unix_8c_source.html --- a/Symbian3/Examples/guid-6013a680-57f9-415b-8851-c4fa63356636/unix_8c_source.html Fri Jun 11 15:24:34 2010 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,61 +0,0 @@ - - - - -TB9.2 Example Applications: examples/PIPS/antiword/src/unix.c Source File - - - - - -

examples/PIPS/antiword/src/unix.c

00001 /*
-00002  * unix.c
-00003  * Copyright (C) 1998-2000 A.J. van Os; Released under GPL
-00004  *
-00005  * Description:
-00006  * Unix approximations of RISC-OS functions
-00007  */
-00008 
-00009 #include <stdio.h>
-00010 #include <stdlib.h>
-00011 #include <stdarg.h>
-00012 #include "antiword.h"
-00013 
-00014 
-00015 /*
-00016  * werr - write an error message and exit if needed
-00017  */
-00018 void
-00019 werr(int iFatal, const char *szFormat, ...)
-00020 {
-00021         va_list tArg;
-00022 
-00023         va_start(tArg, szFormat);
-00024         (void)vfprintf(stderr, szFormat, tArg);
-00025         va_end(tArg);
-00026         fprintf(stderr, "\n");
-00027         switch (iFatal) {
-00028         case 0:         /* The message is just a warning, so no exit */
-00029                 return;
-00030         case 1:         /* Fatal error with a standard exit */
-00031                 exit(EXIT_FAILURE);
-00032         default:        /* Fatal error with a non-standard exit */
-00033                 exit(iFatal);
-00034         }
-00035 } /* end of werr */
-00036 
-00037 void
-00038 Hourglass_On(void)
-00039 {
-00040 } /* end of Hourglass_On */
-00041 
-00042 void
-00043 Hourglass_Off(void)
-00044 {
-00045 } /* end of Hourglass_Off */
-
-
Generated by  - -doxygen 1.6.2
- - diff -r 59758314f811 -r d4524d6a4472 Symbian3/Examples/guid-6013a680-57f9-415b-8851-c4fa63356636/utf8_8c_source.html --- a/Symbian3/Examples/guid-6013a680-57f9-415b-8851-c4fa63356636/utf8_8c_source.html Fri Jun 11 15:24:34 2010 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,276 +0,0 @@ - - - - -TB9.2 Example Applications: examples/PIPS/antiword/src/utf8.c Source File - - - - - -

examples/PIPS/antiword/src/utf8.c

00001 /*
-00002  * utf8.c
-00003  * Copyright (C) 2001-2004 A.J. van Os; Released under GPL
-00004  *
-00005  *====================================================================
-00006  * This part of the software is based on:
-00007  * An implementation of wcwidth() as defined in
-00008  * "The Single UNIX Specification, Version 2, The Open Group, 1997"
-00009  * <http://www.UNIX-systems.org/online.html>
-00010  * Markus Kuhn -- 2001-01-12 -- public domain
-00011  *====================================================================
-00012  * The credit should go to him, but all the bugs are mine.
-00013  */
-00014 
-00015 #include <stdlib.h>
-00016 #include <string.h>
-00017 #include "antiword.h"
-00018 
-00019 struct interval {
-00020         USHORT  first;
-00021         USHORT  last;
-00022 };
-00023 /* Sorted list of non-overlapping intervals of non-spacing characters */
-00024 static const struct interval combining[] = {
-00025         { 0x0300, 0x034E }, { 0x0360, 0x0362 }, { 0x0483, 0x0486 },
-00026         { 0x0488, 0x0489 }, { 0x0591, 0x05A1 }, { 0x05A3, 0x05B9 },
-00027         { 0x05BB, 0x05BD }, { 0x05BF, 0x05BF }, { 0x05C1, 0x05C2 },
-00028         { 0x05C4, 0x05C4 }, { 0x064B, 0x0655 }, { 0x0670, 0x0670 },
-00029         { 0x06D6, 0x06E4 }, { 0x06E7, 0x06E8 }, { 0x06EA, 0x06ED },
-00030         { 0x070F, 0x070F }, { 0x0711, 0x0711 }, { 0x0730, 0x074A },
-00031         { 0x07A6, 0x07B0 }, { 0x0901, 0x0902 }, { 0x093C, 0x093C },
-00032         { 0x0941, 0x0948 }, { 0x094D, 0x094D }, { 0x0951, 0x0954 },
-00033         { 0x0962, 0x0963 }, { 0x0981, 0x0981 }, { 0x09BC, 0x09BC },
-00034         { 0x09C1, 0x09C4 }, { 0x09CD, 0x09CD }, { 0x09E2, 0x09E3 },
-00035         { 0x0A02, 0x0A02 }, { 0x0A3C, 0x0A3C }, { 0x0A41, 0x0A42 },
-00036         { 0x0A47, 0x0A48 }, { 0x0A4B, 0x0A4D }, { 0x0A70, 0x0A71 },
-00037         { 0x0A81, 0x0A82 }, { 0x0ABC, 0x0ABC }, { 0x0AC1, 0x0AC5 },
-00038         { 0x0AC7, 0x0AC8 }, { 0x0ACD, 0x0ACD }, { 0x0B01, 0x0B01 },
-00039         { 0x0B3C, 0x0B3C }, { 0x0B3F, 0x0B3F }, { 0x0B41, 0x0B43 },
-00040         { 0x0B4D, 0x0B4D }, { 0x0B56, 0x0B56 }, { 0x0B82, 0x0B82 },
-00041         { 0x0BC0, 0x0BC0 }, { 0x0BCD, 0x0BCD }, { 0x0C3E, 0x0C40 },
-00042         { 0x0C46, 0x0C48 }, { 0x0C4A, 0x0C4D }, { 0x0C55, 0x0C56 },
-00043         { 0x0CBF, 0x0CBF }, { 0x0CC6, 0x0CC6 }, { 0x0CCC, 0x0CCD },
-00044         { 0x0D41, 0x0D43 }, { 0x0D4D, 0x0D4D }, { 0x0DCA, 0x0DCA },
-00045         { 0x0DD2, 0x0DD4 }, { 0x0DD6, 0x0DD6 }, { 0x0E31, 0x0E31 },
-00046         { 0x0E34, 0x0E3A }, { 0x0E47, 0x0E4E }, { 0x0EB1, 0x0EB1 },
-00047         { 0x0EB4, 0x0EB9 }, { 0x0EBB, 0x0EBC }, { 0x0EC8, 0x0ECD },
-00048         { 0x0F18, 0x0F19 }, { 0x0F35, 0x0F35 }, { 0x0F37, 0x0F37 },
-00049         { 0x0F39, 0x0F39 }, { 0x0F71, 0x0F7E }, { 0x0F80, 0x0F84 },
-00050         { 0x0F86, 0x0F87 }, { 0x0F90, 0x0F97 }, { 0x0F99, 0x0FBC },
-00051         { 0x0FC6, 0x0FC6 }, { 0x102D, 0x1030 }, { 0x1032, 0x1032 },
-00052         { 0x1036, 0x1037 }, { 0x1039, 0x1039 }, { 0x1058, 0x1059 },
-00053         { 0x1160, 0x11FF }, { 0x17B7, 0x17BD }, { 0x17C6, 0x17C6 },
-00054         { 0x17C9, 0x17D3 }, { 0x180B, 0x180E }, { 0x18A9, 0x18A9 },
-00055         { 0x200B, 0x200F }, { 0x202A, 0x202E }, { 0x206A, 0x206F },
-00056         { 0x20D0, 0x20E3 }, { 0x302A, 0x302F }, { 0x3099, 0x309A },
-00057         { 0xFB1E, 0xFB1E }, { 0xFE20, 0xFE23 }, { 0xFEFF, 0xFEFF },
-00058         { 0xFFF9, 0xFFFB }
-00059 };
-00060 
-00061 /* Auxiliary function for binary search in interval table */
-00062 static BOOL
-00063 bIsZeroWidthChar(ULONG ucs)
-00064 {
-00065         int low = 0;
-00066         int high = elementsof(combining) - 1;
-00067         int mid;
-00068 
-00069         if (ucs < (ULONG)combining[low].first ||
-00070             ucs > (ULONG)combining[high].last) {
-00071                 return FALSE;
-00072         }
-00073 
-00074         while (high >= low) {
-00075                 mid = (low + high) / 2;
-00076                 if (ucs > (ULONG)combining[mid].last) {
-00077                         low = mid + 1;
-00078                 } else if (ucs < (ULONG)combining[mid].first) {
-00079                         high = mid - 1;
-00080                 } else {
-00081                         return TRUE;
-00082                 }
-00083         }
-00084         return FALSE;
-00085 } /* end of bIsZeroWidthChar */
-00086 
-00087 /* The following functions define the column width of an ISO 10646
-00088  * character as follows:
-00089  *
-00090  *    - The null character (U+0000) has a column width of 0.
-00091  *
-00092  *    - Other C0/C1 control characters and DEL will lead to a return
-00093  *      value of -1.
-00094  *
-00095  *    - Non-spacing and enclosing combining characters (general
-00096  *      category code Mn or Me in the Unicode database) have a
-00097  *      column width of 0.
-00098  *
-00099  *    - Other format characters (general category code Cf in the Unicode
-00100  *      database) and ZERO WIDTH SPACE (U+200B) have a column width of 0.
-00101  *
-00102  *    - Hangul Jamo medial vowels and final consonants (U+1160-U+11FF)
-00103  *      have a column width of 0.
-00104  *
-00105  *    - Spacing characters in the East Asian Wide (W) or East Asian
-00106  *      FullWidth (F) category as defined in Unicode Technical
-00107  *      Report #11 have a column width of 2.
-00108  *
-00109  *    - All remaining characters (including all printable
-00110  *      ISO 8859-1 and WGL4 characters, Unicode control characters,
-00111  *      etc.) have a column width of 1.
-00112  *
-00113  * This implementation assumes that all characters are encoded
-00114  * in ISO 10646.
-00115  *
-00116  * This function is not named wcwidth() to prevent name clashes
-00117  */
-00118 static int
-00119 iWcWidth(ULONG ucs)
-00120 {
-00121         /* Test for 8-bit control characters */
-00122         if (ucs == 0) {
-00123                 return 0;
-00124         }
-00125         if (ucs < 0x20 || (ucs >= 0x7f && ucs < 0xa0)) {
-00126                 NO_DBG_HEX(ucs);
-00127                 return -1;
-00128         }
-00129 
-00130         /* Binary search in table of non-spacing characters */
-00131         if (bIsZeroWidthChar(ucs)) {
-00132                 return 0;
-00133         }
-00134 
-00135         /* Ucs is not a combining or C0/C1 control character */
-00136 
-00137         return 1 +
-00138         (ucs >= 0x1100 &&
-00139          (ucs <= 0x115f ||                    /* Hangul Jamo init. consonants */
-00140           (ucs >= 0x2e80 && ucs <= 0xa4cf && (ucs & ~0x0011) != 0x300a &&
-00141            ucs != 0x303f) ||                  /* CJK ... Yi */
-00142           (ucs >= 0xac00 && ucs <= 0xd7a3) || /* Hangul Syllables */
-00143           (ucs >= 0xf900 && ucs <= 0xfaff) || /* CJK Compatibility Ideographs */
-00144           (ucs >= 0xfe30 && ucs <= 0xfe6f) || /* CJK Compatibility Forms */
-00145           (ucs >= 0xff00 && ucs <= 0xff5f) || /* Fullwidth Forms */
-00146           (ucs >= 0xffe0 && ucs <= 0xffe6) ||
-00147           (ucs >= 0x20000 && ucs <= 0x2ffff)));
-00148 } /* end of iWcWidth */
-00149 
-00150 /*
-00151  * utf8_to_ucs - convert from UTF-8 to UCS
-00152  *
-00153  * Returns the UCS character,
-00154  * Fills in the number of bytes in the UTF-8 character
-00155  */
-00156 static ULONG
-00157 utf8_to_ucs(const char *p, int iStrLen, int *piUtfLen)
-00158 {
-00159         ULONG   ulUcs;
-00160         int     iIndex, iCharLen;
-00161 
-00162         fail(p == NULL || piUtfLen == NULL);
-00163         fail(iStrLen < 1);
-00164 
-00165         ulUcs = (ULONG)(UCHAR)p[0];
-00166 
-00167         if (ulUcs < 0x80) {
-00168                 *piUtfLen = 1;
-00169                 return ulUcs;
-00170         }
-00171 
-00172         if (ulUcs < 0xe0){
-00173                 iCharLen = 2;
-00174                 ulUcs &= 0x1f;
-00175         } else if (ulUcs < 0xf0){
-00176                 iCharLen = 3;
-00177                 ulUcs &= 0x0f;
-00178         } else if (ulUcs < 0xf8){
-00179                 iCharLen = 4;
-00180                 ulUcs &= 0x07;
-00181         } else if (ulUcs < 0xfc){
-00182                 iCharLen = 5;
-00183                 ulUcs &= 0x03;
-00184         } else {
-00185                 iCharLen = 6;
-00186                 ulUcs &= 0x01;
-00187         }
-00188         for (iIndex = 1; iIndex < iCharLen; iIndex++) {
-00189                 ulUcs <<= 6;
-00190                 if (iIndex < iStrLen) {
-00191                         ulUcs |= (ULONG)(UCHAR)p[iIndex] & 0x3f;
-00192                 }
-00193         }
-00194         *piUtfLen = iCharLen;
-00195         return ulUcs;
-00196 } /* end of utf8_to_ucs */
-00197 
-00198 /*
-00199  * utf8_strwidth - compute the string width of an UTF-8 string
-00200  *
-00201  * Returns the string width in columns
-00202  */
-00203 long
-00204 utf8_strwidth(const char *pcString, size_t tNumchars)
-00205 {
-00206         ULONG   ulUcs;
-00207         long    lTotal;
-00208         int     iToGo, iWidth, iUtflen;
-00209 
-00210         fail(pcString == NULL || tNumchars > (size_t)INT_MAX);
-00211 
-00212         lTotal = 0;
-00213         iToGo = (int)tNumchars;
-00214 
-00215         while (iToGo > 0 && *pcString != '\0') {
-00216                 ulUcs = utf8_to_ucs(pcString, iToGo, &iUtflen);
-00217                 iWidth = iWcWidth(ulUcs);
-00218                 if (iWidth > 0) {
-00219                         lTotal += iWidth;
-00220                 }
-00221                 pcString += iUtflen;
-00222                 iToGo -= iUtflen;
-00223         }
-00224         NO_DBG_DEC(lTotal);
-00225         return lTotal;
-00226 } /* end of utf8_strwidth */
-00227 
-00228 /*
-00229  * utf8_chrlength - get the number of bytes in an UTF-8 character
-00230  *
-00231  * Returns the number of bytes
-00232  */
-00233 int
-00234 utf8_chrlength(const char *p)
-00235 {
-00236         int     iUtflen;
-00237 
-00238         fail(p == NULL);
-00239 
-00240         iUtflen = -1;           /* Just to make sure */
-00241         (void)utf8_to_ucs(p, INT_MAX, &iUtflen);
-00242         NO_DBG_DEC(iUtflen);
-00243         return iUtflen;
-00244 } /* end of utf8_chrlength */
-00245 
-00246 /*
-00247  * is_locale_utf8 - return TRUE if the locale is UTF-8
-00248  */
-00249 BOOL
-00250 is_locale_utf8(void)
-00251 {
-00252         char    szCodeset[20];
-00253 
-00254         szCodeset[0] = '\0';
-00255         if (!bGetNormalizedCodeset(szCodeset, sizeof(szCodeset), NULL)) {
-00256                 return FALSE;
-00257         }
-00258         DBG_MSG(szCodeset);
-00259         return STREQ(szCodeset, "utf8");
-00260 } /* end of is_locale_utf8 */
-
-
Generated by  - -doxygen 1.6.2
- - diff -r 59758314f811 -r d4524d6a4472 Symbian3/Examples/guid-6013a680-57f9-415b-8851-c4fa63356636/version_8h_source.html --- a/Symbian3/Examples/guid-6013a680-57f9-415b-8851-c4fa63356636/version_8h_source.html Fri Jun 11 15:24:34 2010 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,53 +0,0 @@ - - - - -TB9.2 Example Applications: examples/PIPS/antiword/inc/version.h Source File - - - - - -

examples/PIPS/antiword/inc/version.h

00001 /*
-00002  * version.h
-00003  * Copyright (C) 1998-2005 A.J. van Os; Released under GNU GPL
-00004  *
-00005  * Description:
-00006  * Version and release information
-00007  */
-00008 
-00009 #if !defined(__version_h)
-00010 #define __version_h 1
-00011 
-00012 /* Strings for the info box */
-00013 #define PURPOSESTRING   "Display MS-Word files"
-00014 
-00015 #if defined(__riscos)
-00016 #define AUTHORSTRING    "© 1998-2005 Adri van Os"
-00017 #else
-00018 #define AUTHORSTRING    "(C) 1998-2005 Adri van Os"
-00019 #endif /* __riscos */
-00020 
-00021 #define VERSIONSTRING   "0.37  (21 Oct 2005)"
-00022 
-00023 #if defined(__dos)
-00024 #if defined(__DJGPP__)
-00025 #define VERSIONSTRING2  " # 32-bit Protected Mode"
-00026 #else
-00027 #define VERSIONSTRING2  " # 16-bit Real Mode"
-00028 #endif /* __DJGPP__ */
-00029 #endif /* __dos */
-00030 
-00031 #if defined(DEBUG)
-00032 #define STATUSSTRING    "DEBUG version"
-00033 #else
-00034 #define STATUSSTRING    "GNU General Public License"
-00035 #endif /* DEBUG */
-00036 
-00037 #endif /* __version_h */
-
-
Generated by  - -doxygen 1.6.2
- - diff -r 59758314f811 -r d4524d6a4472 Symbian3/Examples/guid-6013a680-57f9-415b-8851-c4fa63356636/word2text_8c_source.html --- a/Symbian3/Examples/guid-6013a680-57f9-415b-8851-c4fa63356636/word2text_8c_source.html Fri Jun 11 15:24:34 2010 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1521 +0,0 @@ - - - - -TB9.2 Example Applications: examples/PIPS/antiword/src/word2text.c Source File - - - - - -

examples/PIPS/antiword/src/word2text.c

00001 /*
-00002  * word2text.c
-00003  * Copyright (C) 1998-2005 A.J. van Os; Released under GNU GPL
-00004  *
-00005  * Description:
-00006  * MS Word to "text" functions
-00007  */
-00008 
-00009 #include <stdio.h>
-00010 #include <stdlib.h>
-00011 #include <string.h>
-00012 #include <ctype.h>
-00013 #if defined(__riscos)
-00014 #include "DeskLib:Hourglass.h"
-00015 #include "drawfile.h"
-00016 #endif /* __riscos */
-00017 #include "antiword.h"
-00018 
-00019 
-00020 #define INITIAL_SIZE            40
-00021 #define EXTENTION_SIZE          20
-00022 
-00023 
-00024 /* Macros to make sure all such statements will be identical */
-00025 #define OUTPUT_LINE()           \
-00026         do {\
-00027                 vAlign2Window(pDiag, pAnchor, lWidthMax, ucAlignment);\
-00028                 TRACE_MSG("after vAlign2Window");\
-00029                 pAnchor = pStartNewOutput(pAnchor, NULL);\
-00030                 pOutput = pAnchor;\
-00031         } while(0)
-00032 
-00033 #define RESET_LINE()            \
-00034         do {\
-00035                 pAnchor = pStartNewOutput(pAnchor, NULL);\
-00036                 pOutput = pAnchor;\
-00037         } while(0)
-00038 
-00039 #if defined(__riscos)
-00040 /* Length of the document in characters */
-00041 static ULONG    ulDocumentLength;
-00042 /* Number of characters processed so far */
-00043 static ULONG    ulCharCounter;
-00044 static int      iCurrPct, iPrevPct;
-00045 #endif /* __riscos */
-00046 /* The document is in the format belonging to this version of Word */
-00047 static int      iWordVersion = -1;
-00048 /* Special treatment for files from Word 4/5/6 on an Apple Macintosh */
-00049 static BOOL     bOldMacFile = FALSE;
-00050 /* Section Information */
-00051 static const section_block_type *pSection = NULL;
-00052 static const section_block_type *pSectionNext = NULL;
-00053 /* All the (command line) options */
-00054 static options_type     tOptions;
-00055 /* Needed for reading a complete table row */
-00056 static const row_block_type     *pRowInfo = NULL;
-00057 static BOOL     bStartRow = FALSE;
-00058 static BOOL     bEndRowNorm = FALSE;
-00059 static BOOL     bEndRowFast = FALSE;
-00060 static BOOL     bIsTableRow = FALSE;
-00061 /* Index of the next style and font information */
-00062 static USHORT   usIstdNext = ISTD_NORMAL;
-00063 /* Needed for finding the start of a style */
-00064 static const style_block_type   *pStyleInfo = NULL;
-00065 static style_block_type         tStyleNext;
-00066 static BOOL     bStartStyle = FALSE;
-00067 static BOOL     bStartStyleNext = FALSE;
-00068 /* Needed for finding the start of a font */
-00069 static const font_block_type    *pFontInfo = NULL;
-00070 static font_block_type          tFontNext;
-00071 static BOOL     bStartFont = FALSE;
-00072 static BOOL     bStartFontNext = FALSE;
-00073 /* Needed for finding an image */
-00074 static ULONG    ulFileOffsetImage = FC_INVALID;
-00075 
-00076 
-00077 /*
-00078  * vUpdateCounters - Update the counters for the hourglass
-00079  */
-00080 static void
-00081 vUpdateCounters(void)
-00082 {
-00083 #if defined(__riscos)
-00084         ulCharCounter++;
-00085         iCurrPct = (int)((ulCharCounter * 100) / ulDocumentLength);
-00086         if (iCurrPct != iPrevPct) {
-00087                 Hourglass_Percentage(iCurrPct);
-00088                 iPrevPct = iCurrPct;
-00089         }
-00090 #endif /* __riscos */
-00091 } /* end of vUpdateCounters */
-00092 
-00093 /*
-00094  * bOutputContainsText - see if the output contains more than white space
-00095  */
-00096 BOOL
-00097 bOutputContainsText(const output_type *pAnchor)
-00098 {
-00099         const output_type       *pCurr;
-00100         size_t  tIndex;
-00101 
-00102         fail(pAnchor == NULL);
-00103 
-00104         for (pCurr = pAnchor; pCurr != NULL; pCurr = pCurr->pNext) {
-00105                 fail(pCurr->lStringWidth < 0);
-00106                 for (tIndex = 0; tIndex < pCurr->tNextFree; tIndex++) {
-00107                         if (isspace((int)(UCHAR)pCurr->szStorage[tIndex])) {
-00108                                 continue;
-00109                         }
-00110 #if defined(DEBUG)
-00111                         if (pCurr->szStorage[tIndex] == FILLER_CHAR) {
-00112                                 continue;
-00113                         }
-00114 #endif /* DEBUG */
-00115                         return TRUE;
-00116                 }
-00117         }
-00118         return FALSE;
-00119 } /* end of bOutputContainsText */
-00120 
-00121 /*
-00122  * lTotalStringWidth - compute the total width of the output string
-00123  */
-00124 static long
-00125 lTotalStringWidth(const output_type *pAnchor)
-00126 {
-00127         const output_type       *pCurr;
-00128         long            lTotal;
-00129 
-00130         lTotal = 0;
-00131         for (pCurr = pAnchor; pCurr != NULL; pCurr = pCurr->pNext) {
-00132                 DBG_DEC_C(pCurr->lStringWidth < 0, pCurr->lStringWidth);
-00133                 fail(pCurr->lStringWidth < 0);
-00134                 lTotal += pCurr->lStringWidth;
-00135         }
-00136         return lTotal;
-00137 } /* end of lTotalStringWidth */
-00138 
-00139 /*
-00140  * vStoreByte - store one byte
-00141  */
-00142 static void
-00143 vStoreByte(UCHAR ucChar, output_type *pOutput)
-00144 {
-00145         fail(pOutput == NULL);
-00146 
-00147         if (ucChar == 0) {
-00148                 pOutput->szStorage[pOutput->tNextFree] = '\0';
-00149                 return;
-00150         }
-00151 
-00152         while (pOutput->tNextFree + 2 > pOutput->tStorageSize) {
-00153                 pOutput->tStorageSize += EXTENTION_SIZE;
-00154                 pOutput->szStorage = xrealloc(pOutput->szStorage,
-00155                                         pOutput->tStorageSize);
-00156         }
-00157         pOutput->szStorage[pOutput->tNextFree] = (char)ucChar;
-00158         pOutput->szStorage[pOutput->tNextFree + 1] = '\0';
-00159         pOutput->tNextFree++;
-00160 } /* end of vStoreByte */
-00161 
-00162 /*
-00163  * vStoreChar - store a character as one or more bytes
-00164  */
-00165 static void
-00166 vStoreChar(ULONG ulChar, BOOL bChangeAllowed, output_type *pOutput)
-00167 {
-00168         char    szResult[4];
-00169         size_t  tIndex, tLen;
-00170 
-00171         fail(pOutput == NULL);
-00172 
-00173         if (tOptions.eEncoding == encoding_utf_8 && bChangeAllowed) {
-00174                 DBG_HEX_C(ulChar > 0xffff, ulChar);
-00175                 fail(ulChar > 0xffff);
-00176                 tLen = tUcs2Utf8(ulChar, szResult, sizeof(szResult));
-00177                 for (tIndex = 0; tIndex < tLen; tIndex++) {
-00178                         vStoreByte((UCHAR)szResult[tIndex], pOutput);
-00179                 }
-00180         } else {
-00181                 DBG_HEX_C(ulChar > 0xff, ulChar);
-00182                 fail(ulChar > 0xff);
-00183                 vStoreByte((UCHAR)ulChar, pOutput);
-00184                 tLen = 1;
-00185         }
-00186         pOutput->lStringWidth += lComputeStringWidth(
-00187                                 pOutput->szStorage + pOutput->tNextFree - tLen,
-00188                                 tLen,
-00189                                 pOutput->tFontRef,
-00190                                 pOutput->usFontSize);
-00191 } /* end of vStoreChar */
-00192 
-00193 /*
-00194  * vStoreCharacter - store one character
-00195  */
-00196 static void
-00197 vStoreCharacter(ULONG ulChar, output_type *pOutput)
-00198 {
-00199         vStoreChar(ulChar, TRUE, pOutput);
-00200 } /* end of vStoreCharacter */
-00201 
-00202 /*
-00203  * vStoreString - store a string
-00204  */
-00205 static void
-00206 vStoreString(const char *szString, size_t tStringLength, output_type *pOutput)
-00207 {
-00208         size_t  tIndex;
-00209 
-00210         fail(szString == NULL || pOutput == NULL);
-00211 
-00212         for (tIndex = 0; tIndex < tStringLength; tIndex++) {
-00213                 vStoreCharacter((ULONG)(UCHAR)szString[tIndex], pOutput);
-00214         }
-00215 } /* end of vStoreString */
-00216 
-00217 /*
-00218  * vStoreNumberAsDecimal - store a number as a decimal number
-00219  */
-00220 static void
-00221 vStoreNumberAsDecimal(UINT uiNumber, output_type *pOutput)
-00222 {
-00223         size_t  tLen;
-00224         char    szString[3 * sizeof(UINT) + 1];
-00225 
-00226         fail(uiNumber == 0);
-00227         fail(pOutput == NULL);
-00228 
-00229         tLen = (size_t)sprintf(szString, "%u", uiNumber);
-00230         vStoreString(szString, tLen, pOutput);
-00231 } /* end of vStoreNumberAsDecimal */
-00232 
-00233 /*
-00234  * vStoreNumberAsRoman - store a number as a roman numerical
-00235  */
-00236 static void
-00237 vStoreNumberAsRoman(UINT uiNumber, output_type *pOutput)
-00238 {
-00239         size_t  tLen;
-00240         char    szString[15];
-00241 
-00242         fail(uiNumber == 0);
-00243         fail(pOutput == NULL);
-00244 
-00245         tLen = tNumber2Roman(uiNumber, FALSE, szString);
-00246         vStoreString(szString, tLen, pOutput);
-00247 } /* end of vStoreNumberAsRoman */
-00248 
-00249 /*
-00250  * vStoreStyle - store a style
-00251  */
-00252 static void
-00253 vStoreStyle(diagram_type *pDiag, output_type *pOutput,
-00254         const style_block_type *pStyle)
-00255 {
-00256         size_t  tLen;
-00257         char    szString[120];
-00258 
-00259         fail(pDiag == NULL);
-00260         fail(pOutput == NULL);
-00261         fail(pStyle == NULL);
-00262 
-00263         if (tOptions.eConversionType == conversion_xml) {
-00264                 vSetHeaders(pDiag, pStyle->usIstd);
-00265         } else {
-00266                 tLen = tStyle2Window(szString, sizeof(szString),
-00267                                         pStyle, pSection);
-00268                 vStoreString(szString, tLen, pOutput);
-00269         }
-00270 } /* end of vStoreStyle */
-00271 
-00272 /*
-00273  * vPutIndentation - output the specified amount of indentation
-00274  */
-00275 static void
-00276 vPutIndentation(diagram_type *pDiag, output_type *pOutput,
-00277         BOOL bNoMarks, BOOL bFirstLine,
-00278         UINT uiListNumber, UCHAR ucNFC, const char *szListChar,
-00279         long lLeftIndentation, long lLeftIndentation1)
-00280 {
-00281         long    lWidth;
-00282         size_t  tIndex, tNextFree;
-00283         char    szLine[30];
-00284 
-00285         fail(pDiag == NULL);
-00286         fail(pOutput == NULL);
-00287         fail(szListChar == NULL);
-00288         fail(lLeftIndentation < 0);
-00289 
-00290         if (tOptions.eConversionType == conversion_xml) {
-00291                 /* XML does its own indentation at rendering time */
-00292                 return;
-00293         }
-00294 
-00295         if (bNoMarks) {
-00296                 if (bFirstLine) {
-00297                         lLeftIndentation += lLeftIndentation1;
-00298                 }
-00299                 if (lLeftIndentation < 0) {
-00300                         lLeftIndentation = 0;
-00301                 }
-00302                 vSetLeftIndentation(pDiag, lLeftIndentation);
-00303                 return;
-00304         }
-00305         if (lLeftIndentation <= 0) {
-00306                 DBG_HEX_C(ucNFC != 0x00, ucNFC);
-00307                 vSetLeftIndentation(pDiag, 0);
-00308                 return;
-00309         }
-00310 
-00311 #if defined(DEBUG)
-00312         if (tOptions.eEncoding == encoding_utf_8) {
-00313                 fail(strlen(szListChar) > 3);
-00314         } else {
-00315                 DBG_HEX_C(iscntrl((int)szListChar[0]), szListChar[0]);
-00316                 fail(iscntrl((int)szListChar[0]));
-00317                 fail(szListChar[1] != '\0');
-00318         }
-00319 #endif /* DEBUG */
-00320 
-00321         switch (ucNFC) {
-00322         case LIST_ARABIC_NUM:
-00323         case LIST_NUMBER_TXT:
-00324                 tNextFree = (size_t)sprintf(szLine, "%u", uiListNumber);
-00325                 break;
-00326         case LIST_UPPER_ROMAN:
-00327         case LIST_LOWER_ROMAN:
-00328                 tNextFree = tNumber2Roman(uiListNumber,
-00329                                 ucNFC == LIST_UPPER_ROMAN, szLine);
-00330                 break;
-00331         case LIST_UPPER_ALPHA:
-00332         case LIST_LOWER_ALPHA:
-00333                 tNextFree = tNumber2Alpha(uiListNumber,
-00334                                 ucNFC == LIST_UPPER_ALPHA, szLine);
-00335                 break;
-00336         case LIST_ORDINAL_NUM:
-00337         case LIST_ORDINAL_TXT:
-00338                 if (uiListNumber % 10 == 1 && uiListNumber != 11) {
-00339                         tNextFree =
-00340                                 (size_t)sprintf(szLine, "%ust", uiListNumber);
-00341                 } else if (uiListNumber % 10 == 2 && uiListNumber != 12) {
-00342                         tNextFree =
-00343                                 (size_t)sprintf(szLine, "%und", uiListNumber);
-00344                 } else if (uiListNumber % 10 == 3 && uiListNumber != 13) {
-00345                         tNextFree =
-00346                                 (size_t)sprintf(szLine, "%urd", uiListNumber);
-00347                 } else {
-00348                         tNextFree =
-00349                                 (size_t)sprintf(szLine, "%uth", uiListNumber);
-00350                 }
-00351                 break;
-00352         case LIST_OUTLINE_NUM:
-00353                 tNextFree = (size_t)sprintf(szLine, "%02u", uiListNumber);
-00354                 break;
-00355         case LIST_SPECIAL:
-00356         case LIST_SPECIAL2:
-00357         case LIST_BULLETS:
-00358                 tNextFree = 0;
-00359                 break;
-00360         default:
-00361                 DBG_HEX(ucNFC);
-00362                 DBG_FIXME();
-00363                 tNextFree = (size_t)sprintf(szLine, "%u", uiListNumber);
-00364                 break;
-00365         }
-00366         tNextFree += (size_t)sprintf(szLine + tNextFree, "%.3s", szListChar);
-00367         szLine[tNextFree++] = ' ';
-00368         szLine[tNextFree] = '\0';
-00369         lWidth = lComputeStringWidth(szLine, tNextFree,
-00370                                 pOutput->tFontRef, pOutput->usFontSize);
-00371         lLeftIndentation -= lWidth;
-00372         if (lLeftIndentation < 0) {
-00373                 lLeftIndentation = 0;
-00374         }
-00375         vSetLeftIndentation(pDiag, lLeftIndentation);
-00376         for (tIndex = 0; tIndex < tNextFree; tIndex++) {
-00377                 vStoreChar((ULONG)(UCHAR)szLine[tIndex], FALSE, pOutput);
-00378         }
-00379 } /* end of vPutIndentation */
-00380 
-00381 /*
-00382  * vPutSeparatorLine - output a separator line
-00383  *
-00384  * A separator line is a horizontal line two inches long.
-00385  * Two inches equals 144000 millipoints.
-00386  */
-00387 static void
-00388 vPutSeparatorLine(output_type *pOutput)
-00389 {
-00390         long    lCharWidth;
-00391         int     iCounter, iChars;
-00392         char    szOne[2];
-00393 
-00394         fail(pOutput == NULL);
-00395 
-00396         szOne[0] = OUR_EM_DASH;
-00397         szOne[1] = '\0';
-00398         lCharWidth = lComputeStringWidth(szOne, 1,
-00399                                 pOutput->tFontRef, pOutput->usFontSize);
-00400         NO_DBG_DEC(lCharWidth);
-00401         iChars = (int)((144000 + lCharWidth / 2) / lCharWidth);
-00402         NO_DBG_DEC(iChars);
-00403         for (iCounter = 0; iCounter < iChars; iCounter++) {
-00404                 vStoreCharacter((ULONG)(UCHAR)OUR_EM_DASH, pOutput);
-00405         }
-00406 } /* end of vPutSeparatorLine */
-00407 
-00408 /*
-00409  * pStartNextOutput - start the next output record
-00410  *
-00411  * returns a pointer to the next record
-00412  */
-00413 static output_type *
-00414 pStartNextOutput(output_type *pCurrent)
-00415 {
-00416         output_type     *pNew;
-00417 
-00418         TRACE_MSG("pStartNextOutput");
-00419 
-00420         if (pCurrent->tNextFree == 0) {
-00421                 /* The current record is empty, re-use */
-00422                 fail(pCurrent->szStorage[0] != '\0');
-00423                 fail(pCurrent->lStringWidth != 0);
-00424                 return pCurrent;
-00425         }
-00426         /* The current record is in use, make a new one */
-00427         pNew = xmalloc(sizeof(*pNew));
-00428         pCurrent->pNext = pNew;
-00429         pNew->tStorageSize = INITIAL_SIZE;
-00430         pNew->szStorage = xmalloc(pNew->tStorageSize);
-00431         pNew->szStorage[0] = '\0';
-00432         pNew->tNextFree = 0;
-00433         pNew->lStringWidth = 0;
-00434         pNew->ucFontColor = FONT_COLOR_DEFAULT;
-00435         pNew->usFontStyle = FONT_REGULAR;
-00436         pNew->tFontRef = (drawfile_fontref)0;
-00437         pNew->usFontSize = DEFAULT_FONT_SIZE;
-00438         pNew->pPrev = pCurrent;
-00439         pNew->pNext = NULL;
-00440         return pNew;
-00441 } /* end of pStartNextOutput */
-00442 
-00443 /*
-00444  * pStartNewOutput
-00445  */
-00446 static output_type *
-00447 pStartNewOutput(output_type *pAnchor, output_type *pLeftOver)
-00448 {
-00449         output_type     *pCurr, *pNext;
-00450         USHORT          usFontStyle, usFontSize;
-00451         drawfile_fontref        tFontRef;
-00452         UCHAR           ucFontColor;
-00453 
-00454         TRACE_MSG("pStartNewOutput");
-00455 
-00456         ucFontColor = FONT_COLOR_DEFAULT;
-00457         usFontStyle = FONT_REGULAR;
-00458         tFontRef = (drawfile_fontref)0;
-00459         usFontSize = DEFAULT_FONT_SIZE;
-00460         /* Free the old output space */
-00461         pCurr = pAnchor;
-00462         while (pCurr != NULL) {
-00463                 TRACE_MSG("Free the old output space");
-00464                 pNext = pCurr->pNext;
-00465                 pCurr->szStorage = xfree(pCurr->szStorage);
-00466                 if (pCurr->pNext == NULL) {
-00467                         ucFontColor = pCurr->ucFontColor;
-00468                         usFontStyle = pCurr->usFontStyle;
-00469                         tFontRef = pCurr->tFontRef;
-00470                         usFontSize = pCurr->usFontSize;
-00471                 }
-00472                 pCurr = xfree(pCurr);
-00473                 pCurr = pNext;
-00474         }
-00475         if (pLeftOver == NULL) {
-00476                 /* Create new output space */
-00477                 TRACE_MSG("Create new output space");
-00478                 pLeftOver = xmalloc(sizeof(*pLeftOver));
-00479                 pLeftOver->tStorageSize = INITIAL_SIZE;
-00480                 NO_DBG_DEC(pLeftOver->tStorageSize);
-00481                 TRACE_MSG("before 2nd xmalloc");
-00482                 pLeftOver->szStorage = xmalloc(pLeftOver->tStorageSize);
-00483                 TRACE_MSG("after 2nd xmalloc");
-00484                 pLeftOver->szStorage[0] = '\0';
-00485                 pLeftOver->tNextFree = 0;
-00486                 pLeftOver->lStringWidth = 0;
-00487                 pLeftOver->ucFontColor = ucFontColor;
-00488                 pLeftOver->usFontStyle = usFontStyle;
-00489                 pLeftOver->tFontRef = tFontRef;
-00490                 pLeftOver->usFontSize = usFontSize;
-00491                 pLeftOver->pPrev = NULL;
-00492                 pLeftOver->pNext = NULL;
-00493         }
-00494         fail(!bCheckDoubleLinkedList(pLeftOver));
-00495         return pLeftOver;
-00496 } /* end of pStartNewOutput */
-00497 
-00498 /*
-00499  * ulGetChar - get the next character from the specified list
-00500  *
-00501  * returns the next character of EOF
-00502  */
-00503 static ULONG
-00504 ulGetChar(FILE *pFile, list_id_enum eListID)
-00505 {
-00506         const font_block_type   *pCurr;
-00507         ULONG           ulChar, ulFileOffset, ulCharPos;
-00508         row_info_enum   eRowInfo;
-00509         USHORT          usChar, usPropMod;
-00510         BOOL            bSkip;
-00511 
-00512         fail(pFile == NULL);
-00513 
-00514         pCurr = pFontInfo;
-00515         bSkip = FALSE;
-00516         for (;;) {
-00517                 usChar = usNextChar(pFile, eListID,
-00518                                 &ulFileOffset, &ulCharPos, &usPropMod);
-00519                 if (usChar == (USHORT)EOF) {
-00520                         return (ULONG)EOF;
-00521                 }
-00522 
-00523                 vUpdateCounters();
-00524 
-00525                 eRowInfo = ePropMod2RowInfo(usPropMod, iWordVersion);
-00526                 if (!bStartRow) {
-00527 #if 0
-00528                         bStartRow = eRowInfo == found_a_cell ||
-00529                                 (pRowInfo != NULL &&
-00530                                  ulFileOffset == pRowInfo->ulFileOffsetStart &&
-00531                                  eRowInfo != found_not_a_cell);
-00532 #else
-00533                         bStartRow = pRowInfo != NULL &&
-00534                                 ulFileOffset == pRowInfo->ulFileOffsetStart;
-00535 #endif
-00536                         NO_DBG_HEX_C(bStartRow, pRowInfo->ulFileOffsetStart);
-00537                 }
-00538                 if (!bEndRowNorm) {
-00539 #if 0
-00540                         bEndRow = eRowInfo == found_end_of_row ||
-00541                                 (pRowInfo != NULL &&
-00542                                  ulFileOffset == pRowInfo->ulFileOffsetEnd &&
-00543                                  eRowInfo != found_not_end_of_row);
-00544 #else
-00545                         bEndRowNorm = pRowInfo != NULL &&
-00546                                 ulFileOffset == pRowInfo->ulFileOffsetEnd;
-00547 #endif
-00548                         NO_DBG_HEX_C(bEndRowNorm, pRowInfo->ulFileOffsetEnd);
-00549                 }
-00550                 if (!bEndRowFast) {
-00551                         bEndRowFast = eRowInfo == found_end_of_row;
-00552                         NO_DBG_HEX_C(bEndRowFast, pRowInfo->ulFileOffsetEnd);
-00553                 }
-00554 
-00555                 if (!bStartStyle) {
-00556                         bStartStyle = pStyleInfo != NULL &&
-00557                                 ulFileOffset == pStyleInfo->ulFileOffset;
-00558                         NO_DBG_HEX_C(bStartStyle, ulFileOffset);
-00559                 }
-00560                 if (pCurr != NULL && ulFileOffset == pCurr->ulFileOffset) {
-00561                         bStartFont = TRUE;
-00562                         NO_DBG_HEX(ulFileOffset);
-00563                         pFontInfo = pCurr;
-00564                         pCurr = pGetNextFontInfoListItem(pCurr);
-00565                 }
-00566 
-00567                 /* Skip embedded characters */
-00568                 if (usChar == START_EMBEDDED) {
-00569                         bSkip = TRUE;
-00570                         continue;
-00571                 }
-00572                 if (usChar == END_IGNORE || usChar == END_EMBEDDED) {
-00573                         bSkip = FALSE;
-00574                         continue;
-00575                 }
-00576                 if (bSkip) {
-00577                         continue;
-00578                 }
-00579                 ulChar = ulTranslateCharacters(usChar,
-00580                                         ulFileOffset,
-00581                                         iWordVersion,
-00582                                         tOptions.eConversionType,
-00583                                         tOptions.eEncoding,
-00584                                         bOldMacFile);
-00585                 if (ulChar == IGNORE_CHARACTER) {
-00586                         continue;
-00587                 }
-00588                 if (ulChar == PICTURE) {
-00589                         ulFileOffsetImage = ulGetPictInfoListItem(ulFileOffset);
-00590                 } else {
-00591                         ulFileOffsetImage = FC_INVALID;
-00592                 }
-00593                 if (ulChar == PAR_END) {
-00594                         /* End of paragraph seen, prepare for the next */
-00595                         vFillStyleFromStylesheet(usIstdNext, &tStyleNext);
-00596                         vCorrectStyleValues(&tStyleNext);
-00597                         bStartStyleNext = TRUE;
-00598                         vFillFontFromStylesheet(usIstdNext, &tFontNext);
-00599                         vCorrectFontValues(&tFontNext);
-00600                         bStartFontNext = TRUE;
-00601                 }
-00602                 if (ulChar == PAGE_BREAK) {
-00603                         /* Might be the start of a new section */
-00604                         pSectionNext = pGetSectionInfo(pSection, ulCharPos);
-00605                 }
-00606                 return ulChar;
-00607         }
-00608 } /* end of ulGetChar */
-00609 
-00610 /*
-00611  * lGetWidthMax - get the maximum line width from the paragraph break value
-00612  *
-00613  * Returns the maximum line width in millipoints
-00614  */
-00615 static long
-00616 lGetWidthMax(int iParagraphBreak)
-00617 {
-00618         fail(iParagraphBreak < 0);
-00619 
-00620         if (iParagraphBreak == 0) {
-00621                 return LONG_MAX;
-00622         }
-00623         if (iParagraphBreak < MIN_SCREEN_WIDTH) {
-00624                 return lChar2MilliPoints(MIN_SCREEN_WIDTH);
-00625         }
-00626         if (iParagraphBreak > MAX_SCREEN_WIDTH) {
-00627                 return lChar2MilliPoints(MAX_SCREEN_WIDTH);
-00628         }
-00629         return lChar2MilliPoints(iParagraphBreak);
-00630 } /* end of lGetWidthMax */
-00631 
-00632 /*
-00633  * bWordDecryptor - turn Word to something more useful
-00634  *
-00635  * returns TRUE when succesful, otherwise FALSE
-00636  */
-00637 BOOL
-00638 bWordDecryptor(FILE *pFile, long lFilesize, diagram_type *pDiag)
-00639 {
-00640         imagedata_type  tImage;
-00641         const style_block_type  *pStyleTmp;
-00642         const font_block_type   *pFontTmp;
-00643         const char      *szListChar;
-00644         output_type     *pAnchor, *pOutput, *pLeftOver;
-00645         ULONG   ulChar;
-00646         long    lBeforeIndentation, lAfterIndentation;
-00647         long    lLeftIndentation, lLeftIndentation1, lRightIndentation;
-00648         long    lWidthCurr, lWidthMax, lDefaultTabWidth, lHalfSpaceWidth, lTmp;
-00649         list_id_enum    eListID;
-00650         image_info_enum eRes;
-00651         UINT    uiFootnoteNumber, uiEndnoteNumber, uiTmp;
-00652         int     iListSeqNumber;
-00653         BOOL    bWasTableRow, bTableFontClosed, bWasEndOfParagraph;
-00654         BOOL    bInList, bWasInList, bNoMarks, bFirstLine;
-00655         BOOL    bAllCapitals, bHiddenText, bMarkDelText, bSuccess;
-00656         USHORT  usListNumber;
-00657         USHORT  usFontStyle, usFontStyleMinimal, usFontSize, usTmp;
-00658         UCHAR   ucFontNumber, ucFontColor;
-00659         UCHAR   ucNFC, ucAlignment;
-00660 
-00661         fail(pFile == NULL || lFilesize <= 0 || pDiag == NULL);
-00662 
-00663         TRACE_MSG("bWordDecryptor");
-00664 
-00665         iWordVersion = iInitDocument(pFile, lFilesize);
-00666         if (iWordVersion < 0) {
-00667                 DBG_DEC(iWordVersion);
-00668                 return FALSE;
-00669         }
-00670 
-00671         vGetOptions(&tOptions);
-00672         bOldMacFile = bIsOldMacFile();
-00673         vPrepareHdrFtrText(pFile);
-00674         vPrepareFootnoteText(pFile);
-00675 
-00676         vPrologue2(pDiag, iWordVersion);
-00677 
-00678         /* Initialisation */
-00679 #if defined(__riscos)
-00680         ulCharCounter = 0;
-00681         iCurrPct = 0;
-00682         iPrevPct = -1;
-00683         ulDocumentLength = ulGetDocumentLength();
-00684 #endif /* __riscos */
-00685         pSection = pGetSectionInfo(NULL, 0);
-00686         pSectionNext = pSection;
-00687         lDefaultTabWidth = lGetDefaultTabWidth();
-00688         DBG_DEC_C(lDefaultTabWidth != 36000, lDefaultTabWidth);
-00689         pRowInfo = pGetNextRowInfoListItem();
-00690         DBG_HEX_C(pRowInfo != NULL, pRowInfo->ulFileOffsetStart);
-00691         DBG_HEX_C(pRowInfo != NULL, pRowInfo->ulFileOffsetEnd);
-00692         DBG_MSG_C(pRowInfo == NULL, "No rows at all");
-00693         bStartRow = FALSE;
-00694         bEndRowNorm = FALSE;
-00695         bEndRowFast = FALSE;
-00696         bIsTableRow = FALSE;
-00697         bWasTableRow = FALSE;
-00698         vResetStyles();
-00699         pStyleInfo = pGetNextTextStyle(NULL);
-00700         bStartStyle = FALSE;
-00701         bInList = FALSE;
-00702         bWasInList = FALSE;
-00703         iListSeqNumber = 0;
-00704         usIstdNext = ISTD_NORMAL;
-00705         pAnchor = NULL;
-00706         pFontInfo = pGetNextFontInfoListItem(NULL);
-00707         DBG_HEX_C(pFontInfo != NULL, pFontInfo->ulFileOffset);
-00708         DBG_MSG_C(pFontInfo == NULL, "No fonts at all");
-00709         bStartFont = FALSE;
-00710         ucFontNumber = 0;
-00711         usFontStyleMinimal = FONT_REGULAR;
-00712         usFontStyle = FONT_REGULAR;
-00713         usFontSize = DEFAULT_FONT_SIZE;
-00714         ucFontColor = FONT_COLOR_DEFAULT;
-00715         pAnchor = pStartNewOutput(pAnchor, NULL);
-00716         pOutput = pAnchor;
-00717         pOutput->ucFontColor = ucFontColor;
-00718         pOutput->usFontStyle = usFontStyle;
-00719         pOutput->tFontRef = tOpenFont(ucFontNumber, usFontStyle, usFontSize);
-00720         pOutput->usFontSize = usFontSize;
-00721         bTableFontClosed = TRUE;
-00722         lBeforeIndentation = 0;
-00723         lAfterIndentation = 0;
-00724         lLeftIndentation = 0;
-00725         lLeftIndentation1 = 0;
-00726         lRightIndentation = 0;
-00727         bWasEndOfParagraph = TRUE;
-00728         bNoMarks = TRUE;
-00729         bFirstLine = TRUE;
-00730         ucNFC = LIST_BULLETS;
-00731         if (pStyleInfo != NULL) {
-00732                 szListChar = pStyleInfo->szListChar;
-00733                 pStyleTmp = pStyleInfo;
-00734         } else {
-00735                 if (tStyleNext.szListChar[0] == '\0') {
-00736                         vGetBulletValue(tOptions.eConversionType,
-00737                                 tOptions.eEncoding, tStyleNext.szListChar, 4);
-00738                 }
-00739                 szListChar = tStyleNext.szListChar;
-00740                 pStyleTmp = &tStyleNext;
-00741         }
-00742         usListNumber = 0;
-00743         ucAlignment = ALIGNMENT_LEFT;
-00744         bAllCapitals = FALSE;
-00745         bHiddenText = FALSE;
-00746         bMarkDelText = FALSE;
-00747         lWidthMax = lGetWidthMax(tOptions.iParagraphBreak);
-00748         NO_DBG_DEC(lWidthMax);
-00749 
-00750         Hourglass_On();
-00751 
-00752         uiFootnoteNumber = 0;
-00753         uiEndnoteNumber = 0;
-00754         eListID = text_list;
-00755         for(;;) {
-00756                 ulChar = ulGetChar(pFile, eListID);
-00757                 if (ulChar == (ULONG)EOF) {
-00758                         if (bOutputContainsText(pAnchor)) {
-00759                                 OUTPUT_LINE();
-00760                         } else {
-00761                                 RESET_LINE();
-00762                         }
-00763                         switch (eListID) {
-00764                         case text_list:
-00765                                 if (tOptions.eConversionType !=
-00766                                                         conversion_xml) {
-00767                                         eListID = footnote_list;
-00768                                         if (uiFootnoteNumber != 0) {
-00769                                                 vPutSeparatorLine(pAnchor);
-00770                                                 OUTPUT_LINE();
-00771                                                 uiFootnoteNumber = 0;
-00772                                         }
-00773                                         break;
-00774                                 }
-00775                                 /* No break or return */
-00776                         case footnote_list:
-00777                                 eListID = endnote_list;
-00778                                 if (uiEndnoteNumber != 0) {
-00779                                         vPutSeparatorLine(pAnchor);
-00780                                         OUTPUT_LINE();
-00781                                         uiEndnoteNumber = 0;
-00782                                 }
-00783                                 break;
-00784                         case endnote_list:
-00785                                 eListID = textbox_list;
-00786                                 if (bExistsTextBox()) {
-00787                                         vPutSeparatorLine(pAnchor);
-00788                                         OUTPUT_LINE();
-00789                                 }
-00790                                 break;
-00791                         case textbox_list:
-00792                                 eListID = hdrtextbox_list;
-00793                                 if (bExistsHdrTextBox()) {
-00794                                         vPutSeparatorLine(pAnchor);
-00795                                         OUTPUT_LINE();
-00796                                 }
-00797                                 break;
-00798                         case hdrtextbox_list:
-00799                         default:
-00800                                 eListID = end_of_lists;
-00801                                 break;
-00802                         }
-00803                         if (eListID == end_of_lists) {
-00804                                 break;
-00805                         }
-00806                         continue;
-00807                 }
-00808 
-00809                 if (ulChar == UNKNOWN_NOTE_CHAR) {
-00810                         switch (eListID) {
-00811                         case footnote_list:
-00812                                 ulChar = FOOTNOTE_CHAR;
-00813                                 break;
-00814                         case endnote_list:
-00815                                 ulChar = ENDNOTE_CHAR;
-00816                                 break;
-00817                         default:
-00818                                 break;
-00819                         }
-00820                 }
-00821 
-00822                 if (bStartRow) {
-00823                         /* Begin of a tablerow found */
-00824                         if (bOutputContainsText(pAnchor)) {
-00825                                 OUTPUT_LINE();
-00826                         } else {
-00827                                 RESET_LINE();
-00828                         }
-00829                         fail(pAnchor != pOutput);
-00830                         if (bTableFontClosed) {
-00831                                 /* Start special table font */
-00832                                 vCloseFont();
-00833                                 /*
-00834                                  * Compensate for the fact that Word uses
-00835                                  * proportional fonts for its tables and we
-00836                                  * only one fixed-width font
-00837                                  */
-00838                                 uiTmp = ((UINT)usFontSize * 5 + 3) / 6;
-00839                                 if (uiTmp < MIN_TABLEFONT_SIZE) {
-00840                                         uiTmp = MIN_TABLEFONT_SIZE;
-00841                                 } else if (uiTmp > MAX_TABLEFONT_SIZE) {
-00842                                         uiTmp = MAX_TABLEFONT_SIZE;
-00843                                 }
-00844                                 pOutput->usFontSize = (USHORT)uiTmp;
-00845                                 pOutput->tFontRef =
-00846                                         tOpenTableFont(pOutput->usFontSize);
-00847                                 pOutput->usFontStyle = FONT_REGULAR;
-00848                                 pOutput->ucFontColor = FONT_COLOR_BLACK;
-00849                                 bTableFontClosed = FALSE;
-00850                         }
-00851                         bIsTableRow = TRUE;
-00852                         bStartRow = FALSE;
-00853                 }
-00854 
-00855                 if (bWasTableRow &&
-00856                     !bIsTableRow &&
-00857                     ulChar != PAR_END &&
-00858                     ulChar != HARD_RETURN &&
-00859                     ulChar != PAGE_BREAK &&
-00860                     ulChar != COLUMN_FEED) {
-00861                         /*
-00862                          * The end of a table should be followed by an
-00863                          * empty line, like the end of a paragraph
-00864                          */
-00865                         OUTPUT_LINE();
-00866                         vEndOfParagraph(pDiag,
-00867                                         pOutput->tFontRef,
-00868                                         pOutput->usFontSize,
-00869                                         (long)pOutput->usFontSize * 600);
-00870                 }
-00871 
-00872                 switch (ulChar) {
-00873                 case PAGE_BREAK:
-00874                 case COLUMN_FEED:
-00875                         if (bIsTableRow) {
-00876                                 /* Ignore when in a table */
-00877                                 break;
-00878                         }
-00879                         if (bOutputContainsText(pAnchor)) {
-00880                                 OUTPUT_LINE();
-00881                         } else {
-00882                                 RESET_LINE();
-00883                         }
-00884                         if (ulChar == PAGE_BREAK) {
-00885                                 vEndOfPage(pDiag, lAfterIndentation,
-00886                                                 pSection != pSectionNext);
-00887                         } else {
-00888                                 vEndOfParagraph(pDiag,
-00889                                         pOutput->tFontRef,
-00890                                         pOutput->usFontSize,
-00891                                         lAfterIndentation);
-00892                         }
-00893                         break;
-00894                 default:
-00895                         break;
-00896                 }
-00897 
-00898                 if (bStartFont || (bStartFontNext && ulChar != PAR_END)) {
-00899                         /* Begin of a font found */
-00900                         if (bStartFont) {
-00901                                 /* bStartFont takes priority */
-00902                                 fail(pFontInfo == NULL);
-00903                                 pFontTmp = pFontInfo;
-00904                         } else {
-00905                                 pFontTmp = &tFontNext;
-00906                         }
-00907                         bAllCapitals = bIsCapitals(pFontTmp->usFontStyle);
-00908                         bHiddenText = bIsHidden(pFontTmp->usFontStyle);
-00909                         bMarkDelText = bIsMarkDel(pFontTmp->usFontStyle);
-00910                         usTmp = pFontTmp->usFontStyle &
-00911                                 (FONT_BOLD|FONT_ITALIC|FONT_UNDERLINE|
-00912                                  FONT_STRIKE|FONT_MARKDEL|
-00913                                  FONT_SUPERSCRIPT|FONT_SUBSCRIPT);
-00914                         if (!bIsTableRow &&
-00915                             (usFontSize != pFontTmp->usFontSize ||
-00916                              ucFontNumber != pFontTmp->ucFontNumber ||
-00917                              usFontStyleMinimal != usTmp ||
-00918                              ucFontColor != pFontTmp->ucFontColor)) {
-00919                                 pOutput = pStartNextOutput(pOutput);
-00920                                 vCloseFont();
-00921                                 pOutput->ucFontColor = pFontTmp->ucFontColor;
-00922                                 pOutput->usFontStyle = pFontTmp->usFontStyle;
-00923                                 pOutput->usFontSize = pFontTmp->usFontSize;
-00924                                 pOutput->tFontRef = tOpenFont(
-00925                                                 pFontTmp->ucFontNumber,
-00926                                                 pFontTmp->usFontStyle,
-00927                                                 pFontTmp->usFontSize);
-00928                                 fail(!bCheckDoubleLinkedList(pAnchor));
-00929                         }
-00930                         ucFontNumber = pFontTmp->ucFontNumber;
-00931                         usFontSize = pFontTmp->usFontSize;
-00932                         ucFontColor = pFontTmp->ucFontColor;
-00933                         usFontStyle = pFontTmp->usFontStyle;
-00934                         usFontStyleMinimal = usTmp;
-00935                         if (bStartFont) {
-00936                                 /* Get the next font info */
-00937                                 pFontInfo = pGetNextFontInfoListItem(pFontInfo);
-00938                                 NO_DBG_HEX_C(pFontInfo != NULL,
-00939                                                 pFontInfo->ulFileOffset);
-00940                                 DBG_MSG_C(pFontInfo == NULL, "No more fonts");
-00941                         }
-00942                         bStartFont = FALSE;
-00943                         bStartFontNext = FALSE;
-00944                 }
-00945 
-00946                 if (bStartStyle || (bStartStyleNext && ulChar != PAR_END)) {
-00947                         bFirstLine = TRUE;
-00948                         /* Begin of a style found */
-00949                         if (bStartStyle) {
-00950                                 /* bStartStyle takes priority */
-00951                                 fail(pStyleInfo == NULL);
-00952                                 pStyleTmp = pStyleInfo;
-00953                         } else {
-00954                                 pStyleTmp = &tStyleNext;
-00955                         }
-00956                         if (!bIsTableRow) {
-00957                                 vStoreStyle(pDiag, pOutput, pStyleTmp);
-00958                         }
-00959                         usIstdNext = pStyleTmp->usIstdNext;
-00960                         lBeforeIndentation =
-00961                                 lTwips2MilliPoints(pStyleTmp->usBeforeIndent);
-00962                         lAfterIndentation =
-00963                                 lTwips2MilliPoints(pStyleTmp->usAfterIndent);
-00964                         lLeftIndentation =
-00965                                 lTwips2MilliPoints(pStyleTmp->sLeftIndent);
-00966                         lLeftIndentation1 =
-00967                                 lTwips2MilliPoints(pStyleTmp->sLeftIndent1);
-00968                         lRightIndentation =
-00969                                 lTwips2MilliPoints(pStyleTmp->sRightIndent);
-00970                         bInList = bStyleImpliesList(pStyleTmp, iWordVersion);
-00971                         bNoMarks = !bInList || pStyleTmp->bNumPause;
-00972                         ucNFC = pStyleTmp->ucNFC;
-00973                         szListChar = pStyleTmp->szListChar;
-00974                         ucAlignment = pStyleTmp->ucAlignment;
-00975                         if (bInList && !bWasInList) {
-00976                                 /* Start of a list */
-00977                                 iListSeqNumber++;
-00978                                 vStartOfList(pDiag, ucNFC,
-00979                                                 bWasTableRow && !bIsTableRow);
-00980                         }
-00981                         if (!bInList && bWasInList) {
-00982                                 /* End of a list */
-00983                                 vEndOfList(pDiag);
-00984                         }
-00985                         bWasInList = bInList;
-00986                         if (bStartStyle) {
-00987                                 pStyleInfo = pGetNextTextStyle(pStyleInfo);
-00988                                 NO_DBG_HEX_C(pStyleInfo != NULL,
-00989                                                 pStyleInfo->ulFileOffset);
-00990                                 DBG_MSG_C(pStyleInfo == NULL,
-00991                                                 "No more styles");
-00992                         }
-00993                         bStartStyle = FALSE;
-00994                         bStartStyleNext = FALSE;
-00995                 }
-00996 
-00997                 if (bWasEndOfParagraph) {
-00998                         vStartOfParagraph1(pDiag, lBeforeIndentation);
-00999                 }
-01000 
-01001                 if (!bIsTableRow &&
-01002                     lTotalStringWidth(pAnchor) == 0) {
-01003                         if (!bNoMarks) {
-01004                                 usListNumber = usGetListValue(iListSeqNumber,
-01005                                                         iWordVersion,
-01006                                                         pStyleTmp);
-01007                         }
-01008                         if (bInList && bFirstLine) {
-01009                                 vStartOfListItem(pDiag, bNoMarks);
-01010                         }
-01011                         vPutIndentation(pDiag, pAnchor, bNoMarks, bFirstLine,
-01012                                         usListNumber, ucNFC, szListChar,
-01013                                         lLeftIndentation, lLeftIndentation1);
-01014                         bFirstLine = FALSE;
-01015                         /* One number or mark per paragraph will do */
-01016                         bNoMarks = TRUE;
-01017                 }
-01018 
-01019                 if (bWasEndOfParagraph) {
-01020                         vStartOfParagraph2(pDiag);
-01021                         bWasEndOfParagraph = FALSE;
-01022                 }
-01023 
-01024                 switch (ulChar) {
-01025                 case PICTURE:
-01026                         (void)memset(&tImage, 0, sizeof(tImage));
-01027                         eRes = eExamineImage(pFile, ulFileOffsetImage, &tImage);
-01028                         switch (eRes) {
-01029                         case image_no_information:
-01030                                 bSuccess = FALSE;
-01031                                 break;
-01032                         case image_minimal_information:
-01033                         case image_full_information:
-01034 #if 0
-01035                                 if (bOutputContainsText(pAnchor)) {
-01036                                         OUTPUT_LINE();
-01037                                 } else {
-01038                                         RESET_LINE();
-01039                                 }
-01040 #endif
-01041                                 bSuccess = bTranslateImage(pDiag, pFile,
-01042                                         eRes == image_minimal_information,
-01043                                         ulFileOffsetImage, &tImage);
-01044                                 break;
-01045                         default:
-01046                                 DBG_DEC(eRes);
-01047                                 bSuccess = FALSE;
-01048                                 break;
-01049                         }
-01050                         if (!bSuccess) {
-01051                                 vStoreString("[pic]", 5, pOutput);
-01052                         }
-01053                         break;
-01054                 case FOOTNOTE_CHAR:
-01055                         uiFootnoteNumber++;
-01056                         if (tOptions.eConversionType == conversion_xml) {
-01057                                 vStoreCharacter((ULONG)FOOTNOTE_OR_ENDNOTE,
-01058                                                                 pOutput);
-01059                                 break;
-01060                         }
-01061                         vStoreCharacter((ULONG)'[', pOutput);
-01062                         vStoreNumberAsDecimal(uiFootnoteNumber, pOutput);
-01063                         vStoreCharacter((ULONG)']', pOutput);
-01064                         break;
-01065                 case ENDNOTE_CHAR:
-01066                         uiEndnoteNumber++;
-01067                         vStoreCharacter((ULONG)'[', pOutput);
-01068                         vStoreNumberAsRoman(uiEndnoteNumber, pOutput);
-01069                         vStoreCharacter((ULONG)']', pOutput);
-01070                         break;
-01071                 case UNKNOWN_NOTE_CHAR:
-01072                         vStoreString("[?]", 3, pOutput);
-01073                         break;
-01074                 case PAR_END:
-01075                         if (bIsTableRow) {
-01076                                 vStoreCharacter((ULONG)'\n', pOutput);
-01077                                 break;
-01078                         }
-01079                         if (bOutputContainsText(pAnchor)) {
-01080                                 OUTPUT_LINE();
-01081                         } else {
-01082                                 vMove2NextLine(pDiag,
-01083                                         pOutput->tFontRef, pOutput->usFontSize);
-01084                                 RESET_LINE();
-01085                         }
-01086                         vEndOfParagraph(pDiag,
-01087                                         pOutput->tFontRef,
-01088                                         pOutput->usFontSize,
-01089                                         lAfterIndentation);
-01090                         bWasEndOfParagraph = TRUE;
-01091                         break;
-01092                 case HARD_RETURN:
-01093                         if (bIsTableRow) {
-01094                                 vStoreCharacter((ULONG)'\n', pOutput);
-01095                                 break;
-01096                         }
-01097                         if (bOutputContainsText(pAnchor)) {
-01098                                 OUTPUT_LINE();
-01099                         } else {
-01100                                 vMove2NextLine(pDiag,
-01101                                         pOutput->tFontRef, pOutput->usFontSize);
-01102                                 RESET_LINE();
-01103                         }
-01104                         break;
-01105                 case PAGE_BREAK:
-01106                 case COLUMN_FEED:
-01107                         pSection = pSectionNext;
-01108                         break;
-01109                 case TABLE_SEPARATOR:
-01110                         if (bIsTableRow) {
-01111                                 vStoreCharacter(ulChar, pOutput);
-01112                                 break;
-01113                         }
-01114                         vStoreCharacter((ULONG)' ', pOutput);
-01115                         vStoreCharacter((ULONG)TABLE_SEPARATOR_CHAR, pOutput);
-01116                         break;
-01117                 case TAB:
-01118                         if (bIsTableRow ||
-01119                             tOptions.eConversionType == conversion_xml) {
-01120                                 vStoreCharacter((ULONG)' ', pOutput);
-01121                                 break;
-01122                         }
-01123                         if (tOptions.iParagraphBreak == 0 &&
-01124                             (tOptions.eConversionType == conversion_text ||
-01125                              tOptions.eConversionType == conversion_fmt_text)) {
-01126                                 /* No logical lines, so no tab expansion */
-01127                                 vStoreCharacter(TAB, pOutput);
-01128                                 break;
-01129                         }
-01130                         lHalfSpaceWidth = (lComputeSpaceWidth(
-01131                                         pOutput->tFontRef,
-01132                                         pOutput->usFontSize) + 1) / 2;
-01133                         lTmp = lTotalStringWidth(pAnchor);
-01134                         lTmp += lDrawUnits2MilliPoints(pDiag->lXleft);
-01135                         lTmp /= lDefaultTabWidth;
-01136                         do {
-01137                                 vStoreCharacter((ULONG)FILLER_CHAR, pOutput);
-01138                                 lWidthCurr = lTotalStringWidth(pAnchor);
-01139                                 lWidthCurr +=
-01140                                         lDrawUnits2MilliPoints(pDiag->lXleft);
-01141                         } while (lTmp == lWidthCurr / lDefaultTabWidth &&
-01142                                  lWidthCurr < lWidthMax + lRightIndentation);
-01143                         break;
-01144                 default:
-01145                         if (bHiddenText && tOptions.bHideHiddenText) {
-01146                                 continue;
-01147                         }
-01148                         if (bMarkDelText && tOptions.bRemoveRemovedText) {
-01149                                 continue;
-01150                         }
-01151                         if (ulChar == UNICODE_ELLIPSIS &&
-01152                             tOptions.eEncoding != encoding_utf_8) {
-01153                                 vStoreString("...", 3, pOutput);
-01154                         } else {
-01155                                 if (bAllCapitals) {
-01156                                         ulChar = ulToUpper(ulChar);
-01157                                 }
-01158                                 vStoreCharacter(ulChar, pOutput);
-01159                         }
-01160                         break;
-01161                 }
-01162 
-01163                 if (bWasTableRow && !bIsTableRow) {
-01164                         /* End of a table */
-01165                         vEndOfTable(pDiag);
-01166                         /* Resume normal font */
-01167                         NO_DBG_MSG("End of table font");
-01168                         vCloseFont();
-01169                         bTableFontClosed = TRUE;
-01170                         pOutput->ucFontColor = ucFontColor;
-01171                         pOutput->usFontStyle = usFontStyle;
-01172                         pOutput->usFontSize = usFontSize;
-01173                         pOutput->tFontRef = tOpenFont(
-01174                                         ucFontNumber, usFontStyle, usFontSize);
-01175                 }
-01176                 bWasTableRow = bIsTableRow;
-01177 
-01178                 if (bIsTableRow) {
-01179                         fail(pAnchor != pOutput);
-01180                         if (!bEndRowNorm && !bEndRowFast) {
-01181                                 continue;
-01182                         }
-01183                         /* End of a table row */
-01184                         if (bEndRowNorm) {
-01185                                 fail(pRowInfo == NULL);
-01186                                 vTableRow2Window(pDiag, pAnchor, pRowInfo,
-01187                                                 tOptions.eConversionType,
-01188                                                 tOptions.iParagraphBreak);
-01189                         } else {
-01190                                 fail(!bEndRowFast);
-01191                         }
-01192                         /* Reset */
-01193                         pAnchor = pStartNewOutput(pAnchor, NULL);
-01194                         pOutput = pAnchor;
-01195                         if (bEndRowNorm) {
-01196                                 pRowInfo = pGetNextRowInfoListItem();
-01197                         }
-01198                         bIsTableRow = FALSE;
-01199                         bEndRowNorm = FALSE;
-01200                         bEndRowFast = FALSE;
-01201                         NO_DBG_HEX_C(pRowInfo != NULL,
-01202                                                 pRowInfo->ulFileOffsetStart);
-01203                         NO_DBG_HEX_C(pRowInfo != NULL,
-01204                                                 pRowInfo->ulFileOffsetEnd);
-01205                         continue;
-01206                 }
-01207                 lWidthCurr = lTotalStringWidth(pAnchor);
-01208                 lWidthCurr += lDrawUnits2MilliPoints(pDiag->lXleft);
-01209                 if (lWidthCurr < lWidthMax + lRightIndentation) {
-01210                         continue;
-01211                 }
-01212                 pLeftOver = pSplitList(pAnchor);
-01213                 vJustify2Window(pDiag, pAnchor,
-01214                                 lWidthMax, lRightIndentation, ucAlignment);
-01215                 pAnchor = pStartNewOutput(pAnchor, pLeftOver);
-01216                 for (pOutput = pAnchor;
-01217                      pOutput->pNext != NULL;
-01218                      pOutput = pOutput->pNext)
-01219                         ;       /* EMPTY */
-01220                 fail(pOutput == NULL);
-01221                 if (lTotalStringWidth(pAnchor) > 0) {
-01222                         vSetLeftIndentation(pDiag, lLeftIndentation);
-01223                 }
-01224         }
-01225 
-01226         pAnchor = pStartNewOutput(pAnchor, NULL);
-01227         pAnchor->szStorage = xfree(pAnchor->szStorage);
-01228         pAnchor = xfree(pAnchor);
-01229         vCloseFont();
-01230         vFreeDocument();
-01231         Hourglass_Off();
-01232         return TRUE;
-01233 } /* end of bWordDecryptor */
-01234 
-01235 /*
-01236  * lLastStringWidth - compute the width of the last part of the output string
-01237  */
-01238 static long
-01239 lLastStringWidth(const output_type *pAnchor)
-01240 {
-01241         const output_type       *pCurr, *pStart;
-01242 
-01243         pStart = NULL;
-01244         for (pCurr = pAnchor; pCurr != NULL; pCurr = pCurr->pNext) {
-01245                 if (pCurr->tNextFree == 1 &&
-01246                     (pCurr->szStorage[0] == PAR_END ||
-01247                      pCurr->szStorage[0] == HARD_RETURN)) {
-01248                         /* Found a separator. Start after the separator */
-01249                         pStart = pCurr->pNext;
-01250                 }
-01251         }
-01252         if (pStart == NULL) {
-01253                 /* No separators. Use the whole output string */
-01254                 pStart = pAnchor;
-01255         }
-01256         return lTotalStringWidth(pStart);
-01257 } /* end of lLastStringWidth */
-01258 
-01259 /*
-01260  * pHdrFtrDecryptor - turn a header/footer list element to something useful
-01261  */
-01262 output_type *
-01263 pHdrFtrDecryptor(FILE *pFile, ULONG ulCharPosStart, ULONG ulCharPosNext)
-01264 {
-01265         output_type     *pAnchor, *pOutput, *pLeftOver;
-01266         ULONG   ulChar, ulFileOffset, ulCharPos;
-01267         long    lWidthCurr, lWidthMax;
-01268         long    lRightIndentation;
-01269         USHORT  usChar;
-01270         UCHAR   ucAlignment;
-01271         BOOL    bSkip;
-01272 
-01273         fail(iWordVersion < 0);
-01274         fail(tOptions.eConversionType == conversion_unknown);
-01275         fail(tOptions.eEncoding == 0);
-01276 
-01277         if (ulCharPosStart == ulCharPosNext) {
-01278                 /* There are no bytes to decrypt */
-01279                 return NULL;
-01280         }
-01281 
-01282         lRightIndentation = 0;
-01283         ucAlignment = ALIGNMENT_LEFT;
-01284         bSkip = FALSE;
-01285         lWidthMax = lGetWidthMax(tOptions.iParagraphBreak);
-01286         pAnchor = pStartNewOutput(NULL, NULL);
-01287         pOutput = pAnchor;
-01288         pOutput->tFontRef = tOpenFont(0, FONT_REGULAR, DEFAULT_FONT_SIZE);
-01289         usChar = usToHdrFtrPosition(pFile, ulCharPosStart);
-01290         ulCharPos = ulCharPosStart;
-01291         ulFileOffset = ulCharPos2FileOffset(ulCharPos);
-01292         while (usChar != (USHORT)EOF && ulCharPos != ulCharPosNext) {
-01293                 /* Skip embedded characters */
-01294                 if (usChar == START_EMBEDDED) {
-01295                         bSkip = TRUE;
-01296                 } else if (usChar == END_IGNORE || usChar == END_EMBEDDED) {
-01297                         bSkip = FALSE;
-01298                 }
-01299                 /* Translate character */
-01300                 if (bSkip || usChar == END_IGNORE || usChar == END_EMBEDDED) {
-01301                         ulChar = IGNORE_CHARACTER;
-01302                 } else {
-01303                         ulChar = ulTranslateCharacters(usChar,
-01304                                         ulFileOffset,
-01305                                         iWordVersion,
-01306                                         tOptions.eConversionType,
-01307                                         tOptions.eEncoding,
-01308                                         bOldMacFile);
-01309                 }
-01310                 /* Process character */
-01311                 if (ulChar != IGNORE_CHARACTER) {
-01312                         switch (ulChar) {
-01313                         case PICTURE:
-01314                                 vStoreString("[pic]", 5, pOutput);
-01315                                 break;
-01316                         case PAR_END:
-01317                         case HARD_RETURN:
-01318                         case PAGE_BREAK:
-01319                         case COLUMN_FEED:
-01320                                 /* To the next substring */
-01321                                 pOutput = pStartNextOutput(pOutput);
-01322                                 vCloseFont();
-01323                                 pOutput->tFontRef = tOpenFont(0,
-01324                                         FONT_REGULAR, DEFAULT_FONT_SIZE);
-01325                                 /* A substring with just one character */
-01326                                 if (ulChar == HARD_RETURN) {
-01327                                         vStoreCharacter(HARD_RETURN, pOutput);
-01328                                 } else {
-01329                                         vStoreCharacter(PAR_END, pOutput);
-01330                                 }
-01331                                 /* To the next substring */
-01332                                 pOutput = pStartNextOutput(pOutput);
-01333                                 vCloseFont();
-01334                                 pOutput->tFontRef = tOpenFont(0,
-01335                                         FONT_REGULAR, DEFAULT_FONT_SIZE);
-01336                                 fail(!bCheckDoubleLinkedList(pAnchor));
-01337                                 break;
-01338                         case TABLE_SEPARATOR:
-01339                                 vStoreCharacter((ULONG)' ', pOutput);
-01340                                 vStoreCharacter((ULONG)TABLE_SEPARATOR_CHAR,
-01341                                                         pOutput);
-01342                                 break;
-01343                         case TAB:
-01344                                 vStoreCharacter((ULONG)FILLER_CHAR, pOutput);
-01345                                 break;
-01346                         default:
-01347                                 vStoreCharacter(ulChar, pOutput);
-01348                                 break;
-01349                         }
-01350                 }
-01351                 lWidthCurr = lLastStringWidth(pAnchor);
-01352                 if (lWidthCurr >= lWidthMax + lRightIndentation) {
-01353                         pLeftOver = pSplitList(pAnchor);
-01354                         for (pOutput = pAnchor;
-01355                              pOutput->pNext != NULL;
-01356                              pOutput = pOutput->pNext)
-01357                                 ;       /* EMPTY */
-01358                         fail(pOutput == NULL);
-01359                         /* To the next substring */
-01360                         pOutput = pStartNextOutput(pOutput);
-01361                         /* A substring with just one HARD_RETURN */
-01362                         vStoreCharacter(HARD_RETURN, pOutput);
-01363                         /* Put the leftover piece(s) at the end */
-01364                         pOutput->pNext = pLeftOver;
-01365                         if (pLeftOver != NULL) {
-01366                                 pLeftOver->pPrev = pOutput;
-01367                         }
-01368                         fail(!bCheckDoubleLinkedList(pAnchor));
-01369                         for (pOutput = pAnchor;
-01370                              pOutput->pNext != NULL;
-01371                              pOutput = pOutput->pNext)
-01372                                 ;       /* EMPTY */
-01373                         fail(pOutput == NULL);
-01374                 }
-01375                 usChar = usNextChar(pFile, hdrftr_list,
-01376                                         &ulFileOffset, &ulCharPos, NULL);
-01377         }
-01378         vCloseFont();
-01379         if (bOutputContainsText(pAnchor)) {
-01380                 return pAnchor;
-01381         }
-01382         pAnchor = pStartNewOutput(pAnchor, NULL);
-01383         pAnchor->szStorage = xfree(pAnchor->szStorage);
-01384         pAnchor = xfree(pAnchor);
-01385         return NULL;
-01386 } /* end of pHdrFtrDecryptor */
-01387 
-01388 /*
-01389  * pFootnoteDecryptor - turn a footnote text list element into text
-01390  */
-01391 char *
-01392 szFootnoteDecryptor(FILE *pFile, ULONG ulCharPosStart, ULONG ulCharPosNext)
-01393 {
-01394         char    *szText;
-01395         ULONG   ulChar, ulFileOffset, ulCharPos;
-01396         USHORT  usChar;
-01397         size_t  tLen, tIndex, tNextFree, tStorageSize;
-01398         char    szResult[6];
-01399         BOOL    bSkip;
-01400 
-01401         fail(iWordVersion < 0);
-01402         fail(tOptions.eConversionType == conversion_unknown);
-01403         fail(tOptions.eEncoding == 0);
-01404 
-01405         if (ulCharPosStart == ulCharPosNext) {
-01406                 /* There are no bytes to decrypt */
-01407                 return NULL;
-01408         }
-01409 
-01410         if (tOptions.eConversionType != conversion_xml) {
-01411                 /* Only implemented for XML output */
-01412                 return NULL;
-01413         }
-01414 
-01415         bSkip = FALSE;
-01416 
-01417         /* Initialise the text buffer */
-01418         tStorageSize = INITIAL_SIZE;
-01419         szText = xmalloc(tStorageSize);
-01420         tNextFree = 0;
-01421         szText[tNextFree] = '\0';
-01422 
-01423         /* Goto the start */
-01424         usChar = usToFootnotePosition(pFile, ulCharPosStart);
-01425         ulCharPos = ulCharPosStart;
-01426         ulFileOffset = ulCharPos2FileOffset(ulCharPos);
-01427         /* Skip the unwanted starting characters */
-01428         while (usChar != (USHORT)EOF && ulCharPos != ulCharPosNext &&
-01429                (usChar == FOOTNOTE_OR_ENDNOTE ||
-01430                 usChar == PAR_END ||
-01431                 usChar == TAB ||
-01432                 usChar == (USHORT)' ')) {
-01433                 usChar = usNextChar(pFile, footnote_list,
-01434                                         &ulFileOffset, &ulCharPos, NULL);
-01435         }
-01436         /* Process the footnote text */
-01437         while (usChar != (USHORT)EOF && ulCharPos != ulCharPosNext) {
-01438                 /* Skip embedded characters */
-01439                 if (usChar == START_EMBEDDED) {
-01440                         bSkip = TRUE;
-01441                 } else if (usChar == END_IGNORE || usChar == END_EMBEDDED) {
-01442                         bSkip = FALSE;
-01443                 }
-01444                 /* Translate character */
-01445                 if (bSkip ||
-01446                     usChar == END_IGNORE ||
-01447                     usChar == END_EMBEDDED ||
-01448                     usChar == FOOTNOTE_OR_ENDNOTE) {
-01449                         ulChar = IGNORE_CHARACTER;
-01450                 } else {
-01451                         ulChar = ulTranslateCharacters(usChar,
-01452                                         ulFileOffset,
-01453                                         iWordVersion,
-01454                                         tOptions.eConversionType,
-01455                                         tOptions.eEncoding,
-01456                                         bOldMacFile);
-01457                 }
-01458                 /* Process character */
-01459                 if (ulChar == PICTURE) {
-01460                         tLen = 5;
-01461                         strcpy(szResult, "[pic]");
-01462                 } else if (ulChar == IGNORE_CHARACTER) {
-01463                         tLen = 0;
-01464                         szResult[0] = '\0';
-01465                 } else {
-01466                         switch (ulChar) {
-01467                         case PAR_END:
-01468                         case HARD_RETURN:
-01469                         case PAGE_BREAK:
-01470                         case COLUMN_FEED:
-01471                                 ulChar = (ULONG)PAR_END;
-01472                                 break;
-01473                         case TAB:
-01474                                 ulChar = (ULONG)' ';
-01475                                 break;
-01476                         default:
-01477                                 break;
-01478                         }
-01479                         tLen = tUcs2Utf8(ulChar, szResult, sizeof(szResult));
-01480                 }
-01481                 /* Add the results to the text */
-01482                 if (tNextFree + tLen + 1 > tStorageSize) {
-01483                         tStorageSize += EXTENTION_SIZE;
-01484                         szText = xrealloc(szText, tStorageSize);
-01485                 }
-01486                 for (tIndex = 0; tIndex < tLen; tIndex++) {
-01487                         szText[tNextFree++] = szResult[tIndex];
-01488                 }
-01489                 szText[tNextFree] = '\0';
-01490                 /* Next character */
-01491                 usChar = usNextChar(pFile, footnote_list,
-01492                                         &ulFileOffset, &ulCharPos, NULL);
-01493         }
-01494         /* Remove redundant spaces */
-01495         while (tNextFree != 0 && szText[tNextFree - 1] == ' ') {
-01496                 szText[tNextFree - 1] = '\0';
-01497                 tNextFree--;
-01498         }
-01499         if (tNextFree == 0) {
-01500                 /* No text */
-01501                 szText = xfree(szText);
-01502                 return NULL;
-01503         }
-01504         return szText;
-01505 } /* end of szFootnoteDecryptor */
-
-
Generated by  - -doxygen 1.6.2
- - diff -r 59758314f811 -r d4524d6a4472 Symbian3/Examples/guid-6013a680-57f9-415b-8851-c4fa63356636/wordconst_8h_source.html --- a/Symbian3/Examples/guid-6013a680-57f9-415b-8851-c4fa63356636/wordconst_8h_source.html Fri Jun 11 15:24:34 2010 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,337 +0,0 @@ - - - - -TB9.2 Example Applications: examples/PIPS/antiword/inc/wordconst.h Source File - - - - - -

examples/PIPS/antiword/inc/wordconst.h

00001 /*
-00002  * wordconst.h
-00003  * Copyright (C) 1998-2004 A.J. van Os; Released under GNU GPL
-00004  *
-00005  * Description:
-00006  * Constants and macros for the interpretation of MS Word files
-00007  */
-00008 
-00009 #if !defined(__wordconst_h)
-00010 #define __wordconst_h 1
-00011 
-00012 /*
-00013  * A bit odd definition of the type Boolean, but RISC OS insists
-00014  * on this and Linux/Unix doesn't mind.
-00015  */
-00016 #if !defined(BOOL)
-00017 #define BOOL int
-00018 #define TRUE 1
-00019 #define FALSE 0
-00020 #endif /* !BOOL */
-00021 
-00022 /* Block sizes */
-00023 #define HEADER_SIZE                     768
-00024 #define BIG_BLOCK_SIZE                  512
-00025 #define PROPERTY_SET_STORAGE_SIZE       128
-00026 #define SMALL_BLOCK_SIZE                 64
-00027 /* Switch size of Depot use */
-00028 #define MIN_SIZE_FOR_BBD_USE            0x1000
-00029 /* Table sizes */
-00030 #define TABLE_COLUMN_MAX                 31
-00031 /* Maximum number of tabs positions in a paragraph */
-00032 #define NUMBER_OF_TABS_MAX               64
-00033 /* Font sizes (in half-points) */
-00034 #define MIN_FONT_SIZE                     8
-00035 #define DEFAULT_FONT_SIZE                20
-00036 #define MAX_FONT_SIZE                   240
-00037 #define MIN_TABLEFONT_SIZE               16
-00038 #define MAX_TABLEFONT_SIZE               20
-00039 /* Font styles */
-00040 #define FONT_REGULAR                    0x0000
-00041 #define FONT_BOLD                       0x0001
-00042 #define FONT_ITALIC                     0x0002
-00043 #define FONT_UNDERLINE                  0x0004
-00044 #define FONT_CAPITALS                   0x0008
-00045 #define FONT_SMALL_CAPITALS             0x0010
-00046 #define FONT_STRIKE                     0x0020
-00047 #define FONT_HIDDEN                     0x0040
-00048 #define FONT_MARKDEL                    0x0080
-00049 #define FONT_SUPERSCRIPT                0x0100
-00050 #define FONT_SUBSCRIPT                  0x0200
-00051 /* Font colors */
-00052 #define FONT_COLOR_DEFAULT               0
-00053 #define FONT_COLOR_BLACK                 1
-00054 #define FONT_COLOR_BLUE                  2
-00055 #define FONT_COLOR_CYAN                  3
-00056 #define FONT_COLOR_GREEN                 4
-00057 #define FONT_COLOR_MAGENTA               5
-00058 #define FONT_COLOR_RED                   6
-00059 #define FONT_COLOR_YELLOW                7
-00060 #define FONT_COLOR_WHITE                 8
-00061 /* Special block numbers */
-00062 #define END_OF_CHAIN                    0xfffffffeUL
-00063 #define UNUSED_BLOCK                    0xffffffffUL
-00064 /* Blocksize (512 bytes) and maximum filesize (4 GB) gives 0..7fffff */
-00065 #define MAX_BLOCKNUMBER                 0x007fffffUL
-00066 /* Invalid character position */
-00067 #define CP_INVALID                      0xffffffffUL
-00068 /* Invalid file offset */
-00069 #define FC_INVALID                      0xffffffffUL
-00070 /* Special istd values */
-00071 #define ISTD_INVALID                    USHRT_MAX
-00072 #define ISTD_NORMAL                     0
-00073 /* Properties modifier without value */
-00074 #define IGNORE_PROPMOD                  0
-00075 /* Types of lists */
-00076 #define LIST_ARABIC_NUM                 0x00
-00077 #define LIST_UPPER_ROMAN                0x01
-00078 #define LIST_LOWER_ROMAN                0x02
-00079 #define LIST_UPPER_ALPHA                0x03
-00080 #define LIST_LOWER_ALPHA                0x04
-00081 #define LIST_ORDINAL_NUM                0x05
-00082 #define LIST_NUMBER_TXT                 0x06
-00083 #define LIST_ORDINAL_TXT                0x07
-00084 #define LIST_OUTLINE_NUM                0x16
-00085 #define LIST_SPECIAL                    0x17
-00086 #define LIST_SPECIAL2                   0x19
-00087 #define LIST_BULLETS                    0xff
-00088 /* Types of paragraph alignment */
-00089 #define ALIGNMENT_LEFT                  0x00
-00090 #define ALIGNMENT_CENTER                0x01
-00091 #define ALIGNMENT_RIGHT                 0x02
-00092 #define ALIGNMENT_JUSTIFY               0x03
-00093 /* Minimum vertical space before and after a heading line */
-00094 #define HEADING_GAP                     120     /* twips */
-00095 /* Style identifier */
-00096 #define STI_USER                        0xffe
-00097 #define STI_NIL                         0xfff
-00098 /* Table border style codes */
-00099 #define TABLE_BORDER_TOP                0x01
-00100 #define TABLE_BORDER_LEFT               0x02
-00101 #define TABLE_BORDER_BOTTOM             0x04
-00102 #define TABLE_BORDER_RIGHT              0x08
-00103 
-00104 /* Macros */
-00105         /* Get macros */
-00106 #define ucGetByte(i,a)          ((unsigned char)(a[i]))
-00107 #define usGetWord(i,a)          ((unsigned short)\
-00108                                         ((unsigned int)(a[(i)+1])<<8|\
-00109                                          (unsigned int)(a[i])))
-00110 #define ulGetLong(i,a)          ((unsigned long)(a[i])|\
-00111                                         (unsigned long)(a[(i)+1])<<8|\
-00112                                         (unsigned long)(a[(i)+2])<<16|\
-00113                                         (unsigned long)(a[(i)+3])<<24)
-00114 #define usGetWordBE(i,a)        ((unsigned short)\
-00115                                         ((unsigned int)(a[i])<<8|\
-00116                                          (unsigned int)(a[(i)+1])))
-00117 #define ulGetLongBE(i,a)        ((unsigned long)(a[(i)+3])|\
-00118                                         (unsigned long)(a[(i)+2])<<8|\
-00119                                         (unsigned long)(a[(i)+1])<<16|\
-00120                                         (unsigned long)(a[i])<<24)
-00121         /* Font style macros */
-00122 #define bIsBold(x)              (((x) & FONT_BOLD) == FONT_BOLD)
-00123 #define bIsItalic(x)            (((x) & FONT_ITALIC) == FONT_ITALIC)
-00124 #define bIsUnderline(x)         (((x) & FONT_UNDERLINE) == FONT_UNDERLINE)
-00125 #define bIsCapitals(x)          (((x) & FONT_CAPITALS) == FONT_CAPITALS)
-00126 #define bIsSmallCapitals(x)     (((x) & FONT_SMALL_CAPITALS) == FONT_SMALL_CAPITALS)
-00127 #define bIsStrike(x)            (((x) & FONT_STRIKE) == FONT_STRIKE)
-00128 #define bIsHidden(x)            (((x) & FONT_HIDDEN) == FONT_HIDDEN)
-00129 #define bIsMarkDel(x)           (((x) & FONT_MARKDEL) == FONT_MARKDEL)
-00130 #define bIsSuperscript(x)       (((x) & FONT_SUPERSCRIPT) == FONT_SUPERSCRIPT)
-00131 #define bIsSubscript(x)         (((x) & FONT_SUBSCRIPT) == FONT_SUBSCRIPT)
-00132         /* Table border style code macros */
-00133 #define bIsTableBorderTop(x)    (((x) & TABLE_BORDER_TOP) == TABLE_BORDER_TOP)
-00134 #define bIsTableBorderLeft(x)   (((x) & TABLE_BORDER_LEFT) == TABLE_BORDER_LEFT)
-00135 #define bIsTableBorderBottom(x) (((x) & TABLE_BORDER_BOTTOM) == TABLE_BORDER_BOTTOM)
-00136 #define bIsTableBorderRight(x)  (((x) & TABLE_BORDER_RIGHT) == TABLE_BORDER_RIGHT)
-00137         /* Computation macros */
-00138 #if defined(__riscos)
-00139 /* From Words half-points to draw units (plus a percentage) */
-00140 #define lWord2DrawUnits00(x)    ((long)(x) * 320)
-00141 #define lWord2DrawUnits20(x)    ((long)(x) * 384)
-00142 #define lToBaseLine(x)          ((long)(x) *  45)
-00143 #endif /* __riscos */
-00144 /* From twips (1/20 of a point) to millipoints */
-00145 #define lTwips2MilliPoints(x)   ((long)(x) * 50)
-00146 /* From twips (1/20 of a point) to points */
-00147 #define dTwips2Points(x)        ((double)(x) / 20.0)
-00148 /* From default characters (16 OS units wide) to millipoints */
-00149 #define lChar2MilliPoints(x)    ((long)(x) * 6400)
-00150 #define iMilliPoints2Char(x)    (int)(((long)(x) + 3200) / 6400)
-00151 #define iDrawUnits2Char(x)      (int)(((long)(x) + 2048) / 4096)
-00152 /* From draw units (1/180*256 inch) to millipoints (1/72*1000 inch) */
-00153 #define lDrawUnits2MilliPoints(x)       (((long)(x) * 25 +  8) / 16)
-00154 #define lMilliPoints2DrawUnits(x)       (((long)(x) * 16 + 12) / 25)
-00155 #define lPoints2DrawUnits(x)            ((long)(x) * 640)
-00156 #define dDrawUnits2Points(x)            ((double)(x) / 640.0)
-00157 
-00158 /* Special characters */
-00159 #define IGNORE_CHARACTER        0x00    /* ^@ */
-00160 #define PICTURE                 0x01    /* ^A */
-00161 #define FOOTNOTE_OR_ENDNOTE     0x02    /* ^B */
-00162 #define FOOTNOTE_SEPARATOR      0x03    /* ^C */
-00163 #define FOOTNOTE_CONTINUATION   0x04    /* ^D */
-00164 #define ANNOTATION              0x05    /* ^E */
-00165 #define TABLE_SEPARATOR         0x07    /* ^G */
-00166 #define FRAME                   0x08    /* ^H */
-00167 #define TAB                     0x09    /* ^I */
-00168 /* End of line characters */
-00169 #define LINE_FEED               0x0a    /* ^J */
-00170 #define HARD_RETURN             0x0b    /* ^K */
-00171 #define PAGE_BREAK              0x0c    /* ^L */
-00172 #define PAR_END                 0x0d    /* ^M */
-00173 #define COLUMN_FEED             0x0e    /* ^N */
-00174 /* Embedded stuff */
-00175 #define START_EMBEDDED          0x13    /* ^S */
-00176 #define END_IGNORE              0x14    /* ^T */
-00177 #define END_EMBEDDED            0x15    /* ^U */
-00178 /* Special characters */
-00179 #if defined(DEBUG)
-00180 #define FILLER_CHAR             '~'
-00181 #else
-00182 #define FILLER_CHAR             ' '
-00183 #endif /* DEBUG */
-00184 #define TABLE_SEPARATOR_CHAR    '|'
-00185 /* Pseudo characters. These must be outside the Unicode range */
-00186 #define FOOTNOTE_CHAR           ((unsigned long)0xffff + 1)
-00187 #define ENDNOTE_CHAR            ((unsigned long)0xffff + 2)
-00188 #define UNKNOWN_NOTE_CHAR       ((unsigned long)0xffff + 3)
-00189 
-00190 /* Charactercodes as used by Word */
-00191 #define WORD_UNBREAKABLE_JOIN           0x1e
-00192 #define WORD_SOFT_HYPHEN                0x1f
-00193 
-00194 /* Unicode characters */
-00195 #define UNICODE_DOUBLE_LEFT_ANGLE_QMARK 0x00ab
-00196 #define UNICODE_MIDDLE_DOT              0x00b7
-00197 #define UNICODE_DOUBLE_RIGHT_ANGLE_QMARK        0x00bb
-00198 #define UNICODE_CAPITAL_D_WITH_STROKE   0x0110
-00199 #define UNICODE_SMALL_D_WITH_STROKE     0x0111
-00200 #define UNICODE_CAPITAL_LIGATURE_OE     0x0152
-00201 #define UNICODE_SMALL_LIGATURE_OE       0x0153
-00202 #define UNICODE_SMALL_F_HOOK            0x0192
-00203 #define UNICODE_GREEK_CAPITAL_CHI       0x03a7
-00204 #define UNICODE_GREEK_SMALL_UPSILON     0x03c5
-00205 #define UNICODE_MODIFIER_CIRCUMFLEX     0x02c6
-00206 #define UNICODE_SMALL_TILDE             0x02dc
-00207 #define UNICODE_SMALL_LETTER_OMEGA      0x03c9
-00208 #define UNICODE_EN_QUAD                 0x2000
-00209 #define UNICODE_EM_QUAD                 0x2001
-00210 #define UNICODE_EN_SPACE                0x2002
-00211 #define UNICODE_EM_SPACE                0x2003
-00212 #define UNICODE_THREE_PER_EM_SPACE      0x2004
-00213 #define UNICODE_FOUR_PER_EM_SPACE       0x2005
-00214 #define UNICODE_SIX_PER_EM_SPACE        0x2006
-00215 #define UNICODE_FIGURE_SPACE            0x2007
-00216 #define UNICODE_PUNCTUATION_SPACE       0x2008
-00217 #define UNICODE_THIN_SPACE              0x2009
-00218 #define UNICODE_HAIR_SPACE              0x200a
-00219 #define UNICODE_ZERO_WIDTH_SPACE        0x200b
-00220 #define UNICODE_ZERO_WIDTH_NON_JOINER   0x200c
-00221 #define UNICODE_ZERO_WIDTH_JOINER       0x200d
-00222 #define UNICODE_LEFT_TO_RIGHT_MARK      0x200e
-00223 #define UNICODE_RIGHT_TO_LEFT_MARK      0x200f
-00224 #define UNICODE_HYPHEN                  0x2010
-00225 #define UNICODE_NON_BREAKING_HYPHEN     0x2011
-00226 #define UNICODE_FIGURE_DASH             0x2012
-00227 #define UNICODE_EN_DASH                 0x2013
-00228 #define UNICODE_EM_DASH                 0x2014
-00229 #define UNICODE_HORIZONTAL_BAR          0x2015
-00230 #define UNICODE_DOUBLE_VERTICAL_LINE    0x2016
-00231 #define UNICODE_DOUBLE_LOW_LINE         0x2017
-00232 #define UNICODE_LEFT_SINGLE_QMARK       0x2018
-00233 #define UNICODE_RIGHT_SINGLE_QMARK      0x2019
-00234 #define UNICODE_SINGLE_LOW_9_QMARK      0x201a
-00235 #define UNICODE_SINGLE_HIGH_REV_9_QMARK 0x201b
-00236 #define UNICODE_LEFT_DOUBLE_QMARK       0x201c
-00237 #define UNICODE_RIGHT_DOUBLE_QMARK      0x201d
-00238 #define UNICODE_DOUBLE_LOW_9_QMARK      0x201e
-00239 #define UNICODE_DOUBLE_HIGH_REV_9_QMARK 0x201f
-00240 #define UNICODE_DAGGER                  0x2020
-00241 #define UNICODE_DOUBLE_DAGGER           0x2021
-00242 #define UNICODE_BULLET                  0x2022
-00243 #define UNICODE_TRIANGULAR_BULLET       0x2023
-00244 #define UNICODE_ONE_DOT_LEADER          0x2024
-00245 #define UNICODE_TWO_DOT_LEADER          0x2025
-00246 #define UNICODE_ELLIPSIS                0x2026
-00247 #define UNICODE_HYPHENATION_POINT       0x2027
-00248 #define UNICODE_LEFT_TO_RIGHT_EMBEDDING 0x202a
-00249 #define UNICODE_RIGHT_TO_LEFT_EMBEDDING 0x202b
-00250 #define UNICODE_POP_DIRECTIONAL_FORMATTING      0x202c
-00251 #define UNICODE_LEFT_TO_RIGHT_OVERRIDE  0x202d
-00252 #define UNICODE_RIGHT_TO_LEFT_OVERRIDE  0x202e
-00253 #define UNICODE_NARROW_NO_BREAK_SPACE   0x202f
-00254 #define UNICODE_PER_MILLE_SIGN          0x2030
-00255 #define UNICODE_PRIME                   0x2032
-00256 #define UNICODE_DOUBLE_PRIME            0x2033
-00257 #define UNICODE_SINGLE_LEFT_ANGLE_QMARK 0x2039
-00258 #define UNICODE_SINGLE_RIGHT_ANGLE_QMARK        0x203a
-00259 #define UNICODE_UNDERTIE                0x203f
-00260 #define UNICODE_FRACTION_SLASH          0x2044
-00261 #define UNICODE_EURO_SIGN               0x20ac
-00262 #define UNICODE_CIRCLE                  0x20dd
-00263 #define UNICODE_SQUARE                  0x20de
-00264 #define UNICODE_DIAMOND                 0x20df
-00265 #define UNICODE_NUMERO_SIGN             0x2116
-00266 #define UNICODE_TRADEMARK_SIGN          0x2122
-00267 #define UNICODE_KELVIN_SIGN             0x212a
-00268 #define UNICODE_LEFTWARDS_ARROW         0x2190
-00269 #define UNICODE_UPWARDS_ARROW           0x2191
-00270 #define UNICODE_RIGHTWARDS_ARROW        0x2192
-00271 #define UNICODE_DOWNWARDS_ARROW         0x2193
-00272 #define UNICODE_N_ARY_SUMMATION         0x2211
-00273 #define UNICODE_MINUS_SIGN              0x2212
-00274 #define UNICODE_DIVISION_SLASH          0x2215
-00275 #define UNICODE_ASTERISK_OPERATOR       0x2217
-00276 #define UNICODE_BULLET_OPERATOR         0x2219
-00277 #define UNICODE_RATIO                   0x2236
-00278 #define UNICODE_TILDE_OPERATOR          0x223c
-00279 #define UNICODE_BD_LIGHT_HORIZONTAL     0x2500
-00280 #define UNICODE_BD_LIGHT_VERTICAL       0x2502
-00281 #define UNICODE_BD_LIGHT_DOWN_RIGHT     0x250c
-00282 #define UNICODE_BD_LIGHT_DOWN_AND_LEFT  0x2510
-00283 #define UNICODE_BD_LIGHT_UP_AND_RIGHT   0x2514
-00284 #define UNICODE_BD_LIGHT_UP_AND_LEFT    0x2518
-00285 #define UNICODE_BD_LIGHT_VERTICAL_AND_RIGHT     0x251c
-00286 #define UNICODE_BD_LIGHT_VERTICAL_AND_LEFT      0x2524
-00287 #define UNICODE_BD_LIGHT_DOWN_AND_HORIZONTAL    0x252c
-00288 #define UNICODE_BD_LIGHT_UP_AND_HORIZONTAL      0x2534
-00289 #define UNICODE_BD_LIGHT_VERTICAL_AND_HORIZONTAL        0x253c
-00290 #define UNICODE_BD_DOUBLE_HORIZONTAL    0x2550
-00291 #define UNICODE_BD_DOUBLE_VERTICAL      0x2551
-00292 #define UNICODE_BD_DOUBLE_DOWN_AND_RIGHT        0x2554
-00293 #define UNICODE_BD_DOUBLE_DOWN_AND_LEFT 0x2557
-00294 #define UNICODE_BD_DOUBLE_UP_AND_RIGHT  0x255a
-00295 #define UNICODE_BD_DOUBLE_UP_AND_LEFT   0x255d
-00296 #define UNICODE_BD_DOUBLE_VERTICAL_AND_RIGHT    0x2560
-00297 #define UNICODE_BD_DOUBLE_VERTICAL_AND_LEFT     0x2563
-00298 #define UNICODE_BD_DOUBLE_DOWN_AND_HORIZONTAL   0x2566
-00299 #define UNICODE_BD_DOUBLE_UP_AND_HORIZONTAL     0x2569
-00300 #define UNICODE_BD_DOUBLE_VERTICAL_AND_HORIZONTAL       0x256c
-00301 #define UNICODE_LIGHT_SHADE             0x2591
-00302 #define UNICODE_MEDIUM_SHADE            0x2592
-00303 #define UNICODE_DARK_SHADE              0x2593
-00304 #define UNICODE_BLACK_SQUARE            0x25a0
-00305 #define UNICODE_BLACK_CLUB_SUIT         0x2663
-00306 #define UNICODE_SMALL_LIGATURE_FI       0xfb01
-00307 #define UNICODE_SMALL_LIGATURE_FL       0xfb02
-00308 #define UNICODE_ZERO_WIDTH_NO_BREAK_SPACE       0xfeff
-00309 
-00310 #if defined(__riscos)
-00311 #define OUR_ELLIPSIS                    0x8c
-00312 #define OUR_EM_DASH                     0x98
-00313 #define OUR_UNBREAKABLE_JOIN            0x99
-00314 #else
-00315 #define OUR_ELLIPSIS                    '.'
-00316 #define OUR_EM_DASH                     '-'
-00317 #define OUR_UNBREAKABLE_JOIN            '-'
-00318 #endif /* __riscos */
-00319 #define OUR_DIAMOND                     '-'
-00320 
-00321 #endif /* __wordconst_h */
-
-
Generated by  - -doxygen 1.6.2
- - diff -r 59758314f811 -r d4524d6a4472 Symbian3/Examples/guid-6013a680-57f9-415b-8851-c4fa63356636/worddos_8c_source.html --- a/Symbian3/Examples/guid-6013a680-57f9-415b-8851-c4fa63356636/worddos_8c_source.html Fri Jun 11 15:24:34 2010 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,126 +0,0 @@ - - - - -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
- - diff -r 59758314f811 -r d4524d6a4472 Symbian3/Examples/guid-6013a680-57f9-415b-8851-c4fa63356636/wordlib_8c_source.html --- a/Symbian3/Examples/guid-6013a680-57f9-415b-8851-c4fa63356636/wordlib_8c_source.html Fri Jun 11 15:24:34 2010 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,375 +0,0 @@ - - - - -TB9.2 Example Applications: examples/PIPS/antiword/src/wordlib.c Source File - - - - - -

examples/PIPS/antiword/src/wordlib.c

00001 /*
-00002  * wordlib.c
-00003  * Copyright (C) 1998-2004 A.J. van Os; Released under GNU GPL
-00004  *
-00005  * Description:
-00006  * Deal with the internals of a MS Word file
-00007  */
-00008 
-00009 #include "antiword.h"
-00010 
-00011 static BOOL     bOldMacFile = FALSE;
-00012 
-00013 
-00014 /*
-00015  * Common part of the file checking functions
-00016  */
-00017 static BOOL
-00018 bCheckBytes(FILE *pFile, const UCHAR *aucBytes, size_t tBytes)
-00019 {
-00020         int     iIndex, iChar;
-00021 
-00022         fail(pFile == NULL || aucBytes == NULL || tBytes == 0);
-00023 
-00024         rewind(pFile);
-00025 
-00026         for (iIndex = 0; iIndex < (int)tBytes; iIndex++) {
-00027                 iChar = getc(pFile);
-00028                 if (iChar == EOF || iChar != (int)aucBytes[iIndex]) {
-00029                         NO_DBG_HEX(iChar);
-00030                         NO_DBG_HEX(aucBytes[iIndex]);
-00031                         return FALSE;
-00032                 }
-00033         }
-00034         return TRUE;
-00035 } /* end of bCheckBytes */
-00036 
-00037 /*
-00038  * This function checks whether the given file is or is not a "Word for DOS"
-00039  * document
-00040  */
-00041 BOOL
-00042 bIsWordForDosFile(FILE *pFile, long lFilesize)
-00043 {
-00044         static UCHAR    aucBytes[] =
-00045                 { 0x31, 0xbe, 0x00, 0x00, 0x00, 0xab }; /* Word for DOS */
-00046 
-00047         DBG_MSG("bIsWordForDosFile");
-00048 
-00049         if (pFile == NULL || lFilesize < 0) {
-00050                 DBG_MSG("No proper file given");
-00051                 return FALSE;
-00052         }
-00053         if (lFilesize < 128) {
-00054                 DBG_MSG("File too small to be a Word document");
-00055                 return FALSE;
-00056         }
-00057         return bCheckBytes(pFile, aucBytes, elementsof(aucBytes));
-00058 } /* end of bIsWordForDosFile */
-00059 
-00060 /*
-00061  * This function checks whether the given file is or is not a file with an
-00062  * OLE envelope (That is a document made by Word 6 or later)
-00063  */
-00064 static BOOL
-00065 bIsWordFileWithOLE(FILE *pFile, long lFilesize)
-00066 {
-00067         static UCHAR    aucBytes[] =
-00068                 { 0xd0, 0xcf, 0x11, 0xe0, 0xa1, 0xb1, 0x1a, 0xe1 };
-00069         int     iTailLen;
-00070 
-00071         if (pFile == NULL || lFilesize < 0) {
-00072                 DBG_MSG("No proper file given");
-00073                 return FALSE;
-00074         }
-00075         if (lFilesize < (long)BIG_BLOCK_SIZE * 3) {
-00076                 DBG_MSG("This file is too small to be a Word document");
-00077                 return FALSE;
-00078         }
-00079 
-00080         iTailLen = (int)(lFilesize % BIG_BLOCK_SIZE);
-00081         switch (iTailLen) {
-00082         case 0:         /* No tail, as it should be */
-00083                 break;
-00084         case 1:
-00085         case 2:         /* Filesize mismatch or a buggy email program */
-00086                 if ((int)(lFilesize % 3) == iTailLen) {
-00087                         DBG_DEC(lFilesize);
-00088                         return FALSE;
-00089                 }
-00090                 /*
-00091                  * Ignore extra bytes caused by buggy email programs.
-00092                  * They have bugs in their base64 encoding or decoding.
-00093                  * 3 bytes -> 4 ascii chars -> 3 bytes
-00094                  */
-00095                 DBG_MSG("Document with extra bytes");
-00096                 break;
-00097         default:        /* Wrong filesize for a Word document */
-00098                 DBG_DEC(lFilesize);
-00099                 DBG_DEC(iTailLen);
-00100                 return FALSE;
-00101         }
-00102         return bCheckBytes(pFile, aucBytes, elementsof(aucBytes));
-00103 } /* end of bIsWordFileWithOLE */
-00104 
-00105 /*
-00106  * This function checks whether the given file is or is not a RTF document
-00107  */
-00108 BOOL
-00109 bIsRtfFile(FILE *pFile)
-00110 {
-00111         static UCHAR    aucBytes[] =
-00112                 { '{', '\\', 'r', 't', 'f', '1' };
-00113 
-00114         DBG_MSG("bIsRtfFile");
-00115 
-00116         return bCheckBytes(pFile, aucBytes, elementsof(aucBytes));
-00117 } /* end of bIsRtfFile */
-00118 
-00119 /*
-00120  * This function checks whether the given file is or is not a WP document
-00121  */
-00122 BOOL
-00123 bIsWordPerfectFile(FILE *pFile)
-00124 {
-00125         static UCHAR    aucBytes[] =
-00126                 { 0xff, 'W', 'P', 'C' };
-00127 
-00128         DBG_MSG("bIsWordPerfectFile");
-00129 
-00130         return bCheckBytes(pFile, aucBytes, elementsof(aucBytes));
-00131 } /* end of bIsWordPerfectFile */
-00132 
-00133 /*
-00134  * This function checks whether the given file is or is not a "Win Word 1 or 2"
-00135  * document
-00136  */
-00137 BOOL
-00138 bIsWinWord12File(FILE *pFile, long lFilesize)
-00139 {
-00140         static UCHAR    aucBytes[2][4] = {
-00141                 { 0x9b, 0xa5, 0x21, 0x00 },     /* Win Word 1.x */
-00142                 { 0xdb, 0xa5, 0x2d, 0x00 },     /* Win Word 2.0 */
-00143         };
-00144         int     iIndex;
-00145 
-00146         DBG_MSG("bIsWinWord12File");
-00147 
-00148         if (pFile == NULL || lFilesize < 0) {
-00149                 DBG_MSG("No proper file given");
-00150                 return FALSE;
-00151         }
-00152         if (lFilesize < 384) {
-00153                 DBG_MSG("This file is too small to be a Word document");
-00154                 return FALSE;
-00155         }
-00156 
-00157         for (iIndex = 0; iIndex < (int)elementsof(aucBytes); iIndex++) {
-00158                 if (bCheckBytes(pFile,
-00159                                 aucBytes[iIndex],
-00160                                 elementsof(aucBytes[iIndex]))) {
-00161                         return TRUE;
-00162                 }
-00163         }
-00164         return FALSE;
-00165 } /* end of bIsWinWord12File */
-00166 
-00167 /*
-00168  * This function checks whether the given file is or is not a "Mac Word 4 or 5"
-00169  * document
-00170  */
-00171 BOOL
-00172 bIsMacWord45File(FILE *pFile)
-00173 {
-00174         static UCHAR    aucBytes[2][6] = {
-00175                 { 0xfe, 0x37, 0x00, 0x1c, 0x00, 0x00 }, /* Mac Word 4 */
-00176                 { 0xfe, 0x37, 0x00, 0x23, 0x00, 0x00 }, /* Mac Word 5 */
-00177         };
-00178         int     iIndex;
-00179 
-00180         DBG_MSG("bIsMacWord45File");
-00181 
-00182         for (iIndex = 0; iIndex < (int)elementsof(aucBytes); iIndex++) {
-00183                 if (bCheckBytes(pFile,
-00184                                 aucBytes[iIndex],
-00185                                 elementsof(aucBytes[iIndex]))) {
-00186                         return TRUE;
-00187                 }
-00188         }
-00189         return FALSE;
-00190 } /* end of bIsMacWord45File */
-00191 
-00192 /*
-00193  * iGuessVersionNumber - guess the Word version number from first few bytes
-00194  *
-00195  * Returns the guessed version number or -1 when no guess it possible
-00196  */
-00197 int
-00198 iGuessVersionNumber(FILE *pFile, long lFilesize)
-00199 {
-00200         if(bIsWordForDosFile(pFile, lFilesize)) {
-00201                 return 0;
-00202         }
-00203         if (bIsWinWord12File(pFile, lFilesize)) {
-00204                 return 2;
-00205         }
-00206         if (bIsMacWord45File(pFile)) {
-00207                 return 5;
-00208         }
-00209         if (bIsWordFileWithOLE(pFile, lFilesize)) {
-00210                 return 6;
-00211         }
-00212         return -1;
-00213 } /* end of iGuessVersionNumber */
-00214 
-00215 /*
-00216  * iGetVersionNumber - get the Word version number from the header
-00217  *
-00218  * Returns the version number or -1 when unknown
-00219  */
-00220 int
-00221 iGetVersionNumber(const UCHAR *aucHeader)
-00222 {
-00223         USHORT  usFib, usChse;
-00224 
-00225         usFib = usGetWord(0x02, aucHeader);
-00226         if (usFib >= 0x1000) {
-00227                 /* To big: must be MacWord using Big Endian */
-00228                 DBG_HEX(usFib);
-00229                 usFib = usGetWordBE(0x02, aucHeader);
-00230         }
-00231         DBG_DEC(usFib);
-00232         bOldMacFile = FALSE;
-00233         switch (usFib) {
-00234         case   0:
-00235                 DBG_MSG("Word for DOS");
-00236                 return 0;
-00237         case  28:
-00238                 DBG_MSG("Word 4 for Macintosh");
-00239                 bOldMacFile = TRUE;
-00240                 return 4;
-00241         case  33:
-00242                 DBG_MSG("Word 1.x for Windows");
-00243                 return 1;
-00244         case  35:
-00245                 DBG_MSG("Word 5 for Macintosh");
-00246                 bOldMacFile = TRUE;
-00247                 return 5;
-00248         case  45:
-00249                 DBG_MSG("Word 2 for Windows");
-00250                 return 2;
-00251         case 101:
-00252         case 102:
-00253                 DBG_MSG("Word 6 for Windows");
-00254                 return 6;
-00255         case 103:
-00256         case 104:
-00257                 usChse = usGetWord(0x14, aucHeader);
-00258                 DBG_DEC(usChse);
-00259                 switch (usChse) {
-00260                 case 0:
-00261                         DBG_MSG("Word 7 for Win95");
-00262                         return 7;
-00263                 case 256:
-00264                         DBG_MSG("Word 6 for Macintosh");
-00265                         bOldMacFile = TRUE;
-00266                         return 6;
-00267                 default:
-00268                         DBG_FIXME();
-00269                         if ((int)ucGetByte(0x05, aucHeader) == 0xe0) {
-00270                                 DBG_MSG("Word 7 for Win95");
-00271                                 return 7;
-00272                         }
-00273                         DBG_MSG("Word 6 for Macintosh");
-00274                         bOldMacFile = TRUE;
-00275                         return 6;
-00276                 }
-00277         default:
-00278                 usChse = usGetWord(0x14, aucHeader);
-00279                 DBG_DEC(usChse);
-00280                 if (usFib < 192) {
-00281                         /* Unknown or unsupported version of Word */
-00282                         DBG_DEC(usFib);
-00283                         return -1;
-00284                 }
-00285                 DBG_MSG_C(usChse != 256, "Word97 for Win95/98/NT");
-00286                 DBG_MSG_C(usChse == 256, "Word98 for Macintosh");
-00287                 return 8;
-00288         }
-00289 } /* end of iGetVersionNumber */
-00290 
-00291 /*
-00292  * TRUE if the current file was made by Word version 6 or older on an
-00293  * Apple Macintosh, otherwise FALSE.
-00294  * This function hides the methode of how to find out from the rest of the
-00295  * program.
-00296  */
-00297 BOOL
-00298 bIsOldMacFile(void)
-00299 {
-00300         return bOldMacFile;
-00301 } /* end of bIsOldMacFile */
-00302 
-00303 /*
-00304  * iInitDocument - initialize a document
-00305  *
-00306  * Returns the version of Word that made the document or -1
-00307  */
-00308 int
-00309 iInitDocument(FILE *pFile, long lFilesize)
-00310 {
-00311         int     iGuess, iWordVersion;
-00312 
-00313         iGuess = iGuessVersionNumber(pFile, lFilesize);
-00314         switch (iGuess) {
-00315         case 0:
-00316                 iWordVersion = iInitDocumentDOS(pFile, lFilesize);
-00317                 break;
-00318         case 2:
-00319                 iWordVersion = iInitDocumentWIN(pFile, lFilesize);
-00320                 break;
-00321         case 5:
-00322                 iWordVersion = iInitDocumentMAC(pFile, lFilesize);
-00323                 break;
-00324         case 6:
-00325                 iWordVersion = iInitDocumentOLE(pFile, lFilesize);
-00326                 break;
-00327         default:
-00328                 DBG_DEC(iGuess);
-00329                 iWordVersion = -1;
-00330                 break;
-00331         }
-00332         return iWordVersion;
-00333 } /* end of iInitDocument */
-00334 
-00335 /*
-00336  * vFreeDocument - free a document by free-ing its parts
-00337  */
-00338 void
-00339 vFreeDocument(void)
-00340 {
-00341         DBG_MSG("vFreeDocument");
-00342 
-00343         /* Free the memory */
-00344         vDestroyTextBlockList();
-00345         vDestroyDataBlockList();
-00346         vDestroyListInfoList();
-00347         vDestroyRowInfoList();
-00348         vDestroyStyleInfoList();
-00349         vDestroyFontInfoList();
-00350         vDestroyStylesheetList();
-00351         vDestroyPictInfoList();
-00352         vDestroyDocumentInfoList();
-00353         vDestroySectionInfoList();
-00354         vDestroyHdrFtrInfoList();
-00355         vDestroyPropModList();
-00356         vDestroyNotesInfoLists();
-00357         vDestroyFontTable();
-00358         vDestroySummaryInfo();
-00359 } /* end of vFreeDocument */
-
-
Generated by  - -doxygen 1.6.2
- - 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 @@ - - - - -TB9.2 Example Applications: examples/PIPS/antiword/src/wordmac.c Source File - - - - - -

examples/PIPS/antiword/src/wordmac.c

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 */
-
-
Generated by  - -doxygen 1.6.2
- - diff -r 59758314f811 -r d4524d6a4472 Symbian3/Examples/guid-6013a680-57f9-415b-8851-c4fa63356636/wordole_8c_source.html --- a/Symbian3/Examples/guid-6013a680-57f9-415b-8851-c4fa63356636/wordole_8c_source.html Fri Jun 11 15:24:34 2010 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,820 +0,0 @@ - - - - -TB9.2 Example Applications: examples/PIPS/antiword/src/wordole.c Source File - - - - - -

examples/PIPS/antiword/src/wordole.c

00001 /*
-00002  * wordole.c
-00003  * Copyright (C) 1998-2004 A.J. van Os; Released under GPL
-00004  *
-00005  * Description:
-00006  * Deal with the OLE internals of a MS Word file
-00007  */
-00008 
-00009 #include <string.h>
-00010 #include "antiword.h"
-00011 
-00012 /* Private type for Property Set Storage entries */
-00013 typedef struct pps_entry_tag {
-00014         ULONG   ulNext;
-00015         ULONG   ulPrevious;
-00016         ULONG   ulDir;
-00017         ULONG   ulSB;
-00018         ULONG   ulSize;
-00019         int     iLevel;
-00020         char    szName[32];
-00021         UCHAR   ucType;
-00022 } pps_entry_type;
-00023 
-00024 /* Show that a PPS number or index should not be used */
-00025 #define PPS_NUMBER_INVALID      0xffffffffUL
-00026 
-00027 
-00028 /* Macro to make sure all such statements will be identical */
-00029 #define FREE_ALL()              \
-00030         do {\
-00031                 vDestroySmallBlockList();\
-00032                 aulRootList = xfree(aulRootList);\
-00033                 aulSbdList = xfree(aulSbdList);\
-00034                 aulBbdList = xfree(aulBbdList);\
-00035                 aulSBD = xfree(aulSBD);\
-00036                 aulBBD = xfree(aulBBD);\
-00037         } while(0)
-00038 
-00039 
-00040 /*
-00041  * ulReadLong - read four bytes from the given file and offset
-00042  */
-00043 static ULONG
-00044 ulReadLong(FILE *pFile, ULONG ulOffset)
-00045 {
-00046         UCHAR   aucBytes[4];
-00047 
-00048         fail(pFile == NULL);
-00049 
-00050         if (!bReadBytes(aucBytes, 4, ulOffset, pFile)) {
-00051                 werr(1, "Read long 0x%lx not possible", ulOffset);
-00052         }
-00053         return ulGetLong(0, aucBytes);
-00054 } /* end of ulReadLong */
-00055 
-00056 /*
-00057  * vName2String - turn the name into a proper string.
-00058  */
-00059 static void
-00060 vName2String(char *szName, const UCHAR *aucBytes, size_t tNameSize)
-00061 {
-00062         char    *pcChar;
-00063         size_t  tIndex;
-00064 
-00065         fail(aucBytes == NULL || szName == NULL);
-00066 
-00067         if (tNameSize < 2) {
-00068                 szName[0] = '\0';
-00069                 return;
-00070         }
-00071         for (tIndex = 0, pcChar = szName;
-00072              tIndex < 2 * tNameSize;
-00073              tIndex += 2, pcChar++) {
-00074                 *pcChar = (char)aucBytes[tIndex];
-00075         }
-00076         szName[tNameSize - 1] = '\0';
-00077 } /* end of vName2String */
-00078 
-00079 /*
-00080  * tReadBlockIndices - read the Big/Small Block Depot indices
-00081  *
-00082  * Returns the number of indices read
-00083  */
-00084 static size_t
-00085 tReadBlockIndices(FILE *pFile, ULONG *aulBlockDepot,
-00086         size_t tMaxRec, ULONG ulOffset)
-00087 {
-00088         size_t  tDone;
-00089         int     iIndex;
-00090         UCHAR   aucBytes[BIG_BLOCK_SIZE];
-00091 
-00092         fail(pFile == NULL || aulBlockDepot == NULL);
-00093         fail(tMaxRec == 0);
-00094 
-00095         /* Read a big block with BBD or SBD indices */
-00096         if (!bReadBytes(aucBytes, BIG_BLOCK_SIZE, ulOffset, pFile)) {
-00097                 werr(0, "Reading big block from 0x%lx is not possible",
-00098                         ulOffset);
-00099                 return 0;
-00100         }
-00101         /* Split the big block into indices, an index is four bytes */
-00102         tDone = min(tMaxRec, (size_t)BIG_BLOCK_SIZE / 4);
-00103         for (iIndex = 0; iIndex < (int)tDone; iIndex++) {
-00104                 aulBlockDepot[iIndex] = ulGetLong(4 * iIndex, aucBytes);
-00105                 NO_DBG_DEC(aulBlockDepot[iIndex]);
-00106         }
-00107         return tDone;
-00108 } /* end of tReadBlockIndices */
-00109 
-00110 /*
-00111  * bGetBBD - get the Big Block Depot indices from the index-blocks
-00112  */
-00113 static BOOL
-00114 bGetBBD(FILE *pFile, const ULONG *aulDepot, size_t tDepotLen,
-00115         ULONG *aulBBD, size_t tBBDLen)
-00116 {
-00117         ULONG   ulBegin;
-00118         size_t  tToGo, tDone;
-00119         int     iIndex;
-00120 
-00121         fail(pFile == NULL || aulDepot == NULL || aulBBD == NULL);
-00122 
-00123         DBG_MSG("bGetBBD");
-00124 
-00125         tToGo = tBBDLen;
-00126         for (iIndex = 0; iIndex < (int)tDepotLen && tToGo != 0; iIndex++) {
-00127                 ulBegin = (aulDepot[iIndex] + 1) * BIG_BLOCK_SIZE;
-00128                 NO_DBG_HEX(ulBegin);
-00129                 tDone = tReadBlockIndices(pFile, aulBBD, tToGo, ulBegin);
-00130                 fail(tDone > tToGo);
-00131                 if (tDone == 0) {
-00132                         return FALSE;
-00133                 }
-00134                 aulBBD += tDone;
-00135                 tToGo -= tDone;
-00136         }
-00137         return tToGo == 0;
-00138 } /* end of bGetBBD */
-00139 
-00140 /*
-00141  * bGetSBD - get the Small Block Depot indices from the index-blocks
-00142  */
-00143 static BOOL
-00144 bGetSBD(FILE *pFile, const ULONG *aulDepot, size_t tDepotLen,
-00145         ULONG *aulSBD, size_t tSBDLen)
-00146 {
-00147         ULONG   ulBegin;
-00148         size_t  tToGo, tDone;
-00149         int     iIndex;
-00150 
-00151         fail(pFile == NULL || aulDepot == NULL || aulSBD == NULL);
-00152 
-00153         DBG_MSG("bGetSBD");
-00154 
-00155         tToGo = tSBDLen;
-00156         for (iIndex = 0; iIndex < (int)tDepotLen && tToGo != 0; iIndex++) {
-00157                 fail(aulDepot[iIndex] >= ULONG_MAX / BIG_BLOCK_SIZE);
-00158                 ulBegin = (aulDepot[iIndex] + 1) * BIG_BLOCK_SIZE;
-00159                 NO_DBG_HEX(ulBegin);
-00160                 tDone = tReadBlockIndices(pFile, aulSBD, tToGo, ulBegin);
-00161                 fail(tDone > tToGo);
-00162                 if (tDone == 0) {
-00163                         return FALSE;
-00164                 }
-00165                 aulSBD += tDone;
-00166                 tToGo -= tDone;
-00167         }
-00168         return tToGo == 0;
-00169 } /* end of bGetSBD */
-00170 
-00171 /*
-00172  * vComputePPSlevels - compute the levels of the Property Set Storage entries
-00173  */
-00174 static void
-00175 vComputePPSlevels(pps_entry_type *atPPSlist, pps_entry_type *pNode,
-00176                         int iLevel, int iRecursionLevel)
-00177 {
-00178         fail(atPPSlist == NULL || pNode == NULL);
-00179         fail(iLevel < 0 || iRecursionLevel < 0);
-00180 
-00181         if (iRecursionLevel > 25) {
-00182                 /* This removes the possibility of an infinite recursion */
-00183                 DBG_DEC(iRecursionLevel);
-00184                 return;
-00185         }
-00186         if (pNode->iLevel <= iLevel) {
-00187                 /* Avoid entering a loop */
-00188                 DBG_DEC(iLevel);
-00189                 DBG_DEC(pNode->iLevel);
-00190                 return;
-00191         }
-00192 
-00193         pNode->iLevel = iLevel;
-00194 
-00195         if (pNode->ulDir != PPS_NUMBER_INVALID) {
-00196                 vComputePPSlevels(atPPSlist,
-00197                                 &atPPSlist[pNode->ulDir],
-00198                                 iLevel + 1,
-00199                                 iRecursionLevel + 1);
-00200         }
-00201         if (pNode->ulNext != PPS_NUMBER_INVALID) {
-00202                 vComputePPSlevels(atPPSlist,
-00203                                 &atPPSlist[pNode->ulNext],
-00204                                 iLevel,
-00205                                 iRecursionLevel + 1);
-00206         }
-00207         if (pNode->ulPrevious != PPS_NUMBER_INVALID) {
-00208                 vComputePPSlevels(atPPSlist,
-00209                                 &atPPSlist[pNode->ulPrevious],
-00210                                 iLevel,
-00211                                 iRecursionLevel + 1);
-00212         }
-00213 } /* end of vComputePPSlevels */
-00214 
-00215 /*
-00216  * bGetPPS - search the Property Set Storage for three sets
-00217  *
-00218  * Return TRUE if the WordDocument PPS is found
-00219  */
-00220 static BOOL
-00221 bGetPPS(FILE *pFile,
-00222         const ULONG *aulRootList, size_t tRootListLen, pps_info_type *pPPS)
-00223 {
-00224         pps_entry_type  *atPPSlist;
-00225         ULONG   ulBegin, ulOffset, ulTmp;
-00226         size_t  tNbrOfPPS, tNameSize;
-00227         int     iIndex, iStartBlock, iRootIndex;
-00228         BOOL    bWord, bExcel;
-00229         UCHAR   aucBytes[PROPERTY_SET_STORAGE_SIZE];
-00230 
-00231         fail(pFile == NULL || aulRootList == NULL || pPPS == NULL);
-00232 
-00233         DBG_MSG("bGetPPS");
-00234 
-00235         NO_DBG_DEC(tRootListLen);
-00236 
-00237         bWord = FALSE;
-00238         bExcel = FALSE;
-00239         (void)memset(pPPS, 0, sizeof(*pPPS));
-00240 
-00241         /* Read and store all the Property Set Storage entries */
-00242 
-00243         tNbrOfPPS = tRootListLen * BIG_BLOCK_SIZE / PROPERTY_SET_STORAGE_SIZE;
-00244         atPPSlist = xcalloc(tNbrOfPPS, sizeof(pps_entry_type));
-00245         iRootIndex = 0;
-00246 
-00247         for (iIndex = 0; iIndex < (int)tNbrOfPPS; iIndex++) {
-00248                 ulTmp = (ULONG)iIndex * PROPERTY_SET_STORAGE_SIZE;
-00249                 iStartBlock = (int)(ulTmp / BIG_BLOCK_SIZE);
-00250                 ulOffset = ulTmp % BIG_BLOCK_SIZE;
-00251                 ulBegin = (aulRootList[iStartBlock] + 1) * BIG_BLOCK_SIZE +
-00252                                 ulOffset;
-00253                 NO_DBG_HEX(ulBegin);
-00254                 if (!bReadBytes(aucBytes, PROPERTY_SET_STORAGE_SIZE,
-00255                                                         ulBegin, pFile)) {
-00256                         werr(0, "Reading PPS %d is not possible", iIndex);
-00257                         atPPSlist = xfree(atPPSlist);
-00258                         return FALSE;
-00259                 }
-00260                 tNameSize = (size_t)usGetWord(0x40, aucBytes);
-00261                 tNameSize = (tNameSize + 1) / 2;
-00262                 vName2String(atPPSlist[iIndex].szName, aucBytes, tNameSize);
-00263                 atPPSlist[iIndex].ucType = ucGetByte(0x42, aucBytes);
-00264                 if (atPPSlist[iIndex].ucType == 5) {
-00265                         iRootIndex = iIndex;
-00266                 }
-00267                 atPPSlist[iIndex].ulPrevious = ulGetLong(0x44, aucBytes);
-00268                 atPPSlist[iIndex].ulNext = ulGetLong(0x48, aucBytes);
-00269                 atPPSlist[iIndex].ulDir = ulGetLong(0x4c, aucBytes);
-00270                 atPPSlist[iIndex].ulSB = ulGetLong(0x74, aucBytes);
-00271                 atPPSlist[iIndex].ulSize = ulGetLong(0x78, aucBytes);
-00272                 atPPSlist[iIndex].iLevel = INT_MAX;
-00273                 if ((atPPSlist[iIndex].ulPrevious >= (ULONG)tNbrOfPPS &&
-00274                      atPPSlist[iIndex].ulPrevious != PPS_NUMBER_INVALID) ||
-00275                     (atPPSlist[iIndex].ulNext >= (ULONG)tNbrOfPPS &&
-00276                      atPPSlist[iIndex].ulNext != PPS_NUMBER_INVALID) ||
-00277                     (atPPSlist[iIndex].ulDir >= (ULONG)tNbrOfPPS &&
-00278                      atPPSlist[iIndex].ulDir != PPS_NUMBER_INVALID)) {
-00279                         DBG_DEC(iIndex);
-00280                         DBG_DEC(atPPSlist[iIndex].ulPrevious);
-00281                         DBG_DEC(atPPSlist[iIndex].ulNext);
-00282                         DBG_DEC(atPPSlist[iIndex].ulDir);
-00283                         DBG_DEC(tNbrOfPPS);
-00284                         werr(0, "The Property Set Storage is damaged");
-00285                         atPPSlist = xfree(atPPSlist);
-00286                         return FALSE;
-00287                 }
-00288         }
-00289 
-00290 #if 0 /* defined(DEBUG) */
-00291         DBG_MSG("Before");
-00292         for (iIndex = 0; iIndex < (int)tNbrOfPPS; iIndex++) {
-00293                 DBG_MSG(atPPSlist[iIndex].szName);
-00294                 DBG_HEX(atPPSlist[iIndex].ulDir);
-00295                 DBG_HEX(atPPSlist[iIndex].ulPrevious);
-00296                 DBG_HEX(atPPSlist[iIndex].ulNext);
-00297                 DBG_DEC(atPPSlist[iIndex].ulSB);
-00298                 DBG_HEX(atPPSlist[iIndex].ulSize);
-00299                 DBG_DEC(atPPSlist[iIndex].iLevel);
-00300         }
-00301 #endif /* DEBUG */
-00302 
-00303         /* Add level information to each entry */
-00304         vComputePPSlevels(atPPSlist, &atPPSlist[iRootIndex], 0, 0);
-00305 
-00306         /* Check the entries on level 1 for the required information */
-00307         NO_DBG_MSG("After");
-00308         for (iIndex = 0; iIndex < (int)tNbrOfPPS; iIndex++) {
-00309 #if 0 /* defined(DEBUG) */
-00310                 DBG_MSG(atPPSlist[iIndex].szName);
-00311                 DBG_HEX(atPPSlist[iIndex].ulDir);
-00312                 DBG_HEX(atPPSlist[iIndex].ulPrevious);
-00313                 DBG_HEX(atPPSlist[iIndex].ulNext);
-00314                 DBG_DEC(atPPSlist[iIndex].ulSB);
-00315                 DBG_HEX(atPPSlist[iIndex].ulSize);
-00316                 DBG_DEC(atPPSlist[iIndex].iLevel);
-00317 #endif /* DEBUG */
-00318                 if (atPPSlist[iIndex].iLevel != 1 ||
-00319                     atPPSlist[iIndex].ucType != 2 ||
-00320                     atPPSlist[iIndex].szName[0] == '\0' ||
-00321                     atPPSlist[iIndex].ulSize == 0) {
-00322                         /* This entry can be ignored */
-00323                         continue;
-00324                 }
-00325                 if (pPPS->tWordDocument.ulSize == 0 &&
-00326                     STREQ(atPPSlist[iIndex].szName, "WordDocument")) {
-00327                         pPPS->tWordDocument.ulSB = atPPSlist[iIndex].ulSB;
-00328                         pPPS->tWordDocument.ulSize = atPPSlist[iIndex].ulSize;
-00329                         bWord = TRUE;
-00330                 } else if (pPPS->tData.ulSize == 0 &&
-00331                            STREQ(atPPSlist[iIndex].szName, "Data")) {
-00332                         pPPS->tData.ulSB = atPPSlist[iIndex].ulSB;
-00333                         pPPS->tData.ulSize = atPPSlist[iIndex].ulSize;
-00334                 } else if (pPPS->t0Table.ulSize == 0 &&
-00335                            STREQ(atPPSlist[iIndex].szName, "0Table")) {
-00336                         pPPS->t0Table.ulSB = atPPSlist[iIndex].ulSB;
-00337                         pPPS->t0Table.ulSize = atPPSlist[iIndex].ulSize;
-00338                 } else if (pPPS->t1Table.ulSize == 0 &&
-00339                            STREQ(atPPSlist[iIndex].szName, "1Table")) {
-00340                         pPPS->t1Table.ulSB = atPPSlist[iIndex].ulSB;
-00341                         pPPS->t1Table.ulSize = atPPSlist[iIndex].ulSize;
-00342                 } else if (pPPS->tSummaryInfo.ulSize == 0 &&
-00343                            STREQ(atPPSlist[iIndex].szName,
-00344                                                 "\005SummaryInformation")) {
-00345                         pPPS->tSummaryInfo.ulSB = atPPSlist[iIndex].ulSB;
-00346                         pPPS->tSummaryInfo.ulSize = atPPSlist[iIndex].ulSize;
-00347                 } else if (pPPS->tDocSummaryInfo.ulSize == 0 &&
-00348                            STREQ(atPPSlist[iIndex].szName,
-00349                                         "\005DocumentSummaryInformation")) {
-00350                         pPPS->tDocSummaryInfo.ulSB = atPPSlist[iIndex].ulSB;
-00351                         pPPS->tDocSummaryInfo.ulSize = atPPSlist[iIndex].ulSize;
-00352                 } else if (STREQ(atPPSlist[iIndex].szName, "Book") ||
-00353                            STREQ(atPPSlist[iIndex].szName, "Workbook")) {
-00354                         bExcel = TRUE;
-00355                 }
-00356         }
-00357 
-00358         /* Free the space for the Property Set Storage entries */
-00359         atPPSlist = xfree(atPPSlist);
-00360 
-00361         /* Draw your conclusions */
-00362         if (bWord) {
-00363                 return TRUE;
-00364         }
-00365 
-00366         if (bExcel) {
-00367                 werr(0, "Sorry, but this is an Excel spreadsheet");
-00368         } else {
-00369                 werr(0, "This OLE file does not contain a Word document");
-00370         }
-00371         return FALSE;
-00372 } /* end of bGetPPS */
-00373 
-00374 /*
-00375  * vGetBbdList - make a list of the places to find big blocks
-00376  */
-00377 static void
-00378 vGetBbdList(FILE *pFile, int iNbr, ULONG *aulBbdList, ULONG ulOffset)
-00379 {
-00380         int     iIndex;
-00381 
-00382         fail(pFile == NULL);
-00383         fail(iNbr > 127);
-00384         fail(aulBbdList == NULL);
-00385 
-00386         NO_DBG_DEC(iNbr);
-00387         for (iIndex = 0; iIndex < iNbr; iIndex++) {
-00388                 aulBbdList[iIndex] =
-00389                         ulReadLong(pFile, ulOffset + 4 * (ULONG)iIndex);
-00390                 NO_DBG_DEC(iIndex);
-00391                 NO_DBG_HEX(aulBbdList[iIndex]);
-00392         }
-00393 } /* end of vGetBbdList */
-00394 
-00395 /*
-00396  * bGetDocumentText - make a list of the text blocks of a Word document
-00397  *
-00398  * Return TRUE when succesful, otherwise FALSE
-00399  */
-00400 static BOOL
-00401 bGetDocumentText(FILE *pFile, const pps_info_type *pPPS,
-00402         const ULONG *aulBBD, size_t tBBDLen,
-00403         const ULONG *aulSBD, size_t tSBDLen,
-00404         const UCHAR *aucHeader, int iWordVersion)
-00405 {
-00406         ULONG   ulBeginOfText;
-00407         ULONG   ulTextLen, ulFootnoteLen, ulEndnoteLen;
-00408         ULONG   ulHdrFtrLen, ulMacroLen, ulAnnotationLen;
-00409         ULONG   ulTextBoxLen, ulHdrTextBoxLen;
-00410         UINT    uiQuickSaves;
-00411         BOOL    bFarEastWord, bTemplate, bFastSaved, bEncrypted, bSuccess;
-00412         USHORT  usIdent, usDocStatus;
-00413 
-00414         fail(pFile == NULL || pPPS == NULL);
-00415         fail(aulBBD == NULL);
-00416         fail(aulSBD == NULL);
-00417 
-00418         DBG_MSG("bGetDocumentText");
-00419 
-00420         /* Get the "magic number" from the header */
-00421         usIdent = usGetWord(0x00, aucHeader);
-00422         DBG_HEX(usIdent);
-00423         bFarEastWord = usIdent == 0x8098 || usIdent == 0x8099 ||
-00424                         usIdent == 0xa697 || usIdent == 0xa699;
-00425         /* Get the status flags from the header */
-00426         usDocStatus = usGetWord(0x0a, aucHeader);
-00427         DBG_HEX(usDocStatus);
-00428         bTemplate = (usDocStatus & BIT(0)) != 0;
-00429         DBG_MSG_C(bTemplate, "This document is a Template");
-00430         bFastSaved = (usDocStatus & BIT(2)) != 0;
-00431         uiQuickSaves = (UINT)(usDocStatus & 0x00f0) >> 4;
-00432         DBG_MSG_C(bFastSaved, "This document is Fast Saved");
-00433         DBG_DEC_C(bFastSaved, uiQuickSaves);
-00434         bEncrypted = (usDocStatus & BIT(8)) != 0;
-00435         if (bEncrypted) {
-00436                 werr(0, "Encrypted documents are not supported");
-00437                 return FALSE;
-00438         }
-00439 
-00440         /* Get length information */
-00441         ulBeginOfText = ulGetLong(0x18, aucHeader);
-00442         DBG_HEX(ulBeginOfText);
-00443         switch (iWordVersion) {
-00444         case 6:
-00445         case 7:
-00446                 ulTextLen = ulGetLong(0x34, aucHeader);
-00447                 ulFootnoteLen = ulGetLong(0x38, aucHeader);
-00448                 ulHdrFtrLen = ulGetLong(0x3c, aucHeader);
-00449                 ulMacroLen = ulGetLong(0x40, aucHeader);
-00450                 ulAnnotationLen = ulGetLong(0x44, aucHeader);
-00451                 ulEndnoteLen = ulGetLong(0x48, aucHeader);
-00452                 ulTextBoxLen = ulGetLong(0x4c, aucHeader);
-00453                 ulHdrTextBoxLen = ulGetLong(0x50, aucHeader);
-00454                 break;
-00455         case 8:
-00456                 ulTextLen = ulGetLong(0x4c, aucHeader);
-00457                 ulFootnoteLen = ulGetLong(0x50, aucHeader);
-00458                 ulHdrFtrLen = ulGetLong(0x54, aucHeader);
-00459                 ulMacroLen = ulGetLong(0x58, aucHeader);
-00460                 ulAnnotationLen = ulGetLong(0x5c, aucHeader);
-00461                 ulEndnoteLen = ulGetLong(0x60, aucHeader);
-00462                 ulTextBoxLen = ulGetLong(0x64, aucHeader);
-00463                 ulHdrTextBoxLen = ulGetLong(0x68, aucHeader);
-00464                 break;
-00465         default:
-00466                 werr(0, "This version of Word is not supported");
-00467                 return FALSE;
-00468         }
-00469         DBG_DEC(ulTextLen);
-00470         DBG_DEC(ulFootnoteLen);
-00471         DBG_DEC(ulHdrFtrLen);
-00472         DBG_DEC(ulMacroLen);
-00473         DBG_DEC(ulAnnotationLen);
-00474         DBG_DEC(ulEndnoteLen);
-00475         DBG_DEC(ulTextBoxLen);
-00476         DBG_DEC(ulHdrTextBoxLen);
-00477 
-00478         /* Make a list of the text blocks */
-00479         switch (iWordVersion) {
-00480         case 6:
-00481         case 7:
-00482                 if (bFastSaved) {
-00483                         bSuccess = bGet6DocumentText(pFile,
-00484                                         bFarEastWord,
-00485                                         pPPS->tWordDocument.ulSB,
-00486                                         aulBBD, tBBDLen,
-00487                                         aucHeader);
-00488                 } else {
-00489                         bSuccess = bAddTextBlocks(ulBeginOfText,
-00490                                 ulTextLen +
-00491                                 ulFootnoteLen +
-00492                                 ulHdrFtrLen +
-00493                                 ulMacroLen + ulAnnotationLen +
-00494                                 ulEndnoteLen +
-00495                                 ulTextBoxLen + ulHdrTextBoxLen,
-00496                                 bFarEastWord,
-00497                                 IGNORE_PROPMOD,
-00498                                 pPPS->tWordDocument.ulSB,
-00499                                 aulBBD, tBBDLen);
-00500                 }
-00501                 break;
-00502         case 8:
-00503                 bSuccess = bGet8DocumentText(pFile,
-00504                                 pPPS,
-00505                                 aulBBD, tBBDLen, aulSBD, tSBDLen,
-00506                                 aucHeader);
-00507                 break;
-00508         default:
-00509                 werr(0, "This version of Word is not supported");
-00510                 bSuccess = FALSE;
-00511                 break;
-00512         }
-00513 
-00514         if (bSuccess) {
-00515                 vSplitBlockList(pFile,
-00516                                 ulTextLen,
-00517                                 ulFootnoteLen,
-00518                                 ulHdrFtrLen,
-00519                                 ulMacroLen,
-00520                                 ulAnnotationLen,
-00521                                 ulEndnoteLen,
-00522                                 ulTextBoxLen,
-00523                                 ulHdrTextBoxLen,
-00524                                 !bFastSaved && iWordVersion == 8);
-00525         } else {
-00526                 vDestroyTextBlockList();
-00527                 werr(0, "I can't find the text of this document");
-00528         }
-00529         return bSuccess;
-00530 } /* end of bGetDocumentText */
-00531 
-00532 /*
-00533  * vGetDocumentData - make a list of the data blocks of a Word document
-00534  */
-00535 static void
-00536 vGetDocumentData(FILE *pFile, const pps_info_type *pPPS,
-00537         const ULONG *aulBBD, size_t tBBDLen,
-00538         const UCHAR *aucHeader, int iWordVersion)
-00539 {
-00540         options_type    tOptions;
-00541         ULONG   ulBeginOfText;
-00542         BOOL    bFastSaved, bHasImages, bSuccess;
-00543         USHORT  usDocStatus;
-00544 
-00545         fail(pFile == NULL);
-00546         fail(pPPS == NULL);
-00547         fail(aulBBD == NULL);
-00548 
-00549         /* Get the options */
-00550         vGetOptions(&tOptions);
-00551 
-00552         /* Get the status flags from the header */
-00553         usDocStatus = usGetWord(0x0a, aucHeader);
-00554         DBG_HEX(usDocStatus);
-00555         bFastSaved = (usDocStatus & BIT(2)) != 0;
-00556         bHasImages = (usDocStatus & BIT(3)) != 0;
-00557 
-00558         if (!bHasImages ||
-00559             tOptions.eConversionType == conversion_text ||
-00560             tOptions.eConversionType == conversion_fmt_text ||
-00561             tOptions.eConversionType == conversion_xml ||
-00562             tOptions.eImageLevel == level_no_images) {
-00563                 /*
-00564                  * No images in the document or text-only output or
-00565                  * no images wanted, so no data blocks will be needed
-00566                  */
-00567                 vDestroyDataBlockList();
-00568                 return;
-00569         }
-00570 
-00571         /* Get length information */
-00572         ulBeginOfText = ulGetLong(0x18, aucHeader);
-00573         DBG_HEX(ulBeginOfText);
-00574 
-00575         /* Make a list of the data blocks */
-00576         switch (iWordVersion) {
-00577         case 6:
-00578         case 7:
-00579                 /*
-00580                  * The data blocks are in the text stream. The text stream
-00581                  * is in "fast saved" format or "normal saved" format
-00582                  */
-00583                 if (bFastSaved) {
-00584                         bSuccess = bGet6DocumentData(pFile,
-00585                                         pPPS->tWordDocument.ulSB,
-00586                                         aulBBD, tBBDLen,
-00587                                         aucHeader);
-00588                 } else {
-00589                         bSuccess = bAddDataBlocks(ulBeginOfText,
-00590                                         (ULONG)LONG_MAX,
-00591                                         pPPS->tWordDocument.ulSB,
-00592                                         aulBBD, tBBDLen);
-00593                 }
-00594                 break;
-00595         case 8:
-00596                 /*
-00597                  * The data blocks are in the data stream. The data stream
-00598                  * is always in "normal saved" format
-00599                  */
-00600                 bSuccess = bAddDataBlocks(0, (ULONG)LONG_MAX,
-00601                                 pPPS->tData.ulSB, aulBBD, tBBDLen);
-00602                 break;
-00603         default:
-00604                 werr(0, "This version of Word is not supported");
-00605                 bSuccess = FALSE;
-00606                 break;
-00607         }
-00608 
-00609         if (!bSuccess) {
-00610                 vDestroyDataBlockList();
-00611                 werr(0, "I can't find the data of this document");
-00612         }
-00613 } /* end of vGetDocumentData */
-00614 
-00615 /*
-00616  * iInitDocumentOLE - initialize an OLE document
-00617  *
-00618  * Returns the version of Word that made the document or -1
-00619  */
-00620 int
-00621 iInitDocumentOLE(FILE *pFile, long lFilesize)
-00622 {
-00623         pps_info_type   PPS_info;
-00624         ULONG   *aulBBD, *aulSBD;
-00625         ULONG   *aulRootList, *aulBbdList, *aulSbdList;
-00626         ULONG   ulBdbListStart, ulAdditionalBBDlist;
-00627         ULONG   ulRootStartblock, ulSbdStartblock, ulSBLstartblock;
-00628         ULONG   ulStart, ulTmp;
-00629         long    lMaxBlock;
-00630         size_t  tBBDLen, tSBDLen, tNumBbdBlocks, tRootListLen;
-00631         int     iWordVersion, iIndex, iToGo;
-00632         BOOL    bSuccess;
-00633         USHORT  usIdent, usDocStatus;
-00634         UCHAR   aucHeader[HEADER_SIZE];
-00635 
-00636         fail(pFile == NULL);
-00637 
-00638         lMaxBlock = lFilesize / BIG_BLOCK_SIZE - 2;
-00639         DBG_DEC(lMaxBlock);
-00640         if (lMaxBlock < 1) {
-00641                 return -1;
-00642         }
-00643         tBBDLen = (size_t)(lMaxBlock + 1);
-00644         tNumBbdBlocks = (size_t)ulReadLong(pFile, 0x2c);
-00645         DBG_DEC(tNumBbdBlocks);
-00646         ulRootStartblock = ulReadLong(pFile, 0x30);
-00647         DBG_DEC(ulRootStartblock);
-00648         ulSbdStartblock = ulReadLong(pFile, 0x3c);
-00649         DBG_DEC(ulSbdStartblock);
-00650         ulAdditionalBBDlist = ulReadLong(pFile, 0x44);
-00651         DBG_HEX(ulAdditionalBBDlist);
-00652         ulSBLstartblock = ulReadLong(pFile,
-00653                         (ulRootStartblock + 1) * BIG_BLOCK_SIZE + 0x74);
-00654         DBG_DEC(ulSBLstartblock);
-00655         tSBDLen = (size_t)(ulReadLong(pFile,
-00656                         (ulRootStartblock + 1) * BIG_BLOCK_SIZE + 0x78) /
-00657                         SMALL_BLOCK_SIZE);
-00658         /* All to be xcalloc-ed pointers to NULL */
-00659         aulRootList = NULL;
-00660         aulSbdList = NULL;
-00661         aulBbdList = NULL;
-00662         aulSBD = NULL;
-00663         aulBBD = NULL;
-00664 /* Big Block Depot */
-00665         aulBbdList = xcalloc(tNumBbdBlocks, sizeof(ULONG));
-00666         aulBBD = xcalloc(tBBDLen, sizeof(ULONG));
-00667         iToGo = (int)tNumBbdBlocks;
-00668         vGetBbdList(pFile, min(iToGo, 109),  aulBbdList, 0x4c);
-00669         ulStart = 109;
-00670         iToGo -= 109;
-00671         while (ulAdditionalBBDlist != END_OF_CHAIN && iToGo > 0) {
-00672                 ulBdbListStart = (ulAdditionalBBDlist + 1) * BIG_BLOCK_SIZE;
-00673                 vGetBbdList(pFile, min(iToGo, 127),
-00674                                         aulBbdList + ulStart, ulBdbListStart);
-00675                 ulAdditionalBBDlist = ulReadLong(pFile,
-00676                                         ulBdbListStart + 4 * 127);
-00677                 DBG_DEC(ulAdditionalBBDlist);
-00678                 DBG_HEX(ulAdditionalBBDlist);
-00679                 ulStart += 127;
-00680                 iToGo -= 127;
-00681         }
-00682         if (!bGetBBD(pFile, aulBbdList, tNumBbdBlocks, aulBBD, tBBDLen)) {
-00683                 FREE_ALL();
-00684                 return -1;
-00685         }
-00686         aulBbdList = xfree(aulBbdList);
-00687 /* Small Block Depot */
-00688         aulSbdList = xcalloc(tBBDLen, sizeof(ULONG));
-00689         aulSBD = xcalloc(tSBDLen, sizeof(ULONG));
-00690         for (iIndex = 0, ulTmp = ulSbdStartblock;
-00691              iIndex < (int)tBBDLen && ulTmp != END_OF_CHAIN;
-00692              iIndex++, ulTmp = aulBBD[ulTmp]) {
-00693                 if (ulTmp >= (ULONG)tBBDLen) {
-00694                         DBG_DEC(ulTmp);
-00695                         DBG_DEC(tBBDLen);
-00696                         werr(1, "The Big Block Depot is damaged");
-00697                 }
-00698                 aulSbdList[iIndex] = ulTmp;
-00699                 NO_DBG_HEX(aulSbdList[iIndex]);
-00700         }
-00701         if (!bGetSBD(pFile, aulSbdList, tBBDLen, aulSBD, tSBDLen)) {
-00702                 FREE_ALL();
-00703                 return -1;
-00704         }
-00705         aulSbdList = xfree(aulSbdList);
-00706 /* Root list */
-00707         for (tRootListLen = 0, ulTmp = ulRootStartblock;
-00708              tRootListLen < tBBDLen && ulTmp != END_OF_CHAIN;
-00709              tRootListLen++, ulTmp = aulBBD[ulTmp]) {
-00710                 if (ulTmp >= (ULONG)tBBDLen) {
-00711                         DBG_DEC(ulTmp);
-00712                         DBG_DEC(tBBDLen);
-00713                         werr(1, "The Big Block Depot is damaged");
-00714                 }
-00715         }
-00716         if (tRootListLen == 0) {
-00717                 werr(0, "No Rootlist found");
-00718                 FREE_ALL();
-00719                 return -1;
-00720         }
-00721         aulRootList = xcalloc(tRootListLen, sizeof(ULONG));
-00722         for (iIndex = 0, ulTmp = ulRootStartblock;
-00723              iIndex < (int)tBBDLen && ulTmp != END_OF_CHAIN;
-00724              iIndex++, ulTmp = aulBBD[ulTmp]) {
-00725                 if (ulTmp >= (ULONG)tBBDLen) {
-00726                         DBG_DEC(ulTmp);
-00727                         DBG_DEC(tBBDLen);
-00728                         werr(1, "The Big Block Depot is damaged");
-00729                 }
-00730                 aulRootList[iIndex] = ulTmp;
-00731                 NO_DBG_DEC(aulRootList[iIndex]);
-00732         }
-00733         fail(tRootListLen != (size_t)iIndex);
-00734         bSuccess = bGetPPS(pFile, aulRootList, tRootListLen, &PPS_info);
-00735         aulRootList = xfree(aulRootList);
-00736         if (!bSuccess) {
-00737                 FREE_ALL();
-00738                 return -1;
-00739         }
-00740 /* Small block list */
-00741         if (!bCreateSmallBlockList(ulSBLstartblock, aulBBD, tBBDLen)) {
-00742                 FREE_ALL();
-00743                 return -1;
-00744         }
-00745 
-00746         if (PPS_info.tWordDocument.ulSize < MIN_SIZE_FOR_BBD_USE) {
-00747                 DBG_DEC(PPS_info.tWordDocument.ulSize);
-00748                 FREE_ALL();
-00749                 werr(0, "I'm afraid the text stream of this file "
-00750                         "is too small to handle.");
-00751                 return -1;
-00752         }
-00753         /* Read the headerblock */
-00754         if (!bReadBuffer(pFile, PPS_info.tWordDocument.ulSB,
-00755                         aulBBD, tBBDLen, BIG_BLOCK_SIZE,
-00756                         aucHeader, 0, HEADER_SIZE)) {
-00757                 FREE_ALL();
-00758                 return -1;
-00759         }
-00760         usIdent = usGetWord(0x00, aucHeader);
-00761         DBG_HEX(usIdent);
-00762         fail(usIdent != 0x8098 &&       /* Word 7 for oriental languages */
-00763              usIdent != 0x8099 &&       /* Word 7 for oriental languages */
-00764              usIdent != 0xa5dc &&       /* Word 6 & 7 */
-00765              usIdent != 0xa5ec &&       /* Word 7 & 97 & 98 */
-00766              usIdent != 0xa697 &&       /* Word 7 for oriental languages */
-00767              usIdent != 0xa699);        /* Word 7 for oriental languages */
-00768         iWordVersion = iGetVersionNumber(aucHeader);
-00769         if (iWordVersion < 6) {
-00770                 FREE_ALL();
-00771                 werr(0, "This file is from a version of Word before Word 6.");
-00772                 return -1;
-00773         }
-00774 
-00775         /* Get the status flags from the header */
-00776         usDocStatus = usGetWord(0x0a, aucHeader);
-00777         if (usDocStatus & BIT(9)) {
-00778                 PPS_info.tTable = PPS_info.t1Table;
-00779         } else {
-00780                 PPS_info.tTable = PPS_info.t0Table;
-00781         }
-00782         /* Clean the entries that should not be used */
-00783         memset(&PPS_info.t0Table, 0, sizeof(PPS_info.t0Table));
-00784         memset(&PPS_info.t1Table, 0, sizeof(PPS_info.t1Table));
-00785 
-00786         bSuccess = bGetDocumentText(pFile, &PPS_info,
-00787                         aulBBD, tBBDLen, aulSBD, tSBDLen,
-00788                         aucHeader, iWordVersion);
-00789         if (bSuccess) {
-00790                 vGetDocumentData(pFile, &PPS_info,
-00791                         aulBBD, tBBDLen, aucHeader, iWordVersion);
-00792                 vGetPropertyInfo(pFile, &PPS_info,
-00793                         aulBBD, tBBDLen, aulSBD, tSBDLen,
-00794                         aucHeader, iWordVersion);
-00795                 vSetDefaultTabWidth(pFile, &PPS_info,
-00796                         aulBBD, tBBDLen, aulSBD, tSBDLen,
-00797                         aucHeader, iWordVersion);
-00798                 vGetNotesInfo(pFile, &PPS_info,
-00799                         aulBBD, tBBDLen, aulSBD, tSBDLen,
-00800                         aucHeader, iWordVersion);
-00801         }
-00802         FREE_ALL();
-00803         return bSuccess ? iWordVersion : -1;
-00804 } /* end of iInitDocumentOLE */
-
-
Generated by  - -doxygen 1.6.2
- - diff -r 59758314f811 -r d4524d6a4472 Symbian3/Examples/guid-6013a680-57f9-415b-8851-c4fa63356636/wordtypes_8h_source.html --- a/Symbian3/Examples/guid-6013a680-57f9-415b-8851-c4fa63356636/wordtypes_8h_source.html Fri Jun 11 15:24:34 2010 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,333 +0,0 @@ - - - - -TB9.2 Example Applications: examples/PIPS/antiword/inc/wordtypes.h Source File - - - - - -

examples/PIPS/antiword/inc/wordtypes.h

00001 /*
-00002  * wordtypes.h
-00003  * Copyright (C) 1998-2004 A.J. van Os; Released under GPL
-00004  *
-00005  * Description:
-00006  * Typedefs for the interpretation of MS Word files
-00007  */
-00008 
-00009 #if !defined(__wordtypes_h)
-00010 #define __wordtypes_h 1
-00011 
-00012 #include <time.h>
-00013 #if defined(__riscos)
-00014 #include "DeskLib:Font.h"
-00015 #include "DeskLib:Wimp.h"
-00016 #endif /* __riscos */
-00017 
-00018 typedef unsigned char   UCHAR;
-00019 typedef unsigned short  USHORT;
-00020 typedef unsigned int    UINT;
-00021 typedef unsigned long   ULONG;
-00022 
-00023 #if defined(__riscos)
-00024 typedef struct diagram_tag {
-00025         drawfile_info   tInfo;
-00026         window_handle   tMainWindow;
-00027         window_handle   tScaleWindow;
-00028         menu_ptr        pSaveMenu;
-00029         long            lXleft;                 /* In DrawUnits */
-00030         long            lYtop;                  /* In DrawUnits */
-00031         size_t          tMemorySize;
-00032         int             iScaleFactorCurr;       /* In percentage */
-00033         int             iScaleFactorTemp;       /* In percentage */
-00034         char            szFilename[19+1];
-00035 } diagram_type;
-00036 #else
-00037 typedef struct diagram_tag {
-00038         FILE            *pOutFile;
-00039         long            lXleft;                 /* In DrawUnits */
-00040         long            lYtop;                  /* In DrawUnits */
-00041 } diagram_type;
-00042 typedef UCHAR           drawfile_fontref;
-00043 #endif /* __riscos */
-00044 
-00045 typedef struct output_tag {
-00046         char    *szStorage;
-00047         long    lStringWidth;           /* In millipoints */
-00048         size_t  tStorageSize;
-00049         size_t  tNextFree;
-00050         USHORT  usFontStyle;
-00051         USHORT  usFontSize;
-00052         UCHAR   ucFontColor;
-00053         drawfile_fontref        tFontRef;
-00054         struct output_tag       *pPrev;
-00055         struct output_tag       *pNext;
-00056 } output_type;
-00057 
-00058 /* Types of conversion */
-00059 typedef enum conversion_tag {
-00060         conversion_unknown = 0,
-00061         conversion_text,
-00062         conversion_draw,
-00063         conversion_ps,
-00064         conversion_xml,
-00065         conversion_pdf,
-00066         conversion_fmt_text
-00067 } conversion_type;
-00068 
-00069 /* Types of encoding */
-00070 typedef enum encoding_tag {
-00071         encoding_neutral = 100,
-00072         encoding_latin_1 = 801,
-00073         encoding_latin_2 = 802,
-00074         encoding_cyrillic = 805,
-00075         encoding_utf_8 = 1601
-00076 } encoding_type;
-00077 
-00078 /* Font translation table entry */
-00079 typedef struct font_table_tag {
-00080         USHORT  usFontStyle;
-00081         UCHAR   ucWordFontNumber;
-00082         UCHAR   ucFFN;
-00083         UCHAR   ucEmphasis;
-00084         UCHAR   ucInUse;
-00085         char    szWordFontname[65];
-00086         char    szOurFontname[33];
-00087 } font_table_type;
-00088 
-00089 /* Options */
-00090 typedef enum image_level_tag {
-00091         level_gs_special = 0,
-00092         level_no_images,
-00093         level_ps_2,
-00094         level_ps_3,
-00095         level_default = level_ps_2
-00096 } image_level_enum;
-00097 
-00098 typedef struct options_tag {
-00099         int             iParagraphBreak;
-00100         conversion_type eConversionType;
-00101         BOOL            bHideHiddenText;
-00102         BOOL            bRemoveRemovedText;
-00103         BOOL            bUseLandscape;
-00104         encoding_type   eEncoding;
-00105         int             iPageHeight;            /* In points */
-00106         int             iPageWidth;             /* In points */
-00107         image_level_enum        eImageLevel;
-00108 #if defined(__riscos)
-00109         BOOL            bAutofiletypeAllowed;
-00110         int             iScaleFactor;           /* As a percentage */
-00111 #endif /* __riscos */
-00112 } options_type;
-00113 
-00114 /* Property Set Storage */
-00115 typedef struct pps_tag {
-00116         ULONG   ulSB;
-00117         ULONG   ulSize;
-00118 } pps_type;
-00119 typedef struct pps_info_tag {
-00120         pps_type        tWordDocument;  /* Text stream */
-00121         pps_type        tData;          /* Data stream */
-00122         pps_type        tTable;         /* Table stream */
-00123         pps_type        tSummaryInfo;   /* Summary Information */
-00124         pps_type        tDocSummaryInfo;/* Document Summary Information */
-00125         pps_type        t0Table;        /* Table 0 stream */
-00126         pps_type        t1Table;        /* Table 1 stream */
-00127 } pps_info_type;
-00128 
-00129 /* Record of data block information */
-00130 typedef struct data_block_tag {
-00131         ULONG   ulFileOffset;
-00132         ULONG   ulDataPos;
-00133         ULONG   ulLength;
-00134 } data_block_type;
-00135 
-00136 /* Record of text block information */
-00137 typedef struct text_block_tag {
-00138         ULONG   ulFileOffset;
-00139         ULONG   ulCharPos;
-00140         ULONG   ulLength;
-00141         BOOL    bUsesUnicode;   /* This block uses 16 bits per character */
-00142         USHORT  usPropMod;
-00143 } text_block_type;
-00144 
-00145 /* Record of the document block information */
-00146 typedef struct document_block_tag {
-00147         time_t  tCreateDate;            /* Unix timestamp */
-00148         time_t  tRevisedDate;           /* Unix timestamp */
-00149         USHORT  usDefaultTabWidth;      /* In twips */
-00150         UCHAR   ucHdrFtrSpecification;
-00151 } document_block_type;
-00152 
-00153 /* Record of table-row block information */
-00154 typedef struct row_block_tag {
-00155         ULONG   ulFileOffsetStart;
-00156         ULONG   ulFileOffsetEnd;
-00157         ULONG   ulCharPosStart;
-00158         ULONG   ulCharPosEnd;
-00159         short   asColumnWidth[TABLE_COLUMN_MAX+1];      /* In twips */
-00160         UCHAR   ucNumberOfColumns;
-00161         UCHAR   ucBorderInfo;
-00162 } row_block_type;
-00163 
-00164 /* Various level types */
-00165 typedef enum level_type_tag {
-00166         level_type_none = 0,
-00167         level_type_outline,
-00168         level_type_numbering,
-00169         level_type_sequence,
-00170         level_type_pause
-00171 } level_type_enum;
-00172 
-00173 typedef enum list_id_tag {
-00174         no_list = 0,
-00175         text_list,
-00176         footnote_list,
-00177         hdrftr_list,
-00178         macro_list,
-00179         annotation_list,
-00180         endnote_list,
-00181         textbox_list,
-00182         hdrtextbox_list,
-00183         end_of_lists
-00184 } list_id_enum;
-00185 
-00186 /* Linked list of style description information */
-00187 typedef struct style_block_tag {
-00188         ULONG   ulFileOffset;   /* The style start with this character */
-00189         list_id_enum    eListID;/* The fileoffset is in this list */
-00190         BOOL    bNumPause;
-00191         BOOL    bNoRestart;     /* Don't restart by more significant levels */
-00192         USHORT  usIstd;         /* Current style */
-00193         USHORT  usIstdNext;     /* Next style unless overruled */
-00194         USHORT  usStartAt;      /* Number at the start of a list */
-00195         USHORT  usBeforeIndent; /* Vertical indent before paragraph in twips */
-00196         USHORT  usAfterIndent;  /* Vertical indent after paragraph in twips */
-00197         USHORT  usListIndex;    /* Before Word 8 this field was not filled */
-00198         USHORT  usListChar;     /* Character for an itemized list (Unicode) */
-00199         short   sLeftIndent;    /* Left indentation in twips */
-00200         short   sLeftIndent1;   /* First line left indentation in twips */
-00201         short   sRightIndent;   /* Right indentation in twips */
-00202         UCHAR   ucAlignment;
-00203         UCHAR   ucNFC;          /* Number format code */
-00204         UCHAR   ucNumLevel;
-00205         UCHAR   ucListLevel;    /* Before Word 8 this field was not filled */
-00206         char    szListChar[4];  /* Character for an itemized list */
-00207 } style_block_type;
-00208 
-00209 /* Font description information */
-00210 typedef struct font_block_tag {
-00211         ULONG   ulFileOffset;
-00212         USHORT  usFontStyle;
-00213         USHORT  usFontSize;
-00214         UCHAR   ucFontNumber;
-00215         UCHAR   ucFontColor;
-00216 } font_block_type;
-00217 
-00218 /* Picture description information */
-00219 typedef struct picture_block_tag {
-00220         ULONG   ulFileOffset;
-00221         ULONG   ulFileOffsetPicture;
-00222         ULONG   ulPictureOffset;
-00223 } picture_block_type;
-00224 
-00225 /* Section description information */
-00226 typedef struct section_block_tag {
-00227         BOOL    bNewPage;
-00228         USHORT  usNeedPrevLvl;          /* Print previous level numbers */
-00229         USHORT  usHangingIndent;
-00230         UCHAR   aucNFC[9];              /* Number format code */
-00231         UCHAR   ucHdrFtrSpecification;  /* Which headers/footers Word < 8 */
-00232 } section_block_type;
-00233 
-00234 /* Header/footer description information */
-00235 typedef struct hdrftr_block_tag {
-00236         output_type     *pText;
-00237         long            lHeight;        /* In DrawUnits */
-00238 } hdrftr_block_type;
-00239 
-00240 /* Footnote description information */
-00241 typedef struct footnote_block_tag {
-00242         char            *szText;
-00243 } footnote_block_type;
-00244 
-00245 /* List description information */
-00246 typedef struct list_block_tag {
-00247         ULONG   ulStartAt;      /* Number at the start of a list */
-00248         BOOL    bNoRestart;     /* Don't restart by more significant levels */
-00249         USHORT  usListChar;     /* Character for an itemized list (Unicode) */
-00250         short   sLeftIndent;    /* Left indentation in twips */
-00251         UCHAR   ucNFC;          /* Number format code */
-00252 } list_block_type;
-00253 
-00254 /* Types of images */
-00255 typedef enum imagetype_tag {
-00256         imagetype_is_unknown = 0,
-00257         imagetype_is_external,
-00258         imagetype_is_emf,
-00259         imagetype_is_wmf,
-00260         imagetype_is_pict,
-00261         imagetype_is_jpeg,
-00262         imagetype_is_png,
-00263         imagetype_is_dib
-00264 } imagetype_enum;
-00265 
-00266 /* Types of compression */
-00267 typedef enum compression_tag {
-00268         compression_unknown = 0,
-00269         compression_none,
-00270         compression_rle4,
-00271         compression_rle8,
-00272         compression_jpeg,
-00273         compression_zlib
-00274 } compression_enum;
-00275 
-00276 /* Image information */
-00277 typedef struct imagedata_tag {
-00278         /* The type of the image */
-00279         imagetype_enum  eImageType;
-00280         /* Information from the Word document */
-00281         size_t  tPosition;
-00282         size_t  tLength;
-00283         int     iHorSizeScaled;         /* Size in points */
-00284         int     iVerSizeScaled;         /* Size in points */
-00285         /* Information from the image */
-00286         int     iWidth;                 /* Size in pixels */
-00287         int     iHeight;                /* Size in pixels */
-00288         int     iComponents;            /* Number of color components */
-00289         UINT    uiBitsPerComponent;     /* Bits per color component */
-00290         BOOL    bAdobe; /* Image includes Adobe comment marker */
-00291         compression_enum        eCompression;   /* Type of compression */
-00292         BOOL    bColorImage;    /* Is color image */
-00293         int     iColorsUsed;    /* 0 = uses the maximum number of colors */
-00294         UCHAR   aucPalette[256][3];     /* RGB palette */
-00295 } imagedata_type;
-00296 
-00297 typedef enum row_info_tag {
-00298         found_nothing,
-00299         found_a_cell,
-00300         found_not_a_cell,
-00301         found_end_of_row,
-00302         found_not_end_of_row
-00303 } row_info_enum;
-00304 
-00305 typedef enum notetype_tag {
-00306         notetype_is_footnote,
-00307         notetype_is_endnote,
-00308         notetype_is_unknown
-00309 } notetype_enum;
-00310 
-00311 typedef enum image_info_tag {
-00312         image_no_information,
-00313         image_minimal_information,
-00314         image_full_information
-00315 } image_info_enum;
-00316 
-00317 #endif /* __wordtypes_h */
-
-
Generated by  - -doxygen 1.6.2
- - diff -r 59758314f811 -r d4524d6a4472 Symbian3/Examples/guid-6013a680-57f9-415b-8851-c4fa63356636/wordwin_8c_source.html --- a/Symbian3/Examples/guid-6013a680-57f9-415b-8851-c4fa63356636/wordwin_8c_source.html Fri Jun 11 15:24:34 2010 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,225 +0,0 @@ - - - - -TB9.2 Example Applications: examples/PIPS/antiword/src/wordwin.c Source File - - - - - -

examples/PIPS/antiword/src/wordwin.c

00001 /*
-00002  * wordwin.c
-00003  * Copyright (C) 2002-2005 A.J. van Os; Released under GPL
-00004  *
-00005  * Description:
-00006  * Deal with the WIN 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;
-00022         ULONG   ulTextLen, ulFootnoteLen;
-00023         ULONG   ulHdrFtrLen, ulMacroLen, ulAnnotationLen;
-00024         UINT    uiQuickSaves;
-00025         USHORT  usDocStatus;
-00026         BOOL    bTemplate, bFastSaved, bEncrypted, bSuccess;
-00027 
-00028         fail(pFile == NULL);
-00029         fail(aucHeader == NULL);
-00030 
-00031         DBG_MSG("bGetDocumentText");
-00032 
-00033         /* Get the status flags from the header */
-00034         usDocStatus = usGetWord(0x0a, aucHeader);
-00035         DBG_HEX(usDocStatus);
-00036         bTemplate = (usDocStatus & BIT(0)) != 0;
-00037         DBG_MSG_C(bTemplate, "This document is a Template");
-00038         bFastSaved = (usDocStatus & BIT(2)) != 0;
-00039         uiQuickSaves = (UINT)(usDocStatus & 0x00f0) >> 4;
-00040         DBG_MSG_C(bFastSaved, "This document is Fast Saved");
-00041         DBG_DEC_C(bFastSaved, uiQuickSaves);
-00042         if (bFastSaved) {
-00043                 werr(0, "Word2: fast saved documents are not supported yet");
-00044                 return FALSE;
-00045         }
-00046         bEncrypted = (usDocStatus & BIT(8)) != 0;
-00047         if (bEncrypted) {
-00048                 werr(0, "Encrypted documents are not supported");
-00049                 return FALSE;
-00050         }
-00051 
-00052         /* Get length information */
-00053         ulBeginOfText = ulGetLong(0x18, aucHeader);
-00054         DBG_HEX(ulBeginOfText);
-00055         ulTextLen = ulGetLong(0x34, aucHeader);
-00056         ulFootnoteLen = ulGetLong(0x38, aucHeader);
-00057         ulHdrFtrLen = ulGetLong(0x3c, aucHeader);
-00058         ulMacroLen = ulGetLong(0x40, aucHeader);
-00059         ulAnnotationLen = ulGetLong(0x44, aucHeader);
-00060         DBG_DEC(ulTextLen);
-00061         DBG_DEC(ulFootnoteLen);
-00062         DBG_DEC(ulHdrFtrLen);
-00063         DBG_DEC(ulMacroLen);
-00064         DBG_DEC(ulAnnotationLen);
-00065         if (bFastSaved) {
-00066                 bSuccess = FALSE;
-00067         } else {
-00068                 tTextBlock.ulFileOffset = ulBeginOfText;
-00069                 tTextBlock.ulCharPos = ulBeginOfText;
-00070                 tTextBlock.ulLength = ulTextLen +
-00071                                 ulFootnoteLen +
-00072                                 ulHdrFtrLen + ulMacroLen + ulAnnotationLen;
-00073                 tTextBlock.bUsesUnicode = FALSE;
-00074                 tTextBlock.usPropMod = IGNORE_PROPMOD;
-00075                 bSuccess = bAdd2TextBlockList(&tTextBlock);
-00076                 DBG_HEX_C(!bSuccess, tTextBlock.ulFileOffset);
-00077                 DBG_HEX_C(!bSuccess, tTextBlock.ulCharPos);
-00078                 DBG_DEC_C(!bSuccess, tTextBlock.ulLength);
-00079                 DBG_DEC_C(!bSuccess, tTextBlock.bUsesUnicode);
-00080                 DBG_DEC_C(!bSuccess, tTextBlock.usPropMod);
-00081         }
-00082 
-00083         if (bSuccess) {
-00084                 vSplitBlockList(pFile,
-00085                                 ulTextLen,
-00086                                 ulFootnoteLen,
-00087                                 ulHdrFtrLen,
-00088                                 ulMacroLen,
-00089                                 ulAnnotationLen,
-00090                                 0,
-00091                                 0,
-00092                                 0,
-00093                                 FALSE);
-00094         } else {
-00095                 vDestroyTextBlockList();
-00096                 werr(0, "I can't find the text of this document");
-00097         }
-00098         return bSuccess;
-00099 } /* end of bGetDocumentText */
-00100 
-00101 /*
-00102  * vGetDocumentData - make a list of the data blocks of a Word document
-00103  */
-00104 static void
-00105 vGetDocumentData(FILE *pFile, const UCHAR *aucHeader)
-00106 {
-00107         data_block_type tDataBlock;
-00108         options_type    tOptions;
-00109         ULONG   ulEndOfText, ulBeginCharInfo;
-00110         BOOL    bFastSaved, bHasImages, bSuccess;
-00111         USHORT  usDocStatus;
-00112 
-00113         /* Get the options */
-00114         vGetOptions(&tOptions);
-00115 
-00116         /* Get the status flags from the header */
-00117         usDocStatus = usGetWord(0x0a, aucHeader);
-00118         DBG_HEX(usDocStatus);
-00119         bFastSaved = (usDocStatus & BIT(2)) != 0;
-00120         bHasImages = (usDocStatus & BIT(3)) != 0;
-00121 
-00122         if (!bHasImages ||
-00123             tOptions.eConversionType == conversion_text ||
-00124             tOptions.eConversionType == conversion_fmt_text ||
-00125             tOptions.eConversionType == conversion_xml ||
-00126             tOptions.eImageLevel == level_no_images) {
-00127                 /*
-00128                  * No images in the document or text-only output or
-00129                  * no images wanted, so no data blocks will be needed
-00130                  */
-00131                 vDestroyDataBlockList();
-00132                 return;
-00133         }
-00134 
-00135         if (bFastSaved) {
-00136                 bSuccess = FALSE;
-00137         } else {
-00138                 /* This datablock is too big, but it contains all images */
-00139                 ulEndOfText = ulGetLong(0x1c, aucHeader);
-00140                 DBG_HEX(ulEndOfText);
-00141                 ulBeginCharInfo = ulGetLong(0xa0, aucHeader);
-00142                 DBG_HEX(ulBeginCharInfo);
-00143                 if (ulBeginCharInfo > ulEndOfText) {
-00144                         tDataBlock.ulFileOffset = ulEndOfText;
-00145                         tDataBlock.ulDataPos = ulEndOfText;
-00146                         tDataBlock.ulLength = ulBeginCharInfo - ulEndOfText;
-00147                         bSuccess = bAdd2DataBlockList(&tDataBlock);
-00148                         DBG_HEX_C(!bSuccess, tDataBlock.ulFileOffset);
-00149                         DBG_HEX_C(!bSuccess, tDataBlock.ulDataPos);
-00150                         DBG_DEC_C(!bSuccess, tDataBlock.ulLength);
-00151                 } else {
-00152                         bSuccess = ulBeginCharInfo == ulEndOfText;
-00153                 }
-00154         }
-00155 
-00156         if (!bSuccess) {
-00157                 vDestroyDataBlockList();
-00158                 werr(0, "I can't find the data of this document");
-00159         }
-00160 } /* end of vGetDocumentData */
-00161 
-00162 /*
-00163  * iInitDocumentWIN - initialize an WIN document
-00164  *
-00165  * Returns the version of Word that made the document or -1
-00166  */
-00167 int
-00168 iInitDocumentWIN(FILE *pFile, long lFilesize)
-00169 {
-00170         int     iWordVersion;
-00171         BOOL    bSuccess;
-00172         USHORT  usIdent;
-00173         UCHAR   aucHeader[384];
-00174 
-00175         fail(pFile == NULL);
-00176 
-00177         if (lFilesize < 384) {
-00178                 return -1;
-00179         }
-00180 
-00181         /* Read the headerblock */
-00182         if (!bReadBytes(aucHeader, 384, 0x00, pFile)) {
-00183                 return -1;
-00184         }
-00185         /* Get the "magic number" from the header */
-00186         usIdent = usGetWord(0x00, aucHeader);
-00187         DBG_HEX(usIdent);
-00188         fail(usIdent != 0xa59b &&       /* WinWord 1.x */
-00189                 usIdent != 0xa5db);     /* WinWord 2.0 */
-00190         iWordVersion = iGetVersionNumber(aucHeader);
-00191         if (iWordVersion != 1 && iWordVersion != 2) {
-00192                 werr(0, "This file is not from ''Win Word 1 or 2'.");
-00193                 return -1;
-00194         }
-00195         bSuccess = bGetDocumentText(pFile, aucHeader);
-00196         if (bSuccess) {
-00197                 vGetDocumentData(pFile, aucHeader);
-00198                 vGetPropertyInfo(pFile, NULL,
-00199                                 NULL, 0, NULL, 0,
-00200                                 aucHeader, iWordVersion);
-00201                 vSetDefaultTabWidth(pFile, NULL,
-00202                                 NULL, 0, NULL, 0,
-00203                                 aucHeader, iWordVersion);
-00204                 vGetNotesInfo(pFile, NULL,
-00205                                 NULL, 0, NULL, 0,
-00206                                 aucHeader, iWordVersion);
-00207         }
-00208         return bSuccess ? iWordVersion : -1;
-00209 } /* end of iInitDocumentWIN */
-
-
Generated by  - -doxygen 1.6.2
- - diff -r 59758314f811 -r d4524d6a4472 Symbian3/Examples/guid-6013a680-57f9-415b-8851-c4fa63356636/xmalloc_8c_source.html --- a/Symbian3/Examples/guid-6013a680-57f9-415b-8851-c4fa63356636/xmalloc_8c_source.html Fri Jun 11 15:24:34 2010 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,152 +0,0 @@ - - - - -TB9.2 Example Applications: examples/PIPS/antiword/src/xmalloc.c Source File - - - - - -

examples/PIPS/antiword/src/xmalloc.c

00001 /*
-00002  * xmalloc.c
-00003  * Copyright (C) 1998-2005 A.J. van Os
-00004  *
-00005  * Description:
-00006  * Extended malloc and friends
-00007  */
-00008 
-00009 #include <stdlib.h>
-00010 #include <string.h>
-00011 #include "antiword.h"
-00012 
-00013 static char *szMessage =
-00014         "Memory allocation failed, unable to continue";
-00015 #if defined(__dos) && !defined(__DJGPP__)
-00016 static char *szDosMessage =
-00017         "DOS can't allocate this kind of memory, unable to continue";
-00018 #endif /* __dos && !__DJGPP__ */
-00019 
-00020 
-00021 /*
-00022  * xmalloc - Allocates dynamic memory
-00023  *
-00024  * See malloc(3), but unlike malloc(3) xmalloc does not return in case
-00025  * of error.
-00026  */
-00027 void *
-00028 xmalloc(size_t tSize)
-00029 {
-00030         void    *pvTmp;
-00031 
-00032         TRACE_MSG("xmalloc");
-00033 
-00034         if (tSize == 0) {
-00035                 tSize = 1;
-00036         }
-00037         pvTmp = malloc(tSize);
-00038         if (pvTmp == NULL) {
-00039                 DBG_MSG("xmalloc returned NULL");
-00040                 DBG_DEC(tSize);
-00041                 werr(1, szMessage);
-00042         }
-00043         return pvTmp;
-00044 } /* end of xmalloc */
-00045 
-00046 /*
-00047  * xcalloc - Allocates and zeros dynamic memory
-00048  *
-00049  * See calloc(3), but unlike calloc(3) xcalloc does not return in case of error
-00050  */
-00051 void *
-00052 xcalloc(size_t tNmemb, size_t tSize)
-00053 {
-00054         void    *pvTmp;
-00055 
-00056         TRACE_MSG("xcalloc");
-00057 
-00058 #if defined(__dos) && !defined(__DJGPP__)
-00059         if ((ULONG)tNmemb * (ULONG)tSize > 0xffffUL) {
-00060                 DBG_DEC((ULONG)tNmemb * (ULONG)tSize);
-00061                 werr(1, szDosMessage);
-00062         }
-00063 #endif /* __dos && !__DJGPP__ */
-00064 
-00065         if (tNmemb == 0 || tSize == 0) {
-00066                 tNmemb = 1;
-00067                 tSize = 1;
-00068         }
-00069         pvTmp = calloc(tNmemb, tSize);
-00070         if (pvTmp == NULL) {
-00071                 DBG_MSG("xcalloc returned NULL");
-00072                 werr(1, szMessage);
-00073         }
-00074         return pvTmp;
-00075 } /* end of xcalloc */
-00076 
-00077 /*
-00078  * xrealloc - Changes the size of a memory object
-00079  *
-00080  * See realloc(3), but unlike realloc(3) xrealloc does not return in case
-00081  * of error.
-00082  */
-00083 void *
-00084 xrealloc(void *pvArg, size_t tSize)
-00085 {
-00086         void    *pvTmp;
-00087 
-00088         TRACE_MSG("xrealloc");
-00089 
-00090         pvTmp = realloc(pvArg, tSize);
-00091         if (pvTmp == NULL) {
-00092                 DBG_MSG("realloc returned NULL");
-00093                 werr(1, szMessage);
-00094         }
-00095         return pvTmp;
-00096 } /* end of xrealloc */
-00097 
-00098 /*
-00099  * xstrdup - Duplicate a string
-00100  *
-00101  * See strdup(3), but unlike strdup(3) xstrdup does not return in case
-00102  * of error.
-00103  *
-00104  * NOTE:
-00105  * Does not use strdup(3), because some systems don't have it.
-00106  */
-00107 char *
-00108 xstrdup(const char *szArg)
-00109 {
-00110         char    *szTmp;
-00111 
-00112         TRACE_MSG("xstrdup");
-00113 
-00114         szTmp = xmalloc(strlen(szArg) + 1);
-00115         strcpy(szTmp, szArg);
-00116         return szTmp;
-00117 } /* end of xstrdup */
-00118 
-00119 /*
-00120  * xfree - Deallocates dynamic memory
-00121  *
-00122  * See free(3).
-00123  *
-00124  * returns NULL;
-00125  * This makes p=xfree(p) possible, free memory and overwrite the pointer to it.
-00126  */
-00127 void *
-00128 xfree(void *pvArg)
-00129 {
-00130         TRACE_MSG("xfree");
-00131 
-00132         if (pvArg != NULL) {
-00133                 free(pvArg);
-00134         }
-00135         return NULL;
-00136 } /* end of xfree */
-
-
Generated by  - -doxygen 1.6.2
- - diff -r 59758314f811 -r d4524d6a4472 Symbian3/Examples/guid-6013a680-57f9-415b-8851-c4fa63356636/xml_8c_source.html --- a/Symbian3/Examples/guid-6013a680-57f9-415b-8851-c4fa63356636/xml_8c_source.html Fri Jun 11 15:24:34 2010 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1454 +0,0 @@ - - - - -TB9.2 Example Applications: examples/PIPS/antiword/src/xml.c Source File - - - - - -

examples/PIPS/antiword/src/xml.c

00001 /*
-00002  * xml.c
-00003  * Copyright (C) 2002-2005 A.J. van Os; Released under GNU GPL
-00004  *
-00005  * Description:
-00006  * Functions to deal with the XML/DocBook format
-00007  *
-00008  */
-00009 
-00010 #include <string.h>
-00011 #include "antiword.h"
-00012 
-00013 
-00014 #define vAddEndTagsUntil1(p,t)  vAddEndTagsUntil2(p,t,TAG_NOTAG)        
-00015 
-00016 #if defined(DEBUG)
-00017 #define vStackTrace()   __vStackTrace(__LINE__)
-00018 #else
-00019 #define vStackTrace()   /* EMPTY */
-00020 #endif /* DEBUG */
-00021 
-00022 /* The character set */
-00023 static encoding_type    eEncoding = encoding_neutral;
-00024 /* Word version */
-00025 static int      iWordVersion = -1;
-00026 /* Special treatment for files from Word 4/5/6 on an Apple Macintosh */
-00027 static BOOL     bOldMacFile = FALSE;
-00028 /* Text is emphasised */
-00029 static BOOL     bEmphasisOpen = FALSE;
-00030 /* Text is superscript */
-00031 static BOOL     bSuperscriptOpen = FALSE;
-00032 /* Text is subscript */
-00033 static BOOL     bSubscriptOpen = FALSE;
-00034 /* Title is open */
-00035 static BOOL     bTitleOpen = FALSE;
-00036 /* Table is open */
-00037 static BOOL     bTableOpen = FALSE;
-00038 /* Footnote is open */
-00039 static BOOL     bFootnoteOpen = FALSE;
-00040 /* Current paragraph level */
-00041 static UINT     uiParagraphLevel = 0;
-00042 /* Current list level */
-00043 static UINT     uiListLevel = 0;
-00044 /* Current list level is still empty */
-00045 static BOOL     bEmptyListLevel = TRUE;
-00046 /* Current header level */
-00047 static USHORT   usHeaderLevelCurrent = 0;
-00048 /* Current header level is still empty */
-00049 static BOOL     bEmptyHeaderLevel = TRUE;
-00050 /* Number of columns in the current table */
-00051 static int      iTableColumnsCurrent = 0;
-00052 /* Footnote number */
-00053 static UINT     uiFootnoteNumber = 0;
-00054 
-00055 /* Constants for the stack */
-00056 #define INITIAL_STACK_SIZE      10
-00057 #if defined(DEBUG)
-00058 #define EXTENSION_STACK_SIZE     2
-00059 #else
-00060 #define EXTENSION_STACK_SIZE    10
-00061 #endif /* DEBUG */
-00062 
-00063 /* Variables for the stack */
-00064 static UCHAR    *aucStack = NULL;
-00065 static size_t   tStacksize = 0;
-00066 static size_t   tStackNextFree = 0;
-00067 
-00068 /* Constants for the tags */
-00069 #define TAG_NOTAG               (UCHAR)0
-00070 #define TAG_AUTHOR              (UCHAR)1
-00071 #define TAG_BEGINPAGE           (UCHAR)2
-00072 #define TAG_BOOK                (UCHAR)3
-00073 #define TAG_BOOKINFO            (UCHAR)4
-00074 #define TAG_CHAPTER             (UCHAR)5
-00075 #define TAG_COLSPEC             (UCHAR)6
-00076 #define TAG_CORPNAME            (UCHAR)7
-00077 #define TAG_DATE                (UCHAR)8
-00078 #define TAG_EMPHASIS            (UCHAR)9
-00079 #define TAG_ENTRY               (UCHAR)10
-00080 #define TAG_FILENAME            (UCHAR)11
-00081 #define TAG_FOOTNOTE            (UCHAR)12
-00082 #define TAG_INFORMALTABLE       (UCHAR)13
-00083 #define TAG_ITEMIZEDLIST        (UCHAR)14
-00084 #define TAG_LISTITEM            (UCHAR)15
-00085 #define TAG_ORDEREDLIST         (UCHAR)16
-00086 #define TAG_PARA                (UCHAR)17
-00087 #define TAG_ROW                 (UCHAR)18
-00088 #define TAG_SECT1               (UCHAR)19
-00089 #define TAG_SECT2               (UCHAR)20
-00090 #define TAG_SECT3               (UCHAR)21
-00091 #define TAG_SECT4               (UCHAR)22
-00092 #define TAG_SECT5               (UCHAR)23
-00093 #define TAG_SUBSCRIPT           (UCHAR)24
-00094 #define TAG_SUBTITLE            (UCHAR)25
-00095 #define TAG_SUPERSCRIPT         (UCHAR)26
-00096 #define TAG_SURNAME             (UCHAR)27
-00097 #define TAG_TBODY               (UCHAR)28
-00098 #define TAG_TGROUP              (UCHAR)29
-00099 #define TAG_TITLE               (UCHAR)30
-00100 
-00101 typedef struct docbooktags_tag {
-00102         UCHAR   ucTagnumber;
-00103         char    szTagname[15];
-00104         BOOL    bAddNewlineStart;
-00105         BOOL    bAddNewlineEnd;
-00106 } docbooktags_type;
-00107 
-00108 static const docbooktags_type atDocBookTags[] = {
-00109         {       TAG_NOTAG,              "!ERROR!",      TRUE,   TRUE    },
-00110         {       TAG_AUTHOR,             "author",       TRUE,   TRUE    },
-00111         {       TAG_BEGINPAGE,          "beginpage",    TRUE,   TRUE    },
-00112         {       TAG_BOOK,               "book",         TRUE,   TRUE    },
-00113         {       TAG_BOOKINFO,           "bookinfo",     TRUE,   TRUE    },
-00114         {       TAG_CHAPTER,            "chapter",      TRUE,   TRUE    },
-00115         {       TAG_COLSPEC,            "colspec",      TRUE,   TRUE    },
-00116         {       TAG_CORPNAME,           "corpname",     FALSE,  FALSE   },
-00117         {       TAG_DATE,               "date",         FALSE,  FALSE   },
-00118         {       TAG_EMPHASIS,           "emphasis",     FALSE,  FALSE   },
-00119         {       TAG_ENTRY,              "entry",        TRUE,   TRUE    },
-00120         {       TAG_FILENAME,           "filename",     FALSE,  FALSE   },
-00121         {       TAG_FOOTNOTE,           "footnote",     FALSE,  FALSE   },
-00122         {       TAG_INFORMALTABLE,      "informaltable",TRUE,   TRUE    },
-00123         {       TAG_ITEMIZEDLIST,       "itemizedlist", TRUE,   TRUE    },
-00124         {       TAG_LISTITEM,           "listitem",     TRUE,   TRUE    },
-00125         {       TAG_ORDEREDLIST,        "orderedlist",  TRUE,   TRUE    },
-00126         {       TAG_PARA,               "para",         TRUE,   TRUE    },
-00127         {       TAG_ROW,                "row",          TRUE,   TRUE    },
-00128         {       TAG_SECT1,              "sect1",        TRUE,   TRUE    },
-00129         {       TAG_SECT2,              "sect2",        TRUE,   TRUE    },
-00130         {       TAG_SECT3,              "sect3",        TRUE,   TRUE    },
-00131         {       TAG_SECT4,              "sect4",        TRUE,   TRUE    },
-00132         {       TAG_SECT5,              "sect5",        TRUE,   TRUE    },
-00133         {       TAG_SUBSCRIPT,          "subscript",    FALSE,  FALSE   },
-00134         {       TAG_SUBTITLE,           "subtitle",     FALSE,  FALSE   },
-00135         {       TAG_SUPERSCRIPT,        "superscript",  FALSE,  FALSE   },
-00136         {       TAG_SURNAME,            "surname",      FALSE,  FALSE   },
-00137         {       TAG_TBODY,              "tbody",        TRUE,   TRUE    },
-00138         {       TAG_TGROUP,             "tgroup",       TRUE,   TRUE    },
-00139         {       TAG_TITLE,              "title",        FALSE,  FALSE   },
-00140 };
-00141 
-00142 static void     vAddStartTag(diagram_type *, UCHAR, const char *);
-00143 static void     vAddEndTag(diagram_type *, UCHAR);
-00144 static void     vAddCombinedTag(diagram_type *, UCHAR, const char *);
-00145 static void     vPrintChar(diagram_type *, char);
-00146 
-00147 
-00148 #if defined(DEBUG)
-00149 /*
-00150  * vCheckTagTable - check the tag table
-00151  */
-00152 static void
-00153 vCheckTagTable(void)
-00154 {
-00155         size_t  tIndex;
-00156 
-00157         for (tIndex = 0; tIndex < elementsof(atDocBookTags); tIndex++) {
-00158                 if (tIndex != (size_t)atDocBookTags[tIndex].ucTagnumber) {
-00159                         DBG_DEC(tIndex);
-00160                         werr(1, "Array atDocBookTags is broken");
-00161                 }
-00162         }
-00163 } /* end of vCheckTagTable */
-00164 
-00165 /*
-00166  * __vStackTrace - show a stack trace
-00167  */
-00168 static void
-00169 __vStackTrace(int iLine)
-00170 {
-00171         int     iIndex;
-00172 
-00173         fprintf(stderr, "%s[%3d]:\n", __FILE__, iLine);
-00174 
-00175         if (tStackNextFree == 0) {
-00176                 fprintf(stderr, "The stack is empty\n");
-00177                 return;
-00178         }
-00179         for (iIndex = (int)tStackNextFree - 1; iIndex >= 0; iIndex--) {
-00180                 fprintf(stderr, "%2d: %2d: '%s'\n",
-00181                         iIndex,
-00182                         (int)atDocBookTags[(UINT)aucStack[iIndex]].ucTagnumber,
-00183                         atDocBookTags[(UINT)aucStack[iIndex]].szTagname);
-00184         }
-00185 } /* end of __vStackTrace */
-00186 #endif /* DEBUG */
-00187 
-00188 /*
-00189  * vPushStack - push a tag onto the stack
-00190  */
-00191 static void
-00192 vPushStack(UCHAR ucTag)
-00193 {
-00194         fail(tStackNextFree > tStacksize);
-00195 
-00196         if (tStackNextFree == tStacksize) {
-00197                 /* The stack is full; enlarge the stack */
-00198                 tStacksize += EXTENSION_STACK_SIZE;
-00199                 aucStack = xrealloc(aucStack, tStacksize * sizeof(UCHAR));
-00200                 DBG_DEC(tStacksize);
-00201         }
-00202 
-00203         fail(tStackNextFree >= tStacksize);
-00204 
-00205         aucStack[tStackNextFree++] = ucTag;
-00206 } /* end of vPushStack */
-00207 
-00208 /*
-00209  * vPopStack - pop a tag from the stack
-00210  */
-00211 static UCHAR
-00212 ucPopStack(void)
-00213 {
-00214         DBG_DEC_C(tStackNextFree > tStacksize, tStackNextFree);
-00215         DBG_DEC_C(tStackNextFree > tStacksize, tStacksize);
-00216         fail(tStackNextFree > tStacksize);
-00217         fail(tStackNextFree == 0);
-00218 
-00219         if (tStackNextFree == 0) {
-00220                 werr(1, "The stack is empty, unable to continue");
-00221                 return TAG_NOTAG;
-00222         }
-00223         return aucStack[--tStackNextFree];
-00224 } /* end of ucPopStack */
-00225 
-00226 /*
-00227  * vReadStack - read a tag from the top of the stack
-00228  */
-00229 static UCHAR
-00230 ucReadStack(void)
-00231 {
-00232         DBG_DEC_C(tStackNextFree > tStacksize, tStackNextFree);
-00233         DBG_DEC_C(tStackNextFree > tStacksize, tStacksize);
-00234         fail(tStackNextFree > tStacksize);
-00235 
-00236         if (tStackNextFree == 0) {
-00237                 /* The stack is empty */
-00238                 return TAG_NOTAG;
-00239         }
-00240         return aucStack[tStackNextFree - 1];
-00241 } /* end of ucReadStack */
-00242 
-00243 /*
-00244  * vPrintLevel - print the tag level
-00245  */
-00246 static void
-00247 vPrintLevel(FILE *pOutFile)
-00248 {
-00249         size_t  tIndex;
-00250 
-00251         fail(pOutFile == NULL);
-00252 
-00253         for (tIndex = 0; tIndex < tStackNextFree; tIndex++) {
-00254                 (void)putc(' ', pOutFile);
-00255         }
-00256 } /* end of vPrintLevel */
-00257 
-00258 /*
-00259  * vPrintFootnote - print a footnote
-00260  */
-00261 static void
-00262 vPrintFootnote(diagram_type *pDiag, UINT uiFootnoteIndex)
-00263 {
-00264         const char      *szText, *pcTmp;
-00265         BOOL    bSuScript;
-00266         UCHAR   ucTopTag;
-00267 
-00268         TRACE_MSG("vPrintFootnote");
-00269 
-00270         szText = szGetFootnootText(uiFootnoteIndex);
-00271 
-00272         if (szText == NULL) {
-00273                 szText = "";
-00274         }
-00275 
-00276         /* Remove the subscript/superscript (if any) */
-00277         ucTopTag = ucReadStack();
-00278         bSuScript = ucTopTag == TAG_SUBSCRIPT || ucTopTag == TAG_SUPERSCRIPT;
-00279         if (bSuScript) {
-00280                 vAddEndTag(pDiag, ucTopTag);
-00281         }
-00282 
-00283         /* Start a footnote */
-00284         vAddStartTag(pDiag, TAG_FOOTNOTE, NULL);
-00285         vAddStartTag(pDiag, TAG_PARA, NULL);
-00286 
-00287         /* Print a footnote */
-00288         for (pcTmp = szText; *pcTmp != '\0'; pcTmp++) {
-00289                 if (*pcTmp == PAR_END) {
-00290                         if (*(pcTmp + 1) != PAR_END && *(pcTmp + 1) != '\0') {
-00291                                 /* PAR_END is not empty and not last */
-00292                                 vAddEndTag(pDiag, TAG_PARA);
-00293                                 vAddStartTag(pDiag, TAG_PARA, NULL);
-00294                         }
-00295                 } else {
-00296                         vPrintChar(pDiag, *pcTmp);
-00297                 }
-00298         }
-00299 
-00300         /* End a footnote */
-00301         vAddEndTag(pDiag, TAG_PARA);
-00302         vAddEndTag(pDiag, TAG_FOOTNOTE);
-00303 
-00304         /* Repair the subscript/superscript (if any) */
-00305         if (bSuScript) {
-00306                 vAddStartTag(pDiag, ucTopTag, NULL);
-00307         }
-00308 } /* end of vPrintFootnote */
-00309 
-00310 /*
-00311  * vPrintChar - print a character with XML encoding
-00312  */
-00313 static void
-00314 vPrintChar(diagram_type *pDiag, char cChar)
-00315 {
-00316         fail(pDiag == NULL);
-00317         fail(pDiag->pOutFile == NULL);
-00318 
-00319         switch (cChar) {
-00320         case FOOTNOTE_OR_ENDNOTE:
-00321                 uiFootnoteNumber++;
-00322                 vPrintFootnote(pDiag, uiFootnoteNumber - 1);
-00323                 break;
-00324         case '<':
-00325                 fprintf(pDiag->pOutFile, "%s", "&lt;");
-00326                 break;
-00327         case '>':
-00328                 fprintf(pDiag->pOutFile, "%s", "&gt;");
-00329                 break;
-00330         case '&':
-00331                 fprintf(pDiag->pOutFile, "%s", "&amp;");
-00332                 break;
-00333         default:
-00334                 (void)putc(cChar, pDiag->pOutFile);
-00335                 break;
-00336         }
-00337 } /* end of vPrintChar */
-00338 
-00339 /*
-00340  * vPrintSpecialChar - convert and print a character
-00341  */
-00342 static void
-00343 vPrintSpecialChar(diagram_type *pDiag, USHORT usChar)
-00344 {
-00345         ULONG   ulChar;
-00346         size_t  tLen, tIndex;
-00347         char    szResult[4];
-00348 
-00349         fail(pDiag == NULL);
-00350         fail(pDiag->pOutFile == NULL);
-00351         fail(iWordVersion < 0);
-00352         fail(eEncoding == encoding_neutral);
-00353 
-00354         ulChar = ulTranslateCharacters(usChar, 0, iWordVersion,
-00355                                 conversion_xml, eEncoding, bOldMacFile);
-00356         tLen = tUcs2Utf8(ulChar, szResult, sizeof(szResult));
-00357         if (tLen == 1) {
-00358                 vPrintChar(pDiag, szResult[0]);
-00359         } else {
-00360                 for (tIndex = 0; tIndex < tLen; tIndex++) {
-00361                         (void)putc(szResult[tIndex], pDiag->pOutFile);
-00362                 }
-00363         }
-00364 } /* end of vPrintSpecialChar */
-00365 
-00366 /*
-00367  * vPrintSpecialString - convert and print a string
-00368  */
-00369 static void
-00370 vPrintSpecialString(diagram_type *pDiag, const char *szString)
-00371 {
-00372         int     iIndex;
-00373         USHORT  usChar;
-00374 
-00375         fail(pDiag == NULL);
-00376         fail(pDiag->pOutFile == NULL);
-00377         fail(szString == NULL);
-00378 
-00379         for (iIndex = 0; szString[iIndex] != '\0'; iIndex++) {
-00380                 usChar = (USHORT)(UCHAR)szString[iIndex];
-00381                 vPrintSpecialChar(pDiag, usChar);
-00382         }
-00383 } /* end of vPrintSpecialString */
-00384 
-00385 /*
-00386  * vAddStartTag - add the specified start tag to the file
-00387  */
-00388 static void
-00389 vAddStartTag(diagram_type *pDiag, UCHAR ucTag, const char *szAttribute)
-00390 {
-00391         fail(pDiag == NULL);
-00392         fail(pDiag->pOutFile == NULL);
-00393         fail((size_t)ucTag >= elementsof(atDocBookTags));
-00394 
-00395         if (atDocBookTags[(UINT)ucTag].bAddNewlineStart) {
-00396                 fprintf(pDiag->pOutFile, "\n");
-00397                 vPrintLevel(pDiag->pOutFile);
-00398         }
-00399 
-00400         if (szAttribute == NULL || szAttribute[0] == '\0') {
-00401                 fprintf(pDiag->pOutFile, "<%s>",
-00402                         atDocBookTags[(UINT)ucTag].szTagname);
-00403         } else {
-00404                 fprintf(pDiag->pOutFile, "<%s %s>",
-00405                         atDocBookTags[(UINT)ucTag].szTagname, szAttribute);
-00406         }
-00407 
-00408         if (atDocBookTags[(UINT)ucTag].bAddNewlineEnd) {
-00409                 fprintf(pDiag->pOutFile, "\n");
-00410                 pDiag->lXleft = 0;
-00411         }
-00412 
-00413         vPushStack(ucTag);
-00414 
-00415         /* Set global variables */
-00416         switch (ucTag) {
-00417         case TAG_CHAPTER:
-00418                 usHeaderLevelCurrent = 1;
-00419                 bEmptyHeaderLevel = TRUE;
-00420                 break;
-00421         case TAG_SECT1:
-00422                 usHeaderLevelCurrent = 2;
-00423                 bEmptyHeaderLevel = TRUE;
-00424                 break;
-00425         case TAG_SECT2:
-00426                 usHeaderLevelCurrent = 3;
-00427                 bEmptyHeaderLevel = TRUE;
-00428                 break;
-00429         case TAG_SECT3:
-00430                 usHeaderLevelCurrent = 4;
-00431                 bEmptyHeaderLevel = TRUE;
-00432                 break;
-00433         case TAG_SECT4:
-00434                 usHeaderLevelCurrent = 5;
-00435                 bEmptyHeaderLevel = TRUE;
-00436                 break;
-00437         case TAG_SECT5:
-00438                 usHeaderLevelCurrent = 6;
-00439                 bEmptyHeaderLevel = TRUE;
-00440                 break;
-00441         case TAG_TITLE:
-00442                 fail(uiParagraphLevel != 0);
-00443                 bTitleOpen = TRUE;
-00444                 break;
-00445         case TAG_FOOTNOTE:
-00446                 bFootnoteOpen = TRUE;
-00447                 break;
-00448         case TAG_PARA:
-00449                 fail(bTitleOpen && !bFootnoteOpen);
-00450                 uiParagraphLevel++;
-00451                 bEmptyHeaderLevel = FALSE;
-00452                 break;
-00453         case TAG_EMPHASIS:
-00454                 bEmphasisOpen = TRUE;
-00455                 break;
-00456         case TAG_ITEMIZEDLIST:
-00457         case TAG_ORDEREDLIST:
-00458                 uiListLevel++;
-00459                 bEmptyListLevel = TRUE;
-00460                 bEmptyHeaderLevel = FALSE;
-00461                 break;
-00462         case TAG_LISTITEM:
-00463                 bEmptyListLevel = FALSE;
-00464                 break;
-00465         case TAG_SUPERSCRIPT:
-00466                 bSuperscriptOpen = TRUE;
-00467                 break;
-00468         case TAG_SUBSCRIPT:
-00469                 bSubscriptOpen = TRUE;
-00470                 break;
-00471         case TAG_INFORMALTABLE:
-00472                 bTableOpen = TRUE;
-00473                 bEmptyHeaderLevel = FALSE;
-00474                 break;
-00475         default:
-00476                 break;
-00477         }
-00478 } /* end of vAddStartTag */
-00479 
-00480 /*
-00481  * vAddEndTag - add the specified end tag to the file
-00482  */
-00483 static void
-00484 vAddEndTag(diagram_type *pDiag, UCHAR ucTag)
-00485 {
-00486         UCHAR   ucTopTag;
-00487 
-00488         fail(pDiag == NULL);
-00489         fail(pDiag->pOutFile == NULL);
-00490         fail((size_t)ucTag >= elementsof(atDocBookTags));
-00491 
-00492 #if defined(DEBUG)
-00493         ucTopTag = ucReadStack();
-00494         if (ucTag != ucTopTag) {
-00495                 DBG_DEC(ucTag);
-00496                 DBG_MSG(atDocBookTags[(UINT)ucTag].szTagname);
-00497                 vStackTrace();
-00498         }
-00499 #endif /* DEBUG */
-00500 
-00501         ucTopTag = ucPopStack();
-00502         fail((size_t)ucTopTag >= elementsof(atDocBookTags));
-00503         if (ucTag != ucTopTag) {
-00504                 DBG_DEC(ucTag);
-00505                 DBG_DEC(ucTopTag);
-00506                 DBG_FIXME();
-00507                 werr(1, "Impossible tag sequence, unable to continue");
-00508         }
-00509 
-00510         if (atDocBookTags[(UINT)ucTag].bAddNewlineEnd) {
-00511                 fprintf(pDiag->pOutFile, "\n");
-00512                 vPrintLevel(pDiag->pOutFile);
-00513         }
-00514 
-00515         fprintf(pDiag->pOutFile, "</%s>", atDocBookTags[(UINT)ucTag].szTagname);
-00516 
-00517         if (atDocBookTags[(UINT)ucTag].bAddNewlineStart) {
-00518                 fprintf(pDiag->pOutFile, "\n");
-00519                 pDiag->lXleft = 0;
-00520         }
-00521 
-00522         /* Set global variables */
-00523         switch (ucTag) {
-00524         case TAG_CHAPTER:
-00525                 usHeaderLevelCurrent = 0;
-00526                 break;
-00527         case TAG_SECT1:
-00528                 usHeaderLevelCurrent = 1;
-00529                 break;
-00530         case TAG_SECT2:
-00531                 usHeaderLevelCurrent = 2;
-00532                 break;
-00533         case TAG_SECT3:
-00534                 usHeaderLevelCurrent = 3;
-00535                 break;
-00536         case TAG_SECT4:
-00537                 usHeaderLevelCurrent = 4;
-00538                 break;
-00539         case TAG_SECT5:
-00540                 usHeaderLevelCurrent = 5;
-00541                 break;
-00542         case TAG_TITLE:
-00543                 bTitleOpen = FALSE;
-00544                 break;
-00545         case TAG_FOOTNOTE:
-00546                 bFootnoteOpen = FALSE;
-00547                 break;
-00548         case TAG_PARA:
-00549                 uiParagraphLevel--;
-00550                 break;
-00551         case TAG_EMPHASIS:
-00552                 bEmphasisOpen = FALSE;
-00553                 break;
-00554         case TAG_SUPERSCRIPT:
-00555                 bSuperscriptOpen = FALSE;
-00556                 break;
-00557         case TAG_ITEMIZEDLIST:
-00558         case TAG_ORDEREDLIST:
-00559                 uiListLevel--;
-00560                 break;
-00561         case TAG_SUBSCRIPT:
-00562                 bSubscriptOpen = FALSE;
-00563                 break;
-00564         case TAG_INFORMALTABLE:
-00565                 bTableOpen = FALSE;
-00566                 iTableColumnsCurrent = 0;
-00567                 break;
-00568         default:
-00569                 break;
-00570         }
-00571 } /* end of vAddEndTag */
-00572 
-00573 /*
-00574  * vAddEndTagOptional - add the specified end tag to the file if needed
-00575  */
-00576 static void
-00577 vAddEndTagOptional(diagram_type *pDiag, UCHAR ucTag)
-00578 {
-00579         UCHAR   ucTopTag;
-00580 
-00581         ucTopTag = ucReadStack();
-00582         if (ucTag == ucTopTag) {
-00583                 vAddEndTag(pDiag, ucTag);
-00584         }
-00585 } /* end of vAddEndTagOptional */
-00586 
-00587 /*
-00588  * vAddCombinedTag - add the specified start and end tag to the file
-00589  */
-00590 static void
-00591 vAddCombinedTag(diagram_type *pDiag, UCHAR ucTag, const char *szAttribute)
-00592 {
-00593         fail(pDiag == NULL);
-00594         fail(pDiag->pOutFile == NULL);
-00595         fail((size_t)ucTag >= elementsof(atDocBookTags));
-00596 
-00597         if (atDocBookTags[(UINT)ucTag].bAddNewlineStart) {
-00598                 fprintf(pDiag->pOutFile, "\n");
-00599                 vPrintLevel(pDiag->pOutFile);
-00600         }
-00601 
-00602         if (szAttribute == NULL || szAttribute[0] == '\0') {
-00603                 fprintf(pDiag->pOutFile, "<%s/>",
-00604                         atDocBookTags[(UINT)ucTag].szTagname);
-00605         } else {
-00606                 fprintf(pDiag->pOutFile, "<%s %s/>",
-00607                         atDocBookTags[(UINT)ucTag].szTagname, szAttribute);
-00608         }
-00609 
-00610         if (atDocBookTags[(UINT)ucTag].bAddNewlineStart) {
-00611                 fprintf(pDiag->pOutFile, "\n");
-00612                 pDiag->lXleft = 0;
-00613         }
-00614 } /* end of vAddCombinedTag */
-00615 
-00616 /*
-00617  * vAddEndTagsUntil2 - add end tags until one the specified tags is seen
-00618  */
-00619 static void
-00620 vAddEndTagsUntil2(diagram_type *pDiag, UCHAR ucTag1, UCHAR ucTag2)
-00621 {
-00622         UCHAR   ucTopTag;
-00623 
-00624         do {
-00625                 ucTopTag = ucReadStack();
-00626                 switch (ucTopTag) {
-00627                 case TAG_CHAPTER:
-00628                 case TAG_SECT1:
-00629                 case TAG_SECT2:
-00630                 case TAG_SECT3:
-00631                 case TAG_SECT4:
-00632                 case TAG_SECT5:
-00633                         if (bEmptyHeaderLevel) {
-00634                                 /*
-00635                                  * An empty chapter is legal in Word,
-00636                                  * but not in DocBook.
-00637                                  */
-00638                                 vAddCombinedTag(pDiag, TAG_PARA, NULL);
-00639                                 bEmptyHeaderLevel = FALSE;
-00640                         }
-00641                         break;
-00642                 case TAG_ITEMIZEDLIST:
-00643                 case TAG_ORDEREDLIST:
-00644                         if (bEmptyListLevel) {
-00645                                 /*
-00646                                  * A list without items is legal in Word,
-00647                                  * but not in DocBook. (Nor are empty items)
-00648                                  */
-00649                                 vAddStartTag(pDiag, TAG_LISTITEM, NULL);
-00650                                 vAddCombinedTag(pDiag, TAG_PARA, NULL);
-00651                                 vAddEndTag(pDiag, TAG_LISTITEM);
-00652                                 bEmptyListLevel = FALSE;
-00653                         }
-00654                         break;
-00655                 default:
-00656                         break;
-00657                 }
-00658                 vAddEndTag(pDiag, ucTopTag);
-00659         } while (ucTopTag != ucTag1 && ucTopTag != ucTag2);
-00660 } /* end of vAddEndTagsUntil2 */
-00661 
-00662 /*
-00663  * vCreateBookIntro - create title and bookinfo
-00664  */
-00665 void
-00666 vCreateBookIntro(diagram_type *pDiag, int iVersion)
-00667 {
-00668         const char      *szTitle, *szSubject, *szAuthor;
-00669         const char      *szLastSaveDtm, *szCompany;
-00670         const char      *szLanguage;
-00671         char            szTmp[13];
-00672 
-00673         fail(pDiag == NULL);
-00674         fail(pDiag->pOutFile == NULL);
-00675         fail(iVersion < 0);
-00676         fail(eEncoding == encoding_neutral);
-00677 
-00678         iWordVersion = iVersion;
-00679         bOldMacFile = bIsOldMacFile();
-00680         szTitle = szGetTitle();
-00681         szSubject = szGetSubject();
-00682         szAuthor = szGetAuthor();
-00683         szLastSaveDtm = szGetLastSaveDtm();
-00684         szCompany = szGetCompany();
-00685 
-00686         /* Start Book */
-00687         szLanguage = szGetLanguage();
-00688         if (szLanguage != NULL) {
-00689                 DBG_MSG(szLanguage);
-00690                 sprintf(szTmp, "lang='%.5s'", szLanguage);
-00691                 szLanguage = szTmp;
-00692         }
-00693         vAddStartTag(pDiag, TAG_BOOK, szLanguage);
-00694 
-00695         /* Book title */
-00696         if (szTitle != NULL && szTitle[0] != '\0') {
-00697                 vAddStartTag(pDiag, TAG_TITLE, NULL);
-00698                 vPrintSpecialString(pDiag, szTitle);
-00699                 vAddEndTag(pDiag, TAG_TITLE);
-00700         }
-00701         /* Bookinfo */
-00702         if ((szTitle != NULL && szTitle[0] != '\0') ||
-00703             (szSubject != NULL && szSubject[0] != '\0') ||
-00704             (szAuthor != NULL && szAuthor[0] != '\0') ||
-00705             (szLastSaveDtm != NULL && szLastSaveDtm[0] != '\0') ||
-00706             (szCompany != NULL && szCompany[0] != '\0')) {
-00707                 vAddStartTag(pDiag, TAG_BOOKINFO, NULL);
-00708                 if (szTitle != NULL && szTitle[0] != '\0') {
-00709                         vAddStartTag(pDiag, TAG_TITLE, NULL);
-00710                         vPrintSpecialString(pDiag, szTitle);
-00711                         vAddEndTag(pDiag, TAG_TITLE);
-00712                 }
-00713                 if (szSubject != NULL && szSubject[0] != '\0') {
-00714                         vAddStartTag(pDiag, TAG_SUBTITLE, NULL);
-00715                         vPrintSpecialString(pDiag, szSubject);
-00716                         vAddEndTag(pDiag, TAG_SUBTITLE);
-00717                 }
-00718                 if (szAuthor != NULL && szAuthor[0] != '\0') {
-00719                         vAddStartTag(pDiag, TAG_AUTHOR, NULL);
-00720                         vAddStartTag(pDiag, TAG_SURNAME, NULL);
-00721                         vPrintSpecialString(pDiag, szAuthor);
-00722                         vAddEndTag(pDiag, TAG_SURNAME);
-00723                         vAddEndTag(pDiag, TAG_AUTHOR);
-00724                 }
-00725                 if (szLastSaveDtm != NULL && szLastSaveDtm[0] != '\0') {
-00726                         vAddStartTag(pDiag, TAG_DATE, NULL);
-00727                         vPrintSpecialString(pDiag, szLastSaveDtm);
-00728                         vAddEndTag(pDiag, TAG_DATE);
-00729                 }
-00730                 if (szCompany != NULL && szCompany[0] != '\0') {
-00731                         vAddStartTag(pDiag, TAG_CORPNAME, NULL);
-00732                         vPrintSpecialString(pDiag, szCompany);
-00733                         vAddEndTag(pDiag, TAG_CORPNAME);
-00734                 }
-00735                 vAddEndTag(pDiag, TAG_BOOKINFO);
-00736         }
-00737 } /* end of vCreateBookIntro */
-00738 
-00739 /*
-00740  * vPrologueXML - perform the XML initialization
-00741  */
-00742 void
-00743 vPrologueXML(diagram_type *pDiag, const options_type *pOptions)
-00744 {
-00745 
-00746         fail(pDiag == NULL);
-00747         fail(pDiag->pOutFile == NULL);
-00748         fail(pOptions == NULL);
-00749 
-00750 #if defined(DEBUG)
-00751         vCheckTagTable();
-00752 #endif /* DEBUG */
-00753 
-00754         /* Set global variables to their start values */
-00755         eEncoding = pOptions->eEncoding;
-00756         bEmphasisOpen = FALSE;
-00757         bSuperscriptOpen = FALSE;
-00758         bSubscriptOpen = FALSE;
-00759         bTitleOpen = FALSE;
-00760         bTableOpen = FALSE;
-00761         bFootnoteOpen = FALSE;
-00762         uiParagraphLevel = 0;
-00763         uiListLevel = 0;
-00764         bEmptyListLevel = TRUE;
-00765         usHeaderLevelCurrent = 0;
-00766         bEmptyHeaderLevel = TRUE;
-00767         iTableColumnsCurrent = 0;
-00768         uiFootnoteNumber = 0;
-00769 
-00770         pDiag->lXleft = 0;
-00771         pDiag->lYtop = 0;
-00772 
-00773         /* Create an empty stack */
-00774         tStacksize = INITIAL_STACK_SIZE;
-00775         aucStack = xcalloc(tStacksize, sizeof(UCHAR));
-00776         tStackNextFree = 0;
-00777 } /* end of vPrologueXML */
-00778 
-00779 /*
-00780  * vEpilogueXML - clean up after everything is done
-00781  */
-00782 void
-00783 vEpilogueXML(diagram_type *pDiag)
-00784 {
-00785         vStackTrace();
-00786 
-00787         vAddEndTagsUntil1(pDiag, TAG_BOOK);
-00788 
-00789         vStackTrace();
-00790 
-00791         /* Destroy the stack */
-00792         fail(tStackNextFree != 0);
-00793         tStacksize = 0;
-00794         aucStack = xfree(aucStack);
-00795         tStackNextFree = 0;
-00796 } /* end of vEpilogueXML */
-00797 
-00798 /*
-00799  * vPrintXML - print a XML string
-00800  */
-00801 static void
-00802 vPrintXML(diagram_type *pDiag, const char *szString, size_t tStringLength,
-00803                 USHORT usFontstyle)
-00804 {
-00805         const char      *szAttr;
-00806         int     iCount;
-00807         size_t  tNextFree;
-00808         BOOL    bNotReady, bEmphasisNew, bSuperscriptNew, bSubscriptNew;
-00809         UCHAR   ucTopTag, aucStorage[3];
-00810 
-00811         fail(szString == NULL);
-00812 
-00813         if (szString == NULL || szString[0] == '\0' || tStringLength == 0) {
-00814                 return;
-00815         }
-00816 
-00817         if (tStringLength == 1 && szString[0] == FOOTNOTE_OR_ENDNOTE) {
-00818                 /* Don't do anything special for just a single footnote */
-00819                 bEmphasisNew = FALSE;
-00820                 bSuperscriptNew = FALSE;
-00821                 bSubscriptNew = FALSE;
-00822         } else {
-00823                 /* Situation normal */
-00824                 bEmphasisNew = bIsBold(usFontstyle) ||
-00825                                 bIsItalic(usFontstyle) ||
-00826                                 bIsUnderline(usFontstyle) ||
-00827                                 bIsStrike(usFontstyle);
-00828                 bSuperscriptNew = bIsSuperscript(usFontstyle);
-00829                 bSubscriptNew = bIsSubscript(usFontstyle);
-00830         }
-00831 
-00832         /* End what has to be ended (or more to keep the stack happy) */
-00833         tNextFree = 0;
-00834         bNotReady = TRUE;
-00835         do {
-00836                 ucTopTag = ucReadStack();
-00837                 switch (ucTopTag) {
-00838                 case TAG_EMPHASIS:
-00839                         fail(!bEmphasisOpen);
-00840                         if (bEmphasisNew) {
-00841                                 aucStorage[tNextFree++] = ucTopTag;
-00842                         }
-00843                         vAddEndTag(pDiag, ucTopTag);
-00844                         break;
-00845                 case TAG_SUPERSCRIPT:
-00846                         fail(!bSuperscriptOpen);
-00847                         if (bSuperscriptNew) {
-00848                                 aucStorage[tNextFree++] = ucTopTag;
-00849                         }
-00850                         vAddEndTag(pDiag, ucTopTag);
-00851                         break;
-00852                 case TAG_SUBSCRIPT:
-00853                         fail(!bSubscriptOpen);
-00854                         if (bSubscriptNew) {
-00855                                 aucStorage[tNextFree++] = ucTopTag;
-00856                         }
-00857                         vAddEndTag(pDiag, ucTopTag);
-00858                         break;
-00859                 default:
-00860                         bNotReady = FALSE;
-00861                         break;
-00862                 }
-00863                 fail(tNextFree > elementsof(aucStorage));
-00864                 fail(bNotReady && tNextFree == elementsof(aucStorage));
-00865         } while (bNotReady);
-00866 
-00867         /* Just te make sure */
-00868         vStartOfParagraphXML(pDiag, 1);
-00869 
-00870         /* Restart to keep the stack happy */
-00871         for (iCount = (int)tNextFree - 1; iCount > 0; iCount--) {
-00872                 vAddStartTag(pDiag, aucStorage[iCount], NULL);
-00873         }
-00874 
-00875         /* Start what has to be started */
-00876         if (bEmphasisNew && !bEmphasisOpen) {
-00877                 if (bIsBold(usFontstyle)) {
-00878                         szAttr = "role='bold'";
-00879                 } else if (bIsItalic(usFontstyle)) {
-00880                         szAttr = NULL;
-00881                 } else if (bIsUnderline(usFontstyle)) {
-00882                         szAttr = "role='underline'";
-00883                 } else if (bIsStrike(usFontstyle)) {
-00884                         szAttr = "role='strikethrough'";
-00885                 } else {
-00886                         szAttr = NULL;
-00887                 }
-00888                 vAddStartTag(pDiag, TAG_EMPHASIS, szAttr);
-00889         }
-00890         if (bSuperscriptNew && !bSuperscriptOpen) {
-00891                 vAddStartTag(pDiag, TAG_SUPERSCRIPT, NULL);
-00892         }
-00893         if (bSubscriptNew && !bSubscriptOpen) {
-00894                 vAddStartTag(pDiag, TAG_SUBSCRIPT, NULL);
-00895         }
-00896 
-00897         /* The print the string */
-00898         for (iCount = 0; iCount < (int)tStringLength; iCount++) {
-00899                 vPrintChar(pDiag, szString[iCount]);
-00900         }
-00901 } /* end of vPrintXML */
-00902 
-00903 /*
-00904  * vMove2NextLineXML - move to the next line
-00905  */
-00906 void
-00907 vMove2NextLineXML(diagram_type *pDiag)
-00908 {
-00909         fail(pDiag == NULL);
-00910 
-00911         /*
-00912         if (uiParagraphLevel != 0) {
-00913                 We need something like HTML's <BR> tag
-00914         }
-00915         */
-00916 } /* end of vMove2NextLineXML */
-00917 
-00918 /*
-00919  * vSubstringXML - put a sub string into a diagram
-00920  */
-00921 void
-00922 vSubstringXML(diagram_type *pDiag,
-00923         const char *szString, size_t tStringLength, long lStringWidth,
-00924         USHORT usFontstyle)
-00925 {
-00926         fail(pDiag == NULL || szString == NULL);
-00927         fail(pDiag->pOutFile == NULL);
-00928         fail(pDiag->lXleft < 0);
-00929         fail(tStringLength != strlen(szString));
-00930 
-00931         if (szString[0] == '\0' || tStringLength == 0) {
-00932                 return;
-00933         }
-00934 
-00935         vPrintXML(pDiag, szString, tStringLength, usFontstyle);
-00936         pDiag->lXleft += lStringWidth;
-00937 } /* end of vSubstringXML */
-00938 
-00939 /*
-00940  * Create an start of a paragraph
-00941  * Only works on paragraph level one, because Word doesn't allow paragraphs
-00942  * in paragraphs. Other paragraph levels result from DocBooks special needs.
-00943  */
-00944 void
-00945 vStartOfParagraphXML(diagram_type *pDiag, UINT uiMaxLevel)
-00946 {
-00947         fail(pDiag == NULL);
-00948 
-00949         if (uiParagraphLevel >= uiMaxLevel || bTitleOpen) {
-00950                 /* In Word a title is just a paragraph */
-00951                 return;
-00952         }
-00953         if (uiListLevel != 0 && bEmptyListLevel) {
-00954                 /* No paragraphs in a list before the first listitem */
-00955                 return;
-00956         }
-00957         if (usHeaderLevelCurrent == 0) {
-00958                 /* No paragraphs without an open header */
-00959                 vAddStartTag(pDiag, TAG_CHAPTER, NULL);
-00960                 /* Dummy title */
-00961                 vAddCombinedTag(pDiag, TAG_TITLE, NULL);
-00962         }
-00963         vAddStartTag(pDiag, TAG_PARA, NULL);
-00964 } /* end of vStartOfParagraphXML */
-00965 
-00966 /*
-00967  * Create an end of a paragraph
-00968  * Only for paragraph level one and for titles
-00969  */
-00970 void
-00971 vEndOfParagraphXML(diagram_type *pDiag, UINT uiMaxLevel)
-00972 {
-00973         UCHAR   ucTopTag;
-00974 
-00975         fail(pDiag == NULL);
-00976 
-00977         if (uiParagraphLevel > uiMaxLevel) {
-00978                 DBG_DEC(uiParagraphLevel);
-00979                 return;
-00980         }
-00981 
-00982         for(;;) {
-00983                 ucTopTag = ucReadStack();
-00984                 switch (ucTopTag) {
-00985                 case TAG_EMPHASIS:
-00986                         fail(!bEmphasisOpen);
-00987                         vAddEndTag(pDiag, TAG_EMPHASIS);
-00988                         break;
-00989                 case TAG_SUPERSCRIPT:
-00990                         fail(!bSuperscriptOpen);
-00991                         vAddEndTag(pDiag, TAG_SUPERSCRIPT);
-00992                         break;
-00993                 case TAG_SUBSCRIPT:
-00994                         fail(!bSubscriptOpen);
-00995                         vAddEndTag(pDiag, TAG_SUBSCRIPT);
-00996                         break;
-00997                 case TAG_TITLE:
-00998                         fail(!bTitleOpen);
-00999                         vAddEndTag(pDiag, TAG_TITLE);
-01000                         return;
-01001                 case TAG_PARA:
-01002                         fail(uiParagraphLevel == 0);
-01003                         vAddEndTag(pDiag, TAG_PARA);
-01004                         return;
-01005                 case TAG_TBODY:
-01006                 case TAG_TGROUP:
-01007                 case TAG_INFORMALTABLE:
-01008                         fail(!bTableOpen);
-01009                         vAddEndTag(pDiag, ucTopTag);
-01010                         break;
-01011                 case TAG_NOTAG:
-01012                         DBG_FIXME();
-01013                         werr(1, "Impossible tag sequence, unable to continue");
-01014                         break;
-01015                 default:
-01016                         DBG_DEC(ucTopTag);
-01017                         DBG_MSG_C((size_t)ucTopTag < elementsof(atDocBookTags),
-01018                                 atDocBookTags[(UINT)ucTopTag].szTagname);
-01019                         return;
-01020                 }
-01021         }
-01022 } /* end of vEndOfParagraphXML */
-01023 
-01024 /*
-01025  * Create an end of a page
-01026  */
-01027 void
-01028 vEndOfPageXML(diagram_type *pDiag)
-01029 {
-01030         if (bTableOpen || usHeaderLevelCurrent == 0) {
-01031                 /* No beginpage in a table or outside a chapter */
-01032                 return;
-01033         }
-01034         if (bTitleOpen) {
-01035                 /* A beginpage is not allowed when in a title */
-01036                 /* So start a new paragraph */
-01037                 vEndOfParagraphXML(pDiag, UINT_MAX);
-01038                 vStartOfParagraphXML(pDiag, UINT_MAX);
-01039                 return;
-01040         }
-01041         vAddCombinedTag(pDiag, TAG_BEGINPAGE, NULL);
-01042 } /* end of vEndOfPageXML */
-01043 
-01044 /*
-01045  * vCloseHeaderLevels - close the specified header levels
-01046  */
-01047 static void
-01048 vCloseHeaderLevels(diagram_type *pDiag, USHORT usIstd)
-01049 {
-01050         BOOL    bNotReady;
-01051         UCHAR   ucTopTag;
-01052 
-01053         DBG_MSG("vCloseHeaderLevels");
-01054         DBG_DEC(usIstd);
-01055         DBG_DEC(usHeaderLevelCurrent);
-01056 
-01057         vStackTrace();
-01058 
-01059         bNotReady = TRUE;
-01060         do {
-01061                 ucTopTag = ucReadStack();
-01062                 switch (ucTopTag) {
-01063                 case TAG_TITLE:
-01064                 case TAG_PARA:
-01065                         vAddEndTag(pDiag, ucTopTag);
-01066                         break;
-01067                 default:
-01068                         bNotReady = FALSE;
-01069                         break;
-01070                 }
-01071         } while (bNotReady);
-01072 
-01073         vStackTrace();
-01074 
-01075         while (usHeaderLevelCurrent >= usIstd) {
-01076                 if (bEmptyHeaderLevel) {
-01077                         vAddCombinedTag(pDiag, TAG_PARA, NULL);
-01078                         bEmptyHeaderLevel = FALSE;
-01079                 }
-01080                 switch (usHeaderLevelCurrent) {
-01081                 case 1: vAddEndTag(pDiag, TAG_CHAPTER); break;
-01082                 case 2: vAddEndTag(pDiag, TAG_SECT1); break;
-01083                 case 3: vAddEndTag(pDiag, TAG_SECT2); break;
-01084                 case 4: vAddEndTag(pDiag, TAG_SECT3); break;
-01085                 case 5: vAddEndTag(pDiag, TAG_SECT4); break;
-01086                 case 6: vAddEndTag(pDiag, TAG_SECT5); break;
-01087                 default:
-01088                         DBG_DEC(usHeaderLevelCurrent);
-01089                         DBG_FIXME();
-01090                         return;
-01091                 }
-01092         }
-01093 
-01094         DBG_DEC(usHeaderLevelCurrent);
-01095 
-01096         vStackTrace();
-01097 } /* end of vCloseHeaderLevels */
-01098 
-01099 /*
-01100  * vSetHeadersXML - set the headers
-01101  */
-01102 void
-01103 vSetHeadersXML(diagram_type *pDiag, USHORT usIstd)
-01104 {
-01105         fail(pDiag == NULL);
-01106 
-01107         if (usIstd == 0 || usIstd > 6) {
-01108                 DBG_DEC_C(usIstd != 0 && usIstd <= 9, usIstd);
-01109                 return;
-01110         }
-01111         DBG_DEC(usIstd);
-01112 
-01113         if (bTableOpen || uiListLevel != 0) {
-01114                 /* No headers when you're in a table or in a list */
-01115                 return;
-01116         }
-01117 
-01118         /* Close levels */
-01119         vCloseHeaderLevels(pDiag, usIstd);
-01120 
-01121         DBG_DEC(usHeaderLevelCurrent);
-01122 
-01123         /* Open levels */
-01124         while (usHeaderLevelCurrent < usIstd) {
-01125                 switch (usHeaderLevelCurrent) {
-01126                 case 0: vAddStartTag(pDiag, TAG_CHAPTER, NULL); break;
-01127                 case 1: vAddStartTag(pDiag, TAG_SECT1, NULL); break;
-01128                 case 2: vAddStartTag(pDiag, TAG_SECT2, NULL); break;
-01129                 case 3: vAddStartTag(pDiag, TAG_SECT3, NULL); break;
-01130                 case 4: vAddStartTag(pDiag, TAG_SECT4, NULL); break;
-01131                 case 5: vAddStartTag(pDiag, TAG_SECT5, NULL); break;
-01132                 default:
-01133                         DBG_DEC(usHeaderLevelCurrent);
-01134                         DBG_FIXME();
-01135                         return;
-01136                 }
-01137                 fail(usIstd == 0);
-01138                 /* The next paragraph should be a title */
-01139                 if (usHeaderLevelCurrent < usIstd) {
-01140                         /* This chapter level is not in the Word document */
-01141                         vAddCombinedTag(pDiag, TAG_TITLE, NULL);
-01142                 } else {
-01143                         vAddStartTag(pDiag, TAG_TITLE, NULL);
-01144                 }
-01145         }
-01146 } /* end of vSetHeadersXML */
-01147 
-01148 /*
-01149  * Create a start of a list
-01150  */
-01151 void
-01152 vStartOfListXML(diagram_type *pDiag, UCHAR ucNFC, BOOL bIsEndOfTable)
-01153 {
-01154         const char      *szAttr;
-01155         UCHAR           ucTag;
-01156 
-01157         fail(pDiag == NULL);
-01158 
-01159         if (bIsEndOfTable) {
-01160                 /* FIXME: until a list in a table is allowed */
-01161                 vEndOfTableXML(pDiag);
-01162         }
-01163 
-01164         if (bTableOpen) {
-01165                 /* FIXME: a list in a table should be allowed */
-01166                 return;
-01167         }
-01168 
-01169         if (usHeaderLevelCurrent == 0) {
-01170                 /* No list without an open header */
-01171                 vAddStartTag(pDiag, TAG_CHAPTER, NULL);
-01172                 /* Dummy title */
-01173                 vAddCombinedTag(pDiag, TAG_TITLE, NULL);
-01174         }
-01175 
-01176         switch (ucNFC) {
-01177         case LIST_ARABIC_NUM:
-01178         case LIST_ORDINAL_NUM:
-01179         case LIST_NUMBER_TXT:
-01180         case LIST_ORDINAL_TXT:
-01181         case LIST_OUTLINE_NUM:
-01182                 ucTag = TAG_ORDEREDLIST;
-01183                 szAttr = "numeration='arabic'";
-01184                 break;
-01185         case LIST_UPPER_ROMAN:
-01186                 ucTag = TAG_ORDEREDLIST;
-01187                 szAttr = "numeration='upperroman'";
-01188                 break;
-01189         case LIST_LOWER_ROMAN:
-01190                 ucTag = TAG_ORDEREDLIST;
-01191                 szAttr = "numeration='lowerroman'";
-01192                 break;
-01193         case LIST_UPPER_ALPHA:
-01194                 ucTag = TAG_ORDEREDLIST;
-01195                 szAttr = "numeration='upperalpha'";
-01196                 break;
-01197         case LIST_LOWER_ALPHA:
-01198                 ucTag = TAG_ORDEREDLIST;
-01199                 szAttr = "numeration='loweralpha'";
-01200                 break;
-01201         case LIST_SPECIAL:
-01202         case LIST_SPECIAL2:
-01203         case LIST_BULLETS:
-01204                 ucTag = TAG_ITEMIZEDLIST;
-01205                 szAttr = "mark='bullet'";
-01206                 break;
-01207         default:
-01208                 ucTag = TAG_ORDEREDLIST;
-01209                 szAttr = "numeration='arabic'";
-01210                 DBG_HEX(ucNFC);
-01211                 DBG_FIXME();
-01212                 break;
-01213         }
-01214         vAddStartTag(pDiag, ucTag, szAttr);
-01215 } /* end of vStartOfListXML */
-01216 
-01217 /*
-01218  * Create an end of a list
-01219  */
-01220 void
-01221 vEndOfListXML(diagram_type *pDiag)
-01222 {
-01223         fail(pDiag == NULL);
-01224 
-01225         if (bTableOpen) {
-01226                 /* FIXME: a list in a table should be allowed */
-01227                 return;
-01228         }
-01229 
-01230         if (uiListLevel != 0) {
-01231                 vStackTrace();
-01232                 vAddEndTagsUntil2(pDiag, TAG_ITEMIZEDLIST, TAG_ORDEREDLIST);
-01233                 vStackTrace();
-01234         }
-01235 } /* end of vEndOfListXML */
-01236 
-01237 /*
-01238  * Create a start of a list item
-01239  */
-01240 void
-01241 vStartOfListItemXML(diagram_type *pDiag, BOOL bNoMarks)
-01242 {
-01243         const char      *szAttr;
-01244         UCHAR   ucTopTag;
-01245 
-01246         fail(pDiag == NULL);
-01247 
-01248         if (bTableOpen) {
-01249                 /* FIXME: a list in a table should be allowed */
-01250                 return;
-01251         }
-01252 
-01253         ucTopTag = ucReadStack();
-01254         if (ucTopTag != TAG_ITEMIZEDLIST && ucTopTag != TAG_ORDEREDLIST) {
-01255                 /* Must end a previous list item first */
-01256                 vAddEndTagsUntil1(pDiag, TAG_LISTITEM);
-01257         }
-01258 
-01259         DBG_DEC_C(ucReadStack() != TAG_ITEMIZEDLIST &&
-01260                 ucReadStack() != TAG_ORDEREDLIST, ucReadStack());
-01261 
-01262         /* Start a new list item */
-01263         szAttr = bNoMarks ? "override='none'" : NULL;
-01264         vAddStartTag(pDiag, TAG_LISTITEM, szAttr);
-01265         /* Start a new paragraph (independant of level) */
-01266         vAddStartTag(pDiag, TAG_PARA, NULL);
-01267 } /* end of vStartOfListItemXML */
-01268 
-01269 /*
-01270  * Create a start of a table
-01271  */
-01272 static void
-01273 vStartOfTable(diagram_type *pDiag, UCHAR ucBorderInfo)
-01274 {
-01275         const char      *szFrame;
-01276         BOOL    bNotReady;
-01277         UCHAR   ucTopTag;
-01278         char    cColSep, cRowSep;
-01279         char    szAttr[40];
-01280 
-01281         fail(pDiag == NULL);
-01282 
-01283         /* Close elements that cannot contain a table */
-01284         bNotReady = TRUE;
-01285         do {
-01286                 ucTopTag = ucReadStack();
-01287                 switch (ucTopTag) {
-01288                 case TAG_TITLE:
-01289                         fail(!bTitleOpen);
-01290                         vAddEndTag(pDiag, TAG_TITLE);
-01291                         break;
-01292                 case TAG_EMPHASIS:
-01293                         fail(!bEmphasisOpen);
-01294                         vAddEndTag(pDiag, TAG_EMPHASIS);
-01295                         break;
-01296                 case TAG_SUPERSCRIPT:
-01297                         fail(!bSuperscriptOpen);
-01298                         vAddEndTag(pDiag, TAG_SUPERSCRIPT);
-01299                         break;
-01300                 case TAG_SUBSCRIPT:
-01301                         fail(!bSubscriptOpen);
-01302                         vAddEndTag(pDiag, TAG_SUBSCRIPT);
-01303                         break;
-01304                 default:
-01305                         bNotReady = FALSE;
-01306                         break;
-01307                 }
-01308         } while (bNotReady);
-01309 
-01310         /* Create table attributes */
-01311         switch (ucBorderInfo) {
-01312         case TABLE_BORDER_TOP:
-01313                 szFrame = "top";
-01314                 break;
-01315         case TABLE_BORDER_LEFT|TABLE_BORDER_RIGHT:
-01316                 szFrame = "sides";
-01317                 break;
-01318         case TABLE_BORDER_TOP|TABLE_BORDER_BOTTOM:
-01319                 szFrame = "topbot";
-01320                 break;
-01321         case TABLE_BORDER_BOTTOM:
-01322                 szFrame = "bottom";
-01323                 break;
-01324         case TABLE_BORDER_TOP|TABLE_BORDER_LEFT|
-01325              TABLE_BORDER_BOTTOM|TABLE_BORDER_RIGHT:
-01326                 szFrame = "all";
-01327                 break;
-01328         default:
-01329                 szFrame = "none";
-01330                 break;
-01331         }
-01332         cColSep = bIsTableBorderLeft(ucBorderInfo) ||
-01333                   bIsTableBorderRight(ucBorderInfo) ? '1' : '0';
-01334         cRowSep = bIsTableBorderTop(ucBorderInfo) ||
-01335                   bIsTableBorderBottom(ucBorderInfo) ? '1' : '0';
-01336 
-01337         sprintf(szAttr, "frame='%.6s' colsep='%c' rowsep='%c'",
-01338                         szFrame, cColSep, cRowSep);
-01339 
-01340         if (usHeaderLevelCurrent == 0) {
-01341                 /* No table without an open header */
-01342                 vAddStartTag(pDiag, TAG_CHAPTER, NULL);
-01343                 /* Dummy title */
-01344                 vAddCombinedTag(pDiag, TAG_TITLE, NULL);
-01345         }
-01346         vAddStartTag(pDiag, TAG_INFORMALTABLE, szAttr);
-01347 } /* end of vStartOfTable */
-01348 
-01349 /*
-01350  * Create a start of a table group
-01351  */
-01352 static void
-01353 vStartOfTableGroup(diagram_type *pDiag,
-01354         int iNbrOfColumns, const short *asColumnWidth)
-01355 {
-01356         double  dWidth;
-01357         int     iIndex;
-01358         char    szCols[6 + 3 * sizeof(int) + 1 + 1];
-01359         char    szColWidth[10 + 3 * sizeof(short) + 3 + 3 + 1];
-01360 
-01361         fail(iNbrOfColumns < 1);
-01362         fail(asColumnWidth == NULL);
-01363 
-01364         sprintf(szCols, "cols='%d'", iNbrOfColumns);
-01365         vAddStartTag(pDiag, TAG_TGROUP, szCols);
-01366 
-01367         for (iIndex= 0; iIndex < iNbrOfColumns; iIndex++) {
-01368                 fail(asColumnWidth[iIndex] < 0);
-01369                 dWidth = dTwips2Points(asColumnWidth[iIndex]);
-01370                 if (dWidth <= 1.0) {
-01371                         strcpy(szColWidth, "colwidth='1.00pt'");
-01372                 } else {
-01373                         sprintf(szColWidth, "colwidth='%.2fpt'", dWidth);
-01374                 }
-01375                 vAddCombinedTag(pDiag, TAG_COLSPEC, szColWidth);
-01376         }
-01377 } /* end of vStartOfTableGroup */
-01378 
-01379 /*
-01380  * Create an end of a table
-01381  */
-01382 void
-01383 vEndOfTableXML(diagram_type *pDiag)
-01384 {
-01385         fail(pDiag == NULL);
-01386 
-01387         if (bTableOpen) {
-01388                 vAddEndTag(pDiag, TAG_TBODY);
-01389                 vAddEndTag(pDiag, TAG_TGROUP);
-01390                 vAddEndTag(pDiag, TAG_INFORMALTABLE);
-01391         }
-01392 } /* end of vEndOfTableXML */
-01393 
-01394 /*
-01395  * Add a table row
-01396  */
-01397 void
-01398 vAddTableRowXML(diagram_type *pDiag, char **aszColTxt,
-01399         int iNbrOfColumns, const short *asColumnWidth, UCHAR ucBorderInfo)
-01400 {
-01401         size_t  tCount, tStringLength;
-01402         int     iIndex;
-01403 
-01404         fail(pDiag == NULL);
-01405         fail(pDiag->pOutFile == NULL);
-01406         fail(aszColTxt == NULL);
-01407         fail(iNbrOfColumns < 1);
-01408         fail(asColumnWidth == NULL);
-01409 
-01410         if (iNbrOfColumns != iTableColumnsCurrent) {
-01411                 /* A new number of columns */
-01412                 /* End the old table body and table group (if they exist) */
-01413                 vAddEndTagOptional(pDiag, TAG_TBODY);
-01414                 vAddEndTagOptional(pDiag, TAG_TGROUP);
-01415                 if (!bTableOpen) {
-01416                         /* No table yet. Start a new table */
-01417                         vStartOfTable(pDiag, ucBorderInfo);
-01418                 }
-01419                 /* Start a new table group and a new table body */
-01420                 vStartOfTableGroup(pDiag, iNbrOfColumns, asColumnWidth);
-01421                 vAddStartTag(pDiag, TAG_TBODY, NULL);
-01422                 iTableColumnsCurrent = iNbrOfColumns;
-01423         }
-01424 
-01425         /* Add the table row */
-01426         vAddStartTag(pDiag, TAG_ROW, NULL);
-01427         for (iIndex = 0; iIndex < iNbrOfColumns; iIndex++) {
-01428                 /* Add a table cell */
-01429                 fail(aszColTxt[iIndex] == NULL);
-01430                 vAddStartTag(pDiag, TAG_ENTRY, NULL);
-01431                 tStringLength = strlen(aszColTxt[iIndex]);
-01432                 for (tCount = 0; tCount < tStringLength; tCount++) {
-01433                         vPrintChar(pDiag, aszColTxt[iIndex][tCount]);
-01434                 }
-01435                 vAddEndTag(pDiag, TAG_ENTRY);
-01436         }
-01437         vAddEndTag(pDiag, TAG_ROW);
-01438 } /* end of vAddTableRowXML */
-
-
Generated by  - -doxygen 1.6.2
- - diff -r 59758314f811 -r d4524d6a4472 Symbian3/Examples/guid-6013a680-57f9-415b-8851-c4fa63356636/zips/guid-72f72df3-653c-414c-a357-7613ad8bc169.zip Binary file Symbian3/Examples/guid-6013a680-57f9-415b-8851-c4fa63356636/zips/guid-72f72df3-653c-414c-a357-7613ad8bc169.zip has changed