/**
*
*/
package de.tutorials;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.FillLayout;
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.ole.win32.Variant;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
/**
* @author Thomas.Darimont
*/
public class SWTOleWordWithoutMenuExample {
public static void main(String[] args) {
Display display = new Display();
Shell shell = new Shell(display);
shell.setText("SWTOleWordWithoutMenuExample");
shell.setSize(640, 480);
shell.setLayout(new FillLayout());
OleFrame frm = new OleFrame(shell, SWT.NONE);
OleClientSite site = new OleClientSite(frm, SWT.NONE, "Word.Document");
shell.open();
OleAutomation oleAutomation = new OleAutomation(site);
int commandBarsDispId = oleAutomation.getIDsOfNames(new String[] { "CommandBars" })[0];
Variant commandBars = oleAutomation.getProperty(commandBarsDispId);
System.out.println(commandBars);
OleAutomation commandBarsAutomation = commandBars.getAutomation();
int commandBarsCountDispId = commandBarsAutomation.getIDsOfNames(new String[] { "Count" })[0];
int commandBarsCount = commandBarsAutomation.getProperty(commandBarsCountDispId).getInt();
for (int i = 0; i < commandBarsCount; i++) {
Variant commandBar = oleAutomation.getProperty(commandBarsDispId, new Variant[] { new Variant(i) });
if (null != commandBar) {
OleAutomation commandBarAutomation = commandBar.getAutomation();
int visibleDispId = commandBarAutomation.getIDsOfNames(new String[] { "Visible" })[0];
commandBarAutomation.setProperty(visibleDispId, new Variant(false));
commandBarAutomation.dispose();
}
}
commandBarsAutomation.dispose();
while (!shell.isDisposed())
if (!display.readAndDispatch()) display.sleep();
site.deactivateInPlaceClient();
oleAutomation.dispose();
site.dispose();
}
}