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