📄 activexcomponent.java
字号:
*/
public void setProperty(String propertyName, int propValue) {
this.setProperty(propertyName, new Variant(propValue));
}
/*-------------------------------------------------------
* Listener logging helpers
*-------------------------------------------------------
*/
/**
* This boolean determines if callback events should be logged
*/
public static boolean shouldLogEvents = false;
/**
* used by the doc and application listeners to get intelligent logging
*
* @param description
* event description
* @param args
* args passed in (variants)
*
*/
public void logCallbackEvent(String description, Variant[] args) {
String argString = "";
if (args != null && ActiveXComponent.shouldLogEvents) {
if (args.length > 0) {
argString += " args: ";
}
for (int i = 0; i < args.length; i++) {
short argType = args[i].getvt();
argString += ",[" + i + "]";
// break out the byref bits if they are on this
if ((argType & Variant.VariantByref) == Variant.VariantByref) {
// show the type and the fact that its byref
argString += "("
+ (args[i].getvt() & ~Variant.VariantByref) + "/"
+ Variant.VariantByref + ")";
} else {
// show the type
argString += "(" + argType + ")";
}
argString += "=";
if (argType == Variant.VariantDispatch) {
Dispatch foo = (args[i].getDispatch());
argString += foo;
} else if ((argType & Variant.VariantBoolean) == Variant.VariantBoolean) {
// do the boolean thing
if ((argType & Variant.VariantByref) == Variant.VariantByref) {
// boolean by ref
argString += args[i].getBooleanRef();
} else {
// boolean by value
argString += args[i].getBoolean();
}
} else if ((argType & Variant.VariantString) == Variant.VariantString) {
// do the string thing
if ((argType & Variant.VariantByref) == Variant.VariantByref) {
// string by ref
argString += args[i].getStringRef();
} else {
// string by value
argString += args[i].getString();
}
} else {
argString += args[i].toString();
}
}
System.out.println(description + argString);
}
}
/*
* ==============================================================
*
* covers for dispatch call methods
* =============================================================
*/
/**
* makes a dispatch call for the passed in action and no parameter
*
* @param callAction
* @return ActiveXComponent representing the results of the call
*/
public ActiveXComponent invokeGetComponent(String callAction) {
return new ActiveXComponent(invoke(callAction).toDispatch());
}
/**
* makes a dispatch call for the passed in action and single parameter
*
* @param callAction
* @param parameter
* @return ActiveXComponent representing the results of the call
*/
public ActiveXComponent invokeGetComponent(String callAction,
Variant parameter) {
return new ActiveXComponent(invoke(callAction, parameter).toDispatch());
}
/**
* makes a dispatch call for the passed in action and single parameter
*
* @param callAction
* @param parameter1
* @param parameter2
* @return ActiveXComponent representing the results of the call
*/
public ActiveXComponent invokeGetComponent(String callAction,
Variant parameter1, Variant parameter2) {
return new ActiveXComponent(invoke(callAction, parameter1, parameter2)
.toDispatch());
}
/**
* makes a dispatch call for the passed in action and single parameter
*
* @param callAction
* @param parameter1
* @param parameter2
* @param parameter3
* @return ActiveXComponent representing the results of the call
*/
public ActiveXComponent invokeGetComponent(String callAction,
Variant parameter1, Variant parameter2, Variant parameter3) {
return new ActiveXComponent(invoke(callAction, parameter1, parameter2,
parameter3).toDispatch());
}
/**
* makes a dispatch call for the passed in action and single parameter
*
* @param callAction
* @param parameter1
* @param parameter2
* @param parameter3
* @param parameter4
* @return ActiveXComponent representing the results of the call
*/
public ActiveXComponent invokeGetComponent(String callAction,
Variant parameter1, Variant parameter2, Variant parameter3,
Variant parameter4) {
return new ActiveXComponent(invoke(callAction, parameter1, parameter2,
parameter3, parameter4).toDispatch());
}
/**
* invokes a single parameter call on this dispatch that returns no value
*
* @param actionCommand
* @param parameter
* @return a Variant but that may be null for some calls
*/
public Variant invoke(String actionCommand, String parameter) {
return Dispatch.call(this, actionCommand, parameter);
}
/**
* makes a dispatch call to the passed in action with a single boolean
* parameter
*
* @param actionCommand
* @param parameter
* @return Variant result
*/
public Variant invoke(String actionCommand, boolean parameter) {
return Dispatch.call(this, actionCommand, new Variant(parameter));
}
/**
* makes a dispatch call to the passed in action with a single int parameter
*
* @param actionCommand
* @param parameter
* @return Variant result of the invoke (Dispatch.call)
*/
public Variant invoke(String actionCommand, int parameter) {
return Dispatch.call(this, actionCommand, new Variant(parameter));
}
/**
* makes a dispatch call to the passed in action with a string and integer
* parameter (this was put in for some application)
*
* @param actionCommand
* @param parameter1
* @param parameter2
* @return Variant result
*/
public Variant invoke(String actionCommand, String parameter1,
int parameter2) {
return Dispatch.call(this, actionCommand, parameter1, new Variant(
parameter2));
}
/**
* makes a dispatch call to the passed in action with two integer parameters
* (this was put in for some application)
*
* @param actionCommand
* @param parameter1
* @param parameter2
* @return a Variant but that may be null for some calls
*/
public Variant invoke(String actionCommand, int parameter1, int parameter2) {
return Dispatch.call(this, actionCommand, new Variant(parameter1),
new Variant(parameter2));
}
/**
* makes a dispatch call for the passed in action and single parameter
*
* @param callAction
* @param parameter
* @return a Variant but that may be null for some calls
*/
public Variant invoke(String callAction, Variant parameter) {
return Dispatch.call(this, callAction, parameter);
}
/**
* makes a dispatch call for the passed in action and two parameter
*
* @param callAction
* @param parameter1
* @param parameter2
* @return a Variant but that may be null for some calls
*/
public Variant invoke(String callAction, Variant parameter1,
Variant parameter2) {
return Dispatch.call(this, callAction, parameter1, parameter2);
}
/**
* makes a dispatch call for the passed in action and two parameter
*
* @param callAction
* @param parameter1
* @param parameter2
* @param parameter3
* @return Variant result data
*/
public Variant invoke(String callAction, Variant parameter1,
Variant parameter2, Variant parameter3) {
return Dispatch.call(this, callAction, parameter1, parameter2,
parameter3);
}
/**
* calls call() with 4 variant parameters
*
* @param callAction
* @param parameter1
* @param parameter2
* @param parameter3
* @param parameter4
* @return Variant result data
*/
public Variant invoke(String callAction, Variant parameter1,
Variant parameter2, Variant parameter3, Variant parameter4) {
return Dispatch.call(this, callAction, parameter1, parameter2,
parameter3, parameter4);
}
/**
* makes a dispatch call for the passed in action and no parameter
*
* @param callAction
* @return a Variant but that may be null for some calls
*/
public Variant invoke(String callAction) {
return Dispatch.call(this, callAction);
}
/**
* This is really a cover for call(String,Variant[]) that should be
* eliminated call with a variable number of args mainly used for quit.
*
* @param name
* @param args
* @return Variant returned by the invoke (Dispatch.callN)
*/
public Variant invoke(String name, Variant[] args) {
return Dispatch.callN(this, name, args);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -