1 //========================================================================
5 // Copyright 1996-2007 Glyph & Cog, LLC
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 //========================================================================
38 #ifdef USE_GCC_PRAGMAS
42 #include "poppler-config.h"
44 #include "goo/GooMutex.h"
59 class ViewerPreferences
;
63 //------------------------------------------------------------------------
65 //------------------------------------------------------------------------
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
);
80 Entry(Array
*array
, int index
);
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
);
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 //------------------------------------------------------------------------
102 //------------------------------------------------------------------------
108 Catalog(PDFDoc
*docA
);
114 GBool
isOk() { return ok
; }
116 // Get number of pages.
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
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.
137 markInfoNull
= 1 << 0,
138 markInfoMarked
= 1 << 1,
139 markInfoUserProperties
= 1 << 2,
140 markInfoSuspects
= 1 << 3,
144 // Find a page, given its object ID. Returns page number, or 0 if
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
);
154 // Get the number of named destinations in name-dict
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
; }
202 FormType
getFormType();
205 ViewerPreferences
*getViewerPreferences();
218 pageLayoutSinglePage
,
220 pageLayoutTwoColumnLeft
,
221 pageLayoutTwoColumnRight
,
222 pageLayoutTwoPageLeft
,
223 pageLayoutTwoPageRight
,
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
);
243 // Get page label info.
244 PageLabelInfo
*getPageLabelInfo();
247 XRef
*xref
; // the xref table for this PDF file
248 Page
**pages
; // array of pages
249 Ref
*pageRefs
; // object ID for each page
251 std::vector
<Dict
*> *pagesList
;
252 std::vector
<Ref
> *pagesRefList
;
253 std::vector
<PageAttrs
*> *attrsList
;
254 std::vector
<int> *kidsIdxList
;
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
);
282 NameTree
*getDestNameTree();
283 NameTree
*getEmbeddedFileNameTree();
284 NameTree
*getJSNameTree();
285 LinkDest
*createLinkDest(Object
*obj
);