Coverage Report

Created: 2025-07-11 07:47

/src/xpdf-4.05/xpdf/Catalog.h
Line
Count
Source (jump to first uncovered line)
1
//========================================================================
2
//
3
// Catalog.h
4
//
5
// Copyright 1996-2007 Glyph & Cog, LLC
6
//
7
//========================================================================
8
9
#ifndef CATALOG_H
10
#define CATALOG_H
11
12
#include <aconf.h>
13
14
#if MULTITHREADED
15
#include "GMutex.h"
16
#endif
17
#include "CharTypes.h"
18
19
class GList;
20
class PDFDoc;
21
class XRef;
22
class Object;
23
class Page;
24
class PageAttrs;
25
struct Ref;
26
class LinkDest;
27
class PageTreeNode;
28
class PageLabelNode;
29
class AcroForm;
30
class TextString;
31
32
//------------------------------------------------------------------------
33
// Catalog
34
//------------------------------------------------------------------------
35
36
class Catalog {
37
public:
38
39
  // Constructor.
40
  Catalog(PDFDoc *docA);
41
42
  // Destructor.
43
  ~Catalog();
44
45
  // Is catalog valid?
46
1.43k
  GBool isOk() { return ok; }
47
48
  // Get number of pages.
49
98.4k
  int getNumPages() { return numPages; }
50
51
  // Get a page.
52
  Page *getPage(int i);
53
54
  // Get the reference for a page object.
55
  Ref *getPageRef(int i);
56
57
  // Remove a page from the catalog.  (It can be reloaded later by
58
  // calling getPage).
59
  void doneWithPage(int i);
60
61
  // Return base URI, or NULL if none.
62
0
  GString *getBaseURI() { return baseURI; }
63
64
  // Return the contents of the metadata stream, or NULL if there is
65
  // no metadata.
66
  GString *readMetadata();
67
68
  // Return the structure tree root object.
69
0
  Object *getStructTreeRoot() { return &structTreeRoot; }
70
71
  // Find a page, given its object ID.  Returns page number, or 0 if
72
  // not found.
73
  int findPage(int num, int gen);
74
75
  // Find a named destination.  Returns the link destination, or
76
  // NULL if <name> is not a destination.
77
  LinkDest *findDest(GString *name);
78
79
0
  Object *getDests() { return &dests; }
80
81
0
  Object *getNameTree() { return &nameTree; }
82
83
1.24k
  Object *getOutline() { return &outline; }
84
85
0
  Object *getAcroForm() { return &acroForm; }
86
87
0
  AcroForm *getForm() { return form; }
88
89
566
  GBool getNeedsRendering() { return needsRendering; }
90
91
1.24k
  Object *getOCProperties() { return &ocProperties; }
92
93
  // Return the DestOutputProfile stream, or NULL if there isn't one.
94
  Object *getDestOutputProfile(Object *destOutProf);
95
96
  // Get the list of embedded files.
97
  int getNumEmbeddedFiles();
98
  Unicode *getEmbeddedFileName(int idx);
99
  int getEmbeddedFileNameLength(int idx);
100
  Object *getEmbeddedFileStreamRef(int idx);
101
  Object *getEmbeddedFileStreamObj(int idx, Object *strObj);
102
103
  // Return true if the document has page labels.
104
0
  GBool hasPageLabels() { return pageLabels != NULL; }
105
106
  // Get the page label for page number [pageNum].  Returns NULL if
107
  // the PDF file doesn't have page labels.
108
  TextString *getPageLabel(int pageNum);
109
110
  // Returns the page number corresponding to [pageLabel].  Returns -1
111
  // if there is no matching page label, or if the document doesn't
112
  // have page labels.
113
  int getPageNumFromPageLabel(TextString *pageLabel);
114
115
0
  Object *getViewerPreferences() { return &viewerPrefs; }
116
117
  // Return true if the document uses JavaScript.
118
  GBool usesJavaScript();
119
120
private:
121
122
  PDFDoc *doc;
123
  XRef *xref;     // the xref table for this PDF file
124
  PageTreeNode *pageTree; // the page tree
125
  Page **pages;     // array of pages
126
  Ref *pageRefs;    // object ID for each page
127
#if MULTITHREADED
128
  GMutex pageMutex;
129
#endif
130
  int numPages;     // number of pages
131
  Object dests;     // named destination dictionary
132
  Object nameTree;    // name tree
133
  GString *baseURI;   // base URI for URI-type links
134
  Object metadata;    // metadata stream
135
  Object structTreeRoot;  // structure tree root dictionary
136
  Object outline;   // outline dictionary
137
  Object acroForm;    // AcroForm dictionary
138
  GBool needsRendering;   // NeedsRendering flag
139
  AcroForm *form;   // parsed form
140
  Object ocProperties;    // OCProperties dictionary
141
  GList *embeddedFiles;   // embedded file list [EmbeddedFile]
142
  GList *pageLabels;    // page labels [PageLabelNode]
143
  Object viewerPrefs;   // ViewerPreferences object
144
  GBool ok;     // true if catalog is valid
145
146
  Object *findDestInTree(Object *tree, GString *name, Object *obj);
147
  GBool readPageTree(Object *catDict);
148
  int countPageTree(Object *pagesNodeRef, char *touchedObjs);
149
  void loadPage(int pg);
150
  void loadPage2(int pg, int relPg, PageTreeNode *node);
151
  void readEmbeddedFileList(Dict *catDict);
152
  void readEmbeddedFileTree(Object *nodeRef, char *touchedObjs);
153
  void readFileAttachmentAnnots(Object *pageNodeRef,
154
        char *touchedObjs);
155
  void readEmbeddedFile(Object *fileSpec, Object *name1);
156
  void readPageLabelTree(Object *root);
157
  void readPageLabelTree2(Object *node, char *touchedObjs);
158
  PageLabelNode *findPageLabel(int pageNum);
159
  GString *makeRomanNumeral(int num, GBool uppercase);
160
  GString *makeLetterLabel(int num, GBool uppercase);
161
  GBool convertPageLabelToInt(TextString *pageLabel, int prefixLength,
162
            char style, int *n);
163
  GBool scanPageTreeForJavaScript(Object *pageNodeRef, char *touchedObjs);
164
  GBool scanAAForJavaScript(Object *aaObj);
165
};
166
167
#endif