fix build with recent changes/gcc 6.3.0
[AROS-Contrib.git] / arospdf / xpdf / Page.h
blob0b52318d15f406fdea215ffdbdecdcffd3ba0b80
1 //========================================================================
2 //
3 // Page.h
4 //
5 // Copyright 1996-2003 Glyph & Cog, LLC
6 //
7 //========================================================================
9 #ifndef PAGE_H
10 #define PAGE_H
12 #include <aconf.h>
14 #ifdef USE_GCC_PRAGMAS
15 #pragma interface
16 #endif
18 #include "Object.h"
20 class Dict;
21 class XRef;
22 class OutputDev;
23 class Links;
24 class Catalog;
26 //------------------------------------------------------------------------
28 class PDFRectangle {
29 public:
30 double x1, y1, x2, y2;
32 PDFRectangle() { x1 = y1 = x2 = y2 = 0; }
33 PDFRectangle(double x1A, double y1A, double x2A, double y2A)
34 { x1 = x1A; y1 = y1A; x2 = x2A; y2 = y2A; }
35 GBool isValid() { return x1 != 0 || y1 != 0 || x2 != 0 || y2 != 0; }
36 void clipTo(PDFRectangle *rect);
39 //------------------------------------------------------------------------
40 // PageAttrs
41 //------------------------------------------------------------------------
43 class PageAttrs {
44 public:
46 // Construct a new PageAttrs xObject by merging a dictionary
47 // (of type Pages or Page) into another PageAttrs xObject. If
48 // <attrs> is NULL, uses defaults.
49 PageAttrs(PageAttrs *attrs, Dict *dict);
51 // Destructor.
52 ~PageAttrs();
54 // Accessors.
55 PDFRectangle *getMediaBox() { return &mediaBox; }
56 PDFRectangle *getCropBox() { return &cropBox; }
57 GBool isCropped() { return haveCropBox; }
58 PDFRectangle *getBleedBox() { return &bleedBox; }
59 PDFRectangle *getTrimBox() { return &trimBox; }
60 PDFRectangle *getArtBox() { return &artBox; }
61 int getRotate() { return rotate; }
62 GString *getLastModified()
63 { return lastModified.isString()
64 ? lastModified.getString() : (GString *)NULL; }
65 Dict *getBoxColorInfo()
66 { return boxColorInfo.isDict() ? boxColorInfo.getDict() : (Dict *)NULL; }
67 Dict *getGroup()
68 { return group.isDict() ? group.getDict() : (Dict *)NULL; }
69 Stream *getMetadata()
70 { return metadata.isStream() ? metadata.getStream() : (Stream *)NULL; }
71 Dict *getPieceInfo()
72 { return pieceInfo.isDict() ? pieceInfo.getDict() : (Dict *)NULL; }
73 Dict *getSeparationInfo()
74 { return separationInfo.isDict()
75 ? separationInfo.getDict() : (Dict *)NULL; }
76 Dict *getResourceDict()
77 { return resources.isDict() ? resources.getDict() : (Dict *)NULL; }
79 private:
81 GBool readBox(Dict *dict, char *key, PDFRectangle *box);
83 PDFRectangle mediaBox;
84 PDFRectangle cropBox;
85 GBool haveCropBox;
86 PDFRectangle bleedBox;
87 PDFRectangle trimBox;
88 PDFRectangle artBox;
89 int rotate;
90 xObject lastModified;
91 xObject boxColorInfo;
92 xObject group;
93 xObject metadata;
94 xObject pieceInfo;
95 xObject separationInfo;
96 xObject resources;
99 //------------------------------------------------------------------------
100 // Page
101 //------------------------------------------------------------------------
103 class Page {
104 public:
106 // Constructor.
107 Page(XRef *xrefA, int numA, Dict *pageDict, PageAttrs *attrsA);
109 // Destructor.
110 ~Page();
112 // Is page valid?
113 GBool isOk() { return ok; }
115 // Get page parameters.
116 int getNum() { return num; }
117 PDFRectangle *getMediaBox() { return attrs->getMediaBox(); }
118 PDFRectangle *getCropBox() { return attrs->getCropBox(); }
119 GBool isCropped() { return attrs->isCropped(); }
120 double getMediaWidth()
121 { return attrs->getMediaBox()->x2 - attrs->getMediaBox()->x1; }
122 double getMediaHeight()
123 { return attrs->getMediaBox()->y2 - attrs->getMediaBox()->y1; }
124 double getCropWidth()
125 { return attrs->getCropBox()->x2 - attrs->getCropBox()->x1; }
126 double getCropHeight()
127 { return attrs->getCropBox()->y2 - attrs->getCropBox()->y1; }
128 PDFRectangle *getBleedBox() { return attrs->getBleedBox(); }
129 PDFRectangle *getTrimBox() { return attrs->getTrimBox(); }
130 PDFRectangle *getArtBox() { return attrs->getArtBox(); }
131 int getRotate() { return attrs->getRotate(); }
132 GString *getLastModified() { return attrs->getLastModified(); }
133 Dict *getBoxColorInfo() { return attrs->getBoxColorInfo(); }
134 Dict *getGroup() { return attrs->getGroup(); }
135 Stream *getMetadata() { return attrs->getMetadata(); }
136 Dict *getPieceInfo() { return attrs->getPieceInfo(); }
137 Dict *getSeparationInfo() { return attrs->getSeparationInfo(); }
139 // Get resource dictionary.
140 Dict *getResourceDict() { return attrs->getResourceDict(); }
142 // Get annotations array.
143 xObject *getAnnots(xObject *obj) { return annots.fetch(xref, obj); }
145 // Return a list of links.
146 Links *getLinks(Catalog *catalog);
148 // Get contents.
149 xObject *getContents(xObject *obj) { return contents.fetch(xref, obj); }
151 // Display a page.
152 void display(OutputDev *out, double hDPI, double vDPI,
153 int rotate, GBool useMediaBox, GBool crop,
154 GBool printing, Catalog *catalog,
155 GBool (*abortCheckCbk)(void *data) = NULL,
156 void *abortCheckCbkData = NULL);
158 // Display part of a page.
159 void displaySlice(OutputDev *out, double hDPI, double vDPI,
160 int rotate, GBool useMediaBox, GBool crop,
161 int sliceX, int sliceY, int sliceW, int sliceH,
162 GBool printing, Catalog *catalog,
163 GBool (*abortCheckCbk)(void *data) = NULL,
164 void *abortCheckCbkData = NULL);
166 void makeBox(double hDPI, double vDPI, int rotate,
167 GBool useMediaBox, GBool upsideDown,
168 double sliceX, double sliceY, double sliceW, double sliceH,
169 PDFRectangle *box, GBool *crop);
171 void processLinks(OutputDev *out, Catalog *catalog);
173 // Get the page's default CTM.
174 void getDefaultCTM(double *ctm, double hDPI, double vDPI,
175 int rotate, GBool useMediaBox, GBool upsideDown);
177 private:
179 XRef *xref; // the xref table for this PDF file
180 int num; // page number
181 PageAttrs *attrs; // page attributes
182 xObject annots; // annotations array
183 xObject contents; // page contents
184 GBool ok; // true if page is valid
187 #endif