X-Git-Url: http://git.asbjorn.biz/?a=blobdiff_plain;f=lib%2Fxpdf%2FGFXOutputDev.cc;h=45a0a923f8b074eef30a8baac72f0f5d4746835d;hb=66f6d2a40bed5716c469f0e2c8de1cc13e0022a2;hp=c412a8db6dc66104a61e6d37c0d1182718219d49;hpb=7698e805046e0f7c99813b916df2539408fdad4f;p=swftools.git diff --git a/lib/xpdf/GFXOutputDev.cc b/lib/xpdf/GFXOutputDev.cc index c412a8d..45a0a92 100644 --- a/lib/xpdf/GFXOutputDev.cc +++ b/lib/xpdf/GFXOutputDev.cc @@ -170,6 +170,8 @@ GFXOutputDev::GFXOutputDev(parameter_t*p) this->type3Warning = 0; this->user_movex = 0; this->user_movey = 0; + this->clipmovex = 0; + this->clipmovey = 0; this->user_clipx1 = 0; this->user_clipy1 = 0; this->user_clipx2 = 0; @@ -253,8 +255,9 @@ static char*getFontName(GfxFont*font) Ref*r=font->getID(); sprintf(buf, "UFONT%d", r->num); fontid = strdup(buf); + } else { + fontid = strdup(fname); } - fontid = strdup(fname); char*fontname= 0; char* plus = strchr(fontid, '+'); @@ -555,7 +558,7 @@ gfxline_t* gfxPath_to_gfxline(GfxState*state, GfxPath*path, int closed, int user void GFXOutputDev::stroke(GfxState *state) { GfxPath * path = state->getPath(); - gfxline_t*line= gfxPath_to_gfxline(state, path, 0, user_movex, user_movey); + gfxline_t*line= gfxPath_to_gfxline(state, path, 0, user_movex + clipmovex, user_movey + clipmovey); strokeGfxline(state, line); gfxline_free(line); } @@ -667,7 +670,7 @@ void GFXOutputDev::fillGfxLine(GfxState *state, gfxline_t*line) void GFXOutputDev::fill(GfxState *state) { GfxPath * path = state->getPath(); - gfxline_t*line= gfxPath_to_gfxline(state, path, 1, user_movex, user_movey); + gfxline_t*line= gfxPath_to_gfxline(state, path, 1, user_movex + clipmovex, user_movey + clipmovey); fillGfxLine(state, line); gfxline_free(line); } @@ -676,7 +679,7 @@ void GFXOutputDev::eoFill(GfxState *state) GfxPath * path = state->getPath(); gfxcolor_t col = getFillColor(state); - gfxline_t*line= gfxPath_to_gfxline(state, path, 1, user_movex, user_movey); + gfxline_t*line= gfxPath_to_gfxline(state, path, 1, user_movex + clipmovex, user_movey + clipmovey); if(getLogLevel() >= LOGLEVEL_TRACE) { msg(" eofill\n"); @@ -690,7 +693,7 @@ void GFXOutputDev::eoFill(GfxState *state) void GFXOutputDev::clip(GfxState *state) { GfxPath * path = state->getPath(); - gfxline_t*line = gfxPath_to_gfxline(state, path, 1, user_movex, user_movey); + gfxline_t*line = gfxPath_to_gfxline(state, path, 1, user_movex + clipmovex, user_movey + clipmovey); clipToGfxLine(state, line); gfxline_free(line); } @@ -708,7 +711,7 @@ void GFXOutputDev::clipToGfxLine(GfxState *state, gfxline_t*line) void GFXOutputDev::eoClip(GfxState *state) { GfxPath * path = state->getPath(); - gfxline_t*line = gfxPath_to_gfxline(state, path, 1, user_movex, user_movey); + gfxline_t*line = gfxPath_to_gfxline(state, path, 1, user_movex + clipmovex, user_movey + clipmovey); if(getLogLevel() >= LOGLEVEL_TRACE) { msg(" eoclip\n"); @@ -976,8 +979,8 @@ void GFXOutputDev::drawChar(GfxState *state, double x, double y, gfxmatrix_t m = this->current_font_matrix; state->transform(x, y, &m.tx, &m.ty); - m.tx += user_movex; - m.ty += user_movey; + m.tx += user_movex + clipmovex; + m.ty += user_movey + clipmovey; if(render == RENDER_FILL) { device->drawchar(device, current_gfxfont, charid, &col, &m); @@ -1084,6 +1087,11 @@ void GFXOutputDev::endType3Char(GfxState *state) void GFXOutputDev::startFrame(int width, int height) { + if(outer_clip_box) { + device->endclip(device); + outer_clip_box = 0; + } + device->startpage(device, width, height); } @@ -1113,23 +1121,21 @@ void GFXOutputDev::startPage(int pageNum, GfxState *state, double crop_x1, doubl if(x2clipmovex = -(int)x1; + this->clipmovey = -(int)y1; + /* apply user clip box */ if(user_clipx1|user_clipy1|user_clipx2|user_clipy2) { /*if(user_clipx1 > x1)*/ x1 = user_clipx1; /*if(user_clipx2 < x2)*/ x2 = user_clipx2; /*if(user_clipy1 > y1)*/ y1 = user_clipy1; /*if(user_clipy2 < y2)*/ y2 = user_clipy2; + msg(" Using user clip box %f/%f/%f/%f",x1,y1,x2,y2); } //msg(" Bounding box is (%f,%f)-(%f,%f) [shifted by %d/%d]", x1,y1,x2,y2, user_movex, user_movey); - if(outer_clip_box) { - device->endclip(device); - outer_clip_box = 0; - } - - msg(" processing PDF page %d (%dx%d:%d:%d) (move:%d:%d)", pageNum, (int)x2-(int)x1,(int)y2-(int)y1, (int)x1, (int)y1, user_movex, user_movey); + msg(" processing PDF page %d (%dx%d:%d:%d) (move:%d:%d)", pageNum, (int)x2-(int)x1,(int)y2-(int)y1, (int)x1, (int)y1, user_movex + clipmovex, user_movey + clipmovey); if(rot!=0) msg(" page is rotated %d degrees\n", rot); @@ -1153,28 +1159,28 @@ void GFXOutputDev::drawLink(Link *link, Catalog *catalog) link->getRect(&x1, &y1, &x2, &y2); cvtUserToDev(x1, y1, &x, &y); points[0].type = gfx_moveTo; - points[0].x = points[4].x = x + user_movex; - points[0].y = points[4].y = y + user_movey; + points[0].x = points[4].x = x + user_movex + clipmovex; + points[0].y = points[4].y = y + user_movey + clipmovey; points[0].next = &points[1]; cvtUserToDev(x2, y1, &x, &y); points[1].type = gfx_lineTo; - points[1].x = x + user_movex; - points[1].y = y + user_movey; + points[1].x = x + user_movex + clipmovex; + points[1].y = y + user_movey + clipmovey; points[1].next = &points[2]; cvtUserToDev(x2, y2, &x, &y); points[2].type = gfx_lineTo; - points[2].x = x + user_movex; - points[2].y = y + user_movey; + points[2].x = x + user_movex + clipmovex; + points[2].y = y + user_movey + clipmovey; points[2].next = &points[3]; cvtUserToDev(x1, y2, &x, &y); points[3].type = gfx_lineTo; - points[3].x = x + user_movex; - points[3].y = y + user_movey; + points[3].x = x + user_movex + clipmovex; + points[3].y = y + user_movey + clipmovey; points[3].next = &points[4]; cvtUserToDev(x1, y1, &x, &y); points[4].type = gfx_lineTo; - points[4].x = x + user_movex; - points[4].y = y + user_movey; + points[4].x = x + user_movex + clipmovex; + points[4].y = y + user_movey + clipmovey; points[4].next = 0; msg(" drawlink %.2f/%.2f %.2f/%.2f %.2f/%.2f %.2f/%.2f\n", @@ -1213,9 +1219,17 @@ void GFXOutputDev::drawLink(Link *link, Catalog *catalog) case actionGoToR: { type = "GoToR"; LinkGoToR*l = (LinkGoToR*)action; - GString*g = l->getNamedDest(); - if(g) + GString*g = l->getFileName(); + if(g) s = strdup(g->getCString()); + if(!s) { + /* if the GoToR link has no filename, then + try to find a refernce in the *local* + file */ + GString*g = l->getNamedDest(); + if(g) + s = strdup(g->getCString()); + } } break; case actionNamed: { @@ -1410,7 +1424,7 @@ void GFXOutputDev::updateStrokeColor(GfxState *state) void FoFiWrite(void *stream, char *data, int len) { - fwrite(data, len, 1, (FILE*)stream); + int ret = fwrite(data, len, 1, (FILE*)stream); } char*GFXOutputDev::writeEmbeddedFontToFile(XRef*ref, GfxFont*font) @@ -1716,6 +1730,10 @@ int GFXOutputDev::setGfxFont(char*id, char*name, char*filename, double maxSize) msg(" Loading %s...", filename); font = gfxfont_load(id, filename, quality); + if(!font) { + msg(" Couldn't load Font %s (%s)", filename, id); + return 0; + } msg(" Font %s (%s) loaded successfully", filename, id); l = new fontlist_t; @@ -2042,10 +2060,10 @@ void GFXOutputDev::drawGeneralImage(GfxState *state, Object *ref, Stream *str, return; } - state->transform(0, 1, &x1, &y1); x1 += user_movex; y1 += user_movey; - state->transform(0, 0, &x2, &y2); x2 += user_movex; y2 += user_movey; - state->transform(1, 0, &x3, &y3); x3 += user_movex; y3 += user_movey; - state->transform(1, 1, &x4, &y4); x4 += user_movex; y4 += user_movey; + state->transform(0, 1, &x1, &y1); x1 += user_movex + clipmovex; y1 += user_movey + clipmovey; + state->transform(0, 0, &x2, &y2); x2 += user_movex + clipmovex; y2 += user_movey + clipmovey; + state->transform(1, 0, &x3, &y3); x3 += user_movex + clipmovex; y3 += user_movey + clipmovey; + state->transform(1, 1, &x4, &y4); x4 += user_movex + clipmovex; y4 += user_movey + clipmovey; if(!pbminfo && !(str->getKind()==strDCT)) { @@ -2218,8 +2236,6 @@ void GFXOutputDev::drawImageMask(GfxState *state, Object *ref, Stream *str, int width, int height, GBool invert, GBool inlineImg) { - if(states[statepos].textRender & 4) //clipped - return; msg(" drawImageMask %dx%d, invert=%d inline=%d", width, height, invert, inlineImg); drawGeneralImage(state,ref,str,width,height,0,invert,inlineImg,1, 0, 0,0,0,0, 0); } @@ -2228,9 +2244,6 @@ void GFXOutputDev::drawImage(GfxState *state, Object *ref, Stream *str, int width, int height, GfxImageColorMap *colorMap, int *maskColors, GBool inlineImg) { - if(states[statepos].textRender & 4) //clipped - return; - msg(" drawImage %dx%d, %s, %s, inline=%d", width, height, colorMap?"colorMap":"no colorMap", maskColors?"maskColors":"no maskColors", @@ -2247,9 +2260,6 @@ void GFXOutputDev::drawMaskedImage(GfxState *state, Object *ref, Stream *str, Stream *maskStr, int maskWidth, int maskHeight, GBool maskInvert) { - if(states[statepos].textRender & 4) //clipped - return; - msg(" drawMaskedImage %dx%d, %s, %dx%d mask", width, height, colorMap?"colorMap":"no colorMap", maskWidth, maskHeight); @@ -2266,9 +2276,6 @@ void GFXOutputDev::drawSoftMaskedImage(GfxState *state, Object *ref, Stream *str int maskWidth, int maskHeight, GfxImageColorMap *maskColorMap) { - if(states[statepos].textRender & 4) //clipped - return; - msg(" drawSoftMaskedImage %dx%d, %s, %dx%d mask", width, height, colorMap?"colorMap":"no colorMap", maskWidth, maskHeight);