Apache OpenOffice (AOO) Bugzilla – Issue 51621
Macro Copy Paste does not work from a button
Last modified: 2013-02-24 21:06:56 UTC
Attached document bugCopyPaste contains two simple macros which are started from two buttons on the first sheet. The buttons are working OK in 1.1.4 but do not work as expected in 1.9.xxx First button executes a copy/paste frome one zone to another of the same Calc sheet. In 1.9.xxx there is no copy, and no paste. But, if the macro is started from menu Tools > Macros it works OK. Second button executes a copy from this document and a paste to another existing Calc document. Path of the other document : C:\Docs OpenOffice\target.sxc In 1.9.xxx there is no copy, but paste works (with the current clipboard content). But, if the macro is started from menu Tools > Macros it works OK. The same behaviour appears with a similar .ods document.
Created attachment 27738 [details] Calc document with two macros started by buttons.
Created attachment 27739 [details] Ordinary Calc document for use with 2nd button.
Can confirm the first part: copying in the same document. However, copying to another document is working for me (1.9.m113 WinXP).
sw->tbe: the first button has no effect and the second copies what is currently in the clipboard, if nothing is in there nothing happens here either. All seems to work fine when the macro are executed via "Tools-Macros". Setting target to OOo2.0.1 since this used to work for example in OOo1.1.4
TBE->FS: The macro is executed in both cases, when pressing the button and via Tools/Macros/Run Macro. But when pressing the button, the executeDispatch() call fails. The reason for that is, that the macro runs in the wrong context. In this case the FmFormShell is on the shell stack. For more details, please ask CD.
for the records: workaround: Set the "Take focus in click" property of the button to "No"
fixed in CWS dba201c The problem here is that when you click onto the button, it grabs the focus. Now in 2.0, when a form control has a focus, certain actions from the menu/toolbar (for instance cut/copy/paste) are routed to this control, and not to the main document anymore. This makes sense for, for instance, text input fields: You can now operate them via the toolbox. However, it doesn't make sense for buttons (which can just realize that the desired functionality is not available). Speaking very strictly, this is a problem of the macro, since it uses the dispatch API to access cut/copy/paste functionality. The dispatch API is always dependent on the document state, and thus not 100 percent reliable. However, there is no other API for cut/copy/paste, and the macro recorder produces code which uses the dispatch API, so declaring this as "wrong" would not really be a good solution :) Fixed this by not routing cut/copy/paste (and a lot of other functionalities) to the active control, if this active control cannot serve the functionality, anyway.
fs-> msc: please verify in CWS dba201d re-open issue and reassign to msc
reassign to msc
reset resolution to FIXED
verified in cws dba201d
Hi, this is fixed in the current master. The current master is available at http://download.openoffice.org/680/index.html I close this issue now. Bye Marc