fix build with recent changes/gcc 6.3.0
[AROS-Contrib.git] / arospdf / xpdf / PDFDoc.h
blob6c1f3e6c65a65895a133cfe6146b3879dab0a66d
1 //========================================================================
2 //
3 // PDFDoc.h
4 //
5 // Copyright 1996-2003 Glyph & Cog, LLC
6 //
7 //========================================================================
9 #ifndef PDFDOC_H
10 #define PDFDOC_H
12 #include <aconf.h>
14 #ifdef USE_GCC_PRAGMAS
15 #pragma interface
16 #endif
18 #include <stdio.h>
19 #include "XRef.h"
20 #include "Catalog.h"
21 #include "Page.h"
23 class GString;
24 class BaseStream;
25 class OutputDev;
26 class Links;
27 class LinkAction;
28 class LinkDest;
29 class Outline;
31 //------------------------------------------------------------------------
32 // PDFDoc
33 //------------------------------------------------------------------------
35 class PDFDoc {
36 public:
38 PDFDoc(GString *fileNameA, GString *ownerPassword = NULL,
39 GString *userPassword = NULL, void *guiDataA = NULL);
40 #ifdef WIN32
41 PDFDoc(wchar_t *fileNameA, int fileNameLen, GString *ownerPassword = NULL,
42 GString *userPassword = NULL, void *guiDataA = NULL);
43 #endif
44 PDFDoc(BaseStream *strA, GString *ownerPassword = NULL,
45 GString *userPassword = NULL, void *guiDataA = NULL);
46 ~PDFDoc();
48 // Was PDF document successfully opened?
49 GBool isOk() { return ok; }
51 // Get the error code (if isOk() returns false).
52 int getErrorCode() { return errCode; }
54 // Get file name.
55 GString *getFileName() { return fileName; }
57 // Get the xref table.
58 XRef *getXRef() { return xref; }
60 // Get catalog.
61 Catalog *getCatalog() { return catalog; }
63 // Get base stream.
64 BaseStream *getBaseStream() { return str; }
66 // Get page parameters.
67 double getPageMediaWidth(int page)
68 { return catalog->getPage(page)->getMediaWidth(); }
69 double getPageMediaHeight(int page)
70 { return catalog->getPage(page)->getMediaHeight(); }
71 double getPageCropWidth(int page)
72 { return catalog->getPage(page)->getCropWidth(); }
73 double getPageCropHeight(int page)
74 { return catalog->getPage(page)->getCropHeight(); }
75 int getPageRotate(int page)
76 { return catalog->getPage(page)->getRotate(); }
78 // Get number of pages.
79 int getNumPages() { return catalog->getNumPages(); }
81 // Return the contents of the metadata stream, or NULL if there is
82 // no metadata.
83 GString *readMetadata() { return catalog->readMetadata(); }
85 // Return the structure tree root xObject.
86 xObject *getStructTreeRoot() { return catalog->getStructTreeRoot(); }
88 // Display a page.
89 void displayPage(OutputDev *out, int page,
90 double hDPI, double vDPI, int rotate,
91 GBool useMediaBox, GBool crop, GBool printing,
92 GBool (*abortCheckCbk)(void *data) = NULL,
93 void *abortCheckCbkData = NULL);
95 // Display a range of pages.
96 void displayPages(OutputDev *out, int firstPage, int lastPage,
97 double hDPI, double vDPI, int rotate,
98 GBool useMediaBox, GBool crop, GBool printing,
99 GBool (*abortCheckCbk)(void *data) = NULL,
100 void *abortCheckCbkData = NULL);
102 // Display part of a page.
103 void displayPageSlice(OutputDev *out, int page,
104 double hDPI, double vDPI, int rotate,
105 GBool useMediaBox, GBool crop, GBool printing,
106 int sliceX, int sliceY, int sliceW, int sliceH,
107 GBool (*abortCheckCbk)(void *data) = NULL,
108 void *abortCheckCbkData = NULL);
110 // Find a page, given its xObject ID. Returns page number, or 0 if
111 // not found.
112 int findPage(int num, int gen) { return catalog->findPage(num, gen); }
114 // Returns the links for the current page, transferring ownership to
115 // the caller.
116 Links *getLinks(int page);
118 // Find a named destination. Returns the link destination, or
119 // NULL if <name> is not a destination.
120 LinkDest *findDest(GString *name)
121 { return catalog->findDest(name); }
123 // Process the links for a page.
124 void processLinks(OutputDev *out, int page);
126 #ifndef DISABLE_OUTLINE
127 // Return the outline xObject.
128 Outline *getOutline() { return outline; }
129 #endif
131 // Is the file encrypted?
132 GBool isEncrypted() { return xref->isEncrypted(); }
134 // Check various permissions.
135 GBool okToPrint(GBool ignoreOwnerPW = gFalse)
136 { return xref->okToPrint(ignoreOwnerPW); }
137 GBool okToChange(GBool ignoreOwnerPW = gFalse)
138 { return xref->okToChange(ignoreOwnerPW); }
139 GBool okToCopy(GBool ignoreOwnerPW = gFalse)
140 { return xref->okToCopy(ignoreOwnerPW); }
141 GBool okToAddNotes(GBool ignoreOwnerPW = gFalse)
142 { return xref->okToAddNotes(ignoreOwnerPW); }
144 // Is this document linearized?
145 GBool isLinearized();
147 // Return the document's Info dictionary (if any).
148 xObject *getDocInfo(xObject *obj) { return xref->getDocInfo(obj); }
149 xObject *getDocInfoNF(xObject *obj) { return xref->getDocInfoNF(obj); }
151 // Return the PDF version specified by the file.
152 double getPDFVersion() { return pdfVersion; }
154 // Save this file with another name.
155 GBool saveAs(GString *name);
157 // Return a pointer to the GUI (XPDFCore or WinPDFCore xObject).
158 void *getGUIData() { return guiData; }
161 private:
163 GBool setup(GString *ownerPassword, GString *userPassword);
164 void checkHeader();
165 GBool checkEncryption(GString *ownerPassword, GString *userPassword);
167 GString *fileName;
168 FILE *file;
169 BaseStream *str;
170 void *guiData;
171 double pdfVersion;
172 XRef *xref;
173 Catalog *catalog;
174 #ifndef DISABLE_OUTLINE
175 Outline *outline;
176 #endif
179 GBool ok;
180 int errCode;
183 #endif