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