|
Eclipse Platform 2.0 |
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.eclipse.swt.ole.win32.OleAutomation
OleAutomation provides a generic mechanism for accessing functionality that is specific to a particular ActiveX Control or OLE Document.
The OLE Document or ActiveX Control must support the IDispatch interface in order to provide
OleAutomation support. The additional functionality provided by the OLE Object is specified in
its IDL file. The additional methods can either be to get property values (getProperty
),
to set property values (setProperty
) or to invoke a method (invoke
or
invokeNoReply
). Arguments are passed around in the form of Variant
objects.
Here is a sample IDL fragment:
interface IMyControl : IDispatch { [propget, id(0)] HRESULT maxFileCount([retval, out] int *c); [propput, id(0)] HRESULT maxFileCount([in] int c); [id(1)] HRESULT AddFile([in] BSTR fileName); };
An example of how to interact with this extended functionality is shown below:
OleAutomation automation = new OleAutomation(myControlSite);
// Look up the ID of the maxFileCount parameter
int[] rgdispid = automation.getIDsOfNames(new String[]{"maxFileCount"});
int maxFileCountID = rgdispid[0];
// Set the property maxFileCount to 100:
if (automation.setProperty(maxFileCountID, new Variant(100))) {
System.out.println("Max File Count was successfully set.");
}
// Get the new value of the maxFileCount parameter:
Variant pVarResult = automation.getProperty(maxFileCountID);
if (pVarResult != null) {
System.out.println("Max File Count is "+pVarResult.getInt());
}
// Invoke the AddFile method
// Look up the IDs of the AddFile method and its parameter
rgdispid = automation.getIDsOfNames(new String[]{"AddFile", "fileName"});
int dispIdMember = rgdispid[0];
int[] rgdispidNamedArgs = new int[] {rgdispid[1]};
// Convert arguments to Variant objects
Variant[] rgvarg = new Variant[1];
String fileName = "C:\\testfile";
rgvarg[0] = new Variant(fileName);
// Call the method
Variant pVarResult = automation.invoke(dispIdMember, rgvarg, rgdispidNamedArgs);
// Check the return value
if (pVarResult == null || pVarResult.getInt() != OLE.S_OK){
System.out.println("Failed to add file "+fileName);
}
automation.dispose();
Constructor Summary | |
OleAutomation(OleClientSite clientSite)
Creates an OleAutomation object for the specified client. |
Method Summary | |
void |
dispose()
Disposes the automation object. |
String |
getDocumentation(int dispId)
|
OleFunctionDescription |
getFunctionDescription(int index)
|
String |
getHelpFile(int dispId)
|
int[] |
getIDsOfNames(String[] names)
Returns the positive integer values (IDs) that are associated with the specified names by the IDispatch implementor. |
String |
getLastError()
Returns a description of the last error encountered. |
String |
getName(int dispId)
|
String[] |
getNames(int dispId,
int maxSize)
|
Variant |
getProperty(int dispIdMember)
Returns the value of the property specified by the dispIdMember. |
Variant |
getProperty(int dispIdMember,
Variant[] rgvarg)
Returns the value of the property specified by the dispIdMember. |
Variant |
getProperty(int dispIdMember,
Variant[] rgvarg,
int[] rgdispidNamedArgs)
Returns the value of the property specified by the dispIdMember. |
OlePropertyDescription |
getPropertyDescription(int index)
|
org.eclipse.swt.internal.ole.win32.TYPEATTR |
getTypeInfoAttributes()
|
Variant |
invoke(int dispIdMember)
Invokes a method on the OLE Object; the method has no parameters. |
Variant |
invoke(int dispIdMember,
Variant[] rgvarg)
Invokes a method on the OLE Object; the method has no optional parameters. |
Variant |
invoke(int dispIdMember,
Variant[] rgvarg,
int[] rgdispidNamedArgs)
Invokes a method on the OLE Object; the method has optional parameters. |
void |
invokeNoReply(int dispIdMember)
Invokes a method on the OLE Object; the method has no parameters. |
void |
invokeNoReply(int dispIdMember,
Variant[] rgvarg)
Invokes a method on the OLE Object; the method has no optional parameters. |
void |
invokeNoReply(int dispIdMember,
Variant[] rgvarg,
int[] rgdispidNamedArgs)
Invokes a method on the OLE Object; the method has optional parameters. |
boolean |
setProperty(int dispIdMember,
Variant rgvarg)
Sets the property specified by the dispIdMember to a new value. |
boolean |
setProperty(int dispIdMember,
Variant[] rgvarg)
Sets the property specified by the dispIdMember to a new value. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public OleAutomation(OleClientSite clientSite)
clientSite
- the site for the OLE Document or ActiveX Control whose additional functionality
you need to access
SWTError
- Method Detail |
public void dispose()
This method releases the IDispatch interface on the OLE Document or ActiveX Control. Do not use the OleAutomation object after it has been disposed.
public String getHelpFile(int dispId)
public String getDocumentation(int dispId)
public OlePropertyDescription getPropertyDescription(int index)
public OleFunctionDescription getFunctionDescription(int index)
public org.eclipse.swt.internal.ole.win32.TYPEATTR getTypeInfoAttributes()
public String getName(int dispId)
public String[] getNames(int dispId, int maxSize)
public int[] getIDsOfNames(String[] names)
names
- an array of names for which you require the identifiers
public String getLastError()
public Variant getProperty(int dispIdMember)
dispIdMember
- the ID of the property as specified by the IDL of the ActiveX Control; the
value for the ID can be obtained using OleAutomation.getIDsOfNames
public Variant getProperty(int dispIdMember, Variant[] rgvarg)
dispIdMember
- the ID of the property as specified by the IDL of the ActiveX Control; the
value for the ID can be obtained using OleAutomation.getIDsOfNamesrgvarg
- an array of arguments for the method. All arguments are considered to be
read only unless the Variant is a By Reference Variant type.
public Variant getProperty(int dispIdMember, Variant[] rgvarg, int[] rgdispidNamedArgs)
dispIdMember
- the ID of the property as specified by the IDL of the ActiveX Control; the
value for the ID can be obtained using OleAutomation.getIDsOfNamesrgvarg
- an array of arguments for the method. All arguments are considered to be
read only unless the Variant is a By Reference Variant type.rgdispidNamedArgs
- an array of identifiers for the arguments specified in rgvarg; the
parameter IDs must be in the same order as their corresponding values;
all arguments must have an identifier - identifiers can be obtained using
OleAutomation.getIDsOfNames
public Variant invoke(int dispIdMember)
dispIdMember
- the ID of the method as specified by the IDL of the ActiveX Control; the
value for the ID can be obtained using OleAutomation.getIDsOfNames
public Variant invoke(int dispIdMember, Variant[] rgvarg)
dispIdMember
- the ID of the method as specified by the IDL of the ActiveX Control; the
value for the ID can be obtained using OleAutomation.getIDsOfNamesrgvarg
- an array of arguments for the method. All arguments are considered to be
read only unless the Variant is a By Reference Variant type.
public Variant invoke(int dispIdMember, Variant[] rgvarg, int[] rgdispidNamedArgs)
dispIdMember
- the ID of the method as specified by the IDL of the ActiveX Control; the
value for the ID can be obtained using OleAutomation.getIDsOfNamesrgvarg
- an array of arguments for the method. All arguments are considered to be
read only unless the Variant is a By Reference Variant type.rgdispidNamedArgs
- an array of identifiers for the arguments specified in rgvarg; the
parameter IDs must be in the same order as their corresponding values;
all arguments must have an identifier - identifiers can be obtained using
OleAutomation.getIDsOfNames
public void invokeNoReply(int dispIdMember)
public void invoke(int dispIdMember)
.
dispIdMember
- the ID of the method as specified by the IDL of the ActiveX Control; the
value for the ID can be obtained using OleAutomation.getIDsOfNames
SWTError
- public void invokeNoReply(int dispIdMember, Variant[] rgvarg)
public void invoke(int dispIdMember, Variant[] rgvarg)
.
dispIdMember
- the ID of the method as specified by the IDL of the ActiveX Control; the
value for the ID can be obtained using OleAutomation.getIDsOfNamesrgvarg
- an array of arguments for the method. All arguments are considered to be
read only unless the Variant is a By Reference Variant type.
SWTError
- public void invokeNoReply(int dispIdMember, Variant[] rgvarg, int[] rgdispidNamedArgs)
public void invoke(int dispIdMember, Variant[] rgvarg, int[] rgdispidNamedArgs)
.
dispIdMember
- the ID of the method as specified by the IDL of the ActiveX Control; the
value for the ID can be obtained using OleAutomation.getIDsOfNamesrgvarg
- an array of arguments for the method. All arguments are considered to be
read only unless the Variant is a By Reference Variant type.rgdispidNamedArgs
- an array of identifiers for the arguments specified in rgvarg; the
parameter IDs must be in the same order as their corresponding values;
all arguments must have an identifier - identifiers can be obtained using
OleAutomation.getIDsOfNames
SWTError
- public boolean setProperty(int dispIdMember, Variant rgvarg)
dispIdMember
- the ID of the property as specified by the IDL of the ActiveX Control; the
value for the ID can be obtained using OleAutomation.getIDsOfNamesrgvarg
- the new value of the property
public boolean setProperty(int dispIdMember, Variant[] rgvarg)
dispIdMember
- the ID of the property as specified by the IDL of the ActiveX Control; the
value for the ID can be obtained using OleAutomation.getIDsOfNamesrgvarg
- an array of arguments for the method. All arguments are considered to be
read only unless the Variant is a By Reference Variant type.
|
Eclipse Platform 2.0 |
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |