static int EndPage(PSEngine *psEngine) { char *line= psEngine->line; int xll, yll, xur, yur; if (EndClip(psEngine)) return 1; if ((psEngine->nchars && PutLine(psEngine)) || Append(psEngine, "PG restore") || PutLine(psEngine)) return 1; if (Append(psEngine, "showpage") || PutLine(psEngine)) return 1; if (Append(psEngine, "end") || PutLine(psEngine)) return 1; if (Append(psEngine, "%%PageTrailer") || PutLine(psEngine)) return 1; GetEPSFBox(psEngine->e.landscape, &psEngine->pageBB, &xll, &yll, &xur, &yur); if (xll < psEngine->docBB.xll) psEngine->docBB.xll= xll; if (yll < psEngine->docBB.yll) psEngine->docBB.yll= yll; if (xur > psEngine->docBB.xur) psEngine->docBB.xur= xur; if (yur > psEngine->docBB.yur) psEngine->docBB.yur= yur; sprintf(line, "%%%%PageBoundingBox: %d %d %d %d", xll, yll, xur, yur); if (Append(psEngine, line) || PutLine(psEngine)) return 1; psEngine->currentPage++; psEngine->e.marked= 0; SetPageDefaults(psEngine); if (psEngine->file!=pf_stdout) p_fflush(psEngine->file); return 0; }
static int BeginClip(PSEngine *psEngine, GpTransform *trans) { GpReal x[2], y[2]; GpPoint *points; int xll, yll, xur, yur; GpBox *port= &trans->viewport; GpBox *box= &psEngine->clipBox; if (!psEngine->e.marked && BeginPage(psEngine)) return 1; if (psEngine->curClip) { if (port->xmin==box->xmin && port->xmax==box->xmax && port->ymin==box->ymin && port->ymax==box->ymax) return 0; if (EndClip(psEngine)) return 1; } x[0]= trans->window.xmin; x[1]= trans->window.xmax; y[0]= trans->window.ymin; y[1]= trans->window.ymax; GpIntPoints(&psEngine->e.map, 3, 2, x, y, &points); if (points[0].x > points[1].x) { xll= points[1].x; xur= points[0].x; } else { xll= points[0].x; xur= points[1].x; } if (points[0].y > points[1].y) { yll= points[1].y; yur= points[0].y; } else { yll= points[0].y; yur= points[1].y; } sprintf(line, "%d %d %d %d CLON", xur-xll, yur-yll, xll, yll); if (Append(psEngine, line)) return 1; psEngine->curClip= 1; *box= *port; /* Must save state at time of CLON, since CLOF does grestore */ psEngine->clipColor= psEngine->curColor; psEngine->clipType= psEngine->curType; psEngine->clipWidth= psEngine->curWidth; psEngine->clipFont= psEngine->curFont; psEngine->clipHeight= psEngine->curHeight; /* Note that text alignment/opacity is not affected by grestore */ /* Expand page boundary to include clip boundary */ if (xll < psEngine->pageBB.xll) psEngine->pageBB.xll= xll; if (yll < psEngine->pageBB.yll) psEngine->pageBB.yll= yll; if (xur > psEngine->pageBB.xur) psEngine->pageBB.xur= xur; if (yur > psEngine->pageBB.yur) psEngine->pageBB.yur= yur; return 0; }
~ClipRect() { DeleteObject(m_hNewRegionClip); EndClip(); }
static int CheckClip(PSEngine *psEngine) { if (gistClip) return BeginClip(psEngine, &gistT); else if (psEngine->curClip) return EndClip(psEngine); return 0; }