Hi,
I try to display a simple message box with javascript macro but nothing appears when I run the code with Rhino JS Debugger. What is wrong in my js code ?
If I use icon in toolbar to launch the code I obtain an error message:
I use libreoffice 7.2.4 for linux64 with jre-8u311 and jre-8u221
This is the code:
// Source of the code :
// [Java, BSH and JS Script examples] Display a message box (View topic) • Apache OpenOffice Community Forum
importClass(Packages.com.sun.star.uno.UnoRuntime);
importClass(Packages.com.sun.star.awt.MessageBoxButtons);
importClass(Packages.com.sun.star.awt.Rectangle);
importClass(Packages.com.sun.star.awt.XMessageBox);
importClass(Packages.com.sun.star.awt.XMessageBoxFactory);
importClass(Packages.com.sun.star.awt.XWindow);
importClass(Packages.com.sun.star.awt.XWindowPeer);
document = XSCRIPTCONTEXT.getDocument();
parentWindow = document.getCurrentController().getFrame().getContainerWindow();
parentWindowPeer = UnoRuntime.queryInterface(XWindowPeer, parentWindow);
messageBoxFactory = UnoRuntime.queryInterface(XMessageBoxFactory,parentWindowPeer.getToolkit());
messageBoxType = “MESSAGEBOX”;
messageBoxButtons = 1;
messageBoxTitle = “Window Title”;
message = “Hello world”;
box = messageBoxFactory.createMessageBox(parentWindowPeer, messageBoxType, messageBoxButtons, messageBoxTitle, message) ;
box.execute();