Community
Participate
Working Groups
I'm really not sure whether this is a SWT Bug but I was asked to report this: I would like to embed OpenOffice 1.9.79 in a Java program using SWT. So far everthing works fine, the window appears but when I try (or better SWT trys) to save the edited document by oleClientSite.save(file, true) it seems the resulting document is not complete. As soon as I open the so saved document OpenOffice asks me about a filter to select. If I try the same thing by using MS Word it works fine (although the Word instance will not be killed but this is different topic) You need to have OpenOffice 2.0 beta installed. Run the Snippet, SWT should open with an embedded OO window, type something, select file menu, exit and try to open the generated test.odt with openoffice. In my case it asks you to select a filter. Also, no matter how much you edit or write the written file seems to be always identical. Thanks -- Tobias Snippet -------------------> import java.io.File; import org.eclipse.swt.SWT; import org.eclipse.swt.layout.FillLayout; import org.eclipse.swt.ole.win32.OLE; import org.eclipse.swt.ole.win32.OleAutomation; import org.eclipse.swt.ole.win32.OleClientSite; import org.eclipse.swt.ole.win32.OleFrame; import org.eclipse.swt.widgets.Event; import org.eclipse.swt.widgets.Listener; import org.eclipse.swt.widgets.Menu; import org.eclipse.swt.widgets.MenuItem; import org.eclipse.swt.widgets.Shell; /* * Created on 25.04.2005 * */ /** * @author Tobias Himstedt, Unilog Avinci * */ public class TestOO { org.eclipse.swt.widgets.Display display = null; private org.eclipse.swt.widgets.Shell sShell = null; private OleFrame oleFrame = null; private OleClientSite oleClientSite = null; private OleAutomation automation = null; /** * This method initializes oleFrame * */ private void createOleFrame(Shell shell) { Menu bar = new Menu(sShell, SWT.BAR); sShell.setMenuBar(bar); oleFrame = new OleFrame(sShell, SWT.NONE); // oleClientSite = new OleClientSite(oleFrame, SWT.NONE, "Word.Document"); oleClientSite = new OleClientSite(oleFrame, SWT.NONE, "opendocument.WriterDocument.1"); // oleClientSite = new OleClientSite(oleFrame, SWT.NONE, "opendocument.CalcDocument.1"); // OleAutomation automation = new OleAutomation(oleClientSite); MenuItem fileItem1 = new MenuItem(bar, SWT.CASCADE); fileItem1.setText("&File"); Menu fileMenu = new Menu(shell, SWT.DROP_DOWN); fileItem1.setMenu( fileMenu ); MenuItem exitApp = new MenuItem(fileMenu, SWT.PUSH); exitApp.setText("&Exit"); exitApp.addListener(SWT.Selection, new Listener() { public void handleEvent(Event event) { exit(); } } ); oleFrame.setFileMenus(new MenuItem[] { fileItem1 }); // oleClientSite.doVerb( OLE.OLEIVERB_INPLACEACTIVATE ); oleClientSite.doVerb( OLE.OLEIVERB_SHOW); } void exit() { File file; file = new File("test.odt"); oleClientSite.save(file, true); oleClientSite.deactivateInPlaceClient(); oleClientSite.dispose(); display.dispose(); System.exit(0); } /** * This method initializes sShell */ private void createSShell() { sShell = new org.eclipse.swt.widgets.Shell(); createOleFrame(sShell); sShell.setText("Shell"); sShell.setLayout(new FillLayout()); sShell.setSize(new org.eclipse.swt.graphics.Point(300,200)); } /** * This method initializes oleClientSite * */ public static void main(String[] args) { /* Before this is run, be sure to set up the following in the launch configuration * (Arguments->VM Arguments) for the correct SWT library path. * The following is a windows example: * -Djava.library.path="installation_directory\plugins\org.eclipse.swt.win32_3.0.0\os\win32\x86" */ TestOO thisClass = new TestOO(); thisClass.display = org.eclipse.swt.widgets.Display.getDefault(); thisClass.createSShell() ; thisClass.sShell.open(); while (!thisClass.sShell.isDisposed()) { if (!thisClass.display.readAndDispatch()) thisClass.display.sleep (); } thisClass.display.dispose(); } } <--------- End Snippet
Created attachment 20400 [details] Snippet to test the behavior This is the same snippet as in the description.
Your bug has been moved to triage, visit http://www.eclipse.org/swt/triage.php for more info.
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet. As such, we're closing this bug. If you have further information on the current state of the bug, please add it and reopen this bug. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant. -- The automated Eclipse Genie.