Description: When assigning a macro to the "Selected area changed" sheet event, left-clicking on any cell generates not one, but four event firings - one when clicked, three when released. There must be one. Steps to Reproduce: 1. Open attached file. 2. Left-click any cell 3. Look at firings Actual Results: Multiple sheet event firings Expected Results: One sheet event firing Reproducible: Always User Profile Reset: No Additional Info: Version: 24.2.3.2 (X86_64) / LibreOffice Community Build ID: 433d9c2ded56988e8a90e6b2e771ee4e6a5ab2ba CPU threads: 4; OS: Windows 10.0 Build 22000; UI render: Skia/Raster; VCL: win Locale: ru-RU (ru_RU); UI: ru-RU Calc: CL threaded
Created attachment 194602 [details] File to show bug
The problem is that ScTabView::SelectionChanged (sc/source/ui/view/tabview3.cxx), which itself calls ScTabViewObj::SelectionChanged (sc/source/ui/unoobj/viewuno.cxx), finally executing the script, is called in conditions where a change *could* had happened, and then it needs to be done; but the call site has no information if that change has actually happened. For example, the mouse up event first fires that call from ScTabView::MoveCursorAbs, explicitly for the case when the coordinates *are the same*; then it calls the function two times directly in ScGridWindow::MouseButtonUp - before and after some code. The function does a lot of other stuff, and it is unclear to me how to fix this. For file open case, the first two calls are from ScDrawView::SdrEndTextEdit, which itself is called, when "unselect all" code is executed when setting current sheet. Only the third call is actually setting the target cell (which in this case is unchanged compared to the previous state, just needs to be signalled to the Basic code for the first time).