beta-0.89.2
[luatex.git] / source / libs / poppler / poppler-src / poppler / Catalog.h
blobbc9ce20b0985ae23c09113ba70cba371f4c99051
1 //========================================================================
2 //
3 // Catalog.h
4 //
5 // Copyright 1996-2007 Glyph & Cog, LLC
6 //
7 //========================================================================
9 //========================================================================
11 // Modified under the Poppler project - http://poppler.freedesktop.org
13 // All changes made under the Poppler project to this file are licensed
14 // under GPL version 2 or later
16 // Copyright (C) 2005 Kristian Høgsberg <krh@redhat.com>
17 // Copyright (C) 2005, 2007, 2009-2011, 2013 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, 2011 Pino Toscano <pino@kde.org>
22 // Copyright (C) 2010 Hib Eris <hib@hiberis.nl>
23 // Copyright (C) 2012 Fabio D'Urso <fabiodurso@hotmail.it>
24 // Copyright (C) 2013 Thomas Freitag <Thomas.Freitag@alfa.de>
25 // Copyright (C) 2013 Adrian Perez de Castro <aperez@igalia.com>
26 // Copyright (C) 2013 Adrian Johnson <ajohnson@redneon.com>
27 // Copyright (C) 2013 José Aliste <jaliste@src.gnome.org>
29 // To see a description of the changes please see the Changelog file that
30 // came with your tarball or type make ChangeLog if you are building from git
32 //========================================================================
34 #ifndef CATALOG_H
35 #define CATALOG_H
37 #ifdef USE_GCC_PRAGMAS
38 #pragma interface
39 #endif
41 #include "poppler-config.h"
42 #include "Object.h"
43 #include "goo/GooMutex.h"
45 #include <vector>
47 class PDFDoc;
48 class XRef;
49 class Object;
50 class Page;
51 class PageAttrs;
52 struct Ref;
53 class LinkDest;
54 class LinkAction;
55 class PageLabelInfo;
56 class Form;
57 class OCGs;
58 class ViewerPreferences;
59 class FileSpec;
60 class StructTreeRoot;
62 //------------------------------------------------------------------------
63 // NameTree
64 //------------------------------------------------------------------------
66 class NameTree {
67 public:
68 NameTree();
69 ~NameTree();
70 void init(XRef *xref, Object *tree);
71 GBool lookup(GooString *name, Object *obj);
72 int numEntries() { return length; };
73 // iterator accessor, note it returns a shallow copy, do not free the object
74 Object getValue(int i);
75 GooString *getName(int i);
77 private:
78 struct Entry {
79 Entry(Array *array, int index);
80 ~Entry();
81 GooString name;
82 Object value;
83 void free();
84 static int cmpEntry(const void *voidEntry, const void *voidOtherEntry);
85 static int cmp(const void *key, const void *entry);
88 void parse(Object *tree);
89 void addEntry(Entry *entry);
91 XRef *xref;
92 Object *root;
93 Entry **entries;
94 int size, length; // size is the number of entries in
95 // the array of Entry*
96 // length is the number of real Entry
99 //------------------------------------------------------------------------
100 // Catalog
101 //------------------------------------------------------------------------
103 class Catalog {
104 public:
106 // Constructor.
107 Catalog(PDFDoc *docA);
109 // Destructor.
110 ~Catalog();
112 // Is catalog valid?
113 GBool isOk() { return ok; }
115 // Get number of pages.
116 int getNumPages();
118 // Get a page.
119 Page *getPage(int i);
121 // Get the reference for a page object.
122 Ref *getPageRef(int i);
124 // Return base URI, or NULL if none.
125 GooString *getBaseURI() { return baseURI; }
127 // Return the contents of the metadata stream, or NULL if there is
128 // no metadata.
129 GooString *readMetadata();
131 // Return the structure tree root object.
132 StructTreeRoot *getStructTreeRoot();
134 // Return values from the MarkInfo dictionary as flags in a bitfield.
135 enum MarkInfoFlags {
136 markInfoNull = 1 << 0,
137 markInfoMarked = 1 << 1,
138 markInfoUserProperties = 1 << 2,
139 markInfoSuspects = 1 << 3,
141 Guint getMarkInfo();
143 // Find a page, given its object ID. Returns page number, or 0 if
144 // not found.
145 int findPage(int num, int gen);
147 // Find a named destination. Returns the link destination, or
148 // NULL if <name> is not a destination.
149 LinkDest *findDest(GooString *name);
151 Object *getDests();
153 // Get the number of embedded files
154 int numEmbeddedFiles() { return getEmbeddedFileNameTree()->numEntries(); }
156 // Get the i'th file embedded (at the Document level) in the document
157 FileSpec *embeddedFile(int i);
159 // Get the number of javascript scripts
160 int numJS() { return getJSNameTree()->numEntries(); }
161 GooString *getJSName(int i) { return getJSNameTree()->getName(i); }
163 // Get the i'th JavaScript script (at the Document level) in the document
164 GooString *getJS(int i);
166 // Convert between page indices and page labels.
167 GBool labelToIndex(GooString *label, int *index);
168 GBool indexToLabel(int index, GooString *label);
170 Object *getOutline();
172 Object *getAcroForm() { return &acroForm; }
174 OCGs *getOptContentConfig() { return optContent; }
176 enum FormType
178 NoForm,
179 AcroForm,
180 XfaForm
183 FormType getFormType();
184 Form* getForm();
186 ViewerPreferences *getViewerPreferences();
188 enum PageMode {
189 pageModeNone,
190 pageModeOutlines,
191 pageModeThumbs,
192 pageModeFullScreen,
193 pageModeOC,
194 pageModeAttach,
195 pageModeNull
197 enum PageLayout {
198 pageLayoutNone,
199 pageLayoutSinglePage,
200 pageLayoutOneColumn,
201 pageLayoutTwoColumnLeft,
202 pageLayoutTwoColumnRight,
203 pageLayoutTwoPageLeft,
204 pageLayoutTwoPageRight,
205 pageLayoutNull
208 // Returns the page mode.
209 PageMode getPageMode();
210 PageLayout getPageLayout();
212 enum DocumentAdditionalActionsType {
213 actionCloseDocument, ///< Performed before closing the document
214 actionSaveDocumentStart, ///< Performed before saving the document
215 actionSaveDocumentFinish, ///< Performed after saving the document
216 actionPrintDocumentStart, ///< Performed before printing the document
217 actionPrintDocumentFinish, ///< Performed after printing the document
220 LinkAction *getAdditionalAction(DocumentAdditionalActionsType type);
222 private:
224 // Get page label info.
225 PageLabelInfo *getPageLabelInfo();
227 PDFDoc *doc;
228 XRef *xref; // the xref table for this PDF file
229 Page **pages; // array of pages
230 Ref *pageRefs; // object ID for each page
231 int lastCachedPage;
232 std::vector<Dict *> *pagesList;
233 std::vector<Ref> *pagesRefList;
234 std::vector<PageAttrs *> *attrsList;
235 std::vector<int> *kidsIdxList;
236 Form *form;
237 ViewerPreferences *viewerPrefs;
238 int numPages; // number of pages
239 int pagesSize; // size of pages array
240 Object dests; // named destination dictionary
241 Object names; // named names dictionary
242 NameTree *destNameTree; // named destination name-tree
243 NameTree *embeddedFileNameTree; // embedded file name-tree
244 NameTree *jsNameTree; // Java Script name-tree
245 GooString *baseURI; // base URI for URI-type links
246 Object metadata; // metadata stream
247 StructTreeRoot *structTreeRoot; // structure tree root
248 Guint markInfo; // Flags from MarkInfo dictionary
249 Object outline; // outline dictionary
250 Object acroForm; // AcroForm dictionary
251 Object viewerPreferences; // ViewerPreference dictionary
252 OCGs *optContent; // Optional Content groups
253 GBool ok; // true if catalog is valid
254 PageLabelInfo *pageLabelInfo; // info about page labels
255 PageMode pageMode; // page mode
256 PageLayout pageLayout; // page layout
257 Object additionalActions; // page additional actions
259 GBool cachePageTree(int page); // Cache first <page> pages.
260 Object *findDestInTree(Object *tree, GooString *name, Object *obj);
262 Object *getNames();
263 NameTree *getDestNameTree();
264 NameTree *getEmbeddedFileNameTree();
265 NameTree *getJSNameTree();
266 #if MULTITHREADED
267 GooMutex mutex;
268 #endif
272 #endif