View | Details | Raw Unified | Return to bug 96394 | Differences between
and this patch

Collapse All | Expand All

(-)Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/OS.java (-1 / +119 lines)
Lines 511-516 Link Here
511
	public static final int DATE_LONGDATE = 0x00000002;
511
	public static final int DATE_LONGDATE = 0x00000002;
512
	public static final int DATE_SHORTDATE = 0x00000001;
512
	public static final int DATE_SHORTDATE = 0x00000001;
513
	public static final int DATE_YEARMONTH = 0x00000008; //#if(WINVER >= 0x0500)
513
	public static final int DATE_YEARMONTH = 0x00000008; //#if(WINVER >= 0x0500)
514
	public static final int DC_PAPERS = 2;
515
	public static final int DC_PAPERNAMES = 16;
514
	public static final int DCX_CACHE = 0x2;
516
	public static final int DCX_CACHE = 0x2;
515
	public static final int DCX_CLIPCHILDREN = 0x8;
517
	public static final int DCX_CLIPCHILDREN = 0x8;
516
	public static final int DCX_CLIPSIBLINGS = 0x10;
518
	public static final int DCX_CLIPSIBLINGS = 0x10;
Lines 544-553 Link Here
544
	public static final short DMCOLLATE_TRUE = 1;
546
	public static final short DMCOLLATE_TRUE = 1;
545
	public static final int DM_SETDEFID = 0x401;
547
	public static final int DM_SETDEFID = 0x401;
546
	public static final int DM_COLLATE = 0x00008000;
548
	public static final int DM_COLLATE = 0x00008000;
549
	public static final int DM_FORMNAME = 0x00010000;
550
	public static final int DM_IN_BUFFER = 0x00000002;
551
	public static final int DM_SCALE = 0x00000010;
552
	public static final int DM_DUPLEX = 0x00001000;	
553
	public static final int DM_YRESOLUTION = 0x00002000;
554
	public static final int DM_PRINTQUALITY = 0x00000400;
555
	public static final int DM_NUP = 0x00000040;
547
	public static final int DM_COPIES = 0x00000100;
556
	public static final int DM_COPIES = 0x00000100;
548
	public static final int DM_ORIENTATION = 0x00000001;
557
	public static final int DM_ORIENTATION = 0x00000001;
558
	public static final int DM_PAPERSIZE = 0x00000002;
559
	public static final int DM_PAPERLENGTH = 0x00000004;
560
	public static final int DM_PAPERWIDTH = 0x00000008;
549
	public static final short DMORIENT_PORTRAIT = 1;
561
	public static final short DMORIENT_PORTRAIT = 1;
550
	public static final short DMORIENT_LANDSCAPE = 2;
562
	public static final short DMORIENT_LANDSCAPE = 2;
563
	public static final short DMPAPER_LETTER = 1;
564
	public static final short DMPAPER_LEGAL = 5;
565
	public static final short DMPAPER_USER = 256;
566
	public static final short DMPAPER_EXECUTIVE = 7;
567
	public static final short DMPAPER_A2 = 66;
568
	public static final short DMPAPER_A4 = 9;
569
	public static final short DMPAPER_A5 = 11;
570
	public static final short DMPAPER_A6 = 70;
571
	public static final short DMPAPER_B5 = 34;
572
	public static final short DMPAPER_JB5 = 13;
551
	public static final int DSS_DISABLED = 0x20;
573
	public static final int DSS_DISABLED = 0x20;
552
	public static final int DSTINVERT = 0x550009;
574
	public static final int DSTINVERT = 0x550009;
553
	public static final int DST_BITMAP = 0x4;
575
	public static final int DST_BITMAP = 0x4;
Lines 2189-2194 Link Here
2189
public static final native int DRAWITEMSTRUCT_sizeof ();
2211
public static final native int DRAWITEMSTRUCT_sizeof ();
2190
public static final native int DROPFILES_sizeof ();
2212
public static final native int DROPFILES_sizeof ();
2191
public static final native int DWM_BLURBEHIND_sizeof ();
2213
public static final native int DWM_BLURBEHIND_sizeof ();
2214
public static final native int FORM_INFO_1_sizeof ();
2192
public static final native int EMR_sizeof ();
2215
public static final native int EMR_sizeof ();
2193
public static final native int EMREXTCREATEFONTINDIRECTW_sizeof ();
2216
public static final native int EMREXTCREATEFONTINDIRECTW_sizeof ();
2194
public static final native int EXTLOGFONTW_sizeof ();
2217
public static final native int EXTLOGFONTW_sizeof ();
Lines 2383-2388 Link Here
2383
	return CreateDCA (lpszDriver1, lpszDevice1, lpszOutput, lpInitData);
2406
	return CreateDCA (lpszDriver1, lpszDevice1, lpszOutput, lpInitData);
2384
}
2407
}
2385
2408
2409
public static final int /*long*/ ResetDC (int /*long*/ hdc, int /*long*/ lpInitData) {
2410
	if (IsUnicode) {
2411
		return ResetDCW (hdc, lpInitData);
2412
	}
2413
	return ResetDCA (hdc, lpInitData);
2414
}
2415
2386
public static final int /*long*/ CreateEnhMetaFile (int /*long*/ hdcRef, TCHAR lpFilename, RECT lpRect, TCHAR lpDescription) {
2416
public static final int /*long*/ CreateEnhMetaFile (int /*long*/ hdcRef, TCHAR lpFilename, RECT lpRect, TCHAR lpDescription) {
2387
	if (IsUnicode) {
2417
	if (IsUnicode) {
2388
		char [] lpFilename1 = lpFilename == null ? null : lpFilename.chars;
2418
		char [] lpFilename1 = lpFilename == null ? null : lpFilename.chars;
Lines 2932-2937 Link Here
2932
		MoveMemory (Destination, Source1, Length);
2962
		MoveMemory (Destination, Source1, Length);
2933
	}
2963
	}
2934
}
2964
}
2965
/**
2966
 * @param Destination cast=(PVOID)
2967
 * @param paperInfo cast=(CONST VOID *),flags=no_out
2968
 */
