00001
00002
00003
00004
00005
00006
00007
00008
00009 #ifndef GFX_H
00010 #define GFX_H
00011
00012 #ifdef __GNUC__
00013 #pragma interface
00014 #endif
00015
00016 #include "gtypes.h"
00017
00018 class GString;
00019 class XRef;
00020 class Array;
00021 class Stream;
00022 class Parser;
00023 class Dict;
00024 class OutputDev;
00025 class GfxFontDict;
00026 class GfxFont;
00027 class GfxPattern;
00028 class GfxShading;
00029 class GfxAxialShading;
00030 class GfxRadialShading;
00031 class GfxState;
00032 class Gfx;
00033 struct PDFRectangle;
00034
00035
00036
00037
00038
00039 enum GfxClipType {
00040 clipNone,
00041 clipNormal,
00042 clipEO
00043 };
00044
00045 enum TchkType {
00046 tchkBool,
00047 tchkInt,
00048 tchkNum,
00049 tchkString,
00050 tchkName,
00051 tchkArray,
00052 tchkProps,
00053 tchkSCN,
00054 tchkNone
00055 };
00056
00057 #define maxArgs 8
00058
00059 struct Operator {
00060 char name[4];
00061 int numArgs;
00062 TchkType tchk[maxArgs];
00063 void (Gfx::*func)(Object args[], int numArgs);
00064 };
00065
00066 class GfxResources {
00067 public:
00068
00069 GfxResources(XRef *xref, Dict *resDict, GfxResources *nextA);
00070 ~GfxResources();
00071
00072 GfxFont *lookupFont(char *name);
00073 GBool lookupXObject(char *name, Object *obj);
00074 GBool lookupXObjectNF(char *name, Object *obj);
00075 void lookupColorSpace(char *name, Object *obj);
00076 GfxPattern *lookupPattern(char *name);
00077 GfxShading *lookupShading(char *name);
00078 GBool lookupGState(char *name, Object *obj);
00079
00080 GfxResources *getNext() { return next; }
00081
00082 private:
00083
00084 GfxFontDict *fonts;
00085 Object xObjDict;
00086 Object colorSpaceDict;
00087 Object patternDict;
00088 Object shadingDict;
00089 Object gStateDict;
00090 GfxResources *next;
00091 };
00092
00093 class Gfx {
00094 public:
00095
00096
00097 Gfx(XRef *xrefA, OutputDev *outA, int pageNum, Dict *resDict, fouble dpi,
00098 PDFRectangle *box, GBool crop, PDFRectangle *cropBox, int rotate,
00099 GBool printCommandsA);
00100
00101
00102 Gfx(XRef *xrefA, OutputDev *outA, Dict *resDict,
00103 PDFRectangle *box, GBool crop, PDFRectangle *cropBox);
00104
00105 ~Gfx();
00106
00107
00108 void display(Object *obj, GBool topLevel = gTrue);
00109
00110
00111
00112 void doAnnot(Object *str, fouble xMin, fouble yMin,
00113 fouble xMax, fouble yMax);
00114
00115 void pushResources(Dict *resDict);
00116 void popResources();
00117
00118 private:
00119
00120 XRef *xref;
00121 OutputDev *out;
00122 GBool subPage;
00123 GBool printCommands;
00124 GfxResources *res;
00125 int updateLevel;
00126
00127 GfxState *state;
00128 GBool fontChanged;
00129 GfxClipType clip;
00130 int ignoreUndef;
00131 fouble baseMatrix[6];
00132
00133
00134 Parser *parser;
00135
00136 static Operator opTab[];
00137
00138 void go(GBool topLevel);
00139 void execOp(Object *cmd, Object args[], int numArgs);
00140 Operator *findOp(char *name);
00141 GBool checkArg(Object *arg, TchkType type);
00142 int getPos();
00143
00144
00145 void opSave(Object args[], int numArgs);
00146 void opRestore(Object args[], int numArgs);
00147 void opConcat(Object args[], int numArgs);
00148 void opSetDash(Object args[], int numArgs);
00149 void opSetFlat(Object args[], int numArgs);
00150 void opSetLineJoin(Object args[], int numArgs);
00151 void opSetLineCap(Object args[], int numArgs);
00152 void opSetMiterLimit(Object args[], int numArgs);
00153 void opSetLineWidth(Object args[], int numArgs);
00154 void opSetExtGState(Object args[], int numArgs);
00155 void opSetRenderingIntent(Object args[], int numArgs);
00156
00157
00158 void opSetFillGray(Object args[], int numArgs);
00159 void opSetStrokeGray(Object args[], int numArgs);
00160 void opSetFillCMYKColor(Object args[], int numArgs);
00161 void opSetStrokeCMYKColor(Object args[], int numArgs);
00162 void opSetFillRGBColor(Object args[], int numArgs);
00163 void opSetStrokeRGBColor(Object args[], int numArgs);
00164 void opSetFillColorSpace(Object args[], int numArgs);
00165 void opSetStrokeColorSpace(Object args[], int numArgs);
00166 void opSetFillColor(Object args[], int numArgs);
00167 void opSetStrokeColor(Object args[], int numArgs);
00168 void opSetFillColorN(Object args[], int numArgs);
00169 void opSetStrokeColorN(Object args[], int numArgs);
00170
00171
00172 void opMoveTo(Object args[], int numArgs);
00173 void opLineTo(Object args[], int numArgs);
00174 void opCurveTo(Object args[], int numArgs);
00175 void opCurveTo1(Object args[], int numArgs);
00176 void opCurveTo2(Object args[], int numArgs);
00177 void opRectangle(Object args[], int numArgs);
00178 void opClosePath(Object args[], int numArgs);
00179
00180
00181 void opEndPath(Object args[], int numArgs);
00182 void opStroke(Object args[], int numArgs);
00183 void opCloseStroke(Object args[], int numArgs);
00184 void opFill(Object args[], int numArgs);
00185 void opEOFill(Object args[], int numArgs);
00186 void opFillStroke(Object args[], int numArgs);
00187 void opCloseFillStroke(Object args[], int numArgs);
00188 void opEOFillStroke(Object args[], int numArgs);
00189 void opCloseEOFillStroke(Object args[], int numArgs);
00190 void doPatternFill(GBool eoFill);
00191 void opShFill(Object args[], int numArgs);
00192 void doAxialShFill(GfxAxialShading *shading);
00193 void doRadialShFill(GfxRadialShading *shading);
00194 void doEndPath();
00195
00196
00197 void opClip(Object args[], int numArgs);
00198 void opEOClip(Object args[], int numArgs);
00199
00200
00201 void opBeginText(Object args[], int numArgs);
00202 void opEndText(Object args[], int numArgs);
00203
00204
00205 void opSetCharSpacing(Object args[], int numArgs);
00206 void opSetFont(Object args[], int numArgs);
00207 void opSetTextLeading(Object args[], int numArgs);
00208 void opSetTextRender(Object args[], int numArgs);
00209 void opSetTextRise(Object args[], int numArgs);
00210 void opSetWordSpacing(Object args[], int numArgs);
00211 void opSetHorizScaling(Object args[], int numArgs);
00212
00213
00214 void opTextMove(Object args[], int numArgs);
00215 void opTextMoveSet(Object args[], int numArgs);
00216 void opSetTextMatrix(Object args[], int numArgs);
00217 void opTextNextLine(Object args[], int numArgs);
00218
00219
00220 void opShowText(Object args[], int numArgs);
00221 void opMoveShowText(Object args[], int numArgs);
00222 void opMoveSetShowText(Object args[], int numArgs);
00223 void opShowSpaceText(Object args[], int numArgs);
00224 void doShowText(GString *s);
00225
00226
00227 void opXObject(Object args[], int numArgs);
00228 void doImage(Object *ref, Stream *str, GBool inlineImg);
00229 void doForm(Object *str);
00230 void doForm1(Object *str, Dict *resDict, fouble *matrix, fouble *bbox);
00231
00232
00233 void opBeginImage(Object args[], int numArgs);
00234 Stream *buildImageStream();
00235 void opImageData(Object args[], int numArgs);
00236 void opEndImage(Object args[], int numArgs);
00237
00238
00239 void opSetCharWidth(Object args[], int numArgs);
00240 void opSetCacheDevice(Object args[], int numArgs);
00241
00242
00243 void opBeginIgnoreUndef(Object args[], int numArgs);
00244 void opEndIgnoreUndef(Object args[], int numArgs);
00245
00246
00247 void opBeginMarkedContent(Object args[], int numArgs);
00248 void opEndMarkedContent(Object args[], int numArgs);
00249 void opMarkPoint(Object args[], int numArgs);
00250 };
00251
00252 #endif