{Start|End}{Doc|Page} go through DCfuncs.

Implement these in the PostScript driver.
Change PSDRV_Escape to use them.
This commit is contained in:
Huw D M Davies 1999-07-25 11:25:59 +00:00 committed by Alexandre Julliard
parent d0e15a6b72
commit 815615025e
7 changed files with 267 additions and 136 deletions

View File

@ -7,12 +7,13 @@
#include "psdrv.h"
#include "debugtools.h"
#include "winspool.h"
#include "heap.h"
DEFAULT_DEBUG_CHANNEL(psdrv)
INT PSDRV_Escape( DC *dc, INT nEscape, INT cbInput,
SEGPTR lpInData, SEGPTR lpOutData )
SEGPTR lpInData, SEGPTR lpOutData )
{
PSDRV_PDEVICE *physDev = (PSDRV_PDEVICE *)dc->physDev;
@ -38,13 +39,11 @@ INT PSDRV_Escape( DC *dc, INT nEscape, INT cbInput,
if(!physDev->job.hJob) {
FIXME("hJob == 0. Now what?\n");
return 0;
return SP_ERROR;
}
if(!PSDRV_WriteEndPage( dc ))
return 0;
physDev->job.NeedPageHeader = TRUE;
if(!PSDRV_EndPage( dc ))
return SP_ERROR;
return 1;
case QUERYESCSUPPORT:
@ -86,46 +85,35 @@ INT PSDRV_Escape( DC *dc, INT nEscape, INT cbInput,
return 1;
case STARTDOC:
{
DOCINFOA doc;
char *name = NULL;
INT16 ret;
TRACE("STARTDOC\n");
if(physDev->job.hJob) {
FIXME("hJob != 0. Now what?\n");
return 0;
}
physDev->job.hJob = OpenJob16(physDev->job.output,
PTR_SEG_TO_LIN(lpInData), dc->hSelf);
if(!physDev->job.hJob) {
WARN("OpenJob failed\n");
return 0;
/* lpInData may not be 0 terminated so we must copy it */
if(lpInData) {
name = HeapAlloc( GetProcessHeap(), 0, cbInput+1 );
memcpy(name, PTR_SEG_TO_LIN(lpInData), cbInput);
name[cbInput] = '\0';
}
physDev->job.banding = FALSE;
physDev->job.NeedPageHeader = FALSE;
physDev->job.PageNo = 1;
if(!PSDRV_WriteHeader( dc, PTR_SEG_TO_LIN(lpInData), cbInput ))
return 0;
doc.cbSize = sizeof(doc);
doc.lpszDocName = name;
doc.lpszOutput = doc.lpszDatatype = NULL;
doc.fwType = 0;
if(!PSDRV_WriteNewPage( dc ))
return 0;
return 1;
ret = PSDRV_StartDoc(dc, &doc);
if(name) HeapFree( GetProcessHeap(), 0, name );
if(ret <= 0) return -1;
ret = PSDRV_StartPage(dc);
if(ret <= 0) return -1;
return ret;
}
case ENDDOC:
TRACE("ENDDOC\n");
if(!physDev->job.hJob) {
FIXME("hJob == 0. Now what?\n");
return 0;
}
physDev->job.NeedPageHeader = FALSE;
if(!PSDRV_WriteFooter( dc ))
return 0;
if( CloseJob16( physDev->job.hJob ) == SP_ERROR ) {
WARN("CloseJob error\n");
return 0;
}
physDev->job.hJob = 0;
return 1;
return PSDRV_EndDoc( dc );
case GETPHYSPAGESIZE:
{
@ -257,3 +245,99 @@ INT PSDRV_Escape( DC *dc, INT nEscape, INT cbInput,
return 0;
}
}
/************************************************************************
* PSDRV_StartPage
*/
INT PSDRV_StartPage( DC *dc )
{
PSDRV_PDEVICE *physDev = (PSDRV_PDEVICE *)dc->physDev;
if(!physDev->job.OutOfPage) {
FIXME("Already started a page?\n");
return 1;
}
physDev->job.PageNo++;
if(!PSDRV_WriteNewPage( dc ))
return 0;
physDev->job.OutOfPage = FALSE;
return 1;
}
/************************************************************************
* PSDRV_EndPage
*/
INT PSDRV_EndPage( DC *dc )
{
PSDRV_PDEVICE *physDev = (PSDRV_PDEVICE *)dc->physDev;
if(physDev->job.OutOfPage) {
FIXME("Already ended a page?\n");
return 1;
}
if(!PSDRV_WriteEndPage( dc ))
return 0;
physDev->job.OutOfPage = TRUE;
return 1;
}
/************************************************************************
* PSDRV_StartDoc
*/
INT PSDRV_StartDoc( DC *dc, const DOCINFOA *doc )
{
PSDRV_PDEVICE *physDev = (PSDRV_PDEVICE *)dc->physDev;
if(physDev->job.hJob) {
FIXME("hJob != 0. Now what?\n");
return 0;
}
if(doc->lpszOutput) {
HeapFree( PSDRV_Heap, 0, physDev->job.output );
physDev->job.output = HEAP_strdupA( PSDRV_Heap, 0, doc->lpszOutput );
}
physDev->job.hJob = OpenJob16(physDev->job.output, doc->lpszDocName,
dc->hSelf);
if(!physDev->job.hJob) {
WARN("OpenJob failed\n");
return 0;
}
physDev->job.banding = FALSE;
physDev->job.OutOfPage = TRUE;
physDev->job.PageNo = 0;
if(!PSDRV_WriteHeader( dc, doc->lpszDocName ))
return 0;
return physDev->job.hJob;
}
/************************************************************************
* PSDRV_EndDoc
*/
INT PSDRV_EndDoc( DC *dc )
{
PSDRV_PDEVICE *physDev = (PSDRV_PDEVICE *)dc->physDev;
if(!physDev->job.hJob) {
FIXME("hJob == 0. Now what?\n");
return 0;
}
if(!physDev->job.OutOfPage) {
WARN("Somebody forgot a EndPage\n");
PSDRV_EndPage( dc );
}
if(!PSDRV_WriteFooter( dc ))
return 0;
if( CloseJob16( physDev->job.hJob ) == SP_ERROR ) {
WARN("CloseJob error\n");
return 0;
}
physDev->job.hJob = 0;
return 1;
}

View File

@ -36,8 +36,8 @@ static const DC_FUNCTIONS PSDRV_Funcs =
NULL, /* pDeleteObject */
PSDRV_DeviceCapabilities, /* pDeviceCapabilities */
PSDRV_Ellipse, /* pEllipse */
NULL, /* pEndDoc */
NULL, /* pEndPage */
PSDRV_EndDoc, /* pEndDoc */
PSDRV_EndPage, /* pEndPage */
PSDRV_EnumDeviceFonts, /* pEnumDeviceFonts */
PSDRV_Escape, /* pEscape */
NULL, /* pExcludeClipRect */
@ -95,8 +95,8 @@ static const DC_FUNCTIONS PSDRV_Funcs =
NULL, /* pSetViewportOrg (optional) */
NULL, /* pSetWindowExt (optional) */
NULL, /* pSetWindowOrg (optional) */
NULL, /* pStartDoc */
NULL, /* pStartPage */
PSDRV_StartDoc, /* pStartDoc */
PSDRV_StartPage, /* pStartPage */
NULL, /* pStretchBlt */
PSDRV_StretchDIBits /* pStretchDIBits */
};

View File

@ -251,11 +251,9 @@ int PSDRV_WriteSpool(DC *dc, LPSTR lpData, WORD cch)
{
PSDRV_PDEVICE *physDev = (PSDRV_PDEVICE *)dc->physDev;
if(physDev->job.NeedPageHeader) {
physDev->job.PageNo++;
if( !PSDRV_WriteNewPage(dc) )
if(physDev->job.OutOfPage) { /* Will get here after NEWFRAME Escape */
if( !PSDRV_StartPage(dc) )
return FALSE;
physDev->job.NeedPageHeader = FALSE;
}
return WriteSpool16( physDev->job.hJob, lpData, cch );
}
@ -282,26 +280,20 @@ INT PSDRV_WriteFeature(HANDLE16 hJob, char *feature, char *value,
INT PSDRV_WriteHeader( DC *dc, char *title, int len )
INT PSDRV_WriteHeader( DC *dc, LPCSTR title )
{
PSDRV_PDEVICE *physDev = (PSDRV_PDEVICE *)dc->physDev;
char *buf, *titlebuf, *orient, vectbuf[256];
char *buf, *orient, vectbuf[256];
INPUTSLOT *slot;
PAGESIZE *page;
int urx, ury, i, j;
titlebuf = (char *)HeapAlloc( PSDRV_Heap, 0, len+1 );
if(!titlebuf) {
WARN("HeapAlloc failed\n");
return 0;
}
memcpy(titlebuf, title, len);
titlebuf[len] = '\0';
TRACE("'%s'\n", title);
buf = (char *)HeapAlloc( PSDRV_Heap, 0, sizeof(psheader) + len + 30);
buf = (char *)HeapAlloc( PSDRV_Heap, 0, sizeof(psheader) +
strlen(title) + 30 );
if(!buf) {
WARN("HeapAlloc failed\n");
HeapFree( PSDRV_Heap, 0, titlebuf );
return 0;
}
@ -319,16 +311,14 @@ INT PSDRV_WriteHeader( DC *dc, char *title, int len )
/* FIXME should do something better with BBox */
sprintf(buf, psheader, titlebuf, 0, 0, urx, ury, orient);
sprintf(buf, psheader, title, 0, 0, urx, ury, orient);
if( WriteSpool16( physDev->job.hJob, buf, strlen(buf) ) !=
strlen(buf) ) {
WARN("WriteSpool error\n");
HeapFree( PSDRV_Heap, 0, titlebuf );
HeapFree( PSDRV_Heap, 0, buf );
return 0;
}
HeapFree( PSDRV_Heap, 0, titlebuf );
HeapFree( PSDRV_Heap, 0, buf );
WriteSpool16( physDev->job.hJob, psbeginprolog, strlen(psbeginprolog) );

View File

@ -258,10 +258,10 @@ file gdi.exe
376 pascal16 ResetDC(word ptr) ResetDC16
377 pascal16 StartDoc(word ptr) StartDoc16
378 pascal16 EndDoc(word) EndDoc16
379 pascal16 StartPage(word) stub_GDI_379
379 pascal16 StartPage(word) StartPage16
380 pascal16 EndPage(word) EndPage16
381 pascal16 SetAbortProc(word segptr) SetAbortProc16
382 pascal16 AbortDoc() stub_GDI_382
382 pascal16 AbortDoc() AbortDoc16
400 pascal16 FastWindowFrame(word ptr s_word s_word long) FastWindowFrame16
401 stub GDIMOVEBITMAP
403 stub GDIINIT2

View File

@ -214,9 +214,9 @@ typedef struct {
typedef struct {
HANDLE16 hJob;
LPSTR output; /* Output file/port */
BOOL banding; /* Have we received a NEXTBAND */
BOOL NeedPageHeader; /* Page header not sent yet */
INT PageNo;
BOOL banding; /* Have we received a NEXTBAND */
BOOL OutOfPage; /* Page header not sent yet */
INT PageNo;
} JOB;
typedef struct {
@ -263,7 +263,7 @@ extern void PSDRV_CreateColor( PSDRV_PDEVICE *physDev, PSCOLOR *pscolor,
COLORREF wincolor );
extern INT PSDRV_WriteHeader( DC *dc, char *title, int len );
extern INT PSDRV_WriteHeader( DC *dc, LPCSTR title );
extern INT PSDRV_WriteFooter( DC *dc );
extern INT PSDRV_WriteNewPage( DC *dc );
extern INT PSDRV_WriteEndPage( DC *dc );
@ -315,6 +315,8 @@ extern BOOL PSDRV_Chord( DC *dc, INT left, INT top, INT right,
INT xend, INT yend );
extern BOOL PSDRV_Ellipse( DC *dc, INT left, INT top, INT right,
INT bottom );
extern INT PSDRV_EndDoc( DC *dc );
extern INT PSDRV_EndPage( DC *dc );
extern BOOL PSDRV_EnumDeviceFonts( DC* dc, LPLOGFONT16 plf,
DEVICEFONTENUMPROC proc, LPARAM lp );
extern INT PSDRV_Escape( DC *dc, INT nEscape, INT cbInput,
@ -349,11 +351,14 @@ extern COLORREF PSDRV_SetBkColor( DC *dc, COLORREF color );
extern VOID PSDRV_SetDeviceClipping( DC *dc );
extern COLORREF PSDRV_SetPixel( DC *dc, INT x, INT y, COLORREF color );
extern COLORREF PSDRV_SetTextColor( DC *dc, COLORREF color );
extern INT PSDRV_StartDoc( DC *dc, const DOCINFOA *doc );
extern INT PSDRV_StartPage( DC *dc );
extern INT PSDRV_StretchDIBits( DC *dc, INT xDst, INT yDst,
INT widthDst, INT heightDst, INT xSrc,
INT ySrc, INT widthSrc, INT heightSrc,
const void *bits, const BITMAPINFO *info,
UINT wUsage, DWORD dwRop );
INT widthDst, INT heightDst, INT xSrc,
INT ySrc, INT widthSrc, INT heightSrc,
const void *bits, const BITMAPINFO *info,
UINT wUsage, DWORD dwRop );
extern INT PSDRV_ExtDeviceMode(HWND hwnd, LPDEVMODEA lpdmOutput,
LPSTR lpszDevice, LPSTR lpszPort,
LPDEVMODEA lpdmInput, LPSTR lpszProfile,

View File

@ -431,7 +431,7 @@ BOOL16 WINAPI OffsetViewportOrgEx16(HDC16,INT16,INT16,LPPOINT16);
INT16 WINAPI OffsetVisRgn16(HDC16,INT16,INT16);
DWORD WINAPI OffsetWindowOrg16(HDC16,INT16,INT16);
BOOL16 WINAPI OffsetWindowOrgEx16(HDC16,INT16,INT16,LPPOINT16);
HANDLE16 WINAPI OpenJob16(LPSTR,LPSTR,HDC16);
HANDLE16 WINAPI OpenJob16(LPCSTR,LPCSTR,HDC16);
BOOL16 WINAPI PaintRgn16(HDC16,HRGN16);
BOOL16 WINAPI PatBlt16(HDC16,INT16,INT16,INT16,INT16,DWORD);
HRGN16 WINAPI PathToRegion16(HDC16);

View File

@ -25,6 +25,7 @@
#include "callback.h"
#include "xmalloc.h"
#include "options.h"
#include "heap.h"
DEFAULT_DEBUG_CHANNEL(print)
@ -39,74 +40,65 @@ static char Printers[] = "System\\CurrentControlSet\\Control\\Print\\Printers\\
*/
INT16 WINAPI StartDoc16( HDC16 hdc, const DOCINFO16 *lpdoc )
{
INT16 retVal;
TRACE("(%p)\n", lpdoc );
TRACE("%d 0x%lx:0x%p 0x%lx:0x%p\n",lpdoc->cbSize,
lpdoc->lpszDocName,PTR_SEG_TO_LIN(lpdoc->lpszDocName),
lpdoc->lpszOutput,PTR_SEG_TO_LIN(lpdoc->lpszOutput));
TRACE("%d %s %s\n",lpdoc->cbSize,
(LPSTR)PTR_SEG_TO_LIN(lpdoc->lpszDocName),
(LPSTR)PTR_SEG_TO_LIN(lpdoc->lpszOutput));
retVal = Escape16(hdc, STARTDOC,
strlen((LPSTR)PTR_SEG_TO_LIN(lpdoc->lpszDocName)), lpdoc->lpszDocName, 0);
TRACE("Escape16 returned %d\n",retVal);
return retVal;
DOCINFOA docA;
docA.cbSize = lpdoc->cbSize;
docA.lpszDocName = PTR_SEG_TO_LIN(lpdoc->lpszDocName);
docA.lpszOutput = PTR_SEG_TO_LIN(lpdoc->lpszOutput);
docA.lpszDatatype = NULL;
docA.fwType = 0;
return StartDocA(hdc, &docA);
}
/******************************************************************
* EndPage16 [GDI.380]
* StartDocA [GDI32.347]
*
*/
INT16 WINAPI EndPage16( HDC16 hdc )
INT WINAPI StartDocA(HDC hdc, const DOCINFOA* doc)
{
INT16 retVal;
retVal = Escape16(hdc, NEWFRAME, 0, 0, 0);
TRACE("Escape16 returned %d\n",retVal);
return retVal;
}
DC *dc = DC_GetDCPtr( hdc );
/******************************************************************
* StartDoc32A [GDI32.347]
*
*/
INT WINAPI StartDocA(HDC hdc ,const DOCINFOA* doc)
{
TRACE("DocName = '%s' Output = '%s' Datatype = '%s'\n",
doc->lpszDocName, doc->lpszOutput, doc->lpszDatatype);
return Escape(hdc,
STARTDOC,
strlen(doc->lpszDocName),
doc->lpszDocName,
0);
if(!dc) return 0;
if(dc->funcs->pStartDoc)
return dc->funcs->pStartDoc( dc, doc );
else
return Escape(hdc, STARTDOC, strlen(doc->lpszDocName),
doc->lpszDocName, 0);
}
/*************************************************************************
* StartDoc32W [GDI32.348]
* StartDocW [GDI32.348]
*
*/
INT WINAPI StartDocW(HDC hdc, const DOCINFOW* doc) {
FIXME("stub\n");
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
return 0; /* failure*/
}
/******************************************************************
* StartPage32 [GDI32.349]
*
*/
INT WINAPI StartPage(HDC hdc)
INT WINAPI StartDocW(HDC hdc, const DOCINFOW* doc)
{
FIXME("stub\n");
return 1;
}
DOCINFOA docA;
INT ret;
/******************************************************************
* EndPage32 [GDI32.77]
*
*/
INT WINAPI EndPage(HDC hdc)
{
return Escape(hdc, NEWFRAME, 0, 0, 0);
docA.cbSize = doc->cbSize;
docA.lpszDocName = doc->lpszDocName ?
HEAP_strdupWtoA( GetProcessHeap(), 0, doc->lpszDocName ) : NULL;
docA.lpszOutput = doc->lpszOutput ?
HEAP_strdupWtoA( GetProcessHeap(), 0, doc->lpszOutput ) : NULL;
docA.lpszDatatype = doc->lpszDatatype ?
HEAP_strdupWtoA( GetProcessHeap(), 0, doc->lpszDatatype ) : NULL;
docA.fwType = doc->fwType;
ret = StartDocA(hdc, &docA);
if(docA.lpszDocName)
HeapFree( GetProcessHeap(), 0, (LPSTR)docA.lpszDocName );
if(docA.lpszOutput)
HeapFree( GetProcessHeap(), 0, (LPSTR)docA.lpszOutput );
if(docA.lpszDatatype)
HeapFree( GetProcessHeap(), 0, (LPSTR)docA.lpszDatatype );
return ret;
}
/******************************************************************
@ -115,16 +107,71 @@ INT WINAPI EndPage(HDC hdc)
*/
INT16 WINAPI EndDoc16(HDC16 hdc)
{
return Escape16(hdc, ENDDOC, 0, 0, 0);
return EndDoc(hdc);
}
/******************************************************************
* EndDoc32 [GDI32.76]
* EndDoc [GDI32.76]
*
*/
INT WINAPI EndDoc(HDC hdc)
{
return Escape(hdc, ENDDOC, 0, 0, 0);
DC *dc = DC_GetDCPtr( hdc );
if(!dc) return 0;
if(dc->funcs->pEndDoc)
return dc->funcs->pEndDoc( dc );
else
return Escape(hdc, ENDDOC, 0, 0, 0);
}
/******************************************************************
* StartPage16 [GDI.379]
*
*/
INT16 WINAPI StartPage16(HDC16 hdc)
{
return StartPage(hdc);
}
/******************************************************************
* StartPage [GDI32.349]
*
*/
INT WINAPI StartPage(HDC hdc)
{
DC *dc = DC_GetDCPtr( hdc );
if(!dc) return 0;
if(dc->funcs->pStartPage)
return dc->funcs->pStartPage( dc );
FIXME("stub\n");
return 1;
}
/******************************************************************
* EndPage16 [GDI.380]
*
*/
INT16 WINAPI EndPage16( HDC16 hdc )
{
return EndPage(hdc);
}
/******************************************************************
* EndPage [GDI32.77]
*
*/
INT WINAPI EndPage(HDC hdc)
{
DC *dc = DC_GetDCPtr( hdc );
if(!dc) return 0;
if(dc->funcs->pEndPage)
return dc->funcs->pEndPage( dc );
else
return Escape(hdc, NEWFRAME, 0, 0, 0);
}
/******************************************************************************
@ -132,20 +179,25 @@ INT WINAPI EndDoc(HDC hdc)
*/
INT16 WINAPI AbortDoc16(HDC16 hdc)
{
return Escape16(hdc, ABORTDOC, 0, 0, 0);
return AbortDoc(hdc);
}
/******************************************************************************
* AbortDoc32 [GDI32.0]
* AbortDoc [GDI32.105]
*/
INT WINAPI AbortDoc(HDC hdc)
{
FIXME("(%d): stub\n", hdc);
return 1;
DC *dc = DC_GetDCPtr( hdc );
if(!dc) return 0;
if(dc->funcs->pAbortDoc)
return dc->funcs->pAbortDoc( dc );
else
return Escape(hdc, ABORTDOC, 0, 0, 0);
}
/**********************************************************************
* QueryAbort (GDI.155)
* QueryAbort16 (GDI.155)
*
* Calls the app's AbortProc function if avail.
*
@ -363,7 +415,7 @@ static PPRINTJOB FindPrintJobFromHandle(HANDLE16 hHandle)
}
/* TTD Need to do some DOS->UNIX file conversion here */
static int CreateSpoolFile(LPSTR pszOutput)
static int CreateSpoolFile(LPCSTR pszOutput)
{
int fd=-1;
char psCmd[1024];
@ -378,7 +430,7 @@ static int CreateSpoolFile(LPSTR pszOutput)
TRACE("Got printerSpoolCommand '%s' for output device '%s'\n",
psCmd, pszOutput);
if (!*psCmd)
psCmdP = pszOutput;
psCmdP = (char *)pszOutput;
else
{
while (*psCmdP && isspace(*psCmdP))
@ -444,7 +496,7 @@ static int FreePrintJob(HANDLE16 hJob)
* OpenJob (GDI.240)
*
*/
HANDLE16 WINAPI OpenJob16(LPSTR lpOutput, LPSTR lpTitle, HDC16 hDC)
HANDLE16 WINAPI OpenJob16(LPCSTR lpOutput, LPCSTR lpTitle, HDC16 hDC)
{
HANDLE16 hHandle = (HANDLE16)SP_ERROR;
PPRINTJOB pPrintJob;