~ubuntu-branches/ubuntu/precise/ipe/precise

« back to all changes in this revision

Viewing changes to src/xpdflib/globalparams.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Steve M. Robbins
  • Date: 2005-02-24 22:09:16 UTC
  • mfrom: (2.1.1 hoary)
  • Revision ID: james.westby@ubuntu.com-20050224220916-9vxiiqjz066r5489
Tags: 6.0pre23-2
debian/control: Ipe should depend on exact version of libipe.
Closes: #296771.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
//========================================================================
2
 
//
3
 
// GlobalParams.cc
4
 
//
5
 
// Copyright 2001-2002 Glyph & Cog, LLC
6
 
//
7
 
//========================================================================
8
 
 
9
 
#include "aconf.h"
10
 
 
11
 
#ifdef USE_GCC_PRAGMAS
12
 
#pragma implementation
13
 
#endif
14
 
 
15
 
#include <string.h>
16
 
#include <ctype.h>
17
 
#if HAVE_PAPER_H
18
 
#include <paper.h>
19
 
#endif
20
 
#include "gmem.h"
21
 
#include "gstring.h"
22
 
#include "glist.h"
23
 
#include "ghash.h"
24
 
#include "ocfile.h"
25
 
#include "error.h"
26
 
#include "nametocharcode.h"
27
 
#include "charcodetounicode.h"
28
 
#include "unicodemap.h"
29
 
#include "cmap.h"
30
 
#include "builtinfonttables.h"
31
 
#include "fontencodingtables.h"
32
 
#include "globalparams.h"
33
 
 
34
 
#if MULTITHREADED
35
 
#  define globalParamsLock gLockMutex(&mutex)
36
 
#  define globalParamsUnlock gUnlockMutex(&mutex)
37
 
#else
38
 
#  define globalParamsLock
39
 
#  define globalParamsUnlock
40
 
#endif
41
 
 
42
 
#include "nametounicodetable.h"
43
 
#include "unicodemaptables.h"
44
 
#include "displayfonttable.h"
45
 
#include "utf8.h"
46
 
 
47
 
//------------------------------------------------------------------------
48
 
 
49
 
GlobalParams *globalParams = NULL;
50
 
 
51
 
//------------------------------------------------------------------------
52
 
// DisplayFontParam
53
 
//------------------------------------------------------------------------
54
 
 
55
 
DisplayFontParam::DisplayFontParam(GString *nameA,
56
 
                                   DisplayFontParamKind kindA) {
57
 
  name = nameA;
58
 
  kind = kindA;
59
 
  switch (kind) {
60
 
  case displayFontX:
61
 
    x.xlfd = NULL;
62
 
    x.encoding = NULL;
63
 
    break;
64
 
  case displayFontT1:
65
 
    t1.fileName = NULL;
66
 
    break;
67
 
  case displayFontTT:
68
 
    tt.fileName = NULL;
69
 
    break;
70
 
  }
71
 
}
72
 
 
73
 
DisplayFontParam::DisplayFontParam(char *nameA, char *xlfdA, char *encodingA) {
74
 
  name = new GString(nameA);
75
 
  kind = displayFontX;
76
 
  x.xlfd = new GString(xlfdA);
77
 
  x.encoding = new GString(encodingA);
78
 
}
79
 
 
80
 
DisplayFontParam::~DisplayFontParam() {
81
 
  delete name;
82
 
  switch (kind) {
83
 
  case displayFontX:
84
 
    if (x.xlfd) {
85
 
      delete x.xlfd;
86
 
    }
87
 
    if (x.encoding) {
88
 
      delete x.encoding;
89
 
    }
90
 
    break;
91
 
  case displayFontT1:
92
 
    if (t1.fileName) {
93
 
      delete t1.fileName;
94
 
    }
95
 
    break;
96
 
  case displayFontTT:
97
 
    if (tt.fileName) {
98
 
      delete tt.fileName;
99
 
    }
100
 
    break;
101
 
  }
102
 
}
103
 
 
104
 
//------------------------------------------------------------------------
105
 
// PSFontParam
106
 
//------------------------------------------------------------------------
107
 
 
108
 
PSFontParam::PSFontParam(GString *pdfFontNameA, int wModeA,
109
 
                         GString *psFontNameA, GString *encodingA) {
110
 
  pdfFontName = pdfFontNameA;
111
 
  wMode = wModeA;
112
 
  psFontName = psFontNameA;
113
 
  encoding = encodingA;
114
 
}
115
 
 
116
 
PSFontParam::~PSFontParam() {
117
 
  delete pdfFontName;
118
 
  delete psFontName;
119
 
  if (encoding) {
120
 
    delete encoding;
121
 
  }
122
 
}
123
 
 
124
 
//------------------------------------------------------------------------
125
 
// parsing
126
 
//------------------------------------------------------------------------
127
 
 
128
 
