Community
Participate
Working Groups
Build Identifier: I have embedded MS Word in an Eclipse view using OlecontrolSite. When the view is created, the MSWord shows up with the menus/ribbon. Once I click in a different area outside the view the menus/ribbon area disappear from the MSWord. Reproducible: Always
I am using the following code: private OleFrame oleFrame = null; public OleControlSite oleControlSite = null; private OleAutomation dispInterface = null; private void setUpView( Composite parent ) { oleFrame = new OleFrame( parent, SWT.NULL ); oleFrame.setBackground( JFaceColors.getBannerBackground( oleFrame.getDisplay() ) ); IMenuManager fileMenu = AUtility.getWorkbenchWindowMenuManager().findMenuUsingPath( IWorkbenchActionConstants.M_FILE ); oleFrame.setFileMenus( new MenuItem[] { ( (MenuManager) fileMenu ).getMenu().getParentItem() } ); IMenuManager windowsMenu = AUtility.getWorkbenchWindowMenuManager().findMenuUsingPath( IWorkbenchActionConstants.M_WINDOW ); oleFrame.setWindowMenus( new MenuItem[] { ( (MenuManager) windowsMenu ).getMenu().getParentItem() } ); } private void activateClient( IWorkbenchPart part ) { if( part == this ) { oleActivate(); if( oleControlSite != null ) { oleControlSite.setEnabled( true ); } } } private void deactivateClient( IWorkbenchPart part ) { if( part == this && clientActive ) { if( oleControlSite != null ) { oleControlSite.deactivateInPlaceClient(); } clientActive = false; oleActivated = false; } } private void oleActivate() { //Make ole active so that the controls are rendered. // 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 ); oleControlSite.doVerb( OLE.OLEIVERB_INPLACEACTIVATE ); oleControlSite.setEnabled( false ); oleActivated = true; clientActive = true; } } /** * Instantiates the IE as an ActiveX component * hosted using the OleControlSite wrapper provided by Eclipse * * @param file the input file * @return An instance of OleControlSite wrapper for IE. * @unpublished */ protected OleControlSite getOleControlSite( File file ) { // 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 { /** * The constructor here is instantiating an IE web browser control * which will be used to host the MS Word document. */ oleControlSite = new OleControlSite( oleFrame, SWT.NONE, "Shell.Explorer" ); oleControlSite.setBackground( JFaceColors.getBannerBackground( oleFrame.getDisplay() ) ); } catch( SWTException exception ) { exception.printStackTrace(); return null; } return oleControlSite; }
It works fine with Eclipse 3.5 OleControlSite. The issue is with Eclipse 3.6 OleControlSite, when you focus out of the Word view the word ribbon/toolbar disappears. Thanks for your prompt response.
The onFocusEvent in OleControlSite.java has undergone changes between Eclipse 3.5 and Eclipse 3.6
I am also seeing the same behavior, however in my case it seems related to focus change. If I click on the Eclipse View, click to give some other application focus, and then click back to give eclipse focus...then the MS ribbon hides.
I can't run the snippet in comment 1, could please post a snippet that is SWT only ? (no dependecies on other plugins if possible). Thank you.
//Here is the requested SWT only code. public class EmbeddedWordView extends ViewPart implements ISelectionListener, ISaveablePart2, IPartListener2 { private File inputFile = null; /** The OleFrame. */ private OleFrame oleFrame = null; /** The OleClientSite. */ public OleControlSite oleControlSite = null; /** * Keep track of whether we have an active client so we do not deactivate * 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 part listener. */ private IPartListener partListener = new IPartListener() { public void partActivated( IWorkbenchPart part ) { if( part == EmbeddedWordView.this ) { 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 ); setupEmbeddedWordView( parent ); } private void setupEmbeddedWordView( Composite parent ) { oleFrame = new OleFrame( parent, SWT.NULL ); oleFrame.setBackground( JFaceColors.getBannerBackground( oleFrame.getDisplay() ) ); IWorkbench iwb = PlatformUI.getWorkbench(); IWorkbenchWindow iww = iwb.getActiveWorkbenchWindow(); WorkbenchWindow ww = (WorkbenchWindow) iww; IMenuManager fileMenu = ww.getMenuManager().findMenuUsingPath( IWorkbenchActionConstants.M_FILE ); oleFrame.setFileMenus( new MenuItem[] { ( (MenuManager) fileMenu ).getMenu().getParentItem() } ); IMenuManager windowsMenu = ww.getMenuManager().findMenuUsingPath( IWorkbenchActionConstants.M_WINDOW ); oleFrame.setWindowMenus( new MenuItem[] { ( (MenuManager) windowsMenu ).getMenu().getParentItem() } ); } private void activateClient( IWorkbenchPart part ) { if( part == this ) { oleActivate(); if( oleControlSite != null ) { oleControlSite.setEnabled( true ); } } } private void deactivateClient( IWorkbenchPart part ) { if( part == this && clientActive ) { if( oleControlSite != null ) { oleControlSite.deactivateInPlaceClient(); } clientActive = false; oleActivated = false; } } private void oleActivate() { //Make ole active so that the controls are rendered. // 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 ); oleControlSite.doVerb( OLE.OLEIVERB_INPLACEACTIVATE ); oleControlSite.setEnabled( false ); oleActivated = true; clientActive = true; } } /** * Instantiates the IE as an ActiveX component * hosted using the OleControlSite wrapper provided by Eclipse * * @param file the input file * @return An instance of OleControlSite wrapper for IE. * @unpublished */ protected OleControlSite getOleControlSite( File file ) { // 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 { /** * The constructor here is instantiating an IE web browser control * which will be used to host the MS Word document. */ oleControlSite = new OleControlSite( oleFrame, SWT.NONE, "Shell.Explorer" ); oleControlSite.setBackground( JFaceColors.getBannerBackground( oleFrame.getDisplay() ) ); } catch( SWTException exception ) { exception.printStackTrace(); return null; } return oleControlSite; } /** * This method dispose the oleClientSite. * * @unpublished */ private void disposeClient() { if( oleControlSite != null ) { deactivateClient( this ); oleControlSite.dispose(); } oleControlSite = null; } /** * Call this program and pass an MS Word .docx file after the setupEmbeddedWordView() call * * @param f the input file MS Word .docx */ private void setInput( File f ) { inputFile = f; if( oleControlSite != null ) { disposeClient(); } if( inputFile != null ) { oleControlSite = getOleControlSite( inputFile ); OleAutomation wb = null; if( oleControlSite != null ) { oleActivate(); oleControlSite.setEnabled( true ); // Open the word document using Navigate2 interface. wb = new OleAutomation( oleControlSite ); } else { // throw and exception and get out of here. } if( wb != null ) { // Make control visible int[] visibleID = wb.getIDsOfNames( new String[] { "Visible" } ); if( visibleID != null ) { boolean result = wb.setProperty( visibleID[0], new Variant[] { new Variant( true ) } ); if( !result ) { // throw an exception or something } } // Load the document using Navigate2 method int[] navigate2Id = wb.getIDsOfNames( new String[] { "Navigate2" } ); if( navigate2Id != null ) { wb.invoke( navigate2Id[0], new Variant[] { new Variant( f.getAbsolutePath() ) } ); } } } else { // give some proper message? } } }
sorry, I still can't run that. You are including several types that are not SWT (like jface, ui, etc). Also, your class does not have a main method, I guess I would need include this view part in a plugin or something before I can run it... This is what I mean by a SWT only snippet: http://www.eclipse.org/swt/snippets/index.php#ole
Created attachment 197650 [details] This file has SWT only code to reproduce MS Word Ribbon issues This file has SWT only code to reproduce the following MS Word Ribbon issues: 1. Run the program and choose a docx file in the file open dialog to launch the application with MS Word document. Check the MS Word ribbon which is in enabled state. Click on the Windows taskbar or some place outside Eclipse and notice the ribbon is disabled. 2. Click the desktop area outside Eclipse and click on the scrollbar in the application from Step 1 (or click on the Ribbon itself), the ribbon disappears
I followed the steps in comment 8 on my Windows Vista (sorry, I don't have word on my Windows 7). After I select a .docx file my word 2007 opens in a new widow, the ribbon is enabled and remains enabled no matter where I click. In the application window, that opens just after the word window opens, has a menu bar and in the client area has a message 'Navigation to the webpage was canceled'.
Felipe: IF it opens in an external application, you aren't embedding the word document into SWT application. To solve the issue that it opens in a new external application: For windows 7: http://support.microsoft.com/kb/927009 For windows XP: 1. Open Windows Explorer. 2. Choose Tools→Folder Options. 3. Click the File Types tab. 4. In the Registered File Types list, select the DOC extension. 5. Click the Advanced button. 6. In the Edit File Type dialog box, ensure that Browse in same window check box is selected. Click OK. 7. Repeat steps 4–6 for the DOCX, PPT, PPTX, XLS, and XLSX extensions. I have no idea about the solution for Windows Vista. If it isn't embedded in SWT, then you wouldn't be able to duplicate the bug. Thanks, Shyam
(In reply to comment #9) > I followed the steps in comment 8 on my Windows Vista (sorry, I don't have word > on my Windows 7). > After I select a .docx file my word 2007 opens in a new widow, the ribbon is > enabled and remains enabled no matter where I click. > In the application window, that opens just after the word window opens, has a > menu bar and in the client area has a message 'Navigation to the webpage was > canceled'. Felipe, You can use the following Microsoft link to browse in same window. Follow the workaround section in this article. It will update the registry entries for you. http://support.microsoft.com/kb/927009
Damodhar, I won't be in the office tomorrow so I will just give you a quick update from my last investigation on this probelem (I was able to reproduce after following the instruction in the previous comment). The bug is caused (the ribbon dissapearing) by a call to UIDeactivate() in OleControlSite#OnFocusOut(), this call was introduced as a fix for bug 264398. If you remove that method call the problem goes away.
(In reply to comment #12) > Damodhar, > I won't be in the office tomorrow so I will just give you a quick update from > my last investigation on this probelem (I was able to reproduce after following > the instruction in the previous comment). > The bug is caused (the ribbon dissapearing) by a call to UIDeactivate() in > OleControlSite#OnFocusOut(), this call was introduced as a fix for bug 264398. > If you remove that method call the problem goes away. Felipe, Thanks for the update! The bug is in OleControlSite that we don't have access to and we cannot modify it. What about the inactive ribbon issue? Would that be solved with the suggested change? How is this bug going to be addressed by Eclipse? I appreciate your inputs.
I don't see how to fix this problem without re-introducing bug 264398. In both cases the prog id is Shell.Explorer. If I call UIDeactivate() this breaks, if I don't then bug 264398 breaks. Do you know if IE web browser control has API to check what app it is hosting ? Note that you can fix the problem on your end by: 1. Using OleClientSite instead of OleControlSite 2. Using SetupWord.clientSite = new OleControlSite( SetupWord.frame, SWT.NONE, new File("C:\\Users\\Felipe\\Documents\\whatever.docx")); or SetupWord.clientSite = new OleControlSite( SetupWord.frame, SWT.NONE, "Word.Document" ); Instead of SetupWord.clientSite = new OleControlSite( SetupWord.frame, SWT.NONE, "Shell.Explorer" );
(In reply to comment #14) > I don't see how to fix this problem without re-introducing bug 264398. > In both cases the prog id is Shell.Explorer. > If I call UIDeactivate() this breaks, if I don't then bug 264398 breaks. > Do you know if IE web browser control has API to check what app it is hosting > ? > Note that you can fix the problem on your end by: > 1. Using OleClientSite instead of OleControlSite > 2. Using > SetupWord.clientSite = new OleControlSite( SetupWord.frame, SWT.NONE, new > File("C:\\Users\\Felipe\\Documents\\whatever.docx")); > or > SetupWord.clientSite = new OleControlSite( SetupWord.frame, SWT.NONE, > "Word.Document" ); > Instead of > SetupWord.clientSite = new OleControlSite( SetupWord.frame, SWT.NONE, > "Shell.Explorer" ); Felipe, We will need to use Shell.Explorer, which will give access to additional functionality for the OLE Document or ActiveX Control What does host application do? Thanks, Damodhar
> We will need to use Shell.Explorer, which will give access to additional > functionality for the OLE Document or ActiveX Control > What does host application do? You are using the "Navigate2" method of Shell.Explorer to open your docx. At the point you have SWT hosting Shell.Explorer and Shell.Explorer hosting Word. Why question was, do you know if Shell.Explorer has a method which we could use to know if Shell.Explorer is showing a word document ?
(In reply to comment #16) > > We will need to use Shell.Explorer, which will give access to additional > > functionality for the OLE Document or ActiveX Control > > What does host application do? > You are using the "Navigate2" method of Shell.Explorer to open your docx. > At the point you have SWT hosting Shell.Explorer and Shell.Explorer hosting > Word. > Why question was, do you know if Shell.Explorer has a method which we could use > to know if Shell.Explorer is showing a word document ? What would be your suggestion if we have a way to tell Shell.Explorer is showing a Word document? Thanks
(In reply to comment #17) > What would be your suggestion if we have a way to tell Shell.Explorer is > showing a Word document? If there is a way secure way (no hacks please) to do that we can use to stop the fix of bug 264398 from running. This means that UIDeactivate() would not be called, thus the ribbon would not disappear. I believe that would work.
(In reply to comment #18) > (In reply to comment #17) > > What would be your suggestion if we have a way to tell Shell.Explorer is > > showing a Word document? > If there is a way secure way (no hacks please) to do that we can use to stop > the fix of bug 264398 from running. This means that UIDeactivate() would not be > called, thus the ribbon would not disappear. I believe that would work. Please go through the following link that will explain how you can look for Microsoft Word document for a Web Browser. Hope this helps: http://msdn.microsoft.com/en-us/library/aa752052(v=VS.85).aspx Thanks.
(In reply to comment #19) > (In reply to comment #18) > > (In reply to comment #17) > > > What would be your suggestion if we have a way to tell Shell.Explorer is > > > showing a Word document? > > If there is a way secure way (no hacks please) to do that we can use to stop > > the fix of bug 264398 from running. This means that UIDeactivate() would not be > > called, thus the ribbon would not disappear. I believe that would work. > Please go through the following link that will explain how you can look for > Microsoft Word document for a Web Browser. Hope this helps: > http://msdn.microsoft.com/en-us/library/aa752052(v=VS.85).aspx > Thanks. Sorry, I don't see how that is useful, can you please send an snippet showing how to use this API ?
Created attachment 198576 [details] Snippet to display type of document opened Hi Felipe, Enclosed the snippet to figure out which document is opened. You can select a Word (.docx) or Excel(.xlsx) file and open it. Select File->Print App to see the type of document opened on the tile bar. Hope this helps. Thanks.
(In reply to comment #20) > (In reply to comment #19) > > (In reply to comment #18) > > > (In reply to comment #17) > > > > What would be your suggestion if we have a way to tell Shell.Explorer is > > > > showing a Word document? > > > If there is a way secure way (no hacks please) to do that we can use to stop > > > the fix of bug 264398 from running. This means that UIDeactivate() would not be > > > called, thus the ribbon would not disappear. I believe that would work. > > Please go through the following link that will explain how you can look for > > Microsoft Word document for a Web Browser. Hope this helps: > > http://msdn.microsoft.com/en-us/library/aa752052(v=VS.85).aspx > > Thanks. > Sorry, I don't see how that is useful, can you please send an snippet showing > how to use this API ? Felipe, Hope the latest snippet I provided is useful. Any update? Thanks, Damodhar
(In reply to comment #22) > Any update? I'll try this tomorrow first thing in the morning, do you have a target milestone of eclipse that you will need to fix in (provided that we do succeed finding a fix for the problem) ?
(In reply to comment #23) > (In reply to comment #22) > > Any update? > I'll try this tomorrow first thing in the morning, do you have a target > milestone of eclipse that you will need to fix in (provided that we do succeed > finding a fix for the problem) ? Thanks! Let me know what you find. We will need as soon as you can make it possible.
Created attachment 198920 [details] patch Please try this patch on your product and let me know the result. It worked for me (fixes this bug without re-introducing Bug 264398). Thank you
have you had the chance to try the patch ? note you should download SWT from the CVS before applying the patch http://eclipse.org/swt/cvs.php
(In reply to comment #26) > have you had the chance to try the patch ? > note you should download SWT from the CVS before applying the patch > http://eclipse.org/swt/cvs.php I have applied the patch after downloading the org.eclipse.swt project from CVS repository (from HEAD). I see the difference in behavior in the following scenarios: I have launched our app from within Eclipse and noticed ribbon doesn’t disappear anymore, but when you lose focus from within the app somehow and come back the ribbon gets disabled(not responding). You have to click in the document after focusing out of the app to get it enabled. Please let me know your inputs. You mentioned this patch will be available 3.7.1 or 3.8. So, does that mean it is available as early as 3.7.1? Do you know the time frames of both these releases? Thanks.
The patch has changes to onFocusIn and onFocusOut Can you remove the changes in onFocusIn and try again ? I'm not sure of the dates, but major release 3.8 prop in june 2012 minor release 3.7.1 prop in sep 2011 minor release 3.7.2 prop in feb 2012 I will be able to release the code to 3.7.1 only if it is a simple change, if the fix gets too big I probably won't be able to commit it.
(In reply to comment #28) > The patch has changes to onFocusIn and onFocusOut > Can you remove the changes in onFocusIn and try again ? > I'm not sure of the dates, but > major release 3.8 prop in june 2012 > minor release 3.7.1 prop in sep 2011 > minor release 3.7.2 prop in feb 2012 > I will be able to release the code to 3.7.1 only if it is a simple change, if > the fix gets too big I probably won't be able to commit it. I tested it by removing the line from onFocusIn. The problem is still there but seems to be intermittent when I lose focus within the app.
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. If you have further information on the current state of the bug, please add it. 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.