saleem145 wrote:Hello,
Stuck again!!
How do I pass in an array of strings as an input to one of my functions??
Specifically what should the function prototype be and what goes into the idl. I tried using Sequence< OUString const & > with no luck.
Thanks a ton for your help!!
Saleem
I hadn't tried this yet, so it gave me a chance to learn something.
Once again, add-in functions use two dimensional arrays, but that presents no problem because we can just have a two dimensional array with one column.
I made a function that accepts an array of strings (assuming one column), then reverses each string and returns the reversed array. In the idl it looks like
Code: Select all
sequence< sequence< string > > reversestrings([in] sequence< sequence< string > > inString);
Now, after compiling the .idl, and generating the .rdb and the c++ headers, we find that in the header file that the function prototype does expect OUStrings, so our function looks like
Code: Select all
Sequence <Sequence< OUString >> SAL_CALL MyService1Impl::reversestrings(Sequence <Sequence< OUString >> const & inString )
throw (RuntimeException)
{
long n = inString.getLength();
long i;
Sequence <Sequence< OUString >> reversedstrings(n);
for(i = 0;i < n;i++)
{
reversedstrings[i] = Sequence<OUString>(1);
reversedstrings[i][0] = oureverse(inString[i][0]);
}
return reversedstrings;
}
Where to teach a bit about manipulating OUStrings, we reverse them with
Code: Select all
OUString oureverse(OUString s)
{
OUString r;
r = OUString();
long i;
for(i = s.getLength() - 1;i >= 0; i--)
{
r += OUString(s[i]);
}
return r;
}
I think you can handle the CalcAddin.xcu and such.