GlobalParams::GlobalParams(char *cfgFileName) {
129
 
  UnicodeMap *map;
130
 
  DisplayFontParam *dfp;
131
 
  GString *fileName;
132
 
  OCFILE *f;
133
 
  int i;
134
 
 
135
 
#if MULTITHREADED
136
 
  gInitMutex(&mutex);
137
 
#endif
138
 
 
139
 
  initBuiltinFontTables();
140
 
 
141
 
  // scan the encoding in reverse because we want the lowest-numbered
142
 
  // index for each char name ('space' is encoded twice)
143
 
  macRomanReverseMap = new NameToCharCode();
144
 
  for (i = 255; i >= 0; --i) {
145
 
    if (macRomanEncoding[i]) {
146
 
      macRomanReverseMap->add(macRomanEncoding[i], (CharCode)i);
147
 
    }
148
 
  }
149
 
 
150
 
  nameToUnicode = new NameToCharCode();
151
 
  cidToUnicodes = new GHash(gTrue);
152
 
  residentUnicodeMaps = new GHash();
153
 
  unicodeMaps = new GHash(gTrue);
154
 
  cMapDirs = new GHash(gTrue);
155
 
  toUnicodeDirs = new GList();
156
 
  displayFonts = new GHash();
157
 
  displayCIDFonts = new GHash();
158
 
  displayNamedCIDFonts = new GHash();
159
 
#if HAVE_PAPER_H
160
 
  char *paperName;
161
 
  const struct paper *paperType;
162
 
  paperinit();
163
 
  if ((paperName = systempapername())) {
164
 
    paperType = paperinfo(paperName);
165
 
    psPaperWidth = (int)paperpswidth(paperType);
166
 
    psPaperHeight = (int)paperpsheight(paperType);
167
 
  } else {
168
 
    error(-1, "No paper information available - using defaults");
169
 
    psPaperWidth = defPaperWidth;
170
 
    psPaperHeight = defPaperHeight;
171
 
  }
172
 
  paperdone();
173
 
#else
174
 
  psPaperWidth = defPaperWidth;
175
 
  psPaperHeight = defPaperHeight;
176
 
#endif
177
 
  psDuplex = gFalse;
178
 
  psLevel = psLevel2;
179
 
  psFile = NULL;
180
 
  psFonts = new GHash();
181
 
  psNamedFonts16 = new GList();
182
 
  psFonts16 = new GList();
183
 
  psEmbedType1 = gTrue;
184
 
  psEmbedTrueType = gTrue;
185
 
  psEmbedCIDPostScript = gTrue;
186
 
  psEmbedCIDTrueType = gTrue;
187
 
  psOPI = gFalse;
188
 
  psASCIIHex = gFalse;
189
 
  textEncoding = new GString("Latin1");
190
 
#if defined(WIN32)
191
 
  textEOL = eolDOS;
192
 
#elif defined(MACOS)
193
 
  textEOL = eolMac;
194
 
#else
195
 
  textEOL = eolUnix;
196
 
#endif
197
 
  textKeepTinyChars = gFalse;
198
 
  fontDirs = new GList();
199
 
  initialZoom = new GString("1");
200
 
  t1libControl = fontRastAALow;
201
 
  freetypeControl = fontRastAALow;
202
 
  urlCommand = NULL;
203
 
  movieCommand = NULL;
204
 
  mapNumericCharNames = gTrue;
205
 
  printCommands = gFalse;
206
 
  errQuiet = gFalse;
207
 
 
208
 
  cidToUnicodeCache = new CIDToUnicodeCache();
209
 
  unicodeMapCache = new UnicodeMapCache();
210
 
  cMapCache = new CMapCache();
211
 
 
212
 
  // set up the initial nameToUnicode table
213
 
  for (i = 0; nameToUnicodeTab[i].name; ++i) {
214
 
    nameToUnicode->add(nameToUnicodeTab[i].name, nameToUnicodeTab[i].u);
215
 
  }
216
 
 
217
 
  // set up the residentUnicodeMaps table
218
 
  map = new UnicodeMap("Latin1", gFalse,
219
 
                       latin1UnicodeMapRanges, latin1UnicodeMapLen);
220
 
  residentUnicodeMaps->add(map->getEncodingName(), map);
221
 
  map = new UnicodeMap("ASCII7", gFalse,
222
 
                       ascii7UnicodeMapRanges, ascii7UnicodeMapLen);
223
 
  residentUnicodeMaps->add(map->getEncodingName(), map);
224
 
  map = new UnicodeMap("Symbol", gFalse,
225
 
                       symbolUnicodeMapRanges, symbolUnicodeMapLen);
226
 
  residentUnicodeMaps->add(map->getEncodingName(), map);
227
 
  map = new UnicodeMap("ZapfDingbats", gFalse, zapfDingbatsUnicodeMapRanges,
228
 
                       zapfDingbatsUnicodeMapLen);
229
 
  residentUnicodeMaps->add(map->getEncodingName(), map);
230
 
  map = new UnicodeMap("UTF-8", gTrue, &mapUTF8);
231
 
  residentUnicodeMaps->add(map->getEncodingName(), map);
232
 
  map = new UnicodeMap("UCS-2", gTrue, &mapUCS2);
233
 
  residentUnicodeMaps->add(map->getEncodingName(), map);
234
 
 
235
 
  // default displayFonts table
236
 
  for (i = 0; displayFontTab[i].name; ++i) {
237
 
    dfp = new DisplayFontParam(displayFontTab[i].name,
238
 
                               displayFontTab[i].xlfd,
239
 
                               displayFontTab[i].encoding);
240
 
    displayFonts->add(dfp->name, dfp);
241
 
  }
242
 
 
243
 
  // look for a user config file, then a system-wide config file
244
 
#if 0
245
 
  f = NULL;
246
 
  fileName = NULL;
247
 
  if (cfgFileName && cfgFileName[0]) {
248
 
    fileName = new GString(cfgFileName);
249
 
    if (!(f = ocfopen(fileName->getCString(), "r"))) {
250
 
      delete fileName;
251
 
    }
252
 
  }
253
 
  if (!f) {
254
 
    fileName = appendToPath(getHomeDir(), xpdfUserConfigFile);
255
 
    if (!(f = ocfopen(fileName->getCString(), "r"))) {
256
 
      delete fileName;
257
 
    }
258
 
  }
259
 
  if (!f) {
260
 
#if defined(WIN32) && !defined(__CYGWIN32__)
261
 
    char buf[512];
262
 
    i = GetModuleFileName(NULL, buf, sizeof(buf));
263
 
    if (i <= 0 || i >= sizeof(buf)) {
264
 
      // error or path too long for buffer - just use the current dir
265
 
      buf[0] = '\0';
266
 
    }
267
 
    fileName = grabPath(buf);
268
 
    appendToPath(fileName, xpdfSysConfigFile);
269
 
#else
270
 
    fileName = new GString(xpdfSysConfigFile);
271
 
#endif
272
 
    if (!(f = ocfopen(fileName->getCString(), "r"))) {
273
 
      delete fileName;
274
 
    }
275
 
  }
276
 
  if (f) {
277
 
    parseFile(fileName, f);
278
 
    delete fileName;
279
 
    fclose(f);
280
 
  }
281
 
#endif
282
 
}
283
 
 
284
 
