private static class CMN_invokeOleFunction extends ControlCommandMessage {
@Override
public Object run(Object[] args) {
String[] propertyPath = (String[])args[1];
OleAutomation automation = new OleAutomation(getSite((OleFrame)getControl()));
int[] ids;
for(int i=0; i<propertyPath.length; i++) {
ids = automation.getIDsOfNames(new String[] {propertyPath[i]});
if(ids == null) {
automation.dispose();
return null;
}
if(i == propertyPath.length - 1) {
Object[] vargs = (Object[])args[2];
Variant[] params = new Variant[vargs.length];
for(int j=0; j<vargs.length; j++) {
params[j] = createVariant(vargs[j]);
}
Object result;
if((Boolean)args[0]) {
Variant resultVariant = automation.invoke(ids[0], params);
result = getVariantValue(resultVariant);
dispose(resultVariant);
} else {
result = null;
automation.invokeNoReply(ids[0], params);
}
for(Variant param: params) {
dispose(param);
}
automation.dispose();
return result;
}
Variant variantProperty = automation.getProperty(ids[0]);
OleAutomation newAutomation = variantProperty.getAutomation();
variantProperty.dispose();
automation.dispose();
automation = newAutomation;
}
automation.dispose();