winspool: Move the default page size query to cups.c.
Signed-off-by: Huw Davies <huw@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
f519535879
commit
a75c1aa78e
|
@ -32,6 +32,62 @@
|
||||||
#include <cups/ppd.h>
|
#include <cups/ppd.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef HAVE_APPLICATIONSERVICES_APPLICATIONSERVICES_H
|
||||||
|
#define GetCurrentProcess GetCurrentProcess_Mac
|
||||||
|
#define GetCurrentThread GetCurrentThread_Mac
|
||||||
|
#define LoadResource LoadResource_Mac
|
||||||
|
#define AnimatePalette AnimatePalette_Mac
|
||||||
|
#define EqualRgn EqualRgn_Mac
|
||||||
|
#define FillRgn FillRgn_Mac
|
||||||
|
#define FrameRgn FrameRgn_Mac
|
||||||
|
#define GetPixel GetPixel_Mac
|
||||||
|
#define InvertRgn InvertRgn_Mac
|
||||||
|
#define LineTo LineTo_Mac
|
||||||
|
#define OffsetRgn OffsetRgn_Mac
|
||||||
|
#define PaintRgn PaintRgn_Mac
|
||||||
|
#define Polygon Polygon_Mac
|
||||||
|
#define ResizePalette ResizePalette_Mac
|
||||||
|
#define SetRectRgn SetRectRgn_Mac
|
||||||
|
#define EqualRect EqualRect_Mac
|
||||||
|
#define FillRect FillRect_Mac
|
||||||
|
#define FrameRect FrameRect_Mac
|
||||||
|
#define GetCursor GetCursor_Mac
|
||||||
|
#define InvertRect InvertRect_Mac
|
||||||
|
#define OffsetRect OffsetRect_Mac
|
||||||
|
#define PtInRect PtInRect_Mac
|
||||||
|
#define SetCursor SetCursor_Mac
|
||||||
|
#define SetRect SetRect_Mac
|
||||||
|
#define ShowCursor ShowCursor_Mac
|
||||||
|
#define UnionRect UnionRect_Mac
|
||||||
|
#include <ApplicationServices/ApplicationServices.h>
|
||||||
|
#undef GetCurrentProcess
|
||||||
|
#undef GetCurrentThread
|
||||||
|
#undef LoadResource
|
||||||
|
#undef AnimatePalette
|
||||||
|
#undef EqualRgn
|
||||||
|
#undef FillRgn
|
||||||
|
#undef FrameRgn
|
||||||
|
#undef GetPixel
|
||||||
|
#undef InvertRgn
|
||||||
|
#undef LineTo
|
||||||
|
#undef OffsetRgn
|
||||||
|
#undef PaintRgn
|
||||||
|
#undef Polygon
|
||||||
|
#undef ResizePalette
|
||||||
|
#undef SetRectRgn
|
||||||
|
#undef EqualRect
|
||||||
|
#undef FillRect
|
||||||
|
#undef FrameRect
|
||||||
|
#undef GetCursor
|
||||||
|
#undef InvertRect
|
||||||
|
#undef OffsetRect
|
||||||
|
#undef PtInRect
|
||||||
|
#undef SetCursor
|
||||||
|
#undef SetRect
|
||||||
|
#undef ShowCursor
|
||||||
|
#undef UnionRect
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "ntstatus.h"
|
#include "ntstatus.h"
|
||||||
#define WIN32_NO_STATUS
|
#define WIN32_NO_STATUS
|
||||||
#include "windef.h"
|
#include "windef.h"
|
||||||
|
@ -341,3 +397,44 @@ NTSTATUS unix_get_ppd( void *args )
|
||||||
free( unix_ppd );
|
free( unix_ppd );
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
NTSTATUS unix_get_default_page_size( void *args )
|
||||||
|
{
|
||||||
|
#ifdef HAVE_APPLICATIONSERVICES_APPLICATIONSERVICES_H
|
||||||
|
struct get_default_page_size_params *params = args;
|
||||||
|
NTSTATUS status = STATUS_UNSUCCESSFUL;
|
||||||
|
PMPrintSession session = NULL;
|
||||||
|
PMPageFormat format = NULL;
|
||||||
|
CFStringRef paper_name;
|
||||||
|
PMPaper paper;
|
||||||
|
CFRange range;
|
||||||
|
int size;
|
||||||
|
|
||||||
|
if (PMCreateSession( &session )) goto end;
|
||||||
|
if (PMCreatePageFormat( &format )) goto end;
|
||||||
|
if (PMSessionDefaultPageFormat( session, format )) goto end;
|
||||||
|
if (PMGetPageFormatPaper( format, &paper )) goto end;
|
||||||
|
if (PMPaperGetPPDPaperName( paper, &paper_name )) goto end;
|
||||||
|
|
||||||
|
range.location = 0;
|
||||||
|
range.length = CFStringGetLength( paper_name );
|
||||||
|
size = (range.length + 1) * sizeof(WCHAR);
|
||||||
|
|
||||||
|
if (params->name_size >= size)
|
||||||
|
{
|
||||||
|
CFStringGetCharacters( paper_name, range, (UniChar*)params->name );
|
||||||
|
params->name[range.length] = 0;
|
||||||
|
status = STATUS_SUCCESS;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
status = STATUS_BUFFER_OVERFLOW;
|
||||||
|
params->name_size = size;
|
||||||
|
|
||||||
|
end:
|
||||||
|
if (format) PMRelease( format );
|
||||||
|
if (session) PMRelease( session );
|
||||||
|
return status;
|
||||||
|
#else
|
||||||
|
return STATUS_NOT_IMPLEMENTED;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
|
@ -48,62 +48,6 @@
|
||||||
# include <cups/ppd.h>
|
# include <cups/ppd.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef HAVE_APPLICATIONSERVICES_APPLICATIONSERVICES_H
|
|
||||||
#define GetCurrentProcess GetCurrentProcess_Mac
|
|
||||||
#define GetCurrentThread GetCurrentThread_Mac
|
|
||||||
#define LoadResource LoadResource_Mac
|
|
||||||
#define AnimatePalette AnimatePalette_Mac
|
|
||||||
#define EqualRgn EqualRgn_Mac
|
|
||||||
#define FillRgn FillRgn_Mac
|
|
||||||
#define FrameRgn FrameRgn_Mac
|
|
||||||
#define GetPixel GetPixel_Mac
|
|
||||||
#define InvertRgn InvertRgn_Mac
|
|
||||||
#define LineTo LineTo_Mac
|
|
||||||
#define OffsetRgn OffsetRgn_Mac
|
|
||||||
#define PaintRgn PaintRgn_Mac
|
|
||||||
#define Polygon Polygon_Mac
|
|
||||||
#define ResizePalette ResizePalette_Mac
|
|
||||||
#define SetRectRgn SetRectRgn_Mac
|
|
||||||
#define EqualRect EqualRect_Mac
|
|
||||||
#define FillRect FillRect_Mac
|
|
||||||
#define FrameRect FrameRect_Mac
|
|
||||||
#define GetCursor GetCursor_Mac
|
|
||||||
#define InvertRect InvertRect_Mac
|
|
||||||
#define OffsetRect OffsetRect_Mac
|
|
||||||
#define PtInRect PtInRect_Mac
|
|
||||||
#define SetCursor SetCursor_Mac
|
|
||||||
#define SetRect SetRect_Mac
|
|
||||||
#define ShowCursor ShowCursor_Mac
|
|
||||||
#define UnionRect UnionRect_Mac
|
|
||||||
#include <ApplicationServices/ApplicationServices.h>
|
|
||||||
#undef GetCurrentProcess
|
|
||||||
#undef GetCurrentThread
|
|
||||||
#undef LoadResource
|
|
||||||
#undef AnimatePalette
|
|
||||||
#undef EqualRgn
|
|
||||||
#undef FillRgn
|
|
||||||
#undef FrameRgn
|
|
||||||
#undef GetPixel
|
|
||||||
#undef InvertRgn
|
|
||||||
#undef LineTo
|
|
||||||
#undef OffsetRgn
|
|
||||||
#undef PaintRgn
|
|
||||||
#undef Polygon
|
|
||||||
#undef ResizePalette
|
|
||||||
#undef SetRectRgn
|
|
||||||
#undef EqualRect
|
|
||||||
#undef FillRect
|
|
||||||
#undef FrameRect
|
|
||||||
#undef GetCursor
|
|
||||||
#undef InvertRect
|
|
||||||
#undef OffsetRect
|
|
||||||
#undef PtInRect
|
|
||||||
#undef SetCursor
|
|
||||||
#undef SetRect
|
|
||||||
#undef ShowCursor
|
|
||||||
#undef UnionRect
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define NONAMELESSSTRUCT
|
#define NONAMELESSSTRUCT
|
||||||
#define NONAMELESSUNION
|
#define NONAMELESSUNION
|
||||||
|
|
||||||
|
@ -987,46 +931,20 @@ end:
|
||||||
|
|
||||||
static void set_ppd_overrides( HANDLE printer )
|
static void set_ppd_overrides( HANDLE printer )
|
||||||
{
|
{
|
||||||
WCHAR *wstr = NULL;
|
WCHAR buffer[256];
|
||||||
int size = 0;
|
struct get_default_page_size_params params = { .name = buffer, .name_size = sizeof(buffer) };
|
||||||
#ifdef HAVE_APPLICATIONSERVICES_APPLICATIONSERVICES_H
|
NTSTATUS status;
|
||||||
OSStatus status;
|
|
||||||
PMPrintSession session = NULL;
|
|
||||||
PMPageFormat format = NULL;
|
|
||||||
PMPaper paper;
|
|
||||||
CFStringRef paper_name;
|
|
||||||
CFRange range;
|
|
||||||
|
|
||||||
status = PMCreateSession( &session );
|
while (1)
|
||||||
if (status) goto end;
|
{
|
||||||
|
status = UNIX_CALL( get_default_page_size, ¶ms );
|
||||||
status = PMCreatePageFormat( &format );
|
if (status != STATUS_BUFFER_OVERFLOW) break;
|
||||||
if (status) goto end;
|
if (params.name != buffer) heap_free( params.name );
|
||||||
|
params.name = heap_alloc( params.name_size );
|
||||||
status = PMSessionDefaultPageFormat( session, format );
|
if (!params.name) break;
|
||||||
if (status) goto end;
|
}
|
||||||
|
if (!status) SetPrinterDataExW( printer, PPD_Overrides, DefaultPageSize, REG_SZ, (BYTE*)params.name, params.name_size );
|
||||||
status = PMGetPageFormatPaper( format, &paper );
|
if (params.name != buffer) heap_free( params.name );
|
||||||
if (status) goto end;
|
|
||||||
|
|
||||||
status = PMPaperGetPPDPaperName( paper, &paper_name );
|
|
||||||
if (status) goto end;
|
|
||||||
|
|
||||||
range.location = 0;
|
|
||||||
range.length = CFStringGetLength( paper_name );
|
|
||||||
size = (range.length + 1) * sizeof(WCHAR);
|
|
||||||
|
|
||||||
wstr = HeapAlloc( GetProcessHeap(), 0, size );
|
|
||||||
CFStringGetCharacters( paper_name, range, (UniChar*)wstr );
|
|
||||||
wstr[range.length] = 0;
|
|
||||||
|
|
||||||
end:
|
|
||||||
if (format) PMRelease( format );
|
|
||||||
if (session) PMRelease( session );
|
|
||||||
#endif
|
|
||||||
|
|
||||||
SetPrinterDataExW( printer, PPD_Overrides, DefaultPageSize, REG_SZ, (BYTE*)wstr, size );
|
|
||||||
HeapFree( GetProcessHeap(), 0, wstr );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static BOOL update_driver( HANDLE printer )
|
static BOOL update_driver( HANDLE printer )
|
||||||
|
|
|
@ -52,6 +52,12 @@ struct enum_printers_params
|
||||||
unsigned int num;
|
unsigned int num;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct get_default_page_size_params
|
||||||
|
{
|
||||||
|
WCHAR *name;
|
||||||
|
unsigned int name_size;
|
||||||
|
};
|
||||||
|
|
||||||
struct get_ppd_params
|
struct get_ppd_params
|
||||||
{
|
{
|
||||||
const WCHAR *printer; /* set to NULL to unlink */
|
const WCHAR *printer; /* set to NULL to unlink */
|
||||||
|
@ -62,4 +68,5 @@ struct get_ppd_params
|
||||||
|
|
||||||
NTSTATUS unix_process_attach( void * ) DECLSPEC_HIDDEN;
|
NTSTATUS unix_process_attach( void * ) DECLSPEC_HIDDEN;
|
||||||
NTSTATUS unix_enum_printers( void * ) DECLSPEC_HIDDEN;
|
NTSTATUS unix_enum_printers( void * ) DECLSPEC_HIDDEN;
|
||||||
|
NTSTATUS unix_get_default_page_size( void * ) DECLSPEC_HIDDEN;
|
||||||
NTSTATUS unix_get_ppd( void * ) DECLSPEC_HIDDEN;
|
NTSTATUS unix_get_ppd( void * ) DECLSPEC_HIDDEN;
|
||||||
|
|
Loading…
Reference in New Issue