Take into account unprintable margins in psdrv.
This commit is contained in:
parent
71891e1fd6
commit
d4b933e7d2
|
@ -267,6 +267,8 @@ static BOOL PSDRV_CreateDC( DC *dc, LPCSTR driver, LPCSTR device,
|
|||
PSDRV_PDEVICE *physDev;
|
||||
PRINTERINFO *pi;
|
||||
DeviceCaps *devCaps;
|
||||
PAGESIZE *page;
|
||||
INT width = 0, height = 0;
|
||||
|
||||
/* If no device name was specified, retrieve the device name
|
||||
* from the DEVMODE structure from the DC's physDev.
|
||||
|
@ -311,19 +313,6 @@ static BOOL PSDRV_CreateDC( DC *dc, LPCSTR driver, LPCSTR device,
|
|||
devCaps = HeapAlloc( PSDRV_Heap, 0, sizeof(PSDRV_DevCaps) );
|
||||
memcpy(devCaps, &PSDRV_DevCaps, sizeof(PSDRV_DevCaps));
|
||||
|
||||
if(physDev->Devmode->dmPublic.u1.s1.dmOrientation == DMORIENT_PORTRAIT) {
|
||||
devCaps->horzSize = physDev->Devmode->dmPublic.u1.s1.dmPaperWidth / 10;
|
||||
devCaps->vertSize = physDev->Devmode->dmPublic.u1.s1.dmPaperLength / 10;
|
||||
} else {
|
||||
devCaps->horzSize = physDev->Devmode->dmPublic.u1.s1.dmPaperLength / 10;
|
||||
devCaps->vertSize = physDev->Devmode->dmPublic.u1.s1.dmPaperWidth / 10;
|
||||
}
|
||||
|
||||
devCaps->horzRes = physDev->pi->ppd->DefaultResolution *
|
||||
devCaps->horzSize / 25.4;
|
||||
devCaps->vertRes = physDev->pi->ppd->DefaultResolution *
|
||||
devCaps->vertSize / 25.4;
|
||||
|
||||
/* Are aspect[XY] and logPixels[XY] correct? */
|
||||
/* Need to handle different res in x and y => fix ppd */
|
||||
devCaps->aspectX = devCaps->logPixelsX =
|
||||
|
@ -333,6 +322,57 @@ static BOOL PSDRV_CreateDC( DC *dc, LPCSTR driver, LPCSTR device,
|
|||
devCaps->aspectXY = (int)hypot( (double)devCaps->aspectX,
|
||||
(double)devCaps->aspectY );
|
||||
|
||||
|
||||
for(page = pi->ppd->PageSizes; page; page = page->next) {
|
||||
if(page->WinPage == physDev->Devmode->dmPublic.u1.s1.dmPaperSize)
|
||||
break;
|
||||
}
|
||||
if(!page) {
|
||||
FIXME("Can't find page\n");
|
||||
physDev->PageSize.left = 0;
|
||||
physDev->PageSize.right = 0;
|
||||
physDev->PageSize.bottom = 0;
|
||||
physDev->PageSize.top = 0;
|
||||
} else if(page->ImageableArea) { /* PageSize is in device units */
|
||||
physDev->PageSize.left = page->ImageableArea->llx *
|
||||
devCaps->logPixelsX / 72;
|
||||
physDev->PageSize.right = page->ImageableArea->urx *
|
||||
devCaps->logPixelsX / 72;
|
||||
physDev->PageSize.bottom = page->ImageableArea->lly *
|
||||
devCaps->logPixelsY / 72;
|
||||
physDev->PageSize.top = page->ImageableArea->ury *
|
||||
devCaps->logPixelsY / 72;
|
||||
} else {
|
||||
physDev->PageSize.left = physDev->PageSize.bottom = 0;
|
||||
physDev->PageSize.right = page->PaperDimension->x *
|
||||
devCaps->logPixelsX / 72;
|
||||
physDev->PageSize.top = page->PaperDimension->y *
|
||||
devCaps->logPixelsY / 72;
|
||||
}
|
||||
TRACE("PageSize = (%d,%d - %d,%d)\n", physDev->PageSize.left, physDev->PageSize.bottom, physDev->PageSize.right, physDev->PageSize.top);
|
||||
|
||||
/* these are in mm */
|
||||
width = (physDev->PageSize.right - physDev->PageSize.left) * 25.4 /
|
||||
devCaps->logPixelsX;
|
||||
height = (physDev->PageSize.top - physDev->PageSize.bottom) * 25.4 /
|
||||
devCaps->logPixelsY;
|
||||
|
||||
if(physDev->Devmode->dmPublic.u1.s1.dmOrientation == DMORIENT_PORTRAIT) {
|
||||
devCaps->horzSize = width;
|
||||
devCaps->vertSize = height;
|
||||
} else {
|
||||
devCaps->horzSize = height;
|
||||
devCaps->vertSize = width;
|
||||
}
|
||||
|
||||
devCaps->horzRes = devCaps->logPixelsX * devCaps->horzSize / 25.4;
|
||||
devCaps->vertRes = devCaps->logPixelsY * devCaps->vertSize / 25.4;
|
||||
|
||||
TRACE("devcaps: horzSize = %dmm, vertSize = %dmm, "
|
||||
"horzRes = %d, vertRes = %d\n",
|
||||
devCaps->horzSize, devCaps->vertSize,
|
||||
devCaps->horzRes, devCaps->vertRes);
|
||||
|
||||
if(physDev->pi->ppd->ColorDevice) {
|
||||
devCaps->bitsPixel = 8;
|
||||
devCaps->numColors = 256;
|
||||
|
|
|
@ -273,8 +273,8 @@ INT PSDRV_WriteFeature(HANDLE16 hJob, char *feature, char *value,
|
|||
char *invocation)
|
||||
{
|
||||
|
||||
char *buf = (char *)HeapAlloc( PSDRV_Heap, 0, sizeof(psheader) +
|
||||
strlen(feature) + strlen(value));
|
||||
char *buf = (char *)HeapAlloc( PSDRV_Heap, 0, sizeof(psbeginfeature) +
|
||||
strlen(feature) + strlen(value));
|
||||
|
||||
|
||||
sprintf(buf, psbeginfeature, feature, value);
|
||||
|
@ -296,7 +296,7 @@ INT PSDRV_WriteHeader( DC *dc, LPCSTR title )
|
|||
char *buf, *orient, vectbuf[256];
|
||||
INPUTSLOT *slot;
|
||||
PAGESIZE *page;
|
||||
int urx, ury, i, j;
|
||||
int llx, lly, urx, ury, i, j;
|
||||
|
||||
TRACE("'%s'\n", title);
|
||||
|
||||
|
@ -306,22 +306,23 @@ INT PSDRV_WriteHeader( DC *dc, LPCSTR title )
|
|||
WARN("HeapAlloc failed\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* BBox co-ords are in default user co-ord system so urx < ury even in
|
||||
landscape mode */
|
||||
llx = physDev->PageSize.left * 72.0 / dc->devCaps->logPixelsX;
|
||||
lly = physDev->PageSize.bottom * 72.0 / dc->devCaps->logPixelsY;
|
||||
urx = physDev->PageSize.right * 72.0 / dc->devCaps->logPixelsX;
|
||||
ury = physDev->PageSize.top * 72.0 / dc->devCaps->logPixelsY;
|
||||
|
||||
if(physDev->Devmode->dmPublic.u1.s1.dmOrientation == DMORIENT_LANDSCAPE) {
|
||||
/* BBox co-ords are in default user co-ord system so urx < ury even in
|
||||
landscape mode */
|
||||
urx = (int) (dc->devCaps->vertSize * 72.0 / 25.4);
|
||||
ury = (int) (dc->devCaps->horzSize * 72.0 / 25.4);
|
||||
orient = "Landscape";
|
||||
} else {
|
||||
urx = (int) (dc->devCaps->horzSize * 72.0 / 25.4);
|
||||
ury = (int) (dc->devCaps->vertSize * 72.0 / 25.4);
|
||||
orient = "Portrait";
|
||||
}
|
||||
|
||||
/* FIXME should do something better with BBox */
|
||||
|
||||
sprintf(buf, psheader, title, 0, 0, urx, ury, orient);
|
||||
sprintf(buf, psheader, title, llx, lly, urx, ury, orient);
|
||||
|
||||
if( WriteSpool16( physDev->job.hJob, buf, strlen(buf) ) !=
|
||||
strlen(buf) ) {
|
||||
|
@ -440,16 +441,17 @@ INT PSDRV_WriteNewPage( DC *dc )
|
|||
|
||||
if(physDev->Devmode->dmPublic.u1.s1.dmOrientation == DMORIENT_LANDSCAPE) {
|
||||
if(physDev->pi->ppd->LandscapeOrientation == -90) {
|
||||
xtrans = dc->devCaps->vertRes;
|
||||
ytrans = dc->devCaps->horzRes;
|
||||
xtrans = physDev->PageSize.right;
|
||||
ytrans = physDev->PageSize.top;
|
||||
rotation = 90;
|
||||
} else {
|
||||
xtrans = ytrans = 0;
|
||||
xtrans = physDev->PageSize.left;
|
||||
ytrans = physDev->PageSize.bottom;
|
||||
rotation = -90;
|
||||
}
|
||||
} else {
|
||||
xtrans = 0;
|
||||
ytrans = dc->devCaps->vertRes;
|
||||
xtrans = physDev->PageSize.left;
|
||||
ytrans = physDev->PageSize.top;
|
||||
rotation = 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -231,6 +231,7 @@ typedef struct {
|
|||
JOB job;
|
||||
PSDRV_DEVMODEA *Devmode;
|
||||
PRINTERINFO *pi;
|
||||
RECT PageSize; /* Imageable area in device co-ords */
|
||||
} PSDRV_PDEVICE;
|
||||
|
||||
typedef struct {
|
||||
|
|
Loading…
Reference in New Issue