### Eclipse Workspace Patch 1.0 #P org.eclipse.swt Index: Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/OS.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/OS.java,v retrieving revision 1.428 diff -u -r1.428 OS.java --- Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/OS.java 20 Jan 2010 19:06:50 -0000 1.428 +++ Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/OS.java 22 Feb 2010 14:19:43 -0000 @@ -511,6 +511,8 @@ public static final int DATE_LONGDATE = 0x00000002; public static final int DATE_SHORTDATE = 0x00000001; public static final int DATE_YEARMONTH = 0x00000008; //#if(WINVER >= 0x0500) + public static final int DC_PAPERS = 2; + public static final int DC_PAPERNAMES = 16; public static final int DCX_CACHE = 0x2; public static final int DCX_CLIPCHILDREN = 0x8; public static final int DCX_CLIPSIBLINGS = 0x10; @@ -544,10 +546,30 @@ public static final short DMCOLLATE_TRUE = 1; public static final int DM_SETDEFID = 0x401; public static final int DM_COLLATE = 0x00008000; + public static final int DM_FORMNAME = 0x00010000; + public static final int DM_IN_BUFFER = 0x00000002; + public static final int DM_SCALE = 0x00000010; + public static final int DM_DUPLEX = 0x00001000; + public static final int DM_YRESOLUTION = 0x00002000; + public static final int DM_PRINTQUALITY = 0x00000400; + public static final int DM_NUP = 0x00000040; public static final int DM_COPIES = 0x00000100; public static final int DM_ORIENTATION = 0x00000001; + public static final int DM_PAPERSIZE = 0x00000002; + public static final int DM_PAPERLENGTH = 0x00000004; + public static final int DM_PAPERWIDTH = 0x00000008; public static final short DMORIENT_PORTRAIT = 1; public static final short DMORIENT_LANDSCAPE = 2; + public static final short DMPAPER_LETTER = 1; + public static final short DMPAPER_LEGAL = 5; + public static final short DMPAPER_USER = 256; + public static final short DMPAPER_EXECUTIVE = 7; + public static final short DMPAPER_A2 = 66; + public static final short DMPAPER_A4 = 9; + public static final short DMPAPER_A5 = 11; + public static final short DMPAPER_A6 = 70; + public static final short DMPAPER_B5 = 34; + public static final short DMPAPER_JB5 = 13; public static final int DSS_DISABLED = 0x20; public static final int DSTINVERT = 0x550009; public static final int DST_BITMAP = 0x4; @@ -2189,6 +2211,7 @@ public static final native int DRAWITEMSTRUCT_sizeof (); public static final native int DROPFILES_sizeof (); public static final native int DWM_BLURBEHIND_sizeof (); +public static final native int FORM_INFO_1_sizeof (); public static final native int EMR_sizeof (); public static final native int EMREXTCREATEFONTINDIRECTW_sizeof (); public static final native int EXTLOGFONTW_sizeof (); @@ -2383,6 +2406,13 @@ return CreateDCA (lpszDriver1, lpszDevice1, lpszOutput, lpInitData); } +public static final int /*long*/ ResetDC (int /*long*/ hdc, int /*long*/ lpInitData) { + if (IsUnicode) { + return ResetDCW (hdc, lpInitData); + } + return ResetDCA (hdc, lpInitData); +} + public static final int /*long*/ CreateEnhMetaFile (int /*long*/ hdcRef, TCHAR lpFilename, RECT lpRect, TCHAR lpDescription) { if (IsUnicode) { char [] lpFilename1 = lpFilename == null ? null : lpFilename.chars; @@ -2932,6 +2962,11 @@ MoveMemory (Destination, Source1, Length); } } +/** + * @param Destination cast=(PVOID) + * @param paperInfo cast=(CONST VOID *),flags=no_out + */ +public static native final void MoveMemory (int /*long*/ Destination, FORM_INFO_1 paperInfo, int Length); public static final void MoveMemory (TCHAR Destination, int /*long*/ Source, int Length) { if (IsUnicode) { @@ -2951,6 +2986,23 @@ } } +public static final int DeviceCapabilities (String device, char[] port, int capability, int /*long*/ output, int /*long*/ devMode) { + if (IsUnicode) { + char[] nameChars = new char[device.length()+1]; + device.getChars(0, device.length(), nameChars, 0); + return OS.DeviceCapabilitiesW (nameChars, port, capability, output, devMode); + } else { + return OS.DeviceCapabilitiesA (device.getBytes(), port, capability, output, devMode); + } +} + +public static final boolean SetForm (int /*long*/ printer_handle, byte[] name, int level, int /*long*/ pForm) { + if (IsUnicode) { + return SetFormW(printer_handle, name, level, pForm); + } + return SetFormA(printer_handle, name, level, pForm); +} + public static final void MoveMemory (DEVMODE Destination, int /*long*/ Source, int Length) { if (IsUnicode) { MoveMemory ((DEVMODEW)Destination, Source, Length); @@ -3592,6 +3644,16 @@ */ public static final native int /*long*/ CreateDCW (char [] lpszDriver, char [] lpszDevice, int /*long*/ lpszOutput, int /*long*/ lpInitData); /** + * @param hdc cast=(HDC) + * @param lpInitData cast=(CONST VOID *) + */ +public static final native int /*long*/ ResetDCW (int /*long*/ hdc, int /*long*/ lpInitData); +/** + * @param hdc cast=(HDC) + * @param lpInitData cast=(CONST VOID *) + */ +public static final native int /*long*/ ResetDCA (int /*long*/ hdc, int /*long*/ lpInitData); +/** * @param lpszDriver cast=(LPSTR) * @param lpszDevice cast=(LPSTR) * @param lpszOutput cast=(LPSTR) @@ -3753,6 +3815,20 @@ public static final native boolean DestroyMenu (int /*long*/ hMenu); /** @param hWnd cast=(HWND) */ public static final native boolean DestroyWindow (int /*long*/ hWnd); +/** + * @param device cast=(LPCTSTR) + * @param port cast=(LPCTSTR) + * @param output cast=(LPTSTR) + * @param devMode cast=(const DEVMODE *) + */ +public static native final int DeviceCapabilitiesA (byte[] device, char[] port, int capability, int /*long*/ output, int /*long*/ devMode); +/** + * @param device cast=(LPCTSTR) + * @param port cast=(LPCTSTR) + * @param output cast=(LPTSTR) + * @param devMode cast=(const DEVMODE *) + */ +public static native final int DeviceCapabilitiesW (char[] device, char[] port, int capability, int /*long*/ output, int /*long*/ devMode); public static final native int /*long*/ DispatchMessageW (MSG lpmsg); public static final native int /*long*/ DispatchMessageA (MSG lpmsg); /** @param hdc cast=(HDC) */ @@ -5750,6 +5826,38 @@ */ public static final native int ScriptGetCMap (int /*long*/ hdc, int /*long*/ psc, char[] pwcChars, int cChars, int dwFlags, short[] pwOutGlyphs); /** + * @param name cast=(LPTSTR) + * @param length cast=(WORD*) + */ +public static final native boolean GetDefaultPrinter (byte[] name, int[] /*long*/ length); +/** + * @param name cast=(LPTSTR) + * @param handle cast=(LPHANDLE*) + * @param defaults cast=(LPPRINTER_DEFAULTS) + */ +public static final native boolean OpenPrinter (byte[] name, int[] /*long*/ handle, int[] /*long*/ defaults); +/** + * @param printer_handle cast=(HANDLE) + * @param level cast=(DWORD) + * @param pForm cast=(LPBYTE) + */ +public static final native boolean AddForm (int /*long*/ printer_handle, int level, int /*long*/ pForm); +/** + * @param printer_handle cast=(HANDLE) + * @param name cast=(LPTSTR) + * @param level cast=(DWORD) + * @param pForm cast=(LPBYTE) + */ +public static final native boolean SetFormW (int /*long*/ printer_handle, byte[] name, int level, int /*long*/ pForm); +/** + * @param printer_handle cast=(HANDLE) + * @param name cast=(LPTSTR) + * @param level cast=(DWORD) + * @param pForm cast=(LPBYTE) + */ +public static final native boolean SetFormA (int /*long*/ printer_handle, byte[] name, int level, int /*long*/ pForm); + +/** * @param hdc cast=(HDC) * @param psc cast=(SCRIPT_CACHE *) * @param pwcChars cast=(const WCHAR *) @@ -6264,6 +6372,15 @@ * @param dwLayout cast=(DWORD) */ public static final native int SetLayout (int /*long*/ hdc, int dwLayout); +/** + * @param hParent cast=(HWND) + * @param hPrinter cast=(HANDLE) + * @param deviceName cast=(LPTSTR) + * @param pDevModeOut cast=(PDEVMODE) + * @param pDevModeIn cast=(PDEVMODE) + * @param flags cast=(DWORD) + */ +public static final native int DocumentProperties (int /*long*/ hParent, int /*long*/ hPrinter, byte[] deviceName, int /*long*/ pDevModeOut, int /*long*/ pDevModeIn, int flags); /** @param hdc cast=(HDC) */ public static final native int SetMapMode (int /*long*/ hdc, int fnMapMode); /** @@ -6569,6 +6686,8 @@ public static final native boolean UpdateLayeredWindow (int /*long*/ hwnd, int /*long*/ hdcDst, POINT pptDst, SIZE psize, int /*long*/ hdcSrc, POINT pptSrc, int crKey, BLENDFUNCTION pblend, int dwFlags); /** @param hWnd cast=(HWND) */ public static final native boolean UpdateWindow (int /*long*/ hWnd); +/** @param ptr cast=(CONST VOID *) */ +public static final native void updateNup (int /*long*/ ptr, int nup); /** @param hWnd cast=(HWND) */ public static final native boolean ValidateRect (int /*long*/ hWnd, RECT lpRect); /** @param ch cast=(WCHAR) */ @@ -6647,5 +6766,4 @@ */ public static final native boolean DuplicateHandle(int /*long*/ hSourceProcessHandle, int /*long*/ hSourceHandle, int /*long*/ hTargetProcessHandle, int /*long*/ [] lpTargetHandle, int dwDesiredAccess, boolean b, int dwOptions); - } Index: Eclipse SWT Printing/win32/org/eclipse/swt/printing/PrintDialog.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.swt/Eclipse SWT Printing/win32/org/eclipse/swt/printing/PrintDialog.java,v retrieving revision 1.49 diff -u -r1.49 PrintDialog.java --- Eclipse SWT Printing/win32/org/eclipse/swt/printing/PrintDialog.java 23 Nov 2009 21:54:12 -0000 1.49 +++ Eclipse SWT Printing/win32/org/eclipse/swt/printing/PrintDialog.java 22 Feb 2010 14:19:44 -0000 @@ -121,6 +121,18 @@ return checkBits (style, SWT.LEFT_TO_RIGHT, SWT.RIGHT_TO_LEFT, 0, 0, 0, 0); } +short getSystemPaperSize (String paperSize) { + if (paperSize == null) return -1; + String[] paperList = Printer.getPaperNameList(); + int i; + for (i=0; i 0) { + resArray = new String[paperNamesLen]; + for (int i=0; i< paperNamesLen; i++) { + TCHAR buf = new TCHAR(0, 64); + OS.MoveMemory(buf, pOutput[0] + (i * 64 * TCHAR.sizeof), 64); + String fullString = String.valueOf(buf); + resArray[i] = fullString.substring(0,fullString.indexOf('\0')); + } + if (pOutput[0] != 0) OS.HeapFree(OS.GetProcessHeap(), 0, pOutput[0]); + } + return resArray; +} + +static short[] getPaperSizeList () { + short[] resArray = null; + int[] pOutput = new int[1]; + int paperNamesLen = getDeviceCapabilities(OS.DC_PAPERS, pOutput); + if (paperNamesLen > 0) { + resArray = new short[paperNamesLen]; + OS.MoveMemory(resArray, pOutput[0], paperNamesLen * 2); + if (pOutput[0] != 0) OS.HeapFree(OS.GetProcessHeap(), 0, pOutput[0]); + } + return resArray; +} + +static int getDeviceCapabilities (int capability, int[] pOutput) { + int[] nameLen = new int[1]; + OS.GetDefaultPrinter (null, nameLen); + byte[] nameBytes = new byte[nameLen[0] - 1]; + OS.GetDefaultPrinter (nameBytes, nameLen); + String nameStr = new String(nameBytes); + + int len = OS.DeviceCapabilities (nameStr, null, capability, 0, 0); + if (len > 0) { + int /*long*/ hHeap = OS.GetProcessHeap(); + switch (capability) { + case OS.DC_PAPERS: + pOutput[0] = OS.HeapAlloc(hHeap, OS.HEAP_ZERO_MEMORY, 2 * len); + OS.DeviceCapabilities (nameStr, null, capability, pOutput[0], 0); + break; + case OS.DC_PAPERNAMES /* String [] */ : + /* + * Each paper name string buffer returned is of 64 chars long. If the name + * is shorter than 64, then \0 is filled into the buffer, otherwise the + * name is truncated at 64 chars. + */ + pOutput[0] = OS.HeapAlloc(hHeap, OS.HEAP_ZERO_MEMORY, TCHAR.sizeof * len * 64); + OS.DeviceCapabilities (nameStr, null, capability, pOutput[0], 0); + break; + } + } + return len; +} + static DeviceData checkNull (PrinterData data) { if (data == null) data = new PrinterData(); if (data.driver == null || data.name == null) { Index: Eclipse SWT PI/win32/library/os_custom.h =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.swt/Eclipse SWT PI/win32/library/os_custom.h,v retrieving revision 1.46 diff -u -r1.46 os_custom.h --- Eclipse SWT PI/win32/library/os_custom.h 1 Jul 2009 14:49:44 -0000 1.46 +++ Eclipse SWT PI/win32/library/os_custom.h 22 Feb 2010 14:19:31 -0000 @@ -77,3 +77,4 @@ #define SetWindowTheme_LIB "uxtheme.dll" #define TransparentBlt_LIB "msimg32.dll" #define UpdateLayeredWindow_LIB "user32.dll" +#define updateNup(arg0, arg1) ((PBYTE) (((BYTE *)arg0) + ((LPDEVMODE)arg0)->dmSize))[24] = arg1 \ No newline at end of file Index: Eclipse SWT Printing/common/org/eclipse/swt/printing/PrinterData.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.swt/Eclipse SWT Printing/common/org/eclipse/swt/printing/PrinterData.java,v retrieving revision 1.25 diff -u -r1.25 PrinterData.java --- Eclipse SWT Printing/common/org/eclipse/swt/printing/PrinterData.java 20 Jan 2010 13:43:49 -0000 1.25 +++ Eclipse SWT Printing/common/org/eclipse/swt/printing/PrinterData.java 22 Feb 2010 14:19:43 -0000 @@ -111,8 +111,120 @@ * @since 3.5 */ public int orientation = PORTRAIT; + + /** + * The scaling factor of the page and paper rectangle, + * expressed as a percentage by which the printed output + * to be scaled. Default value is 100 indicating no scale. + * + * @since 3.6 + */ + public double scale = 100; + + /** + * The number of logical pages to be tiled on a + * physical sheet of paper, whose value can be + * expressed either of 1, 2, 4, 6, 9 or 16. + * + * @since 3.6 + */ + public int pagesPerSide = 1; + + /** + * specifies a print job that can print either single-sided or + * double-sided printing, expressed as one of the following values: + *
+ *
DUPLEX_SIMPLEX
+ *
Normal one-sided printing
+ *
DUPLEX_HORIZONTAL
+ *
Duplex printing with page being horizontal
+ *
DUPLEX_VERTICAL
+ *
Duplex printing with page being vertical
+ *
+ * + * @since 3.6 + */ + public int duplex = DUPLEX_SIMPLEX; + + /** + * Specifies the name for the paper size used in a + * print job, expressed as one of the following values: + *
+ *
PAPER_LETTER
+ *
PAPER_LEGAL
+ *
PAPER_A2
+ *
PAPER_A4
+ *
PAPER_A5
+ *
PAPER_A6
+ *
PAPER_B5
+ *
PAPER_JB5
+ *
PAPER_EXECUTIVE
+ *
PAPER_CUSTOM
+ *
+ * + * Also accepts any paper size from the list of available paper size + * names returned by method Printer.getPaperSizeList. + * + * @since 3.6 + */ + public String paperSizeName = PAPER_A4; + + /** + * The physical height of the custom paper name in inches. + * Note that this field is ignored if paperSize + * is not specified as PAPER_CUSTOM. + * + * @since 3.6 + */ + public double customPaperHeight = 0; + + /** + * The physical width of the custom paper name in inches. + * Note that this field is ignored if paperSize + * is not specified as PAPER_CUSTOM. + * + * @since 3.6 + */ + public double customPaperWidth = 0; + + /** + * The name of the custom paper size. + * Note that this field is ignored if paperSize + * is not specified as PAPER_CUSTOM. + * + * @since 3.6 + */ + public String customPaperName; + + /** + * The human-readable name of the custom paper size to + * be displayed in print dialog. Note that this field + * is ignored if paperSize is not + * specified as PAPER_CUSTOM. + * + * @since 3.6 + */ + public String customPaperDisplayName; + + /** + * Specifies the x-resolution in dots-per-inch of the printer. + * This configures the print settings to the closest resolution + * setting that can be used for destination print job. + * + * @since 3.6 + */ + public double resolutionX; /** + * Specifies the y-resolution in dots-per-inch of the printer. + * This configures the print settings to the closest resolution + * setting that can be used for destination print job. + * + * @since 3.6 + */ + public double resolutionY; + + /** * scope field value indicating that * all pages should be printed */ @@ -148,6 +260,116 @@ public static final int LANDSCAPE = 2; /** + * duplex field value indicating + * one-sided printing + * + * @since 3.6 + */ + public static final int DUPLEX_SIMPLEX = 1; + + /** + * duplex field value indicating + * double sided printing on short edge + * + * @since 3.6 + */ + public static final int DUPLEX_HORIZONTAL = 2; + + /** + * duplex field value indicating + * double sided printing on long edge + * + * @since 3.6 + */ + public static final int DUPLEX_VERTICAL = 3; + + /** + * paperSize field value indicating + * the paper size as LETTER + * + * @since 3.6 + */ + public static final String PAPER_LETTER = "LETTER"; + + /** + * paperSize field value indicating + * the paper size as LEGAL + * + * @since 3.6 + */ + public static final String PAPER_LEGAL = "LEGAL"; + + /** + * paperSize field value indicating + * the paper size as A4 sheet + * + * @since 3.6 + */ + public static final String PAPER_A2 = "A2"; + + /** + * paperSize field value indicating + * the paper size as A4 sheet + * + * @since 3.6 + */ + public static final String PAPER_A4 = "A4"; + + /** + * paperSize field value indicating + * the paper size as A4 sheet + * + * @since 3.6 + */ + public static final String PAPER_A5 = "A5"; + + /** + * paperSize field value indicating + * the paper size as A4 sheet + * + * @since 3.6 + */ + public static final String PAPER_A6 = "A6"; + + /** + * paperSize field value indicating + * the paper size as B5 sheet + * + * @since 3.6 + */ + public static final String PAPER_B5 = "B5"; + + /** + * paperSize field value indicating + * the paper size as JB5 sheet + * + * @since 3.6 + */ + public static final String PAPER_JB5 = "JB5"; + + /** + * paperSize field value indicating + * the paper size as EXECUTIVE + * + * @since 3.6 + */ + public static final String PAPER_EXECUTIVE = "EXECUTIVE"; + + /** + * paperSize field value indicating the paper + * size as Custom. When this field is specified, the values + * for customPaperHeight and customPaperWidth + * are required to create a custom paper size and optionally, + * customPaperName customPaperDisplayName. + * + * Note that customPaperHeight and customPaperWidth are ignored + * when the field has not specified this value. + * + * @since 3.6 + */ + public static final String PAPER_CUSTOM = "CUSTOM"; + + /** * private, platform-specific data * On Windows, this contains a copy of the DEVMODE struct * returned from the PrintDialog. @@ -158,7 +380,7 @@ * This field is not currently used on the X/Window System. */ byte [] otherData; - + /** * Constructs an instance of this class that can be * used to print to the default printer. Index: Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/FORM_INFO_1.java =================================================================== RCS file: Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/FORM_INFO_1.java diff -N Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/FORM_INFO_1.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/FORM_INFO_1.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,10 @@ +package org.eclipse.swt.internal.win32; + + public class FORM_INFO_1 { + public int Flags; //DWORD + /** @field cast=(LPCTSTR) */ + public int /*long*/ pName; + public SIZE Size = new SIZE(); + public RECT ImageableArea = new RECT(); + public static final int sizeof = OS.FORM_INFO_1_sizeof (); +}