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>
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 //========================================================================
37 #ifdef USE_GCC_PRAGMAS
41 #include "poppler-config.h"
43 #include "goo/GooMutex.h"
58 class ViewerPreferences
;
62 //------------------------------------------------------------------------
64 //------------------------------------------------------------------------
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
);
79 Entry(Array
*array
, int index
);
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
);
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 //------------------------------------------------------------------------
101 //------------------------------------------------------------------------
107 Catalog(PDFDoc
*docA
);
113 GBool
isOk() { return ok
; }
115 // Get number of pages.
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
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.
136 markInfoNull
= 1 << 0,
137 markInfoMarked
= 1 << 1,
138 markInfoUserProperties
= 1 << 2,
139 markInfoSuspects
= 1 << 3,
143 // Find a page, given its object ID. Returns page number, or 0 if
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
);
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
; }
183 FormType
getFormType();
186 ViewerPreferences
*getViewerPreferences();
199 pageLayoutSinglePage
,
201 pageLayoutTwoColumnLeft
,
202 pageLayoutTwoColumnRight
,
203 pageLayoutTwoPageLeft
,
204 pageLayoutTwoPageRight
,
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
);
224 // Get page label info.
225 PageLabelInfo
*getPageLabelInfo();
228 XRef
*xref
; // the xref table for this PDF file
229 Page
**pages
; // array of pages
230 Ref
*pageRefs
; // object ID for each page
232 std::vector
<Dict
*> *pagesList
;
233 std::vector
<Ref
> *pagesRefList
;
234 std::vector
<PageAttrs
*> *attrsList
;
235 std::vector
<int> *kidsIdxList
;
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
);
263 NameTree
*getDestNameTree();
264 NameTree
*getEmbeddedFileNameTree();
265 NameTree
*getJSNameTree();