Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

Gfx.h

Go to the documentation of this file.
00001 //========================================================================
00002 //
00003 // Gfx.h
00004 //
00005 // Copyright 1996-2002 Glyph & Cog, LLC
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 // Gfx
00037 //------------------------------------------------------------------------
00038 
00039 enum GfxClipType {
00040   clipNone,
00041   clipNormal,
00042   clipEO
00043 };
00044 
00045 enum TchkType {
00046   tchkBool,                     // boolean
00047   tchkInt,                      // integer
00048   tchkNum,                      // number (integer or real)
00049   tchkString,                   // string
00050   tchkName,                     // name
00051   tchkArray,                    // array
00052   tchkProps,                    // properties (dictionary or name)
00053   tchkSCN,                      // scn/SCN args (number of name)
00054   tchkNone                      // used to avoid empty initializer lists
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   // Constructor for regular output.
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   // Constructor for a sub-page object.
00102   Gfx(XRef *xrefA, OutputDev *outA, Dict *resDict,
00103       PDFRectangle *box, GBool crop, PDFRectangle *cropBox);
00104 
00105   ~Gfx();
00106 
00107   // Interpret a stream or array of streams.
00108   void display(Object *obj, GBool topLevel = gTrue);
00109 
00110   // Display an annotation, given its appearance (a Form XObject) and
00111   // bounding box (in default user space).
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;                   // the xref table for this PDF file
00121   OutputDev *out;               // output device
00122   GBool subPage;                // is this a sub-page object?
00123   GBool printCommands;          // print the drawing commands (for debugging)
00124   GfxResources *res;            // resource stack
00125   int updateLevel;
00126 
00127   GfxState *state;              // current graphics state
00128   GBool fontChanged;            // set if font or text matrix has changed
00129   GfxClipType clip;             // do a clip?
00130   int ignoreUndef;              // current BX/EX nesting level
00131   fouble baseMatrix[6];         // default matrix for most recent
00132                                 //   page/form/pattern
00133 
00134   Parser *parser;               // parser for page content stream(s)
00135 
00136   static Operator opTab[];      // table of operators
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   // graphics state operators
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   // color operators
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   // path segment operators
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   // path painting operators
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   // path clipping operators
00197   void opClip(Object args[], int numArgs);
00198   void opEOClip(Object args[], int numArgs);
00199 
00200   // text object operators
00201   void opBeginText(Object args[], int numArgs);
00202   void opEndText(Object args[], int numArgs);
00203 
00204   // text state operators
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   // text positioning operators
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   // text string operators
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   // XObject operators
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   // in-line image operators
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   // type 3 font operators
00239   void opSetCharWidth(Object args[], int numArgs);
00240   void opSetCacheDevice(Object args[], int numArgs);
00241 
00242   // compatibility operators
00243   void opBeginIgnoreUndef(Object args[], int numArgs);
00244   void opEndIgnoreUndef(Object args[], int numArgs);
00245 
00246   // marked content operators
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

Generated on Sat Nov 5 16:18:14 2005 for OPIE by  doxygen 1.4.2