Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » how to embed openoffice
how to embed openoffice [message #447288] Mon, 13 December 2004 11:09 Go to next message
Jochen Stärk is currently offline Jochen StärkFriend
Messages: 3
Registered: July 2009
Junior Member
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 13:31 Go to previous messageGo to next message
Veronika Irvine is currently offline Veronika IrvineFriend
Messages: 1272
Registered: July 2009
Senior Member
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 #447623 is a reply to message #447304] Wed, 15 December 2004 12:32 Go to previous messageGo to next message
Jochen Stärk is currently offline Jochen StärkFriend
Messages: 3
Registered: July 2009
Junior Member
Hi,
> 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

thanks, I figured out how to embed AWT components, unfortunately, the
OfficeBean does not seem to be compatible to SWT

(Exception in thread "main" java.lang.RuntimeException: assertion failed
at com.sun.star.beans.LocalOfficeWindow.getNativeWindow(Native Method)
at
com.sun.star.beans.LocalOfficeWindow.aquireSystemWindow(Loca lOfficeWindow.java:171)
at
com.sun.star.beans.LocalOfficeWindow.setVisible(LocalOfficeW indow.java:226)
at swt1.BasicOfficeBean.load(BasicOfficeBean.java:187)
at swt1.Snippet137.main(Snippet137.java:30)
)

thanks a lot anyway.

bye
Jochen
Re: how to embed openoffice [message #447627 is a reply to message #447623] Wed, 15 December 2004 15:27 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: joerg.von.frantzius.artnology.nospam.com

Hello Jochen,

do you have any idea what this incompatibility could be?

Thanks,
Jörg.

Jochen Staerk schrieb:

> Hi,
>
>> 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
>>
>
>
> thanks, I figured out how to embed AWT components, unfortunately, the
> OfficeBean does not seem to be compatible to SWT
>
> (Exception in thread "main" java.lang.RuntimeException: assertion failed
> at com.sun.star.beans.LocalOfficeWindow.getNativeWindow(Native
> Method)
> at
> com.sun.star.beans.LocalOfficeWindow.aquireSystemWindow(Loca lOfficeWindow.java:171)
>
> at
> com.sun.star.beans.LocalOfficeWindow.setVisible(LocalOfficeW indow.java:226)
>
> at swt1.BasicOfficeBean.load(BasicOfficeBean.java:187)
> at swt1.Snippet137.main(Snippet137.java:30)
> )
>
> thanks a lot anyway.
>
> bye
> Jochen
Re: how to embed openoffice [message #447643 is a reply to message #447627] Wed, 15 December 2004 21:08 Go to previous message
Jochen Stärk is currently offline Jochen StärkFriend
Messages: 3
Registered: July 2009
Junior Member
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
Previous Topic:Good books for SWT and JFace
Next Topic:Open an file when clicking a TableTreeViewer
Goto Forum:
  


Current Time: Thu Apr 25 10:53:29 GMT 2024

Powered by FUDForum. Page generated in 0.03305 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top