void GlobalParams::parseFile(GString *fileName, OCFILE *f) {
285
 
  int line;
286
 
  GList *tokens;
287
 
  GString *cmd, *incFile;
288
 
  char *p1, *p2;
289
 
  char buf[512];
290
 
  OCFILE *f2;
291
 
 
292
 
  line = 1;
293
 
  while (getLine(buf, sizeof(buf) - 1, f)) {
294
 
 
295
 
    // break the line into tokens
296
 
    tokens = new GList();
297
 
    p1 = buf;
298
 
    while (*p1) {
299
 
      for (; *p1 && isspace(*p1); ++p1) ;
300
 
      if (!*p1) {
301
 
        break;
302
 
      }
303
 
      if (*p1 == '"' || *p1 == '\'') {
304
 
        for (p2 = p1 + 1; *p2 && *p2 != *p1; ++p2) ;
305
 
        ++p1;
306
 
      } else {
307
 
        for (p2 = p1 + 1; *p2 && !isspace(*p2); ++p2) ;
308
 
      }
309
 
      tokens->append(new GString(p1, p2 - p1));
310
 
      p1 = *p2 ? p2 + 1 : p2;
311
 
    }
312
 
 
313
 
    if (tokens->getLength() > 0 &&
314
 
        ((GString *)tokens->get(0))->getChar(0) != '#') {
315
 
      cmd = (GString *)tokens->get(0);
316
 
      if (!cmd->cmp("include")) {
317
 
        if (tokens->getLength() == 2) {
318
 
          incFile = (GString *)tokens->get(1);
319
 
          if ((f2 = ocfopen(incFile->getCString(), "r"))) {
320
 
            parseFile(incFile, f2);
321
 
            fclose(f2);
322
 
          } else {
323
 
            error(-1, "Couldn't find included config file: '%s' (%s:%d)",
324
 
                  incFile->getCString(), fileName->getCString(), line);
325
 
          }
326
 
        } else {
327
 
          error(-1, "Bad 'include' config file command (%s:%d)",
328
 
                fileName->getCString(), line);
329
 
        }
330
 
      } else if (!cmd->cmp("nameToUnicode")) {
331
 
        parseNameToUnicode(tokens, fileName, line);
332
 
      } else if (!cmd->cmp("cidToUnicode")) {
333
 
        parseCIDToUnicode(tokens, fileName, line);
334
 
      } else if (!cmd->cmp("unicodeMap")) {
335
 
        parseUnicodeMap(tokens, fileName, line);
336
 
      } else if (!cmd->cmp("cMapDir")) {
337
 
        parseCMapDir(tokens, fileName, line);
338
 
      } else if (!cmd->cmp("toUnicodeDir")) {
339
 
        parseToUnicodeDir(tokens, fileName, line);
340
 
      } else if (!cmd->cmp("displayFontX")) {
341
 
        parseDisplayFont(tokens, displayFonts, displayFontX, fileName, line);
342
 
      } else if (!cmd->cmp("displayFontT1")) {
343
 
        parseDisplayFont(tokens, displayFonts, displayFontT1, fileName, line);
344
 
      } else if (!cmd->cmp("displayFontTT")) {
345
 
        parseDisplayFont(tokens, displayFonts, displayFontTT, fileName, line);
346
 
      } else if (!cmd->cmp("displayNamedCIDFontX")) {
347
 
        parseDisplayFont(tokens, displayNamedCIDFonts,
348
 
                         displayFontX, fileName, line);
349
 
      } else if (!cmd->cmp("displayCIDFontX")) {
350
 
        parseDisplayFont(tokens, displayCIDFonts,
351
 
                         displayFontX, fileName, line);
352
 
      } else if (!cmd->cmp("displayNamedCIDFontT1")) {
353
 
        parseDisplayFont(tokens, displayNamedCIDFonts,
354
 
                         displayFontT1, fileName, line);
355
 
      } else if (!cmd->cmp("displayCIDFontT1")) {
356
 
        parseDisplayFont(tokens, displayCIDFonts,
357
 
                         displayFontT1, fileName, line);
358
 
      } else if (!cmd->cmp("psFile")) {
359
 
        parsePSFile(tokens, fileName, line);
360
 
      } else if (!cmd->cmp("psFont")) {
361
 
        parsePSFont(tokens, fileName, line);
362
 
      } else if (!cmd->cmp("psNamedFont16")) {
363
 
        parsePSFont16("psNamedFont16", psNamedFonts16,
364
 
                      tokens, fileName, line);
365
 
      } else if (!cmd->cmp("psFont16")) {
366
 
        parsePSFont16("psFont16", psFonts16, tokens, fileName, line);
367
 
      } else if (!cmd->cmp("psPaperSize")) {
368
 
        parsePSPaperSize(tokens, fileName, line);
369
 
      } else if (!cmd->cmp("psDuplex")) {
370
 
        parseYesNo("psDuplex", &psDuplex, tokens, fileName, line);
371
 
      } else if (!cmd->cmp("psLevel")) {
372
 
        parsePSLevel(tokens, fileName, line);
373
 
      } else if (!cmd->cmp("psEmbedType1Fonts")) {
374
 
        parseYesNo("psEmbedType1", &psEmbedType1, tokens, fileName, line);
375
 
      } else if (!cmd->cmp("psEmbedTrueTypeFonts")) {
376
 
        parseYesNo("psEmbedTrueType", &psEmbedTrueType,
377
 
                   tokens, fileName, line);
378
 
      } else if (!cmd->cmp("psEmbedCIDPostScriptFonts")) {
379
 
        parseYesNo("psEmbedCIDPostScript", &psEmbedCIDPostScript,
380
 
                   tokens, fileName, line);
381
 
      } else if (!cmd->cmp("psEmbedCIDTrueTypeFonts")) {
382
 
        parseYesNo("psEmbedCIDTrueType", &psEmbedCIDTrueType,
383
 
                   tokens, fileName, line);
384
 
      } else if (!cmd->cmp("psOPI")) {
385
 
        parseYesNo("psOPI", &psOPI, tokens, fileName, line);
386
 
      } else if (!cmd->cmp("psASCIIHex")) {
387
 
        parseYesNo("psASCIIHex", &psASCIIHex, tokens, fileName, line);
388
 
      } else if (!cmd->cmp("textEncoding")) {
389
 
        parseTextEncoding(tokens, fileName, line);
390
 
      } else if (!cmd->cmp("textEOL")) {
391
 
        parseTextEOL(tokens, fileName, line);
392
 
      } else if (!cmd->cmp("textKeepTinyChars")) {
393
 
        parseYesNo("textKeepTinyChars", &textKeepTinyChars,
394
 
                   tokens, fileName, line);
395
 
      } else if (!cmd->cmp("fontDir")) {
396
 
        parseFontDir(tokens, fileName, line);
397
 
      } else if (!cmd->cmp("initialZoom")) {
398
 
        parseInitialZoom(tokens, fileName, line);
399
 
      } else if (!cmd->cmp("t1libControl")) {
400
 
        parseFontRastControl("t1libControl", &t1libControl,
401
 
                             tokens, fileName, line);
402
 
      } else if (!cmd->cmp("freetypeControl")) {
403
 
        parseFontRastControl("freetypeControl", &freetypeControl,
404
 
                             tokens, fileName, line);
405
 
      } else if (!cmd->cmp("urlCommand")) {
406
 
        parseCommand("urlCommand", &urlCommand, tokens, fileName, line);
407
 
      } else if (!cmd->cmp("movieCommand")) {
408
 
        parseCommand("movieCommand", &movieCommand, tokens, fileName, line);
409
 
      } else if (!cmd->cmp("mapNumericCharNames")) {
410
 
        parseYesNo("mapNumericCharNames", &mapNumericCharNames,
411
 
                   tokens, fileName, line);
412
 
      } else if (!cmd->cmp("printCommands")) {
413
 
        parseYesNo("printCommands", &printCommands, tokens, fileName, line);
414
 
      } else if (!cmd->cmp("errQuiet")) {
415
 
        parseYesNo("errQuiet", &errQuiet, tokens, fileName, line);
416
 
      } else if (!cmd->cmp("fontpath") || !cmd->cmp("fontmap")) {
417
 
        error(-1, "Unknown config file command");
418
 
        error(-1, "-- the config file format has changed since Xpdf 0.9x");
419
 
      } else {
420
 
        error(-1, "Unknown config file command '%s' (%s:%d)",
421
 
              cmd->getCString(), fileName->getCString(), line);
422
 
      }
423
 
    }
424
 
 
425
 
    deleteGList(tokens, GString);
426
 
    ++line;
427
 
  }
428
 
}
429
 
 
430
 
void GlobalParams::parseNameToUnicode(GList *tokens, GString *fileName,
431
 
                                         int line) {
432
 
  GString *name;
433
 
  char *tok1, *tok2;
434
 
  OCFILE *f;
435
 
  char buf[256];
436
 
  int line2;
437
 
  Unicode u;
438
 
 
439
 
  if (tokens->getLength() != 2) {
440
 
    error(-1, "Bad 'nameToUnicode' config file command (%s:%d)",
441
 
          fileName->getCString(), line);
442
 
    return;
443
 
  }
444
 
  name = (GString *)tokens->get(1);
445
 
  if (!(f = ocfopen(name->getCString(), "r"))) {
446
 
    error(-1, "Couldn't open 'nameToUnicode' file '%s'",
447
 
          name->getCString());
448
 
    return;
449
 
  }
450
 
  line2 = 1;
451
 
  while (getLine(buf, sizeof(buf), f)) {
452
 
    tok1 = strtok(buf, " \t\r\n");
453
 
    tok2 = strtok(NULL, " \t\r\n");
454
 
    if (tok1 && tok2) {
455
 
      sscanf(tok1, "%x", &u);
456
 
      nameToUnicode->add(tok2, u);
457
 
    } else {
458
 
      error(-1, "Bad line in 'nameToUnicode' file (%s:%d)", name, line2);
459
 
    }
460
 
    ++line2;
461
 
  }
462
 
  fclose(f);
463
 
}
464
 
 
465
 
