summaryrefslogtreecommitdiffstats
path: root/bundles/org.eclipse.swt/Eclipse SWT Printing
diff options
context:
space:
mode:
authorVeronika Irvine <veronika>2002-10-22 19:22:36 +0000
committerVeronika Irvine <veronika>2002-10-22 19:22:36 +0000
commit842d07969dacb7ccb36713b08e1d43e4684cb003 (patch)
tree9314df4cf422749d0db47dff6aee8b1ab7163c99 /bundles/org.eclipse.swt/Eclipse SWT Printing
parent51d7d26214d5211ba5d9d10e286258af4fb28a56 (diff)
downloadeclipse.platform.swt-842d07969dacb7ccb36713b08e1d43e4684cb003.tar.gz
eclipse.platform.swt-842d07969dacb7ccb36713b08e1d43e4684cb003.tar.xz
eclipse.platform.swt-842d07969dacb7ccb36713b08e1d43e4684cb003.zip
make sure an even multiple of TCHAR
Diffstat (limited to 'bundles/org.eclipse.swt/Eclipse SWT Printing')
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT Printing/win32/org/eclipse/swt/printing/PrintDialog.java29
1 files changed, 16 insertions, 13 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Printing/win32/org/eclipse/swt/printing/PrintDialog.java b/bundles/org.eclipse.swt/Eclipse SWT Printing/win32/org/eclipse/swt/printing/PrintDialog.java
index 7cf33534f9..341254af6a 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT Printing/win32/org/eclipse/swt/printing/PrintDialog.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT Printing/win32/org/eclipse/swt/printing/PrintDialog.java
@@ -1,9 +1,9 @@
package org.eclipse.swt.printing;
/*
- * Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
- * This file is made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
+ * Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
+ * This file is made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*/
@@ -217,19 +217,21 @@ public PrinterData open() {
pd.nToPage = (short) endPage;
if (OS.PrintDlg(pd)) {
/* Get driver and device from the DEVNAMES struct */
- int size = OS.GlobalSize(pd.hDevNames);
- int ptr = OS.GlobalLock(pd.hDevNames);
+ int hMem = pd.hDevNames;
+ /* Ensure size is a multiple of 2 bytes on UNICODE platforms */
+ int size = OS.GlobalSize(hMem) / TCHAR.sizeof * TCHAR.sizeof;
+ int ptr = OS.GlobalLock(hMem);
short[] offsets = new short[4];
OS.MoveMemory(offsets, ptr, 2 * offsets.length);
TCHAR buffer = new TCHAR(0, size);
OS.MoveMemory(buffer, ptr, size);
- OS.GlobalUnlock(ptr);
+ OS.GlobalUnlock(hMem);
int driverOffset = offsets[0];
int i = 0;
while (driverOffset + i < size) {
if (buffer.tcharAt(driverOffset + i) == 0) break;
- else i++;
+ i++;
}
String driver = buffer.toString(driverOffset, i);
@@ -237,7 +239,7 @@ public PrinterData open() {
i = 0;
while (deviceOffset + i < size) {
if (buffer.tcharAt(deviceOffset + i) == 0) break;
- else i++;
+ i++;
}
String device = buffer.toString(deviceOffset, i);
@@ -245,7 +247,7 @@ public PrinterData open() {
i = 0;
while (outputOffset + i < size) {
if (buffer.tcharAt(outputOffset + i) == 0) break;
- else i++;
+ i++;
}
String output = buffer.toString(outputOffset, i);
@@ -264,14 +266,15 @@ public PrinterData open() {
data.collate = (pd.Flags & OS.PD_COLLATE) != 0;
/* Bulk-save the printer-specific settings in the DEVMODE struct */
- ptr = OS.GlobalLock(pd.hDevMode);
- size = OS.GlobalSize(ptr);
+ hMem = pd.hDevMode;
+ size = OS.GlobalSize(hMem);
+ ptr = OS.GlobalLock(hMem);
data.otherData = new byte[size];
OS.MoveMemory(data.otherData, ptr, size);
- OS.GlobalUnlock(ptr);
+ OS.GlobalUnlock(hMem);
return data;
}
return null;
}
-}
+}