Issue 51621 - Macro Copy Paste does not work from a button
Summary: Macro Copy Paste does not work from a button
Status: CLOSED FIXED
Alias: None
Product: App Dev
Classification: Unclassified
Component: api (show other issues)
Version: 3.3.0 or older (OOo)
Hardware: All Windows XP
: P3 Trivial
Target Milestone: ---
Assignee: marc.neumann
QA Contact: issues@api
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-07-06 09:28 UTC by bmarcelly
Modified: 2013-02-24 21:06 UTC (History)
1 user (show)

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


Attachments
Calc document with two macros started by buttons. (9.87 KB, application/vnd.sun.xml.calc)
2005-07-06 09:29 UTC, bmarcelly
no flags Details
Ordinary Calc document for use with 2nd button. (6.18 KB, application/vnd.sun.xml.calc)
2005-07-06 09:30 UTC, bmarcelly
no flags Details

Note You need to log in before you can comment on or make changes to this issue.
Description bmarcelly 2005-07-06 09:28:43 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.
Comment 1 bmarcelly 2005-07-06 09:29:30 UTC
Created attachment 27738 [details]
Calc document with two macros started by buttons.
Comment 2 bmarcelly 2005-07-06 09:30:13 UTC
Created attachment 27739 [details]
Ordinary Calc document for use with 2nd button.
Comment 3 christianjunker 2005-07-08 21:08:28 UTC
Can confirm the first part: copying in the same document.
However, copying to another document is working for me (1.9.m113 WinXP).

Comment 4 stephan.wunderlich 2005-07-11 12:34:35 UTC
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
Comment 5 thomas.benisch 2005-08-03 13:19:12 UTC
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.
Comment 6 Frank Schönheit 2005-08-19 09:01:06 UTC
for the records: workaround: Set the "Take focus in click" property of the
button to "No"
Comment 7 Frank Schönheit 2005-08-19 10:47:18 UTC
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.
Comment 8 Frank Schönheit 2005-10-11 08:22:44 UTC
fs-> msc: please verify in CWS dba201d

re-open issue and reassign to msc
Comment 9 Frank Schönheit 2005-10-11 08:23:11 UTC
reassign to msc
Comment 10 Frank Schönheit 2005-10-11 08:23:25 UTC
reset resolution to FIXED
Comment 11 marc.neumann 2005-10-19 15:15:04 UTC
verified in cws dba201d
Comment 12 marc.neumann 2005-11-15 14:03:08 UTC
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