Created attachment 41370 [details] avoid a double paste The setup for this can be found at https://bugzilla.redhat.com/show_bug.cgi?id=663724 Fundamentally if you middle click to paste into an active comment in calc, then it also pastes into the cell behind the postit. If you then fiddle with undo and and undo the insertion of the comment the comment indicator doesn't disappear and view->comment will blow up calc. Best thing I guess is to not double paste. The attached attempts to do that and works for me at least. There might be a more elegant way to do this ?
Wow. Very interesting corner case. :-) I also discovered that (while trying to reproduce this), middle-clicking while a cell comment is selected pastes a copy of that selected comment object, and all sorts of interesting things start to happen. I guess we should disable duplicating cell comment objects via middle-click too while we are at it.
The patch looks good. That's what I would've done too. The only thing I'm not sure is bEEMouse = TRUE. Unless there is a specific reason for setting this, I would remove it. It looks like this boolean flag is used in case we need to handle mouse events inside the edit engine instance (?). In this particular case since we are ignoring this event completely, I'd say let's leave the flag alone.
Ah, bEEMouse *is* required to skip the paste into cell! Interesting...
I prefer to have this handled in ScGridWindow::PasteSelection(). I feel that's more appropriate place. But I think a better solution is to have the note object somehow tell the grid window instance that it has already handled the paste, or not even send the event to the grid window. I don't know if that's possible or not... Let me look into that.
Actually the active note object isn't always associated with the current cell cursor position. So, we need to change how we determine the active note object underneath the mouse cursor.
Fixed on master. This is what I ended up committing: http://cgit.freedesktop.org/libreoffice/calc/commit/?id=342f3cfe6f2b27ea62bd9883e16014c188276356