| View previous topic :: View next topic |
| Author |
Message |
ffigarol Newbie

Joined: 26 Feb 2006 Posts: 3
|
Posted: Sun Feb 26, 2006 1:48 pm Post subject: calling OOBasic macro from java |
|
|
Well, its possible to run java from oobasic, but what about the contrary ?
I am not sure its usefull but, when you have already done some coding in oobasic, you might want to use it and continue with something else in Java, at least for a while.
Thanks for your help, beacause i am stuck at this point |
|
| Back to top |
|
 |
hol.sten Super User


Joined: 14 Nov 2004 Posts: 3532 Location: Hamburg, Germany
|
|
| Back to top |
|
 |
ffigarol Newbie

Joined: 26 Feb 2006 Posts: 3
|
Posted: Tue Feb 28, 2006 10:50 am Post subject: |
|
|
Thanks a lot, these are the inforamtions I was looiing for. I 'll do some test soon, normally tomorow.
regards,
ffigarol |
|
| Back to top |
|
 |
ffigarol Newbie

Joined: 26 Feb 2006 Posts: 3
|
Posted: Fri Mar 17, 2006 8:51 am Post subject: |
|
|
Hello again. Sorry it took me so long to reply. I was very busy. I finally found a good answer to my problem.
I gave up with the dispatch framework, that was apparently the only solution avaialable for OO1.1.x
And move on to hte very nice new script framework available with OO.2.x
The code (addapted from hol.sten urls above from the old framework to the new script fworks) works fine and looks like this :
Saysomething is a simple basic macro taht takes only one parameter of type string (the java String a="Hi")
The macro must be application wide, for instance in the "My Macros" folder :
| Code: | // ----- Trying with the new script framework") ----- */
// retrieve the current component and access the controller
XComponent xCurrentComponent = xDesktop.getCurrentComponent();
XModel xDocModel = (XModel)UnoRuntime.queryInterface(XModel.class, xCurrentComponent);
// geting a masterscript factory and a script provider
Object oMSPFac = mxRemoteServiceManager.createInstanceWithContext( "com.sun.star.script.provider.MasterScriptProviderFactory", mxRemoteContext);
XScriptProviderFactory xScriptProviderFactory = (XScriptProviderFactory) UnoRuntime.queryInterface(XScriptProviderFactory.class, oMSPFac);
Object oMSP = xScriptProviderFactory.createScriptProvider("");
XScriptProvider xScriptProvider = (XScriptProvider) UnoRuntime.queryInterface(XScriptProvider.class, oMSP);
// getting the script (same command string than used in OpenOffice to link for isntance a buton action to a given macro)
XScript myScript = xScriptProvider.getScript("vnd.sun.star.script:Standard.Module1.SaySomething?language=Basic&location=application");
// building all parameters : objects arrays, etc
String a;
a="Hi";
Object[] objectArray = {a};
short[][] s = { {0,0}, {0,0}};
Object b;
b = null;
Object[][] object0 = { {b,b},{b,b}};
// at last launching the script and getting the result (which is quite a nice feature too, even if i do not do much with it so far)
Object result = myScript.invoke( objectArray, s, object0); |
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|