Re: [dev] custom menu item disappearing after printpreview
This is how the disappearing menuItem got fixed. > //the menubar we want is a property of the XUIElement oMenuBar > XMenuBar bar = (XMenuBar) > UnoRuntime.queryInterface(XMenuBar.class, > menuBarProps.getPropertyValue("XMenuBar")); > > XUIElementSettings xoMenuBarSettings = > (XUIElementSettings) UnoRuntime > .queryInterface(XUIElementSettings.class, > oMenuBar); > XIndexContainer oMenuBarSettings = (XIndexContainer) > UnoRuntime > .queryInterface(XIndexContainer.class, > xoMenuBarSettings > .getSettings(true)); > > XSingleComponentFactory factory = > (XSingleComponentFactory) > UnoRuntime > > .queryInterface(XSingleComponentFactory.class, > oMenuBarSettings); > > PropertyValue[] menu = createMenu(".uno:PickList","VAPH", > factory); > oMenuBarSettings.insertByIndex(0, menu); > > XIndexContainer vaphContainer = (XIndexContainer) > UnoRuntime.queryInterface(XIndexContainer.class, menu[3].Value); > > PropertyValue[] subPv1 = createMenuItem(".uno:Print++", > FENIKS_PRINT); > PropertyValue[] paragraaf = > createMenuItem(".uno:Paragraaf++","Optionele ~Paragrafen..."); > > vaphContainer.insertByIndex(0,subPv1); > vaphContainer.insertByIndex(1,paragraaf); > > xoMenuBarSettings.setSettings(oMenuBarSettings); > XTopWindow topWindow = (XTopWindow) > UnoRuntime.queryInterface(XTopWindow.class, > xFrameWindow.getUNOWindowPeer()); > > //setting the new menubar > topWindow.setMenuBar(bar); > //not setting it persistent otherwise is will be added > multiple times on every reload > menuBarProps.setPropertyValue("Persistent", new > Boolean(false)); > > >private PropertyValue[] createMenuItem(String sMyCommand, String label) > throws Exception { > PropertyValue[] loadProps = new PropertyValue[4]; > loadProps[0] = new PropertyValue(); > loadProps[1] = new PropertyValue(); > loadProps[2] = new PropertyValue(); > loadProps[3] = new PropertyValue(); > > loadProps[0].Name = "CommandURL"; > loadProps[0].Value = sMyCommand; > loadProps[1].Name = "Label"; > loadProps[1].Value = label; > loadProps[2].Name = "Type"; > loadProps[2].Value = 0; > loadProps[3].Name = "ItemDescriptorContainer"; > loadProps[3].Value = null; > > return loadProps; > } > > Carsten Driesner wrote: > > Fhomasp wrote: >> Hey, >> >> Alright, noted. However I still need to get this to work. At this point >> it >> seems that the LayoutManager lifecycle is already put into another >> Thread. >> How else could it be that I can get it working slightly better with the >> use >> of Threads, and get 100% successrate if I wait long enough in Debug mode? >> Still. It's nowhere near a good solution, and I can't have the users go >> through debug mode :-) >> > Hi Fhomasp, > > I don't know why you have these kind of problems as I cannot reproduce > it with my own implementation. I also know that the LayoutManager is > normally not running in a different thread. OpenOffice.org has just one > thread for the user interface called the main thread. It's possible to > call the LayoutManager from a different thread using remote UNO but I > cannot recommend it. The only thing I can propose to you is that you > send me your solution via mail and I will try to find out what's wrong. > As we are short before the release of OOo 3.1 I cannot promise that I > have time to check it in the next couple of days. > > Regards, > Carsten > > - > To unsubscribe, e-mail: dev-unsubscr...@openoffice.org > For additional commands, e-mail: dev-h...@openoffice.org > > > -- View this message in context: http://www.nabble.com/custom-menu-item-disappearing-after-printpreview-tp22741195p22950787.html Sent from the openoffice - dev mailing list archive at Nabble.com. - To unsubscribe, e-mail: dev-unsubscr...@openoffice.org For additional commands, e-mail: dev-h...@openoffice.org
Re: [dev] custom menu item disappearing after printpreview
I'm using OpenOffice 2.4. It's not my choice. Maybe that has something to do with it. There are a few other functions that seems to require OOo 2.4. However with this version I've noticed some other strange behaviour as well. It might have something to do with how the proxies are implemented, although that's just speculation on my part. Of course the listeners do run in a seperate Thread, IIRC. I'll send you my controller class and the Swing panel containing the document. No rush of course, you've been most helpful already. Carsten Driesner wrote: > > Fhomasp wrote: >> Hey, >> >> Alright, noted. However I still need to get this to work. At this point >> it >> seems that the LayoutManager lifecycle is already put into another >> Thread. >> How else could it be that I can get it working slightly better with the >> use >> of Threads, and get 100% successrate if I wait long enough in Debug mode? >> Still. It's nowhere near a good solution, and I can't have the users go >> through debug mode :-) >> > Hi Fhomasp, > > I don't know why you have these kind of problems as I cannot reproduce > it with my own implementation. I also know that the LayoutManager is > normally not running in a different thread. OpenOffice.org has just one > thread for the user interface called the main thread. It's possible to > call the LayoutManager from a different thread using remote UNO but I > cannot recommend it. The only thing I can propose to you is that you > send me your solution via mail and I will try to find out what's wrong. > As we are short before the release of OOo 3.1 I cannot promise that I > have time to check it in the next couple of days. > > Regards, > Carsten > > - > To unsubscribe, e-mail: dev-unsubscr...@openoffice.org > For additional commands, e-mail: dev-h...@openoffice.org > > > -- View this message in context: http://www.nabble.com/custom-menu-item-disappearing-after-printpreview-tp22741195p22804938.html Sent from the openoffice - dev mailing list archive at Nabble.com. - To unsubscribe, e-mail: dev-unsubscr...@openoffice.org For additional commands, e-mail: dev-h...@openoffice.org
Re: [dev] custom menu item disappearing after printpreview
Fhomasp wrote: Hey, Alright, noted. However I still need to get this to work. At this point it seems that the LayoutManager lifecycle is already put into another Thread. How else could it be that I can get it working slightly better with the use of Threads, and get 100% successrate if I wait long enough in Debug mode? Still. It's nowhere near a good solution, and I can't have the users go through debug mode :-) Hi Fhomasp, I don't know why you have these kind of problems as I cannot reproduce it with my own implementation. I also know that the LayoutManager is normally not running in a different thread. OpenOffice.org has just one thread for the user interface called the main thread. It's possible to call the LayoutManager from a different thread using remote UNO but I cannot recommend it. The only thing I can propose to you is that you send me your solution via mail and I will try to find out what's wrong. As we are short before the release of OOo 3.1 I cannot promise that I have time to check it in the next couple of days. Regards, Carsten - To unsubscribe, e-mail: dev-unsubscr...@openoffice.org For additional commands, e-mail: dev-h...@openoffice.org
Re: [dev] custom menu item disappearing after printpreview
Hey, Alright, noted. However I still need to get this to work. At this point it seems that the LayoutManager lifecycle is already put into another Thread. How else could it be that I can get it working slightly better with the use of Threads, and get 100% successrate if I wait long enough in Debug mode? Still. It's nowhere near a good solution, and I can't have the users go through debug mode :-) Carsten Driesner wrote: > > Fhomasp wrote: >> Hey, thanks >> >> I'm not very used to working with proxies. >> >> Some new info about my issue here has come to light. It would seem that >> both your suggested approaches work occasionally. That is, both only >> works >> in debug mode. Which makes me assume that it is a Threading issue. >> However attempting to control the sequence of the Threads doesn't work at >> all. For example: >> >> public void layoutEvent(EventObject eventObject, short i, Object object) >> { >> if (i == LayoutManagerEvents.UIELEMENT_VISIBLE && >> object.equals("private:resource/menubar/menubar")) { >> SwingUtilities.invokeLater(new Runnable(){ >> >> public void run() { >> try { >> addParagraafMenu(); >> } catch (Exception e) { >> throw new >> SeriousException(e.getMessage(),this,e); >> } >> } >> }); >> >> } >> } >> > Hi Fhomasp, > > Please don't call your menu bar changes in another thread. You have to > make the changes directly in the layoutEvent call. OpenOffice.org is not > well prepared for multi threading. > > Regards, > Carsten > > - > To unsubscribe, e-mail: dev-unsubscr...@openoffice.org > For additional commands, e-mail: dev-h...@openoffice.org > > > -- View this message in context: http://www.nabble.com/custom-menu-item-disappearing-after-printpreview-tp22741195p22804128.html Sent from the openoffice - dev mailing list archive at Nabble.com. - To unsubscribe, e-mail: dev-unsubscr...@openoffice.org For additional commands, e-mail: dev-h...@openoffice.org
Re: [dev] custom menu item disappearing after printpreview
Fhomasp wrote: Hey, thanks I'm not very used to working with proxies. Some new info about my issue here has come to light. It would seem that both your suggested approaches work occasionally. That is, both only works in debug mode. Which makes me assume that it is a Threading issue. However attempting to control the sequence of the Threads doesn't work at all. For example: public void layoutEvent(EventObject eventObject, short i, Object object) { if (i == LayoutManagerEvents.UIELEMENT_VISIBLE && object.equals("private:resource/menubar/menubar")) { SwingUtilities.invokeLater(new Runnable(){ public void run() { try { addParagraafMenu(); } catch (Exception e) { throw new SeriousException(e.getMessage(),this,e); } } }); } } Hi Fhomasp, Please don't call your menu bar changes in another thread. You have to make the changes directly in the layoutEvent call. OpenOffice.org is not well prepared for multi threading. Regards, Carsten - To unsubscribe, e-mail: dev-unsubscr...@openoffice.org For additional commands, e-mail: dev-h...@openoffice.org
Re: [dev] custom menu item disappearing after printpreview
Hey, thanks I'm not very used to working with proxies. Some new info about my issue here has come to light. It would seem that both your suggested approaches work occasionally. That is, both only works in debug mode. Which makes me assume that it is a Threading issue. However attempting to control the sequence of the Threads doesn't work at all. For example: public void layoutEvent(EventObject eventObject, short i, Object object) { if (i == LayoutManagerEvents.UIELEMENT_VISIBLE && object.equals("private:resource/menubar/menubar")) { SwingUtilities.invokeLater(new Runnable(){ public void run() { try { addParagraafMenu(); } catch (Exception e) { throw new SeriousException(e.getMessage(),this,e); } } }); } } Carsten Driesner wrote: > > Fhomasp wrote: >> Hey, and thanks! :) >> >> You mean an XLayoutManagerEventBroadcaster I assume? >> I can't say I found many examples of an XLayoutManagerEventBroadcaster. >> And >> I'm not sure where and which listener I need to attach. >> > Hi Fhomasp, > > This is trivial if you look at the interface declaration of > com.sun.star.frame.XLayoutManagerEventBroadcaster. You need to implement > the interface com.sun.star.frame.XLayoutManagerListener. It contains > just on method called: > > void layoutEvent( [in] com::sun::star::lang::EventObject aSource, [in] > short eLayoutEvent, [in] any aInfo ); > > As your code already retrieves the LayoutManager from the frame it's > fairly simple to query for > com.sun.star.frame.XLayoutManagerEventBroadcaster and call > addLayoutManagerEventListener( yourlistenerinstance ). > > In your implementation for layoutEvent(...) you should first look for > the interesting eLayoutEvent called UIELEMENT_VISIBLE. The aInfo > parameter contains the resource url of the user interface element. E.g. > for your use case this is "private:resource/menubar/menubar". So if you > receive an event with eLayoutEvent == UIELEMENT_VISIBLE and aInfo == > "private:resource/menubar/menubar" than you should use the source (which > is the LayoutManager) to query for the menu bar. If the menu bar needs > to be changed you should call your configuration code. > > Regards, > Carsten > > - > To unsubscribe, e-mail: dev-unsubscr...@openoffice.org > For additional commands, e-mail: dev-h...@openoffice.org > > > -- View this message in context: http://www.nabble.com/custom-menu-item-disappearing-after-printpreview-tp22741195p22800525.html Sent from the openoffice - dev mailing list archive at Nabble.com. - To unsubscribe, e-mail: dev-unsubscr...@openoffice.org For additional commands, e-mail: dev-h...@openoffice.org
Re: [dev] custom menu item disappearing after printpreview
Fhomasp wrote: Hey, and thanks! :) You mean an XLayoutManagerEventBroadcaster I assume? I can't say I found many examples of an XLayoutManagerEventBroadcaster. And I'm not sure where and which listener I need to attach. Hi Fhomasp, This is trivial if you look at the interface declaration of com.sun.star.frame.XLayoutManagerEventBroadcaster. You need to implement the interface com.sun.star.frame.XLayoutManagerListener. It contains just on method called: void layoutEvent( [in] com::sun::star::lang::EventObject aSource, [in] short eLayoutEvent, [in] any aInfo ); As your code already retrieves the LayoutManager from the frame it's fairly simple to query for com.sun.star.frame.XLayoutManagerEventBroadcaster and call addLayoutManagerEventListener( yourlistenerinstance ). In your implementation for layoutEvent(...) you should first look for the interesting eLayoutEvent called UIELEMENT_VISIBLE. The aInfo parameter contains the resource url of the user interface element. E.g. for your use case this is "private:resource/menubar/menubar". So if you receive an event with eLayoutEvent == UIELEMENT_VISIBLE and aInfo == "private:resource/menubar/menubar" than you should use the source (which is the LayoutManager) to query for the menu bar. If the menu bar needs to be changed you should call your configuration code. Regards, Carsten - To unsubscribe, e-mail: dev-unsubscr...@openoffice.org For additional commands, e-mail: dev-h...@openoffice.org
Re: [dev] custom menu item disappearing after printpreview
Hey, and thanks! :) You mean an XLayoutManagerEventBroadcaster I assume? I can't say I found many examples of an XLayoutManagerEventBroadcaster. And I'm not sure where and which listener I need to attach. Carsten Driesner wrote: > > Fhomasp wrote: >> Hey, >> >> Thanks for the info. >> >> I do seem to run into problems trying to get it to work adding a >> FrameActionListener. Here's what happens. >> >> 1. I add an anonymous implementation of XFrameActionListener to the frame >> when a document is loaded. >> When I catch the FrameAction: "FrameAction.COMPONENT_REATTACHED" only I >> catch the Action when PrintPreview is invoked. >> When I catch using if - else and use "FrameAction.COMPONENT_ATTACHED" >> then >> in the first "if", as described above, I can't catch an action when >> PrintPreview is invoked. >> >> 2. In any of the given situations I cannot seem to get a hold of the >> MenuBar. It's always null. I tried to get the XFrame in several ways, >> which works and then try to get the XLayoutManager using the XPropertySet >> from the different ways of getting the XFrame. I get "an" >> XLayoutManager, >> however it never has any Elements. I print out the Elements received >> from >> xLayoutManager.getElements(), but it's an empty Array. >> >> > Hi Fhomasp, > > That sounds strange as my code does the same and works without a > problem. Looks like that your listener is called before the layout > manager gets notified which would result in an empty user interface. > Therefore another approach is to use the LayoutManager notifications for > the user interface elements. Use the XLayoutManagerBroadcaster and add > your code as a listener. Whenever you receive a > css::frame::LayoutManagerEvents::UIELEMENT_VISIBLE notification and the > aInfo parameter contains the resource URL of the menu bar, you can check > if you have to make your changes again. > > Regards, > Carsten > > - > To unsubscribe, e-mail: dev-unsubscr...@openoffice.org > For additional commands, e-mail: dev-h...@openoffice.org > > > -- View this message in context: http://www.nabble.com/custom-menu-item-disappearing-after-printpreview-tp22741195p22780221.html Sent from the openoffice - dev mailing list archive at Nabble.com. - To unsubscribe, e-mail: dev-unsubscr...@openoffice.org For additional commands, e-mail: dev-h...@openoffice.org
Re: [dev] custom menu item disappearing after printpreview
Fhomasp wrote: Hey, Thanks for the info. I do seem to run into problems trying to get it to work adding a FrameActionListener. Here's what happens. 1. I add an anonymous implementation of XFrameActionListener to the frame when a document is loaded. When I catch the FrameAction: "FrameAction.COMPONENT_REATTACHED" only I catch the Action when PrintPreview is invoked. When I catch using if - else and use "FrameAction.COMPONENT_ATTACHED" then in the first "if", as described above, I can't catch an action when PrintPreview is invoked. 2. In any of the given situations I cannot seem to get a hold of the MenuBar. It's always null. I tried to get the XFrame in several ways, which works and then try to get the XLayoutManager using the XPropertySet from the different ways of getting the XFrame. I get "an" XLayoutManager, however it never has any Elements. I print out the Elements received from xLayoutManager.getElements(), but it's an empty Array. Hi Fhomasp, That sounds strange as my code does the same and works without a problem. Looks like that your listener is called before the layout manager gets notified which would result in an empty user interface. Therefore another approach is to use the LayoutManager notifications for the user interface elements. Use the XLayoutManagerBroadcaster and add your code as a listener. Whenever you receive a css::frame::LayoutManagerEvents::UIELEMENT_VISIBLE notification and the aInfo parameter contains the resource URL of the menu bar, you can check if you have to make your changes again. Regards, Carsten - To unsubscribe, e-mail: dev-unsubscr...@openoffice.org For additional commands, e-mail: dev-h...@openoffice.org
Re: [dev] custom menu item disappearing after printpreview
Hey, Thanks for the info. I do seem to run into problems trying to get it to work adding a FrameActionListener. Here's what happens. 1. I add an anonymous implementation of XFrameActionListener to the frame when a document is loaded. When I catch the FrameAction: "FrameAction.COMPONENT_REATTACHED" only I catch the Action when PrintPreview is invoked. When I catch using if - else and use "FrameAction.COMPONENT_ATTACHED" then in the first "if", as described above, I can't catch an action when PrintPreview is invoked. 2. In any of the given situations I cannot seem to get a hold of the MenuBar. It's always null. I tried to get the XFrame in several ways, which works and then try to get the XLayoutManager using the XPropertySet from the different ways of getting the XFrame. I get "an" XLayoutManager, however it never has any Elements. I print out the Elements received from xLayoutManager.getElements(), but it's an empty Array. Here's the code I used: > aFrame.addFrameActionListener(new XFrameActionListener(){ > > public void frameAction(FrameActionEvent > frameActionEvent) { > //System.out.println(frameActionEvent + > "\t"+frameActionEvent.Action.getValue()); > //FrameAction.COMPONENT_ATTACHED; > > if(frameActionEvent.Action.equals(FrameAction.COMPONENT_REATTACHED)){ > Object source = frameActionEvent.Source; > System.out.println("ReAttached!"); > try{ > > addParagraafMenu(source); > }catch(Exception e){ > e.printStackTrace(); > } > } > // commented out because this causes the selection above not to trigger > anymore > //else > if(frameActionEvent.Action.equals(FrameAction.COMPONENT_ATTACHED)){ > // > //try { > // > addParagraafMenu(frameActionEvent.Source); > //} catch (Exception e) { > //e.printStackTrace(); > //} > //} > } > > public void addParagraafMenu(Object source) throws Exception, > WrappedTargetException, IndexOutOfBoundsException, > IllegalArgumentException, PropertyVetoException { > //I can get this frame > XFrame srcFrame = > (XFrame)UnoRuntime.queryInterface(XFrame.class,source); > > XMultiComponentFactory fact = > iConnection.getComponentContext().getServiceManager(); > Object desktop = > fact.createInstanceWithContext("com.sun.star.frame.Desktop",iConnection.getComponentContext()); > //Using the XDesktop I can also get the frame, but no help there > XDesktop xDesktop = (XDesktop) > UnoRuntime.queryInterface(XDesktop.class,desktop); > > XPropertySet xps = (XPropertySet) UnoRuntime.queryInterface( > XPropertySet.class, srcFrame); > //xLayoutManager is never null but never has any XUIElements > XLayoutManager xLayoutManager = (XLayoutManager) > UnoRuntime.queryInterface( > XLayoutManager.class, > xps.getPropertyValue("LayoutManager")); > XUIElement myMenubar = > xLayoutManager.getElement("private:resource/menubar/menubar"); > > XUIElement[] elements = xLayoutManager.getElements(); > for(XUIElement elem:elements){ > String hmm = elem.toString()+"\t"; > hmm.concat(elem.getRealInterface().toString()); > System.out.println(hmm); > } > > XUIElementSettings myMenuBarSettings = (XUIElementSettings) > UnoRuntime.queryInterface(XUIElementSettings.class, > myMenubar); > XIndexContainer myMenuBarSettingsContainer = (XIndexContainer) > UnoRuntime.queryInterface( > > XIndexContainer.class,myMenuBarSettings.getSettings(true)); > > XPropertySet menuBarSets = (XPropertySet) > UnoRuntime.queryInterface( > XPropertySet.class, myMenubar); > > menuBarSets.setPropertyValue("Persistent",new Boolean(false)); > XMenuBar bar = (XMenuBar) > UnoRuntime.queryInterface(XMenuBar.class, > menuBarProps.getPropertyValue("XMenuBar")); > bar.insertItem((short) 0, "~Paragraaf", > com.sun.star.awt.MenuItemStyle.AUTOCHECK, (short) 0); > //setting the menu > bar.setPopupMenu((short) 0, getPopupMenu()); > bar.addMenuListener(this); > myMenuBarSettings.setSettings(myMenuBarSettingsContainer); > > } > Carsten Driesner wrote: > > Fhomasp wrote: >> Hey, >> >> I implemented a custom menu item using one of the examples. However this >> extra menu item disappears as soon as a printpreview screen is invoked. >> The >> menu item doesn't re
Re: [dev] custom menu item disappearing after printpreview
Fhomasp wrote: Hey, I implemented a custom menu item using one of the examples. However this extra menu item disappears as soon as a printpreview screen is invoked. The menu item doesn't return when the printpreview is closed. Here's the code I used Hi Fhomasp, You use non-persistent changes for the menu bar. The print preview function uses a different controller implementation and therefore the user interface elements are reinitialized, means destroyed and created. That's why your changes get lost. You have to add a FrameActionListener to the frame and redo your changes whenever your receive a FRAMEACTION_ATTACHED, FRAMEACTION_REATTACHED notification. Regards, Carsten -- Carsten Driesner (cd) - Project Lead OpenOffice.org Framework Framework wiki: http://wiki.services.openoffice.org/wiki/Framework OpenOffice.org Engineering at Sun: http://blogs.sun.com/GullFOSS - To unsubscribe, e-mail: dev-unsubscr...@openoffice.org For additional commands, e-mail: dev-h...@openoffice.org
[dev] custom menu item disappearing after printpreview
Hey, I implemented a custom menu item using one of the examples. However this extra menu item disappears as soon as a printpreview screen is invoked. The menu item doesn't return when the printpreview is closed. Here's the code I used > public void doMenuExtras() { > try { > //getting the extra menu names > getConditionList(); > //you need the top window of the openoffice window > if (xTraMenuList.size() > 0) { > > String sMenuBar = "private:resource/menubar/menubar"; > XComponentContext context = > iConnection.getComponentContext(); > XMultiComponentFactory serviceMgr = > context.getServiceManager(); > XPropertySet xps = (XPropertySet) > UnoRuntime.queryInterface( > XPropertySet.class, aFrame); > XLayoutManager xLayoutManager = (XLayoutManager) > UnoRuntime.queryInterface( > XLayoutManager.class, > xps.getPropertyValue("LayoutManager")); > > //getting the menubar of the topwindow by the > layoutmanager > XUIElement oMenuBar = xLayoutManager.getElement(sMenuBar); > menuBarProps = (XPropertySet) UnoRuntime.queryInterface( > XPropertySet.class, oMenuBar); > > //the menubar we want is a property of the XUIElement > oMenuBar > XMenuBar bar = (XMenuBar) > UnoRuntime.queryInterface(XMenuBar.class, > menuBarProps.getPropertyValue("XMenuBar")); > > XUIElementSettings xoMenuBarSettings = > (XUIElementSettings) UnoRuntime > .queryInterface(XUIElementSettings.class, > oMenuBar); > XIndexContainer oMenuBarSettings = (XIndexContainer) > UnoRuntime > .queryInterface(XIndexContainer.class, > xoMenuBarSettings > .getSettings(true)); > > XSingleComponentFactory factory = > (XSingleComponentFactory) > UnoRuntime > > .queryInterface(XSingleComponentFactory.class, > oMenuBarSettings); > > > PropertyValue[] propsContainer = (PropertyValue[]) > oMenuBarSettings.getByIndex(0); > XIndexContainer container = null; > > for (int i = 0; i < propsContainer.length; i++) { > if > (propsContainer[i].Name.equals("ItemDescriptorContainer")) { > container = (XIndexContainer) > UnoRuntime.queryInterface(XIndexContainer.class, propsContainer[i].Value); > > } > } > > PropertyValue[] subPv1 = createMenuItem(".uno:Print++", > FENIKS_PRINT, factory); > > container.insertByIndex(26, subPv1); > xoMenuBarSettings.setSettings(oMenuBarSettings); > XTopWindow topWindow = (XTopWindow) > UnoRuntime.queryInterface(XTopWindow.class, > xFrameWindow.getUNOWindowPeer()); > > //inserting an new menu name > bar.insertItem((short) 0, "~Paragraaf", > com.sun.star.awt.MenuItemStyle.AUTOCHECK, (short) 0); > //setting the menu > bar.setPopupMenu((short) 0, getPopupMenu()); > > //adding an menuListener > bar.addMenuListener(this); > > //setting the new menubar > topWindow.setMenuBar(bar); > //not setting it persistent otherwise is will be added > multiple times on every reload > menuBarProps.setPropertyValue("Persistent", false); //true > helpt niet voor het print prev prob > > > } > } catch (Exception e) { > e.printStackTrace(); //To change body of catch statement use > File | Settings | File Templates. > } > } > > public XPopupMenu getPopupMenu() { > XPopupMenu xPopupMenu = null; > try { > // create a popup menu > XComponentContext context = iConnection.getComponentContext(); > Object oPopupMenu = > context.getServiceManager().createInstanceWithContext("stardiv.Toolkit.VCLXPopupMenu", > context); > xPopupMenu = (XPopupMenu) > UnoRuntime.queryInterface(XPopupMenu.class, oPopupMenu); > XMenuExtended xMenuExtended = (XMenuExtended) > UnoRuntime.queryInterface(XMenuExtended.class, xPopupMenu); > XTextSectionsSupplier oTSSupp = (XTextSectionsSupplier) > UnoRuntime.queryInterface( > XTextSectionsSupplier.class, aDocument); > > XNameAccess nameAccess = oTSSupp.getTextSections(); > > > for (int i = 0; i < xTraMenuList.size(); i++) { > XPropertySet pAccess = (XPropertySet) > UnoRuntime.queryInterface(XPropertySet.class, > nameAccess.getByName(xTraMenuList.get(i))); > xPo