Bug 92896 - [OLE] OLE / OpenOffice / clientSite.save() problem
Summary: [OLE] OLE / OpenOffice / clientSite.save() problem
Status: CLOSED WONTFIX
Alias: None
Product: Platform
Classification: Eclipse Project
Component: SWT (show other bugs)
Version: 3.0.2   Edit
Hardware: PC Windows All
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Platform-SWT-Inbox CLA
QA Contact:
URL:
Whiteboard: stalebug
Keywords: triaged
Depends on:
Blocks: 43379
  Show dependency tree
 
Reported: 2005-04-27 08:20 EDT by Tobias Himstedt CLA
Modified: 2020-04-06 04:05 EDT (History)
3 users (show)

See Also:


Attachments
Snippet to test the behavior (3.23 KB, application/octet-stream)
2005-04-27 08:41 EDT, Tobias Himstedt CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Tobias Himstedt CLA 2005-04-27 08:21:00 EDT
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
Comment 1 Tobias Himstedt CLA 2005-04-27 08:41:35 EDT
Created attachment 20400 [details]
Snippet to test the behavior

This is the same snippet as in the description.
Comment 2 Felipe Heidrich CLA 2009-08-13 09:29:26 EDT
Your bug has been moved to triage, visit http://www.eclipse.org/swt/triage.php for more info.
Comment 3 Eclipse Genie CLA 2020-04-06 04:05:38 EDT
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.