We will investigate it deeper and let you know the results.
Yuriy
I'm trying to use the code generator for comfyj gui to generate the code required to handle events from powerpoint 2003.
I selected "Generate for a registered com type library" then selected "Microsoft Powerpoint 11.0 object library" and ticked the "generate dispinterfaces" check box.
When the code generator has finished I found some event methods in an interface called EApplication.java, which extends IDispatch, but could not find the corresponding server class in the server directory which extends IDispatchServer .
From looking at the ComfyJ Programmers guide I need to be able to extend the (missing) server class in order to set up event handling.
When I run the code generator in the same way for word I get ApplicationEvent<2,3,4> interfaces and ApplicationEventServer<2,3,4>Server classes, which is more like what I was expecting.
Similarly when running the code generator for excel I get the expected AppEvents interface and AppEventsServer class.
I'm Using ComfyJ 2.7 on windows xp with Microsoft Office 2003.
Is there something else I have to do to get the code generator to produce the classes I'm expecting, or is event handling for Microsoft Powerpoint done in some other way?
Thanks
Peter.
I updated this thread just in case another developers might come accross the same issue.
We found out that all events interface from PowerPoint library are defined not as usual dispinterfaces but as dual interfaces. Here is the quotation from the Microsoft support article:
Note that EApplication is derived from IDispatch and is not the dispinterface that is
commonly used as a source interface. If the source interface is a dispinterface,
you can determine the dispatch identifiers (DISPIDs) for its methods by using
the OLE/COM Object Viewer. However, because EApplication is not a dispinterface, you cannot
determine the DISPIDs for PowerPoint events by examining the type library.
That is why the "Codegen for ComfyJ" application does not generate the appropriate *Server classes.
However it's still possible to listen to events of application. In fact, all those *Server classes are just the stubs which are derived from IDispatchServer class which also implement the required events interface.
In case of PowerPoint integration such Java COM server class will look like following:
public static class PowerPointEventHandler extends com.jniwrapper.win32.com.server.IDispatchServer implements EApplication {
...
}
The EApplicaiton here is the interface designed for handling power point events. We also found that they do not define the ID's of the methods in this interface in regular way. That's why we had to add all those ID's from the IDL file manually, by defining them as constants.
I attached the complete PowerPointEventsHandling.java example that demonstrates how to subscribe to the events of PowerPoint application.
-Serge
Thanks for the attached sample and it indeed worked.
It's found from this sample that when the frame was just opened, there were tool bar and status bar, etc., that is, everything was there. However, when I clicked the top right cornor to get the full screen, those bars disappeared and never came back. How can we keep the bars there so people can use it?
Another issue: when the tool bar is available, I clicked "open" icon to open file, but nothing happened. is there any problem when embedding the component into java frame? It seemed worked in the comfyj demo sample.
When I clicked "start page" icon, the whole ppt app crashed. I don't know what happened. It might be an issue of STA?
Appreciate any answers,
Cobble S.
I have not seen such issues though I tried it with MS Office 2007. We will investigate this issue tomorrow and let you know the results.
What configuration (version of OS, JDK and ComfyJ) do you run it on?
-Serge
Serge,
The OS is Windows 2000 Professional (too old, isn't it?) running a Pentium 4 with 2.8 GHz, 2 Gbs RAM (Dell) since I like the 2000 System.
The JDK is 1.6.0_16.
The ComFyj is 2.7.
At the same desktop, I ran the ComFyj's demo sample, similar things repeated.
Thanks,
Cobble S.
I tested it on Windows Vista with the same JDK and ComFyj version, and the MS Office 2003, the same things happened.
Thanks,
Cobble S.
I tried your example code with some slight class name modifications (which I'll detail below) and it does work, however I get the following error message:
[com.jniwrapper.win32.com.server.IClassFactoryServer] : The com.quolos.client.powerpoint.EApplicationWithDisp interface was not registered for com.quolos.client.powerpoint.PowerpointEventsComfyJ$Handler, because com.quolos.client.powerpoint.server.EApplicationWithDispVTBL class was not found.
com.quolos.client.powerpoint.EApplicationWithDisp is com.quolos.client.powerpoint.EApplicationWithDisp from the example.
com.quolos.client.powerpoint.PowerpointEventsComfyJ$Handler is PowerPointEventHandler from the example.
The powerpoint events still come through despite this error.
Could you please explain what this error means, what effect not having the relevant VTBL class will have, and how I can get rid of the error?
That warning message simply indicates that ComfyJ could not find an appropriate EApplicationWithDispVTBL class in order to configure the class factory server automatically in the following constructor:
classFactoryServer = new IClassFactoryServer(PowerPointEventHandler.class);
ComfyJ constructs EApplicationWithDispVTBL class name by concatenation of interface name (EApplicationWithDisp) plus 'VTBL' suffix. Then IClassFactoryServer searches it in the 'server' subpackage, relatively to a location of EApplicationWithDisp interface.
You can simply ignore that message, because the 'classFactoryServer' object is configured by two following lines:
classFactoryServer.registerInterface(EApplicationWithDisp.class, new IDispatchVTBL(classFactoryServer));
classFactoryServer.setDefaultInterface(IDispatch.class);
And the simplest way to aviod that message at all is to move all these DISPID constants directly to the EApplication interface, of course if you do not use a compiled library, for example:
public interface EApplication extends com.jniwrapper.win32.automation.IDispatch {
final static String INTERFACE_IDENTIFIER = "{914934C2-5A91-11CF-8700-00AA0060263B}";
final static int DISPID_windowSelectionChange = 2001;
final static int DISPID_windowBeforeRightClick = 2002;
final static int DISPID_windowBeforeDoubleClick = 2003;
final static int DISPID_presentationClose = 2004;
final static int DISPID_presentationSave = 2005;
...
-Serge
is there any updating for this problem?
Cobble S.
We were able to reproduce this issue with Office 2003 applicaitons and now we are looking for the solution. The good news that there is no such problem with Office 2007 applicaitons. We'll provide the updated ComfyJ library when this issue is fixed.
-Serge