Accessing active listeners programmatically

Hello everyone,

Is there a method of accessing activated listeners programmatically, other than defining the variable as global?

If I start a listener and walk away from a computer for an extended period of time, allowing for it to “sleep”, the listeners are still active once I reactivate the desktop. However, subsequently when I try to run the subroutine to disable the listener, it does not . The only solution I have at this point is to simply reload Calc.

Thank you in advance for any information or workaround suggestions.

Hello,
(Sorry - do not like editing on this site)
.

It may be possible but I do not have that information. Do remember doing something different but it was in using Python.
.
Not certain you are aware of this, but you can install a listener multiple times and then when using a global object, it will not stop. Do not have answer to fix or why to this happening. Just check your code to see if somehow it is being started more than once.

1 Like

Not certain you are aware of this, but you can install a listener multiple times and then when using a global object, it will not stop.

I was aware of this, but in this case it’s the complete opposite. The listener STILL works, after the computer has resumed from its “sleep” mode. I’d like to be able to disable that listener.

Just check your code to see if somehow it is being started more than once.

That I am certain of, as I invoked that listener manually. There is no automation created that would run this command twice.

Not an answer but clarification.
Your problem and my test are the same. The listener still works but cannot be stopped. In my case I did start manually also but just did the install twice.
.
I imagine (as it works for me) stopping the listener before sleeping works.
.
My concern for you is what is sleep doing to the listener?

I was thinking precisely the same; stop the listener before the machine goes to “sleep”. I’m looking for a listener that could broadcast an event like this, and shut down all active listeners.

I imagine that it could be possible to do in fully developed coding language such as Python or JavaScript. But I do not know either one yet. I am actually planning on learning JavaScript, as yet another program that I would like to automate (QCAD) has scripting capability in that language.

@marus_b
Could not get sleep to work on my computer. It was a hardware issue and now works.
.
Tested in Linux Ubuntu 20.04.4 using Suspend. No problem with the listener. When OS resumed, the listener was still working AND could stop the Listener without issue.
.
With Win10 there was the same result. First test was to manually put to sleep. No issue when awakened. Next let it go to sleep on its’ own - also no issue.
.
Not certain where your problem lies.
.
Edit:
The listener I tested with was com.sun.star.util.XModifyListener for a specific cell. Which are you using?

1 Like

@Ratslinger Thank you for looking into this.

The listener I was using was com.sun.star.view.XSelectionChangeListener invoked from com.sun.star.sheet.Spreadsheetview.

I’m going to test it some more over the weekend, when I get a little bit of free time. As a matter of fact I’ll try the XModifyListener for a specific cell as well, so that we are comparing apples to apples. For now, unfortunately I have to abide by house rules, otherwise I may end up being a subject of a selection change myself ;-).

Nevertheless, I noticed this already on several occasions in the last few weeks. It was consistently the same type of behavior; once I walked away for an extended period of time and then came back to a computer in suspended state, the listener still worked after “waking it back up” and logging back in, but I could not address the global variable when attempting to disable it. Whereas, otherwise I could engage it and disengage it as I pleased.

My current configuration is as follows:

Version: 7.3.0.3 (x64) / LibreOffice Community
Build ID: 0f246aa12d0eee4a0f7adcefbf7c878fc2238db3
CPU threads: 16; OS: Windows 10.0 Build 22000; UI render: Skia/Raster; VCL: win
Locale: en-CA (en_CA); UI: en-US
Calc: threaded

@marus_b
Did test XSelectionChangeListener and also mouse listener (sample from this post > https://ask.libreoffice.org/t/calc-sheet-selection-change-event-and-mouse/73623) on both Ubuntu 20 and Win10. Was able to shut down each listener after system was awaken from sleep.
On Win10 used LO:

Version: 7.2.5.2 (x64) / LibreOffice Community
Build ID: 499f9727c189e6ef3471021d6132d4c694f357e5
CPU threads: 8; OS: Windows 10.0 Build 19044; UI render: default; VCL: win
Locale: en-US (en_US); UI: en-US
Calc: threaded

A bit older LO version. Notice no Skia, and Win10 is a bit different from yours.
.
Again, not certain where your problem may be except that I know it is not easy to work with the SelectionChangeListener.

@Ratslinger

I opened up a completely new file and coded both: XSelectionChangeListener and XModifyListener (bound to a cell). They both work, just like you have said. I tested them with putting the computer to sleep and to hibernate and absolutely no problem. I attempted declaring the broadcaster as a local file and as a global one, no difference. Maybe it was an issue with the previous file itself. Once again, thank you for looking into this.