Patch 1208570 added parameters that let a user provide typelib information required to get Excel events

This commit is contained in:
clay_shooter
2005-10-28 22:58:51 +00:00
parent 545b81e5b1
commit 4e2d45e3ff
7 changed files with 295 additions and 133 deletions

View File

@@ -11,15 +11,14 @@
</ul> </ul>
</li> </li>
<li> <li>
<b>Nothing Yet</b> <b>Event Callbacks</b>
<ul> <ul>
<li>Nothing Yet <li>Jacob normally uses information in the registry to find the connection
</ul> information needed to set up event callbacks. Excel and other programs
</li> don't put that information in the registry. A new optional parameter
<li> has been added to the DispatchEvents constructors that lets a user provide
<b>Nothing Yet</b> the location of the OLB or EXE that contains the information required to
<ul> retrieve the events.
<li>Nothing Yet
</ul> </ul>
</li> </li>
@@ -41,8 +40,8 @@
<td width="100%" colspan="2"><b>Patches</b></td> <td width="100%" colspan="2"><b>Patches</b></td>
</tr> </tr>
<tr> <tr>
<td width="13%">00000 </td> <td width="13%">1208570</td>
<td width="87%">none at this time</td> <td width="87%">Support Excel and other objects events</td>
</tr> </tr>
<tr> <tr>
<td width="13%">&nbsp;</td> <td width="13%">&nbsp;</td>

View File

