]> www.fi.muni.cz Git - evince.git/blob - pdf/xpdf/Gfx.h
Reused eog HIG dialog in GPdf.
[evince.git] / pdf / xpdf / Gfx.h
1 //========================================================================
2 //
3 // Gfx.h
4 //
5 // Copyright 1996-2003 Glyph & Cog, LLC
6 //
7 //========================================================================
8
9 #ifndef GFX_H
10 #define GFX_H
11
12 #include <aconf.h>
13
14 #ifdef USE_GCC_PRAGMAS
15 #pragma interface
16 #endif
17
18 #include "gtypes.h"
19 #include "Object.h"
20
21 class GString;
22 class XRef;
23 class Array;
24 class Stream;
25 class Parser;
26 class Dict;
27 class OutputDev;
28 class GfxFontDict;
29 class GfxFont;
30 class GfxPattern;
31 class GfxShading;
32 class GfxAxialShading;
33 class GfxRadialShading;
34 class GfxState;
35 class Gfx;
36 class PDFRectangle;
37
38 //------------------------------------------------------------------------
39 // Gfx
40 //------------------------------------------------------------------------
41
42 enum GfxClipType {
43   clipNone,
44   clipNormal,
45   clipEO
46 };
47
48 enum TchkType {
49   tchkBool,                     // boolean
50   tchkInt,                      // integer
51   tchkNum,                      // number (integer or real)
52   tchkString,                   // string
53   tchkName,                     // name
54   tchkArray,                    // array
55   tchkProps,                    // properties (dictionary or name)
56   tchkSCN,                      // scn/SCN args (number of name)
57   tchkNone                      // used to avoid empty initializer lists
58 };
59
60 #define maxArgs 8
61
62 struct Operator {
63   char name[4];
64   int numArgs;
65   TchkType tchk[maxArgs];
66   void (Gfx::*func)(Object args[], int numArgs);
67 };
68
69 class GfxResources {
70 public:
71
72   GfxResources(XRef *xref, Dict *resDict, GfxResources *nextA);
73   ~GfxResources();
74
75   GfxFont *lookupFont(char *name);
76   GBool lookupXObject(char *name, Object *obj);
77   GBool lookupXObjectNF(char *name, Object *obj);
78   void lookupColorSpace(char *name, Object *obj);
79   GfxPattern *lookupPattern(char *name);
80   GfxShading *lookupShading(char *name);
81   GBool lookupGState(char *name, Object *obj);
82
83   GfxResources *getNext() { return next; }
84
85 private:
86
87   GfxFontDict *fonts;
88   Object xObjDict;
89   Object colorSpaceDict;
90   Object patternDict;
91   Object shadingDict;
92   Object gStateDict;
93   GfxResources *next;
94 };
95
96 class Gfx {
97 public:
98
99   // Constructor for regular output.
100   Gfx(XRef *xrefA, OutputDev *outA, int pageNum, Dict *resDict, double dpi,
101       PDFRectangle *box, GBool crop, PDFRectangle *cropBox, int rotate,
102       GBool (*abortCheckCbkA)(void *data) = NULL,
103       void *abortCheckCbkDataA = NULL);
104
105   // Constructor for a sub-page object.
106   Gfx(XRef *xrefA, OutputDev *outA, Dict *resDict,
107       PDFRectangle *box, GBool crop, PDFRectangle *cropBox,
108       GBool (*abortCheckCbkA)(void *data) = NULL,
109       void *abortCheckCbkDataA = NULL);
110
111   ~Gfx();
112
113   // Interpret a stream or array of streams.
114   void display(Object *obj, GBool topLevel = gTrue);
115
116   // Display an annotation, given its appearance (a Form XObject) and
117   // bounding box (in default user space).
118   void doAnnot(Object *str, double xMin, double yMin,
119                double xMax, double yMax);
120
121   void pushResources(Dict *resDict);
122   void popResources();
123
124 private:
125
126   XRef *xref;                   // the xref table for this PDF file
127   OutputDev *out;               // output device
128   GBool subPage;                // is this a sub-page object?
129   GBool printCommands;          // print the drawing commands (for debugging)
130   GfxResources *res;            // resource stack
131   int updateLevel;
132
133   GfxState *state;              // current graphics state
134   GBool fontChanged;            // set if font or text matrix has changed
135   GfxClipType clip;             // do a clip?
136   int ignoreUndef;              // current BX/EX nesting level
137   double baseMatrix[6];         // default matrix for most recent
138                                 //   page/form/pattern
139
140   Parser *parser;               // parser for page content stream(s)
141
142   GBool                         // callback to check for an abort
143     (*abortCheckCbk)(void *data);
144   void *abortCheckCbkData;
145
146   static Operator opTab[];      // table of operators
147
148   void go(GBool topLevel);
149   void execOp(Object *cmd, Object args[], int numArgs);
150   Operator *findOp(char *name);
151   GBool checkArg(Object *arg, TchkType type);
152   int getPos();
153
154   // graphics state operators
155   void opSave(Object args[], int numArgs);
156   void opRestore(Object args[], int numArgs);
157   void opConcat(Object args[], int numArgs);
158   void opSetDash(Object args[], int numArgs);
159   void opSetFlat(Object args[], int numArgs);
160   void opSetLineJoin(Object args[], int numArgs);
161   void opSetLineCap(Object args[], int numArgs);
162   void opSetMiterLimit(Object args[], int numArgs);
163   void opSetLineWidth(Object args[], int numArgs);
164   void opSetExtGState(Object args[], int numArgs);
165   void opSetRenderingIntent(Object args[], int numArgs);
166
167   // color operators
168   void opSetFillGray(Object args[], int numArgs);
169   void opSetStrokeGray(Object args[], int numArgs);
170   void opSetFillCMYKColor(Object args[], int numArgs);
171   void opSetStrokeCMYKColor(Object args[], int numArgs);
172   void opSetFillRGBColor(Object args[], int numArgs);
173   void opSetStrokeRGBColor(Object args[], int numArgs);
174   void opSetFillColorSpace(Object args[], int numArgs);
175   void opSetStrokeColorSpace(Object args[], int numArgs);
176   void opSetFillColor(Object args[], int numArgs);
177   void opSetStrokeColor(Object args[], int numArgs);
178   void opSetFillColorN(Object args[], int numArgs);
179   void opSetStrokeColorN(Object args[], int numArgs);
180
181   // path segment operators
182   void opMoveTo(Object args[], int numArgs);
183   void opLineTo(Object args[], int numArgs);
184   void opCurveTo(Object args[], int numArgs);
185   void opCurveTo1(Object args[], int numArgs);
186   void opCurveTo2(Object args[], int numArgs);
187   void opRectangle(Object args[], int numArgs);
188   void opClosePath(Object args[], int numArgs);
189
190   // path painting operators
191   void opEndPath(Object args[], int numArgs);
192   void opStroke(Object args[], int numArgs);
193   void opCloseStroke(Object args[], int numArgs);
194   void opFill(Object args[], int numArgs);
195   void opEOFill(Object args[], int numArgs);
196   void opFillStroke(Object args[], int numArgs);
197   void opCloseFillStroke(Object args[], int numArgs);
198   void opEOFillStroke(Object args[], int numArgs);
199   void opCloseEOFillStroke(Object args[], int numArgs);
200   void doPatternFill(GBool eoFill);
201   void opShFill(Object args[], int numArgs);
202   void doAxialShFill(GfxAxialShading *shading);
203   void doRadialShFill(GfxRadialShading *shading);
204   void doEndPath();
205
206   // path clipping operators
207   void opClip(Object args[], int numArgs);
208   void opEOClip(Object args[], int numArgs);
209
210   // text object operators
211   void opBeginText(Object args[], int numArgs);
212   void opEndText(Object args[], int numArgs);
213
214   // text state operators
215   void opSetCharSpacing(Object args[], int numArgs);
216   void opSetFont(Object args[], int numArgs);
217   void opSetTextLeading(Object args[], int numArgs);
218   void opSetTextRender(Object args[], int numArgs);
219   void opSetTextRise(Object args[], int numArgs);
220   void opSetWordSpacing(Object args[], int numArgs);
221   void opSetHorizScaling(Object args[], int numArgs);
222
223   // text positioning operators
224   void opTextMove(Object args[], int numArgs);
225   void opTextMoveSet(Object args[], int numArgs);
226   void opSetTextMatrix(Object args[], int numArgs);
227   void opTextNextLine(Object args[], int numArgs);
228
229   // text string operators
230   void opShowText(Object args[], int numArgs);
231   void opMoveShowText(Object args[], int numArgs);
232   void opMoveSetShowText(Object args[], int numArgs);
233   void opShowSpaceText(Object args[], int numArgs);
234   void doShowText(GString *s);
235
236   // XObject operators
237   void opXObject(Object args[], int numArgs);
238   void doImage(Object *ref, Stream *str, GBool inlineImg);
239   void doForm(Object *str);
240   void doForm1(Object *str, Dict *resDict, double *matrix, double *bbox);
241
242   // in-line image operators
243   void opBeginImage(Object args[], int numArgs);
244   Stream *buildImageStream();
245   void opImageData(Object args[], int numArgs);
246   void opEndImage(Object args[], int numArgs);
247
248   // type 3 font operators
249   void opSetCharWidth(Object args[], int numArgs);
250   void opSetCacheDevice(Object args[], int numArgs);
251
252   // compatibility operators
253   void opBeginIgnoreUndef(Object args[], int numArgs);
254   void opEndIgnoreUndef(Object args[], int numArgs);
255
256   // marked content operators
257   void opBeginMarkedContent(Object args[], int numArgs);
258   void opEndMarkedContent(Object args[], int numArgs);
259   void opMarkPoint(Object args[], int numArgs);
260 };
261
262 #endif