ContextMenuInterceptor.java (a893be29) | ContextMenuInterceptor.java (509df7cb) |
---|---|
1/************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance --- 39 unchanged lines hidden (view full) --- 48 com.sun.star.frame.XComponentLoader xCompLoader = 49 (com.sun.star.frame.XComponentLoader)UnoRuntime.queryInterface( 50 com.sun.star.frame.XComponentLoader.class, xDesktop); 51 52 com.sun.star.lang.XComponent xComponent = 53 xCompLoader.loadComponentFromURL("private:factory/swriter", 54 "_blank", 0, new com.sun.star.beans.PropertyValue[0]); 55 | 1/************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance --- 39 unchanged lines hidden (view full) --- 48 com.sun.star.frame.XComponentLoader xCompLoader = 49 (com.sun.star.frame.XComponentLoader)UnoRuntime.queryInterface( 50 com.sun.star.frame.XComponentLoader.class, xDesktop); 51 52 com.sun.star.lang.XComponent xComponent = 53 xCompLoader.loadComponentFromURL("private:factory/swriter", 54 "_blank", 0, new com.sun.star.beans.PropertyValue[0]); 55 |
56 // intialize the test document | 56 // initialize the test document |
57 com.sun.star.frame.XFrame xFrame = null; 58 { 59 com.sun.star.text.XTextDocument xDoc =(com.sun.star.text.XTextDocument) 60 UnoRuntime.queryInterface(com.sun.star.text.XTextDocument.class, 61 xComponent); 62 63 String infoMsg = new String("All context menus of the created document frame contains now a 'Help' entry with the submenus 'Content', 'Help Agent' and 'Tips'.\n\nPress 'Return' in the shell to remove the context menu interceptor and finish the example!"); 64 xDoc.getText().setString(infoMsg); --- 100 unchanged lines hidden (view full) --- 165 166 // query sub menu for index container to get access 167 com.sun.star.container.XIndexContainer xSubMenuContainer = 168 (com.sun.star.container.XIndexContainer)UnoRuntime.queryInterface( 169 com.sun.star.container.XIndexContainer.class, 170 xMenuElementFactory.createInstance( 171 "com.sun.star.ui.ActionTriggerContainer" )); 172 | 57 com.sun.star.frame.XFrame xFrame = null; 58 { 59 com.sun.star.text.XTextDocument xDoc =(com.sun.star.text.XTextDocument) 60 UnoRuntime.queryInterface(com.sun.star.text.XTextDocument.class, 61 xComponent); 62 63 String infoMsg = new String("All context menus of the created document frame contains now a 'Help' entry with the submenus 'Content', 'Help Agent' and 'Tips'.\n\nPress 'Return' in the shell to remove the context menu interceptor and finish the example!"); 64 xDoc.getText().setString(infoMsg); --- 100 unchanged lines hidden (view full) --- 165 166 // query sub menu for index container to get access 167 com.sun.star.container.XIndexContainer xSubMenuContainer = 168 (com.sun.star.container.XIndexContainer)UnoRuntime.queryInterface( 169 com.sun.star.container.XIndexContainer.class, 170 xMenuElementFactory.createInstance( 171 "com.sun.star.ui.ActionTriggerContainer" )); 172 |
173 // intialize root menu entry | 173 // initialize root menu entry |
174 xRootMenuEntry.setPropertyValue( "Text", new String( "Help" )); 175 xRootMenuEntry.setPropertyValue( "CommandURL", new String( "slot:5410" )); 176 xRootMenuEntry.setPropertyValue( "HelpURL", new String( "5410" )); 177 xRootMenuEntry.setPropertyValue( "SubContainer", (Object)xSubMenuContainer ); 178 179 // create menu entries for the new sub menu 180 | 174 xRootMenuEntry.setPropertyValue( "Text", new String( "Help" )); 175 xRootMenuEntry.setPropertyValue( "CommandURL", new String( "slot:5410" )); 176 xRootMenuEntry.setPropertyValue( "HelpURL", new String( "5410" )); 177 xRootMenuEntry.setPropertyValue( "SubContainer", (Object)xSubMenuContainer ); 178 179 // create menu entries for the new sub menu 180 |
181 // intialize help/content menu entry | 181 // initialize help/content menu entry |
182 XPropertySet xMenuEntry = (XPropertySet)UnoRuntime.queryInterface( 183 XPropertySet.class, xMenuElementFactory.createInstance( 184 "com.sun.star.ui.ActionTrigger" )); 185 186 xMenuEntry.setPropertyValue( "Text", new String( "Content" )); 187 xMenuEntry.setPropertyValue( "CommandURL", new String( "slot:5401" )); 188 xMenuEntry.setPropertyValue( "HelpURL", new String( "5401" )); 189 190 // insert menu entry to sub menu 191 xSubMenuContainer.insertByIndex( 0, (Object)xMenuEntry ); 192 | 182 XPropertySet xMenuEntry = (XPropertySet)UnoRuntime.queryInterface( 183 XPropertySet.class, xMenuElementFactory.createInstance( 184 "com.sun.star.ui.ActionTrigger" )); 185 186 xMenuEntry.setPropertyValue( "Text", new String( "Content" )); 187 xMenuEntry.setPropertyValue( "CommandURL", new String( "slot:5401" )); 188 xMenuEntry.setPropertyValue( "HelpURL", new String( "5401" )); 189 190 // insert menu entry to sub menu 191 xSubMenuContainer.insertByIndex( 0, (Object)xMenuEntry ); 192 |
193 // intialize help/help agent | 193 // initialize help/help agent |
194 xMenuEntry = (com.sun.star.beans.XPropertySet)UnoRuntime.queryInterface( 195 com.sun.star.beans.XPropertySet.class, 196 xMenuElementFactory.createInstance( 197 "com.sun.star.ui.ActionTrigger" )); 198 xMenuEntry.setPropertyValue( "Text", new String( "Help Agent" )); 199 xMenuEntry.setPropertyValue( "CommandURL", new String( "slot:5962" )); 200 xMenuEntry.setPropertyValue( "HelpURL", new String( "5962" )); 201 202 // insert menu entry to sub menu 203 xSubMenuContainer.insertByIndex( 1, (Object)xMenuEntry ); 204 | 194 xMenuEntry = (com.sun.star.beans.XPropertySet)UnoRuntime.queryInterface( 195 com.sun.star.beans.XPropertySet.class, 196 xMenuElementFactory.createInstance( 197 "com.sun.star.ui.ActionTrigger" )); 198 xMenuEntry.setPropertyValue( "Text", new String( "Help Agent" )); 199 xMenuEntry.setPropertyValue( "CommandURL", new String( "slot:5962" )); 200 xMenuEntry.setPropertyValue( "HelpURL", new String( "5962" )); 201 202 // insert menu entry to sub menu 203 xSubMenuContainer.insertByIndex( 1, (Object)xMenuEntry ); 204 |
205 // intialize help/tips | 205 // initialize help/tips |
206 xMenuEntry = (com.sun.star.beans.XPropertySet)UnoRuntime.queryInterface( 207 com.sun.star.beans.XPropertySet.class, 208 xMenuElementFactory.createInstance( 209 "com.sun.star.ui.ActionTrigger" )); 210 xMenuEntry.setPropertyValue( "Text", new String( "Tips" )); 211 xMenuEntry.setPropertyValue( "CommandURL", new String( "slot:5404" )); 212 xMenuEntry.setPropertyValue( "HelpURL", new String( "5404" )); 213 --- 32 unchanged lines hidden --- | 206 xMenuEntry = (com.sun.star.beans.XPropertySet)UnoRuntime.queryInterface( 207 com.sun.star.beans.XPropertySet.class, 208 xMenuElementFactory.createInstance( 209 "com.sun.star.ui.ActionTrigger" )); 210 xMenuEntry.setPropertyValue( "Text", new String( "Tips" )); 211 xMenuEntry.setPropertyValue( "CommandURL", new String( "slot:5404" )); 212 xMenuEntry.setPropertyValue( "HelpURL", new String( "5404" )); 213 --- 32 unchanged lines hidden --- |