void GlobalParams::parseCIDToUnicode(GList *tokens, GString *fileName,
466
 
                                     int line) {
467
 
  GString *collection, *name, *old;
468
 
 
469
 
  if (tokens->getLength() != 3) {
470
 
    error(-1, "Bad 'cidToUnicode' config file command (%s:%d)",
471
 
          fileName->getCString(), line);
472
 
    return;
473
 
  }
474
 
  collection = (GString *)tokens->get(1);
475
 
  name = (GString *)tokens->get(2);
476
 
  if ((old = (GString *)cidToUnicodes->remove(collection))) {
477
 
    delete old;
478
 
  }
479
 
  cidToUnicodes->add(collection->copy(), name->copy());
480
 
}
481
 
 
482
 
void GlobalParams::parseUnicodeMap(GList *tokens, GString *fileName,
483
 
                                   int line) {
484
 
  GString *encodingName, *name, *old;
485
 
 
486
 
  if (tokens->getLength() != 3) {
487
 
    error(-1, "Bad 'unicodeMap' config file command (%s:%d)",
488
 
          fileName->getCString(), line);
489
 
    return;
490
 
  }
491
 
  encodingName = (GString *)tokens->get(1);
492
 
  name = (GString *)tokens->get(2);
493
 
  if ((old = (GString *)unicodeMaps->remove(encodingName))) {
494
 
    delete old;
495
 
  }
496
 
  unicodeMaps->add(encodingName->copy(), name->copy());
497
 
}
498
 
 
499
 
void GlobalParams::parseCMapDir(GList *tokens, GString *fileName, int line) {
500
 
  GString *collection, *dir;
501
 
  GList *list;
502
 
 
503
 
  if (tokens->getLength() != 3) {
504
 
    error(-1, "Bad 'cMapDir' config file command (%s:%d)",
505
 
          fileName->getCString(), line);
506
 
    return;
507
 
  }
508
 
  collection = (GString *)tokens->get(1);
509
 
  dir = (GString *)tokens->get(2);
510
 
  if (!(list = (GList *)cMapDirs->lookup(collection))) {
511
 
    list = new GList();
512
 
    cMapDirs->add(collection->copy(), list);
513
 
  }
514
 
  list->append(dir->copy());
515
 
}
516
 
 
517
 
void GlobalParams::parseToUnicodeDir(GList *tokens, GString *fileName,
518
 
                                     int line) {
519
 
  if (tokens->getLength() != 2) {
520
 
    error(-1, "Bad 'toUnicodeDir' config file command (%s:%d)",
521
 
          fileName->getCString(), line);
522
 
    return;
523
 
  }
524
 
  toUnicodeDirs->append(((GString *)tokens->get(1))->copy());
525
 
}
526
 
 
527
 
void GlobalParams::parseDisplayFont(GList *tokens, GHash *fontHash,
528
 
                                    DisplayFontParamKind kind,
529
 
                                    GString *fileName, int line) {
530
 
  DisplayFontParam *param, *old;
531
 
 
532
 
  if (tokens->getLength() < 2) {
533
 
    goto err1;
534
 
  }
535
 
  param = new DisplayFontParam(((GString *)tokens->get(1))->copy(), kind);
536
 
  
537
 
  switch (kind) {
538
 
  case displayFontX:
539
 
    if (tokens->getLength() != 4) {
540
 
      goto err2;
541
 
    }
542
 
    param->x.xlfd = ((GString *)tokens->get(2))->copy();
543
 
    param->x.encoding = ((GString *)tokens->get(3))->copy();
544
 
    break;
545
 
  case displayFontT1:
546
 
    if (tokens->getLength() != 3) {
547
 
      goto err2;
548
 
    }
549
 
    param->t1.fileName = ((GString *)tokens->get(2))->copy();
550
 
    break;
551
 
  case displayFontTT:
552
 
    if (tokens->getLength() != 3) {
553
 
      goto err2;
554
 
    }
555
 
    param->tt.fileName = ((GString *)tokens->get(2))->copy();
556
 
    break;
557
 
  }
558
 
 
559
 
  if ((old = (DisplayFontParam *)fontHash->remove(param->name))) {
560
 
    delete old;
561
 
  }
562
 
  fontHash->add(param->name, param);
563
 
  return;
564
 
 
565
 
 err2:
566
 
  delete param;
567
 
 err1:
568
 
  error(-1, "Bad 'display*Font*' config file command (%s:%d)",
569
 
        fileName->getCString(), line);
570
 
}
571
 
 
572
 
void GlobalParams::parsePSPaperSize(GList *tokens, GString *fileName,
573
 
                                    int line) {
574
 
  GString *tok;
575
 
 
576
 
  if (tokens->getLength() == 2) {
577
 
    tok = (GString *)tokens->get(1);
578
 
    if (!setPSPaperSize(tok->getCString())) {
579
 
      error(-1, "Bad 'psPaperSize' config file command (%s:%d)",
580
 
            fileName->getCString(), line);
581
 
    }
582
 
  } else if (tokens->getLength() == 3) {
583
 
    tok = (GString *)tokens->get(1);
584
 
    psPaperWidth = atoi(tok->getCString());
585
 
    tok = (GString *)tokens->get(2);
586
 
    psPaperHeight = atoi(tok->getCString());
587
 
  } else {
588
 
    error(-1, "Bad 'psPaperSize' config file command (%s:%d)",
589
 
          fileName->getCString(), line);
590
 
  }
591
 
}
592
 
 
593
 
void GlobalParams::parsePSLevel(GList *tokens, GString *fileName, int line) {
594
 
  GString *tok;
595
 
 
596
 
  if (tokens->getLength() != 2) {
597
 
    error(-1, "Bad 'psLevel' config file command (%s:%d)",
598
 
          fileName->getCString(), line);
599
 
    return;
600
 
  }
601
 
  tok = (GString *)tokens->get(1);
602
 
  if (!tok->cmp("level1")) {
603
 
    psLevel = psLevel1;
604
 
  } else if (!tok->cmp("level1sep")) {
605
 
    psLevel = psLevel1Sep;
606
 
  } else if (!tok->cmp("level2")) {
607
 
    psLevel = psLevel2;
608
 
  } else if (!tok->cmp("level2sep")) {
609
 
    psLevel = psLevel2Sep;
610
 
  } else if (!tok->cmp("level3")) {
611
 
    psLevel = psLevel3;
612
 
  } else if (!tok->cmp("level3Sep")) {
613
 
    psLevel = psLevel3Sep;
614
 
  } else {
615
 
    error(-1, "Bad 'psLevel' config file command (%s:%d)",
616
 
          fileName->getCString(), line);
617
 
  }
618
 
}
619
 
 
620
 
void GlobalParams::parsePSFile(GList *tokens, GString *fileName, int line) {
621
 
  if (tokens->getLength() != 2) {
622
 
    error(-1, "Bad 'psFile' config file command (%s:%d)",
623
 
          fileName->getCString(), line);
624
 
    return;
625
 
  }
626
 
  if (psFile) {
627
 
    delete psFile;
628
 
  }
629
 
  psFile = ((GString *)tokens->get(1))->copy();
630
 
}
631
 
 
632
 
