source: trunk/poppler/mypoppler/poppler/CharCodeToUnicode.h @ 257

Last change on this file since 257 was 257, checked in by Eugene Romanenko, 13 years ago

PDF plugin: Poppler library updated to version 0.10.0

File size: 3.9 KB
Line 
1//========================================================================
2//
3// CharCodeToUnicode.h
4//
5// Mapping from character codes to Unicode.
6//
7// Copyright 2001-2003 Glyph & Cog, LLC
8//
9//========================================================================
10
11//========================================================================
12//
13// Modified under the Poppler project - http://poppler.freedesktop.org
14//
15// All changes made under the Poppler project to this file are licensed
16// under GPL version 2 or later
17//
18// Copyright (C) 2007 Julien Rebetez <julienr@svn.gnome.org>
19// Copyright (C) 2007 Koji Otani <sho@bbr.jp>
20// Copyright (C) 2008 Albert Astals Cid <aacid@kde.org>
21//
22// To see a description of the changes please see the Changelog file that
23// came with your tarball or type make ChangeLog if you are building from git
24//
25//========================================================================
26
27#ifndef CHARCODETOUNICODE_H
28#define CHARCODETOUNICODE_H
29
30#ifdef USE_GCC_PRAGMAS
31#pragma interface
32#endif
33
34#include "poppler-config.h"
35#include "CharTypes.h"
36
37#if MULTITHREADED
38#include "goo/GooMutex.h"
39#endif
40
41struct CharCodeToUnicodeString;
42
43//------------------------------------------------------------------------
44
45class CharCodeToUnicode {
46friend class UnicodeToCharCode;
47public:
48
49  // Read the CID-to-Unicode mapping for <collection> from the file
50  // specified by <fileName>.  Sets the initial reference count to 1.
51  // Returns NULL on failure.
52  static CharCodeToUnicode *parseCIDToUnicode(GooString *fileName,
53                                              GooString *collection);
54
55  // Create a Unicode-to-Unicode mapping from the file specified by
56  // <fileName>.  Sets the initial reference count to 1.  Returns NULL
57  // on failure.
58  static CharCodeToUnicode *parseUnicodeToUnicode(GooString *fileName);
59
60  // Create the CharCode-to-Unicode mapping for an 8-bit font.
61  // <toUnicode> is an array of 256 Unicode indexes.  Sets the initial
62  // reference count to 1.
63  static CharCodeToUnicode *make8BitToUnicode(Unicode *toUnicode);
64
65  // Parse a ToUnicode CMap for an 8- or 16-bit font.
66  static CharCodeToUnicode *parseCMap(GooString *buf, int nBits);
67  static CharCodeToUnicode *parseCMapFromFile(GooString *fileName, int nBits);
68
69  // Parse a ToUnicode CMap for an 8- or 16-bit font, merging it into
70  // <this>.
71  void mergeCMap(GooString *buf, int nBits);
72
73  ~CharCodeToUnicode();
74
75  void incRefCnt();
76  void decRefCnt();
77
78  // Return true if this mapping matches the specified <tagA>.
79  GBool match(GooString *tagA);
80
81  // Set the mapping for <c>.
82  void setMapping(CharCode c, Unicode *u, int len);
83
84  // Map a CharCode to Unicode.
85  int mapToUnicode(CharCode c, Unicode **u);
86
87  int mapToCharCode(Unicode* u, CharCode *c, int usize);
88
89  // Return the mapping's length, i.e., one more than the max char
90  // code supported by the mapping.
91  CharCode getLength() { return mapLen; }
92
93private:
94
95  void parseCMap1(int (*getCharFunc)(void *), void *data, int nBits);
96  void addMapping(CharCode code, char *uStr, int n, int offset);
97  CharCodeToUnicode(GooString *tagA);
98  CharCodeToUnicode(GooString *tagA, Unicode *mapA,
99                    CharCode mapLenA, GBool copyMap,
100                    CharCodeToUnicodeString *sMapA,
101                    int sMapLenA, int sMapSizeA);
102
103  GooString *tag;
104  Unicode *map;
105  CharCode mapLen;
106  CharCodeToUnicodeString *sMap;
107  int sMapLen, sMapSize;
108  int refCnt;
109#if MULTITHREADED
110  GooMutex mutex;
111#endif
112};
113
114//------------------------------------------------------------------------
115
116class CharCodeToUnicodeCache {
117public:
118
119  CharCodeToUnicodeCache(int sizeA);
120  ~CharCodeToUnicodeCache();
121
122  // Get the CharCodeToUnicode object for <tag>.  Increments its
123  // reference count; there will be one reference for the cache plus
124  // one for the caller of this function.  Returns NULL on failure.
125  CharCodeToUnicode *getCharCodeToUnicode(GooString *tag);
126
127  // Insert <ctu> into the cache, in the most-recently-used position.
128  void add(CharCodeToUnicode *ctu);
129
130private:
131
132  CharCodeToUnicode **cache;
133  int size;
134};
135
136#endif
Note: See TracBrowser for help on using the repository browser.