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

Creating a macro - Writing a Script - Using the API (OpenOffice Basic, Python, BeanShell, JavaScript)
Post Reply
hubert lambert
Posts: 145
Joined: Mon Jun 13, 2016 10:50 am

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

Post 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...
Attachments
pystringtest.oxt
(3.29 KiB) Downloaded 304 times
AOOo 4.1.2 on Win7 | LibreOffice on various Linux systems
User avatar
Villeroy
Volunteer
Posts: 31363
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

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

Post by Villeroy »

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 with LibreOffice 6.0, latest OpenOffice and LibreOffice
hubert lambert
Posts: 145
Joined: Mon Jun 13, 2016 10:50 am

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

Post 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 
Attachments
pystringtest_example.ods
needs previous installation of above extension
(8.33 KiB) Downloaded 297 times
AOOo 4.1.2 on Win7 | LibreOffice on various Linux systems
mikekaganski
Posts: 14
Joined: Mon Oct 30, 2017 12:39 pm

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

Post by mikekaganski »

This is a regression in LibreOffice 5.4; it worked OK in 5.3. Filed tdf#150926.
LibreOffice 7.6 on Windows 10
User avatar
Zizi64
Volunteer
Posts: 11505
Joined: Wed May 26, 2010 7:55 am
Location: Budapest, Hungary

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

Post 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?
Tibor Kovacs, Hungary; LO7.5.8/25.8.5.2 /Win7-10-11 x64Prof.
PortableApps: LO3.3.0-25.8.5.2;AOO4.1.14
Please, edit the initial post in the topic: add the word [Solved] at the beginning of the subject line - if your problem has been solved.
mikekaganski
Posts: 14
Joined: Mon Oct 30, 2017 12:39 pm

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

Post 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.
LibreOffice 7.6 on Windows 10
User avatar
karolus
Volunteer
Posts: 1242
Joined: Sat Jul 02, 2011 9:47 am

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

Post 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.
Libreoffice 25.2… on Debian 13 (trixie) (on RaspberryPI5)
Libreoffice 25.8… flatpak on Debian 13 (trixie) (on RaspberryPI5)
User avatar
Zizi64
Volunteer
Posts: 11505
Joined: Wed May 26, 2010 7:55 am
Location: Budapest, Hungary

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

Post by Zizi64 »

mikekaganski, karolus: thank you. I will trying...
Tibor Kovacs, Hungary; LO7.5.8/25.8.5.2 /Win7-10-11 x64Prof.
PortableApps: LO3.3.0-25.8.5.2;AOO4.1.14
Please, edit the initial post in the topic: add the word [Solved] at the beginning of the subject line - if your problem has been solved.
Post Reply