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
[Solved] How to pass in a 1D array of strings into cpp addin
[Solved] How to pass in a 1D array of strings into cpp addin
Last edited by saleem145 on Sun Jul 15, 2012 1:53 pm, edited 2 times in total.
OpenOffice 3.4.0
Mac OS X 10.5.8
Mac OS X 10.5.8
- Charlie Young
- Volunteer
- Posts: 1559
- Joined: Fri May 14, 2010 1:07 am
Re: How to pass in a 1D array of strings into cpp addin
I hadn't tried this yet, so it gave me a chance to learn something.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
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);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;
}
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;
}
Apache OpenOffice 4.1.1
Windows XP
Windows XP