Page 1 of 1

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

Posted: Mon Jun 13, 2016 11:19 am
by hubert lambert
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

=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

#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

    def pystringtest(self, teststring):
        s = teststring
        return s
Could anyone figure out where I’m wrong ?
A big thanks for any help...

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

Posted: Mon Jun 13, 2016 12:51 pm
by Villeroy
Your function returns a string. It is supposed to return an array of strings.

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

Posted: Mon Jun 13, 2016 4:45 pm
by hubert lambert
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

=PYSTRINGTEST(A1:A2)
 Edit: Added an example spreadsheet 

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

Posted: Tue Sep 13, 2022 11:59 am
by mikekaganski
This is a regression in LibreOffice 5.4; it worked OK in 5.3. Filed tdf#150926.

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

Posted: Wed Sep 14, 2022 7:49 am
by Zizi64
Sorry for the littlebit offtopic question:
pystringtest.oxt
I just studied the code lines in the embedded files in the sample .oxt.

I never created Python Add-in, but I want to make something similar.
Everything is clear (will be clear) for me in the code, except the .rdb file.
I can edit (modify) all of the files with the Geany text (code) editor software, except the .rdb file, because its content seems a compiled(?) code

How to create that .rdb file? It must recreate, when I modify something in the other files?

What is its function in the extension?

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

Posted: Wed Sep 14, 2022 8:07 am
by mikekaganski
Zizi64 wrote: Wed Sep 14, 2022 7:49 am How to create that .rdb file?
What is its function in the extension?
Please search for "rdb" in https://wiki.documentfoundation.org/Doc ... Components.

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

Posted: Thu Sep 15, 2022 9:49 am
by karolus
Hallo
How to create that .rdb file? It must recreate, when I modify something in the other files?
It needs to be compiled from the .idl file (see ./source-folder)
the .idl-file defines how calc should pass arguments and return-values to|from the function.

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

Posted: Thu Sep 15, 2022 9:51 am
by Zizi64
mikekaganski, karolus: thank you. I will trying...