Diffstat (limited to 'noncore/unsupported/qpdf/xpdf/CMap.h') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/unsupported/qpdf/xpdf/CMap.h | 93 |
1 files changed, 93 insertions, 0 deletions
diff --git a/noncore/unsupported/qpdf/xpdf/CMap.h b/noncore/unsupported/qpdf/xpdf/CMap.h new file mode 100644 index 0000000..8b29ef7 --- a/dev/null +++ b/noncore/unsupported/qpdf/xpdf/CMap.h | |||
@@ -0,0 +1,93 @@ | |||
1 | //======================================================================== | ||
2 | // | ||
3 | // CMap.h | ||
4 | // | ||
5 | // Copyright 2001 Derek B. Noonburg | ||
6 | // | ||
7 | //======================================================================== | ||
8 | |||
9 | #ifndef CMAP_H | ||
10 | #define CMAP_H | ||
11 | |||
12 | #ifdef __GNUC__ | ||
13 | #pragma interface | ||
14 | #endif | ||
15 | |||
16 | #include "gtypes.h" | ||
17 | #include "CharTypes.h" | ||
18 | |||
19 | class GString; | ||
20 | struct CMapVectorEntry; | ||
21 | class CMapCache; | ||
22 | |||
23 | //------------------------------------------------------------------------ | ||
24 | |||
25 | class CMap { | ||
26 | public: | ||
27 | |||
28 | // Create the CMap specified by <collection> and <cMapName>. Sets | ||
29 | // the initial reference count to 1. Returns NULL on failure. | ||
30 | static CMap *parse(CMapCache *cache, GString *collectionA, | ||
31 | GString *cMapNameA); | ||
32 | |||
33 | ~CMap(); | ||
34 | |||
35 | void incRefCnt(); | ||
36 | void decRefCnt(); | ||
37 | |||
38 | // Return collection name (<registry>-<ordering>). | ||
39 | GString *getCollection() { return collection; } | ||
40 | |||
41 | // Return true if this CMap matches the specified <collectionA>, and | ||
42 | // <cMapNameA>. | ||
43 | GBool match(GString *collectionA, GString *cMapNameA); | ||
44 | |||
45 | // Return the CID corresponding to the character code starting at | ||
46 | // <s>, which contains <len> bytes. Sets *<nUsed> to the number of | ||
47 | // bytes used by the char code. | ||
48 | CID getCID(char *s, int len, int *nUsed); | ||
49 | |||
50 | // Return the writing mode (0=horizontal, 1=vertical). | ||
51 | int getWMode() { return wMode; } | ||
52 | |||
53 | private: | ||
54 | |||
55 | CMap(GString *collectionA, GString *cMapNameA); | ||
56 | CMap(GString *collectionA, GString *cMapNameA, int wModeA); | ||
57 | void useCMap(CMapCache *cache, char *useName); | ||
58 | void copyVector(CMapVectorEntry *dest, CMapVectorEntry *src); | ||
59 | void addCodeSpace(CMapVectorEntry *vec, Guint start, Guint end, | ||
60 | Guint nBytes); | ||
61 | void addCIDs(Guint start, Guint end, Guint nBytes, CID firstCID); | ||
62 | void freeCMapVector(CMapVectorEntry *vec); | ||
63 | |||
64 | GString *collection; | ||
65 | GString *cMapName; | ||
66 | int wMode; // writing mode (0=horizontal, 1=vertical) | ||
67 | CMapVectorEntry *vector;// vector for first byte (NULL for | ||
68 | // identity CMap) | ||
69 | int refCnt; | ||
70 | }; | ||
71 | |||
72 | //------------------------------------------------------------------------ | ||
73 | |||
74 | #define cMapCacheSize 4 | ||
75 | |||
76 | class CMapCache { | ||
77 | public: | ||
78 | |||
79 | CMapCache(); | ||
80 | ~CMapCache(); | ||
81 | |||
82 | // Get the <cMapName> CMap for the specified character collection. | ||
83 | // Increments its reference count; there will be one reference for | ||
84 | // the cache plus one for the caller of this function. Returns NULL | ||
85 | // on failure. | ||
86 | CMap *getCMap(GString *collection, GString *cMapName); | ||
87 | |||
88 | private: | ||
89 | |||
90 | CMap *cache[cMapCacheSize]; | ||
91 | }; | ||
92 | |||
93 | #endif | ||