Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 159788 Details for
Bug 96394
Printing: get a list of paper formats for a printer
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
Windows Printer Patchv01
Print_v01.txt (text/plain), 29.32 KB, created by
Praveen
on 2010-02-22 09:29:29 EST
(
hide
)
Description:
Windows Printer Patchv01
Filename:
MIME Type:
Creator:
Praveen
Created:
2010-02-22 09:29:29 EST
Size:
29.32 KB
patch
obsolete
>### 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<paperList.length; i++) { >+ if (paperSize.equals(paperList[i])) break; >+ } >+ if (i == paperList.length) return -1; >+ short[] paperSizeNumbers = Printer.getPaperSizeList(); >+ return paperSizeNumbers[i]; >+} >+ > /** > * Sets the printer data that will be used when the dialog > * is opened. >@@ -327,7 +339,7 @@ > /* Initialize PRINTDLG fields, including DEVMODE. */ > pd.Flags = OS.PD_RETURNDEFAULT; > if (OS.PrintDlg(pd)) { >- >+ > /* > * If user setup info from a previous print dialog was specified, > * then restore the previous DEVMODE struct. >@@ -347,26 +359,135 @@ > int /*long*/ ptr = OS.GlobalLock(hMem); > DEVMODE devmode = OS.IsUnicode ? (DEVMODE)new DEVMODEW () : new DEVMODEA (); > OS.MoveMemory(devmode, ptr, OS.IsUnicode ? OS.DEVMODEW_sizeof() : OS.DEVMODEA_sizeof()); >+ /* Printer Name */ >+ if (printerData.name != null) { >+ String name = printerData.name; >+ if (OS.IsUnicode) { >+ char[] buffer = new char[32]; >+ name.getChars(0, name.length(), buffer, 0); >+ ((DEVMODEW)devmode).dmDeviceName = buffer; >+ } else { >+ ((DEVMODEA)devmode).dmDeviceName = name.getBytes(); >+ } >+ } >+ /* Orientation */ > devmode.dmFields |= OS.DM_ORIENTATION; > devmode.dmOrientation = printerData.orientation == PrinterData.PORTRAIT ? OS.DMORIENT_PORTRAIT : OS.DMORIENT_LANDSCAPE; >- if (printerData.copyCount != 1) { >- devmode.dmFields |= OS.DM_COPIES; >- devmode.dmCopies = (short)printerData.copyCount; >- } >- if (printerData.collate != false) { >- devmode.dmFields |= OS.DM_COLLATE; >- devmode.dmCollate = OS.DMCOLLATE_TRUE; >+ /* Copy Count */ >+ devmode.dmFields |= OS.DM_COPIES; >+ devmode.dmCopies = (short)printerData.copyCount; >+ /* Collate */ >+ devmode.dmFields |= OS.DM_COLLATE; >+ devmode.dmCollate = OS.DMCOLLATE_TRUE; >+ /*Scale*/ >+ devmode.dmFields |= OS.DM_SCALE; >+ devmode.dmScale = (short)printerData.scale; >+ /* Duplex Mode */ >+ devmode.dmFields |= OS.DM_DUPLEX; >+ devmode.dmDuplex = (short)(printerData.duplex + 1); >+ /* Paper size*/ >+ byte[] currentPrinter; >+ if (printerData.name == null) { >+ int[] nameLen = new int[1]; >+ OS.GetDefaultPrinter (null, nameLen); >+ currentPrinter = new byte[nameLen[0] - 1]; >+ OS.GetDefaultPrinter (currentPrinter, nameLen); >+ } else { >+ currentPrinter = printerData.name.getBytes(); >+ } >+ int[] /*long*/ printerHandle = new int /*long*/ [1]; >+ OS.OpenPrinter (currentPrinter, printerHandle, null); >+ /* TODO: >+ * Do we need to CreateDC and ResetDC for the changes of >+ * custom paperSize to get reflected in the public devmode >+ * settings ? >+ */ >+/* TCHAR driver1 = new TCHAR(0, "winspool", true); >+ TCHAR name = new TCHAR(0, ((DEVMODEW)devmode).dmDeviceName, true); >+ int long hdc = OS.CreateDC(driver1, name, 0, ptr);*/ >+ if (printerData.paperSizeName.intern() == PrinterData.PAPER_CUSTOM) { >+ devmode.dmFields |= OS.DM_PAPERSIZE | OS.DM_PAPERWIDTH | OS.DM_PAPERLENGTH; >+ devmode.dmPaperSize = OS.DMPAPER_USER; >+ /* Coversion from Inches -to- tenths of mm */ >+ devmode.dmPaperLength = (short)(printerData.customPaperHeight * 25.40 * 10); >+ devmode.dmPaperWidth = (short)(printerData.customPaperWidth * 25.40 * 10); >+ >+ /*TODO: We might need to add a new custom paper size to the existing >+ * set of forms. However, this doesn't work for unknown reasons for now. >+ */ >+ /*FORM_INFO_1 printForm = new FORM_INFO_1(); >+ printForm.Flags = 0; >+ printForm.Size.cx = (int) printerData.customPaperHeight * 25400; >+ printForm.Size.cy = (int) printerData.customPaperHeight * 25400; >+ printForm.ImageableArea.left = 0; >+ printForm.ImageableArea.top = 0; >+ printForm.ImageableArea.bottom = printForm.Size.cx; >+ printForm.ImageableArea.right = printForm.Size.cy; >+ >+ TCHAR buffer = new TCHAR (0, printerData.customPaperName, true); >+ int byteCount = buffer.length () * TCHAR.sizeof; >+ printForm.pName = OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, byteCount); >+ OS.MoveMemory (printForm.pName, buffer, byteCount); >+ >+ int long formPtr = OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, FORM_INFO_1.sizeof); >+ OS.MoveMemory(formPtr, printForm, FORM_INFO_1.sizeof); >+ boolean addRes = OS.AddForm (printerHandle[0], 1, formPtr); >+ System.out.println("AddForm result:"+addRes); >+ addRes = OS.SetForm (printerHandle[0], buffer.bytes, 1, formPtr); >+ System.out.println("SetForm result:"+addRes);*/ >+ } else { >+ devmode.dmFields |= OS.DM_PAPERSIZE; >+ String keys[] = {PrinterData.PAPER_LEGAL, PrinterData.PAPER_LETTER, PrinterData.PAPER_A2, PrinterData.PAPER_A4, >+ PrinterData.PAPER_A5, PrinterData.PAPER_A6, PrinterData.PAPER_B5, PrinterData.PAPER_JB5, PrinterData.PAPER_EXECUTIVE}; >+ short[] values = {OS.DMPAPER_LEGAL, OS.DMPAPER_LETTER, OS.DMPAPER_A2, OS.DMPAPER_A4, >+ OS.DMPAPER_A5, OS.DMPAPER_A6, OS.DMPAPER_B5, OS.DMPAPER_JB5, OS.DMPAPER_EXECUTIVE}; >+ int index; >+ for (index=0; index < keys.length; index++) { >+ if (printerData.paperSizeName.equals(keys[index])) break; >+ } >+ if (index < keys.length) { >+ devmode.dmPaperSize = values [index]; >+ } else { >+ try { >+ devmode.dmPaperSize = Short.parseShort(printerData.paperSizeName); >+ } catch(NumberFormatException nfe) { >+ short paperNumber = getSystemPaperSize (printerData.paperSizeName); >+ if (paperNumber != -1) devmode.dmPaperSize = paperNumber; >+ else devmode.dmPaperSize = OS.DMPAPER_A4; >+ } >+ } >+ } >+ /* Pages Per Side */ >+ if (devmode.dmNup == 1) { >+ devmode.dmFields |= OS.DM_NUP; >+ /*TODO: Currently there is no way of directly >+ * assigning the Nup value. >+ * OS.updateNup(devmode.dmDriverExtra, 4); >+ */ > } >+ /* Resolution */ >+ if (printerData.resolutionX != 0 && printerData.resolutionY != 0) { >+ devmode.dmFields |= OS.DM_YRESOLUTION | OS.DM_PRINTQUALITY; >+ devmode.dmYResolution = (short) printerData.resolutionY; >+ devmode.dmPrintQuality = (short) printerData.resolutionX; >+ } >+ /* Sync with devmode settings for getting apt values of PaperSize */ > OS.MoveMemory(ptr, devmode, OS.IsUnicode ? OS.DEVMODEW_sizeof() : OS.DEVMODEA_sizeof()); >+ OS.DocumentProperties(0, printerHandle[0], currentPrinter, 0, ptr, OS.DM_IN_BUFFER); >+ /*OS.ResetDC (hdc, ptr);*/ > OS.GlobalUnlock(hMem); >- >+ > pd.Flags = OS.PD_USEDEVMODECOPIESANDCOLLATE; >- if (printerData.printToFile) pd.Flags |= OS.PD_PRINTTOFILE; > switch (printerData.scope) { > case PrinterData.PAGE_RANGE: pd.Flags |= OS.PD_PAGENUMS; break; > case PrinterData.SELECTION: pd.Flags |= OS.PD_SELECTION; break; > default: pd.Flags |= OS.PD_ALLPAGES; > } >+ String outputFileName = null; >+ if (printerData.printToFile) { >+ pd.Flags |= OS.PD_PRINTTOFILE; >+ if (printerData.fileName != null) outputFileName = printerData.fileName; >+ } > pd.nMinPage = 1; > pd.nMaxPage = -1; > pd.nFromPage = (short) Math.min (0xFFFF, Math.max (1, printerData.startPage)); >@@ -405,7 +526,7 @@ > short[] offsets = new short[4]; > OS.MoveMemory(offsets, ptr, 2 * offsets.length); > TCHAR buffer = new TCHAR(0, size); >- OS.MoveMemory(buffer, ptr, size); >+ OS.MoveMemory(buffer, ptr, size); > OS.GlobalUnlock(hMem); > if (pd.hDevNames != 0) OS.GlobalFree(pd.hDevNames); > >@@ -416,7 +537,7 @@ > i++; > } > String driver = buffer.toString(driverOffset, i); >- >+ > int deviceOffset = offsets[1]; > i = 0; > while (deviceOffset + i < size) { >@@ -443,7 +564,15 @@ > data.scope = PrinterData.SELECTION; > } > data.printToFile = (pd.Flags & OS.PD_PRINTTOFILE) != 0; >- if (data.printToFile) data.fileName = output; >+ if (data.printToFile) { >+ String fullPath; >+ if (outputFileName != null && !outputFileName.equals("")) { >+ fullPath = outputFileName; >+ } else { >+ fullPath = output; >+ } >+ data.fileName = fullPath; >+ } > data.copyCount = pd.nCopies; > data.collate = (pd.Flags & OS.PD_COLLATE) != 0; > >Index: Eclipse SWT Printing/win32/org/eclipse/swt/printing/Printer.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.swt/Eclipse SWT Printing/win32/org/eclipse/swt/printing/Printer.java,v >retrieving revision 1.48 >diff -u -r1.48 Printer.java >--- Eclipse SWT Printing/win32/org/eclipse/swt/printing/Printer.java 1 Jul 2009 14:50:47 -0000 1.48 >+++ Eclipse SWT Printing/win32/org/eclipse/swt/printing/Printer.java 22 Feb 2010 14:19:45 -0000 >@@ -150,6 +150,72 @@ > return new PrinterData(driver, deviceName); > } > >+/** >+ * Returns an array of String objects representing all >+ * paper size names supported by printer on the platform. >+ * Note that the returned paper size names might be the >+ * list supported by only default printer. >+ * >+ * @return a String array containing paper size names. >+ */ >+public static String[] getPaperNameList () { >+ String[] resArray = null; >+ int[] pOutput = new int[1]; >+ int paperNamesLen = getDeviceCapabilities(OS.DC_PAPERNAMES, pOutput); >+ if (paperNamesLen > 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: >+ * <dl> >+ * <dt><code>DUPLEX_SIMPLEX</code></dt> >+ * <dd>Normal one-sided printing</dd> >+ * <dt><code>DUPLEX_HORIZONTAL</code></dt> >+ * <dd>Duplex printing with page being horizontal</dd> >+ * <dt><code>DUPLEX_VERTICAL</code></dt> >+ * <dd>Duplex printing with page being vertical</dd> >+ * </dl> >+ * >+ * @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: >+ * <dl> >+ * <dt><code>PAPER_LETTER</code></dt> >+ * <dt><code>PAPER_LEGAL</code></dt> >+ * <dt><code>PAPER_A2</code></dt> >+ * <dt><code>PAPER_A4</code></dt> >+ * <dt><code>PAPER_A5</code></dt> >+ * <dt><code>PAPER_A6</code></dt> >+ * <dt><code>PAPER_B5</code></dt> >+ * <dt><code>PAPER_JB5</code></dt> >+ * <dt><code>PAPER_EXECUTIVE</code></dt> >+ * <dt><code>PAPER_CUSTOM</code></dt> >+ * </dl> >+ * >+ * Also accepts any paper size from the list of available paper size >+ * names returned by method <code>Printer.getPaperSizeList</code>. >+ * >+ * @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 <code>paperSize</code> >+ * is not specified as <code>PAPER_CUSTOM</code>. >+ * >+ * @since 3.6 >+ */ >+ public double customPaperHeight = 0; >+ >+ /** >+ * The physical width of the custom paper name in inches. >+ * Note that this field is ignored if <code>paperSize</code> >+ * is not specified as <code>PAPER_CUSTOM</code>. >+ * >+ * @since 3.6 >+ */ >+ public double customPaperWidth = 0; >+ >+ /** >+ * The name of the custom paper size. >+ * Note that this field is ignored if <code>paperSize</code> >+ * is not specified as <code>PAPER_CUSTOM</code>. >+ * >+ * @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 <code>paperSize</code> is not >+ * specified as <code>PAPER_CUSTOM</code>. >+ * >+ * @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; >+ >+ /** > * <code>scope</code> field value indicating that > * all pages should be printed > */ >@@ -148,6 +260,116 @@ > public static final int LANDSCAPE = 2; > > /** >+ * <code>duplex</code> field value indicating >+ * one-sided printing >+ * >+ * @since 3.6 >+ */ >+ public static final int DUPLEX_SIMPLEX = 1; >+ >+ /** >+ * <code>duplex</code> field value indicating >+ * double sided printing on short edge >+ * >+ * @since 3.6 >+ */ >+ public static final int DUPLEX_HORIZONTAL = 2; >+ >+ /** >+ * <code>duplex</code> field value indicating >+ * double sided printing on long edge >+ * >+ * @since 3.6 >+ */ >+ public static final int DUPLEX_VERTICAL = 3; >+ >+ /** >+ * <code>paperSize</code> field value indicating >+ * the paper size as LETTER >+ * >+ * @since 3.6 >+ */ >+ public static final String PAPER_LETTER = "LETTER"; >+ >+ /** >+ * <code>paperSize</code> field value indicating >+ * the paper size as LEGAL >+ * >+ * @since 3.6 >+ */ >+ public static final String PAPER_LEGAL = "LEGAL"; >+ >+ /** >+ * <code>paperSize</code> field value indicating >+ * the paper size as A4 sheet >+ * >+ * @since 3.6 >+ */ >+ public static final String PAPER_A2 = "A2"; >+ >+ /** >+ * <code>paperSize</code> field value indicating >+ * the paper size as A4 sheet >+ * >+ * @since 3.6 >+ */ >+ public static final String PAPER_A4 = "A4"; >+ >+ /** >+ * <code>paperSize</code> field value indicating >+ * the paper size as A4 sheet >+ * >+ * @since 3.6 >+ */ >+ public static final String PAPER_A5 = "A5"; >+ >+ /** >+ * <code>paperSize</code> field value indicating >+ * the paper size as A4 sheet >+ * >+ * @since 3.6 >+ */ >+ public static final String PAPER_A6 = "A6"; >+ >+ /** >+ * <code>paperSize</code> field value indicating >+ * the paper size as B5 sheet >+ * >+ * @since 3.6 >+ */ >+ public static final String PAPER_B5 = "B5"; >+ >+ /** >+ * <code>paperSize</code> field value indicating >+ * the paper size as JB5 sheet >+ * >+ * @since 3.6 >+ */ >+ public static final String PAPER_JB5 = "JB5"; >+ >+ /** >+ * <code>paperSize</code> field value indicating >+ * the paper size as EXECUTIVE >+ * >+ * @since 3.6 >+ */ >+ public static final String PAPER_EXECUTIVE = "EXECUTIVE"; >+ >+ /** >+ * <code>paperSize</code> field value indicating the paper >+ * size as Custom. When this field is specified, the values >+ * for <code>customPaperHeight</code> and <code>customPaperWidth</code> >+ * are required to create a custom paper size and optionally, >+ * <code>customPaperName</code> <code>customPaperDisplayName</code>. >+ * >+ * 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 <code>PrintDialog</code>. >@@ -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 (); >+}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 96394
:
158751
|
158841
|
159788
|
161015
|
161111
|
162862
|
162867