source: trunk/poppler/mypoppler/poppler/CMap.h @ 461

Last change on this file since 461 was 277, checked in by rbri, 12 years ago

PDF plugin: Poppler library updated to version 0.12.3

File size: 3.6 KB
Line 
1//========================================================================
2//
3// CMap.h
4//
5// Copyright 2001-2003 Glyph & Cog, LLC
6//
7//========================================================================
8
9//========================================================================
10//
11// Modified under the Poppler project - http://poppler.freedesktop.org
12//
13// All changes made under the Poppler project to this file are licensed
14// under GPL version 2 or later
15//
16// Copyright (C) 2008 Koji Otani <sho@bbr.jp>
17// Copyright (C) 2009 Albert Astals Cid <aacid@kde.org>
18//
19// To see a description of the changes please see the Changelog file that
20// came with your tarball or type make ChangeLog if you are building from git
21//
22//========================================================================
23
24#ifndef CMAP_H
25#define CMAP_H
26
27#ifdef USE_GCC_PRAGMAS
28#pragma interface
29#endif
30
31#include "poppler-config.h"
32#include "goo/gtypes.h"
33#include "CharTypes.h"
34
35#if MULTITHREADED
36#include "goo/GooMutex.h"
37#endif
38
39class GooString;
40struct CMapVectorEntry;
41class CMapCache;
42class Stream;
43
44//------------------------------------------------------------------------
45
46class CMap {
47public:
48
49  // Create the CMap specified by <collection> and <cMapName>.  Sets
50  // the initial reference count to 1.
51  // Stream is a stream containing the CMap, can be NULL and
52  // this means the CMap will be searched in the CMap files
53  // Returns NULL on failure.
54  static CMap *parse(CMapCache *cache, GooString *collectionA,
55                     GooString *cMapNameA, Stream *stream);
56
57  ~CMap();
58
59  void incRefCnt();
60  void decRefCnt();
61
62  // Return collection name (<registry>-<ordering>).
63  GooString *getCollection() { return collection; }
64
65  // Return true if this CMap matches the specified <collectionA>, and
66  // <cMapNameA>.
67  GBool match(GooString *collectionA, GooString *cMapNameA);
68
69  // Return the CID corresponding to the character code starting at
70  // <s>, which contains <len> bytes.  Sets *<nUsed> to the number of
71  // bytes used by the char code.
72  CID getCID(char *s, int len, int *nUsed);
73
74  // Return the writing mode (0=horizontal, 1=vertical).
75  int getWMode() { return wMode; }
76
77  void setReverseMap(Guint *rmap, Guint rmapSize, Guint ncand);
78
79private:
80
81  CMap(GooString *collectionA, GooString *cMapNameA);
82  CMap(GooString *collectionA, GooString *cMapNameA, int wModeA);
83  void useCMap(CMapCache *cache, char *useName);
84  void copyVector(CMapVectorEntry *dest, CMapVectorEntry *src);
85  void addCodeSpace(CMapVectorEntry *vec, Guint start, Guint end,
86                    Guint nBytes);
87  void addCIDs(Guint start, Guint end, Guint nBytes, CID firstCID);
88  void freeCMapVector(CMapVectorEntry *vec);
89  void setReverseMapVector(Guint startCode, CMapVectorEntry *vec,
90          Guint *rmap, Guint rmapSize, Guint ncand);
91
92  GooString *collection;
93  GooString *cMapName;
94  int wMode;                    // writing mode (0=horizontal, 1=vertical)
95  CMapVectorEntry *vector;      // vector for first byte (NULL for
96                                //   identity CMap)
97  int refCnt;
98#if MULTITHREADED
99  GooMutex mutex;
100#endif
101};
102
103//------------------------------------------------------------------------
104
105#define cMapCacheSize 4
106
107class CMapCache {
108public:
109
110  CMapCache();
111  ~CMapCache();
112
113  // Get the <cMapName> CMap for the specified character collection.
114  // Increments its reference count; there will be one reference for
115  // the cache plus one for the caller of this function.
116  // Stream is a stream containing the CMap, can be NULL and
117  // this means the CMap will be searched in the CMap files
118  // Returns NULL on failure.
119  CMap *getCMap(GooString *collection, GooString *cMapName, Stream *stream);
120
121private:
122
123  CMap *cache[cMapCacheSize];
124};
125
126#endif
Note: See TracBrowser for help on using the repository browser.