~ubuntu-branches/ubuntu/breezy/koffice/breezy

« back to all changes in this revision

Viewing changes to filters/kword/pdf/xpdf/xpdf/UnicodeMap.h

  • Committer: Bazaar Package Importer
  • Author(s): Ben Burton
  • Date: 2004-05-09 11:33:00 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20040509113300-vfrdadqsvjfuhn3b
Tags: 1:1.3.1-1
* New upstream bugfix release.
* Built against newer imagemagick (closes: #246623).
* Made koffice-libs/kformula recommend/depend on latex-xft-fonts, which
  provides mathematical fonts that the formula editor can use.  Also
  patched the kformula part to make these fonts the default.
* Changed kword menu hint from "WordProcessors" to "Word processors"
  (closes: #246209).
* Spellchecker configuration is now fixed (closes: #221256, #227568).

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
//========================================================================
 
2
//
 
3
// UnicodeMap.h
 
4
//
 
5
// Mapping from Unicode to an encoding.
 
6
//
 
7
// Copyright 2001-2002 Glyph & Cog, LLC
 
8
//
 
9
//========================================================================
 
10
 
 
11
#ifndef UNICODEMAP_H
 
12
#define UNICODEMAP_H
 
13
 
 
14
#include <aconf.h>
 
15
 
 
16
#ifdef USE_GCC_PRAGMAS
 
17
#pragma interface
 
18
#endif
 
19
 
 
20
#include "gtypes.h"
 
21
#include "CharTypes.h"
 
22
 
 
23
class GString;
 
24
 
 
25
//------------------------------------------------------------------------
 
26
 
 
27
enum UnicodeMapKind {
 
28
  unicodeMapUser,               // read from a file
 
29
  unicodeMapResident,           // static list of ranges
 
30
  unicodeMapFunc                // function pointer
 
31
};
 
32
 
 
33
typedef int (*UnicodeMapFunc)(Unicode u, char *buf, int bufSize);
 
34
 
 
35
struct UnicodeMapRange {
 
36
  Unicode start, end;           // range of Unicode chars
 
37
  Guint code, nBytes;           // first output code
 
38
};
 
39
 
 
40
struct UnicodeMapExt;
 
41
 
 
42
//------------------------------------------------------------------------
 
43
 
 
44
class UnicodeMap {
 
45
public:
 
46
 
 
47
  // Create the UnicodeMap specified by <encodingName>.  Sets the
 
48
  // initial reference count to 1.  Returns NULL on failure.
 
49
  static UnicodeMap *parse(GString *encodingNameA);
 
50
 
 
51
  // Create a resident UnicodeMap.
 
52
  UnicodeMap(const char *encodingNameA, GBool unicodeOutA,
 
53
             UnicodeMapRange *rangesA, int lenA);
 
54
 
 
55
  // Create a resident UnicodeMap that uses a function instead of a
 
56
  // list of ranges.
 
57
  UnicodeMap(const char *encodingNameA, GBool unicodeOutA,
 
58
             UnicodeMapFunc funcA);
 
59
 
 
60
  ~UnicodeMap();
 
61
 
 
62
  void incRefCnt();
 
63
  void decRefCnt();
 
64
 
 
65
  GString *getEncodingName() { return encodingName; }
 
66
 
 
67
  GBool isUnicode() { return unicodeOut; }
 
68
 
 
69
  // Return true if this UnicodeMap matches the specified
 
70
  // <encodingNameA>.
 
71
  GBool match(GString *encodingNameA);
 
72
 
 
73
  // Map Unicode to the target encoding.  Fills in <buf> with the
 
74
  // output and returns the number of bytes used.  Output will be
 
75
  // truncated at <bufSize> bytes.  No string terminator is written.
 
76
  // Returns 0 if no mapping is found.
 
77
  int mapUnicode(Unicode u, char *buf, int bufSize);
 
78
 
 
79
private:
 
80
 
 
81
  UnicodeMap(GString *encodingNameA);
 
82
 
 
83
  GString *encodingName;
 
84
  UnicodeMapKind kind;
 
85
  GBool unicodeOut;
 
86
  union {
 
87
    UnicodeMapRange *ranges;    // (user, resident)
 
88
    UnicodeMapFunc func;        // (func)
 
89
  };
 
90
  int len;                      // (user, resident)
 
91
  UnicodeMapExt *eMaps;         // (user)
 
92
  int eMapsLen;                 // (user)
 
93
  int refCnt;
 
94
};
 
95
 
 
96
//------------------------------------------------------------------------
 
97
 
 
98
#define unicodeMapCacheSize 4
 
99
 
 
100
class UnicodeMapCache {
 
101
public:
 
102
 
 
103
  UnicodeMapCache();
 
104
  ~UnicodeMapCache();
 
105
 
 
106
  // Get the UnicodeMap for <encodingName>.  Increments its reference
 
107
  // count; there will be one reference for the cache plus one for the
 
108
  // caller of this function.  Returns NULL on failure.
 
109
  UnicodeMap *getUnicodeMap(GString *encodingName);
 
110
 
 
111
private:
 
112
 
 
113
  UnicodeMap *cache[unicodeMapCacheSize];
 
114
};
 
115
 
 
116
#endif