source: trunk/poppler/mypoppler/poppler/Catalog.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: 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 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
121private:
122  GooString *m_name;
123  GooString *m_description;
124  int m_size;
125  GooString *m_createDate;
126  GooString *m_modDate;
127  GooString *m_checksum;
128  GooString *m_mimetype;
129  Object m_objStr;
130};
131
132//------------------------------------------------------------------------
133// Catalog
134//------------------------------------------------------------------------
135
136class Catalog {
137public:
138
139  // Constructor.
140  Catalog(XRef *xrefA);
141
142  // Destructor.
143  ~Catalog();
144
145  // Is catalog valid?
146  GBool isOk() { return ok; }
147
148  // Get number of pages.
149  int getNumPages() { return numPages; }
150
151  // Get a page.
152  Page *getPage(int i) { return pages[i-1]; }
153
154  // Get the reference for a page object.
155  Ref *getPageRef(int i) { return &pageRefs[i-1]; }
156
157  // Return base URI, or NULL if none.
158  GooString *getBaseURI() { return baseURI; }
159
160  // Return the contents of the metadata stream, or NULL if there is
161  // no metadata.
162  GooString *readMetadata();
163
164  // Return the structure tree root object.
165  Object *getStructTreeRoot() { return &structTreeRoot; }
166
167  // Find a page, given its object ID.  Returns page number, or 0 if
168  // not found.
169  int findPage(int num, int gen);
170
171  // Find a named destination.  Returns the link destination, or
172  // NULL if <name> is not a destination.
173  LinkDest *findDest(GooString *name);
174
175  Object *getDests() { return &dests; }
176
177  // Get the number of embedded files
178  int numEmbeddedFiles() { return embeddedFileNameTree.numEntries(); }
179
180  // Get the i'th file embedded (at the Document level) in the document
181  EmbFile *embeddedFile(int i);
182
183  // Get the number of javascript scripts
184  int numJS() { return jsNameTree.numEntries(); }
185
186  // Get the i'th JavaScript script (at the Document level) in the document
187  GooString *getJS(int i);
188
189  // Convert between page indices and page labels.
190  GBool labelToIndex(GooString *label, int *index);
191  GBool indexToLabel(int index, GooString *label);
192
193  Object *getOutline() { return &outline; }
194
195  Object *getAcroForm() { return &acroForm; }
196
197  OCGs *getOptContentConfig() { return optContent; }
198
199  Form* getForm() { return form; }
200
201  enum PageMode {
202    pageModeNone,
203    pageModeOutlines,
204    pageModeThumbs,
205    pageModeFullScreen,
206    pageModeOC,
207    pageModeAttach
208  };
209  enum PageLayout {
210    pageLayoutNone,
211    pageLayoutSinglePage,
212    pageLayoutOneColumn,
213    pageLayoutTwoColumnLeft,
214    pageLayoutTwoColumnRight,
215    pageLayoutTwoPageLeft,
216    pageLayoutTwoPageRight
217  };
218
219  // Returns the page mode.
220  PageMode getPageMode() { return pageMode; }
221  PageLayout getPageLayout() { return pageLayout; }
222
223private:
224
225  XRef *xref;                   // the xref table for this PDF file
226  Page **pages;                 // array of pages
227  Ref *pageRefs;                // object ID for each page
228  Form *form;
229  int numPages;                 // number of pages
230  int pagesSize;                // size of pages array
231  Object dests;                 // named destination dictionary
232  NameTree destNameTree;        // named destination name-tree
233  NameTree embeddedFileNameTree;  // embedded file name-tree
234  NameTree jsNameTree;          // Java Script name-tree
235  GooString *baseURI;           // base URI for URI-type links
236  Object metadata;              // metadata stream
237  Object structTreeRoot;        // structure tree root dictionary
238  Object outline;               // outline dictionary
239  Object acroForm;              // AcroForm dictionary
240  OCGs *optContent;             // Optional Content groups
241  GBool ok;                     // true if catalog is valid
242  PageLabelInfo *pageLabelInfo; // info about page labels
243  PageMode pageMode;            // page mode
244  PageLayout pageLayout;        // page layout
245
246  int readPageTree(Dict *pages, PageAttrs *attrs, int start,
247                   char *alreadyRead);
248  Object *findDestInTree(Object *tree, GooString *name, Object *obj);
249};
250
251#endif
Note: See TracBrowser for help on using the repository browser.