void GlobalParams::parsePSFont(GList *tokens, GString *fileName, int line) {
633
 
  PSFontParam *param;
634
 
 
635
 
  if (tokens->getLength() != 3) {
636
 
    error(-1, "Bad 'psFont' config file command (%s:%d)",
637
 
          fileName->getCString(), line);
638
 
    return;
639
 
  }
640
 
  param = new PSFontParam(((GString *)tokens->get(1))->copy(), 0,
641
 
                          ((GString *)tokens->get(2))->copy(), NULL);
642
 
  psFonts->add(param->pdfFontName, param);
643
 
}
644
 
 
645
 
void GlobalParams::parsePSFont16(char *cmdName, GList *fontList,
646
 
                                 GList *tokens, GString *fileName, int line) {
647
 
  PSFontParam *param;
648
 
  int wMode;
649
 
  GString *tok;
650
 
 
651
 
  if (tokens->getLength() != 5) {
652
 
    error(-1, "Bad '%s' config file command (%s:%d)",
653
 
          cmdName, fileName->getCString(), line);
654
 
    return;
655
 
  }
656
 
  tok = (GString *)tokens->get(2);
657
 
  if (!tok->cmp("H")) {
658
 
    wMode = 0;
659
 
  } else if (!tok->cmp("V")) {
660
 
    wMode = 1;
661
 
  } else {
662
 
    error(-1, "Bad '%s' config file command (%s:%d)",
663
 
          cmdName, fileName->getCString(), line);
664
 
    return;
665
 
  }
666
 
  param = new PSFontParam(((GString *)tokens->get(1))->copy(),
667
 
                          wMode,
668
 
                          ((GString *)tokens->get(3))->copy(),
669
 
                          ((GString *)tokens->get(4))->copy());
670
 
  fontList->append(param);
671
 
}
672
 
 
673
 
void GlobalParams::parseTextEncoding(GList *tokens, GString *fileName,
674
 
                                     int line) {
675
 
  if (tokens->getLength() != 2) {
676
 
    error(-1, "Bad 'textEncoding' config file command (%s:%d)",
677
 
          fileName->getCString(), line);
678
 
    return;
679
 
  }
680
 
  delete textEncoding;
681
 
  textEncoding = ((GString *)tokens->get(1))->copy();
682
 
}
683
 
 
684
 
void GlobalParams::parseTextEOL(GList *tokens, GString *fileName, int line) {
685
 
  GString *tok;
686
 
 
687
 
  if (tokens->getLength() != 2) {
688
 
    error(-1, "Bad 'textEOL' config file command (%s:%d)",
689
 
          fileName->getCString(), line);
690
 
    return;
691
 
  }
692
 
  tok = (GString *)tokens->get(1);
693
 
  if (!tok->cmp("unix")) {
694
 
    textEOL = eolUnix;
695
 
  } else if (!tok->cmp("dos")) {
696
 
    textEOL = eolDOS;
697
 
  } else if (!tok->cmp("mac")) {
698
 
    textEOL = eolMac;
699
 
  } else {
700
 
    error(-1, "Bad 'textEOL' config file command (%s:%d)",
701
 
          fileName->getCString(), line);
702
 
  }
703
 
}
704
 
 
705
 
void GlobalParams::parseFontDir(GList *tokens, GString *fileName, int line) {
706
 
  if (tokens->getLength() != 2) {
707
 
    error(-1, "Bad 'fontDir' config file command (%s:%d)",
708
 
          fileName->getCString(), line);
709
 
    return;
710
 
  }
711
 
  fontDirs->append(((GString *)tokens->get(1))->copy());
712
 
}
713
 
 
714
 
void GlobalParams::parseInitialZoom(GList *tokens,
715
 
                                    GString *fileName, int line) {
716
 
  if (tokens->getLength() != 2) {
717
 
    error(-1, "Bad 'initialZoom' config file command (%s:%d)",
718
 
          fileName->getCString(), line);
719
 
    return;
720
 
  }
721
 
  delete initialZoom;
722
 
  initialZoom = ((GString *)tokens->get(1))->copy();
723
 
}
724
 
 
725
 
void GlobalParams::parseFontRastControl(char *cmdName, FontRastControl *val,
726
 
                                        GList *tokens, GString *fileName,
727
 
                                        int line) {
728
 
  GString *tok;
729
 
 
730
 
  if (tokens->getLength() != 2) {
731
 
    error(-1, "Bad '%s' config file command (%s:%d)",
732
 
          cmdName, fileName->getCString(), line);
733
 
    return;
734
 
  }
735
 
  tok = (GString *)tokens->get(1);
736
 
  if (!setFontRastControl(val, tok->getCString())) {
737
 
    error(-1, "Bad '%s' config file command (%s:%d)",
738
 
          cmdName, fileName->getCString(), line);
739
 
  }
740
 
}
741
 
 
742
 
void GlobalParams::parseCommand(char *cmdName, GString **val,
743
 
                                GList *tokens, GString *fileName, int line) {
744
 
  if (tokens->getLength() != 2) {
745
 
    error(-1, "Bad '%s' config file command (%s:%d)",
746
 
          cmdName, fileName->getCString(), line);
747
 
    return;
748
 
  }
749
 
  if (*val) {
750
 
    delete *val;
751
 
  }
752
 
  *val = ((GString *)tokens->get(1))->copy();
753
 
}
754
 
 
755
 
void GlobalParams::parseYesNo(char *cmdName, GBool *flag,
756
 
                              GList *tokens, GString *fileName, int line) {
757
 
  GString *tok;
758
 
 
759
 
  if (tokens->getLength() != 2) {
760
 
    error(-1, "Bad '%s' config file command (%s:%d)",
761
 
          cmdName, fileName->getCString(), line);
762
 
    return;
763
 
  }
764
 
  tok = (GString *)tokens->get(1);
765
 
  if (!tok->cmp("yes")) {
766
 
    *flag = gTrue;
767
 
  } else if (!tok->cmp("no")) {
768
 
    *flag = gFalse;
769
 
  } else {
770
 
    error(-1, "Bad '%s' config file command (%s:%d)",
771
 
          cmdName, fileName->getCString(), line);
772
 
  }
773
 
}
774
 
 
775
 
GlobalParams::~GlobalParams() {
776
 
  GHashIter *iter;
777
 
  GString *key;
778
 
  GList *list;
779
 
 
780
 
  freeBuiltinFontTables();
781
 
 
782
 
  delete macRomanReverseMap;
783
 
 
784
 
  delete nameToUnicode;
785
 
  deleteGHash(cidToUnicodes, GString);
786
 
  deleteGHash(residentUnicodeMaps, UnicodeMap);
787
 
  deleteGHash(unicodeMaps, GString);
788
 
  deleteGList(toUnicodeDirs, GString);
789
 
  deleteGHash(displayFonts, DisplayFontParam);
790
 
  deleteGHash(displayCIDFonts, DisplayFontParam);
791
 
  deleteGHash(displayNamedCIDFonts, DisplayFontParam);
792
 
  if (psFile) {
793
 
    delete psFile;
794
 
  }
795
 
  deleteGHash(psFonts, PSFontParam);
796
 
  deleteGList(psNamedFonts16, PSFontParam);
797
 
  deleteGList(psFonts16, PSFontParam);
798
 
  delete textEncoding;
799
 
  deleteGList(fontDirs, GString);
800
 
  delete initialZoom;
801
 
  if (urlCommand) {
802
 
    delete urlCommand;
803
 
  }
804
 
  if (movieCommand) {
805
 
    delete movieCommand;
806
 
  }
807
 
 
808
 
  cMapDirs->startIter(&iter);
809
 
  while (cMapDirs->getNext(&iter, &key, (void **)&list)) {
810
 
    deleteGList(list, GString);
811
 
  }
812
 
  delete cMapDirs;
813
 
 
814
 
  delete cidToUnicodeCache;
815
 
  delete unicodeMapCache;
816
 
  delete cMapCache;
817
 
 
818
 
#if MULTITHREADED
819
 
  gDestroyMutex(&mutex);
820
 
#endif
821
 
}
822
 
 
823
 
