1 //========================================================================
5 // Copyright 1996-2003 Glyph & Cog, LLC
7 //========================================================================
14 #ifdef USE_GCC_PRAGMAS
31 class GfxTilingPattern
;
32 class GfxShadingPattern
;
34 class GfxFunctionShading
;
35 class GfxAxialShading
;
36 class GfxRadialShading
;
37 class GfxGouraudTriangleShading
;
38 class GfxPatchMeshShading
;
45 class AnnotBorderStyle
;
47 //------------------------------------------------------------------------
58 tchkNum
, // number (integer or real)
62 tchkProps
, // properties (dictionary or name)
63 tchkSCN
, // scn/SCN args (number of name)
64 tchkNone
// used to avoid empty initializer lists
72 TchkType tchk
[maxArgs
];
73 void (Gfx::*func
)(xObject args
[], int numArgs
);
76 //------------------------------------------------------------------------
81 GfxResources(XRef
*xref
, Dict
*resDict
, GfxResources
*nextA
);
84 GfxFont
*lookupFont(char *name
);
85 GBool
lookupXObject(char *name
, xObject
*obj
);
86 GBool
lookupXObjectNF(char *name
, xObject
*obj
);
87 void lookupColorSpace(char *name
, xObject
*obj
);
88 GfxPattern
*lookupPattern(char *name
);
89 GfxShading
*lookupShading(char *name
);
90 GBool
lookupGState(char *name
, xObject
*obj
);
92 GfxResources
*getNext() { return next
; }
98 xObject colorSpaceDict
;
105 //------------------------------------------------------------------------
107 //------------------------------------------------------------------------
112 // Constructor for regular output.
113 Gfx(XRef
*xrefA
, OutputDev
*outA
, int pageNum
, Dict
*resDict
,
114 double hDPI
, double vDPI
, PDFRectangle
*box
,
115 PDFRectangle
*cropBox
, int rotate
,
116 GBool (*abortCheckCbkA
)(void *data
) = NULL
,
117 void *abortCheckCbkDataA
= NULL
);
119 // Constructor for a sub-page xObject.
120 Gfx(XRef
*xrefA
, OutputDev
*outA
, Dict
*resDict
,
121 PDFRectangle
*box
, PDFRectangle
*cropBox
,
122 GBool (*abortCheckCbkA
)(void *data
) = NULL
,
123 void *abortCheckCbkDataA
= NULL
);
127 // Interpret a stream or array of streams.
128 void display(xObject
*obj
, GBool topLevel
= gTrue
);
130 // Display an annotation, given its appearance (a Form XObject),
131 // border style, and bounding box (in default user space).
132 void drawAnnot(xObject
*str
, AnnotBorderStyle
*borderStyle
,
133 double xMin
, double yMin
, double xMax
, double yMax
);
135 // Save graphics state.
138 // Restore graphics state.
141 // Get the current graphics state xObject.
142 GfxState
*getState() { return state
; }
146 XRef
*xref
; // the xref table for this PDF file
147 OutputDev
*out
; // output device
148 GBool subPage
; // is this a sub-page xObject?
149 GBool printCommands
; // print the drawing commands (for debugging)
150 GfxResources
*res
; // resource stack
153 GfxState
*state
; // current graphics state
154 GBool fontChanged
; // set if font or text matrix has changed
155 GfxClipType clip
; // do a clip?
156 int ignoreUndef
; // current BX/EX nesting level
157 double baseMatrix
[6]; // default matrix for most recent
161 Parser
*parser
; // parser for page content stream(s)
163 GBool
// callback to check for an abort
164 (*abortCheckCbk
)(void *data
);
165 void *abortCheckCbkData
;
167 static Operator opTab
[]; // table of operators
169 void go(GBool topLevel
);
170 void execOp(xObject
*cmd
, xObject args
[], int numArgs
);
171 Operator
*findOp(char *name
);
172 GBool
checkArg(xObject
*arg
, TchkType type
);
175 // graphics state operators
176 void opSave(xObject args
[], int numArgs
);
177 void opRestore(xObject args
[], int numArgs
);
178 void opConcat(xObject args
[], int numArgs
);
179 void opSetDash(xObject args
[], int numArgs
);
180 void opSetFlat(xObject args
[], int numArgs
);
181 void opSetLineJoin(xObject args
[], int numArgs
);
182 void opSetLineCap(xObject args
[], int numArgs
);
183 void opSetMiterLimit(xObject args
[], int numArgs
);
184 void opSetLineWidth(xObject args
[], int numArgs
);
185 void opSetExtGState(xObject args
[], int numArgs
);
186 void doSoftMask(xObject
*str
, GBool alpha
,
187 GfxColorSpace
*blendingColorSpace
,
188 GBool isolated
, GBool knockout
,
189 Function
*transferFunc
, GfxColor
*backdropColor
);
190 void opSetRenderingIntent(xObject args
[], int numArgs
);
193 void opSetFillGray(xObject args
[], int numArgs
);
194 void opSetStrokeGray(xObject args
[], int numArgs
);
195 void opSetFillCMYKColor(xObject args
[], int numArgs
);
196 void opSetStrokeCMYKColor(xObject args
[], int numArgs
);
197 void opSetFillRGBColor(xObject args
[], int numArgs
);
198 void opSetStrokeRGBColor(xObject args
[], int numArgs
);
199 void opSetFillColorSpace(xObject args
[], int numArgs
);
200 void opSetStrokeColorSpace(xObject args
[], int numArgs
);
201 void opSetFillColor(xObject args
[], int numArgs
);
202 void opSetStrokeColor(xObject args
[], int numArgs
);
203 void opSetFillColorN(xObject args
[], int numArgs
);
204 void opSetStrokeColorN(xObject args
[], int numArgs
);
206 // path segment operators
207 void opMoveTo(xObject args
[], int numArgs
);
208 void opLineTo(xObject args
[], int numArgs
);
209 void opCurveTo(xObject args
[], int numArgs
);
210 void opCurveTo1(xObject args
[], int numArgs
);
211 void opCurveTo2(xObject args
[], int numArgs
);
212 void opRectangle(xObject args
[], int numArgs
);
213 void opClosePath(xObject args
[], int numArgs
);
215 // path painting operators
216 void opEndPath(xObject args
[], int numArgs
);
217 void opStroke(xObject args
[], int numArgs
);
218 void opCloseStroke(xObject args
[], int numArgs
);
219 void opFill(xObject args
[], int numArgs
);
220 void opEOFill(xObject args
[], int numArgs
);
221 void opFillStroke(xObject args
[], int numArgs
);
222 void opCloseFillStroke(xObject args
[], int numArgs
);
223 void opEOFillStroke(xObject args
[], int numArgs
);
224 void opCloseEOFillStroke(xObject args
[], int numArgs
);
225 void doPatternFill(GBool eoFill
);
226 void doPatternStroke();
227 void doTilingPatternFill(GfxTilingPattern
*tPat
,
228 GBool stroke
, GBool eoFill
);
229 void doShadingPatternFill(GfxShadingPattern
*sPat
,
230 GBool stroke
, GBool eoFill
);
231 void opShFill(xObject args
[], int numArgs
);
232 void doFunctionShFill(GfxFunctionShading
*shading
);
233 void doFunctionShFill1(GfxFunctionShading
*shading
,
234 double x0
, double y0
,
235 double x1
, double y1
,
236 GfxColor
*colors
, int depth
);
237 void doAxialShFill(GfxAxialShading
*shading
);
238 void doRadialShFill(GfxRadialShading
*shading
);
239 void doGouraudTriangleShFill(GfxGouraudTriangleShading
*shading
);
240 void gouraudFillTriangle(double x0
, double y0
, GfxColor
*color0
,
241 double x1
, double y1
, GfxColor
*color1
,
242 double x2
, double y2
, GfxColor
*color2
,
243 int nComps
, int depth
);
244 void doPatchMeshShFill(GfxPatchMeshShading
*shading
);
245 void fillPatch(GfxPatch
*patch
, int nComps
, int depth
);
248 // path clipping operators
249 void opClip(xObject args
[], int numArgs
);
250 void opEOClip(xObject args
[], int numArgs
);
252 // text xObject operators
253 void opBeginText(xObject args
[], int numArgs
);
254 void opEndText(xObject args
[], int numArgs
);
256 // text state operators
257 void opSetCharSpacing(xObject args
[], int numArgs
);
258 void opSetFont(xObject args
[], int numArgs
);
259 void opSetTextLeading(xObject args
[], int numArgs
);
260 void opSetTextRender(xObject args
[], int numArgs
);
261 void opSetTextRise(xObject args
[], int numArgs
);
262 void opSetWordSpacing(xObject args
[], int numArgs
);
263 void opSetHorizScaling(xObject args
[], int numArgs
);
265 // text positioning operators
266 void opTextMove(xObject args
[], int numArgs
);
267 void opTextMoveSet(xObject args
[], int numArgs
);
268 void opSetTextMatrix(xObject args
[], int numArgs
);
269 void opTextNextLine(xObject args
[], int numArgs
);
271 // text string operators
272 void opShowText(xObject args
[], int numArgs
);
273 void opMoveShowText(xObject args
[], int numArgs
);
274 void opMoveSetShowText(xObject args
[], int numArgs
);
275 void opShowSpaceText(xObject args
[], int numArgs
);
276 void doShowText(GString
*s
);
279 void opXObject(xObject args
[], int numArgs
);
280 void doImage(xObject
*ref
, Stream
*str
, GBool inlineImg
);
281 void doForm(xObject
*str
);
282 void doForm1(xObject
*str
, Dict
*resDict
, double *matrix
, double *bbox
,
283 GBool transpGroup
= gFalse
, GBool softMask
= gFalse
,
284 GfxColorSpace
*blendingColorSpace
= NULL
,
285 GBool isolated
= gFalse
, GBool knockout
= gFalse
,
286 GBool alpha
= gFalse
, Function
*transferFunc
= NULL
,
287 GfxColor
*backdropColor
= NULL
);
289 // in-line image operators
290 void opBeginImage(xObject args
[], int numArgs
);
291 Stream
*buildImageStream();
292 void opImageData(xObject args
[], int numArgs
);
293 void opEndImage(xObject args
[], int numArgs
);
295 // type 3 font operators
296 void opSetCharWidth(xObject args
[], int numArgs
);
297 void opSetCacheDevice(xObject args
[], int numArgs
);
299 // compatibility operators
300 void opBeginIgnoreUndef(xObject args
[], int numArgs
);
301 void opEndIgnoreUndef(xObject args
[], int numArgs
);
303 // marked content operators
304 void opBeginMarkedContent(xObject args
[], int numArgs
);
305 void opEndMarkedContent(xObject args
[], int numArgs
);
306 void opMarkPoint(xObject args
[], int numArgs
);
308 void pushResources(Dict
*resDict
);