2969
public static native final void MoveMemory (int /*long*/ Destination, FORM_INFO_1 paperInfo, int Length);
2935
2970
2936
public static final void MoveMemory (TCHAR Destination, int /*long*/ Source, int Length) {
2971
public static final void MoveMemory (TCHAR Destination, int /*long*/ Source, int Length) {
2937
	if (IsUnicode) {
2972
	if (IsUnicode) {
Lines 2951-2956 Link Here
2951
	}
2986
	}
2952
}
2987
}
2953
2988
2989
public static final int DeviceCapabilities (String device, char[] port, int capability, int /*long*/ output, int /*long*/ devMode) {
2990
	if (IsUnicode) {
2991
		char[] nameChars = new char[device.length()+1];
2992
		device.getChars(0, device.length(), nameChars, 0);
2993
		return OS.DeviceCapabilitiesW (nameChars, port, capability, output, devMode);
2994
	} else {
2995
		return OS.DeviceCapabilitiesA (device.getBytes(), port, capability, output, devMode);
2996
	}
2997
}
2998
2999
public static final boolean SetForm (int /*long*/ printer_handle, byte[] name, int level, int /*long*/ pForm) {
3000
	if (IsUnicode) {
3001
		return SetFormW(printer_handle, name, level, pForm);
3002
	}
3003
	return SetFormA(printer_handle, name, level, pForm);
3004
}
3005
2954
public static final void MoveMemory (DEVMODE Destination, int /*long*/ Source, int Length) {
3006
public static final void MoveMemory (DEVMODE Destination, int /*long*/ Source, int Length) {
2955
	if (IsUnicode) {
3007
	if (IsUnicode) {
2956
		MoveMemory ((DEVMODEW)Destination, Source, Length);
3008
		MoveMemory ((DEVMODEW)Destination, Source, Length);
Lines 3592-3597 Link Here
3592
 */
3644
 */
3593
public static final native int /*long*/ CreateDCW (char [] lpszDriver, char [] lpszDevice, int /*long*/ lpszOutput, int /*long*/ lpInitData);  
3645
public static final native int /*long*/ CreateDCW (char [] lpszDriver, char [] lpszDevice, int /*long*/ lpszOutput, int /*long*/ lpInitData);  
3594
/**
3646
/**
3647
 * @param hdc cast=(HDC)
3648
 * @param lpInitData cast=(CONST VOID *)
3649
 */
3650
public static final native int /*long*/ ResetDCW (int /*long*/ hdc, int /*long*/ lpInitData);
3651
/**
3652
 * @param hdc cast=(HDC)
3653
 * @param lpInitData cast=(CONST VOID *)
3654
 */
3655
public static final native int /*long*/ ResetDCA (int /*long*/ hdc, int /*long*/ lpInitData);
3656
/**
3595
 * @param lpszDriver cast=(LPSTR)
3657
 * @param lpszDriver cast=(LPSTR)
3596
 * @param lpszDevice cast=(LPSTR)
3658
 * @param lpszDevice cast=(LPSTR)
3597
 * @param lpszOutput cast=(LPSTR)
3659
 * @param lpszOutput cast=(LPSTR)
Lines 3753-3758 Link Here
3753
public static final native boolean DestroyMenu (int /*long*/ hMenu);
3815
public static final native boolean DestroyMenu (int /*long*/ hMenu);
3754
/** @param hWnd cast=(HWND) */
3816
/** @param hWnd cast=(HWND) */
3755
public static final native boolean DestroyWindow (int /*long*/ hWnd);
3817
public static final native boolean DestroyWindow (int /*long*/ hWnd);
3818
/**
3819
 * @param device cast=(LPCTSTR)
3820
 * @param port cast=(LPCTSTR)
3821
 * @param output cast=(LPTSTR)
3822
 * @param devMode cast=(const DEVMODE *)
3823
 */
3824
public static native final int DeviceCapabilitiesA (byte[] device, char[] port, int capability, int /*long*/ output, int /*long*/ devMode);
3825
/**
3826
 * @param device cast=(LPCTSTR)
3827
 * @param port cast=(LPCTSTR)
3828
 * @param output cast=(LPTSTR)
3829
 * @param devMode cast=(const DEVMODE *)
3830
 */
3831
public static native final int DeviceCapabilitiesW (char[] device, char[] port, int capability, int /*long*/ output, int /*long*/ devMode);
3756
public static final native int /*long*/ DispatchMessageW (MSG lpmsg);
3832
public static final native int /*long*/ DispatchMessageW (MSG lpmsg);
3757
public static final native int /*long*/ DispatchMessageA (MSG lpmsg);
3833
public static final native int /*long*/ DispatchMessageA (MSG lpmsg);
3758
/** @param hdc cast=(HDC) */
3834
/** @param hdc cast=(HDC) */
Lines 5750-5755 Link Here
5750
 */
5826
 */
5751
public static final native int ScriptGetCMap (int /*long*/ hdc, int /*long*/ psc, char[] pwcChars, int cChars, int dwFlags, short[] pwOutGlyphs);
5827
public static final native int ScriptGetCMap (int /*long*/ hdc, int /*long*/ psc, char[] pwcChars, int cChars, int dwFlags, short[] pwOutGlyphs);
5752
/**
5828
/**
5829
 * @param name cast=(LPTSTR)
5830
 * @param length cast=(WORD*)
5831
 */
5832
public static final native boolean GetDefaultPrinter (byte[] name, int[] /*long*/ length);
5833
/**
5834
 * @param name cast=(LPTSTR)
5835
 * @param handle cast=(LPHANDLE*)
5836
 * @param defaults cast=(LPPRINTER_DEFAULTS)
5837
 */
5838
public static final native boolean OpenPrinter (byte[] name, int[] /*long*/ handle, int[] /*long*/ defaults);
5839
/**
5840
 * @param printer_handle cast=(HANDLE)
5841
 * @param level cast=(DWORD)
5842
 * @param pForm cast=(LPBYTE)
5843
 */
5844
public static final native boolean AddForm (int /*long*/ printer_handle, int level, int /*long*/ pForm);
5845
/**
5846
 * @param printer_handle cast=(HANDLE)
5847
 * @param name cast=(LPTSTR)
5848
 * @param level cast=(DWORD)
5849
 * @param pForm cast=(LPBYTE)
5850
 */
5851
public static final native boolean SetFormW (int /*long*/ printer_handle, byte[] name, int level, int /*long*/ pForm);
5852
/**
5853
 * @param printer_handle cast=(HANDLE)
5854
 * @param name cast=(LPTSTR)
5855
 * @param level cast=(DWORD)
5856
 * @param pForm cast=(LPBYTE)
5857
 */
5858
public static final native boolean SetFormA (int /*long*/ printer_handle, byte[] name, int level, int /*long*/ pForm);
5859
5860
/**
5753
 * @param hdc cast=(HDC)
5861
 * @param hdc cast=(HDC)
5754
 * @param psc cast=(SCRIPT_CACHE *)
5862
 * @param psc cast=(SCRIPT_CACHE *)
5755
 * @param pwcChars cast=(const WCHAR *)
5863
 * @param pwcChars cast=(const WCHAR *)
Lines 6264-6269 Link Here
6264
 * @param dwLayout cast=(DWORD)
6372
 * @param dwLayout cast=(DWORD)
6265
 */
6373
 */
6266
public static final native int SetLayout (int /*long*/ hdc, int dwLayout);
6374
public static final native int SetLayout (int /*long*/ hdc, int dwLayout);
6375
/**
6376
 * @param hParent cast=(HWND)
6377
 * @param hPrinter cast=(HANDLE)
6378
 * @param deviceName cast=(LPTSTR)
6379
 * @param pDevModeOut cast=(PDEVMODE)
6380
 * @param pDevModeIn cast=(PDEVMODE)
6381
 * @param flags cast=(DWORD)
6382
 */
6383
public static final native int DocumentProperties (int /*long*/ hParent, int /*long*/ hPrinter, byte[] deviceName, int /*long*/ pDevModeOut, int /*long*/ pDevModeIn, int flags);
6267
/** @param hdc cast=(HDC) */
6384
/** @param hdc cast=(HDC) */
6268
public static final native int SetMapMode (int /*long*/ hdc, int fnMapMode);
6385
public static final native int SetMapMode (int /*long*/ hdc, int fnMapMode);
6269
/**
6386
/**
Lines 6569-6574 Link Here
6569
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);
6686
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);
6570
/** @param hWnd cast=(HWND) */
6687
/** @param hWnd cast=(HWND) */
6571
public static final native boolean UpdateWindow (int /*long*/ hWnd);
6688
public static final native boolean UpdateWindow (int /*long*/ hWnd);
6689
/** @param ptr cast=(CONST VOID *) */
6690
public static final native void updateNup (int /*long*/ ptr, int nup);
6572
/** @param hWnd cast=(HWND) */
6691
/** @param hWnd cast=(HWND) */
6573
public static final native boolean ValidateRect (int /*long*/ hWnd, RECT lpRect);
6692
public static final native boolean ValidateRect (int /*long*/ hWnd, RECT lpRect);
6574
/** @param ch cast=(WCHAR) */
6693
/** @param ch cast=(WCHAR) */
Lines 6647-6651 Link Here
6647
 */
6766
 */
6648
public static final native boolean DuplicateHandle(int /*long*/ hSourceProcessHandle, int /*long*/ hSourceHandle, int /*long*/ hTargetProcessHandle,
6767
public static final native boolean DuplicateHandle(int /*long*/ hSourceProcessHandle, int /*long*/ hSourceHandle, int /*long*/ hTargetProcessHandle,
6649
		int /*long*/ [] lpTargetHandle, int dwDesiredAccess, boolean b, int dwOptions);
6768
		int /*long*/ [] lpTargetHandle, int dwDesiredAccess, boolean b, int dwOptions);
6650
6651
}
6769
}
(-)Eclipse SWT Printing/win32/org/eclipse/swt/printing/PrintDialog.java (-13 / +142 lines)
Lines 121-126 Link Here
121
	return checkBits (style, SWT.LEFT_TO_RIGHT, SWT.RIGHT_TO_LEFT, 0, 0, 0, 0);
121
	return checkBits (style, SWT.LEFT_TO_RIGHT, SWT.RIGHT_TO_LEFT, 0, 0, 0, 0);
122
}
122
}
123
123
124
short getSystemPaperSize (String paperSize) {
125
	if (paperSize == null) return -1;
126
	String[] paperList = Printer.getPaperNameList();
127
	int i;
128
	for (i=0; i<paperList.length; i++) {
129
		if (paperSize.equals(paperList[i])) break;
130
	}
131
	if (i == paperList.length) return -1;
132
	short[] paperSizeNumbers = Printer.getPaperSizeList();
133
	return paperSizeNumbers[i];
134
}
135
124
/**
136
/**
125
 * Sets the printer data that will be used when the dialog
137
 * Sets the printer data that will be used when the dialog
126
 * is opened.
138
 * is opened.
Lines 327-333 Link Here
327
	/* Initialize PRINTDLG fields, including DEVMODE. */
