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.
This commit is contained in:
45
scripting/examples/javascript/Highlight/ShowDialog.js
Normal file
45
scripting/examples/javascript/Highlight/ShowDialog.js
Normal file
@@ -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());
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user