Calc Re-calculation Listener - does such a thing exist?

I am working on an extension I it would be very helpful if the extension could be notified when a re-calculation has been triggered.

Is this possible? Is there a listener for when a sheet calculation is taking place?

There are Sheet Events,
SheetEvents

and Document events…


.
They are not enough for your task?

Thank you, this is close to what I am looking for. I have been digging around an I can not find where to attach an event in code.


I wrote the Calc Sheet Activation Event Example for sheet activation events. Which is done by adding a XActivationEventListener via addActivationEventListener() to the SpreadsheetView


I am not able to find how to listen for calculation events in a similar manor without attaching a macro to the sheet events. Any ideas on this?

The “Formulas calculated” is the onCalculate sheet event. This How to set a macro to an sheet-event by a macro - #2 by PYS illustrates how a sheet event script can be set, the sheet’s Events (in BASIC, or getEvents()) exports a css::container::XNameReplace interface at which replaceByName() is used to set a sheet event. It should be possible to adapt the Script property’s value vnd.sun.star.script:... to use the Python routine and language=Python&location=user or similar.

This is a reasonalbe solution for macros in a document but not a good solution for an extension. I am working on an extension so I will have to hook the event without attaching via the XNamedReplace interface; Otherwise, the event could be replaced by another macro down the road.

But this is a common danger.
A skilled programmer must remember someone else’s event listener and call it after his own listener (or before, depending on his upbringing). :slightly_smiling_face: