source: trunk/poppler/mypoppler/poppler/Catalog.h @ 2

Last change on this file since 2 was 2, checked in by Eugene Romanenko, 15 years ago

First import

File size: 5.0 KB
Line 
1//========================================================================
2//
3// Catalog.h
4//
5// Copyright 1996-2003 Glyph & Cog, LLC
6//
7//========================================================================
8
9#ifndef CATALOG_H
10#define CATALOG_H
11
12#ifdef USE_GCC_PRAGMAS
13#pragma interface
14#endif
15
16class XRef;
17class Object;
18class Page;
19class PageAttrs;
20struct Ref;
21class LinkDest;
22class UGooString;
23class PageLabelInfo;
24
25//------------------------------------------------------------------------
26// NameTree
27//------------------------------------------------------------------------
28
29class NameTree {
30public:
31  NameTree();
32  void init(XRef *xref, Object *tree);
33  void parse(Object *tree);
34  GBool lookup(UGooString *name, Object *obj);
35  void free();
36  int numEntries() { return length; };
37  // iterator accessor
38  Object getValue(int i);
39  UGooString *getName(int i);
40
41private:
42  struct Entry {
43    Entry(Array *array, int index);
44    ~Entry();
45    UGooString *name;
46    Object value;
47    void free();
48    static int cmp(const void *key, const void *entry);
49  };
50
51  void addEntry(Entry *entry);
52
53  XRef *xref;
54  Object *root;
55  Entry **entries;
56  int size, length; // size is the number of entries in
57                    // the array of Entry*
58                    // length is the number of real Entry
59};
60
61class EmbFile {
62public:
63  EmbFile(GooString *name, GooString *description, 
64          GooString *createDate,
65          GooString *modDate, Object objStr) :
66    m_name(name),
67    m_description(description),
68    m_createDate(createDate),
69    m_modDate(modDate)
70  {
71    objStr.copy(&m_objStr);
72  }
73
74  ~EmbFile()
75  {
76    delete m_name;
77    delete m_description;
78    delete m_modDate;
79    delete m_createDate;
80    m_objStr.free();
81  }
82
83  GooString *name() { return m_name; }
84  GooString *description() { return m_description; }
85  GooString *modDate() { return m_modDate; }
86  GooString *createDate() { return m_createDate; }
87  Object &streamObject() { return m_objStr; }
88
89private:
90  GooString *m_name;
91  GooString *m_description;
92  GooString *m_createDate;
93  GooString *m_modDate;
94  Object m_objStr;
95};
96
97//------------------------------------------------------------------------
98// Catalog
99//------------------------------------------------------------------------
100
101class Catalog {
102public:
103
104  // Constructor.
105  Catalog(XRef *xrefA);
106
107  // Destructor.
108  ~Catalog();
109
110  // Is catalog valid?
111  GBool isOk() { return ok; }
112
113  // Get number of pages.
114  int getNumPages() { return numPages; }
115
116  // Get a page.
117  Page *getPage(int i) { return pages[i-1]; }
118
119  // Get the reference for a page object.
120  Ref *getPageRef(int i) { return &pageRefs[i-1]; }
121
122  // Return base URI, or NULL if none.
123  GooString *getBaseURI() { return baseURI; }
124
125  // Return the contents of the metadata stream, or NULL if there is
126  // no metadata.
127  GooString *readMetadata();
128
129  // Return the structure tree root object.
130  Object *getStructTreeRoot() { return &structTreeRoot; }
131
132  // Find a page, given its object ID.  Returns page number, or 0 if
133  // not found.
134  int findPage(int num, int gen);
135
136  // Find a named destination.  Returns the link destination, or
137  // NULL if <name> is not a destination.
138  LinkDest *findDest(UGooString *name);
139
140  // Get the number of embedded files
141  int numEmbeddedFiles() { return embeddedFileNameTree.numEntries(); }
142
143  // Get the i'th file embedded (at the Document level) in the document
144  EmbFile *embeddedFile(int i);
145
146  // Convert between page indices and page labels.
147  GBool labelToIndex(GooString *label, int *index);
148  GBool indexToLabel(int index, GooString *label);
149
150  Object *getOutline() { return &outline; }
151
152  Object *getAcroForm() { return &acroForm; }
153
154  enum PageMode {
155    pageModeNone,
156    pageModeOutlines,
157    pageModeThumbs,
158    pageModeFullScreen,
159    pageModeOC,
160    pageModeAttach
161  };
162  enum PageLayout {
163    pageLayoutNone,
164    pageLayoutSinglePage,
165    pageLayoutOneColumn,
166    pageLayoutTwoColumnLeft,
167    pageLayoutTwoColumnRight,
168    pageLayoutTwoPageLeft,
169    pageLayoutTwoPageRight,
170  };
171
172  // Returns the page mode.
173  PageMode getPageMode() { return pageMode; }
174  PageLayout getPageLayout() { return pageLayout; }
175
176private:
177
178  XRef *xref;                   // the xref table for this PDF file
179  Page **pages;                 // array of pages
180  Ref *pageRefs;                // object ID for each page
181  int numPages;                 // number of pages
182  int pagesSize;                // size of pages array
183  Object dests;                 // named destination dictionary
184  NameTree destNameTree;        // named destination name-tree
185  NameTree embeddedFileNameTree;  // embedded file name-tree
186  GooString *baseURI;           // base URI for URI-type links
187  Object metadata;              // metadata stream
188  Object structTreeRoot;        // structure tree root dictionary
189  Object outline;               // outline dictionary
190  Object acroForm;              // AcroForm dictionary
191  GBool ok;                     // true if catalog is valid
192  PageLabelInfo *pageLabelInfo; // info about page labels
193  PageMode pageMode;            // page mode
194  PageLayout pageLayout;        // page layout
195
196  int readPageTree(Dict *pages, PageAttrs *attrs, int start);
197  Object *findDestInTree(Object *tree, GooString *name, Object *obj);
198};
199
200#endif
Note: See TracBrowser for help on using the repository browser.