source: trunk/poppler/mypoppler/poppler/Catalog.h @ 250

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

PDF plugin: poppler library updated to version 0.8.3

File size: 5.5 KB
Line 
1//========================================================================
2//
3// Catalog.h
4//
5// Copyright 1996-2007 Glyph & Cog, LLC
6//
7//========================================================================
8
9#ifndef CATALOG_H
10#define CATALOG_H
11
12#ifdef USE_GCC_PRAGMAS
13#pragma interface
14#endif
15
16class XRef;
17class Object;
18class Page;
19class PageAttrs;
20struct Ref;
21class LinkDest;
22class PageLabelInfo;
23class Form;
24class OCGs;
25
26//------------------------------------------------------------------------
27// NameTree
28//------------------------------------------------------------------------
29
30class NameTree {
31public:
32  NameTree();
33  void init(XRef *xref, Object *tree);
34  void parse(Object *tree);
35  GBool lookup(GooString *name, Object *obj);
36  void free();
37  int numEntries() { return length; };
38  // iterator accessor
39  Object getValue(int i);
40  GooString *getName(int i);
41
42private:
43  struct Entry {
44    Entry(Array *array, int index);
45    ~Entry();
46    GooString name;
47    Object value;
48    void free();
49    static int cmp(const void *key, const void *entry);
50  };
51
52  void addEntry(Entry *entry);
53
54  XRef *xref;
55  Object *root;
56  Entry **entries;
57  int size, length; // size is the number of entries in
58                    // the array of Entry*
59                    // length is the number of real Entry
60};
61
62class EmbFile {
63public:
64  EmbFile(GooString *name, GooString *description, 
65          int size,
66          GooString *createDate,
67          GooString *modDate, GooString *checksum,
68          GooString *mimetype,
69          Object objStr) :
70    m_name(name),
71    m_description(description),
72    m_size(size),
73    m_createDate(createDate),
74    m_modDate(modDate),
75    m_checksum(checksum),
76    m_mimetype(mimetype)
77  {
78    objStr.copy(&m_objStr);
79  }
80
81  ~EmbFile()
82  {
83    delete m_name;
84    delete m_description;
85    delete m_modDate;
86    delete m_createDate;
87    delete m_checksum;
88    delete m_mimetype;
89    m_objStr.free();
90  }
91
92  GooString *name() { return m_name; }
93  GooString *description() { return m_description; }
94  int size() { return m_size; }
95  GooString *modDate() { return m_modDate; }
96  GooString *createDate() { return m_createDate; }
97  GooString *checksum() { return m_checksum; }
98  GooString *mimeType() { return m_mimetype; }
99  Object &streamObject() { return m_objStr; }
100
101private:
102  GooString *m_name;
103  GooString *m_description;
104  int m_size;
105  GooString *m_createDate;
106  GooString *m_modDate;
107  GooString *m_checksum;
108  GooString *m_mimetype;
109  Object m_objStr;
110};
111
112//------------------------------------------------------------------------
113// Catalog
114//------------------------------------------------------------------------
115
116class Catalog {
117public:
118
119  // Constructor.
120  Catalog(XRef *xrefA);
121
122  // Destructor.
123  ~Catalog();
124
125  // Is catalog valid?
126  GBool isOk() { return ok; }
127
128  // Get number of pages.
129  int getNumPages() { return numPages; }
130
131  // Get a page.
132  Page *getPage(int i) { return pages[i-1]; }
133
134  // Get the reference for a page object.
135  Ref *getPageRef(int i) { return &pageRefs[i-1]; }
136
137  // Return base URI, or NULL if none.
138  GooString *getBaseURI() { return baseURI; }
139
140  // Return the contents of the metadata stream, or NULL if there is
141  // no metadata.
142  GooString *readMetadata();
143
144  // Return the structure tree root object.
145  Object *getStructTreeRoot() { return &structTreeRoot; }
146
147  // Find a page, given its object ID.  Returns page number, or 0 if
148  // not found.
149  int findPage(int num, int gen);
150
151  // Find a named destination.  Returns the link destination, or
152  // NULL if <name> is not a destination.
153  LinkDest *findDest(GooString *name);
154
155  Object *getDests() { return &dests; }
156
157  // Get the number of embedded files
158  int numEmbeddedFiles() { return embeddedFileNameTree.numEntries(); }
159
160  // Get the i'th file embedded (at the Document level) in the document
161  EmbFile *embeddedFile(int i);
162
163  // Convert between page indices and page labels.
164  GBool labelToIndex(GooString *label, int *index);
165  GBool indexToLabel(int index, GooString *label);
166
167  Object *getOutline() { return &outline; }
168
169  Object *getAcroForm() { return &acroForm; }
170
171  OCGs *getOptContentConfig() { return optContent; }
172
173  Form* getForm() { return form; }
174
175  enum PageMode {
176    pageModeNone,
177    pageModeOutlines,
178    pageModeThumbs,
179    pageModeFullScreen,
180    pageModeOC,
181    pageModeAttach
182  };
183  enum PageLayout {
184    pageLayoutNone,
185    pageLayoutSinglePage,
186    pageLayoutOneColumn,
187    pageLayoutTwoColumnLeft,
188    pageLayoutTwoColumnRight,
189    pageLayoutTwoPageLeft,
190    pageLayoutTwoPageRight
191  };
192
193  // Returns the page mode.
194  PageMode getPageMode() { return pageMode; }
195  PageLayout getPageLayout() { return pageLayout; }
196
197private:
198
199  XRef *xref;                   // the xref table for this PDF file
200  Page **pages;                 // array of pages
201  Ref *pageRefs;                // object ID for each page
202  Form *form;
203  int numPages;                 // number of pages
204  int pagesSize;                // size of pages array
205  Object dests;                 // named destination dictionary
206  NameTree destNameTree;        // named destination name-tree
207  NameTree embeddedFileNameTree;  // embedded file name-tree
208  GooString *baseURI;           // base URI for URI-type links
209  Object metadata;              // metadata stream
210  Object structTreeRoot;        // structure tree root dictionary
211  Object outline;               // outline dictionary
212  Object acroForm;              // AcroForm dictionary
213  OCGs *optContent;             // Optional Content groups
214  GBool ok;                     // true if catalog is valid
215  PageLabelInfo *pageLabelInfo; // info about page labels
216  PageMode pageMode;            // page mode
217  PageLayout pageLayout;        // page layout
218
219  int readPageTree(Dict *pages, PageAttrs *attrs, int start,
220                   char *alreadyRead);
221  Object *findDestInTree(Object *tree, GooString *name, Object *obj);
222};
223
224#endif
Note: See TracBrowser for help on using the repository browser.