OpenOffice.org Forum at OOoForum.orgThe OpenOffice.org Forum
 
 [Home]   [FAQ]   [Search]   [Memberlist]   [Usergroups]   [Register
 [Profile]   [Log in to check your private messages]   [Log in

calling OOBasic macro from java

 
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Macros and API
View previous topic :: View next topic  
Author Message
ffigarol
Newbie
Newbie


Joined: 26 Feb 2006
Posts: 3

PostPosted: Sun Feb 26, 2006 1:48 pm    Post subject: calling OOBasic macro from java Reply with quote

Question Well, its possible to run java from oobasic, but what about the contrary ? Question

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
View user's profile Send private message
hol.sten
Super User
Super User


Joined: 14 Nov 2004
Posts: 3532
Location: Hamburg, Germany

PostPosted: Sun Feb 26, 2006 11:06 pm    Post subject: Re: calling OOBasic macro from java Reply with quote

ffigarol wrote:
Question Well, its possible to run java from oobasic, but what about the contrary ? Question

Try this links for example:
- http://www.oooforum.org/forum/viewtopic.phtml?t=25757&highlight=xray+java
- http://www.oooforum.org/forum/viewtopic.phtml?t=31923&highlight=xray+java

With kind regards
hol.sten
Back to top
View user's profile Send private message
ffigarol
Newbie
Newbie


Joined: 26 Feb 2006
Posts: 3

PostPosted: Tue Feb 28, 2006 10:50 am    Post subject: Reply with quote

Thanks a lot, these are the inforamtions I was looiing for. I 'll do some test soon, normally tomorow.

regards,

ffigarol
Back to top
View user's profile Send private message
ffigarol
Newbie
Newbie


Joined: 26 Feb 2006
Posts: 3

PostPosted: Fri Mar 17, 2006 8:51 am    Post subject: Reply with quote

Cool 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
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Macros and API All times are GMT - 8 Hours
Page 1 of 1

 
Jump to:  
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