fix getsup (HH)
[luatex.git] / source / libs / poppler / poppler-src / poppler / Catalog.h
blob81b0e125c6d6bbac6e4b784cd210b815aaa99b80
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>
28 // Copyright (C) 2016 Masamichi Hosoda <trueroad@trueroad.jp>
30 // To see a description of the changes please see the Changelog file that
31 // came with your tarball or type make ChangeLog if you are building from git
33 //========================================================================
35 #ifndef CATALOG_H
36 #define CATALOG_H
38 #ifdef USE_GCC_PRAGMAS
39 #pragma interface
40 #endif
42 #include "poppler-config.h"
43 #include "Object.h"
44 #include "goo/GooMutex.h"
46 #include <vector>
48 class PDFDoc;
49 class XRef;
50 class Object;
51 class Page;
52 class PageAttrs;
53 struct Ref;
54 class LinkDest;
55 class LinkAction;
56 class PageLabelInfo;
57 class Form;
58 class OCGs;
59 class ViewerPreferences;
60 class FileSpec;
61 class StructTreeRoot;
63 //------------------------------------------------------------------------
64 // NameTree
65 //------------------------------------------------------------------------
67 class NameTree {
68 public:
69 NameTree();
70 ~NameTree();
71 void init(XRef *xref, Object *tree);
72 GBool lookup(GooString *name, Object *obj);
73 int numEntries() { return length; };
74 // iterator accessor, note it returns a shallow copy, do not free the object
75 Object getValue(int i);
76 GooString *getName(int i);
78 private:
79 struct Entry {
80 Entry(Array *array, int index);
81 ~Entry();
82 GooString name;
83 Object value;
84 void free();
85 static int cmpEntry(const void *voidEntry, const void *voidOtherEntry);
86 static int cmp(const void *key, const void *entry);
89 void parse(Object *tree);
90 void addEntry(Entry *entry);
92 XRef *xref;
93 Object *root;
94 Entry **entries;
95 int size, length; // size is the number of entries in
96 // the array of Entry*
97 // length is the number of real Entry
100 //------------------------------------------------------------------------
101 // Catalog
102 //------------------------------------------------------------------------
104 class Catalog {
105 public:
107 // Constructor.
108 Catalog(PDFDoc *docA);
110 // Destructor.
111 ~Catalog();
113 // Is catalog valid?
114 GBool isOk() { return ok; }
116 // Get number of pages.
117 int getNumPages();
119 // Get a page.
120 Page *getPage(int i);
122 // Get the reference for a page object.
123 Ref *getPageRef(int i);
125 // Return base URI, or NULL if none.
126 GooString *getBaseURI() { return baseURI; }
128 // Return the contents of the metadata stream, or NULL if there is
129 // no metadata.
130 GooString *readMetadata();
132 // Return the structure tree root object.
133 StructTreeRoot *getStructTreeRoot();
135 // Return values from the MarkInfo dictionary as flags in a bitfield.
136 enum MarkInfoFlags {
137 markInfoNull = 1 << 0,
138 markInfoMarked = 1 << 1,
139 markInfoUserProperties = 1 << 2,
140 markInfoSuspects = 1 << 3,
142 Guint getMarkInfo();
144 // Find a page, given its object ID. Returns page number, or 0 if
145 // not found.
146 int findPage(int num, int gen);
148 // Find a named destination. Returns the link destination, or
149 // NULL if <name> is not a destination.
150 LinkDest *findDest(GooString *name);
152 Object *getDests();
154 // Get the number of named destinations in name-dict
155 int numDests();
157 // Get the i'th named destination name in name-dict
158 char *getDestsName(int i);
160 // Get the i'th named destination link destination in name-dict
161 LinkDest *getDestsDest(int i);
163 // Get the number of named destinations in name-tree
164 int numDestNameTree() { return getDestNameTree()->numEntries(); }
166 // Get the i'th named destination name in name-tree
167 GooString *getDestNameTreeName(int i) { return getDestNameTree()->getName(i); }
169 // Get the i'th named destination link destination in name-tree
170 LinkDest *getDestNameTreeDest(int i);
172 // Get the number of embedded files
173 int numEmbeddedFiles() { return getEmbeddedFileNameTree()->numEntries(); }
175 // Get the i'th file embedded (at the Document level) in the document
176 FileSpec *embeddedFile(int i);
178 // Get the number of javascript scripts
179 int numJS() { return getJSNameTree()->numEntries(); }
180 GooString *getJSName(int i) { return getJSNameTree()->getName(i); }
182 // Get the i'th JavaScript script (at the Document level) in the document
183 GooString *getJS(int i);
185 // Convert between page indices and page labels.
186 GBool labelToIndex(GooString *label, int *index);
187 GBool indexToLabel(int index, GooString *label);
189 Object *getOutline();
191 Object *getAcroForm() { return &acroForm; }
193 OCGs *getOptContentConfig() { return optContent; }
195 enum FormType
197 NoForm,
198 AcroForm,
199 XfaForm
202 FormType getFormType();
203 Form* getForm();
205 ViewerPreferences *getViewerPreferences();
207 enum PageMode {
208 pageModeNone,
209 pageModeOutlines,
210 pageModeThumbs,
211 pageModeFullScreen,
212 pageModeOC,
213 pageModeAttach,
214 pageModeNull
216 enum PageLayout {
217 pageLayoutNone,
218 pageLayoutSinglePage,
219 pageLayoutOneColumn,
220 pageLayoutTwoColumnLeft,
221 pageLayoutTwoColumnRight,
222 pageLayoutTwoPageLeft,
223 pageLayoutTwoPageRight,
224 pageLayoutNull
227 // Returns the page mode.
228 PageMode getPageMode();
229 PageLayout getPageLayout();
231 enum DocumentAdditionalActionsType {
232 actionCloseDocument, ///< Performed before closing the document
233 actionSaveDocumentStart, ///< Performed before saving the document
234 actionSaveDocumentFinish, ///< Performed after saving the document
235 actionPrintDocumentStart, ///< Performed before printing the document
236 actionPrintDocumentFinish, ///< Performed after printing the document
239 LinkAction *getAdditionalAction(DocumentAdditionalActionsType type);
241 private:
243 // Get page label info.
244 PageLabelInfo *getPageLabelInfo();
246 PDFDoc *doc;
247 XRef *xref; // the xref table for this PDF file
248 Page **pages; // array of pages
249 Ref *pageRefs; // object ID for each page
250 int lastCachedPage;
251 std::vector<Dict *> *pagesList;
252 std::vector<Ref> *pagesRefList;
253 std::vector<PageAttrs *> *attrsList;
254 std::vector<int> *kidsIdxList;
255 Form *form;
256 ViewerPreferences *viewerPrefs;
257 int numPages; // number of pages
258 int pagesSize; // size of pages array
259 Object dests; // named destination dictionary
260 Object names; // named names dictionary
261 NameTree *destNameTree; // named destination name-tree
262 NameTree *embeddedFileNameTree; // embedded file name-tree
263 NameTree *jsNameTree; // Java Script name-tree
264 GooString *baseURI; // base URI for URI-type links
265 Object metadata; // metadata stream
266 StructTreeRoot *structTreeRoot; // structure tree root
267 Guint markInfo; // Flags from MarkInfo dictionary
268 Object outline; // outline dictionary
269 Object acroForm; // AcroForm dictionary
270 Object viewerPreferences; // ViewerPreference dictionary
271 OCGs *optContent; // Optional Content groups
272 GBool ok; // true if catalog is valid
273 PageLabelInfo *pageLabelInfo; // info about page labels
274 PageMode pageMode; // page mode
275 PageLayout pageLayout; // page layout
276 Object additionalActions; // page additional actions
278 GBool cachePageTree(int page); // Cache first <page> pages.
279 Object *findDestInTree(Object *tree, GooString *name, Object *obj);
281 Object *getNames();
282 NameTree *getDestNameTree();
283 NameTree *getEmbeddedFileNameTree();
284 NameTree *getJSNameTree();
285 LinkDest *createLinkDest(Object *obj);
286 #if MULTITHREADED
287 GooMutex mutex;
288 #endif
292 #endif