afad803fc88b689060dd4406f5a137d5897c85ee
[swftools.git] / pdf2swf / xpdf / Catalog.h
1 //========================================================================
2 //
3 // Catalog.h
4 //
5 // Copyright 1996-2002 Glyph & Cog, LLC
6 //
7 //========================================================================
8
9 #ifndef CATALOG_H
10 #define CATALOG_H
11
12 #ifdef __GNUC__
13 #pragma interface
14 #endif
15
16 class XRef;
17 class Object;
18 class Page;
19 class PageAttrs;
20 struct Ref;
21 class LinkDest;
22
23 //------------------------------------------------------------------------
24 // Catalog
25 //------------------------------------------------------------------------
26
27 class Catalog {
28 public:
29
30   // Constructor.
31   Catalog(XRef *xrefA, GBool printCommands = gFalse);
32
33   // Destructor.
34   ~Catalog();
35
36   // Is catalog valid?
37   GBool isOk() { return ok; }
38
39   // Get number of pages.
40   int getNumPages() { return numPages; }
41
42   // Get a page.
43   Page *getPage(int i) { return pages[i-1]; }
44
45   // Get the reference for a page object.
46   Ref *getPageRef(int i) { return &pageRefs[i-1]; }
47
48   // Return base URI, or NULL if none.
49   GString *getBaseURI() { return baseURI; }
50
51   // Return the contents of the metadata stream, or NULL if there is
52   // no metadata.
53   GString *readMetadata();
54
55   // Return the structure tree root object.
56   Object *getStructTreeRoot() { return &structTreeRoot; }
57
58   // Find a page, given its object ID.  Returns page number, or 0 if
59   // not found.
60   int findPage(int num, int gen);
61
62   // Find a named destination.  Returns the link destination, or
63   // NULL if <name> is not a destination.
64   LinkDest *findDest(GString *name);
65
66 private:
67
68   XRef *xref;                   // the xref table for this PDF file
69   Page **pages;                 // array of pages
70   Ref *pageRefs;                // object ID for each page
71   int numPages;                 // number of pages
72   int pagesSize;                // size of pages array
73   Object dests;                 // named destination dictionary
74   Object nameTree;              // name tree
75   GString *baseURI;             // base URI for URI-type links
76   Object metadata;              // metadata stream
77   Object structTreeRoot;        // structure tree root dictionary
78   GBool ok;                     // true if catalog is valid
79
80   int readPageTree(Dict *pages, PageAttrs *attrs, int start,
81                    GBool printCommands);
82   Object *findDestInTree(Object *tree, GString *name, Object *obj);
83 };
84
85 #endif