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

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

PDF plugin: Poppler library updated to version 0.12.3

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