how to embed openoffice [message #447288] |
Mon, 13 December 2004 06:09  |
Eclipse User |
|
|
|
Hi,
I've been using the Openoffice.org OfficeBean to embed OpenOffice in a
AWT application. Well, I used that app only to test OO-embedding and now
I'm looking for a decent java window toolkit.
AFAIK, it should theoretically be possible to embed OO in SWT (it isn't
in Swing, because Swing uses non-native-drawing-routines), the only
thing is: I have no idea how. Obviously, many widgets expect a
shell-parameter which notices the shell to draw them, but of course the
O.o O-Bean does not expect a shell-parameter in it's constructor beause
it is used to the process that the layout manager is explicitly told to
show this new widget.
Is there a way to get AWT-Components to work in SWT? If there was, maybe
that would be similar to the solution for my OO-problem? Or does anybody
happen to know how to embed OpenOffice?
thanks,
Jochen
|
|
|
Re: how to embed openoffice [message #447304 is a reply to message #447288] |
Mon, 13 December 2004 08:31   |
Eclipse User |
|
|
|
You can embed AWT in SWT using the SWT_AWT class. See:
http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.swt.sni ppets/src/org/eclipse/swt/snippets/Snippet135.java?rev=HEAD& amp;content-type=text/vnd.viewcvs-markup
See also this SWT FAQ about support for AWT in SWT:
http://dev.eclipse.org/viewcvs/index.cgi/%7Echeckout%7E/plat form-swt-home/faq.html#swinginswt
"Jochen Staerk" <jstaerk@usegroup.de> wrote in message
news:cpjt97$2bi$1@www.eclipse.org...
> Hi,
>
> I've been using the Openoffice.org OfficeBean to embed OpenOffice in a AWT
> application. Well, I used that app only to test OO-embedding and now I'm
> looking for a decent java window toolkit.
>
> AFAIK, it should theoretically be possible to embed OO in SWT (it isn't in
> Swing, because Swing uses non-native-drawing-routines), the only thing is:
> I have no idea how. Obviously, many widgets expect a shell-parameter which
> notices the shell to draw them, but of course the O.o O-Bean does not
> expect a shell-parameter in it's constructor beause it is used to the
> process that the layout manager is explicitly told to show this new
> widget.
>
> Is there a way to get AWT-Components to work in SWT? If there was, maybe
> that would be similar to the solution for my OO-problem? Or does anybody
> happen to know how to embed OpenOffice?
>
>
> thanks,
> Jochen
|
|
|
|
|
Re: how to embed openoffice [message #447643 is a reply to message #447627] |
Wed, 15 December 2004 16:08  |
Eclipse User |
|
|
|
Joerg von Frantzius wrote:
> Hello Jochen,
>
> do you have any idea what this incompatibility could be?
I think I've already seen this when I tried to get the officebean
directly on a Swing JForm. I'd guess that maybe the officebean does not
get a native window handle in the format it expects, if it gets one at
all, but that's wild guessing right now.
Besides, this is not related to the fact that the SWT/AWT bridge does
not work correctly on linux with jdk 1.4.2, I upgraded to 1.5.0 to get
Veronika's Snippet 135 working.
My source is (LocalOfficeConnection, SimpleBean and dependant files are
taken from the OO-SDK):
package swt1;
import org.eclipse.swt.widgets.Composite;
import java.awt.Frame;
import com.sun.star.beans.LocalOfficeConnection;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.*;
import org.eclipse.swt.awt.SWT_AWT;
import org.eclipse.swt.layout.GridLayout;
import java.io.IOException;
public class Snippet138 {
public static void main(String[] args) {
final Display display = new Display();
final Shell shell = new Shell(display);
Composite comp = new Composite(shell,SWT.EMBEDDED);
Frame frame = SWT_AWT.new_Frame(comp);
SimpleBean rv = new SimpleBean();
rv.setOfficeConnection(new LocalOfficeConnection());
// this next command causes a getNativeWindow-Assertion
try {
rv.load("private:factory/swriter");
} catch (IOException ex) {
ex.printStackTrace();
}
frame.add( rv );
frame.setVisible(true);
// seems as if SOME sort of layout is needed
GridLayout layout = new GridLayout(1, false);
shell.setLayout(layout);
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) display.sleep();
}
display.dispose();
}
}
bye
Jochen
|
|
|
Powered by
FUDForum. Page generated in 0.04154 seconds