X-Git-Url: https://www.fi.muni.cz/~kas/git//home/kas/public_html/git/?a=blobdiff_plain;f=pdf%2Fxpdf%2FGfx.cc;h=63896d89120e248d6f961de2db7009016eccbdc6;hb=884f739665dc56e66f51e104350f2affd33f2dd8;hp=0b00f9116d26d764a783057ade84fbb401c24e0c;hpb=2a393c134fe3fe8eb85bf818cb7ad6ae4396322a;p=evince.git diff --git a/pdf/xpdf/Gfx.cc b/pdf/xpdf/Gfx.cc index 0b00f911..63896d89 100644 --- a/pdf/xpdf/Gfx.cc +++ b/pdf/xpdf/Gfx.cc @@ -2,20 +2,22 @@ // // Gfx.cc // -// Copyright 1996-2002 Glyph & Cog, LLC +// Copyright 1996-2003 Glyph & Cog, LLC // //======================================================================== -#ifdef __GNUC__ +#include + +#ifdef USE_GCC_PRAGMAS #pragma implementation #endif -#include #include #include #include #include #include "gmem.h" +#include "GlobalParams.h" #include "CharTypes.h" #include "Object.h" #include "Array.h" @@ -381,12 +383,13 @@ GBool GfxResources::lookupGState(char *name, Object *obj) { Gfx::Gfx(XRef *xrefA, OutputDev *outA, int pageNum, Dict *resDict, double dpi, PDFRectangle *box, GBool crop, PDFRectangle *cropBox, int rotate, - GBool printCommandsA) { + GBool (*abortCheckCbkA)(void *data), + void *abortCheckCbkDataA) { int i; xref = xrefA; subPage = gFalse; - printCommands = printCommandsA; + printCommands = globalParams->getPrintCommands(); // start the resource stack res = new GfxResources(xref, resDict, NULL); @@ -403,6 +406,8 @@ Gfx::Gfx(XRef *xrefA, OutputDev *outA, int pageNum, Dict *resDict, double dpi, for (i = 0; i < 6; ++i) { baseMatrix[i] = state->getCTM()[i]; } + abortCheckCbk = abortCheckCbkA; + abortCheckCbkData = abortCheckCbkDataA; // set crop box if (crop) { @@ -418,12 +423,14 @@ Gfx::Gfx(XRef *xrefA, OutputDev *outA, int pageNum, Dict *resDict, double dpi, } Gfx::Gfx(XRef *xrefA, OutputDev *outA, Dict *resDict, - PDFRectangle *box, GBool crop, PDFRectangle *cropBox) { + PDFRectangle *box, GBool crop, PDFRectangle *cropBox, + GBool (*abortCheckCbkA)(void *data), + void *abortCheckCbkDataA) { int i; xref = xrefA; subPage = gTrue; - printCommands = gFalse; + printCommands = globalParams->getPrintCommands(); // start the resource stack res = new GfxResources(xref, resDict, NULL); @@ -437,6 +444,8 @@ Gfx::Gfx(XRef *xrefA, OutputDev *outA, Dict *resDict, for (i = 0; i < 6; ++i) { baseMatrix[i] = state->getCTM()[i]; } + abortCheckCbk = abortCheckCbkA; + abortCheckCbkData = abortCheckCbkDataA; // set crop box if (crop) { @@ -494,11 +503,11 @@ void Gfx::display(Object *obj, GBool topLevel) { void Gfx::go(GBool topLevel) { Object obj; Object args[maxArgs]; - int numArgs; - int i; + int numArgs, i; + int lastAbortCheck; // scan a sequence of objects - updateLevel = 0; + updateLevel = lastAbortCheck = 0; numArgs = 0; parser->getObj(&obj); while (!obj.isEOF()) { @@ -526,6 +535,16 @@ void Gfx::go(GBool topLevel) { updateLevel = 0; } + // check for an abort + if (abortCheckCbk) { + if (updateLevel - lastAbortCheck > 10) { + if ((*abortCheckCbk)(abortCheckCbkData)) { + break; + } + lastAbortCheck = updateLevel; + } + } + // got an argument - save it } else if (numArgs < maxArgs) { args[numArgs++] = obj; @@ -575,7 +594,7 @@ void Gfx::execOp(Object *cmd, Object args[], int numArgs) { int i; // find operator - name = cmd->getName(); + name = cmd->getCmd(); if (!(op = findOp(name))) { if (ignoreUndef == 0) error(getPos(), "Unknown operator '%s'", name); @@ -1806,7 +1825,7 @@ void Gfx::doRadialShFill(GfxRadialShading *shading) { } void Gfx::doEndPath() { - if (state->isPath() && clip != clipNone) { + if (state->isCurPt() && clip != clipNone) { state->clip(); if (clip == clipNormal) { out->clip(state); @@ -2019,7 +2038,7 @@ void Gfx::doShowText(GString *s) { double riseX, riseY; CharCode code; Unicode u[8]; - double x, y, dx, dy, dx2, dy2, curX, curY, tdx, tdy; + double x, y, dx, dy, dx2, dy2, curX, curY, tdx, tdy, lineX, lineY; double originX, originY, tOriginX, tOriginY; double oldCTM[6], newCTM[6]; double *mat; @@ -2063,6 +2082,8 @@ void Gfx::doShowText(GString *s) { state->textTransformDelta(0, state->getRise(), &riseX, &riseY); curX = state->getCurX(); curY = state->getCurY(); + lineX = state->getLineX(); + lineY = state->getLineY(); oldParser = parser; p = s->getCString(); len = s->getLength(); @@ -2101,10 +2122,11 @@ void Gfx::doShowText(GString *s) { state = state->restore(); out->restoreState(state); // GfxState::restore() does *not* restore the current position, - // so we track it here with (curX, curY) + // so we deal with it here using (curX, curY) and (lineX, lineY) curX += tdx; curY += tdy; state->moveTo(curX, curY); + state->textSetPos(lineX, lineY); p += n; len -= n; }