comparison dwt/ole/win32/OleAutomation.d @ 246:fd9c62a2998e

Updater SWT 3.4M7 to 3.4
author Frank Benoit <benoit@tionex.de>
date Tue, 01 Jul 2008 10:15:59 +0200
parents ab60f3309436
children bb89fd34ec82
comparison
equal deleted inserted replaced
245:d8c3d4a4f2b0 246:fd9c62a2998e
1 /******************************************************************************* 1 /*******************************************************************************
2 * Copyright (c) 2000, 2007 IBM Corporation and others. 2 * Copyright (c) 2000, 2008 IBM Corporation and others.
3 * All rights reserved. This program and the accompanying materials 3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Eclipse Public License v1.0 4 * are made available under the terms of the Eclipse Public License v1.0
5 * which accompanies this distribution, and is available at 5 * which accompanies this distribution, and is available at
6 * http://www.eclipse.org/legal/epl-v10.html 6 * http://www.eclipse.org/legal/epl-v10.html
7 * 7 *
97 * } 97 * }
98 * 98 *
99 * automation.dispose(); 99 * automation.dispose();
100 * 100 *
101 * </pre></code> 101 * </pre></code>
102 *
103 * @see <a href="http://www.eclipse.org/swt/snippets/#ole">OLE and ActiveX snippets</a>
104 * @see <a href="http://www.eclipse.org/swt/examples.php">DWT Examples: OLEExample, OleWebBrowser</a>
102 */ 105 */
103 public final class OleAutomation { 106 public final class OleAutomation {
104 private IDispatch objIDispatch; 107 private IDispatch objIDispatch;
105 private String exceptionDescription; 108 private String exceptionDescription;
106 private ITypeInfo objITypeInfo; 109 private ITypeInfo objITypeInfo;
154 157
155 } 158 }
156 IDispatch getAddress() { 159 IDispatch getAddress() {
157 return objIDispatch; 160 return objIDispatch;
158 } 161 }
162 /**
163 * Returns the fully qualified name of the Help file for the given member ID.
164 *
165 * @param dispId the member ID whose Help file is being retrieved.
166 * @return a string representing the fully qualified name of a Help
167 * file or null.
168 */
159 public String getHelpFile(int dispId) { 169 public String getHelpFile(int dispId) {
160 if (objITypeInfo is null) return null; 170 if (objITypeInfo is null) return null;
161 BSTR file; 171 BSTR file;
162 HRESULT rc = objITypeInfo.GetDocumentation(dispId, null, null, null, &file ); 172 HRESULT rc = objITypeInfo.GetDocumentation(dispId, null, null, null, &file );
163 if (rc is OLE.S_OK) { 173 if (rc is OLE.S_OK) {
165 COM.SysFreeString(file); 175 COM.SysFreeString(file);
166 return str; 176 return str;
167 } 177 }
168 return null; 178 return null;
169 } 179 }
180 /**
181 * Returns the documentation string for the given member ID.
182 *
183 * @param dispId the member ID in which the documentation is being retrieved.
184 * @return the documentation string if it exists; otherwise return null.
185 */
170 public String getDocumentation(int dispId) { 186 public String getDocumentation(int dispId) {
171 if (objITypeInfo is null) return null; 187 if (objITypeInfo is null) return null;
172 BSTR doc; 188 BSTR doc;
173 HRESULT rc = objITypeInfo.GetDocumentation(dispId, null, &doc, null, null ); 189 HRESULT rc = objITypeInfo.GetDocumentation(dispId, null, &doc, null, null );
174 if (rc == OLE.S_OK) { 190 if (rc == OLE.S_OK) {
176 COM.SysFreeString(doc); 192 COM.SysFreeString(doc);
177 return s; 193 return s;
178 } 194 }
179 return null; 195 return null;
180 } 196 }
197 /**
198 * Returns the property description of a variable at the given index.
199 *
200 * @param index the index of a variable whose property is being retrieved.
201 * @return an OlePropertyDescription for a variable at the given index.
202 */
181 public OlePropertyDescription getPropertyDescription(int index) { 203 public OlePropertyDescription getPropertyDescription(int index) {
182 if (objITypeInfo is null) return null; 204 if (objITypeInfo is null) return null;
183 VARDESC* vardesc; 205 VARDESC* vardesc;
184 HRESULT rc = objITypeInfo.GetVarDesc(index, &vardesc); 206 HRESULT rc = objITypeInfo.GetVarDesc(index, &vardesc);
185 if (rc != OLE.S_OK) return null; 207 if (rc != OLE.S_OK) return null;
202 data.helpFile = getHelpFile(vardesc.memid); 224 data.helpFile = getHelpFile(vardesc.memid);
203 225
204 objITypeInfo.ReleaseVarDesc(vardesc); 226 objITypeInfo.ReleaseVarDesc(vardesc);
205 return data; 227 return data;
206 } 228 }
229 /**
230 * Returns the description of a function at the given index.
231 *
232 * @param index the index of a function whose property is being retrieved.
233 * @return an OleFunctionDescription for a function at the given index.
234 */
207 public OleFunctionDescription getFunctionDescription(int index) { 235 public OleFunctionDescription getFunctionDescription(int index) {
208 if (objITypeInfo is null) return null; 236 if (objITypeInfo is null) return null;
209 FUNCDESC* funcdesc; 237 FUNCDESC* funcdesc;
210 HRESULT rc = objITypeInfo.GetFuncDesc(index, &funcdesc); 238 HRESULT rc = objITypeInfo.GetFuncDesc(index, &funcdesc);
211 if (rc != OLE.S_OK) return null; 239 if (rc != OLE.S_OK) return null;
254 } 282 }
255 283
256 objITypeInfo.ReleaseFuncDesc(funcdesc); 284 objITypeInfo.ReleaseFuncDesc(funcdesc);
257 return data; 285 return data;
258 } 286 }
287 /**
288 * Returns the type info of the current object referenced by the automation.
289 * The type info contains information about the object such as the function descriptions,
290 * the member descriptions and attributes of the type.
291 *
292 * @return the type info of the receiver
293 */
259 public TYPEATTR* getTypeInfoAttributes() { 294 public TYPEATTR* getTypeInfoAttributes() {
260 if (objITypeInfo is null) return null; 295 if (objITypeInfo is null) return null;
261 TYPEATTR* ppTypeAttr; 296 TYPEATTR* ppTypeAttr;
262 HRESULT rc = objITypeInfo.GetTypeAttr(&ppTypeAttr); 297 HRESULT rc = objITypeInfo.GetTypeAttr(&ppTypeAttr);
263 if (rc !is OLE.S_OK) return null; 298 if (rc !is OLE.S_OK) return null;
264 TYPEATTR* typeattr = new TYPEATTR(); 299 TYPEATTR* typeattr = new TYPEATTR();
265 COM.MoveMemory(typeattr, ppTypeAttr, TYPEATTR.sizeof); 300 COM.MoveMemory(typeattr, ppTypeAttr, TYPEATTR.sizeof);
266 objITypeInfo.ReleaseTypeAttr(ppTypeAttr); 301 objITypeInfo.ReleaseTypeAttr(ppTypeAttr);
267 return typeattr; 302 return typeattr;
268 } 303 }
269 304 /**
305 * Returns the name of the given member ID.
306 *
307 * @param dispId the member ID in which the name is being retrieved.
308 * @return the name if it exists; otherwise return null.
309 */
270 public String getName(int dispId) { 310 public String getName(int dispId) {
271 if (objITypeInfo is null) return null; 311 if (objITypeInfo is null) return null;
272 BSTR name; 312 BSTR name;
273 HRESULT rc = objITypeInfo.GetDocumentation(dispId, &name, null, null, null ); 313 HRESULT rc = objITypeInfo.GetDocumentation(dispId, &name, null, null, null );
274 if (rc == OLE.S_OK) { 314 if (rc == OLE.S_OK) {
276 COM.SysFreeString(name); 316 COM.SysFreeString(name);
277 return s; 317 return s;
278 } 318 }
279 return null; 319 return null;
280 } 320 }
281 321 /**
322 * Returns the name of a function and parameter names for the specified function ID.
323 *
324 * @param dispId the function ID in which the name and parameters are being retrieved.
325 * @param maxSize the maximum number of names to retrieve.
326 * @return an array of name containing the function name and the parameter names
327 */
282 public String[] getNames(int dispId, int maxSize) { 328 public String[] getNames(int dispId, int maxSize) {
283 if (objITypeInfo is null) return new String[0]; 329 if (objITypeInfo is null) return new String[0];
284 BSTR[] names = new BSTR[maxSize]; 330 BSTR[] names = new BSTR[maxSize];
285 uint count; 331 uint count;
286 HRESULT rc = objITypeInfo.GetNames(dispId, names.ptr, maxSize, &count); 332 HRESULT rc = objITypeInfo.GetNames(dispId, names.ptr, maxSize, &count);