@@ -36,7 +36,9 @@ extern "C"
// defined below // defined below
BOOL GetEventIID(IUnknown*, IID*, CComBSTR **, DISPID **, int *,LPOLESTR); BOOL GetEventIID(IUnknown*, IID*, CComBSTR **, DISPID **, int *,LPOLESTR);
BOOL GetEventIIDForTypeLib(BSTR, IID*, CComBSTR **, DISPID **, int *,LPOLESTR);
BOOL getClassInfoFromProgId(LPOLESTR bsProgId,LPTYPEINFO *pClassInfo); BOOL getClassInfoFromProgId(LPOLESTR bsProgId,LPTYPEINFO *pClassInfo);
BOOL MapEventIIDs(IID*, CComBSTR **, DISPID **, int *, LPOLESTR , LPTYPEINFO );
// extract a EventProxy* from a jobject // extract a EventProxy* from a jobject
EventProxy *extractProxy(JNIEnv *env, jobject arg) EventProxy *extractProxy(JNIEnv *env, jobject arg)
@@ -56,25 +58,42 @@ void putProxy(JNIEnv *env, jobject arg, EventProxy *ep)
env->SetIntField(arg, ajf, (jint)ep); env->SetIntField(arg, ajf, (jint)ep);
} }
/* /*
* Class: DispatchEvents * Class: com_jacob_com_DispatchEvents
* Method: init2 * Method: init3
* Signature: (LDispatch;Ljava/lang/Object;Ljava/lang/String;)V * Signature: (Lcom/jacob/com/Dispatch;Ljava/lang/Object;Ljava/lang/String;Ljava/lang/String;)V
*/ */
JNIEXPORT void JNICALL Java_com_jacob_com_DispatchEvents_init2 JNIEXPORT void JNICALL Java_com_jacob_com_DispatchEvents_init3
(JNIEnv *env, (JNIEnv *env,
jobject _this, jobject src, jobject _this, jobject src,
jobject sink, jobject sink,
jstring _progid) jstring _progid,
jstring _typelib)
{ {
USES_CONVERSION; USES_CONVERSION;
// find progid if any
LPOLESTR bsProgId = NULL; if (_typelib != NULL && _progid == NULL){
if (_progid!=NULL) { // both are required if typelib exists
const char *progid = env->GetStringUTFChars(_progid, NULL); ThrowComFail(env,"TypeLib was specified but no program id was",-1);
bsProgId = A2W(progid); return;
}
BSTR typeLib = NULL;
if (_typelib != NULL){
const char *typelib = env->GetStringUTFChars(_typelib, NULL);
typeLib = A2W(typelib);
//printf("we have a type lib %ls\n",typeLib);
} }
// find progid if any
LPOLESTR bsProgId = NULL;
if (_progid!=NULL) {
const char *progid = env->GetStringUTFChars(_progid, NULL);
bsProgId = A2W(progid);
//printf("we have an applicaton %ls\n",bsProgId);
}
// get the IDispatch for the source object // get the IDispatch for the source object
IDispatch *pDisp = extractDispatch(env, src); IDispatch *pDisp = extractDispatch(env, src);
CComQIPtr<IUnknown, &IID_IUnknown> pUnk(pDisp); CComQIPtr<IUnknown, &IID_IUnknown> pUnk(pDisp);
@@ -86,19 +105,26 @@ JNIEXPORT void JNICALL Java_com_jacob_com_DispatchEvents_init2
ThrowComFail(env, "Can't find IConnectionPointContainer", -1); ThrowComFail(env, "Can't find IConnectionPointContainer", -1);
return; return;
} }
// hook up to the default source iid
CComPtr<IConnectionPoint> pCP;
IID eventIID; IID eventIID;
CComBSTR *mNames; CComBSTR *mNames;
DISPID *mIDs; DISPID *mIDs;
int n_EventMethods; int n_EventMethods;
if (!GetEventIID(pUnk, &eventIID, &mNames, &mIDs, &n_EventMethods,bsProgId)) { if (_typelib == NULL){
ThrowComFail(env, "Can't find event iid", -1); if (!GetEventIID(pUnk, &eventIID, &mNames, &mIDs, &n_EventMethods,bsProgId)) {
return; ThrowComFail(env, "Can't find event iid", -1);
return;
}
} else {
if (!GetEventIIDForTypeLib(typeLib, &eventIID, &mNames, &mIDs, &n_EventMethods,bsProgId)) {
ThrowComFail(env, "Can't find event iid for type lib", -1);
return;
}
} }
// hook up to the default source iid
CComPtr<IConnectionPoint> pCP;
HRESULT hr = pCPC->FindConnectionPoint(eventIID, &pCP); HRESULT hr = pCPC->FindConnectionPoint(eventIID, &pCP);
// VC++ 6.0 compiler realiized we weren't using this variable
//DWORD dwEventCookie;
if (SUCCEEDED(hr)) if (SUCCEEDED(hr))
{ {
EventProxy *ep = new EventProxy(env, sink, pCP, eventIID, mNames, mIDs, n_EventMethods); EventProxy *ep = new EventProxy(env, sink, pCP, eventIID, mNames, mIDs, n_EventMethods);
@@ -109,17 +135,6 @@ JNIEXPORT void JNICALL Java_com_jacob_com_DispatchEvents_init2
} }
} }
/*
* Class: DispatchEvents
* Method: init
* Signature: (LDispatch;Ljava/lang/Object;)V
*/
JNIEXPORT void JNICALL Java_com_jacob_com_DispatchEvents_init
(JNIEnv *env, jobject _this, jobject src, jobject sink)
{
Java_com_jacob_com_DispatchEvents_init2(env,_this,src,sink, NULL);
}
/* /*
* Class: DispatchEvents * Class: DispatchEvents
* Method: release * Method: release
@@ -179,7 +194,6 @@ LoadNameCache(LPTYPEINFO pTypeInfo, LPTYPEATTR pta,
#define IMPLTYPE_DEFAULTSOURCE \ #define IMPLTYPE_DEFAULTSOURCE \
(IMPLTYPEFLAG_FDEFAULT | IMPLTYPEFLAG_FSOURCE) (IMPLTYPEFLAG_FDEFAULT | IMPLTYPEFLAG_FSOURCE)
BOOL GetEventIID(IUnknown *m_pObject, IID* piid, BOOL GetEventIID(IUnknown *m_pObject, IID* piid,
CComBSTR **mNames, DISPID **mIDs, int *nmeth,LPOLESTR bsProgId) CComBSTR **mNames, DISPID **mIDs, int *nmeth,LPOLESTR bsProgId)
{ {
@@ -200,17 +214,22 @@ BOOL GetEventIID(IUnknown *m_pObject, IID* piid,
else if (getClassInfoFromProgId(bsProgId,&pClassInfo)) { else if (getClassInfoFromProgId(bsProgId,&pClassInfo)) {
} }
else { else {
printf("couldn't get IProvideClassInfo\n"); printf("GetEventIID: couldn't get IProvideClassInfo\n");
return false; return false;
} }
return MapEventIIDs(piid, mNames, mIDs, nmeth, bsProgId, pClassInfo);
}
//printf("got ClassInfo\n"); BOOL MapEventIIDs(IID* piid,
CComBSTR **mNames, DISPID **mIDs, int *nmeth, LPOLESTR bsProgId, LPTYPEINFO pClassInfo)
{
ATLASSERT(pClassInfo != NULL); ATLASSERT(pClassInfo != NULL);
//printf("MapEventIIDs: got past ClassInfo assert\n");
LPTYPEATTR pClassAttr; LPTYPEATTR pClassAttr;
if (SUCCEEDED(pClassInfo->GetTypeAttr(&pClassAttr))) if (SUCCEEDED(pClassInfo->GetTypeAttr(&pClassAttr)))
{ {
//printf("got TypeAttr\n"); //printf("MapEventIIDs: got TypeAttr\n");
ATLASSERT(pClassAttr != NULL); ATLASSERT(pClassAttr != NULL);
ATLASSERT(pClassAttr->typekind == TKIND_COCLASS); ATLASSERT(pClassAttr->typekind == TKIND_COCLASS);
@@ -218,6 +237,7 @@ BOOL GetEventIID(IUnknown *m_pObject, IID* piid,
int nFlags; int nFlags;
HREFTYPE hRefType; HREFTYPE hRefType;
//printf("MapEventIIDs: looking at %d class attribute impl types \n");
for (unsigned int i = 0; i < pClassAttr->cImplTypes; i++) for (unsigned int i = 0; i < pClassAttr->cImplTypes; i++)
{ {
if (SUCCEEDED(pClassInfo->GetImplTypeFlags(i, &nFlags)) && if (SUCCEEDED(pClassInfo->GetImplTypeFlags(i, &nFlags)) &&
@@ -300,6 +320,42 @@ BOOL getClassInfoFromProgId(LPOLESTR bsProgId,LPTYPEINFO *pClassInfo)
return true; return true;
} }
/*
* Get the class info from the progId using the given typeLib.
*/
BOOL getClassInfoFromProgIdTypeLib(BSTR typeLib, LPOLESTR bsProgId, LPTYPEINFO *pClassInfo)
{
USES_CONVERSION;
CLSID clsid;
if (FAILED(CLSIDFromProgID(bsProgId, &clsid))) return false;
if (FAILED(StringFromCLSID(clsid,&bsProgId))) return false;
ITypeLib* pITypeLib;
if (FAILED(LoadTypeLib(typeLib, &pITypeLib))) return false;
//Find ITypeInfo for coclass.
pITypeLib->GetTypeInfoOfGuid(clsid, pClassInfo);
pITypeLib->Release();
return true;
} }
BOOL GetEventIIDForTypeLib(BSTR typeLib, IID* piid,
CComBSTR **mNames, DISPID **mIDs, int *nmeth,LPOLESTR bsProgId)
{
LPTYPEINFO pClassInfo = NULL;
if(getClassInfoFromProgIdTypeLib(typeLib, bsProgId,&pClassInfo))
{
if (pClassInfo == NULL){
printf("we had a successful return but pClassInfo is null\n");
}
return MapEventIIDs(piid, mNames, mIDs, nmeth, bsProgId, pClassInfo);
}
else
{
printf("GetEventIIDForTypeLib: couldn't get IProvideClassInfo\n");
return false;
}
}
}

