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