]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.eclipse.swt.win32.win32.x86_64/src/org/eclipse/swt/internal/ole/win32/ITypeInfo.java
Work around SWT 4.13 - 4.18 Win32 DnD bug 567422
[simantics/platform.git] / bundles / org.eclipse.swt.win32.win32.x86_64 / src / org / eclipse / swt / internal / ole / win32 / ITypeInfo.java
1 /*******************************************************************************
2  * Copyright (c) 2000, 2017 IBM Corporation and others.
3  *
4  * This program and the accompanying materials
5  * are made available under the terms of the Eclipse Public License 2.0
6  * which accompanies this distribution, and is available at
7  * https://www.eclipse.org/legal/epl-2.0/
8  *
9  * SPDX-License-Identifier: EPL-2.0
10  *
11  * Contributors:
12  *     IBM Corporation - initial API and implementation
13  *******************************************************************************/
14 package org.eclipse.swt.internal.ole.win32;
15
16
17 import org.eclipse.swt.internal.win32.*;
18
19 public class ITypeInfo extends IUnknown
20 {
21
22 public ITypeInfo(long address) {
23         super(address);
24 }
25 public int GetDocumentation(int index, String[] name, String[] docString, int[] pdwHelpContext, String[] helpFile ) {
26         long[] pBstrName = null;
27         if (name != null) pBstrName = new long[1];
28         long[] pBstrDocString = null;
29         if (docString != null) pBstrDocString = new long[1];
30         long[] pBstrHelpFile  = null;
31         if (helpFile != null) pBstrHelpFile = new long[1];
32         int rc = COM.VtblCall(12, address, index, pBstrName, pBstrDocString, pdwHelpContext, pBstrHelpFile);
33         if (name != null && pBstrName[0] != 0) {
34                 int size = COM.SysStringByteLen(pBstrName[0]);
35                 if (size > 0){
36                         // get the unicode character array from the global memory and create a String
37                         char[] buffer = new char[(size + 1) /2]; // add one to avoid rounding errors
38                         OS.MoveMemory(buffer, pBstrName[0], size);
39                         name[0] = new String(buffer);
40                         int subindex = name[0].indexOf("\0");
41                         if (subindex > 0)
42                                 name[0] = name[0].substring(0, subindex);
43                 }
44                 COM.SysFreeString(pBstrName[0]);
45         }
46         if (docString != null && pBstrDocString[0] != 0) {
47                 int size = COM.SysStringByteLen(pBstrDocString[0]);
48                 if (size > 0){
49                         // get the unicode character array from the global memory and create a String
50                         char[] buffer = new char[(size + 1) /2]; // add one to avoid rounding errors
51                         OS.MoveMemory(buffer, pBstrDocString[0], size);
52                         docString[0] = new String(buffer);
53                         int subindex = docString[0].indexOf("\0");
54                         if (subindex > 0)
55                                 docString[0] = docString[0].substring(0, subindex);
56                 }
57                 COM.SysFreeString(pBstrDocString[0]);
58         }
59         if (helpFile != null && pBstrHelpFile[0] != 0) {
60                 int size = COM.SysStringByteLen(pBstrHelpFile[0]);
61                 if (size > 0){
62                         // get the unicode character array from the global memory and create a String
63                         char[] buffer = new char[(size + 1) /2]; // add one to avoid rounding errors
64                         OS.MoveMemory(buffer, pBstrHelpFile[0], size);
65                         helpFile[0] = new String(buffer);
66                         int subindex = helpFile[0].indexOf("\0");
67                         if (subindex > 0)
68                                 helpFile[0] = helpFile[0].substring(0, subindex);
69                 }
70                 COM.SysFreeString(pBstrHelpFile[0]);
71         }
72         return rc;
73 }
74 public int GetFuncDesc(int index, long[] ppFuncDesc) {
75         return COM.VtblCall(5, address, index, ppFuncDesc);
76 }
77 public int GetImplTypeFlags(int index, int[] pImplTypeFlags) {
78         return COM.VtblCall(9, address, index, pImplTypeFlags);
79 }
80 public int GetNames(int memid, String[] names, int cMaxNames, int[] pcNames){
81
82         int nameSize = names.length;
83         long[] rgBstrNames = new long[nameSize];
84         int rc = COM.VtblCall(7, address, memid, rgBstrNames, nameSize, pcNames);
85
86         if (rc == COM.S_OK) {
87                 for (int i = 0; i < pcNames[0]; i++) {
88                         int size = COM.SysStringByteLen(rgBstrNames[i]);
89                         if (size > 0){
90                                 // get the unicode character array from the global memory and create a String
91                                 char[] buffer = new char[(size + 1) /2]; // add one to avoid rounding errors
92                                 OS.MoveMemory(buffer, rgBstrNames[i], size);
93                                 names[i] = new String(buffer);
94                                 int subindex = names[i].indexOf("\0");
95                                 if (subindex > 0)
96                                         names[i] = names[i].substring(0, subindex);
97                         }
98                         COM.SysFreeString(rgBstrNames[i]);
99                 }
100         }
101
102         return rc;
103 }
104 public int GetRefTypeInfo(int hRefType, long[] ppTInfo) {
105         return COM.VtblCall(14, address, hRefType, ppTInfo);
106 }
107 public int GetRefTypeOfImplType(int index, int[] pRefType) {
108         return COM.VtblCall(8, address, index, pRefType);
109 }
110 public int GetTypeAttr(long[] ppTypeAttr) {
111         return COM.VtblCall(3, address, ppTypeAttr);
112 }
113 public int GetVarDesc(int index, long[] ppVarDesc ) {
114         return COM.VtblCall(6, address, index, ppVarDesc);
115 }
116 public int ReleaseFuncDesc(long pFuncDesc ) {
117         return COM.VtblCall(20, address, pFuncDesc);
118 }
119 public int ReleaseTypeAttr(long pTypeAttr) {
120         return COM.VtblCall(19, address, pTypeAttr);
121 }
122 public int ReleaseVarDesc(long pVarDesc ) {
123         return COM.VtblCall(21, address, pVarDesc);
124 }
125 }