[Basic][Calc] Listener on renaming/moving sheets


Is there a good way to call a macro whenever a sheet is added, deleted, renamed or moved ? So far, the best solution I have seen (in this topic Listener for a spreadsheet rename event (View topic) • Apache OpenOffice Community Forum) is to set a UndoManagerListener and to check the name of the newly added undo action. But this listener fires many useless events for this situation.

An other approach would be to replace the menu item by a custom macro who does the same action (eg. : remove a sheet), plus whatever we want to do. But this does not work for every situation, for example if I move a sheet manually without using the menu.

Does anybody know of a good solution ? Why is it not possible to simply set a XModifyListener on ThisComponent.Sheets (or more precisely, is there a reason why the service Spreadsheets does not export this interface) ? Or why a XPropertyChangeListener cannot be set to a property without the “bound” attribute ?