How to embed OleControlSite in a MultiPageEditor? [message #800505] |
Fri, 17 February 2012 06:45 |
Narendran Shanmugasundaram Messages: 5 Registered: July 2009 |
Junior Member |
|
|
Hello,
I am trying to embed the MS Word OleControlSite in one of the pages of MultiPageEditor. I want to have a tree (which will display bookmarks) on the left and the OleControlSite on the right. I have added two composites - one for the tree and one for the ole control. Here is the code (the argument 'container' is obtained from MultiPageEditorPart.getContainer()) :
public Composite createContents(Composite container) {
final ScrolledComposite scParent = new ScrolledComposite(container, SWT.V_SCROLL | SWT.H_SCROLL | SWT.BORDER);
final Composite parent = new Composite(scParent,SWT.NONE);
scParent.setContent(parent);
GridLayout layout = new GridLayout();
layout.numColumns = 10;
parent.setLayout(layout);
GridData gridData = new GridData();
final Composite treeParent = new Composite(parent, 0);
treeParent.setLayout(new GridLayout());
gridData = new GridData(GridData.FILL_VERTICAL);
gridData.horizontalSpan = 2;
treeParent.setLayoutData(gridData);
final Composite wordParent = new Composite(parent, 0);
wordParent.setLayout(new GridLayout());
gridData = new GridData(GridData.FILL_BOTH);
gridData.horizontalSpan = 8;
wordParent.setLayoutData(gridData);
Shell wordShell = wordParent.getShell();
wordShell.setLayout(new FillLayout());
wordShell.setSize(parent.getSize());
final TreeViewer sectionTreeViewer = new TreeViewer(treeParent);
gridData = new GridData(GridData.FILL_BOTH);
final Tree sectionTree = sectionTreeViewer.getTree();
sectionTree.setLayoutData(gridData);
OleFrame frame = new OleFrame(wordParent.getShell(), SWT.NONE);
OleControlSite controlSite =
new OleControlSite(frame, SWT.NONE, "Word.Document", new File("C:\\test\\test.docx"));
controlSite.doVerb(OLE.OLEIVERB_INPLACEACTIVATE);
parent.setSize(parent.computeSize(1200, 800));
parent.addDisposeListener(new DisposeListener(){
@Override
public void widgetDisposed(DisposeEvent e) {
keysFont.dispose();
whiteColor.dispose();
}
});
return scParent;
}
But the ole control always gets displayed outside the editor (attached image). I found that this does not happen when I change wordShell.setLayout(new FillLayout()) to set any other layout. But when I change the layout, the ole control doesnt get displayed.
I am not sure how to fix this problem. Any help would be very welcome.
Thanks,
Naren.
|
|
|
|
|
Powered by
FUDForum. Page generated in 5.04336 seconds