339
	/* Initialize PRINTDLG fields, including DEVMODE. */
328
	pd.Flags = OS.PD_RETURNDEFAULT;
340
	pd.Flags = OS.PD_RETURNDEFAULT;
329
	if (OS.PrintDlg(pd)) {
341
	if (OS.PrintDlg(pd)) {
330
	
342
		
331
		/*
343
		/*
332
		 * If user setup info from a previous print dialog was specified,
344
		 * If user setup info from a previous print dialog was specified,
333
		 * then restore the previous DEVMODE struct.
345
		 * then restore the previous DEVMODE struct.
Lines 347-372 Link Here
347
		int /*long*/ ptr = OS.GlobalLock(hMem);
359
		int /*long*/ ptr = OS.GlobalLock(hMem);
348
		DEVMODE devmode = OS.IsUnicode ? (DEVMODE)new DEVMODEW () : new DEVMODEA ();
360
		DEVMODE devmode = OS.IsUnicode ? (DEVMODE)new DEVMODEW () : new DEVMODEA ();
349
		OS.MoveMemory(devmode, ptr, OS.IsUnicode ? OS.DEVMODEW_sizeof() : OS.DEVMODEA_sizeof());
361
		OS.MoveMemory(devmode, ptr, OS.IsUnicode ? OS.DEVMODEW_sizeof() : OS.DEVMODEA_sizeof());
362
		/* Printer Name */
363
		if (printerData.name != null) {
364
			String name = printerData.name;
365
			if (OS.IsUnicode) {
366
				char[] buffer = new char[32];
367
				name.getChars(0, name.length(), buffer, 0);
368
				((DEVMODEW)devmode).dmDeviceName = buffer;
369
			} else {
370
				((DEVMODEA)devmode).dmDeviceName = name.getBytes();
371
			}
372
		}
373
		/* Orientation */
350
		devmode.dmFields |= OS.DM_ORIENTATION;
374
		devmode.dmFields |= OS.DM_ORIENTATION;
351
		devmode.dmOrientation = printerData.orientation == PrinterData.PORTRAIT ? OS.DMORIENT_PORTRAIT : OS.DMORIENT_LANDSCAPE;
375
		devmode.dmOrientation = printerData.orientation == PrinterData.PORTRAIT ? OS.DMORIENT_PORTRAIT : OS.DMORIENT_LANDSCAPE;
352
		if (printerData.copyCount != 1) {
376
		/* Copy Count */
353
			devmode.dmFields |= OS.DM_COPIES;
377
		devmode.dmFields |= OS.DM_COPIES;
354
			devmode.dmCopies = (short)printerData.copyCount;
378
		devmode.dmCopies = (short)printerData.copyCount;
355
		}
379
		/* Collate */
356
		if (printerData.collate != false) {
380
		devmode.dmFields |= OS.DM_COLLATE;
357
			devmode.dmFields |= OS.DM_COLLATE;
381
		devmode.dmCollate = OS.DMCOLLATE_TRUE;
358
			devmode.dmCollate = OS.DMCOLLATE_TRUE;
382
		/*Scale*/
383
		devmode.dmFields |= OS.DM_SCALE;
384
		devmode.dmScale = (short)printerData.scale;
385
		/* Duplex Mode */
386
		devmode.dmFields |= OS.DM_DUPLEX;
387
		devmode.dmDuplex = (short)(printerData.duplex + 1);
388
		/* Paper size*/
389
		byte[] currentPrinter;
390
		if (printerData.name == null) {
391
			int[] nameLen = new int[1];
392
			OS.GetDefaultPrinter (null, nameLen);
393
			currentPrinter = new byte[nameLen[0] - 1];
394
			OS.GetDefaultPrinter (currentPrinter, nameLen);
395
		} else {
396
			currentPrinter = printerData.name.getBytes();
397
		}
398
		int[] /*long*/ printerHandle = new int /*long*/ [1];
399
		OS.OpenPrinter (currentPrinter, printerHandle, null);
400
		/* TODO: 
401
		 * Do we need to CreateDC and ResetDC for the changes of
402
		 * custom paperSize to get reflected in the public devmode 
403
		 * settings ?
404
		 */
405
/*		TCHAR driver1 = new TCHAR(0, "winspool", true); 
406
		TCHAR name = new TCHAR(0, ((DEVMODEW)devmode).dmDeviceName, true);
407
		int long hdc = OS.CreateDC(driver1, name, 0, ptr);*/
408
		if (printerData.paperSizeName.intern() == PrinterData.PAPER_CUSTOM) {
409
			devmode.dmFields |= OS.DM_PAPERSIZE | OS.DM_PAPERWIDTH | OS.DM_PAPERLENGTH; 
410
			devmode.dmPaperSize = OS.DMPAPER_USER;
411
			/* Coversion from Inches -to- tenths of mm */
412
			devmode.dmPaperLength = (short)(printerData.customPaperHeight * 25.40 * 10);
413
			devmode.dmPaperWidth = (short)(printerData.customPaperWidth * 25.40 * 10);
414
415
			/*TODO: We might need to add a new custom paper size to the existing
416
			 * set of forms. However, this doesn't work for unknown reasons for now.
417
			 */
418
			/*FORM_INFO_1 printForm = new FORM_INFO_1();
419
			printForm.Flags = 0;
420
			printForm.Size.cx = (int) printerData.customPaperHeight * 25400;
421
			printForm.Size.cy = (int) printerData.customPaperHeight * 25400;
422
			printForm.ImageableArea.left = 0;
423
			printForm.ImageableArea.top = 0;
424
			printForm.ImageableArea.bottom = printForm.Size.cx;
425
			printForm.ImageableArea.right = printForm.Size.cy;
426
			
427
			TCHAR buffer = new TCHAR (0, printerData.customPaperName, true);
428
			int byteCount = buffer.length () * TCHAR.sizeof;
429
			printForm.pName = OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, byteCount);
430
			OS.MoveMemory (printForm.pName, buffer, byteCount);
431
			
432
			int long formPtr =  OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, FORM_INFO_1.sizeof);
433
			OS.MoveMemory(formPtr, printForm, FORM_INFO_1.sizeof);
434
			boolean addRes = OS.AddForm (printerHandle[0], 1, formPtr);
435
			System.out.println("AddForm result:"+addRes);
436
			addRes = OS.SetForm (printerHandle[0], buffer.bytes, 1, formPtr);
437
			System.out.println("SetForm result:"+addRes);*/
438
		} else {
439
			devmode.dmFields |= OS.DM_PAPERSIZE;
440
			String keys[] = {PrinterData.PAPER_LEGAL, PrinterData.PAPER_LETTER, PrinterData.PAPER_A2, PrinterData.PAPER_A4,
441
					PrinterData.PAPER_A5, PrinterData.PAPER_A6, PrinterData.PAPER_B5, PrinterData.PAPER_JB5, PrinterData.PAPER_EXECUTIVE};
442
			short[] values = {OS.DMPAPER_LEGAL, OS.DMPAPER_LETTER, OS.DMPAPER_A2, OS.DMPAPER_A4,
443
					OS.DMPAPER_A5, OS.DMPAPER_A6, OS.DMPAPER_B5, OS.DMPAPER_JB5, OS.DMPAPER_EXECUTIVE};
444
			int index;
445
			for (index=0; index < keys.length; index++) {
446
				if (printerData.paperSizeName.equals(keys[index])) break;
447
			}
448
			if (index < keys.length) {
449
				devmode.dmPaperSize = values [index];
450
			} else {
451
				try {
452
					devmode.dmPaperSize = Short.parseShort(printerData.paperSizeName);
453
				} catch(NumberFormatException nfe) {
454
					short paperNumber = getSystemPaperSize (printerData.paperSizeName);
455
					if (paperNumber != -1) devmode.dmPaperSize = paperNumber;
456
					else devmode.dmPaperSize = OS.DMPAPER_A4;
457
				}
458
			}
459
		}
460
		/* Pages Per Side */
461
		if (devmode.dmNup == 1) {
462
			devmode.dmFields |= OS.DM_NUP;
463
			/*TODO: Currently there is no way of directly
464
			 * assigning the Nup value. 
465
			 * OS.updateNup(devmode.dmDriverExtra, 4);
466
			 */
359
		}
467
		}
468
		/* Resolution */
469
		if (printerData.resolutionX != 0 && printerData.resolutionY != 0) {
470
			devmode.dmFields |= OS.DM_YRESOLUTION | OS.DM_PRINTQUALITY;
471
			devmode.dmYResolution = (short) printerData.resolutionY;
472
			devmode.dmPrintQuality = (short) printerData.resolutionX;
473
		}
474
		/* Sync with devmode settings for getting apt values of PaperSize */
360
		OS.MoveMemory(ptr, devmode, OS.IsUnicode ? OS.DEVMODEW_sizeof() : OS.DEVMODEA_sizeof());
475
		OS.MoveMemory(ptr, devmode, OS.IsUnicode ? OS.DEVMODEW_sizeof() : OS.DEVMODEA_sizeof());
476
		OS.DocumentProperties(0, printerHandle[0], currentPrinter, 0, ptr, OS.DM_IN_BUFFER);
477
		/*OS.ResetDC (hdc, ptr);*/
361
		OS.GlobalUnlock(hMem);
478
		OS.GlobalUnlock(hMem);
362
	
479
		
363
		pd.Flags = OS.PD_USEDEVMODECOPIESANDCOLLATE;
480
		pd.Flags = OS.PD_USEDEVMODECOPIESANDCOLLATE;
364
		if (printerData.printToFile) pd.Flags |= OS.PD_PRINTTOFILE;
365
		switch (printerData.scope) {
481
		switch (printerData.scope) {
366
			case PrinterData.PAGE_RANGE: pd.Flags |= OS.PD_PAGENUMS; break;
482
			case PrinterData.PAGE_RANGE: pd.Flags |= OS.PD_PAGENUMS; break;
367
			case PrinterData.SELECTION: pd.Flags |= OS.PD_SELECTION; break;
483
			case PrinterData.SELECTION: pd.Flags |= OS.PD_SELECTION; break;
368
			default: pd.Flags |= OS.PD_ALLPAGES;
484
			default: pd.Flags |= OS.PD_ALLPAGES;
369
		}
485
		}
486
		String outputFileName = null;
487
		if (printerData.printToFile) {
488
			pd.Flags |= OS.PD_PRINTTOFILE;
489
			if (printerData.fileName != null) outputFileName = printerData.fileName;
490
		}
370
		pd.nMinPage = 1;
491
		pd.nMinPage = 1;
371
		pd.nMaxPage = -1;
492
		pd.nMaxPage = -1;
372
		pd.nFromPage = (short) Math.min (0xFFFF, Math.max (1, printerData.startPage));
493
		pd.nFromPage = (short) Math.min (0xFFFF, Math.max (1, printerData.startPage));
Lines 405-411 Link Here
405
			short[] offsets = new short[4];
526
			short[] offsets = new short[4];
406
			OS.MoveMemory(offsets, ptr, 2 * offsets.length);
527
			OS.MoveMemory(offsets, ptr, 2 * offsets.length);
407
			TCHAR buffer = new TCHAR(0, size);
528
			TCHAR buffer = new TCHAR(0, size);
408
			OS.MoveMemory(buffer, ptr, size);	
529
			OS.MoveMemory(buffer, ptr, size);
409
			OS.GlobalUnlock(hMem);
530
			OS.GlobalUnlock(hMem);
410
			if (pd.hDevNames != 0) OS.GlobalFree(pd.hDevNames);
531
			if (pd.hDevNames != 0) OS.GlobalFree(pd.hDevNames);
411
	
532
	
Lines 416-422 Link Here
416
				i++;
537
				i++;
417
			}
538
			}
