|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef GFX_H |
|
#define GFX_H |
|
|
|
#include "poppler-config.h" |
|
#include "poppler_private_export.h" |
|
#include "GfxState.h" |
|
#include "Object.h" |
|
#include "PopplerCache.h" |
|
|
|
#include <vector> |
|
|
|
class GooString; |
|
class PDFDoc; |
|
class XRef; |
|
class Array; |
|
class Stream; |
|
class Parser; |
|
class Dict; |
|
class Function; |
|
class OutputDev; |
|
class GfxFontDict; |
|
class GfxFont; |
|
class GfxPattern; |
|
class GfxTilingPattern; |
|
class GfxShadingPattern; |
|
class GfxShading; |
|
class GfxFunctionShading; |
|
class GfxAxialShading; |
|
class GfxRadialShading; |
|
class GfxGouraudTriangleShading; |
|
class GfxPatchMeshShading; |
|
struct GfxPatch; |
|
class GfxState; |
|
struct GfxColor; |
|
class GfxColorSpace; |
|
class Gfx; |
|
class PDFRectangle; |
|
class AnnotBorder; |
|
class AnnotColor; |
|
class Catalog; |
|
struct MarkedContentStack; |
|
|
|
|
|
|
|
enum GfxClipType |
|
{ |
|
clipNone, |
|
clipNormal, |
|
clipEO |
|
}; |
|
|
|
enum TchkType |
|
{ |
|
tchkBool, |
|
tchkInt, |
|
tchkNum, |
|
tchkString, |
|
tchkName, |
|
tchkArray, |
|
tchkProps, |
|
tchkSCN, |
|
tchkNone |
|
}; |
|
|
|
#define maxArgs 33 |
|
|
|
struct Operator |
|
{ |
|
char name[4]; |
|
int numArgs; |
|
TchkType tchk[maxArgs]; |
|
void (Gfx::*func)(Object args[], int numArgs); |
|
}; |
|
|
|
|
|
|
|
class POPPLER_PRIVATE_EXPORT GfxResources |
|
{ |
|
public: |
|
GfxResources(XRef *xref, Dict *resDict, GfxResources *nextA); |
|
~GfxResources(); |
|
|
|
GfxResources(const GfxResources &) = delete; |
|
GfxResources &operator=(const GfxResources &other) = delete; |
|
|
|
std::shared_ptr<GfxFont> lookupFont(const char *name); |
|
std::shared_ptr<const GfxFont> lookupFont(const char *name) const; |
|
Object lookupXObject(const char *name); |
|
Object lookupXObjectNF(const char *name); |
|
Object lookupMarkedContentNF(const char *name); |
|
Object lookupColorSpace(const char *name); |
|
GfxPattern *lookupPattern(const char *name, OutputDev *out, GfxState *state); |
|
GfxShading *lookupShading(const char *name, OutputDev *out, GfxState *state); |
|
Object lookupGState(const char *name); |
|
Object lookupGStateNF(const char *name); |
|
|
|
GfxResources *getNext() const { return next; } |
|
|
|
private: |
|
std::shared_ptr<GfxFont> doLookupFont(const char *name) const; |
|
|
|
GfxFontDict *fonts; |
|
Object xObjDict; |
|
Object colorSpaceDict; |
|
Object patternDict; |
|
Object shadingDict; |
|
Object gStateDict; |
|
PopplerCache<Ref, Object> gStateCache; |
|
XRef *xref; |
|
Object propertiesDict; |
|
GfxResources *next; |
|
}; |
|
|
|
|
|
|
|
|
|
|
|
class POPPLER_PRIVATE_EXPORT Gfx |
|
{ |
|
public: |
|
|
|
Gfx(PDFDoc *docA, OutputDev *outA, int pageNum, Dict *resDict, double hDPI, double vDPI, const PDFRectangle *box, const PDFRectangle *cropBox, int rotate, bool (*abortCheckCbkA)(void *data) = nullptr, void *abortCheckCbkDataA = nullptr, |
|
XRef *xrefA = nullptr); |
|
|
|
|
|
Gfx(PDFDoc *docA, OutputDev *outA, Dict *resDict, const PDFRectangle *box, const PDFRectangle *cropBox, bool (*abortCheckCbkA)(void *data) = nullptr, void *abortCheckCbkDataA = nullptr, Gfx *gfxA = nullptr); |
|
#ifdef USE_CMS |
|
void initDisplayProfile(); |
|
#endif |
|
~Gfx(); |
|
|
|
Gfx(const Gfx &) = delete; |
|
Gfx &operator=(const Gfx &other) = delete; |
|
|
|
XRef *getXRef() { return xref; } |
|
|
|
|
|
void display(Object *obj, bool topLevel = true); |
|
|
|
|
|
|
|
void drawAnnot(Object *str, AnnotBorder *border, AnnotColor *aColor, double xMin, double yMin, double xMax, double yMax, int rotate); |
|
|
|
|
|
void saveState(); |
|
|
|
|
|
void pushStateGuard(); |
|
|
|
|
|
void restoreState(); |
|
|
|
|
|
void popStateGuard(); |
|
|
|
|
|
GfxState *getState() { return state; } |
|
|
|
bool checkTransparencyGroup(Dict *resDict); |
|
|
|
void drawForm(Object *str, Dict *resDict, const double *matrix, const double *bbox, bool transpGroup = false, bool softMask = false, GfxColorSpace *blendingColorSpace = nullptr, bool isolated = false, bool knockout = false, |
|
bool alpha = false, Function *transferFunc = nullptr, GfxColor *backdropColor = nullptr); |
|
|
|
void pushResources(Dict *resDict); |
|
void popResources(); |
|
|
|
private: |
|
PDFDoc *doc; |
|
XRef *xref; |
|
Catalog *catalog; |
|
OutputDev *out; |
|
bool subPage; |
|
const bool printCommands; |
|
const bool profileCommands; |
|
bool commandAborted; |
|
GfxResources *res; |
|
int updateLevel; |
|
|
|
GfxState *state; |
|
int stackHeight; |
|
std::vector<int> stateGuards; |
|
bool fontChanged; |
|
GfxClipType clip; |
|
int ignoreUndef; |
|
double baseMatrix[6]; |
|
|
|
int displayDepth; |
|
bool ocState; |
|
|
|
|
|
MarkedContentStack *mcStack; |
|
|
|
Parser *parser; |
|
|
|
std::set<int> formsDrawing; |
|
std::set<int> charProcDrawing; |
|
|
|
bool |
|
(*abortCheckCbk)(void *data); |
|
void *abortCheckCbkData; |
|
|
|
static const Operator opTab[]; |
|
|
|
void go(bool topLevel); |
|
void execOp(Object *cmd, Object args[], int numArgs); |
|
const Operator *findOp(const char *name); |
|
bool checkArg(Object *arg, TchkType type); |
|
Goffset getPos(); |
|
|
|
int bottomGuard(); |
|
|
|
|
|
void opSave(Object args[], int numArgs); |
|
void opRestore(Object args[], int numArgs); |
|
void opConcat(Object args[], int numArgs); |
|
void opSetDash(Object args[], int numArgs); |
|
void opSetFlat(Object args[], int numArgs); |
|
void opSetLineJoin(Object args[], int numArgs); |
|
void opSetLineCap(Object args[], int numArgs); |
|
void opSetMiterLimit(Object args[], int numArgs); |
|
void opSetLineWidth(Object args[], int numArgs); |
|
void opSetExtGState(Object args[], int numArgs); |
|
void doSoftMask(Object *str, bool alpha, GfxColorSpace *blendingColorSpace, bool isolated, bool knockout, Function *transferFunc, GfxColor *backdropColor); |
|
void opSetRenderingIntent(Object args[], int numArgs); |
|
|
|
|
|
void opSetFillGray(Object args[], int numArgs); |
|
void opSetStrokeGray(Object args[], int numArgs); |
|
void opSetFillCMYKColor(Object args[], int numArgs); |
|
void opSetStrokeCMYKColor(Object args[], int numArgs); |
|
void opSetFillRGBColor(Object args[], int numArgs); |
|
void opSetStrokeRGBColor(Object args[], int numArgs); |
|
void opSetFillColorSpace(Object args[], int numArgs); |
|
void opSetStrokeColorSpace(Object args[], int numArgs); |
|
void opSetFillColor(Object args[], int numArgs); |
|
void opSetStrokeColor(Object args[], int numArgs); |
|
void opSetFillColorN(Object args[], int numArgs); |
|
void opSetStrokeColorN(Object args[], int numArgs); |
|
|
|
|
|
void opMoveTo(Object args[], int numArgs); |
|
void opLineTo(Object args[], int numArgs); |
|
void opCurveTo(Object args[], int numArgs); |
|
void opCurveTo1(Object args[], int numArgs); |
|
void opCurveTo2(Object args[], int numArgs); |
|
void opRectangle(Object args[], int numArgs); |
|
void opClosePath(Object args[], int numArgs); |
|
|
|
|
|
void opEndPath(Object args[], int numArgs); |
|
void opStroke(Object args[], int numArgs); |
|
void opCloseStroke(Object args[], int numArgs); |
|
void opFill(Object args[], int numArgs); |
|
void opEOFill(Object args[], int numArgs); |
|
void opFillStroke(Object args[], int numArgs); |
|
void opCloseFillStroke(Object args[], int numArgs); |
|
void opEOFillStroke(Object args[], int numArgs); |
|
void opCloseEOFillStroke(Object args[], int numArgs); |
|
void doPatternFill(bool eoFill); |
|
void doPatternStroke(); |
|
void doPatternText(); |
|
void doPatternImageMask(Object *ref, Stream *str, int width, int height, bool invert, bool inlineImg); |
|
void doTilingPatternFill(GfxTilingPattern *tPat, bool stroke, bool eoFill, bool text); |
|
void doShadingPatternFill(GfxShadingPattern *sPat, bool stroke, bool eoFill, bool text); |
|
void opShFill(Object args[], int numArgs); |
|
void doFunctionShFill(GfxFunctionShading *shading); |
|
void doFunctionShFill1(GfxFunctionShading *shading, double x0, double y0, double x1, double y1, GfxColor *colors, int depth); |
|
void doAxialShFill(GfxAxialShading *shading); |
|
void doRadialShFill(GfxRadialShading *shading); |
|
void doGouraudTriangleShFill(GfxGouraudTriangleShading *shading); |
|
void gouraudFillTriangle(double x0, double y0, GfxColor *color0, double x1, double y1, GfxColor *color1, double x2, double y2, GfxColor *color2, int nComps, int depth, GfxState::ReusablePathIterator *path); |
|
void gouraudFillTriangle(double x0, double y0, double color0, double x1, double y1, double color1, double x2, double y2, double color2, double refineColorThreshold, int depth, GfxGouraudTriangleShading *shading, |
|
GfxState::ReusablePathIterator *path); |
|
void doPatchMeshShFill(GfxPatchMeshShading *shading); |
|
void fillPatch(const GfxPatch *patch, int colorComps, int patchColorComps, double refineColorThreshold, int depth, const GfxPatchMeshShading *shading); |
|
void doEndPath(); |
|
|
|
|
|
void opClip(Object args[], int numArgs); |
|
void opEOClip(Object args[], int numArgs); |
|
|
|
|
|
void opBeginText(Object args[], int numArgs); |
|
void opEndText(Object args[], int numArgs); |
|
|
|
|
|
void opSetCharSpacing(Object args[], int numArgs); |
|
void opSetFont(Object args[], int numArgs); |
|
void opSetTextLeading(Object args[], int numArgs); |
|
void opSetTextRender(Object args[], int numArgs); |
|
void opSetTextRise(Object args[], int numArgs); |
|
void opSetWordSpacing(Object args[], int numArgs); |
|
void opSetHorizScaling(Object args[], int numArgs); |
|
|
|
|
|
void opTextMove(Object args[], int numArgs); |
|
void opTextMoveSet(Object args[], int numArgs); |
|
void opSetTextMatrix(Object args[], int numArgs); |
|
void opTextNextLine(Object args[], int numArgs); |
|
|
|
|
|
void opShowText(Object args[], int numArgs); |
|
void opMoveShowText(Object args[], int numArgs); |
|
void opMoveSetShowText(Object args[], int numArgs); |
|
void opShowSpaceText(Object args[], int numArgs); |
|
void doShowText(const GooString *s); |
|
void doIncCharCount(const GooString *s); |
|
|
|
|
|
void opXObject(Object args[], int numArgs); |
|
void doImage(Object *ref, Stream *str, bool inlineImg); |
|
void doForm(Object *str); |
|
|
|
|
|
void opBeginImage(Object args[], int numArgs); |
|
Stream *buildImageStream(); |
|
void opImageData(Object args[], int numArgs); |
|
void opEndImage(Object args[], int numArgs); |
|
|
|
|
|
void opSetCharWidth(Object args[], int numArgs); |
|
void opSetCacheDevice(Object args[], int numArgs); |
|
|
|
|
|
void opBeginIgnoreUndef(Object args[], int numArgs); |
|
void opEndIgnoreUndef(Object args[], int numArgs); |
|
|
|
|
|
void opBeginMarkedContent(Object args[], int numArgs); |
|
void opEndMarkedContent(Object args[], int numArgs); |
|
void opMarkPoint(Object args[], int numArgs); |
|
GfxState *saveStateStack(); |
|
void restoreStateStack(GfxState *oldState); |
|
bool contentIsHidden(); |
|
void pushMarkedContent(); |
|
void popMarkedContent(); |
|
}; |
|
|
|
#endif |
|
|