Issue 61802 - Bad behaviour deleting a worksheet with Modify Event attached
Summary: Bad behaviour deleting a worksheet with Modify Event attached
Status: CONFIRMED
Alias: None
Product: Calc
Classification: Application
Component: programming (show other issues)
Version: OOo 2.0.1
Hardware: All All
: P3 Trivial (vote)
Target Milestone: ---
Assignee: AOO issues mailing list
QA Contact:
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-02-08 22:48 UTC by mdelfede
Modified: 2023-05-11 09:51 UTC (History)
2 users (show)

See Also:
Issue Type: DEFECT
Latest Confirmation in: 4.1.1
Developer Difficulty: ---


Attachments
testfile with the sample macro (9.26 KB, application/vnd.oasis.opendocument.spreadsheet)
2015-04-29 13:59 UTC, mroe
no flags Details
2nd document with different way (10.37 KB, application/vnd.oasis.opendocument.spreadsheet)
2023-05-11 09:51 UTC, oooforum (fr)
no flags Details

Note You need to log in before you can comment on or make changes to this issue.
Description mdelfede 2006-02-08 22:48:14 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.
Comment 1 frank 2006-03-07 13:36:43 UTC
Hi Niklas,

as discussed on the phone one for you on target later.

Frank
Comment 2 oooforum (fr) 2015-04-29 08:11:26 UTC
Seems to be obsolete.
Since OOo 3.1, we can assign macro directly on sheet events through Edit > Sheet > Events...
Comment 3 mroe 2015-04-29 13:57:30 UTC
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.
Comment 4 mroe 2015-04-29 13:59:15 UTC
Created attachment 84714 [details]
testfile with the sample macro

testfile with the macro from comment 1.
Issue still exists.
Comment 5 mroe 2015-04-29 14:00:53 UTC
Check the testfile.
Comment 6 Marcus 2017-05-20 10:44:24 UTC
Reset the assignee to the default "issues@openoffice.apache.org".
Comment 7 oooforum (fr) 2023-05-11 09:51:32 UTC
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. :-)