[Calc][Python] Addin inconsistency with string array on LibO

Creating a macro - Writing a Script - Using the API

[Calc][Python] Addin inconsistency with string array on LibO

Postby hubert lambert » Mon Jun 13, 2016 11:19 am

Hello,

I’m working on a Calc addin written in python and dealing with arrays of strings. This addin works fine under OpenOffice. It seems to work the same on LibreOffice, but when I test equality between the strings returned by the addin function, I get always “FALSE”, even when it is as obvious as
Code: Select all   Expand viewCollapse view
=MYFUNCTION(“abc”) = MYFUNCTION(“abc”)
The issue occurs only under LibreOffice, both on Windows and Linux systems. There's no issue when the idl definition returns a single string instead of an array of strings.

I’ve built a minimal addin for test, with a PYSTRINGTEST function that simply returns a string argument unmodified. The idl is
Code: Select all   Expand viewCollapse view
#include <com/sun/star/uno/XInterface.idl>

module org { module pystrings { module pystringtest {

    interface XPyStringTest
    {
        sequence< sequence< string > > pystringtest( [in] sequence< sequence< string > > teststring);
    };

}; }; };

The python code is
Code: Select all   Expand viewCollapse view
    def pystringtest(self, teststring):
        s = teststring
        return s

Could anyone figure out where I’m wrong ?
A big thanks for any help...
Attachments
pystringtest.oxt
(3.29 KiB) Downloaded 62 times
AOOo 4.1.2 on Win7 | LibreOffice on various Linux systems
hubert lambert
 
Posts: 129
Joined: Mon Jun 13, 2016 10:50 am

Re: [Calc][Python] Addin inconsistency with string array on

Postby Villeroy » Mon Jun 13, 2016 12:51 pm

Your function returns a string. It is supposed to return an array of strings.
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04, no OpenOffice, LibreOffice 6.x
User avatar
Villeroy
Volunteer
 
Posts: 26975
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: [Calc][Python] Addin inconsistency with string array on

Postby hubert lambert » Mon Jun 13, 2016 4:45 pm

Thanks for your interest.
It does return an array, but if you pass a single string as argument, it is received as an array of a single row of a single column, and returned the same way.
Try a cell range. For example if you have strings in A1:A2, enter (ctrl+shift+enter) :
Code: Select all   Expand viewCollapse view
=PYSTRINGTEST(A1:A2)


 Edit: Added an example spreadsheet 
Attachments
pystringtest_example.ods
needs previous installation of above extension
(8.33 KiB) Downloaded 48 times
AOOo 4.1.2 on Win7 | LibreOffice on various Linux systems
hubert lambert
 
Posts: 129
Joined: Mon Jun 13, 2016 10:50 am


Return to Macros and UNO API

Who is online

Users browsing this forum: No registered users and 7 guests