OO-Snippets: How to call Java Program Using Scripting Framework

Commons

KeywordsScripting, Framework
LanguageJava
ApplicationOffice
Authors
Supported Versions2.0.x  
Supported OSAll  
Question
Answer

Code-Snippet-Listing (snippet-source)

XMultiComponentFactory xMultiComponentFactory = connection.getComponentContext() .getServiceManager();

Object oMSPFac =xMultiComponentFactory.createInstanceWithContext("com.sun.star.script.provider.MasterScriptProviderFactory",connection.getComponentContext() );
XScriptProviderFactory xScriptProviderFactory = (XScriptProviderFactory ) UnoRuntime.queryInterface(
XScriptProviderFactory.class, oMSPFac );

Object oMSP = xScriptProviderFactory.createScriptProvider(document  );
XScriptProvider xScriptProvider = ( XScriptProvider ) UnoRuntime.queryInterface( XScriptProvider.class, oMSP);

XScript myScript = xScriptProvider.getScript("vnd.sun.star.script:HelloWorld.HelloWorld.printHW?language=Java&location=share");

// building all parameters : objects arrays, etc
String a;
a = "** Hi ***"; //$NON-NLS-1$
Object[] objectArray = { a };
short[][] s = { { 0, 0 }, { 0, 0 } };
Object nullObject;
nullObject = null;
Object[][] object0 = { { nullObject, nullObject }, {nullObject, nullObject } };

Object result = myScript.invoke( objectArray, s,object0 );

Changelog

DateUserModification

and