From 71300e23857ddb8d36e7f0691d6e8c1ad925322e Mon Sep 17 00:00:00 2001 From: Piotr Caban Date: Tue, 4 Jun 2024 21:21:45 +0200 Subject: [PATCH] wineps.drv: Add partial support for changing page size. --- dlls/wineps.drv/printproc.c | 2 ++ dlls/wineps.drv/ps.c | 14 ++++++++++++-- dlls/wineps.drv/psdrv.h | 1 + 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/dlls/wineps.drv/printproc.c b/dlls/wineps.drv/printproc.c index db2979f0fbe..84f4b9f5900 100644 --- a/dlls/wineps.drv/printproc.c +++ b/dlls/wineps.drv/printproc.c @@ -3110,6 +3110,8 @@ BOOL WINAPI PrintDocumentOnPrintProcessor(HANDLE pp, WCHAR *doc_name) if (ret) ret = PSDRV_ResetDC(data->ctx, devmode); + if (ret && devmode && (devmode->dmFields & DM_PAPERSIZE)) + ret = PSDRV_WritePageSize(data->ctx); free(devmode); if (!ret) goto cleanup; diff --git a/dlls/wineps.drv/ps.c b/dlls/wineps.drv/ps.c index 9896ea46bc7..8e52a97867a 100644 --- a/dlls/wineps.drv/ps.c +++ b/dlls/wineps.drv/ps.c @@ -397,6 +397,17 @@ static void write_cups_job_ticket( print_ctx *ctx, const struct ticket_info *inf write_spool( ctx, cups_ap_d_inputslot, sizeof(cups_ap_d_inputslot) - 1 ); } +INT PSDRV_WritePageSize( print_ctx *ctx ) +{ + PAGESIZE *page = find_pagesize( ctx->pi->ppd, &ctx->Devmode->dmPublic ); + + if (page && page->InvocationString) + PSDRV_WriteFeature( ctx, "*PageSize", page->Name, page->InvocationString ); + else + WARN("Page size not set\n"); + return 1; +} + INT PSDRV_WriteHeader( print_ctx *ctx, LPCWSTR title ) { char *buf, *escaped_title; @@ -444,8 +455,7 @@ INT PSDRV_WriteHeader( print_ctx *ctx, LPCWSTR title ) if (slot && slot->InvocationString) PSDRV_WriteFeature( ctx, "*InputSlot", slot->Name, slot->InvocationString ); - if (page && page->InvocationString) - PSDRV_WriteFeature( ctx, "*PageSize", page->Name, page->InvocationString ); + PSDRV_WritePageSize( ctx ); if (duplex && duplex->InvocationString) PSDRV_WriteFeature( ctx, "*Duplex", duplex->Name, duplex->InvocationString ); diff --git a/dlls/wineps.drv/psdrv.h b/dlls/wineps.drv/psdrv.h index d1ac2cc06cd..2c4703de942 100644 --- a/dlls/wineps.drv/psdrv.h +++ b/dlls/wineps.drv/psdrv.h @@ -466,6 +466,7 @@ extern char PSDRV_UnicodeToANSI(int u); extern INT PSDRV_WriteHeader( print_ctx *ctx, LPCWSTR title ); extern INT PSDRV_WriteFooter( print_ctx *ctx ); +extern INT PSDRV_WritePageSize( print_ctx *ctx ); extern INT PSDRV_WriteNewPage( print_ctx *ctx ); extern INT PSDRV_WriteEndPage( print_ctx *ctx ); extern BOOL PSDRV_WriteMoveTo(print_ctx *ctx, INT x, INT y);