public ContextMenuInterceptorAction notifyContextMenuExecute(
com.sun.star.ui.ContextMenuExecuteEvent aEvent ) throws RuntimeException { try { // Retrieve context menu container and query for service factory to // create sub menus, menu entries and separators
XIndexContainer xContextMenu = aEvent.ActionTriggerContainer;
XMultiServiceFactory xMenuElementFactory =
UnoRuntime.queryInterface(
XMultiServiceFactory.class, xContextMenu );
if ( xMenuElementFactory != null ) {
// create root menu entry for sub menu and sub menu
XPropertySet xRootMenuEntry =
UnoRuntime.queryInterface(
XPropertySet.class,
xMenuElementFactory.createInstance("com.sun.star.ui.ActionTrigger" ));
// create a line separator for our new help sub menu
XPropertySet xSeparator =
UnoRuntime.queryInterface(
XPropertySet.class,
xMenuElementFactory.createInstance("com.sun.star.ui.ActionTriggerSeparator" ) ); Short aSeparatorType = Short.valueOf( ActionTriggerSeparatorType.LINE );
xSeparator.setPropertyValue( "SeparatorType", aSeparatorType );
// query sub menu for index container to get access
XIndexContainer xSubMenuContainer =
UnoRuntime.queryInterface(
XIndexContainer.class,
xMenuElementFactory.createInstance("com.sun.star.ui.ActionTriggerContainer" ));
// create menu entries for the new sub menu // initialize help/content menu entry // entry "Content"
XPropertySet xMenuEntry = UnoRuntime.queryInterface(
XPropertySet.class, xMenuElementFactory.createInstance( "com.sun.star.ui.ActionTrigger" ));
xMenuEntry.setPropertyValue( "Text", "Content" );
xMenuEntry.setPropertyValue( "CommandURL", "slot:5401" );
xMenuEntry.setPropertyValue( "HelpURL", "5401" );
// insert menu entry to sub menu
xSubMenuContainer.insertByIndex( 0, xMenuEntry );
// initialize help/help on help // entry "Help on Help"
xMenuEntry = UnoRuntime.queryInterface(
XPropertySet.class,
xMenuElementFactory.createInstance("com.sun.star.ui.ActionTrigger" ));
xMenuEntry.setPropertyValue("Text", "Help on Help");
xMenuEntry.setPropertyValue("CommandURL", "slot:5400");
xMenuEntry.setPropertyValue("HelpURL", "5400");
// insert menu entry to sub menu
xSubMenuContainer.insertByIndex( 1, xMenuEntry ); // initialize help/tips // entry "Tips"
xMenuEntry = UnoRuntime.queryInterface(
XPropertySet.class,
xMenuElementFactory.createInstance("com.sun.star.ui.ActionTrigger" ));
xMenuEntry.setPropertyValue( "Text", "Tips" );
xMenuEntry.setPropertyValue( "CommandURL", "slot:5404" );
xMenuEntry.setPropertyValue( "HelpURL", "5404" );
// insert menu entry to sub menu
xSubMenuContainer.insertByIndex( 2, xMenuEntry );
// add separator into the given context menu
xContextMenu.insertByIndex( 1, xSeparator );
// add new sub menu into the given context menu
xContextMenu.insertByIndex( 1, xRootMenuEntry );
// The controller should execute the modified context menu and stop notifying other // interceptors. return ContextMenuInterceptorAction.EXECUTE_MODIFIED ;
}
} catch ( UnknownPropertyException ex ) { // do something useful // we used an unknown property
} catch ( IndexOutOfBoundsException ex ) { // do something useful // we used an invalid index for accessing a container
} catch ( Exception ex ) { // something strange has happened!
} catch ( Throwable ex ) { // catch java exceptions and do something useful
}
return ContextMenuInterceptorAction.IGNORED;
}
}
Messung V0.5 in Prozent
¤ Dauer der Verarbeitung: 0.1 Sekunden
(vorverarbeitet am 2026-09-28)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.