//------------------------------------------------------------------------
824
 
// accessors
825
 
//------------------------------------------------------------------------
826
 
 
827
 
CharCode GlobalParams::getMacRomanCharCode(char *charName) {
828
 
  return macRomanReverseMap->lookup(charName);
829
 
}
830
 
 
831
 
Unicode GlobalParams::mapNameToUnicode(char *charName) {
832
 
  return nameToUnicode->lookup(charName);
833
 
}
834
 
 
835
 
OCFILE *GlobalParams::getCIDToUnicodeFile(GString *collection) {
836
 
  GString *fileName;
837
 
 
838
 
  if (!(fileName = (GString *)cidToUnicodes->lookup(collection))) {
839
 
    return NULL;
840
 
  }
841
 
  return ocfopen(fileName->getCString(), "r");
842
 
}
843
 
 
844
 
UnicodeMap *GlobalParams::getResidentUnicodeMap(GString *encodingName) {
845
 
  return (UnicodeMap *)residentUnicodeMaps->lookup(encodingName);
846
 
}
847
 
 
848
 
OCFILE *GlobalParams::getUnicodeMapFile(GString *encodingName) {
849
 
  GString *fileName;
850
 
 
851
 
  if (!(fileName = (GString *)unicodeMaps->lookup(encodingName))) {
852
 
    return NULL;
853
 
  }
854
 
  return ocfopen(fileName->getCString(), "r");
855
 
}
856
 
 
857
 
OCFILE *GlobalParams::findCMapFile(GString *collection, GString *cMapName) {
858
 
#if 0
859
 
  GList *list;
860
 
  GString *dir;
861
 
  GString *fileName;
862
 
  OCFILE *f;
863
 
  int i;
864
 
 
865
 
  if (!(list = (GList *)cMapDirs->lookup(collection))) {
866
 
    return NULL;
867
 
  }
868
 
  for (i = 0; i < list->getLength(); ++i) {
869
 
    dir = (GString *)list->get(i);
870
 
    fileName = appendToPath(dir->copy(), cMapName->getCString());
871
 
    f = ocfopen(fileName->getCString(), "r");
872
 
    delete fileName;
873
 
    if (f) {
874
 
      return f;
875
 
    }
876
 
  }
877
 
#endif
878
 
  return NULL;
879
 
}
880
 
 
881
 
OCFILE *GlobalParams::findToUnicodeFile(GString *name) {
882
 
#if 0
883
 
  GString *dir, *fileName;
884
 
  OCFILE *f;
885
 
  int i;
886
 
 
887
 
  for (i = 0; i < toUnicodeDirs->getLength(); ++i) {
888
 
    dir = (GString *)toUnicodeDirs->get(i);
889
 
    fileName = appendToPath(dir->copy(), name->getCString());
890
 
    f = ocfopen(fileName->getCString(), "r");
891
 
    delete fileName;
892
 
    if (f) {
893
 
      return f;
894
 
    }
895
 
  }
896
 
#endif
897
 
  return NULL;
898
 
}
899
 
 
900
 
DisplayFontParam *GlobalParams::getDisplayFont(GString *fontName) {
901
 
  DisplayFontParam *dfp;
902
 
 
903
 
  globalParamsLock;
904
 
  dfp = (DisplayFontParam *)displayFonts->lookup(fontName);
905
 
  globalParamsUnlock;
906
 
  return dfp;
907
 
}
908
 
 
909
 
DisplayFontParam *GlobalParams::getDisplayCIDFont(GString *fontName,
910
 
                                                  GString *collection) {
911
 
  DisplayFontParam *dfp;
912
 
 
913
 
  if (!fontName ||
914
 
      !(dfp = (DisplayFontParam *)displayNamedCIDFonts->lookup(fontName))) {
915
 
    dfp = (DisplayFontParam *)displayCIDFonts->lookup(collection);
916
 
  }
917
 
  return dfp;
918
 
}
919
 
 
920
 
GString *GlobalParams::getPSFile() {
921
 
  GString *s;
922
 
 
923
 
  globalParamsLock;
924
 
  s = psFile ? psFile->copy() : (GString *)NULL;
925
 
  globalParamsUnlock;
926
 
  return s;
927
 
}
928
 
 
929
 
int GlobalParams::getPSPaperWidth() {
930
 
  int w;
931
 
 
932
 
  globalParamsLock;
933
 
  w = psPaperWidth;
934
 
  globalParamsUnlock;
935
 
  return w;
936
 
}
937
 
 
938
 
int GlobalParams::getPSPaperHeight() {
939
 
  int h;
940
 
 
941
 
  globalParamsLock;
942
 
  h = psPaperHeight;
943
 
  globalParamsUnlock;
944
 
  return h;
945
 
}
946
 
 
947
 
GBool GlobalParams::getPSDuplex() {
948
 
  GBool d;
949
 
 
950
 
  globalParamsLock;
951
 
  d = psDuplex;
952
 
  globalParamsUnlock;
953
 
  return d;
954
 
}
955
 
 
956
 
PSLevel GlobalParams::getPSLevel() {
957
 
  PSLevel level;
958
 
 
959
 
  globalParamsLock;
960
 
  level = psLevel;
961
 
  globalParamsUnlock;
962
 
  return level;
963
 
}
964
 
 
965
 
PSFontParam *GlobalParams::getPSFont(GString *fontName) {
966
 
  return (PSFontParam *)psFonts->lookup(fontName);
967
 
}
968
 
 
969
 
PSFontParam *GlobalParams::getPSFont16(GString *fontName,
970
 
                                       GString *collection, int wMode) {
971
 
  PSFontParam *p;
972
 
  int i;
973
 
 
974
 
  p = NULL;
975
 
  if (fontName) {
976
 
    for (i = 0; i < psNamedFonts16->getLength(); ++i) {
977
 
      p = (PSFontParam *)psNamedFonts16->get(i);
978
 
      if (!p->pdfFontName->cmp(fontName) &&
979
 
          p->wMode == wMode) {
980
 
        break;
981
 
      }
982
 
      p = NULL;
983
 
    }
984
 
  }
985
 
  if (!p && collection) {
986
 
    for (i = 0; i < psFonts16->getLength(); ++i) {
987
 
      p = (PSFontParam *)psFonts16->get(i);
988
 
      if (!p->pdfFontName->cmp(collection) &&
989
 
          p->wMode == wMode) {
990
 
        break;
991
 
      }
992
 
      p = NULL;
993
 
    }
994
 
  }
995
 
  return p;
996
 
}
997
 
 
998
 
GBool GlobalParams::getPSEmbedType1() {
999
 
  GBool e;
1000
 
 
1001
 
  globalParamsLock;
1002
 
  e = psEmbedType1;
1003
 
  globalParamsUnlock;
1004
 
  return e;
1005
 
}
1006
 
 
1007
 