418
			String driver = buffer.toString(driverOffset, i);
539
			String driver = buffer.toString(driverOffset, i);
419
	
540
			
420
			int deviceOffset = offsets[1];
541
			int deviceOffset = offsets[1];
421
			i = 0;
542
			i = 0;
422
			while (deviceOffset + i < size) {
543
			while (deviceOffset + i < size) {
Lines 443-449 Link Here
443
				data.scope = PrinterData.SELECTION;
564
				data.scope = PrinterData.SELECTION;
444
			}
565
			}
445
			data.printToFile = (pd.Flags & OS.PD_PRINTTOFILE) != 0;
566
			data.printToFile = (pd.Flags & OS.PD_PRINTTOFILE) != 0;
446
			if (data.printToFile) data.fileName = output;
567
			if (data.printToFile) {
568
				String fullPath;
569
				if (outputFileName != null && !outputFileName.equals("")) {
570
					fullPath = outputFileName;
571
				} else {
572
					fullPath = output;
573
				}
574
				data.fileName = fullPath;
575
			}
447
			data.copyCount = pd.nCopies;
576
			data.copyCount = pd.nCopies;
448
			data.collate = (pd.Flags & OS.PD_COLLATE) != 0;
577
			data.collate = (pd.Flags & OS.PD_COLLATE) != 0;
