Commit 5b71f7bb authored by Huw Davies's avatar Huw Davies Committed by Alexandre Julliard

wineps: Add the ability to override the ppd file's default pagesize and duplex settings.

parent a2a8a613
...@@ -612,7 +612,7 @@ PRINTERINFO *PSDRV_FindPrinterInfo(LPCWSTR name) ...@@ -612,7 +612,7 @@ PRINTERINFO *PSDRV_FindPrinterInfo(LPCWSTR name)
ppd_filename = get_ppd_filename( hPrinter ); ppd_filename = get_ppd_filename( hPrinter );
if (!ppd_filename) goto fail; if (!ppd_filename) goto fail;
pi->ppd = PSDRV_ParsePPD( ppd_filename ); pi->ppd = PSDRV_ParsePPD( ppd_filename, hPrinter );
if (!pi->ppd) if (!pi->ppd)
{ {
WARN( "Couldn't parse PPD file '%s'\n", ppd_filename ); WARN( "Couldn't parse PPD file '%s'\n", ppd_filename );
......
...@@ -611,18 +611,36 @@ static BOOL PSDRV_AddSlot(PPD *ppd, LPCSTR szName, LPCSTR szFullName, ...@@ -611,18 +611,36 @@ static BOOL PSDRV_AddSlot(PPD *ppd, LPCSTR szName, LPCSTR szFullName,
return TRUE; return TRUE;
} }
static char *get_ppd_override( HANDLE printer, const char *value )
{
DWORD err, type, needed;
char *data;
err = GetPrinterDataExA( printer, "PPD Overrides", value, &type, NULL, 0, &needed );
if (err != ERROR_MORE_DATA || type != REG_SZ || needed == 0) return NULL;
data = HeapAlloc( PSDRV_Heap, 0, needed );
if (data)
{
GetPrinterDataExA( printer, "PPD Overrides", value, &type, (BYTE*)data, needed, &needed );
TRACE( "got override %s: %s\n", value, data );
}
return data;
}
/*********************************************************************** /***********************************************************************
* *
* PSDRV_ParsePPD * PSDRV_ParsePPD
* *
* *
*/ */
PPD *PSDRV_ParsePPD(char *fname) PPD *PSDRV_ParsePPD( char *fname, HANDLE printer )
{ {
FILE *fp; FILE *fp;
PPD *ppd; PPD *ppd;
PPDTuple tuple; PPDTuple tuple;
char *default_pagesize = NULL, *default_duplex = NULL; char *default_pagesize = NULL, *default_duplex = NULL;
char *def_pagesize_override = NULL, *def_duplex_override = NULL;
PAGESIZE *page, *page_cursor2; PAGESIZE *page, *page_cursor2;
TRACE("file '%s'\n", fname); TRACE("file '%s'\n", fname);
...@@ -944,7 +962,10 @@ PPD *PSDRV_ParsePPD(char *fname) ...@@ -944,7 +962,10 @@ PPD *PSDRV_ParsePPD(char *fname)
} }
ppd->DefaultPageSize = NULL; ppd->DefaultPageSize = NULL;
if (default_pagesize) def_pagesize_override = get_ppd_override( printer, "DefaultPageSize" );
if (def_pagesize_override)
ppd->DefaultPageSize = get_pagesize( ppd, def_pagesize_override, FALSE );
if (!ppd->DefaultPageSize && default_pagesize)
ppd->DefaultPageSize = get_pagesize( ppd, default_pagesize, FALSE ); ppd->DefaultPageSize = get_pagesize( ppd, default_pagesize, FALSE );
if (!ppd->DefaultPageSize) if (!ppd->DefaultPageSize)
...@@ -955,10 +976,14 @@ PPD *PSDRV_ParsePPD(char *fname) ...@@ -955,10 +976,14 @@ PPD *PSDRV_ParsePPD(char *fname)
} }
TRACE( "DefaultPageSize: %s\n", ppd->DefaultPageSize ? ppd->DefaultPageSize->Name : "<not set>" ); TRACE( "DefaultPageSize: %s\n", ppd->DefaultPageSize ? ppd->DefaultPageSize->Name : "<not set>" );
HeapFree( PSDRV_Heap, 0, def_pagesize_override );
HeapFree( PSDRV_Heap, 0, default_pagesize ); HeapFree( PSDRV_Heap, 0, default_pagesize );
ppd->DefaultDuplex = NULL; ppd->DefaultDuplex = NULL;
if (default_duplex) def_duplex_override = get_ppd_override( printer, "DefaultDuplex" );
if (def_duplex_override)
ppd->DefaultDuplex = get_duplex( ppd, def_duplex_override );
if (!ppd->DefaultDuplex && default_duplex)
ppd->DefaultDuplex = get_duplex( ppd, default_duplex ); ppd->DefaultDuplex = get_duplex( ppd, default_duplex );
if (!ppd->DefaultDuplex) if (!ppd->DefaultDuplex)
...@@ -969,6 +994,7 @@ PPD *PSDRV_ParsePPD(char *fname) ...@@ -969,6 +994,7 @@ PPD *PSDRV_ParsePPD(char *fname)
} }
TRACE( "DefaultDuplex: %s\n", ppd->DefaultDuplex ? ppd->DefaultDuplex->Name : "<not set>" ); TRACE( "DefaultDuplex: %s\n", ppd->DefaultDuplex ? ppd->DefaultDuplex->Name : "<not set>" );
HeapFree( PSDRV_Heap, 0, def_duplex_override );
HeapFree( PSDRV_Heap, 0, default_duplex ); HeapFree( PSDRV_Heap, 0, default_duplex );
......
...@@ -458,7 +458,7 @@ extern BOOL PSDRV_StrokePath( PHYSDEV dev ) DECLSPEC_HIDDEN; ...@@ -458,7 +458,7 @@ extern BOOL PSDRV_StrokePath( PHYSDEV dev ) DECLSPEC_HIDDEN;
extern void PSDRV_MergeDevmodes(PSDRV_DEVMODE *dm1, PSDRV_DEVMODE *dm2, extern void PSDRV_MergeDevmodes(PSDRV_DEVMODE *dm1, PSDRV_DEVMODE *dm2,
PRINTERINFO *pi) DECLSPEC_HIDDEN; PRINTERINFO *pi) DECLSPEC_HIDDEN;
extern BOOL PSDRV_GetFontMetrics(void) DECLSPEC_HIDDEN; extern BOOL PSDRV_GetFontMetrics(void) DECLSPEC_HIDDEN;
extern PPD *PSDRV_ParsePPD(char *fname) DECLSPEC_HIDDEN; extern PPD *PSDRV_ParsePPD(char *fname, HANDLE printer) DECLSPEC_HIDDEN;
extern PRINTERINFO *PSDRV_FindPrinterInfo(LPCWSTR name) DECLSPEC_HIDDEN; extern PRINTERINFO *PSDRV_FindPrinterInfo(LPCWSTR name) DECLSPEC_HIDDEN;
extern const AFM *PSDRV_FindAFMinList(FONTFAMILY *head, LPCSTR name) DECLSPEC_HIDDEN; extern const AFM *PSDRV_FindAFMinList(FONTFAMILY *head, LPCSTR name) DECLSPEC_HIDDEN;
extern BOOL PSDRV_AddAFMtoList(FONTFAMILY **head, const AFM *afm, extern BOOL PSDRV_AddAFMtoList(FONTFAMILY **head, const AFM *afm,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment