Thursday, June 28, 2007

XEMBED, Mono and OpenOffice.org

In my last post I talked about the hack I did to get some Java applets running in an OpenOffice.org docking window.

I played a little more with the code and managed to get a XEMBED socket running in an OpenOffice.org docking window. The picture below shows an OpenOffice.org running with a XEMBED ready docking window:



The title bar of the docking window shows the socket id to which XEMBED applications can connect.

I used the following Mono code to connect to the XEMBED socket:

using System;
using Gtk;

// Compile with:
// mcs -pkg:gtk-sharp SamplePlug.cs

public class SamplePlug
{

public static void Main(string[] args) {
if (args.Length != 1) {
Console.WriteLine("Need socket id as an argument.");
return;
}
uint socket_id = UInt32.Parse(args[0]);

Console.WriteLine("using socket "+socket_id);

Application.Init();

Plug plug= new Plug(socket_id);
// plug.Add(new Label("HELLO"));
plug.Add(new Entry("HELLO"));
plug.ShowAll();

Console.WriteLine("running..");
Application.Run();
}
}


The picture below shows it all running:


In theory this'll work not only with Mono but with any application which can talk the XEMBED protocol like e.g. GTK- and QT-based applications.

Friday, June 22, 2007

ActiveX-like embedding of applications in OpenOffice.org?

I'm working on the problem of embedding applications in an OpenOffice docking window --- similar to the new API inside Word which allows to embed ActiveX applications in a task pane.

I just started “hacking” on the problem and I decided to try whether I can embed a Java Applet inside an OpenOffice.org docking window.

Well I “hacked” :-) the Navigator --- which is a docking window --- and reused some code from the sj module and here it is:





However there a some --- severe --- open problems:
- Focus: The framework knows nothing about XEMBED_REQUEST_FOCUS, etc
(http://standards.freedesktop.org/xembed-spec/latest/ar01s05.html)
So there is a focus problem when the applet is running in "docked" mode. (Maybe this is also the problem why the OOoBean is not working so good?)
- Need to clone the Navigator code...
- Resize problem and other events. Currently the embedded app is not notified
about resize events.
- Need to define an API to get link between embedded aps and the custom
pane.
- Some "solar mutex" problems as always :-)