From: Piotr Caban piotr@codeweavers.com
--- dlls/wineps.drv/ps.c | 85 +++++++++++++++++++++++------------------ dlls/wineps.drv/psdrv.h | 1 + 2 files changed, 49 insertions(+), 37 deletions(-)
diff --git a/dlls/wineps.drv/ps.c b/dlls/wineps.drv/ps.c index 744bda62497..8d3db610647 100644 --- a/dlls/wineps.drv/ps.c +++ b/dlls/wineps.drv/ps.c @@ -54,7 +54,7 @@ static const char cups_ap_d_inputslot[] = "%cupsJobTicket: AP_D_InputSlot=\n"; / static const char psheader[] = /* title llx lly urx ury orientation */ "%%%%Creator: Wine PostScript Driver\n" "%%%%Title: %s\n" -"%%%%BoundingBox: %d %d %d %d\n" +"%%%%BoundingBox: (atend)\n" "%%%%Pages: (atend)\n" "%%%%EndComments\n";
@@ -110,6 +110,7 @@ static const char psendpage[] =
static const char psfooter[] = /* pages */ "%%%%Trailer\n" +"%%%%BoundingBox: %ld %ld %ld %ld\n" "%%%%Pages: %d\n" "%%%%EOF\n";
@@ -400,7 +401,6 @@ INT PSDRV_WriteHeader( print_ctx *ctx, LPCWSTR title ) INPUTSLOT *slot = find_slot( ctx->pi->ppd, &ctx->Devmode->dmPublic ); PAGESIZE *page = find_pagesize( ctx->pi->ppd, &ctx->Devmode->dmPublic ); DUPLEX *duplex = find_duplex( ctx->pi->ppd, &ctx->Devmode->dmPublic ); - int llx, lly, urx, ury; int ret, len;
struct ticket_info ticket_info = { page, duplex }; @@ -419,46 +419,14 @@ INT PSDRV_WriteHeader( print_ctx *ctx, LPCWSTR title )
escaped_title = escape_title(title); buf = HeapAlloc( GetProcessHeap(), 0, sizeof(psheader) + - strlen(escaped_title) + 30 ); + strlen(escaped_title) ); if(!buf) { WARN("HeapAlloc failed\n"); HeapFree(GetProcessHeap(), 0, escaped_title); return 0; }
- /* BBox co-ords are in default user co-ord system so urx < ury even in - landscape mode */ - if ((ctx->Devmode->dmPublic.dmFields & DM_PAPERSIZE) && page) - { - if (page->ImageableArea) - { - llx = page->ImageableArea->llx; - lly = page->ImageableArea->lly; - urx = page->ImageableArea->urx; - ury = page->ImageableArea->ury; - } - else - { - llx = lly = 0; - urx = page->PaperDimension->x; - ury = page->PaperDimension->y; - } - } - else if ((ctx->Devmode->dmPublic.dmFields & DM_PAPERLENGTH) && - (ctx->Devmode->dmPublic.dmFields & DM_PAPERWIDTH)) - { - /* Devmode sizes in 1/10 mm */ - llx = lly = 0; - urx = ctx->Devmode->dmPublic.dmPaperWidth * 72.0 / 254.0; - ury = ctx->Devmode->dmPublic.dmPaperLength * 72.0 / 254.0; - } - else - { - llx = lly = urx = ury = 0; - } - /* FIXME should do something better with BBox */ - - sprintf(buf, psheader, escaped_title, llx, lly, urx, ury); + sprintf(buf, psheader, escaped_title);
HeapFree(GetProcessHeap(), 0, escaped_title);
@@ -498,7 +466,8 @@ INT PSDRV_WriteFooter( print_ctx *ctx ) return 0; }
- sprintf(buf, psfooter, ctx->job.PageNo); + sprintf(buf, psfooter, ctx->bbox.left, ctx->bbox.top, + ctx->bbox.right, ctx->bbox.bottom, ctx->job.PageNo);
if( write_spool( ctx, buf, strlen(buf) ) != strlen(buf) ) { WARN("WriteSpool error\n"); @@ -520,15 +489,57 @@ INT PSDRV_WriteEndPage( print_ctx *ctx ) }
+static void get_bounding_box( print_ctx *ctx, RECT *bbox) +{ + PAGESIZE *page; + + /* BBox co-ords are in default user co-ord system so urx < ury even in + landscape mode */ + if ((ctx->Devmode->dmPublic.dmFields & DM_PAPERSIZE) && + (page = find_pagesize( ctx->pi->ppd, &ctx->Devmode->dmPublic ))) + { + if (page->ImageableArea) + { + bbox->left = page->ImageableArea->llx; + bbox->top = page->ImageableArea->lly; + bbox->right = page->ImageableArea->urx; + bbox->bottom = page->ImageableArea->ury; + } + else + { + bbox->left = bbox->top = 0; + bbox->right = page->PaperDimension->x; + bbox->bottom = page->PaperDimension->y; + } + } + else if ((ctx->Devmode->dmPublic.dmFields & DM_PAPERLENGTH) && + (ctx->Devmode->dmPublic.dmFields & DM_PAPERWIDTH)) + { + /* Devmode sizes in 1/10 mm */ + bbox->left = bbox->top = 0; + bbox->right = ctx->Devmode->dmPublic.dmPaperWidth * 72.0 / 254.0; + bbox->bottom = ctx->Devmode->dmPublic.dmPaperLength * 72.0 / 254.0; + } + else + { + bbox->left = bbox->top = bbox->right = bbox->bottom = 0; + } + /* FIXME should do something better with BBox */ +} +
INT PSDRV_WriteNewPage( print_ctx *ctx ) { signed int xtrans, ytrans, rotation; char buf[256], name[16]; + RECT bbox;
sprintf(name, "%d", ctx->job.PageNo);
+ get_bounding_box( ctx, &bbox ); + UnionRect( &ctx->bbox, &bbox, &ctx->bbox ); + if(ctx->Devmode->dmPublic.dmOrientation == DMORIENT_LANDSCAPE) { if(ctx->pi->ppd->LandscapeOrientation == -90) { xtrans = GetDeviceCaps(ctx->hdc, PHYSICALHEIGHT) - diff --git a/dlls/wineps.drv/psdrv.h b/dlls/wineps.drv/psdrv.h index 31adc36adfc..d1ac2cc06cd 100644 --- a/dlls/wineps.drv/psdrv.h +++ b/dlls/wineps.drv/psdrv.h @@ -368,6 +368,7 @@ typedef struct PSDRV_DEVMODE *Devmode; PRINTERINFO *pi; int pathdepth; + RECT bbox; } print_ctx;
extern print_ctx *create_print_ctx( HDC hdc, const WCHAR *device,