Sorry, mistaken advice from AI. This works for me in LibreOffice and Firefox. The previous advice gave me Japanese input in LibreOffice but not Firefox.
Put this in .xprofile
export XIM=ibus
export GTK_IM_MODULE=ibus
export QT_IM_MODULE=ibus
export XMODIFIERS=@im=ibus
export XIM_PROGRAM="ibus-daemon"
export XIM_ARGS="--daemonize --xim"