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