From 0bca4008e96efc19af84b5ec3649bed36a0ffc8b Mon Sep 17 00:00:00 2001 From: Sander Vesik Date: Mon, 19 Apr 2004 22:01:12 +0000 Subject: INTEGRATION: CWS scriptingf5 (1.1.2); FILE ADDED 2004/03/22 16:27:26 toconnor 1.1.2.2: #i22570# - Update URL usage in examples to new non hierarchical scheme 2004/02/19 17:48:03 toconnor 1.1.2.1: #i25271# Add Highlight example in all languages. Use DialogProvider to create XDialog and display it. --- .../examples/javascript/Highlight/ShowDialog.js | 45 ++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 scripting/examples/javascript/Highlight/ShowDialog.js (limited to 'scripting/examples/javascript/Highlight') diff --git a/scripting/examples/javascript/Highlight/ShowDialog.js b/scripting/examples/javascript/Highlight/ShowDialog.js new file mode 100644 index 000000000000..2f3984274f33 --- /dev/null +++ b/scripting/examples/javascript/Highlight/ShowDialog.js @@ -0,0 +1,45 @@ +importClass(Packages.com.sun.star.uno.UnoRuntime); +importClass(Packages.com.sun.star.lang.XMultiComponentFactory); +importClass(Packages.com.sun.star.awt.XDialogProvider); +importClass(Packages.com.sun.star.awt.XDialog); +importClass(Packages.com.sun.star.uno.Exception); +importClass(Packages.drafts.com.sun.star.script.provider.XScriptContext); + +importClass(java.lang.Thread); +importClass(java.lang.System); + +function getDialogProvider() +{ + // UNO awt components of the Highlight dialog + xmcf = XSCRIPTCONTEXT.getComponentContext().getServiceManager(); + + args = new Array; + args[0] = XSCRIPTCONTEXT.getDocument(); + + try { + obj = xmcf.createInstanceWithArgumentsAndContext( + "com.sun.star.awt.DialogProvider", args, + XSCRIPTCONTEXT.getComponentContext()); + } + catch (e) { + System.err.println("Error getting DialogProvider object"); + return null; + } + + return UnoRuntime.queryInterface(XDialogProvider, obj); +} + +xDialogProvider = getDialogProvider(); + +if (xDialogProvider != null) +{ + try { + findDialog = xDialogProvider.createDialog("vnd.sun.star.script:" + + "ScriptBindingLibrary.Highlight?location=application"); + findDialog.execute(); + } + catch (e) { + System.err.println("Got exception on first creating dialog: " + + e.getMessage()); + } +} -- cgit