GBool GlobalParams::getPSEmbedTrueType() {
1008
 
  GBool e;
1009
 
 
1010
 
  globalParamsLock;
1011
 
  e = psEmbedTrueType;
1012
 
  globalParamsUnlock;
1013
 
  return e;
1014
 
}
1015
 
 
1016
 
GBool GlobalParams::getPSEmbedCIDPostScript() {
1017
 
  GBool e;
1018
 
 
1019
 
  globalParamsLock;
1020
 
  e = psEmbedCIDPostScript;
1021
 
  globalParamsUnlock;
1022
 
  return e;
1023
 
}
1024
 
 
1025
 
GBool GlobalParams::getPSEmbedCIDTrueType() {
1026
 
  GBool e;
1027
 
 
1028
 
  globalParamsLock;
1029
 
  e = psEmbedCIDTrueType;
1030
 
  globalParamsUnlock;
1031
 
  return e;
1032
 
}
1033
 
 
1034
 
GBool GlobalParams::getPSOPI() {
1035
 
  GBool opi;
1036
 
 
1037
 
  globalParamsLock;
1038
 
  opi = psOPI;
1039
 
  globalParamsUnlock;
1040
 
  return opi;
1041
 
}
1042
 
 
1043
 
GBool GlobalParams::getPSASCIIHex() {
1044
 
  GBool ah;
1045
 
 
1046
 
  globalParamsLock;
1047
 
  ah = psASCIIHex;
1048
 
  globalParamsUnlock;
1049
 
  return ah;
1050
 
}
1051
 
 
1052
 
EndOfLineKind GlobalParams::getTextEOL() {
1053
 
  EndOfLineKind eol;
1054
 
 
1055
 
  globalParamsLock;
1056
 
  eol = textEOL;
1057
 
  globalParamsUnlock;
1058
 
  return eol;
1059
 
}
1060
 
 
1061
 
GBool GlobalParams::getTextKeepTinyChars() {
1062
 
  GBool tiny;
1063
 
 
1064
 
  globalParamsLock;
1065
 
  tiny = textKeepTinyChars;
1066
 
  globalParamsUnlock;
1067
 
  return tiny;
1068
 
}
1069
 
 
1070
 
GString *GlobalParams::findFontFile(GString *fontName,
1071
 
                                    char *ext1, char *ext2) {
1072
 
#if 0
1073
 
  GString *dir, *fileName;
1074
 
  OCFILE *f;
1075
 
  int i;
1076
 
 
1077
 
  for (i = 0; i < fontDirs->getLength(); ++i) {
1078
 
    dir = (GString *)fontDirs->get(i);
1079
 
    if (ext1) {
1080
 
      fileName = appendToPath(dir->copy(), fontName->getCString());
1081
 
      fileName->append(ext1);
1082
 
      if ((f = ocfopen(fileName->getCString(), "r"))) {
1083
 
        fclose(f);
1084
 
        return fileName;
1085
 
      }
1086
 
      delete fileName;
1087
 
    }
1088
 
    if (ext2) {
1089
 
      fileName = appendToPath(dir->copy(), fontName->getCString());
1090
 
      fileName->append(ext2);
1091
 
      if ((f = ocfopen(fileName->getCString(), "r"))) {
1092
 
        fclose(f);
1093
 
        return fileName;
1094
 
      }
1095
 
      delete fileName;
1096
 
    }
1097
 
  }
1098
 
#endif 
1099
 
  return NULL;
1100
 
}
1101
 
 
1102
 
GString *GlobalParams::getInitialZoom() {
1103
 
  GString *s;
1104
 
 
1105
 
  globalParamsLock;
1106
 
  s = initialZoom->copy();
1107
 
  globalParamsUnlock;
1108
 
  return s;
1109
 
}
1110
 
 
1111
 
FontRastControl GlobalParams::getT1libControl() {
1112
 
  FontRastControl c;
1113
 
 
1114
 
  globalParamsLock;
1115
 
  c = t1libControl;
1116
 
  globalParamsUnlock;
1117
 
  return c;
1118
 
}
1119
 
 
1120
 
FontRastControl GlobalParams::getFreeTypeControl() {
1121
 
  FontRastControl c;
1122
 
 
1123
 
  globalParamsLock;
1124
 
  c = freetypeControl;
1125
 
  globalParamsUnlock;
1126
 
  return c;
1127
 
}
1128
 
 
1129
 
GBool GlobalParams::getMapNumericCharNames() {
1130
 
  GBool map;
1131
 
 
1132
 
  globalParamsLock;
1133
 
  map = mapNumericCharNames;
1134
 
  globalParamsUnlock;
1135
 
  return map;
1136
 
}
1137
 
 
1138
 
GBool GlobalParams::getPrintCommands() {
1139
 
  GBool p;
1140
 
 
1141
 
  globalParamsLock;
1142
 
  p = printCommands;
1143
 
  globalParamsUnlock;
1144
 
  return p;
1145
 
}
1146
 
 
1147
 
GBool GlobalParams::getErrQuiet() {
1148
 
  GBool q;
1149
 
 
1150
 
  globalParamsLock;
1151
 
  q = errQuiet;
1152
 
  globalParamsUnlock;
1153
 
  return q;
1154
 
}
1155
 
 
1156
 
CharCodeToUnicode *GlobalParams::getCIDToUnicode(GString *collection) {
1157
 
  CharCodeToUnicode *ctu;
1158
 
 
1159
 
  globalParamsLock;
1160
 
  ctu = cidToUnicodeCache->getCIDToUnicode(collection);
1161
 
  globalParamsUnlock;
1162
 
  return ctu;
1163
 
}
1164
 
 
1165
 
UnicodeMap *GlobalParams::getUnicodeMap(GString *encodingName) {
1166
 
  UnicodeMap *map;
1167
 
 
1168
 
  globalParamsLock;
1169
 
  map = getUnicodeMap2(encodingName);
1170
 
  globalParamsUnlock;
1171
 
  return map;
1172
 
}
1173
 
 
1174
 
UnicodeMap *GlobalParams::getUnicodeMap2(GString *encodingName) {
1175
 
  UnicodeMap *map;
1176
 
 
1177
 
  if ((map = getResidentUnicodeMap(encodingName))) {
1178
 
    map->incRefCnt();
1179
 
  } else {
1180
 
    map = unicodeMapCache->getUnicodeMap(encodingName);
1181
 
  }
1182
 
  return map;
1183
 
}
1184
 
 
1185
 
CMap *GlobalParams::getCMap(GString *collection, GString *cMapName) {
1186
 
  CMap *cMap;
1187
 
 
1188
 
  globalParamsLock;
1189
 
  cMap = cMapCache->getCMap(collection, cMapName);
1190
 
  globalParamsUnlock;
1191
 
  return cMap;
1192
 
}
1193
 
 
1194
 
UnicodeMap *GlobalParams::getTextEncoding() {
1195
 
  UnicodeMap *map;
1196
 
 
1197
 
  globalParamsLock;
1198
 
  map = getUnicodeMap2(textEncoding);
1199
 
  globalParamsUnlock;
1200
 
  return map;
1201
 
}
1202
 
 
1203
 
//------------------------------------------------------------------------
1204
 
// functions to set parameters
1205
 
//------------------------------------------------------------------------
1206
 
 
1207
 
