Huw Davies : winspool: On OS/ X read the default paper size from the core printing api.
Alexandre Julliard
julliard at winehq.org
Thu Jun 21 15:03:41 CDT 2012
Module: wine
Branch: master
Commit: 6a65a048932df790c92abcb736ef0ac0c5978a88
URL: http://source.winehq.org/git/wine.git/?a=commit;h=6a65a048932df790c92abcb736ef0ac0c5978a88
Author: Huw Davies <huw at codeweavers.com>
Date: Thu Jun 21 12:59:03 2012 +0100
winspool: On OS/X read the default paper size from the core printing api.
---
dlls/winspool.drv/Makefile.in | 1 +
dlls/winspool.drv/info.c | 106 +++++++++++++++++++++++++++++++++++++++++
2 files changed, 107 insertions(+), 0 deletions(-)
diff --git a/dlls/winspool.drv/Makefile.in b/dlls/winspool.drv/Makefile.in
index 1c6933b..7a5380f 100644
--- a/dlls/winspool.drv/Makefile.in
+++ b/dlls/winspool.drv/Makefile.in
@@ -3,6 +3,7 @@ MODULE = winspool.drv
IMPORTLIB = winspool
IMPORTS = user32 gdi32 advapi32
EXTRAINCL = @CUPSINCL@
+EXTRALIBS = @APPLICATIONSERVICESLIB@
C_SRCS = \
info.c \
diff --git a/dlls/winspool.drv/info.c b/dlls/winspool.drv/info.c
index a8d245f..bb530de 100644
--- a/dlls/winspool.drv/info.c
+++ b/dlls/winspool.drv/info.c
@@ -45,6 +45,63 @@
# include <cups/cups.h>
#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
+#undef DPRINTF
+#endif
+
#define NONAMELESSUNION
#define NONAMELESSSTRUCT
#include "wine/library.h"
@@ -242,6 +299,9 @@ static const WCHAR LPR_Port[] = {'L','P','R',':',0};
static const WCHAR default_doc_title[] = {'L','o','c','a','l',' ','D','o','w','n','l','e','v','e','l',' ',
'D','o','c','u','m','e','n','t',0};
+static const WCHAR PPD_Overrides[] = {'P','P','D',' ','O','v','e','r','r','i','d','e','s',0};
+static const WCHAR DefaultPageSize[] = {'D','e','f','a','u','l','t','P','a','g','e','S','i','z','e',0};
+
static const DWORD di_sizeof[] = {0, sizeof(DRIVER_INFO_1W), sizeof(DRIVER_INFO_2W),
sizeof(DRIVER_INFO_3W), sizeof(DRIVER_INFO_4W),
sizeof(DRIVER_INFO_5W), sizeof(DRIVER_INFO_6W),
@@ -944,6 +1004,50 @@ end:
}
+static void set_ppd_overrides( HANDLE printer )
+{
+ WCHAR *wstr = NULL;
+ int size = 0;
+#ifdef HAVE_APPLICATIONSERVICES_APPLICATIONSERVICES_H
+ OSStatus status;
+ PMPrintSession session = NULL;
+ PMPageFormat format = NULL;
+ PMPaper paper;
+ CFStringRef paper_name;
+ CFRange range;
+
+ status = PMCreateSession( &session );
+ if (status) goto end;
+
+ status = PMCreatePageFormat( &format );
+ if (status) goto end;
+
+ status = PMSessionDefaultPageFormat( session, format );
+ if (status) goto end;
+
+ status = PMGetPageFormatPaper( format, &paper );
+ 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 )
{
BOOL ret, is_cups;
@@ -975,6 +1079,8 @@ static BOOL update_driver( HANDLE printer )
HeapFree( GetProcessHeap(), 0, ppd );
HeapFree( GetProcessHeap(), 0, queue_name );
+ set_ppd_overrides( printer );
+
/* call into the driver to update the devmode */
DocumentPropertiesW( 0, printer, NULL, NULL, NULL, 0 );
More information about the wine-cvs
mailing list