Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVeronika Irvine2004-09-10 15:09:38 +0000
committerVeronika Irvine2004-09-10 15:09:38 +0000
commit7203f644cd57836096a98ff5d2035a1b7d2e4966 (patch)
tree5e01fbbd97f71606fc350bb1842dd41fe94d493d /bundles
parentb410e8153a654b114833e69eeef807b125e605e6 (diff)
downloadeclipse.platform.swt-7203f644cd57836096a98ff5d2035a1b7d2e4966.tar.gz
eclipse.platform.swt-7203f644cd57836096a98ff5d2035a1b7d2e4966.tar.xz
eclipse.platform.swt-7203f644cd57836096a98ff5d2035a1b7d2e4966.zip
bug 47184
Diffstat (limited to 'bundles')
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT Drag and Drop/win32/org/eclipse/swt/dnd/TextTransfer.java25
1 files changed, 17 insertions, 8 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/win32/org/eclipse/swt/dnd/TextTransfer.java b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/win32/org/eclipse/swt/dnd/TextTransfer.java
index 845a569ac6..27de6f85a6 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/win32/org/eclipse/swt/dnd/TextTransfer.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/win32/org/eclipse/swt/dnd/TextTransfer.java
@@ -71,10 +71,12 @@ public void javaToNative (Object object, TransferData transferData){
}
switch (transferData.type) {
case COM.CF_UNICODETEXT: {
- TCHAR buffer = new TCHAR(0, string, true);
- int byteCount = buffer.length() * TCHAR.sizeof;
+ int charCount = string.length ();
+ char[] chars = new char[charCount+1];
+ string.getChars (0, charCount, chars, 0);
+ int byteCount = chars.length * 2;
int newPtr = COM.GlobalAlloc(COM.GMEM_FIXED | COM.GMEM_ZEROINIT, byteCount);
- COM.MoveMemory(newPtr, buffer, byteCount);
+ COM.MoveMemory(newPtr, chars, byteCount);
transferData.stgmedium = new STGMEDIUM();
transferData.stgmedium.tymed = COM.TYMED_HGLOBAL;
transferData.stgmedium.unionField = newPtr;
@@ -130,15 +132,22 @@ public Object nativeToJava(TransferData transferData){
try {
switch (transferData.type) {
case CF_UNICODETEXTID: {
- /* Ensure byteCount is a multiple of 2 bytes on UNICODE platforms */
- int size = COM.GlobalSize(hMem) / TCHAR.sizeof * TCHAR.sizeof;
+ /* Ensure byteCount is a multiple of 2 bytes */
+ int size = COM.GlobalSize(hMem) / 2 * 2;
if (size == 0) return null;
- TCHAR buffer = new TCHAR(0, size / TCHAR.sizeof);
+ char[] chars = new char[size/2];
int ptr = COM.GlobalLock(hMem);
if (ptr == 0) return null;
try {
- COM.MoveMemory(buffer, ptr, size);
- return buffer.toString(0, buffer.strlen());
+ COM.MoveMemory(chars, ptr, size);
+ int length = chars.length;
+ for (int i=0; i<chars.length; i++) {
+ if (chars [i] == '\0') {
+ length = i;
+ break;
+ }
+ }
+ return new String (chars, 0, length);
} finally {
COM.GlobalUnlock(hMem);
}

Back to the top