449
	
578
	
(-)Eclipse SWT Printing/win32/org/eclipse/swt/printing/Printer.java (+66 lines)
Lines 150-155 Link Here
150
	return new PrinterData(driver, deviceName);
150
	return new PrinterData(driver, deviceName);
151
}
151
}
152
152
153
/**
154
 * Returns an array of String objects representing all
155
 * paper size names supported by printer on the platform.
156
 * Note that the returned paper size names might be the
157
 * list supported by only default printer.
158
 * 
159
 * @return a String array containing paper size names.
160
 */
161
public static String[] getPaperNameList () {
162
	String[] resArray = null;
163
	int[] pOutput = new int[1];
164
	int paperNamesLen = getDeviceCapabilities(OS.DC_PAPERNAMES, pOutput);
165
	if (paperNamesLen > 0) {
166
		resArray = new String[paperNamesLen];
167
		for (int i=0; i< paperNamesLen; i++) {
168
			TCHAR buf = new TCHAR(0, 64);
169
			OS.MoveMemory(buf, pOutput[0] + (i * 64 * TCHAR.sizeof), 64);
170
			String fullString = String.valueOf(buf);
171
			resArray[i] = fullString.substring(0,fullString.indexOf('\0'));
172
		}
173
		if (pOutput[0] != 0) OS.HeapFree(OS.GetProcessHeap(), 0, pOutput[0]);
174
	}
175
	return resArray;
176
}
177
178
static short[] getPaperSizeList () {
179
	short[] resArray = null;
180
	int[] pOutput = new int[1];
181
	int paperNamesLen = getDeviceCapabilities(OS.DC_PAPERS, pOutput);
182
	if (paperNamesLen > 0) {
183
		resArray = new short[paperNamesLen];
184
		OS.MoveMemory(resArray, pOutput[0], paperNamesLen * 2);
185
		if (pOutput[0] != 0) OS.HeapFree(OS.GetProcessHeap(), 0, pOutput[0]);
186
	}
187
	return resArray;
188
}
189
190
static int getDeviceCapabilities (int capability, int[] pOutput) {
191
	int[] nameLen = new int[1];
192
	OS.GetDefaultPrinter (null, nameLen);
193
	byte[] nameBytes = new byte[nameLen[0] - 1];
194
	OS.GetDefaultPrinter (nameBytes, nameLen);
195
	String nameStr = new String(nameBytes);
196
197
	int len = OS.DeviceCapabilities (nameStr, null, capability, 0, 0);
198
	if (len > 0) {
199
		int /*long*/ hHeap = OS.GetProcessHeap();
200
		switch (capability) {
201
			case OS.DC_PAPERS:
202
				pOutput[0] = OS.HeapAlloc(hHeap, OS.HEAP_ZERO_MEMORY, 2 * len);
203
				OS.DeviceCapabilities (nameStr, null, capability, pOutput[0], 0);
204
				break;
205
			case OS.DC_PAPERNAMES /* String [] */ :
206
				/* 
207
				 * Each paper name string buffer returned is of 64 chars long. If the name 
208
				 * is shorter than 64, then \0 is filled into the buffer, otherwise the
209
				 * name is truncated at 64 chars.
210
				 */
211
				pOutput[0] = OS.HeapAlloc(hHeap, OS.HEAP_ZERO_MEMORY, TCHAR.sizeof * len * 64);
212
				OS.DeviceCapabilities (nameStr, null, capability, pOutput[0], 0);
213
				break;
214
		}
215
	}
216
	return len;
217
}
218
153
static DeviceData checkNull (PrinterData data) {
219
static DeviceData checkNull (PrinterData data) {
154
	if (data == null) data = new PrinterData();
220
	if (data == null) data = new PrinterData();
155
	if (data.driver == null || data.name == null) {
221
	if (data.driver == null || data.name == null) {
(-)Eclipse SWT PI/win32/library/os_custom.h (+1 lines)
Lines 77-79 Link Here
77
#define SetWindowTheme_LIB "uxtheme.dll"
77
#define SetWindowTheme_LIB "uxtheme.dll"
78
#define TransparentBlt_LIB "msimg32.dll"
78
#define TransparentBlt_LIB "msimg32.dll"
79
#define UpdateLayeredWindow_LIB "user32.dll"
79
#define UpdateLayeredWindow_LIB "user32.dll"
80
#define updateNup(arg0, arg1) ((PBYTE) (((BYTE *)arg0) + ((LPDEVMODE)arg0)->dmSize))[24] = arg1
(-)Eclipse SWT Printing/common/org/eclipse/swt/printing/PrinterData.java (-1 / +223 lines)
Lines 111-118 Link Here
111
	 * @since 3.5
111
	 * @since 3.5
112
	 */
112
	 */
113
	public int orientation = PORTRAIT;
113
	public int orientation = PORTRAIT;
114
	
115
	/**
116
	 * The scaling factor of the page and paper rectangle,
117
	 * expressed as a percentage by which the printed output 
118
	 * to be scaled. Default value is 100 indicating no scale.
119
	 * 
120
	 * @since 3.6
121
	 */
122
	public double scale = 100;
123
124
	/**
125
	 * The number of logical pages to be tiled on a
126
	 * physical sheet of paper, whose value can be 
127
	 * expressed either of 1, 2, 4, 6, 9 or 16.
128
	 * 
129
	 * @since 3.6
130
	 */
131
	public int pagesPerSide = 1;
132
	
133
	/**
134
	 * specifies a print job that can print either single-sided or 
135
	 * double-sided printing, expressed as one of the following values: 
136
	 * <dl>
137
	 * <dt><code>DUPLEX_SIMPLEX</code></dt>
138
	 * <dd>Normal one-sided printing</dd>
139
	 * <dt><code>DUPLEX_HORIZONTAL</code></dt>
140
	 * <dd>Duplex printing with page being horizontal</dd>
141
	 * <dt><code>DUPLEX_VERTICAL</code></dt>
142
	 * <dd>Duplex printing with page being vertical</dd>
143
	 * </dl>
144
	 * 
145
	 * @since 3.6
146
	 */
147
	public int duplex = DUPLEX_SIMPLEX;
148
	
149
	/**
150
	 * Specifies the name for the paper size used in a 
151
	 * print job, expressed as one of the following values:
152
	 * <dl>
153
	 * <dt><code>PAPER_LETTER</code></dt>
154
	 * <dt><code>PAPER_LEGAL</code></dt>
155
	 * <dt><code>PAPER_A2</code></dt>
156
	 * <dt><code>PAPER_A4</code></dt>
157
	 * <dt><code>PAPER_A5</code></dt>
158
	 * <dt><code>PAPER_A6</code></dt>
159
	 * <dt><code>PAPER_B5</code></dt>
160
	 * <dt><code>PAPER_JB5</code></dt>
161
	 * <dt><code>PAPER_EXECUTIVE</code></dt>
162
	 * <dt><code>PAPER_CUSTOM</code></dt>
163
	 * </dl>
164
	 * 
165
	 * Also accepts any paper size from the list of available paper size
166
	 * names returned by method <code>Printer.getPaperSizeList</code>.
167
	 * 
168
	 * @since 3.6
169
	 */
170
	public String paperSizeName = PAPER_A4;
171
	
172
	/**
173
	 * The physical height of the custom paper name in inches. 
174
	 * Note that this field is ignored if <code>paperSize</code>
175
	 * is not specified as <code>PAPER_CUSTOM</code>.
176
	 * 
177
	 * @since 3.6
178
	 */
179
	public double customPaperHeight = 0;
180
181
	/**
182
	 * The physical width of the custom paper name in inches. 
183
	 * Note that this field is ignored if <code>paperSize</code>
184
	 * is not specified as <code>PAPER_CUSTOM</code>.
185
	 * 
186
	 * @since 3.6
187
	 */
188
	public double customPaperWidth = 0;
189
190
	/**
191
	 * The name of the custom paper size. 
192
	 * Note that this field is ignored if <code>paperSize</code>
193
	 * is not specified as <code>PAPER_CUSTOM</code>.
194
	 * 
195
	 * @since 3.6
196
	 */
197
	public String customPaperName;
198
199
	/**
200
	 * The human-readable name of the custom paper size to
201
	 * be displayed in print dialog. Note that this field 
202
	 * is ignored if <code>paperSize</code> is not 
203
	 * specified as <code>PAPER_CUSTOM</code>.
204
	 * 
205
	 * @since 3.6
206
	 */
207
	public String customPaperDisplayName;
208
	
209
	/**
210
	 * Specifies the x-resolution in dots-per-inch of the printer.
211
	 * This configures the print settings to the closest resolution
212
	 * setting that can be used for destination print job.
213
	 * 
214
	 * @since 3.6
215
	 */
216
	public double resolutionX;
114
217
115
	/**
218
	/**
219
	 * Specifies the y-resolution in dots-per-inch of the printer.
220
	 * This configures the print settings to the closest resolution
221
	 * setting that can be used for destination print job.
222
	 * 
223
	 * @since 3.6
224
	 */
225
	public double resolutionY;
226
	
227
	/**
116
	 * <code>scope</code> field value indicating that
228
	 * <code>scope</code> field value indicating that
117
	 * all pages should be printed
229
	 * all pages should be printed
118
	 */	
230
	 */	
Lines 148-153 Link Here
148
	public static final int LANDSCAPE = 2;
260
	public static final int LANDSCAPE = 2;
149
	
261
	
150
	/**
262
	/**
263
	 * <code>duplex</code> field value indicating
264
	 * one-sided printing
265
	 * 
266
	 * @since 3.6
267
	 */
268
	public static final int DUPLEX_SIMPLEX = 1;
269
	
270
	/**
271
	 * <code>duplex</code> field value indicating
272
	 * double sided printing on short edge
273
	 * 
274
	 * @since 3.6
275
	 */
276
	public static final int DUPLEX_HORIZONTAL = 2;
277
	
278
	/**
279
	 * <code>duplex</code> field value indicating
280
	 * double sided printing on long edge
281
	 * 
282
	 * @since 3.6
283
	 */
284
	public static final int DUPLEX_VERTICAL = 3;
285
	
286
	/**
287
	 * <code>paperSize</code> field value indicating
288
	 * the paper size as LETTER
289
	 * 
290
	 * @since 3.6
291
	 */
292
	public static final String PAPER_LETTER = "LETTER";
293
294
	/**
295
	 * <code>paperSize</code> field value indicating
296
	 * the paper size as LEGAL
297
	 * 
298
	 * @since 3.6
299
	 */
300
	public static final String PAPER_LEGAL = "LEGAL";
301
	
302
	/**
303
	 * <code>paperSize</code> field value indicating
304
	 * the paper size as A4 sheet
305
	 * 
306
	 * @since 3.6
307
	 */
308
	public static final String PAPER_A2 = "A2";
309
310
	/**
311
	 * <code>paperSize</code> field value indicating
312
	 * the paper size as A4 sheet
313
	 * 
314
	 * @since 3.6
315
	 */
316
	public static final String PAPER_A4 = "A4";
317
	
318
	/**
319
	 * <code>paperSize</code> field value indicating
320
	 * the paper size as A4 sheet
321
	 * 
322
	 * @since 3.6
323
	 */
324
	public static final String PAPER_A5 = "A5";
325
326
	/**
327
	 * <code>paperSize</code> field value indicating
328
	 * the paper size as A4 sheet
329
	 * 
330
	 * @since 3.6
331
	 */
332
	public static final String PAPER_A6 = "A6";
333
334
	/**
335
	 * <code>paperSize</code> field value indicating
336
	 * the paper size as B5 sheet
337
	 * 
338
	 * @since 3.6
339
	 */
340
	public static final String PAPER_B5 = "B5";
341
	
342
	/**
343
	 * <code>paperSize</code> field value indicating
344
	 * the paper size as JB5 sheet
345
	 * 
346
	 * @since 3.6
347
	 */
348
	public static final String PAPER_JB5 = "JB5";
349
	
350
	/**
351
	 * <code>paperSize</code> field value indicating
352
	 * the paper size as EXECUTIVE
353
	 * 
354
	 * @since 3.6
355
	 */
356
	public static final String PAPER_EXECUTIVE = "EXECUTIVE";
357
	
358
	/**
359
	 * <code>paperSize</code> field value indicating the paper 
360
	 * size as Custom. When this field is specified, the values 
361
	 * for <code>customPaperHeight</code> and <code>customPaperWidth</code>
362
	 * are required to create a custom paper size and optionally, 
363
	 * <code>customPaperName</code> <code>customPaperDisplayName</code>.
364
	 * 
365
	 * Note that customPaperHeight and customPaperWidth are ignored
366
	 * when the field has not specified this value.
367
	 * 
368
	 * @since 3.6
369
	 */
370
	public static final String PAPER_CUSTOM = "CUSTOM";
371
372
	/**
151
	 * private, platform-specific data
373
	 * private, platform-specific data
152
	 * On Windows, this contains a copy of the DEVMODE struct
374
	 * On Windows, this contains a copy of the DEVMODE struct
153
	 * returned from the <code>PrintDialog</code>.
375
	 * returned from the <code>PrintDialog</code>.
Lines 158-164 Link Here
158
	 * This field is not currently used on the X/Window System.
380
	 * This field is not currently used on the X/Window System.
159
	 */	
381
	 */	
160
	byte [] otherData;
382
	byte [] otherData;
161
383
	
162
	/**
384
	/**
163
	 * Constructs an instance of this class that can be
385
	 * Constructs an instance of this class that can be
164
	 * used to print to the default printer.
386
	 * used to print to the default printer.
(-)Eclipse (+10 lines)
Added Link Here
1
package org.eclipse.swt.internal.win32;
2
3
	public class FORM_INFO_1 {
4
		public int Flags; //DWORD
5
		/** @field cast=(LPCTSTR) */
6
		public int /*long*/ pName;
7
		public SIZE Size = new SIZE();
8
		public RECT ImageableArea = new RECT();
9
		public static final int sizeof = OS.FORM_INFO_1_sizeof ();
10
}

Return to bug 96394