Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 155721 Details for
Bug 299244
[OLE] When using OleControlSite to embed MS Word 2007 in RAC view, Word commands do not react
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
Ole test view with OleControlSite to embed MS Word 2007
OleView.java (text/java), 6.50 KB, created by
Alex Safro
on 2010-01-11 04:29:00 EST
(
hide
)
Description:
Ole test view with OleControlSite to embed MS Word 2007
Filename:
MIME Type:
Creator:
Alex Safro
Created:
2010-01-11 04:29:00 EST
Size:
6.50 KB
patch
obsolete
>package testole; > >import java.io.File; >import org.eclipse.jface.resource.JFaceColors; >import org.eclipse.swt.SWT; >import org.eclipse.swt.SWTException; >import org.eclipse.swt.ole.win32.OLE; >import org.eclipse.swt.ole.win32.OleAutomation; >import org.eclipse.swt.ole.win32.OleControlSite; >import org.eclipse.swt.ole.win32.OleFrame; >import org.eclipse.swt.ole.win32.Variant; >import org.eclipse.swt.widgets.Composite; >import org.eclipse.ui.IPartListener; >import org.eclipse.ui.IWorkbenchPart; >import org.eclipse.ui.PlatformUI; >import org.eclipse.ui.part.ViewPart; > >public class OleView extends ViewPart >{ > /** The OleFrame. */ > private OleFrame oleFrame = null; > > /** > * Keep track of whether we have an active client so we do not de-activate > * multiple times. > */ > private boolean clientActive = false; > > /** > * Keep track of whether we have activated OLE or not as some applications > * will only allow single activations. > */ > private boolean oleActivated = false; > > /** The OleClientSite. */ > //private OleClientSite oleClientSite = null; > > /** The OleControlSite. */ > private OleControlSite oleControlSite = null; > > /** The part listener. */ > private IPartListener partListener = new IPartListener() > { > public void partActivated( IWorkbenchPart part ) > { > activateClient( part ); > } > > public void partBroughtToTop( IWorkbenchPart part ) > { > } > > public void partClosed( IWorkbenchPart part ) > { > } > > public void partOpened( IWorkbenchPart part ) > { > } > > public void partDeactivated( IWorkbenchPart part ) > { > deactivateClient( part ); > } > }; > > @Override > public void createPartControl( Composite parent ) > { > getSite().getPage().addPartListener( partListener ); > > populateEditorPart( parent ); > } > > @Override > public void dispose() > { > disposeClient(); > super.dispose(); > } > > @Override > public void setFocus() > { > // To Do > } > > /** > * This method populates the editor part and opens the file in the editor. > * > * @param parent the parent > * @unpublished > */ > public void populateEditorPart(Composite parent) > { > oleFrame = new OleFrame(parent, SWT.CLIP_CHILDREN); > oleFrame.setBackground(JFaceColors.getBannerBackground(oleFrame > .getDisplay())); > > oleFrame.setContainerMenus(PlatformUI.getWorkbench() > .getActiveWorkbenchWindow().getShell().getMenuBar().getItems()); > > if (oleControlSite != null) > { > // dispose the older one > disposeClient(); > } > oleControlSite = new OleControlSite(oleFrame, SWT.NONE, "Word.Document"); > > if (oleControlSite != null) > { > oleControlSite.doVerb(OLE.OLEIVERB_INPLACEACTIVATE); > > } > } > > /** > * Create the oleClientSite with the input file. > * > * @param inputFile the input file > * @return oleclient site > * @unpublished > */ > protected OleControlSite getOleClientSite( File inputFile ) > { > // If there was an OLE Error or nothing has been created yet > if( oleFrame == null || oleFrame.isDisposed() ) > { > return null; > } > // Create a OLE client site. > try > { > oleControlSite = new OleControlSite( oleFrame, SWT.NONE, inputFile ); > } > catch( SWTException exception ) > { > exception.printStackTrace(); > return null; > } > oleControlSite.setBackground( JFaceColors.getBannerBackground( oleFrame.getDisplay() ) ); > return oleControlSite; > } > > /** > * Activate oleClientSite. > * > * @param part the part > * @unpublished > */ > private void activateClient( IWorkbenchPart part ) > { > if( part == this ) > { > oleActivate(); > this.clientActive = true; > } > } > > /** > * De-active the oleClientSite. > * > * @param part the part > * @unpublished > */ > private void deactivateClient( IWorkbenchPart part ) > { > // Check the client active flag. Set it to false when we have > // de-activated to prevent multiple de-activations. > if( part == this && clientActive ) > { > if( oleControlSite != null ) > { > oleControlSite.deactivateInPlaceClient(); > } > this.clientActive = false; > this.oleActivated = false; > } > } > > /** > * Make ole active so that the controls are rendered. > * > * @unpublished > */ > private void oleActivate() > { > // If there was an OLE Error or nothing has been created yet > if( oleControlSite == null || oleFrame == null || oleFrame.isDisposed() ) > { > return; > } > > if( !oleActivated ) > { > oleControlSite.doVerb( OLE.OLEIVERB_SHOW ); > oleActivated = true; > String progId = oleControlSite.getProgramID(); > if( progId != null && progId.startsWith( "Word.Document" ) ) //$NON-NLS-1$ > { > handleWord(); > } > } > } > > /** > * Handle word. > * > * @unpublished > */ > private void handleWord() > { > OleAutomation dispInterface = new OleAutomation( oleControlSite ); > // Get Application > int[] appId = dispInterface.getIDsOfNames( new String[] { "Application" } ); //$NON-NLS-1$ > if( appId != null ) > { > Variant pVarResult = dispInterface.getProperty( appId[0] ); > if( pVarResult != null ) > { > OleAutomation application = pVarResult.getAutomation(); > int[] dispid = application.getIDsOfNames( new String[] { "DisplayScrollBars" } ); //$NON-NLS-1$ > if( dispid != null ) > { > Variant rgvarg = new Variant( true ); > application.setProperty( dispid[0], rgvarg ); > } > application.dispose(); > } > } > dispInterface.dispose(); > } > > /** > * This method dispose the oleClientSite. > * > * @unpublished > */ > private void disposeClient() > { > if( oleControlSite != null ) > { > oleControlSite.dispose(); > } > oleControlSite = null; > } >} // end class OleView
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 299244
: 155721