Apache OpenOffice (AOO) Bugzilla – Issue 61802
Bad behaviour deleting a worksheet with Modify Event attached
Last modified: 2023-05-11 09:51:32 UTC
Following snippet attach an ModifyEvent to each worksheet in a workbook when document opened : Option Explicit Global NumSheets as integer Global SheetsEvents() as Object Sub OnDocumentLoad 'ATTACHED TO DOCUMENT OPEN EVENT dim iSheet as integer dim aListener as Object NumSheets = ThisComponent.Sheets.Count ReDim SheetsEvents(NumSheets) for iSheet = 0 to NumSheets-1 aListener = CreateUnoListener("Sheet_", "com.sun.star.util.XModifyListener") ThisComponent.Sheets(iSheet).AddModifyListener(aListener) SheetsEvents(iSheet) = aListener next iSheet End Sub Sub Sheet_Modified(Evt as object) MsgBox "Sheet modified" End Sub Sub Sheet_Disposing(Evt as object) End Sub If I have for example these 3 worksheets in document : "Table1", "Table2" and "Table3", deleting worksheet "Table3" doesn't kill the event handler but does attach it to "Table2" worksheet, making the event handler called twice when modifying "Table2" worksheet. Even whorse, undoing the deletion restores "Table3" sheet but the event handler still remains attached to "Table2" sheet.
Hi Niklas, as discussed on the phone one for you on target later. Frank
Seems to be obsolete. Since OOo 3.1, we can assign macro directly on sheet events through Edit > Sheet > Events...
Don't know why you mean it could be obsolete. Assigning events via API or via GUI are two different things. But it has nothing to do with this issue.
Created attachment 84714 [details] testfile with the sample macro testfile with the macro from comment 1. Issue still exists.
Check the testfile.
Reset the assignee to the default "issues@openoffice.apache.org".
Created attachment 87187 [details] 2nd document with different way (In reply to mroe from comment #3) > Don't know why you mean it could be obsolete. > Assigning events via API or via GUI are two different things. But it has > nothing to do with this issue. Because with Events property, you don't need to create listeners and this issue gone. :-)