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

Passing arrays from OOBasic to C++ Uno Components

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


Joined: 21 Oct 2006
Posts: 49

PostPosted: Sat Dec 23, 2006 8:42 am    Post subject: Passing arrays from OOBasic to C++ Uno Components Reply with quote

..How can I pass an array from an OOBasic macro to an UNO component I have written in C++ ?

Cheers
Back to top
View user's profile Send private message
Ninds
General User
General User


Joined: 21 Oct 2006
Posts: 49

PostPosted: Sat Dec 23, 2006 8:55 am    Post subject: Reply with quote

..... ok so they are just UNO Sequences ..
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: Sat Dec 23, 2006 9:16 am    Post subject: Reply with quote

See :
Complete AddIn http://wiki.services.openoffice.org/wiki/CompleteAddIn
_________________
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
Ninds
General User
General User


Joined: 21 Oct 2006
Posts: 49

PostPosted: Sat Dec 23, 2006 9:27 am    Post subject: Reply with quote

The problem I am having is returning a Sequence<Sequence<double> > back to Basic fom C++

Sequence<double> I have no problem with


I have looked at
Transforming an Array into Sequence of Sequence
in that link .. but it doesn't seem to work for me
Back to top
View user's profile Send private message
Ninds
General User
General User


Joined: 21 Oct 2006
Posts: 49

PostPosted: Sat Dec 23, 2006 12:48 pm    Post subject: Reply with quote

YES !!!! Figured it out.
I wanted to pass back 2D double arrays FROM C++ to Basic (the other way was not a problem)

I first tried this code
Code:


Sequence<Sequence<double> > foo() {
                          Sequence<Sequence<double> > theMatrix(2);
                          theMatrix[0].realloc(2);
                          theMatrix[1].realloc(2);
                          theMatrix[0][0] = 0;
                          theMatrix[0][1] = 1;
                          theMatrix[1][0] = 2;
                          theMatrix[1][1] = 3;
                          return theMatrix;
}


I just could not use the returned object in BASIC like a 2D array.

But with the following code I could .

Code:


Sequence<Any> foo() {
                          Sequence<Any> theMatrix(2);
                          Sequence<double> row0(2);
                          Sequence<double> row1(2);
                          row0[0] = 0;
                          row0[1] = 1;
                          row1[0] = 2;
                          row1[1] = 3;
                          theMatrix[0]=row1;
                          theMatrix[1]=row2
                          return theMatrix;
}


Its not ideal by any means, but its works, the returned object behaves like a 2D array.

[/code]
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: Mon Dec 25, 2006 6:58 am    Post subject: Reply with quote

See also :
Interfacing GSL with an add-in (C++) http://www.oooforum.org/forum/viewtopic.phtml?t=31232
_________________
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
Ninds
General User
General User


Joined: 21 Oct 2006
Posts: 49

PostPosted: Tue Dec 26, 2006 1:59 am    Post subject: Reply with quote

I had already looked at the references you give, however they do not address my problem
I am comfortable using Sequences and Sequences of Sequences for 2D arrays, but I cannot pass back a 2D array TO OOBAsic from a UNO component.
Back to top
View user's profile Send private message
Ninds
General User
General User


Joined: 21 Oct 2006
Posts: 49

PostPosted: Tue Dec 26, 2006 3:23 am    Post subject: Reply with quote

Does anyone know

1) what SbxArray is ?
2.) is it is the OOBasic Array how do use it in code ?
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 Dec 26, 2006 6:38 am    Post subject: Reply with quote

Quote:
I had already looked at the references you give, however they do not address my problem

Yes, of course I never go further with using a add-in function with OOoBasic. Perhaps later ...
_________________
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
Ninds
General User
General User


Joined: 21 Oct 2006
Posts: 49

PostPosted: Tue Dec 26, 2006 7:13 am    Post subject: Reply with quote

sure ..... but what if you have an addin function that is also callable from Basic, and it returns a 2-dimensional array of double .. how do u do that .

For example

Code:

