public boolean setMenuTextForSwitchOff ( XComponentContext xContext ) { boolean ret = true ; XMenuBar menubar = OfficeTools . getMenuBar ( xContext ) ; if ( menubar == null ) { MessageHandler . printToLogFile ( "Menubar is null" ) ; return ret ; } XPopupMenu toolsMenu = null ; XPopupMenu ltMenu = null ; short toolsId = 0 ; short ltId = 0 ; try { for ( short i = 0 ; i < menubar . getItemCount ( ) ; i ++ ) { toolsId = menubar . getItemId ( i ) ; String command = menubar . getCommand ( toolsId ) ; if ( TOOLS_COMMAND . equals ( command ) ) { toolsMenu = menubar . getPopupMenu ( toolsId ) ; break ; } } if ( toolsMenu == null ) { MessageHandler . printToLogFile ( "Tools Menu is null" ) ; return ret ; } for ( short i = 0 ; i < toolsMenu . getItemCount ( ) ; i ++ ) { String command = toolsMenu . getCommand ( toolsMenu . getItemId ( i ) ) ; if ( WORD_COUNT_COMMAND . equals ( command ) ) { ltId = toolsMenu . getItemId ( ( short ) ( i - 1 ) ) ; ltMenu = toolsMenu . getPopupMenu ( ltId ) ; break ; } } if ( ltMenu == null ) { MessageHandler . printToLogFile ( "LT Menu is null" ) ; return ret ; } short switchOffId = 0 ; for ( short i = 0 ; i < ltMenu . getItemCount ( ) ; i ++ ) { String command = ltMenu . getCommand ( ltMenu . getItemId ( i ) ) ; if ( LT_SWITCH_OFF_COMMAND . equals ( command ) ) { switchOffId = ltMenu . getItemId ( i ) ; break ; } } if ( switchOffId == 0 ) { MessageHandler . printToLogFile ( "switchOffId not found" ) ; return ret ; } boolean isSwitchOff = ltMenu . isItemChecked ( switchOffId ) ; if ( ( switchOff && isSwitchOff ) || ( ! switchOff && ! isSwitchOff ) ) { ret = false ; } ltMenu . setItemText ( switchOffId , messages . getString ( "loMenuSwitchOff" ) ) ; if ( switchOff ) { ltMenu . checkItem ( switchOffId , true ) ; } else { ltMenu . checkItem ( switchOffId , false ) ; } } catch ( Throwable t ) { MessageHandler . printException ( t ) ; } toolsMenu . setPopupMenu ( ltId , ltMenu ) ; menubar . setPopupMenu ( toolsId , toolsMenu ) ; return ret ; }
Set or remove a check mark to the LT menu item Switch Off return true if text should be rechecked