00001 //======================================================================== 00002 // 00003 // Catalog.h 00004 // 00005 // Copyright 1996-2002 Glyph & Cog, LLC 00006 // 00007 //======================================================================== 00008 00009 #ifndef CATALOG_H 00010 #define CATALOG_H 00011 00012 #ifdef __GNUC__ 00013 #pragma interface 00014 #endif 00015 00016 class XRef; 00017 class Object; 00018 class Page; 00019 class PageAttrs; 00020 struct Ref; 00021 class LinkDest; 00022 00023 //------------------------------------------------------------------------ 00024 // Catalog 00025 //------------------------------------------------------------------------ 00026 00027 class Catalog { 00028 public: 00029 00030 // Constructor. 00031 Catalog(XRef *xrefA, GBool printCommands = gFalse); 00032 00033 // Destructor. 00034 ~Catalog(); 00035 00036 // Is catalog valid? 00037 GBool isOk() { return ok; } 00038 00039 // Get number of pages. 00040 int getNumPages() { return numPages; } 00041 00042 // Get a page. 00043 Page *getPage(int i) { return pages[i-1]; } 00044 00045 // Get the reference for a page object. 00046 Ref *getPageRef(int i) { return &pageRefs[i-1]; } 00047 00048 // Return base URI, or NULL if none. 00049 GString *getBaseURI() { return baseURI; } 00050 00051 // Return the contents of the metadata stream, or NULL if there is 00052 // no metadata. 00053 GString *readMetadata(); 00054 00055 // Return the structure tree root object. 00056 Object *getStructTreeRoot() { return &structTreeRoot; } 00057 00058 // Find a page, given its object ID. Returns page number, or 0 if 00059 // not found. 00060 int findPage(int num, int gen); 00061 00062 // Find a named destination. Returns the link destination, or 00063 // NULL if <name> is not a destination. 00064 LinkDest *findDest(GString *name); 00065 00066 private: 00067 00068 XRef *xref; // the xref table for this PDF file 00069 Page **pages; // array of pages 00070 Ref *pageRefs; // object ID for each page 00071 int numPages; // number of pages 00072 int pagesSize; // size of pages array 00073 Object dests; // named destination dictionary 00074 Object nameTree; // name tree 00075 GString *baseURI; // base URI for URI-type links 00076 Object metadata; // metadata stream 00077 Object structTreeRoot; // structure tree root dictionary 00078 GBool ok; // true if catalog is valid 00079 00080 int readPageTree(Dict *pages, PageAttrs *attrs, int start, 00081 GBool printCommands); 00082 Object *findDestInTree(Object *tree, GString *name, Object *obj); 00083 }; 00084 00085 #endif
1.4.2