View File

@@ -25,21 +25,14 @@
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
/*
* Class: DispatchEvents
* Method: init
* Signature: (LDispatch;Ljava/lang/Object;)V
*/
JNIEXPORT void JNICALL Java_com_jacob_com_DispatchEvents_init
(JNIEnv *, jobject, jobject, jobject);
/* /*
* Class: DispatchEvents * Class: com_jacob_com_DispatchEvents
* Method: init2 * Method: init3
* Signature: (LDispatch;Ljava/lang/Object;Ljava/lang/String;)V * Signature: (Lcom/jacob/com/Dispatch;Ljava/lang/Object;Ljava/lang/String;Ljava/lang/String;)V
*/ */
JNIEXPORT void JNICALL Java_com_jacob_com_DispatchEvents_init2 JNIEXPORT void JNICALL Java_com_jacob_com_DispatchEvents_init3
(JNIEnv *, jobject, jobject, jobject, jstring); (JNIEnv *, jobject, jobject, jobject, jstring, jstring);
/* /*
* Class: DispatchEvents * Class: DispatchEvents

View File

@@ -30,6 +30,14 @@ package com.jacob.com;
* Variant... as a parameter. It will then wrap the call back data * Variant... as a parameter. It will then wrap the call back data
* in the Variant array and call the java method of the object * in the Variant array and call the java method of the object
* that this DispatchEvents object was initialized with. * that this DispatchEvents object was initialized with.
* <p>
* Instances of this class are created with "sink object" that
* will receive the event messages. The sink object is wrapped in
* an Invocation handler that actually receives the messages and then
* forwards them on to the "sink object". The constructors recognize when
* an instance of InvocationProxy is passed in and do not create
* a new InvocationProxy as a wrapper. They instead use the passed in
* InvocationProxy.
* *
*/ */
public class DispatchEvents extends JacobObject { public class DispatchEvents extends JacobObject {
@@ -50,30 +58,8 @@ public class DispatchEvents extends JacobObject {
/** /**
* A constructor for those that want to supply their own InvocationProxy. * This is the most commonly used constructor
* or subclass (future implementations may take an interface).
* This lets someone distribute their events to other objects
* at the single method dispatch point.
* <p> * <p>
* Most users of this class will use the other constructors!
*
* @param sourceOfEvent the Dispatch object that will send events
* @param pInvocationProxy the proxy object that expects to receive the
* events for some other object
*/
public DispatchEvents(Dispatch sourceOfEvent, InvocationProxy pInvocationProxy){
mInvocationProxy = pInvocationProxy;
if (mInvocationProxy != null){
init(sourceOfEvent, mInvocationProxy);
} else {
if (JacobObject.isDebugEnabled()){
JacobObject.debug("Cannot register null invocation proxy for events");
}
throw new IllegalArgumentException("Cannot register null invocation proxy for events");
}
}
/**
* Creates the event callback linkage between the the * Creates the event callback linkage between the the
* MS program represented by the Dispatch object and the * MS program represented by the Dispatch object and the
* Java object that will receive the callback. * Java object that will receive the callback.
@@ -81,22 +67,12 @@ public class DispatchEvents extends JacobObject {
* @param eventSink Java object that wants to receive the events * @param eventSink Java object that wants to receive the events
*/ */
public DispatchEvents(Dispatch sourceOfEvent, Object eventSink) { public DispatchEvents(Dispatch sourceOfEvent, Object eventSink) {
if (JacobObject.isDebugEnabled()){ this(sourceOfEvent, eventSink, null );
System.out.println(
"DispatchEvents: Registering "+ eventSink + "for events ");
}
mInvocationProxy = new InvocationProxy(eventSink);
if (mInvocationProxy != null){
init(sourceOfEvent, mInvocationProxy);
} else {
if (JacobObject.isDebugEnabled()){
JacobObject.debug("Cannot register null event sink for events");
}
throw new IllegalArgumentException("Cannot register null event sink for events");
}
} }
/** /**
* None of the samples use this constructor
* <p>
* Creates the event callback linkage between the the * Creates the event callback linkage between the the
* MS program represented by the Dispatch object and the * MS program represented by the Dispatch object and the
* Java object that will receive the callback. * Java object that will receive the callback.
@@ -105,13 +81,37 @@ public class DispatchEvents extends JacobObject {
* @param progId ??? * @param progId ???
*/ */
public DispatchEvents(Dispatch sourceOfEvent, Object eventSink, String progId) { public DispatchEvents(Dispatch sourceOfEvent, Object eventSink, String progId) {
this(sourceOfEvent, eventSink, progId, null );
}
/**
* Creates the event callback linkage between the the
* MS program represented by the Dispatch object and the
* Java object that will receive the callback.
* <pre>
* >DispatchEvents de =
* new DispatchEvents(someDispatch,someEventHAndler,
* "Excel.Application",
* "C:\\Program Files\\Microsoft Office\\OFFICE11\\EXCEL.EXE");
*
* @param sourceOfEvent Dispatch object who's MS app will generate callbacks
* @param eventSink Java object that wants to receive the events
* @param progId , mandatory if the typelib is specified
* @param typeLib The location of the typelib to use
*/
public DispatchEvents(Dispatch sourceOfEvent, Object eventSink, String progId, String typeLib)
{
if (JacobObject.isDebugEnabled()){ if (JacobObject.isDebugEnabled()){
System.out.println( System.out.println(
"DispatchEvents: Registering "+ eventSink + "for events "); "DispatchEvents: Registering "+ eventSink + "for events ");
} }
mInvocationProxy = new InvocationProxy(eventSink); if (eventSink instanceof InvocationProxy) {
mInvocationProxy = (InvocationProxy) eventSink;
} else {
mInvocationProxy = new InvocationProxy(eventSink);
}
if (mInvocationProxy != null) { if (mInvocationProxy != null) {
init2(sourceOfEvent, mInvocationProxy, progId); init3(sourceOfEvent, mInvocationProxy, progId, typeLib);
} else { } else {
if (JacobObject.isDebugEnabled()){ if (JacobObject.isDebugEnabled()){
JacobObject.debug("Cannot register null event sink for events"); JacobObject.debug("Cannot register null event sink for events");
@@ -124,20 +124,15 @@ public class DispatchEvents extends JacobObject {
* hooks up a connection point proxy by progId * hooks up a connection point proxy by progId
* event methods on the sink object will be called * event methods on the sink object will be called
* by name with a signature of <name>(Variant[] args) * by name with a signature of <name>(Variant[] args)
* @param src *
* @param sink * You must specify the location of the typeLib.
*
* @param src dispatch that is the source of the messages
* @param sink the object that will receive the messages
* @param progId optional program id. most folks don't need this either
* @param typeLib optional parameter for those programs that don't register their type libs (like Excel)
*/ */
protected native void init(Dispatch src, Object sink); protected native void init3(Dispatch src, Object sink, String progId, String typeLib);
/**
* hooks up a connection point proxy by progId
* event methods on the sink object will be called
* by name with a signature of <name>(Variant[] args)
* @param src
* @param sink
* @param progId
*/
protected native void init2(Dispatch src, Object sink, String progId);
/** /**
* now private so only this object can asccess * now private so only this object can asccess
@@ -176,4 +171,4 @@ public class DispatchEvents extends JacobObject {
static { static {
System.loadLibrary("jacob"); System.loadLibrary("jacob");
} }
} }

View File

@@ -44,7 +44,17 @@ public class InvocationProxy {
Object mTargetObject = null; Object mTargetObject = null;
/** /**
* constructs an invocation proxy that fronts for an event listener * dummy constructor for subclasses that don't actually wrap
* anything and just want to override the invoke() method
*/
protected InvocationProxy(){
}
/**
* Constructs an invocation proxy that fronts for an event listener.
* The InvocationProxy will wrap the target object and forward
* any received messages to the wrapped object
* @param pTargetObject * @param pTargetObject
*/ */
protected InvocationProxy(Object pTargetObject){ protected InvocationProxy(Object pTargetObject){

View File

@@ -6,45 +6,79 @@ import com.jacob.com.DispatchEvents;
/** /**
* This test was lifted from a forum posting and shows how you can't listen to * This test was lifted from a forum posting and shows how you can't listen to
* Excel events added post 1.9.1 Eclipse Settings... * Excel events (added post 1.9.1 Eclipse Settings.) This also uses the 1.9.1
* InvocationProxy to receive the events.
* <p> supported command line options with default values are
* -Djava.library.path=d:/jacob/release -Dcom.jacob.autogc=false * -Djava.library.path=d:/jacob/release -Dcom.jacob.autogc=false
* -Dcom.jacob.debug=true * -Dcom.jacob.debug=false
*/ */
public class ExcelEventTest { public class ExcelEventTest extends InvocationProxy {
/**
* load up excel, register for events and make stuff happen
* @param args
*/
public static void main(String args[]) { public static void main(String args[]) {
String pid = "Excel.Application";
listenTo("Word.Application",null); String typeLibLocation = "C:\\Program Files\\Microsoft Office\\OFFICE11\\EXCEL.EXE";
// Create an Excel Listener
listenTo("Excel.Application",
"C:\\Program Files\\Microsoft Office\\OFFICE11\\EXCEL.EXE");
}
private static void listenTo(String pid, String typeLibLocation) {
// Grab The Component. // Grab The Component.
ActiveXComponent axc = new ActiveXComponent(pid); ActiveXComponent axc = new ActiveXComponent(pid);
try { try {
// Add a listener (doesn't matter what it is). // Add a listener (doesn't matter what it is).
DispatchEvents de; DispatchEvents de;
if (typeLibLocation == null){ if (typeLibLocation == null) {
de = new DispatchEvents(axc, new ExcelEventTest()); de = new DispatchEvents(axc, new ExcelEventTest());
} else { } else {
de = new DispatchEvents(axc, new ExcelEventTest(), de = new DispatchEvents(axc, new ExcelEventTest(), pid,
pid,typeLibLocation); typeLibLocation);
} }
if (de == null){ if (de == null) {
System.out.println( System.out
"No exception thrown but now dispatch returned for Excel events"); .println("No exception thrown but no dispatch returned for Excel events");
} else {
// Yea!
System.out.println("Successfully attached to " + pid);
} }
// Yea!
System.out.println("Successfully attached to " + pid); System.out.println("version=" + axc.getProperty("Version"));
} catch (ComFailException e) { System.out.println("version=" + Dispatch.get(axc, "Version"));
e.printStackTrace(); axc.setProperty("Visible", true);
Dispatch workbooks = axc.getPropertyAsComponent("Workbooks");
Dispatch workbook = Dispatch.get(workbooks, "Add").toDispatch();
Dispatch sheet = Dispatch.get(workbook, "ActiveSheet").toDispatch();
Dispatch a1 = Dispatch.invoke(sheet, "Range", Dispatch.Get,
new Object[] { "A1" }, new int[1]).toDispatch();
Dispatch a2 = Dispatch.invoke(sheet, "Range", Dispatch.Get,
new Object[] { "A2" }, new int[1]).toDispatch();
Dispatch.put(a1, "Value", "123.456");
Dispatch.put(a2, "Formula", "=A1*2");
System.out.println("Retrieved a1 from excel:" + Dispatch.get(a1, "Value"));
System.out.println("REtrieved a2 from excel:" + Dispatch.get(a2, "Value"));
Variant f = new Variant(false);
Dispatch.call(workbook, "Close", f);
axc.invoke("Quit", new Variant[] {});
} catch (ComFailException cfe) {
cfe.printStackTrace();
System.out.println("Failed to attach to " + pid + ": " System.out.println("Failed to attach to " + pid + ": "
+ e.getMessage()); + cfe.getMessage());
} }
} }
/**
* dummy consturctor to create an InvocationProxy that wraps nothing
*/
public ExcelEventTest() {
}
/**
* override the invoke method to loga ll the events
*/
public void invoke(String methodName, Variant targetParameter[]) {
System.out.println("Received event from Windows program" + methodName);
}
} }

View File

@@ -0,0 +1,75 @@
package com.jacob.com;
import com.jacob.activeX.ActiveXComponent;
import com.jacob.com.ComFailException;
import com.jacob.com.DispatchEvents;
/**
* This test was lifted from a forum posting and shows how you can't listen to
* Excel events (added post 1.9.1 Eclipse Settings.) This also uses the 1.9.1
* InvocationProxy to receive the events.
* <p> supported command line options with default values are
* -Djava.library.path=d:/jacob/release -Dcom.jacob.autogc=false
* -Dcom.jacob.debug=false
*/
public class WordEventTest extends InvocationProxy {
/**
* load up excel, register for events and make stuff happen
* @param args
*/
public static void main(String args[]) {
String pid = "Word.Application";
String typeLibLocation = null;
// Grab The Component.
ActiveXComponent axc = new ActiveXComponent(pid);
try {
// Add a listener (doesn't matter what it is).
DispatchEvents de;
if (typeLibLocation == null) {
de = new DispatchEvents(axc, new WordEventTest());
} else {
de = new DispatchEvents(axc, new WordEventTest(), pid,
typeLibLocation);
}
if (de == null) {
System.out
.println("No exception thrown but no dispatch returned for Word events");
} else {
// Yea!
System.out.println("Successfully attached to " + pid);
}
// this is different from the ExcelEventTest because it uses
// the jacob active X api instead of the Dispatch api
System.out.println("version=" + axc.getPropertyAsString("Version"));
axc.setProperty("Visible",true);
ActiveXComponent documents = axc.getPropertyAsComponent("Documents");
if (documents == null){
System.out.println("unable to get documents");
}
axc.invoke("Quit", new Variant[] {});
} catch (ComFailException cfe) {
cfe.printStackTrace();
System.out.println("Failed to attach to " + pid + ": "
+ cfe.getMessage());
}
}
/**
* dummy consturctor to create an InvocationProxy that wraps nothing
*/
public WordEventTest() {
}
/**
* override the invoke method to loga ll the events
*/
public void invoke(String methodName, Variant targetParameter[]) {
System.out.println("Received event from Windows program" + methodName);
}
}