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

Call a Beanshell function from Basic - how? a solution!

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


Joined: 18 Jan 2005
Posts: 4
Location: Nemours France

PostPosted: Fri Jan 21, 2005 2:00 am    Post subject: Call a Beanshell function from Basic - how? a solution! Reply with quote

Hi,

I use OpenOffice2 and I write my macros in OpenOffice.org Basic.
It's very simple but the speed is not good.
So I want transform some functions to Java or Beanshell functions but I didn't known how to call those new functions from Basic

For Java, I think something like that :
Code:
oModule = createUnoService("daiyam.Module1")
oModule.function1()

But I don't known which super class I need to extend.

For BeanShell, I have no ideas

Can someone help me?
Thanks

Regards,
Daiyam


Last edited by Daiyam on Mon Jan 24, 2005 4:12 pm; edited 1 time in total
Back to top
View user's profile Send private message
pitonyak
Administrator
Administrator


Joined: 09 Mar 2004
Posts: 3655
Location: Columbus, Ohio, USA

PostPosted: Fri Jan 21, 2005 7:05 pm    Post subject: Reply with quote

Worst case, you can create a little plugin and then call that from Basic...
_________________
--
Andrew Pitonyak
http://www.pitonyak.org/oo.php
Back to top
View user's profile Send private message Send e-mail Visit poster's website AIM Address
SergeM
Super User
Super User


Joined: 09 Sep 2003
Posts: 3211
Location: Troyes France

PostPosted: Mon Jan 24, 2005 9:07 am    Post subject: Reply with quote

Be careful with speed. Befor I program in UNO/C++, I though C++ will work quicker than Basic. But I think it's not the case in many applications. OOoBasic access directly the API. C++ have to connect through a socket and I think it's the same with Java. Evry API call is time consuming in Java.
_________________
Linux & Windows OOo3.0
UNO & C++ : WIKI
http://wiki.services.openoffice.org/wiki/Using_Cpp_with_the_OOo_SDK
In French
http://wiki.services.openoffice.org/wiki/Documentation/FR/Cpp_Guide
Back to top
View user's profile Send private message Visit poster's website
Daiyam
Newbie
Newbie


Joined: 18 Jan 2005
Posts: 4
Location: Nemours France

PostPosted: Mon Jan 24, 2005 4:08 pm    Post subject: Reply with quote

Basic is a good and easy language but for the array, i don't like the syntax and the speed is not good! And I work with a lot of arrays.

I found a tempory solution working with OOo 1.9.69.

In Basic :
I can call a beanshell script with :
Code:
oResult = CallBeanShellScript("Library1.Macro1", Array("toto", 145))

CallBeanShellScript Function :
Code:
Function CallBeanShellScript(sName, arguments())
   oScriptProvider = ThisComponent.getScriptProvider()
   oScript = oScriptProvider.getScript("vnd.sun.star.script:"+sName+".bsh?language=BeanShell&location=document")
   CallBeanShellScript = oScript.invoke(arguments(), Array(), Array())
End Function

I set the location to document because when it's share, there is an error!

The beanshell script must start with :
Quote:
if(ARGUMENTS.length == 0) {
return 0;
}

It's seems the script is called firstly with no arguments and secondly with the goods arguments.

With beanshell you can return anything!

It's a good solution but with a lot of limitations!
Back to top
View user's profile Send private message
SergeM
Super User
Super User


Joined: 09 Sep 2003
Posts: 3211
Location: Troyes France

PostPosted: Tue Jan 25, 2005 6:37 am    Post subject: Reply with quote

Quote:
It's a good solution but with a lot of limitations!

And is it quicker than OOoBasic alone ?
_________________
Linux & Windows OOo3.0
UNO & C++ : WIKI
http://wiki.services.openoffice.org/wiki/Using_Cpp_with_the_OOo_SDK
In French
http://wiki.services.openoffice.org/wiki/Documentation/FR/Cpp_Guide
Back to top
View user's profile Send private message Visit poster's website
Daiyam
Newbie
Newbie


Joined: 18 Jan 2005
Posts: 4
Location: Nemours France

PostPosted: Tue Jan 25, 2005 7:03 am    Post subject: Reply with quote

I'm in a very special case (I split a string to a sorted array).
For the same result :
- in Basic, it's take 4-5 hours Shocked
- in Beanshell, it's just 5-10 minutes Razz

It's a huge difference because I didn't use the same functions.
In Beanshell, I can use System.arraycopy and I didn't found a function like that in Basic Sad
Back to top
View user's profile Send private message
SergeM
Super User
Super User


Joined: 09 Sep 2003
Posts: 3211
Location: Troyes France

PostPosted: Wed Jan 26, 2005 11:57 am    Post subject: Reply with quote

Effectively a big difference...
_________________
Linux & Windows OOo3.0
UNO & C++ : WIKI
http://wiki.services.openoffice.org/wiki/Using_Cpp_with_the_OOo_SDK
In French
http://wiki.services.openoffice.org/wiki/Documentation/FR/Cpp_Guide
Back to top
View user's profile Send private message Visit poster's website
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