This Question is Answered

1 "correct" answer available (4 pts) 2 "helpful" answers available (2 pts)
10 Replies Last post: Feb 12, 2010 4:13 PM by Serge Piletsky  
Peter Brown   14 posts since
Jan 18, 2010
Currently Being Moderated

Jan 18, 2010 7:03 PM

Problem generating dispinterfaces for powerpoint 2003

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.

Yuriy Privezentsev TeamDev Ltd. 78 posts since
Jan 19, 2010
Currently Being Moderated
1. Jan 19, 2010 1:28 PM in response to: Peter Brown
Re: Problem generating dispinterfaces for powerpoint 2003
Hi Peter,

 

It looks like MS PowerPoint works in a different way in  comparing with MS Word and Excel. During a small investigation we found the following article that explains how to work with PowerPoint events: http://support.microsoft.com/kb/309309
We  will investigate it deeper and let you know the  results.

 

Regards,
Yuriy
Serge Piletsky TeamDev Ltd. 1,066 posts since
Apr 24, 2006
Currently Being Moderated
2. Jan 27, 2010 4:58 PM in response to: Peter Brown
Re: Problem generating dispinterfaces for powerpoint 2003

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

Attachments:
cobblestone   20 posts since
Jan 15, 2010
Currently Being Moderated
3. Jan 27, 2010 10:44 PM in response to: Serge Piletsky
Re: Problem generating dispinterfaces for powerpoint 2003

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.

Serge Piletsky TeamDev Ltd. 1,066 posts since
Apr 24, 2006
Currently Being Moderated
4. Jan 27, 2010 11:02 PM in response to: cobblestone
Re: Problem generating dispinterfaces for powerpoint 2003

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

cobblestone   20 posts since
Jan 15, 2010
Currently Being Moderated
5. Jan 27, 2010 11:18 PM in response to: Serge Piletsky
Re: Problem generating dispinterfaces for powerpoint 2003

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.

cobblestone   20 posts since
Jan 15, 2010
Currently Being Moderated
6. Jan 27, 2010 11:35 PM in response to: cobblestone
Re: Problem generating dispinterfaces for powerpoint 2003

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.

Serge Piletsky TeamDev Ltd. 1,066 posts since
Apr 24, 2006
Currently Being Moderated
8. Feb 1, 2010 4:37 PM in response to: Peter Brown
Re: Problem generating dispinterfaces for powerpoint 2003

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

cobblestone   20 posts since
Jan 15, 2010
Currently Being Moderated
9. Feb 10, 2010 7:00 PM in response to: cobblestone
Re: Problem generating dispinterfaces for powerpoint 2003

is there any updating for this problem?

 

Cobble S.

Serge Piletsky TeamDev Ltd. 1,066 posts since
Apr 24, 2006
Currently Being Moderated
10. Feb 12, 2010 4:13 PM in response to: cobblestone
Re: Problem generating dispinterfaces for powerpoint 2003

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

More Like This

  • Retrieving data ...