Apache OpenOffice (AOO) Bugzilla – Issue 69205
XModifyListener for cells in one sheet works when removing other sheet
Last modified: 2023-03-19 09:58:52 UTC
Hello, I use an "XModifyListener" for detecting a change in cells in one sheet. This works fine when I'm on the sheet. But the listener works even if I remove an other sheet that isn't the aim of the listener. This occurs only when I remove a sheet not when I add one. This is my macro : '***** BASIC ***** 'Macros permettant d'intercepter un événement : 'ici détecte une modif dans une plage de cellules oCells 'dans la feuille oSheet ("Dates") 'Utilisation de XModifyListener qui est constituée de '4 routines obligatoirement Option Explicit Global oListener as object, oCells as object Sub LanceEcoute 'procédure à assigner à l'évènement ouverture du 'document Outils-Personnaliser-Evènement (dans le doc) dim oDoc as object, oSheets as object, oSheet as object oDoc = thisComponent oSheets = oDoc.getSheets() oSheet = oSheets.getByName("Dates") oCells = oSheet.getCellRangeByName("B1:E44") oListener = CreateUnoListener( "LS_", "com.sun.star.util.XModifyListener" ) oCells.addModifyListener(oListener) MsgBox "Listener actif !" 'permet de vérifier que le Listener est actif End Sub Sub FermeEcoute 'procédure à assigner à l'évènement fermeture DE 'document Outils-Personnaliser-Evènement (dans le doc) oCells.removeModifyListener(oListener) MsgBox "Listener désactivé !" 'permet de vérifier que le Listener est déchargé End Sub Sub LS_modified(evt as object) 'Macro qui se déclenche dès 'que l'événement est détecté (changement dans les cellules) MsgBox "Feuille Dates modifiée !" End Sub Sub LS_disposing'(evt as object) ' routine OBLIGATOIRE lancée à la fermeture du document End Sub '************************************* Fin
Exactly, It depends where the sheet is added or removed in comparison to the position of the sheet "listened". If I add a sheet after, it's OK. If I add a sheet before, the listener works whereas it should'nt. If I remove a sheet touching the sheet listened, the listener works whereas it should'nt. But if I remove a sheet which is after and not near to the sheet listened, it's OK.
Created attachment 38913 [details] Issue 69205_Spreadsheet with macro XlModifyListener
Hi Christof, please have a look at this one and proceed as needed. Frank
Please don't change the version field if you just want to let us know that it's still in 2.0.4. The Version field tells us the timeframe of the first occurence. Frank
cn->nn: in a SO8PP1 this behavior is not reproducable but in src680_m184
retarget 2.x -> 3.x
Reset assigne to the default "issues@openoffice.apache.org".
I confirm that this issue is still present in Open Office version 4.1.5 I also add a clarification : thierry stated "If I add a sheet before, the listener works whereas it should'nt" Expressed in another way, this means : when a sheet is added before, the listener event subroutine is triggered : however no cell in the listened sheed has been changed due to the sheet insertion . Thus the addition or removal of a sheet should not trigger this listener event subroutine !
This issue is old now. Since 3.3, you have sheet events and "Content changed" action. Assign directly your macro on this event. Each sheet is independant and macro scope can be reproduced when you add a new sheet. For me, it's a WONT_FIX status
Created attachment 87178 [details] Sample document with event