~ubuntu-branches/ubuntu/saucy/emscripten/saucy-proposed

« back to all changes in this revision

Viewing changes to tests/poppler/poppler/CMap.h

  • Committer: Package Import Robot
  • Author(s): Sylvestre Ledru
  • Date: 2013-05-02 13:11:51 UTC
  • Revision ID: package-import@ubuntu.com-20130502131151-q8dvteqr1ef2x7xz
Tags: upstream-1.4.1~20130504~adb56cb
ImportĀ upstreamĀ versionĀ 1.4.1~20130504~adb56cb

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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
 
 
39
class GooString;
 
40
struct CMapVectorEntry;
 
41
class CMapCache;
 
42
class Stream;
 
43
 
 
44
//------------------------------------------------------------------------
 
45
 
 
46
class CMap {
 
47
public:
 
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
 
 
79
private:
 
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
 
 
107
class CMapCache {
 
108
public:
 
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
 
 
121
private:
 
122
 
 
123
  CMap *cache[cMapCacheSize];
 
124
};
 
125
 
 
126
#endif