CUPS uses the ppd file to store the default paper size, so we'll read

it from here.
If the ppd doesn't contain an explicit resolution then default to
300dpi.
This commit is contained in:
Huw Davies 2003-05-20 02:22:25 +00:00 committed by Alexandre Julliard
parent 9747a103b5
commit 6124a02733
3 changed files with 52 additions and 6 deletions

View File

@ -588,6 +588,10 @@ PRINTERINFO *PSDRV_FindPrinterInfo(LPCSTR name)
goto closeprinter;
}
/* Some gimp-print ppd files don't contain a DefaultResolution line
set it to 300 if it's not specified */
if(pi->ppd->DefaultResolution == 0)
pi->ppd->DefaultResolution = 300;
if(using_default_devmode) {
DWORD papersize;
@ -604,6 +608,13 @@ PRINTERINFO *PSDRV_FindPrinterInfo(LPCSTR name)
REG_BINARY, (LPBYTE)pi->Devmode, sizeof(DefaultDevmode) );
}
if(pi->ppd->DefaultPageSize) { /* We'll let the ppd override the devmode */
PSDRV_DEVMODEA dm;
memset(&dm, 0, sizeof(dm));
dm.dmPublic.dmFields = DM_PAPERSIZE;
dm.dmPublic.u1.s1.dmPaperSize = pi->ppd->DefaultPageSize->WinPage;
PSDRV_MergeDevmodes(pi->Devmode, &dm, pi);
}
/*
* This is a hack. The default paper size should be read in as part of

View File

@ -355,9 +355,13 @@ static BOOL PSDRV_PPDGetSymbolValue(char *pos, PPDTuple *tuple)
*/
static BOOL PSDRV_PPDGetNextTuple(FILE *fp, PPDTuple *tuple)
{
char line[257], *opt = NULL, *cp, *trans, *endkey;
BOOL gotoption = TRUE;
char line[257], *opt, *cp, *trans, *endkey;
BOOL gotoption;
start:
gotoption = TRUE;
opt = NULL;
memset(tuple, 0, sizeof(*tuple));
do {
@ -369,7 +373,7 @@ static BOOL PSDRV_PPDGetNextTuple(FILE *fp, PPDTuple *tuple)
if(line[strlen(line)-1] != '\n') {
ERR("Line too long.\n");
return FALSE;
goto start;
}
for(cp = line; !isspace(*cp) && *cp != ':'; cp++)
@ -398,7 +402,8 @@ static BOOL PSDRV_PPDGetNextTuple(FILE *fp, PPDTuple *tuple)
cp = strpbrk(opt, ":/");
if(!cp) {
ERR("Error in line '%s'?\n", line);
return FALSE;
HeapFree(GetProcessHeap(), 0, tuple->key);
goto start;
}
tuple->option = HeapAlloc( PSDRV_Heap, 0, cp - opt + 1 );
if(!tuple->option) return FALSE;
@ -410,7 +415,9 @@ static BOOL PSDRV_PPDGetNextTuple(FILE *fp, PPDTuple *tuple)
cp = strchr(trans, ':');
if(!cp) {
ERR("Error in line '%s'?\n", line);
return FALSE;
HeapFree(GetProcessHeap(), 0, tuple->option);
HeapFree(GetProcessHeap(), 0, tuple->key);
goto start;
}
buf = HeapAlloc( PSDRV_Heap, 0, cp - trans + 1 );
if(!buf) return FALSE;
@ -547,6 +554,7 @@ PPD *PSDRV_ParsePPD(char *fname)
FILE *fp;
PPD *ppd;
PPDTuple tuple;
char *default_pagesize = NULL;
TRACE("file '%s'\n", fname);
@ -675,7 +683,16 @@ PPD *PSDRV_ParsePPD(char *fname)
}
}
else if(!strcmp("*ImageableArea", tuple.key)) {
else if(!strcmp("*DefaultPageSize", tuple.key)) {
if(default_pagesize) {
WARN("Already set default pagesize\n");
} else {
default_pagesize = tuple.value;
tuple.value = NULL;
}
}
else if(!strcmp("*ImageableArea", tuple.key)) {
PAGESIZE *page;
page = PSDRV_PPDGetPageSizeInfo(ppd, tuple.option);
@ -804,6 +821,23 @@ PPD *PSDRV_ParsePPD(char *fname)
}
ppd->DefaultPageSize = NULL;
if(default_pagesize) {
PAGESIZE *page;
for(page = ppd->PageSizes; page; page = page->next) {
if(!strcmp(page->Name, default_pagesize)) {
ppd->DefaultPageSize = page;
TRACE("DefaultPageSize: %s\n", page->Name);
break;
}
}
HeapFree(PSDRV_Heap, 0, default_pagesize);
}
if(!ppd->DefaultPageSize) {
ppd->DefaultPageSize = ppd->PageSizes;
TRACE("Setting DefaultPageSize to first in list\n");
}
{
FONTNAME *fn;
PAGESIZE *page;

View File

@ -184,6 +184,7 @@ typedef struct {
char *DefaultFont;
FONTNAME *InstalledFonts; /* ptr to a list of FontNames */
PAGESIZE *PageSizes;
PAGESIZE *DefaultPageSize;
OPTION *InstalledOptions;
CONSTRAINT *Constraints;
INPUTSLOT *InputSlots;