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

Last change on this file since 461 was 461, checked in by Silvan Scherrer, 11 years ago

poppler update to 0.14.2

File size: 6.9 KB
Line 
1//========================================================================
2//
3// Catalog.h
4//
5// Copyright 1996-2007 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) 2005 Kristian HÞgsberg <krh@redhat.com>
17// Copyright (C) 2005, 2007, 2009, 2010 Albert Astals Cid <aacid@kde.org>
18// Copyright (C) 2005 Jonathan Blandford <jrb@redhat.com>
19// Copyright (C) 2005, 2006, 2008 Brad Hards <bradh@frogmouth.net>
20// Copyright (C) 2007 Julien Rebetez <julienr@svn.gnome.org>
21// Copyright (C) 2008 Pino Toscano <pino@kde.org>
22// Copyright (C) 2010 Hib Eris <hib@hiberis.nl>
23//
24// To see a description of the changes please see the Changelog file that
25// came with your tarball or type make ChangeLog if you are building from git
26//
27//========================================================================
28
29#ifndef CATALOG_H
30#define CATALOG_H
31
32#ifdef USE_GCC_PRAGMAS
33#pragma interface
34#endif
35
36class XRef;
37class Object;
38class Page;
39class PageAttrs;
40struct Ref;
41class LinkDest;
42class PageLabelInfo;
43class Form;
44class OCGs;
45
46//------------------------------------------------------------------------
47// NameTree
48//------------------------------------------------------------------------
49
50class NameTree {
51public:
52  NameTree();
53  ~NameTree();
54  void init(XRef *xref, Object *tree);
55  void parse(Object *tree);
56  GBool lookup(GooString *name, Object *obj);
57  int numEntries() { return length; };
58  // iterator accessor
59  Object getValue(int i);
60  GooString *getName(int i);
61
62private:
63  struct Entry {
64    Entry(Array *array, int index);
65    ~Entry();
66    GooString name;
67    Object value;
68    void free();
69    static int cmp(const void *key, const void *entry);
70  };
71
72  void addEntry(Entry *entry);
73
74  XRef *xref;
75  Object *root;
76  Entry **entries;
77  int size, length; // size is the number of entries in
78                    // the array of Entry*
79                    // length is the number of real Entry
80};
81
82class EmbFile {
83public:
84  EmbFile(GooString *name, GooString *description, 
85          int size,
86          GooString *createDate,
87          GooString *modDate, GooString *checksum,
88          GooString *mimetype,
89          Object objStr) :
90    m_name(name),
91    m_description(description),
92    m_size(size),
93    m_createDate(createDate),
94    m_modDate(modDate),
95    m_checksum(checksum),
96    m_mimetype(mimetype)
97  {
98    objStr.copy(&m_objStr);
99  }
100  EmbFile(Object *efDict, GooString *description = 0);
101
102  ~EmbFile()
103  {
104    delete m_name;
105    delete m_description;
106    delete m_modDate;
107    delete m_createDate;
108    delete m_checksum;
109    delete m_mimetype;
110    m_objStr.free();
111  }
112
113  GooString *name() { return m_name; }
114  GooString *description() { return m_description; }
115  int size() { return m_size; }
116  GooString *modDate() { return m_modDate; }
117  GooString *createDate() { return m_createDate; }
118  GooString *checksum() { return m_checksum; }
119  GooString *mimeType() { return m_mimetype; }
120  Object &streamObject() { return m_objStr; }
121  bool isOk() { return m_objStr.isStream(); }
122
123private:
124  GooString *m_name;
125  GooString *m_description;
126  int m_size;
127  GooString *m_createDate;
128  GooString *m_modDate;
129  GooString *m_checksum;
130  GooString *m_mimetype;
131  Object m_objStr;
132};
133
134//------------------------------------------------------------------------
135// Catalog
136//------------------------------------------------------------------------
137
138class Catalog {
139public:
140
141  // Constructor.
142  Catalog(XRef *xrefA);
143
144  // Destructor.
145  ~Catalog();
146
147  // Is catalog valid?
148  GBool isOk() { return ok; }
149
150  // Get number of pages.
151  int getNumPages() { return numPages; }
152
153  // Get a page.
154  Page *getPage(int i) { return pages[i-1]; }
155
156  // Get the reference for a page object.
157  Ref *getPageRef(int i) { return &pageRefs[i-1]; }
158
159  // Return base URI, or NULL if none.
160  GooString *getBaseURI() { return baseURI; }
161
162  // Return the contents of the metadata stream, or NULL if there is
163  // no metadata.
164  GooString *readMetadata();
165
166  // Return the structure tree root object.
167  Object *getStructTreeRoot();
168
169  // Find a page, given its object ID.  Returns page number, or 0 if
170  // not found.
171  int findPage(int num, int gen);
172
173  // Find a named destination.  Returns the link destination, or
174  // NULL if <name> is not a destination.
175  LinkDest *findDest(GooString *name);
176
177  Object *getDests();
178
179  // Get the number of embedded files
180  int numEmbeddedFiles() { return getEmbeddedFileNameTree()->numEntries(); }
181
182  // Get the i'th file embedded (at the Document level) in the document
183  EmbFile *embeddedFile(int i);
184
185  // Get the number of javascript scripts
186  int numJS() { return getJSNameTree()->numEntries(); }
187
188  // Get the i'th JavaScript script (at the Document level) in the document
189  GooString *getJS(int i);
190
191  // Convert between page indices and page labels.
192  GBool labelToIndex(GooString *label, int *index);
193  GBool indexToLabel(int index, GooString *label);
194
195  Object *getOutline();
196
197  Object *getAcroForm() { return &acroForm; }
198
199  OCGs *getOptContentConfig() { return optContent; }
200
201  Form* getForm();
202
203  enum PageMode {
204    pageModeNone,
205    pageModeOutlines,
206    pageModeThumbs,
207    pageModeFullScreen,
208    pageModeOC,
209    pageModeAttach,
210    pageModeNull
211  };
212  enum PageLayout {
213    pageLayoutNone,
214    pageLayoutSinglePage,
215    pageLayoutOneColumn,
216    pageLayoutTwoColumnLeft,
217    pageLayoutTwoColumnRight,
218    pageLayoutTwoPageLeft,
219    pageLayoutTwoPageRight,
220    pageLayoutNull
221  };
222
223  // Returns the page mode.
224  PageMode getPageMode();
225  PageLayout getPageLayout();
226
227private:
228
229  // Get page label info.
230  PageLabelInfo *getPageLabelInfo();
231
232  XRef *xref;                   // the xref table for this PDF file
233  Page **pages;                 // array of pages
234  Ref *pageRefs;                // object ID for each page
235  Form *form;
236  int numPages;                 // number of pages
237  int pagesSize;                // size of pages array
238  Object dests;                 // named destination dictionary
239  Object names;                 // named names dictionary
240  NameTree *destNameTree;       // named destination name-tree
241  NameTree *embeddedFileNameTree;  // embedded file name-tree
242  NameTree *jsNameTree;         // Java Script name-tree
243  GooString *baseURI;           // base URI for URI-type links
244  Object metadata;              // metadata stream
245  Object structTreeRoot;        // structure tree root dictionary
246  Object outline;               // outline dictionary
247  Object acroForm;              // AcroForm dictionary
248  OCGs *optContent;             // Optional Content groups
249  GBool ok;                     // true if catalog is valid
250  PageLabelInfo *pageLabelInfo; // info about page labels
251  PageMode pageMode;            // page mode
252  PageLayout pageLayout;        // page layout
253
254  int readPageTree(Dict *pages, PageAttrs *attrs, int start,
255                   char *alreadyRead);
256  Object *findDestInTree(Object *tree, GooString *name, Object *obj);
257
258  Object *getNames();
259  NameTree *getDestNameTree();
260  NameTree *getEmbeddedFileNameTree();
261  NameTree *getJSNameTree();
262
263};
264
265#endif
Note: See TracBrowser for help on using the repository browser.