Sequence<Sequence<double> > Identity(sal_uInt size) {
             Sequence<Sequence<double> > theIdentity(size);
             
             for (unsigned long i(0);i<size;++i)
                 {
                     theIdentity.realloc(size);
                     theIdentity[i][i] = 1.0;
                     for(unsigned long j(0);j<i;++j)
                         {
                             theIdentity[i][j] = 0.0;
                         }
                  }
              return theIdentity;
}



I think its important to be able to call addin functions from Basic. I can do this in Excel, it allows the user of the addin to wrap the functions as she needs to , if she needs to .
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 Dec 26, 2006 10:19 am    Post subject: Reply with quote

Quote:
I think its important to be able to call addin functions from Basic

I think too but I have not worked around addin for a long time. With a recent thread cannot createUnoService in OOBasic of Calc Addin http://www.oooforum.org/forum/viewtopic.phtml?t=50721 I fear it is not so easy as we can think at first. (I have no answer and no time to investigate)
_________________
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
Ninds
General User
General User


Joined: 21 Oct 2006
Posts: 49

PostPosted: Tue Dec 26, 2006 12:04 pm    Post subject: Reply with quote

To be specific, making Addin functions callable from OOBasic is not difficult. A neccessary and sufficient condition is that the UNO component inherits from XService ( I think thats actualy stated in one your documents on Wikipedia). The problem is the choice of types for return values from these functions is unneccessarily restrictive.

I have been working on derivative pricing models implemeneted in C++ Monte Carlo engines. I have been developing the OOCalc and Excel interface to these models simultaneously, and have found a massive difference in the ease with which to carry out this task. I am a real Opensource convert , but have to say from my persepective and for my requirements OOCalc is not JUST behind Excel, but unbelieveably inferior.
It almost appears that the OOCalc developers have not spent even one second consdiering the user needs. Sure of course, the UNO technology may seem flashy and very clever, but its completely useless to me. My needs, and they are not so specialised are just not met by OOCalc.

I simply want
1. A spreadsheet package for which its is EASY to build addins.
For excel I used to use the opensource 'xlw' library, it was VERY easy to use.
Then I taught myself enough COM to build COM addins in a about one and a half days, with a further half day to learn about VARIANTS and SAFEARRAYS. After only two days I was able to build addin for excel which I could use VERY easily in VBA AND Excel.
In OOCalc its taken MUCH MUCH longer, its been 'notoriously' difficult to build addins.

2. Why is it SO convoluted to bring up the Basic editor.

3. If I have a function returning an array in OOCalc, why can't I just select a bigger range of cells over the cells where the function is already calculated to increase the size of the range.

4. If I have function returning an array in OOCalc, why can't I just select ONE cell from that range to re-calculate.

5. If I have a function written in Basic and call it from the spread sheet, why won't it re-calculate when i edit that function and press F9.

6. Why isn't there a Shift-F9

I think I am going to HAVE TO give up on OOCalc soon, I just don't have the time to spend on developement that is not the core of my project.
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: Thu Dec 28, 2006 4:29 am    Post subject: Reply with quote

Quote:
I think I am going to HAVE TO give up on OOCalc soon, I just don't have the time to spend on developement that is not the core of my project.

If you have working code you can post it in "code snippets forum". Don't forget also that wiki can be edited by everybody (if registered). You can add an example and add also your name in the contributor page... It's for such evolution I take a long time to put my documentation in wiki.
_________________
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
Ninds
General User
General User


Joined: 21 Oct 2006
Posts: 49

PostPosted: Fri Dec 29, 2006 4:20 pm    Post subject: Reply with quote

From
[url] http://api.openoffice.org/docs/common/ref/com/sun/star/script/ArrayWrapper.html#Array [/url]

Code:
Description
Allows an UNO sequence that is passed between different language boundries to indicate it prefers to be represented as a multidimensional array with 0 or 1 based indices. UNO does not natively represent Multi-Dimensional arrays, instead a sequence can have elements that are themselves sequences (an array of arrays ).
Some languages ( example BASIC ) can natively represent both Multi-Dimentional arrays and array of arrays. Those languages could represent a sequence of sequences as either a Multi-Dimentional array or array of arrays. This structure allows a preference for a Multi-Dimensional array representation to be specified.
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