From: Piotr Caban piotr@codeweavers.com
--- dlls/wineps.drv/psdrv.h | 9 --------- dlls/wineps.drv/unixlib.c | 15 +++++++++++---- 2 files changed, 11 insertions(+), 13 deletions(-)
diff --git a/dlls/wineps.drv/psdrv.h b/dlls/wineps.drv/psdrv.h index 1d6ff1c69dc..d16e135aeda 100644 --- a/dlls/wineps.drv/psdrv.h +++ b/dlls/wineps.drv/psdrv.h @@ -143,15 +143,6 @@ typedef struct _tagPAGESIZE { WORD WinPage; /*eg DMPAPER_A4. Doesn't really belong here */ } PAGESIZE;
- -/* For BANDINFO Escape */ -typedef struct _BANDINFOSTRUCT -{ - BOOL GraphicsFlag; - BOOL TextFlag; - RECT GraphicsRect; -} BANDINFOSTRUCT, *PBANDINFOSTRUCT; - typedef struct { struct list entry; diff --git a/dlls/wineps.drv/unixlib.c b/dlls/wineps.drv/unixlib.c index 76e60ca1596..96b8df48f19 100644 --- a/dlls/wineps.drv/unixlib.c +++ b/dlls/wineps.drv/unixlib.c @@ -81,6 +81,13 @@ struct printer_info
static struct list printer_info_list = LIST_INIT(printer_info_list);
+struct band_info +{ + BOOL graphics_flag; + BOOL text_flag; + RECT graphics_rect; +}; + typedef struct { struct gdi_physdev dev; @@ -714,11 +721,11 @@ static int CDECL ext_escape(PHYSDEV dev, int escape, int input_size, const void } case BANDINFO: { - BANDINFOSTRUCT *ibi = (BANDINFOSTRUCT*)input; - BANDINFOSTRUCT *obi = (BANDINFOSTRUCT*)output; + struct band_info *ibi = (struct band_info *)input; + struct band_info *obi = (struct band_info *)output;
- FIXME("BANDINFO(graphics %d, text %d, rect %s), stub!\n", ibi->GraphicsFlag, - ibi->TextFlag, wine_dbgstr_rect(&ibi->GraphicsRect)); + FIXME("BANDINFO(graphics %d, text %d, rect %s), stub!\n", ibi->graphics_flag, + ibi->text_flag, wine_dbgstr_rect(&ibi->graphics_rect)); *obi = *ibi; return 1; }
From: Piotr Caban piotr@codeweavers.com
--- dlls/wineps.drv/builtin.c | 1 - dlls/wineps.drv/font.c | 1 - dlls/wineps.drv/init.c | 1 - dlls/wineps.drv/psdrv.h | 17 ++--------------- dlls/wineps.drv/unixlib.c | 1 - dlls/wineps.drv/unixlib.h | 18 ++++++++++++++++++ 6 files changed, 20 insertions(+), 19 deletions(-)
diff --git a/dlls/wineps.drv/builtin.c b/dlls/wineps.drv/builtin.c index d62d4fc134f..02b452b0a8b 100644 --- a/dlls/wineps.drv/builtin.c +++ b/dlls/wineps.drv/builtin.c @@ -31,7 +31,6 @@ #include "winternl.h"
#include "psdrv.h" -#include "unixlib.h" #include "wine/debug.h"
WINE_DEFAULT_DEBUG_CHANNEL(psdrv); diff --git a/dlls/wineps.drv/font.c b/dlls/wineps.drv/font.c index 869eb0ea9b6..74171c09530 100644 --- a/dlls/wineps.drv/font.c +++ b/dlls/wineps.drv/font.c @@ -30,7 +30,6 @@ #include "winternl.h"
#include "psdrv.h" -#include "unixlib.h" #include "wine/debug.h"
WINE_DEFAULT_DEBUG_CHANNEL(psdrv); diff --git a/dlls/wineps.drv/init.c b/dlls/wineps.drv/init.c index 78a72303708..9cbea031d48 100644 --- a/dlls/wineps.drv/init.c +++ b/dlls/wineps.drv/init.c @@ -31,7 +31,6 @@ #include "psdrv.h" #include "ddk/winddi.h" #include "ntf.h" -#include "unixlib.h" #include "winspool.h" #include "wine/debug.h"
diff --git a/dlls/wineps.drv/psdrv.h b/dlls/wineps.drv/psdrv.h index d16e135aeda..981ef6868dd 100644 --- a/dlls/wineps.drv/psdrv.h +++ b/dlls/wineps.drv/psdrv.h @@ -28,6 +28,8 @@ #include "wingdi.h" #include "winspool.h"
+#include "unixlib.h" + #include "wine/gdi_driver.h" #include "wine/list.h"
@@ -210,19 +212,6 @@ typedef struct { DUPLEX *DefaultDuplex; } PPD;
-typedef struct { - DEVMODEW dmPublic; - int default_resolution; - int landscape_orientation; - int duplex; - int input_slots; - int resolutions; - int page_sizes; - int font_subs; - int installed_fonts; - BYTE data[1]; -} PSDRV_DEVMODE; - typedef struct { struct list entry; @@ -554,7 +543,6 @@ extern void passthrough_leave(print_ctx *ctx) DECLSPEC_HIDDEN; setlocale(LC_NUMERIC,tmplocale); \ } while (0)
-#ifndef WINE_UNIX_LIB static inline WCHAR *strdupW( const WCHAR *str ) { int size; @@ -566,6 +554,5 @@ static inline WCHAR *strdupW( const WCHAR *str ) if (ret) memcpy( ret, str, size ); return ret; } -#endif
#endif diff --git a/dlls/wineps.drv/unixlib.c b/dlls/wineps.drv/unixlib.c index 96b8df48f19..7baffdcd09f 100644 --- a/dlls/wineps.drv/unixlib.c +++ b/dlls/wineps.drv/unixlib.c @@ -32,7 +32,6 @@ #include "winbase.h"
#include "ntf.h" -#include "psdrv.h" #include "unixlib.h" #include "ntgdi.h" #include "ddk/winddi.h" diff --git a/dlls/wineps.drv/unixlib.h b/dlls/wineps.drv/unixlib.h index e28a4416d09..235f48b5832 100644 --- a/dlls/wineps.drv/unixlib.h +++ b/dlls/wineps.drv/unixlib.h @@ -16,6 +16,9 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */
+#ifndef __PSDRV_UNIXLIB_H +#define __PSDRV_UNIXLIB_H + #include "ntuser.h" #include "wine/unixlib.h"
@@ -71,6 +74,19 @@ struct installed_font char name[LF_FACESIZE]; };
+typedef struct { + DEVMODEW dmPublic; + int default_resolution; + int landscape_orientation; + int duplex; + int input_slots; + int resolutions; + int page_sizes; + int font_subs; + int installed_fonts; + BYTE data[1]; +} PSDRV_DEVMODE; + /* Unix calls */ enum wineps_funcs { @@ -94,3 +110,5 @@ struct open_dc_params PSDRV_DEVMODE *def_devmode; HDC hdc; }; + +#endif
From: Piotr Caban piotr@codeweavers.com
--- dlls/wineps.drv/unixlib.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/dlls/wineps.drv/unixlib.c b/dlls/wineps.drv/unixlib.c index 7baffdcd09f..d3d3d2ee68f 100644 --- a/dlls/wineps.drv/unixlib.c +++ b/dlls/wineps.drv/unixlib.c @@ -307,7 +307,7 @@ static inline int paper_size_from_points(float size) return size * 254 / 72; }
-static const struct input_slot *unix_find_slot(const struct printer_info *pi, +static const struct input_slot *find_slot(const struct printer_info *pi, const DEVMODEW *dm) { const struct input_slot *slot = (const struct input_slot *)pi->devmode->data; @@ -321,7 +321,7 @@ static const struct input_slot *unix_find_slot(const struct printer_info *pi, return NULL; }
-static const struct page_size *unix_find_pagesize(const struct printer_info *pi, +static const struct page_size *find_pagesize(const struct printer_info *pi, const DEVMODEW *dm) { const struct page_size *page; @@ -357,7 +357,7 @@ static void merge_devmodes(PSDRV_DEVMODE *dm1, const DEVMODEW *dm2, /* NB PaperWidth is always < PaperLength */ if (dm2->dmFields & DM_PAPERSIZE) { - const struct page_size *page = unix_find_pagesize(pi, dm2); + const struct page_size *page = find_pagesize(pi, dm2);
if (page) { @@ -414,7 +414,7 @@ static void merge_devmodes(PSDRV_DEVMODE *dm1, const DEVMODEW *dm2,
if (dm2->dmFields & DM_DEFAULTSOURCE) { - const struct input_slot *slot = unix_find_slot(pi, dm2); + const struct input_slot *slot = find_slot(pi, dm2);
if (slot) dm1->dmPublic.dmDefaultSource = dm2->dmDefaultSource; @@ -513,7 +513,7 @@ static void update_dev_caps(PSDRV_PDEVICE *pdev) }
if (pdev->devmode->dmPublic.dmFields & DM_PAPERSIZE) { - page = unix_find_pagesize(pdev->pi, &pdev->devmode->dmPublic); + page = find_pagesize(pdev->pi, &pdev->devmode->dmPublic);
if (!page) {
From: Piotr Caban piotr@codeweavers.com
--- dlls/wineps.drv/unixlib.c | 8 ++++---- dlls/wineps.drv/unixlib.h | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/dlls/wineps.drv/unixlib.c b/dlls/wineps.drv/unixlib.c index d3d3d2ee68f..26b1232f63e 100644 --- a/dlls/wineps.drv/unixlib.c +++ b/dlls/wineps.drv/unixlib.c @@ -75,7 +75,7 @@ struct printer_info { struct list entry; const WCHAR *name; - PSDRV_DEVMODE *devmode; + const PSDRV_DEVMODE *devmode; };
static struct list printer_info_list = LIST_INIT(printer_info_list); @@ -91,7 +91,7 @@ typedef struct { struct gdi_physdev dev; PSDRV_DEVMODE *devmode; - struct printer_info *pi; + const struct printer_info *pi;
/* builtin font info */ BOOL builtin; @@ -339,7 +339,7 @@ static const struct page_size *find_pagesize(const struct printer_info *pi, }
static void merge_devmodes(PSDRV_DEVMODE *dm1, const DEVMODEW *dm2, - struct printer_info *pi) + const struct printer_info *pi) { /* some sanity checks here on dm2 */
@@ -1008,7 +1008,7 @@ static struct font_data *find_font_data(const char *name) return NULL; }
-static struct font_data *find_builtin_font(PSDRV_DEVMODE *devmode, +static struct font_data *find_builtin_font(const PSDRV_DEVMODE *devmode, const WCHAR *facename, BOOL it, BOOL bd) { struct installed_font *installed_font; diff --git a/dlls/wineps.drv/unixlib.h b/dlls/wineps.drv/unixlib.h index 235f48b5832..1d908af78b4 100644 --- a/dlls/wineps.drv/unixlib.h +++ b/dlls/wineps.drv/unixlib.h @@ -107,7 +107,7 @@ struct open_dc_params const WCHAR *device; const DEVMODEW *devmode; const WCHAR *output; - PSDRV_DEVMODE *def_devmode; + const PSDRV_DEVMODE *def_devmode; HDC hdc; };
From: Piotr Caban piotr@codeweavers.com
--- dlls/wineps.drv/afm.c | 36 ++++++++++++++++++++++++++++++++---- dlls/wineps.drv/builtin.c | 39 --------------------------------------- dlls/wineps.drv/psdrv.h | 1 - 3 files changed, 32 insertions(+), 44 deletions(-)
diff --git a/dlls/wineps.drv/afm.c b/dlls/wineps.drv/afm.c index cd08cee55f8..ef4f4485b22 100644 --- a/dlls/wineps.drv/afm.c +++ b/dlls/wineps.drv/afm.c @@ -22,6 +22,7 @@ */
#include <string.h> +#include <stdlib.h>
#include "psdrv.h" #include "wine/debug.h" @@ -185,6 +186,33 @@ static void PSDRV_DumpFontList(void) return; }
+/****************************************************************************** + * PSDRV_UVMetrics + * + * Find the AFMMETRICS for a given UV. Returns NULL if the font does not + * have a glyph for the given UV. + */ +static int __cdecl MetricsByUV(const void *a, const void *b) +{ + return (int)(((const AFMMETRICS *)a)->UV - ((const AFMMETRICS *)b)->UV); +} + +static const AFMMETRICS *PSDRV_UVMetrics(LONG UV, const AFM *afm) +{ + AFMMETRICS key; + + /* + * Ugly work-around for symbol fonts. Wine is sending characters which + * belong in the Unicode private use range (U+F020 - U+F0FF) as ASCII + * characters (U+0020 - U+00FF). + */ + + if ((afm->Metrics->UV & 0xff00) == 0xf000 && UV < 0x100) + UV |= 0xf000; + + key.UV = UV; + return bsearch(&key, afm->Metrics, afm->NumofMetrics, sizeof(AFMMETRICS), MetricsByUV); +}
/******************************************************************************* * PSDRV_CalcAvgCharWidth @@ -208,7 +236,7 @@ static inline SHORT MeanCharWidth(const AFM *afm) return (SHORT)(w + 0.5); }
-static const struct { LONG UV; int weight; } UVweight[27] = +static const struct { LONG UV; int weight; } UVweight[] = { { 0x0061, 64 }, { 0x0062, 14 }, { 0x0063, 27 }, { 0x0064, 35 }, { 0x0065, 100 }, { 0x0066, 20 }, { 0x0067, 14 }, { 0x0068, 42 }, @@ -224,13 +252,13 @@ SHORT PSDRV_CalcAvgCharWidth(const AFM *afm) float w = 0.0; int i;
- for (i = 0; i < 27; ++i) + for (i = 0; i < ARRAY_SIZE(UVweight); ++i) { const AFMMETRICS *afmm;
afmm = PSDRV_UVMetrics(UVweight[i].UV, afm); - if (afmm->UV != UVweight[i].UV) /* UVMetrics returns first glyph */ - return MeanCharWidth(afm); /* in font if UV is missing */ + if (!afmm) + return MeanCharWidth(afm);
w += afmm->WX * (float)(UVweight[i].weight); } diff --git a/dlls/wineps.drv/builtin.c b/dlls/wineps.drv/builtin.c index 02b452b0a8b..028c185d59c 100644 --- a/dlls/wineps.drv/builtin.c +++ b/dlls/wineps.drv/builtin.c @@ -84,42 +84,3 @@ BOOL PSDRV_WriteBuiltinGlyphShow(print_ctx *ctx, LPCWSTR str, INT count)
return TRUE; } - -/****************************************************************************** - * PSDRV_UVMetrics - * - * Find the AFMMETRICS for a given UV. Returns first glyph in the font - * (space?) if the font does not have a glyph for the given UV. - */ -static int __cdecl MetricsByUV(const void *a, const void *b) -{ - return (int)(((const AFMMETRICS *)a)->UV - ((const AFMMETRICS *)b)->UV); -} - -const AFMMETRICS *PSDRV_UVMetrics(LONG UV, const AFM *afm) -{ - AFMMETRICS key; - const AFMMETRICS *needle; - - /* - * Ugly work-around for symbol fonts. Wine is sending characters which - * belong in the Unicode private use range (U+F020 - U+F0FF) as ASCII - * characters (U+0020 - U+00FF). - */ - - if ((afm->Metrics->UV & 0xff00) == 0xf000 && UV < 0x100) - UV |= 0xf000; - - key.UV = UV; - - needle = bsearch(&key, afm->Metrics, afm->NumofMetrics, sizeof(AFMMETRICS), - MetricsByUV); - - if (needle == NULL) - { - WARN("No glyph for U+%.4lX in %s\n", UV, afm->FontName); - needle = afm->Metrics; - } - - return needle; -} diff --git a/dlls/wineps.drv/psdrv.h b/dlls/wineps.drv/psdrv.h index 981ef6868dd..afeaa5fec0c 100644 --- a/dlls/wineps.drv/psdrv.h +++ b/dlls/wineps.drv/psdrv.h @@ -501,7 +501,6 @@ INT PSDRV_GlyphListInit(void) DECLSPEC_HIDDEN; const GLYPHNAME *PSDRV_GlyphName(LPCSTR szName) DECLSPEC_HIDDEN; VOID PSDRV_IndexGlyphList(void) DECLSPEC_HIDDEN; BOOL PSDRV_GetType1Metrics(void) DECLSPEC_HIDDEN; -const AFMMETRICS *PSDRV_UVMetrics(LONG UV, const AFM *afm) DECLSPEC_HIDDEN; SHORT PSDRV_CalcAvgCharWidth(const AFM *afm) DECLSPEC_HIDDEN;
extern BOOL PSDRV_WriteSetBuiltinFont(print_ctx *ctx) DECLSPEC_HIDDEN;
From: Piotr Caban piotr@codeweavers.com
--- dlls/wineps.drv/color.c | 28 --------------------------- dlls/wineps.drv/init.c | 42 ++++++----------------------------------- dlls/wineps.drv/ps.c | 1 - dlls/wineps.drv/psdrv.h | 7 ------- 4 files changed, 6 insertions(+), 72 deletions(-)
diff --git a/dlls/wineps.drv/color.c b/dlls/wineps.drv/color.c index 26c235a8c6c..db14319cbd6 100644 --- a/dlls/wineps.drv/color.c +++ b/dlls/wineps.drv/color.c @@ -24,34 +24,6 @@ WINE_DEFAULT_DEBUG_CHANNEL(psdrv);
-/********************************************************************** - * PSDRV_CopyColor - * - * Copies col2 into col1. Return FALSE on error. - */ -BOOL PSDRV_CopyColor(PSCOLOR *col1, PSCOLOR *col2) -{ - - switch(col2->type) { - case PSCOLOR_GRAY: - col1->value.gray.i = col2->value.gray.i; - break; - - case PSCOLOR_RGB: - col1->value.rgb.r = col2->value.rgb.r; - col1->value.rgb.g = col2->value.rgb.g; - col1->value.rgb.b = col2->value.rgb.b; - break; - - default: - ERR("Unknown colour type %d\n", col1->type); - return FALSE; - } - - col1->type = col2->type; - return TRUE; -} - PSRGB rgb_to_grayscale_scale( void ) { static const PSRGB scale = {0.3, 0.59, 0.11}; diff --git a/dlls/wineps.drv/init.c b/dlls/wineps.drv/init.c index 9cbea031d48..9d59830c60d 100644 --- a/dlls/wineps.drv/init.c +++ b/dlls/wineps.drv/init.c @@ -412,7 +412,7 @@ static void PSDRV_UpdateDevCaps( print_ctx *ctx ) { PAGESIZE *page; RESOLUTION *res; - INT width = 0, height = 0, resx = 0, resy = 0; + INT resx = 0, resy = 0;
dump_devmode(&ctx->Devmode->dmPublic);
@@ -460,63 +460,33 @@ static void PSDRV_UpdateDevCaps( print_ctx *ctx ) if(&page->entry == &ctx->pi->ppd->PageSizes) { FIXME("Can't find page\n"); SetRectEmpty(&ctx->ImageableArea); - ctx->PageSize.cx = 0; - ctx->PageSize.cy = 0; } else if(page->ImageableArea) { /* ctx sizes in device units; ppd sizes in 1/72" */ SetRect(&ctx->ImageableArea, page->ImageableArea->llx * ctx->logPixelsX / 72, page->ImageableArea->ury * ctx->logPixelsY / 72, page->ImageableArea->urx * ctx->logPixelsX / 72, page->ImageableArea->lly * ctx->logPixelsY / 72); - ctx->PageSize.cx = page->PaperDimension->x * - ctx->logPixelsX / 72; - ctx->PageSize.cy = page->PaperDimension->y * - ctx->logPixelsY / 72; } else { ctx->ImageableArea.left = ctx->ImageableArea.bottom = 0; - ctx->ImageableArea.right = ctx->PageSize.cx = + ctx->ImageableArea.right = page->PaperDimension->x * ctx->logPixelsX / 72; - ctx->ImageableArea.top = ctx->PageSize.cy = + ctx->ImageableArea.top = page->PaperDimension->y * ctx->logPixelsY / 72; } } else if((ctx->Devmode->dmPublic.dmFields & DM_PAPERLENGTH) && (ctx->Devmode->dmPublic.dmFields & DM_PAPERWIDTH)) { /* ctx sizes in device units; Devmode sizes in 1/10 mm */ ctx->ImageableArea.left = ctx->ImageableArea.bottom = 0; - ctx->ImageableArea.right = ctx->PageSize.cx = + ctx->ImageableArea.right = ctx->Devmode->dmPublic.dmPaperWidth * ctx->logPixelsX / 254; - ctx->ImageableArea.top = ctx->PageSize.cy = + ctx->ImageableArea.top = ctx->Devmode->dmPublic.dmPaperLength * ctx->logPixelsY / 254; } else { FIXME("Odd dmFields %lx\n", ctx->Devmode->dmPublic.dmFields); SetRectEmpty(&ctx->ImageableArea); - ctx->PageSize.cx = 0; - ctx->PageSize.cy = 0; }
- TRACE("ImageableArea = %s: PageSize = %ldx%ld\n", wine_dbgstr_rect(&ctx->ImageableArea), - ctx->PageSize.cx, ctx->PageSize.cy); - - /* these are in device units */ - width = ctx->ImageableArea.right - ctx->ImageableArea.left; - height = ctx->ImageableArea.top - ctx->ImageableArea.bottom; - - if(ctx->Devmode->dmPublic.dmOrientation == DMORIENT_PORTRAIT) { - ctx->horzRes = width; - ctx->vertRes = height; - } else { - ctx->horzRes = height; - ctx->vertRes = width; - } - - /* these are in mm */ - ctx->horzSize = (ctx->horzRes * 25.4) / ctx->logPixelsX; - ctx->vertSize = (ctx->vertRes * 25.4) / ctx->logPixelsY; - - TRACE("devcaps: horzSize = %dmm, vertSize = %dmm, " - "horzRes = %d, vertRes = %d\n", - ctx->horzSize, ctx->vertSize, - ctx->horzRes, ctx->vertRes); + TRACE("ImageableArea = %s\n", wine_dbgstr_rect(&ctx->ImageableArea)); }
print_ctx *create_print_ctx( HDC hdc, const WCHAR *device, diff --git a/dlls/wineps.drv/ps.c b/dlls/wineps.drv/ps.c index 007250e55db..421f01302bf 100644 --- a/dlls/wineps.drv/ps.c +++ b/dlls/wineps.drv/ps.c @@ -635,7 +635,6 @@ BOOL PSDRV_WriteSetColor(print_ctx *ctx, PSCOLOR *color) { char buf[256];
- PSDRV_CopyColor(&ctx->inkColor, color); switch(color->type) { case PSCOLOR_RGB: push_lc_numeric("C"); diff --git a/dlls/wineps.drv/psdrv.h b/dlls/wineps.drv/psdrv.h index afeaa5fec0c..dd63c0000cf 100644 --- a/dlls/wineps.drv/psdrv.h +++ b/dlls/wineps.drv/psdrv.h @@ -338,20 +338,14 @@ typedef struct PSPEN pen; PSBRUSH brush; PSCOLOR bkColor; - PSCOLOR inkColor; /* Last colour set */ JOB job; PSDRV_DEVMODE *Devmode; PRINTERINFO *pi; - SIZE PageSize; /* Physical page size in device units */ RECT ImageableArea; /* Imageable area in device units */ /* NB both PageSize and ImageableArea are not rotated in landscape mode, so PageSize.cx is generally < PageSize.cy */ - int horzRes; /* device caps */ - int vertRes; - int horzSize; - int vertSize; int logPixelsX; int logPixelsY;
@@ -446,7 +440,6 @@ extern void PSDRV_AddClip( print_ctx *ctx, HRGN hrgn ) DECLSPEC_HIDDEN; extern void PSDRV_SetClip( print_ctx *ctx ) DECLSPEC_HIDDEN; extern void PSDRV_ResetClip( print_ctx *ctx ) DECLSPEC_HIDDEN;
-extern BOOL PSDRV_CopyColor(PSCOLOR *col1, PSCOLOR *col2) DECLSPEC_HIDDEN; extern void PSDRV_CreateColor( print_ctx *ctx, PSCOLOR *pscolor, COLORREF wincolor ) DECLSPEC_HIDDEN; extern PSRGB rgb_to_grayscale_scale( void ) DECLSPEC_HIDDEN;
From: Piotr Caban piotr@codeweavers.com
--- dlls/wineps.drv/init.c | 61 ++++++++--------------------------------- dlls/wineps.drv/ps.c | 18 ++++++------ dlls/wineps.drv/psdrv.h | 3 -- 3 files changed, 21 insertions(+), 61 deletions(-)
diff --git a/dlls/wineps.drv/init.c b/dlls/wineps.drv/init.c index 9d59830c60d..649b6ecb41b 100644 --- a/dlls/wineps.drv/init.c +++ b/dlls/wineps.drv/init.c @@ -410,47 +410,12 @@ static void dump_devmode(const DEVMODEW *dm)
static void PSDRV_UpdateDevCaps( print_ctx *ctx ) { + int log_pixels_x = GetDeviceCaps(ctx->hdc, ASPECTX); + int log_pixels_y = GetDeviceCaps(ctx->hdc, ASPECTY); PAGESIZE *page; - RESOLUTION *res; - INT resx = 0, resy = 0;
dump_devmode(&ctx->Devmode->dmPublic);
- if (ctx->Devmode->dmPublic.dmFields & (DM_PRINTQUALITY | DM_YRESOLUTION | DM_LOGPIXELS)) - { - if (ctx->Devmode->dmPublic.dmFields & DM_PRINTQUALITY) - resx = resy = ctx->Devmode->dmPublic.dmPrintQuality; - - if (ctx->Devmode->dmPublic.dmFields & DM_YRESOLUTION) - resy = ctx->Devmode->dmPublic.dmYResolution; - - if (ctx->Devmode->dmPublic.dmFields & DM_LOGPIXELS) - resx = resy = ctx->Devmode->dmPublic.dmLogPixels; - - LIST_FOR_EACH_ENTRY(res, &ctx->pi->ppd->Resolutions, RESOLUTION, entry) - { - if (res->resx == resx && res->resy == resy) - { - ctx->logPixelsX = resx; - ctx->logPixelsY = resy; - break; - } - } - - if (&res->entry == &ctx->pi->ppd->Resolutions) - { - WARN("Requested resolution %dx%d is not supported by device\n", resx, resy); - ctx->logPixelsX = ctx->pi->ppd->DefaultResolution; - ctx->logPixelsY = ctx->logPixelsX; - } - } - else - { - WARN("Using default device resolution %d\n", ctx->pi->ppd->DefaultResolution); - ctx->logPixelsX = ctx->pi->ppd->DefaultResolution; - ctx->logPixelsY = ctx->logPixelsX; - } - if(ctx->Devmode->dmPublic.dmFields & DM_PAPERSIZE) { LIST_FOR_EACH_ENTRY(page, &ctx->pi->ppd->PageSizes, PAGESIZE, entry) { if(page->WinPage == ctx->Devmode->dmPublic.dmPaperSize) @@ -462,25 +427,23 @@ static void PSDRV_UpdateDevCaps( print_ctx *ctx ) SetRectEmpty(&ctx->ImageableArea); } else if(page->ImageableArea) { /* ctx sizes in device units; ppd sizes in 1/72" */ - SetRect(&ctx->ImageableArea, page->ImageableArea->llx * ctx->logPixelsX / 72, - page->ImageableArea->ury * ctx->logPixelsY / 72, - page->ImageableArea->urx * ctx->logPixelsX / 72, - page->ImageableArea->lly * ctx->logPixelsY / 72); + SetRect(&ctx->ImageableArea, page->ImageableArea->llx * log_pixels_x / 72, + page->ImageableArea->ury * log_pixels_y / 72, + page->ImageableArea->urx * log_pixels_x / 72, + page->ImageableArea->lly * log_pixels_y / 72); } else { ctx->ImageableArea.left = ctx->ImageableArea.bottom = 0; - ctx->ImageableArea.right = - page->PaperDimension->x * ctx->logPixelsX / 72; - ctx->ImageableArea.top = - page->PaperDimension->y * ctx->logPixelsY / 72; + ctx->ImageableArea.right = page->PaperDimension->x * log_pixels_x / 72; + ctx->ImageableArea.top = page->PaperDimension->y * log_pixels_y / 72; } } else if((ctx->Devmode->dmPublic.dmFields & DM_PAPERLENGTH) && (ctx->Devmode->dmPublic.dmFields & DM_PAPERWIDTH)) { /* ctx sizes in device units; Devmode sizes in 1/10 mm */ ctx->ImageableArea.left = ctx->ImageableArea.bottom = 0; ctx->ImageableArea.right = - ctx->Devmode->dmPublic.dmPaperWidth * ctx->logPixelsX / 254; + ctx->Devmode->dmPublic.dmPaperWidth * log_pixels_x / 254; ctx->ImageableArea.top = - ctx->Devmode->dmPublic.dmPaperLength * ctx->logPixelsY / 254; + ctx->Devmode->dmPublic.dmPaperLength * log_pixels_y / 254; } else { FIXME("Odd dmFields %lx\n", ctx->Devmode->dmPublic.dmFields); SetRectEmpty(&ctx->ImageableArea); @@ -523,8 +486,7 @@ print_ctx *create_print_ctx( HDC hdc, const WCHAR *device, memcpy( ctx->Devmode, pi->Devmode, pi->Devmode->dmPublic.dmSize + pi->Devmode->dmPublic.dmDriverExtra ); ctx->pi = pi; - ctx->logPixelsX = pi->ppd->DefaultResolution; - ctx->logPixelsY = pi->ppd->DefaultResolution; + ctx->hdc = hdc;
if (devmode) { @@ -533,7 +495,6 @@ print_ctx *create_print_ctx( HDC hdc, const WCHAR *device, }
PSDRV_UpdateDevCaps( ctx ); - ctx->hdc = hdc; SelectObject( hdc, GetStockObject( DEVICE_DEFAULT_FONT )); return ctx; } diff --git a/dlls/wineps.drv/ps.c b/dlls/wineps.drv/ps.c index 421f01302bf..751a5097034 100644 --- a/dlls/wineps.drv/ps.c +++ b/dlls/wineps.drv/ps.c @@ -400,7 +400,7 @@ 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 llx, lly, urx, ury, log_pixels_x, log_pixels_y; int ret, len; const char * dmOrientation;
@@ -429,10 +429,12 @@ INT PSDRV_WriteHeader( print_ctx *ctx, LPCWSTR title )
/* BBox co-ords are in default user co-ord system so urx < ury even in landscape mode */ - llx = ctx->ImageableArea.left * 72.0 / ctx->logPixelsX; - lly = ctx->ImageableArea.bottom * 72.0 / ctx->logPixelsY; - urx = ctx->ImageableArea.right * 72.0 / ctx->logPixelsX; - ury = ctx->ImageableArea.top * 72.0 / ctx->logPixelsY; + log_pixels_x = GetDeviceCaps(ctx->hdc, ASPECTX); + log_pixels_y = GetDeviceCaps(ctx->hdc, ASPECTY); + llx = ctx->ImageableArea.left * 72.0 / log_pixels_x; + lly = ctx->ImageableArea.bottom * 72.0 / log_pixels_y; + urx = ctx->ImageableArea.right * 72.0 / log_pixels_x; + ury = ctx->ImageableArea.top * 72.0 / log_pixels_y; /* FIXME should do something better with BBox */
dmOrientation = (ctx->Devmode->dmPublic.dmOrientation == DMORIENT_LANDSCAPE ? "Landscape" : "Portrait"); @@ -532,7 +534,7 @@ INT PSDRV_WriteNewPage( print_ctx *ctx ) }
sprintf(buf, psnewpage, name, ctx->job.PageNo, - ctx->logPixelsX, ctx->logPixelsY, + GetDeviceCaps(ctx->hdc, ASPECTX), GetDeviceCaps(ctx->hdc, ASPECTY), xtrans, ytrans, rotation);
if( write_spool( ctx, buf, strlen(buf) ) != strlen(buf) ) { @@ -981,8 +983,8 @@ BOOL PSDRV_WriteDIBPatternDict(print_ctx *ctx, const BITMAPINFO *bmi, BYTE *bits PSDRV_WriteIndexColorSpaceEnd(ctx);
/* Windows seems to scale patterns so that a one pixel corresponds to 1/300" */ - w_mult = (ctx->logPixelsX + 150) / 300; - h_mult = (ctx->logPixelsY + 150) / 300; + w_mult = (GetDeviceCaps(ctx->hdc, ASPECTX) + 150) / 300; + h_mult = (GetDeviceCaps(ctx->hdc, ASPECTY) + 150) / 300; sprintf(buf, do_pattern, w * w_mult, h * h_mult, w * w_mult, h * h_mult, w * w_mult, h * h_mult); PSDRV_WriteSpool(ctx, buf, strlen(buf)); HeapFree( GetProcessHeap(), 0, buf ); diff --git a/dlls/wineps.drv/psdrv.h b/dlls/wineps.drv/psdrv.h index dd63c0000cf..20e80e9f1aa 100644 --- a/dlls/wineps.drv/psdrv.h +++ b/dlls/wineps.drv/psdrv.h @@ -346,9 +346,6 @@ typedef struct are not rotated in landscape mode, so PageSize.cx is generally < PageSize.cy */ - int logPixelsX; - int logPixelsY; - int pathdepth; } print_ctx;
From: Piotr Caban piotr@codeweavers.com
--- dlls/wineps.drv/init.c | 53 +++-------------------------------- dlls/wineps.drv/ps.c | 61 +++++++++++++++++++++++++++++------------ dlls/wineps.drv/psdrv.h | 5 ---- 3 files changed, 47 insertions(+), 72 deletions(-)
diff --git a/dlls/wineps.drv/init.c b/dlls/wineps.drv/init.c index 649b6ecb41b..b38c1e1ac43 100644 --- a/dlls/wineps.drv/init.c +++ b/dlls/wineps.drv/init.c @@ -408,50 +408,6 @@ static void dump_devmode(const DEVMODEW *dm) TRACE("dmPelsHeight %lu\n", dm->dmPelsHeight); }
-static void PSDRV_UpdateDevCaps( print_ctx *ctx ) -{ - int log_pixels_x = GetDeviceCaps(ctx->hdc, ASPECTX); - int log_pixels_y = GetDeviceCaps(ctx->hdc, ASPECTY); - PAGESIZE *page; - - dump_devmode(&ctx->Devmode->dmPublic); - - if(ctx->Devmode->dmPublic.dmFields & DM_PAPERSIZE) { - LIST_FOR_EACH_ENTRY(page, &ctx->pi->ppd->PageSizes, PAGESIZE, entry) { - if(page->WinPage == ctx->Devmode->dmPublic.dmPaperSize) - break; - } - - if(&page->entry == &ctx->pi->ppd->PageSizes) { - FIXME("Can't find page\n"); - SetRectEmpty(&ctx->ImageableArea); - } else if(page->ImageableArea) { - /* ctx sizes in device units; ppd sizes in 1/72" */ - SetRect(&ctx->ImageableArea, page->ImageableArea->llx * log_pixels_x / 72, - page->ImageableArea->ury * log_pixels_y / 72, - page->ImageableArea->urx * log_pixels_x / 72, - page->ImageableArea->lly * log_pixels_y / 72); - } else { - ctx->ImageableArea.left = ctx->ImageableArea.bottom = 0; - ctx->ImageableArea.right = page->PaperDimension->x * log_pixels_x / 72; - ctx->ImageableArea.top = page->PaperDimension->y * log_pixels_y / 72; - } - } else if((ctx->Devmode->dmPublic.dmFields & DM_PAPERLENGTH) && - (ctx->Devmode->dmPublic.dmFields & DM_PAPERWIDTH)) { - /* ctx sizes in device units; Devmode sizes in 1/10 mm */ - ctx->ImageableArea.left = ctx->ImageableArea.bottom = 0; - ctx->ImageableArea.right = - ctx->Devmode->dmPublic.dmPaperWidth * log_pixels_x / 254; - ctx->ImageableArea.top = - ctx->Devmode->dmPublic.dmPaperLength * log_pixels_y / 254; - } else { - FIXME("Odd dmFields %lx\n", ctx->Devmode->dmPublic.dmFields); - SetRectEmpty(&ctx->ImageableArea); - } - - TRACE("ImageableArea = %s\n", wine_dbgstr_rect(&ctx->ImageableArea)); -} - print_ctx *create_print_ctx( HDC hdc, const WCHAR *device, const DEVMODEW *devmode ) { @@ -494,7 +450,6 @@ print_ctx *create_print_ctx( HDC hdc, const WCHAR *device, PSDRV_MergeDevmodes( ctx->Devmode, devmode, pi ); }
- PSDRV_UpdateDevCaps( ctx ); SelectObject( hdc, GetStockObject( DEVICE_DEFAULT_FONT )); return ctx; } @@ -502,12 +457,12 @@ print_ctx *create_print_ctx( HDC hdc, const WCHAR *device, /********************************************************************** * ResetDC (WINEPS.@) */ -BOOL CDECL PSDRV_ResetDC( print_ctx *ctx, const DEVMODEW *lpInitData ) +BOOL CDECL PSDRV_ResetDC( print_ctx *ctx, const DEVMODEW *devmode ) { - if (lpInitData) + if (devmode) { - PSDRV_MergeDevmodes(ctx->Devmode, lpInitData, ctx->pi); - PSDRV_UpdateDevCaps(ctx); + dump_devmode( devmode ); + PSDRV_MergeDevmodes( ctx->Devmode, devmode, ctx->pi ); } return TRUE; } diff --git a/dlls/wineps.drv/ps.c b/dlls/wineps.drv/ps.c index 751a5097034..a8050abe19b 100644 --- a/dlls/wineps.drv/ps.c +++ b/dlls/wineps.drv/ps.c @@ -400,7 +400,7 @@ 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, log_pixels_x, log_pixels_y; + int llx, lly, urx, ury; int ret, len; const char * dmOrientation;
@@ -429,12 +429,34 @@ INT PSDRV_WriteHeader( print_ctx *ctx, LPCWSTR title )
/* BBox co-ords are in default user co-ord system so urx < ury even in landscape mode */ - log_pixels_x = GetDeviceCaps(ctx->hdc, ASPECTX); - log_pixels_y = GetDeviceCaps(ctx->hdc, ASPECTY); - llx = ctx->ImageableArea.left * 72.0 / log_pixels_x; - lly = ctx->ImageableArea.bottom * 72.0 / log_pixels_y; - urx = ctx->ImageableArea.right * 72.0 / log_pixels_x; - ury = ctx->ImageableArea.top * 72.0 / log_pixels_y; + 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 */
dmOrientation = (ctx->Devmode->dmPublic.dmOrientation == DMORIENT_LANDSCAPE ? "Landscape" : "Portrait"); @@ -519,18 +541,21 @@ INT PSDRV_WriteNewPage( print_ctx *ctx )
if(ctx->Devmode->dmPublic.dmOrientation == DMORIENT_LANDSCAPE) { if(ctx->pi->ppd->LandscapeOrientation == -90) { - xtrans = ctx->ImageableArea.right; - ytrans = ctx->ImageableArea.top; - rotation = 90; - } else { - xtrans = ctx->ImageableArea.left; - ytrans = ctx->ImageableArea.bottom; - rotation = -90; - } + xtrans = GetDeviceCaps(ctx->hdc, PHYSICALHEIGHT) - + GetDeviceCaps(ctx->hdc, PHYSICALOFFSETY); + ytrans = GetDeviceCaps(ctx->hdc, PHYSICALWIDTH) - + GetDeviceCaps(ctx->hdc, PHYSICALOFFSETX); + rotation = 90; + } else { + xtrans = GetDeviceCaps(ctx->hdc, PHYSICALOFFSETY); + ytrans = GetDeviceCaps(ctx->hdc, PHYSICALOFFSETX); + rotation = -90; + } } else { - xtrans = ctx->ImageableArea.left; - ytrans = ctx->ImageableArea.top; - rotation = 0; + xtrans = GetDeviceCaps(ctx->hdc, PHYSICALOFFSETX); + ytrans = GetDeviceCaps(ctx->hdc, PHYSICALHEIGHT) - + GetDeviceCaps(ctx->hdc, PHYSICALOFFSETY); + rotation = 0; }
sprintf(buf, psnewpage, name, ctx->job.PageNo, diff --git a/dlls/wineps.drv/psdrv.h b/dlls/wineps.drv/psdrv.h index 20e80e9f1aa..389c6a5b562 100644 --- a/dlls/wineps.drv/psdrv.h +++ b/dlls/wineps.drv/psdrv.h @@ -341,11 +341,6 @@ typedef struct JOB job; PSDRV_DEVMODE *Devmode; PRINTERINFO *pi; - RECT ImageableArea; /* Imageable area in device units */ - /* NB both PageSize and ImageableArea - are not rotated in landscape mode, - so PageSize.cx is generally - < PageSize.cy */ int pathdepth; } print_ctx;
This merge request was approved by Huw Davies.