void GlobalParams::addDisplayFont(DisplayFontParam *param) {
1208
 
  DisplayFontParam *old;
1209
 
 
1210
 
  globalParamsLock;
1211
 
  if ((old = (DisplayFontParam *)displayFonts->remove(param->name))) {
1212
 
    delete old;
1213
 
  }
1214
 
  displayFonts->add(param->name, param);
1215
 
  globalParamsUnlock;
1216
 
}
1217
 
 
1218
 
void GlobalParams::setPSFile(char *file) {
1219
 
  globalParamsLock;
1220
 
  if (psFile) {
1221
 
    delete psFile;
1222
 
  }
1223
 
  psFile = new GString(file);
1224
 
  globalParamsUnlock;
1225
 
}
1226
 
 
1227
 
GBool GlobalParams::setPSPaperSize(char *size) {
1228
 
  globalParamsLock;
1229
 
  if (!strcmp(size, "letter")) {
1230
 
    psPaperWidth = 612;
1231
 
    psPaperHeight = 792;
1232
 
  } else if (!strcmp(size, "legal")) {
1233
 
    psPaperWidth = 612;
1234
 
    psPaperHeight = 1008;
1235
 
  } else if (!strcmp(size, "A4")) {
1236
 
    psPaperWidth = 595;
1237
 
    psPaperHeight = 842;
1238
 
  } else if (!strcmp(size, "A3")) {
1239
 
    psPaperWidth = 842;
1240
 
    psPaperHeight = 1190;
1241
 
  } else {
1242
 
    globalParamsUnlock;
1243
 
    return gFalse;
1244
 
  }
1245
 
  globalParamsUnlock;
1246
 
  return gTrue;
1247
 
}
1248
 
 
1249
 
void GlobalParams::setPSPaperWidth(int width) {
1250
 
  globalParamsLock;
1251
 
  psPaperWidth = width;
1252
 
  globalParamsUnlock;
1253
 
}
1254
 
 
1255
 
void GlobalParams::setPSPaperHeight(int height) {
1256
 
  globalParamsLock;
1257
 
  psPaperHeight = height;
1258
 
  globalParamsUnlock;
1259
 
}
1260
 
 
1261
 
void GlobalParams::setPSDuplex(GBool duplex) {
1262
 
  globalParamsLock;
1263
 
  psDuplex = duplex;
1264
 
  globalParamsUnlock;
1265
 
}
1266
 
 
1267
 
void GlobalParams::setPSLevel(PSLevel level) {
1268
 
  globalParamsLock;
1269
 
  psLevel = level;
1270
 
  globalParamsUnlock;
1271
 
}
1272
 
 
1273
 
void GlobalParams::setPSEmbedType1(GBool embed) {
1274
 
  globalParamsLock;
1275
 
  psEmbedType1 = embed;
1276
 
  globalParamsUnlock;
1277
 
}
1278
 
 
1279
 
void GlobalParams::setPSEmbedTrueType(GBool embed) {
1280
 
  globalParamsLock;
1281
 
  psEmbedTrueType = embed;
1282
 
  globalParamsUnlock;
1283
 
}
1284
 
 
1285
 
void GlobalParams::setPSEmbedCIDPostScript(GBool embed) {
1286
 
  globalParamsLock;
1287
 
  psEmbedCIDPostScript = embed;
1288
 
  globalParamsUnlock;
1289
 
}
1290
 
 
1291
 
void GlobalParams::setPSEmbedCIDTrueType(GBool embed) {
1292
 
  globalParamsLock;
1293
 
  psEmbedCIDTrueType = embed;
1294
 
  globalParamsUnlock;
1295
 
}
1296
 
 
1297
 
void GlobalParams::setPSOPI(GBool opi) {
1298
 
  globalParamsLock;
1299
 
  psOPI = opi;
1300
 
  globalParamsUnlock;
1301
 
}
1302
 
 
1303
 
void GlobalParams::setPSASCIIHex(GBool hex) {
1304
 
  globalParamsLock;
1305
 
  psASCIIHex = hex;
1306
 
  globalParamsUnlock;
1307
 
}
1308
 
 
1309
 
void GlobalParams::setTextEncoding(char *encodingName) {
1310
 
  globalParamsLock;
1311
 
  delete textEncoding;
1312
 
  textEncoding = new GString(encodingName);
1313
 
  globalParamsUnlock;
1314
 
}
1315
 
 
1316
 
GBool GlobalParams::setTextEOL(char *s) {
1317
 
  globalParamsLock;
1318
 
  if (!strcmp(s, "unix")) {
1319
 
    textEOL = eolUnix;
1320
 
  } else if (!strcmp(s, "dos")) {
1321
 
    textEOL = eolDOS;
1322
 
  } else if (!strcmp(s, "mac")) {
1323
 
    textEOL = eolMac;
1324
 
  } else {
1325
 
    globalParamsUnlock;
1326
 
    return gFalse;
1327
 
  }
1328
 
  globalParamsUnlock;
1329
 
  return gTrue;
1330
 
}
1331
 
 
1332
 
void GlobalParams::setTextKeepTinyChars(GBool keep) {
1333
 
  globalParamsLock;
1334
 
  textKeepTinyChars = keep;
1335
 
  globalParamsUnlock;
1336
 
}
1337
 
 
1338
 
void GlobalParams::setInitialZoom(char *s) {
1339
 
  globalParamsLock;
1340
 
  delete initialZoom;
1341
 
  initialZoom = new GString(s);
1342
 
  globalParamsUnlock;
1343
 
}
1344
 
 
1345
 
GBool GlobalParams::setT1libControl(char *s) {
1346
 
  GBool ok;
1347
 
 
1348
 
  globalParamsLock;
1349
 
  ok = setFontRastControl(&t1libControl, s);
1350
 
  globalParamsUnlock;
1351
 
  return ok;
1352
 
}
1353
 
 
1354
 
GBool GlobalParams::setFreeTypeControl(char *s) {
1355
 
  GBool ok;
1356
 
 
1357
 
  globalParamsLock;
1358
 
  ok = setFontRastControl(&freetypeControl, s);
1359
 
  globalParamsUnlock;
1360
 
  return ok;
1361
 
}
1362
 
 
1363
 
GBool GlobalParams::setFontRastControl(FontRastControl *val, char *s) {
1364
 
  if (!strcmp(s, "none")) {
1365
 
    *val = fontRastNone;
1366
 
  } else if (!strcmp(s, "plain")) {
1367
 
    *val = fontRastPlain;
1368
 
  } else if (!strcmp(s, "low")) {
1369
 
    *val = fontRastAALow;
1370
 
  } else if (!strcmp(s, "high")) {
1371
 
    *val = fontRastAAHigh;
1372
 
  } else {
1373
 
    return gFalse;
1374
 
  }
1375
 
  return gTrue;
1376
 
}
1377
 
 
1378
 
void GlobalParams::setMapNumericCharNames(GBool map) {
1379
 
  globalParamsLock;
1380
 
  mapNumericCharNames = map;
1381
 
  globalParamsUnlock;
1382
 
}
1383
 
 
1384
 
void GlobalParams::setPrintCommands(GBool printCommandsA) {
1385
 
  globalParamsLock;
1386
 
  printCommands = printCommandsA;
1387
 
  globalParamsUnlock;
1388
 
}
1389
 
 
1390
 
void GlobalParams::setErrQuiet(GBool errQuietA) {
1391
 
  globalParamsLock;
1392
 
  errQuiet = errQuietA;
1393
 
  globalParamsUnlock;
1394
 
}