i hope the node casts are correct here.
[AROS-Contrib.git] / arospdf / xpdf / GlobalParams.h
blobf22c688863dec462ea8ffa2af55636ac4e88cb48
1 //========================================================================
2 //
3 // GlobalParams.h
4 //
5 // Copyright 2001-2003 Glyph & Cog, LLC
6 //
7 //========================================================================
9 #ifndef GLOBALPARAMS_H
10 #define GLOBALPARAMS_H
12 #include <aconf.h>
14 #ifdef USE_GCC_PRAGMAS
15 #pragma interface
16 #endif
18 #include <stdio.h>
19 #include "gtypes.h"
20 #include "CharTypes.h"
22 #if MULTITHREADED
23 #include "GMutex.h"
24 #endif
26 class GString;
27 class GList;
28 class GHash;
29 class NameToCharCode;
30 class CharCodeToUnicode;
31 class CharCodeToUnicodeCache;
32 class UnicodeMap;
33 class UnicodeMapCache;
34 class CMap;
35 class CMapCache;
36 struct XpdfSecurityHandler;
37 class GlobalParams;
38 #ifdef WIN32
39 class WinFontList;
40 #endif
42 //------------------------------------------------------------------------
44 // The global parameters xObject.
45 extern GlobalParams *globalParams;
47 //------------------------------------------------------------------------
49 enum DisplayFontParamKind {
50 displayFontT1,
51 displayFontTT
54 struct DisplayFontParamT1 {
55 GString *fileName;
58 struct DisplayFontParamTT {
59 GString *fileName;
62 class DisplayFontParam {
63 public:
65 GString *name; // font name for 8-bit fonts and named
66 // CID fonts; collection name for
67 // generic CID fonts
68 DisplayFontParamKind kind;
69 union {
70 DisplayFontParamT1 t1;
71 DisplayFontParamTT tt;
74 DisplayFontParam(GString *nameA, DisplayFontParamKind kindA);
75 virtual ~DisplayFontParam();
78 //------------------------------------------------------------------------
80 class PSFontParam {
81 public:
83 GString *pdfFontName; // PDF font name for 8-bit fonts and
84 // named 16-bit fonts; char collection
85 // name for generic 16-bit fonts
86 int wMode; // writing mode (0=horiz, 1=vert) for
87 // 16-bit fonts
88 GString *psFontName; // PostScript font name
89 GString *encoding; // encoding, for 16-bit fonts only
91 PSFontParam(GString *pdfFontNameA, int wModeA,
92 GString *psFontNameA, GString *encodingA);
93 ~PSFontParam();
96 //------------------------------------------------------------------------
98 enum PSLevel {
99 psLevel1,
100 psLevel1Sep,
101 psLevel2,
102 psLevel2Sep,
103 psLevel3,
104 psLevel3Sep
107 //------------------------------------------------------------------------
109 enum EndOfLineKind {
110 eolUnix, // LF
111 eolDOS, // CR+LF
112 eolMac // CR
115 //------------------------------------------------------------------------
117 enum ScreenType {
118 screenUnset,
119 screenDispersed,
120 screenClustered,
121 screenStochasticClustered
124 //------------------------------------------------------------------------
126 class KeyBinding {
127 public:
129 int code; // 0x20 .. 0xfe = ASCII,
130 // >=0x10000 = special keys, mouse buttons,
131 // etc. (xpdfKeyCode* symbols)
132 int mods; // modifiers (xpdfKeyMod* symbols, or-ed
133 // together)
134 int context; // context (xpdfKeyContext* symbols, or-ed
135 // together)
136 GList *cmds; // list of commands [GString]
138 KeyBinding(int codeA, int modsA, int contextA, const char *cmd0);
139 KeyBinding(int codeA, int modsA, int contextA, const char *cmd0, const char *cmd1);
140 KeyBinding(int codeA, int modsA, int contextA, GList *cmdsA);
141 ~KeyBinding();
144 #define xpdfKeyCodeTab 0x1000
145 #define xpdfKeyCodeReturn 0x1001
146 #define xpdfKeyCodeEnter 0x1002
147 #define xpdfKeyCodeBackspace 0x1003
148 #define xpdfKeyCodeInsert 0x1004
149 #define xpdfKeyCodeDelete 0x1005
150 #define xpdfKeyCodeHome 0x1006
151 #define xpdfKeyCodeEnd 0x1007
152 #define xpdfKeyCodePgUp 0x1008
153 #define xpdfKeyCodePgDn 0x1009
154 #define xpdfKeyCodeLeft 0x100a
155 #define xpdfKeyCodeRight 0x100b
156 #define xpdfKeyCodeUp 0x100c
157 #define xpdfKeyCodeDown 0x100d
158 #define xpdfKeyCodeF1 0x1100
159 #define xpdfKeyCodeF35 0x1122
160 #define xpdfKeyCodeMousePress1 0x2001
161 #define xpdfKeyCodeMousePress2 0x2002
162 #define xpdfKeyCodeMousePress3 0x2003
163 #define xpdfKeyCodeMousePress4 0x2004
164 #define xpdfKeyCodeMousePress5 0x2005
165 #define xpdfKeyCodeMousePress6 0x2006
166 #define xpdfKeyCodeMousePress7 0x2007
167 #define xpdfKeyCodeMouseRelease1 0x2101
168 #define xpdfKeyCodeMouseRelease2 0x2102
169 #define xpdfKeyCodeMouseRelease3 0x2103
170 #define xpdfKeyCodeMouseRelease4 0x2104
171 #define xpdfKeyCodeMouseRelease5 0x2105
172 #define xpdfKeyCodeMouseRelease6 0x2106
173 #define xpdfKeyCodeMouseRelease7 0x2107
174 #define xpdfKeyModNone 0
175 #define xpdfKeyModShift (1 << 0)
176 #define xpdfKeyModCtrl (1 << 1)
177 #define xpdfKeyModAlt (1 << 2)
178 #define xpdfKeyContextAny 0
179 #define xpdfKeyContextFullScreen (1 << 0)
180 #define xpdfKeyContextWindow (2 << 0)
181 #define xpdfKeyContextContinuous (1 << 2)
182 #define xpdfKeyContextSinglePage (2 << 2)
183 #define xpdfKeyContextOverLink (1 << 4)
184 #define xpdfKeyContextOffLink (2 << 4)
185 #define xpdfKeyContextOutline (1 << 6)
186 #define xpdfKeyContextMainWin (2 << 6)
187 #define xpdfKeyContextScrLockOn (1 << 8)
188 #define xpdfKeyContextScrLockOff (2 << 8)
190 //------------------------------------------------------------------------
192 class GlobalParams {
193 public:
195 // Initialize the global parameters by attempting to read a config
196 // file.
197 GlobalParams(char *cfgFileName);
199 ~GlobalParams();
201 void setBaseDir(char *dir);
202 void setupBaseFonts(char *dir);
204 void parseLine(char *buf, GString *fileName, int line);
206 //----- accessors
208 CharCode getMacRomanCharCode(char *charName);
210 GString *getBaseDir();
211 Unicode mapNameToUnicode(char *charName);
212 UnicodeMap *getResidentUnicodeMap(GString *encodingName);
213 FILE *getUnicodeMapFile(GString *encodingName);
214 FILE *findCMapFile(GString *collection, GString *cMapName);
215 FILE *findToUnicodeFile(GString *name);
216 DisplayFontParam *getDisplayFont(GString *fontName);
217 DisplayFontParam *getDisplayCIDFont(GString *fontName, GString *collection);
218 GString *getPSFile();
219 int getPSPaperWidth();
220 int getPSPaperHeight();
221 void getPSImageableArea(int *llx, int *lly, int *urx, int *ury);
222 GBool getPSDuplex();
223 GBool getPSCrop();
224 GBool getPSExpandSmaller();
225 GBool getPSShrinkLarger();
226 GBool getPSCenter();
227 PSLevel getPSLevel();
228 PSFontParam *getPSFont(GString *fontName);
229 PSFontParam *getPSFont16(GString *fontName, GString *collection, int wMode);
230 GBool getPSEmbedType1();
231 GBool getPSEmbedTrueType();
232 GBool getPSEmbedCIDPostScript();
233 GBool getPSEmbedCIDTrueType();
234 GBool getPSPreload();
235 GBool getPSOPI();
236 GBool getPSASCIIHex();
237 GString *getTextEncodingName();
238 EndOfLineKind getTextEOL();
239 GBool getTextPageBreaks();
240 GBool getTextKeepTinyChars();
241 GString *findFontFile(GString *fontName, char **exts);
242 GString *getInitialZoom();
243 GBool getContinuousView();
244 GBool getEnableT1lib();
245 GBool getEnableFreeType();
246 GBool getAntialias();
247 GBool getVectorAntialias();
248 GBool getStrokeAdjust();
249 ScreenType getScreenType();
250 int getScreenSize();
251 int getScreenDotRadius();
252 double getScreenGamma();
253 double getScreenBlackThreshold();
254 double getScreenWhiteThreshold();
255 GString *getURLCommand() { return urlCommand; }
256 GString *getMovieCommand() { return movieCommand; }
257 GBool getMapNumericCharNames();
258 GBool getMapUnknownCharNames();
259 GList *getKeyBinding(int code, int mods, int context);
260 GBool getPrintCommands();
261 GBool getErrQuiet();
263 CharCodeToUnicode *getCIDToUnicode(GString *collection);
264 CharCodeToUnicode *getUnicodeToUnicode(GString *fontName);
265 UnicodeMap *getUnicodeMap(GString *encodingName);
266 CMap *getCMap(GString *collection, GString *cMapName);
267 UnicodeMap *getTextEncoding();
269 //----- functions to set parameters
271 void addDisplayFont(DisplayFontParam *param);
272 void setPSFile(char *file);
273 GBool setPSPaperSize(char *size);
274 void setPSPaperWidth(int width);
275 void setPSPaperHeight(int height);
276 void setPSImageableArea(int llx, int lly, int urx, int ury);
277 void setPSDuplex(GBool duplex);
278 void setPSCrop(GBool crop);
279 void setPSExpandSmaller(GBool expand);
280 void setPSShrinkLarger(GBool shrink);
281 void setPSCenter(GBool center);
282 void setPSLevel(PSLevel level);
283 void setPSEmbedType1(GBool embed);
284 void setPSEmbedTrueType(GBool embed);
285 void setPSEmbedCIDPostScript(GBool embed);
286 void setPSEmbedCIDTrueType(GBool embed);
287 void setPSPreload(GBool preload);
288 void setPSOPI(GBool opi);
289 void setPSASCIIHex(GBool hex);
290 void setTextEncoding(char *encodingName);
291 GBool setTextEOL(char *s);
292 void setTextPageBreaks(GBool pageBreaks);
293 void setTextKeepTinyChars(GBool keep);
294 void setInitialZoom(char *s);
295 void setContinuousView(GBool cont);
296 GBool setEnableT1lib(char *s);
297 GBool setEnableFreeType(char *s);
298 GBool setAntialias(char *s);
299 GBool setVectorAntialias(char *s);
300 void setScreenType(ScreenType t);
301 void setScreenSize(int size);
302 void setScreenDotRadius(int r);
303 void setScreenGamma(double gamma);
304 void setScreenBlackThreshold(double thresh);
305 void setScreenWhiteThreshold(double thresh);
306 void setMapNumericCharNames(GBool map);
307 void setMapUnknownCharNames(GBool map);
308 void setPrintCommands(GBool printCommandsA);
309 void setErrQuiet(GBool errQuietA);
311 //----- security handlers
313 void addSecurityHandler(XpdfSecurityHandler *handler);
314 XpdfSecurityHandler *getSecurityHandler(char *name);
316 private:
318 void createDefaultKeyBindings();
319 void parseFile(GString *fileName, FILE *f);
320 void parseNameToUnicode(GList *tokens, GString *fileName, int line);
321 void parseCIDToUnicode(GList *tokens, GString *fileName, int line);
322 void parseUnicodeToUnicode(GList *tokens, GString *fileName, int line);
323 void parseUnicodeMap(GList *tokens, GString *fileName, int line);
324 void parseCMapDir(GList *tokens, GString *fileName, int line);
325 void parseToUnicodeDir(GList *tokens, GString *fileName, int line);
326 void parseDisplayFont(GList *tokens, GHash *fontHash,
327 DisplayFontParamKind kind,
328 GString *fileName, int line);
329 void parsePSFile(GList *tokens, GString *fileName, int line);
330 void parsePSPaperSize(GList *tokens, GString *fileName, int line);
331 void parsePSImageableArea(GList *tokens, GString *fileName, int line);
332 void parsePSLevel(GList *tokens, GString *fileName, int line);
333 void parsePSFont(GList *tokens, GString *fileName, int line);
334 void parsePSFont16(const char *cmdName, GList *fontList,
335 GList *tokens, GString *fileName, int line);
336 void parseTextEncoding(GList *tokens, GString *fileName, int line);
337 void parseTextEOL(GList *tokens, GString *fileName, int line);
338 void parseFontDir(GList *tokens, GString *fileName, int line);
339 void parseInitialZoom(GList *tokens, GString *fileName, int line);
340 void parseScreenType(GList *tokens, GString *fileName, int line);
341 void parseBind(GList *tokens, GString *fileName, int line);
342 void parseUnbind(GList *tokens, GString *fileName, int line);
343 GBool parseKey(GString *modKeyStr, GString *contextStr,
344 int *code, int *mods, int *context,
345 const char *cmdName,
346 GList *tokens, GString *fileName, int line);
347 void parseCommand(const char *cmdName, GString **val,
348 GList *tokens, GString *fileName, int line);
349 void parseYesNo(const char *cmdName, GBool *flag,
350 GList *tokens, GString *fileName, int line);
351 GBool parseYesNo2(const char *token, GBool *flag);
352 void parseInteger(const char *cmdName, int *val,
353 GList *tokens, GString *fileName, int line);
354 void parseFloat(const char *cmdName, double *val,
355 GList *tokens, GString *fileName, int line);
356 UnicodeMap *getUnicodeMap2(GString *encodingName);
357 #ifdef ENABLE_PLUGINS
358 GBool loadPlugin(const char *type, char *name);
359 #endif
361 //----- static tables
363 NameToCharCode * // mapping from char name to
364 macRomanReverseMap; // MacRomanEncoding index
366 //----- user-modifiable settings
368 GString *baseDir; // base directory - for plugins, etc.
369 NameToCharCode * // mapping from char name to Unicode
370 nameToUnicode;
371 GHash *cidToUnicodes; // files for mappings from char collections
372 // to Unicode, indexed by collection name
373 // [GString]
374 GHash *unicodeToUnicodes; // files for Unicode-to-Unicode mappings,
375 // indexed by font name pattern [GString]
376 GHash *residentUnicodeMaps; // mappings from Unicode to char codes,
377 // indexed by encoding name [UnicodeMap]
378 GHash *unicodeMaps; // files for mappings from Unicode to char
379 // codes, indexed by encoding name [GString]
380 GHash *cMapDirs; // list of CMap dirs, indexed by collection
381 // name [GList[GString]]
382 GList *toUnicodeDirs; // list of ToUnicode CMap dirs [GString]
383 GHash *displayFonts; // display font info, indexed by font name
384 // [DisplayFontParam]
385 #ifdef WIN32
386 WinFontList *winFontList; // system TrueType fonts
387 #endif
388 GHash *displayCIDFonts; // display CID font info, indexed by
389 // collection [DisplayFontParam]
390 GHash *displayNamedCIDFonts; // display CID font info, indexed by
391 // font name [DisplayFontParam]
392 GString *psFile; // PostScript file or command (for xpdf)
393 int psPaperWidth; // paper size, in PostScript points, for
394 int psPaperHeight; // PostScript output
395 int psImageableLLX, // imageable area, in PostScript points,
396 psImageableLLY, // for PostScript output
397 psImageableURX,
398 psImageableURY;
399 GBool psCrop; // crop PS output to CropBox
400 GBool psExpandSmaller; // expand smaller pages to fill paper
401 GBool psShrinkLarger; // shrink larger pages to fit paper
402 GBool psCenter; // center pages on the paper
403 GBool psDuplex; // enable duplexing in PostScript?
404 PSLevel psLevel; // PostScript level to generate
405 GHash *psFonts; // PostScript font info, indexed by PDF
406 // font name [PSFontParam]
407 GList *psNamedFonts16; // named 16-bit fonts [PSFontParam]
408 GList *psFonts16; // generic 16-bit fonts [PSFontParam]
409 GBool psEmbedType1; // embed Type 1 fonts?
410 GBool psEmbedTrueType; // embed TrueType fonts?
411 GBool psEmbedCIDPostScript; // embed CID PostScript fonts?
412 GBool psEmbedCIDTrueType; // embed CID TrueType fonts?
413 GBool psPreload; // preload PostScript images and forms into
414 // memory
415 GBool psOPI; // generate PostScript OPI comments?
416 GBool psASCIIHex; // use ASCIIHex instead of ASCII85?
417 GString *textEncoding; // encoding (unicodeMap) to use for text
418 // output
419 EndOfLineKind textEOL; // type of EOL marker to use for text
420 // output
421 GBool textPageBreaks; // insert end-of-page markers?
422 GBool textKeepTinyChars; // keep all characters in text output
423 GList *fontDirs; // list of font dirs [GString]
424 GString *initialZoom; // initial zoom level
425 GBool continuousView; // continuous view mode
426 GBool enableT1lib; // t1lib enable flag
427 GBool enableFreeType; // FreeType enable flag
428 GBool antialias; // font anti-aliasing enable flag
429 GBool vectorAntialias; // vector anti-aliasing enable flag
430 GBool strokeAdjust; // stroke adjustment enable flag
431 ScreenType screenType; // halftone screen type
432 int screenSize; // screen matrix size
433 int screenDotRadius; // screen dot radius
434 double screenGamma; // screen gamma correction
435 double screenBlackThreshold; // screen black clamping threshold
436 double screenWhiteThreshold; // screen white clamping threshold
437 GString *urlCommand; // command executed for URL links
438 GString *movieCommand; // command executed for movie annotations
439 GBool mapNumericCharNames; // map numeric char names (from font subsets)?
440 GBool mapUnknownCharNames; // map unknown char names?
441 GList *keyBindings; // key & mouse button bindings [KeyBinding]
442 GBool printCommands; // print the drawing commands
443 GBool errQuiet; // suppress error messages?
445 CharCodeToUnicodeCache *cidToUnicodeCache;
446 CharCodeToUnicodeCache *unicodeToUnicodeCache;
447 UnicodeMapCache *unicodeMapCache;
448 CMapCache *cMapCache;
450 #ifdef ENABLE_PLUGINS
451 GList *plugins; // list of plugins [Plugin]
452 GList *securityHandlers; // list of loaded security handlers
453 // [XpdfSecurityHandler]
454 #endif
456 #if MULTITHREADED
457 GMutex mutex;
458 GMutex unicodeMapCacheMutex;
459 GMutex cMapCacheMutex;
460 #endif
463 #endif