Quantcast
Channel: Apache OpenOffice Community Forum
Viewing all articles
Browse latest Browse all 1281

Macros and UNO API • Button forgets macros after file save python, basic Calc

$
0
0
Howdy,

Problem:

I created a new calc file, a new script, and bound a button to the script. It worked. Yay! If I save-close the file, and reopen it, the button no longer finds the script. This is true not only of script I write, but also of the included helloworld scripts (in both python and basic). After I re-open the file, If I check in control-properties for the button, the binding is still present, and I can also manually run the macro using:

Code:

Tools->Macros->RunMacro
I started Calc thusly to see if I could get some more info:

Code:

urxvt -e $XOFFICEPATH/scalc -env:PYSCRIPT_LOG_LEVEL=DEBUG --nologo --nofirststartwizard --norestore --accept="socket,host=localhost,port=2002;urp;StarOffice.ServiceManager" & 
When I run the script manually, the debug output shows it running. When the file is new (never closed and re-opened) I see exactly the same thing when I press the button. However after closing the file and re-opening it, the debug shows nothing at all when I click the button. The button doesn't even seem to be looking for binding.

I have tried playing with APSO. No change. I have embedded the script. No change. I have backed my JRE down from openjre 24 to openjre 17 and 11. No change.

The problem seems to be in whatever code dispatches the script, but I have no visibility into that code, and it isn't showing anything useful. Can I get a debug of what the button is doing when I click it?

The code is as follows, but seems irrelevant, since it runs. It just doesn't run a button for some reason.

Code:

from __future__ import unicode_literalsimport sysimport socketimport operatorimport reimport unoimport unohelperdef button_foo1(*args):        self=FOO()      # get the instance handle        self.importuno()        # run the methods        thisclass = str(self.__class__)        self.helloworld(thisclass)         return Trueclass FOO():        def importuno(self):                 self.ctx = uno.getComponentContext()                self.desktop = self.ctx.ServiceManager.createInstanceWithContext("com.sun.star.frame.Desktop", self.ctx)                 self.document = self.desktop.getCurrentComponent()                self.controller = self.document.getCurrentController()        def helloworld(self,hellostr):                 sheet = self.controller.ActiveSheet                cellc3 = sheet.getCellRangeByName("C3")                cellc3.String = hellostr                

I am using:

LibreOffice 24.2.2.2 420(Build:2)
OpenJDK Runtime Environment (build 11.0.22+6-void-r1)
VOID Linux 6.6.25 MUSL


Thanks in advance!

Statistics: Posted by puppyledger — Wed May 01, 2024 12:11 am



Viewing all articles
Browse latest Browse all 1281

Trending Articles