wineps: Use the get_pagesize helper to look up the default pagesize.

This commit is contained in:
Huw Davies 2012-05-16 13:15:17 +01:00 committed by Alexandre Julliard
parent eb29e30188
commit cd770d907a
1 changed files with 23 additions and 26 deletions

View File

@ -459,14 +459,12 @@ static BOOL PSDRV_PPDGetNextTuple(FILE *fp, PPDTuple *tuple)
} }
/********************************************************************* /*********************************************************************
* get_pagesize
* *
* PSDRV_PPDGetPageSizeInfo * Searches ppd PageSize list to return entry matching name or optionally creates new
*
* Searches ppd PageSize list to return entry matching name or creates new
* entry which is appended to the list if name is not found. * entry which is appended to the list if name is not found.
*
*/ */
static PAGESIZE *PSDRV_PPDGetPageSizeInfo(PPD *ppd, char *name) static PAGESIZE *get_pagesize( PPD *ppd, char *name, BOOL create )
{ {
PAGESIZE *page; PAGESIZE *page;
@ -476,6 +474,8 @@ static PAGESIZE *PSDRV_PPDGetPageSizeInfo(PPD *ppd, char *name)
return page; return page;
} }
if (!create) return NULL;
page = HeapAlloc( PSDRV_Heap, HEAP_ZERO_MEMORY, sizeof(*page) ); page = HeapAlloc( PSDRV_Heap, HEAP_ZERO_MEMORY, sizeof(*page) );
list_add_tail(&ppd->PageSizes, &page->entry); list_add_tail(&ppd->PageSizes, &page->entry);
return page; return page;
@ -711,7 +711,7 @@ PPD *PSDRV_ParsePPD(char *fname)
} }
else if(!strcmp("*PageSize", tuple.key)) { else if(!strcmp("*PageSize", tuple.key)) {
page = PSDRV_PPDGetPageSizeInfo(ppd, tuple.option); page = get_pagesize( ppd, tuple.option, TRUE );
if(!page->Name) { if(!page->Name) {
int i; int i;
@ -747,17 +747,17 @@ PPD *PSDRV_ParsePPD(char *fname)
} }
} }
else if(!strcmp("*DefaultPageSize", tuple.key)) { else if(!strcmp("*DefaultPageSize", tuple.key))
if(default_pagesize) { {
WARN("Already set default pagesize\n"); if (!default_pagesize)
} else { {
default_pagesize = tuple.value; default_pagesize = tuple.value;
tuple.value = NULL; tuple.value = NULL;
} }
} }
else if(!strcmp("*ImageableArea", tuple.key)) { else if(!strcmp("*ImageableArea", tuple.key)) {
page = PSDRV_PPDGetPageSizeInfo(ppd, tuple.option); page = get_pagesize( ppd, tuple.option, TRUE );
if(!page->Name) { if(!page->Name) {
page->Name = tuple.option; page->Name = tuple.option;
@ -779,9 +779,8 @@ PPD *PSDRV_ParsePPD(char *fname)
#undef PIA #undef PIA
} }
else if(!strcmp("*PaperDimension", tuple.key)) { else if(!strcmp("*PaperDimension", tuple.key)) {
page = PSDRV_PPDGetPageSizeInfo(ppd, tuple.option); page = get_pagesize( ppd, tuple.option, TRUE );
if(!page->Name) { if(!page->Name) {
page->Name = tuple.option; page->Name = tuple.option;
@ -932,20 +931,18 @@ PPD *PSDRV_ParsePPD(char *fname)
} }
ppd->DefaultPageSize = NULL; ppd->DefaultPageSize = NULL;
if(default_pagesize) { if (default_pagesize)
LIST_FOR_EACH_ENTRY(page, &ppd->PageSizes, PAGESIZE, entry) { ppd->DefaultPageSize = get_pagesize( ppd, default_pagesize, FALSE );
if(!strcmp(page->Name, default_pagesize)) {
ppd->DefaultPageSize = page; if (!ppd->DefaultPageSize)
TRACE("DefaultPageSize: %s\n", page->Name); {
break; struct list *head = list_head( &ppd->PageSizes );
} if (head) ppd->DefaultPageSize = LIST_ENTRY( head, PAGESIZE, entry );
}
HeapFree(PSDRV_Heap, 0, default_pagesize);
}
if(!ppd->DefaultPageSize) {
ppd->DefaultPageSize = LIST_ENTRY(list_head(&ppd->PageSizes), PAGESIZE, entry);
TRACE("Setting DefaultPageSize to first in list\n"); TRACE("Setting DefaultPageSize to first in list\n");
} }
TRACE( "DefaultPageSize: %s\n", ppd->DefaultPageSize ? ppd->DefaultPageSize->Name : "<not set>" );
HeapFree( PSDRV_Heap, 0, default_pagesize );
ppd->DefaultDuplex = NULL; ppd->DefaultDuplex = NULL;
if (default_duplex) if (default_duplex)