Bug 70883 - "uno: copy" via the dispatcher does not work when a button has focus
Summary: "uno: copy" via the dispatcher does not work when a button has focus
Status: NEW
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Calc (show other bugs)
Version:
(earliest affected)
4.0.4.2 release
Hardware: Other All
: medium normal
Assignee: Not Assigned
URL:
Whiteboard:
Keywords: bibisected, bisected, regression
: 115844 131317 (view as bug list)
Depends on:
Blocks: Macro-UNOAPI
  Show dependency treegraph
 
Reported: 2013-10-26 08:02 UTC by pierre-yves samyn
Modified: 2024-05-16 07:12 UTC (History)
13 users (show)

See Also:
Crash report or crash signature:


Attachments
Spreadsheet with a macro (9.77 KB, application/vnd.oasis.opendocument.spreadsheet)
2013-10-26 08:02 UTC, pierre-yves samyn
Details

Note You need to log in before you can comment on or make changes to this bug.
Description pierre-yves samyn 2013-10-26 08:02:57 UTC
Created attachment 88142 [details]
Spreadsheet with a macro

Hello

Context : a macro launched via a command button to copy a range of cells.

The problem arises when a button has the focus. In this case the copy is irrelevant that the macro is launched via the button or otherwise (menus, shortcut).

The attached spreadsheet contains:
- A macro "Disp" that copies A1:A3 to C1.
- A button that launches the macro.

When you open the spreadsheet the button has focus. Start macro without clicking the button, but through the menus (macro> run, or macro> organize> Run). It does not work (move and selection are but not copy).

Click on the sheet (anywhere) then restart the macro via menus: everything works as many times as you want (change the range A1:A3 to check).

There is a workaround (use the copy method of a sheet) but this is an annoying regression because the feature is widely used, especially by beginners.

Set to "New" because reproduced (qa-fr) :
- 4.0.5 Windows 7 32b
- 4.1.1 W8/64
- 4.1.1.2/Ubuntu 12.04
- 4.1.2.1 W/XP
- 4.1.2.3/W8.1/64 

Regards
Pierre-Yves
Comment 1 marc.romano 2013-10-26 10:18:10 UTC
Hello

Reproduced with 4.0.4 W7/32 and 4.1.2.3 Ubuntu 12.04. The problem appears when any button in the sheet has the focus, not only those calling the macro with "uno:copy".

With any version of LibO 3, the macro works fine, regardless the way to launch it, and for all platforms.

Regards
Marc
Comment 2 Michael Stahl (allotropia) 2014-02-04 11:53:51 UTC
works in 4.0.3.3, broken in 4.0.4.2
Comment 3 Matthew Francis 2014-12-06 05:50:49 UTC
Results from bibisect-43all:
 e2a9149a7723f4e00eb3cafe466e204e5da19e9c is the first bad commit
commit e2a9149a7723f4e00eb3cafe466e204e5da19e9c
Author: Bjoern Michaelsen <bjoern.michaelsen@canonical.com>
Date:   Thu Oct 17 05:01:44 2013 +0000

    source-hash-2ede6c95e6481c92cc199e7d74fd36c841636304
    
    commit 2ede6c95e6481c92cc199e7d74fd36c841636304
    Author:     Khaled Hosny <khaledhosny@eglug.org>
    AuthorDate: Sun May 12 17:59:50 2013 +0200
    Commit:     Khaled Hosny <khaledhosny@eglug.org>
    CommitDate: Sun May 12 18:47:36 2013 +0200
    
        Some logging
    
        Change-Id: I4515d4d6760e22ce4d77fbb3cbce93e3ce097b98

# bad: [423a84c4f7068853974887d98442bc2a2d0cc91b] source-hash-c15927f20d4727c3b8de68497b6949e72f9e6e9e
# good: [a71a4447320f177181c9cff9f7c6fd93802cbd8e] source-hash-9afb6e1e38c362a768e8e981f7b03cf8bcaf22cf
git bisect start 'latest' 'last36onmaster'
# bad: [f2554751603ad8537257b3cf52d6171056c76eeb] source-hash-f42768fe0b60ecbbe9c68d775329bf28c0690131
git bisect bad f2554751603ad8537257b3cf52d6171056c76eeb
# good: [c826604de689fbabd8b1b8ea41396694e99a23d4] source-hash-32acb98b3fb6acb4712f7195cf5ea1bd69c9c6b4
git bisect good c826604de689fbabd8b1b8ea41396694e99a23d4
# bad: [e818f97b99709bcedf56865e733647666cfae09c] source-hash-66e39940d763586060c4bcc8c3cd213495c40b79
git bisect bad e818f97b99709bcedf56865e733647666cfae09c
# good: [3142334d94a2c49f484453556493532e4a994002] source-hash-0644a20605965b36fcc983e4c1158820fd858726
git bisect good 3142334d94a2c49f484453556493532e4a994002
# good: [b17e3e62a0b58fb7670463f6934881c1aac97b39] source-hash-092fa33f22bbdcb74c3533750158db1724971878
git bisect good b17e3e62a0b58fb7670463f6934881c1aac97b39
# good: [f1fda5341557321cf4953c0d5dc6ffe262f1b545] source-hash-ee8323e2280c72eb5cc9ec0257164154b2580a78
git bisect good f1fda5341557321cf4953c0d5dc6ffe262f1b545
# bad: [38e06ae137e1dcaaaf82127b977869499742bd94] source-hash-3fb33e3e04c7f339e1e15d24529e8ea1d4dbe321
git bisect bad 38e06ae137e1dcaaaf82127b977869499742bd94
# good: [7735ac016add3b7e4b96d6017919a828e3271a0a] source-hash-923312f67fbf120158f01c2c0e588af38fc22364
git bisect good 7735ac016add3b7e4b96d6017919a828e3271a0a
# bad: [b827dce34450091ab3fd608fcb1774899cb2f865] source-hash-1472b5f87314fe660ef1a7b254e51272669f12f6
git bisect bad b827dce34450091ab3fd608fcb1774899cb2f865
# bad: [e2a9149a7723f4e00eb3cafe466e204e5da19e9c] source-hash-2ede6c95e6481c92cc199e7d74fd36c841636304
git bisect bad e2a9149a7723f4e00eb3cafe466e204e5da19e9c
# first bad commit: [e2a9149a7723f4e00eb3cafe466e204e5da19e9c] source-hash-2ede6c95e6481c92cc199e7d74fd36c841636304
Comment 4 stinstin 2015-01-01 08:50:20 UTC
Hello, 
there is the same problem on : 4.3.5-1

Twice Alternatives (manuel) with :

CODE : 
    Sub CollageSelection
       oDoc = ThisComponent
       oPlage = oDoc.CurrentSelection ' Plage sélectionnée
       oFeuille = oDoc.Sheets.getByName("Feuille1") ' Nom de la feuille où coller
       oColleCellule = oFeuille.getCellRangeByName("A1")  ' Cellule où démarre le collage
       If oPlage.supportsService("com.sun.star.table.CellRange") Then
          oFeuille.copyRange(oColleCellule.CellAddress, oPlage.RangeAddress)
       Else
              ' A compléter si plages discontigües
          msgBox "Sélectionnez au moins deux cellules contigües"
       EndIf
    End Sub

Or with :

CODE : 
    Sub CopyZoneMemeClasseur()
    Dim oDoc as Object, oRange as Object, aCopier as Object
       oDoc = thisComponent
       oRange = oDoc.Sheets(0).getCellRangeByName("H2:H9") ' la zone à copier
       oDoc.CurrentController.select(oRange) 'Sélection de la zone
       aCopier = oDoc.CurrentController.getTransferable() 'Copie
       oRange = oDoc.Sheets(0).getCellRangeByName("A1") 'Première cellule pour recopie de la zone
       oDoc.CurrentController.select(oRange) 'Selection de la cellule
       oDoc.CurrentController.insertTransferable(aCopier) 'Transfert des données
    End Sub


Thank you
Comment 5 Matthew Francis 2015-01-09 17:19:23 UTC
The change in behaviour seems to have been caused by the below commit.

Adding Cc: to lionel@mamane.lu. Any thoughts on what can be done with this one? Thanks


commit 7fd1cc18130464a9f09cb7a866e88c4d52e4716d
Author: Lionel Elie Mamane <lionel@mamane.lu>
Date:   Sun May 12 00:35:31 2013 +0200

    fdo#63695 revert hackish fix to i#51621
    
    Change-Id: I688a659207c4b95cc98ff5dc5c5622d4592b3f89
Comment 6 Lionel Elie Mamane 2015-01-09 17:34:29 UTC
This looks like it is exactly i#51621 ( https://issues.apache.org/ooo/show_bug.cgi?id=51621 ).

Not surprising since my fix to bug 62520 (fdo#62520) was to revert the fix to i#51621.

Since bug 62520 leads to data loss (entered data is not saved and discarded), I consider it as "more important".

So what needs to happen is "somebody fixes this without reintroducing bug 62520".
Comment 7 fsoltrash 2015-01-19 14:11:58 UTC
I encountered this problem in a macro I'm working on. 
Forcing the code to take off the focus from the button seems to work for me.

I placed the following code as the fist line in the macro:

 ThisComponent.CurrentController.Frame.ContainerWindow.setFocus
Comment 8 Robinson Tryon (qubit) 2015-12-13 11:09:22 UTC Comment hidden (obsolete)
Comment 9 charles 2016-02-26 09:45:13 UTC
Quand je veux faire un copier d'un fichier sur un autre, sachant que les 2 fichiers sont ouverts, "copier" se fait sans problème. mais le clic droit réalisé sur la cellule de destination ne présente pas "coller" automatiquement Je suis le plus souvent obligé de fermer et ré-ouvrir le fichier de destination
pour que la proposition "coller" apparaisse !
Cordialement
Jean Charles
Comment 10 Wolfgang Jäger 2017-08-19 16:35:23 UTC
Trying to help with 
https://ask.libreoffice.org/en/question/124400/copy-wont-work-in-macro/ 
I just found the bug living in LibO V 5.4.0.3 under Win 10.
Comment 11 jeromec 2017-09-29 12:18:51 UTC
I can confirm the bug i still there with LibreOffice 5.4.1002 and OS X 10.13 High Sierra.

And thanks @fsoltrash for the workaround!
Comment 12 Alex Thurgood 2018-02-22 08:03:47 UTC
*** Bug 115844 has been marked as a duplicate of this bug. ***
Comment 13 QA Administrators 2019-02-23 03:41:58 UTC Comment hidden (obsolete)
Comment 14 s.p.helma 2019-07-25 12:04:43 UTC
Version: 6.2.5.2
Build ID: 1:6.2.5-0ubuntu0.18.04.1~lo1
CPU threads: 4; OS: Linux 5.1; UI render: default; VCL: gtk3; 
Locale: en-GB (en_GB.UTF-8); UI-Language: en-GB
Calc: threaded

I can confirm that this bug is still present.
Comment 15 romrodz77@outlook.com 2020-01-26 23:10:04 UTC
Versión: 6.3.4.2 (x64)
Id. de compilación: 60da17e045e08f1793c57c00ba83cdfce946d0aa
Subprocs. CPU: 8; SO: Windows 10.0; Repres. IU: GL; VCL: win; 
Configuración regional: es-ES (es_ES); Idioma de IU: es-ES
Calc: CL




The bug is still present.
Comment 16 b. 2020-03-25 22:51:52 UTC
and again i tapped on an old bug nobody cared for since years ... 

(i like libreoffice and consider it one of the best office suites, the weakest points are the 'old bugs', that nobody cares for them, and that new findings are pulled away as duplicates. this is a general weakness of the development as a community, and the systematics of the bugtracker.)

still failing with: 

Version: 7.0.0.0.alpha0+ (x64)
Build ID: 61d8d991a27c3bfe70e3b8d3b4ce4d8a41d18d2d
CPU threads: 8; OS: Windows 6.1 Service Pack 1 Build 7601; UI render: default; VCL: win; 
Locale: de-DE (de_DE); UI-Language: en-US
Calc: 

trick from https://bugs.documentfoundation.org/show_bug.cgi?id=70883#c7 works.
Comment 17 Buovjaga 2020-03-26 09:13:54 UTC
(In reply to b. from comment #16)
> and again i tapped on an old bug nobody cared for since years ... 
> 
> (i like libreoffice and consider it one of the best office suites, the
> weakest points are the 'old bugs', that nobody cares for them, and that new
> findings are pulled away as duplicates. this is a general weakness of the
> development as a community, and the systematics of the bugtracker.)

If you think some report is wrongly closed as a duplicate, please explain why you think so. Findings from duplicates can be copied as comments to the open reports.
Comment 18 b. 2020-03-26 16:44:45 UTC
@Buovjaga: 

> If you think some report is wrongly closed as a duplicate, please explain why you think so. 

no, i didn't say that, thus nothing to explain, 

> Findings from duplicates can be copied as comments to the open reports.

i know that, and did so sometimes, 

what i'd say was: 

"(i like libreoffice and consider it one of the best office suites, the weakest points are the 'old bugs', that nobody cares for them, and that new findings are pulled away as duplicates. this is a general weakness of the development as a community, and the systematics of the bugtracker.)"

as an extenuation of a - gallows humor - remark: 

"and again i tapped on an old bug nobody cared for since years ... "

mean point, as bugs and bugtracker are actually handeled they lead developers to the triage: 1. new bug? oh no, it's a duplicate, 2. care for the origin? oh no, too many comments, difficult stuff, 3. what do do? mark as dup and care for something else. and that buries 'old bugs'. 

you can verify this opinion on this bug - 6 years, no patch, no progress, on other fields like 'shared formulas', parallelizing, - there had been some progress - macro functionality, iterations, comment slowdowns, autocalc, #REF! errors and so on, or on #62196 mentioned by Mike - basic functionality, six years, 13 duplicates, no patch, no progress, it already has a sibling #65606 with some duplicates, and a grandfather #34599 ... you'll see that bug handling for old bugs in calc (and libreoffice?) is not the most effective point of the project. 

i wouldn't cry about that in 'bugs' - imho intended for work on the factual problems - if i'd know any better place, perhaps you can give me a hint. 

reg. 

b.
Comment 19 b. 2020-04-16 09:37:47 UTC
am i right with the following 'backtrace'? 

the problem is old and was once solved - 

https://issues.apache.org/ooo/show_bug.cgi?id=51621

that fix was reverted by @Lionel reg. #62520 and being 'hackish' - 

https://bugs.documentfoundation.org/show_bug.cgi?id=70883#c6

but without noting it in that thread (62520), 

thus the ooo thread 51621 pinpoints the problem, and needs a rework taking into account the problems of #62520?

but the site with the old fix passed away 

(http://eis.services.openoffice.org/EIS2/cws.ShowCWS?Id=3085&Path=SRC680%2Fdba201d is broken), 

and the wayback machine didn't archive that branch, :-(

------------ 

couldn't put 

https://ask.libreoffice.org/en/question/24788/is-there-some-known-issues-using-button-to-execute-a-macro/

under 'see also', thus here.
Comment 20 Mike Kaganski 2020-04-16 10:13:23 UTC
(In reply to b. from comment #19)

You basically correctly describe what had been mentioned in comment 6, bug 63695 comment 21 (which shows that Lionel's change *was* noted there), and i#51621 (https://bz.apache.org/ooo/show_bug.cgi?id=51621).

The original fix was in https://git.libreoffice.org/core/+/bdf02613fe455963dbcb4ee8f85da628856b146c.
Comment 21 b. 2020-04-19 12:45:35 UTC
thanks @Mike, 

I was confused that the 'correction' had not been mentioned in #62520 ...
Comment 22 Buovjaga 2020-05-15 20:25:12 UTC
*** Bug 131317 has been marked as a duplicate of this bug. ***
Comment 23 QA Administrators 2022-05-16 03:35:02 UTC Comment hidden (obsolete)
Comment 24 s.p.helma 2022-05-16 06:47:15 UTC
I just tested the attached spreadsheet (https://bugs.documentfoundation.org/attachment.cgi?id=88142) and can confirm, that the bug still exists.

Version: 7.3.3.2 / LibreOffice Community
Build ID: 30(Build:2)
CPU threads: 4; OS: Linux 5.17; UI render: default; VCL: gtk3
Locale: en-GB (en_GB.UTF-8); UI: en-GB
Ubuntu package version: 1:7.3.3~rc2-0ubuntu0.20.04.1~lo1
Calc: threaded
Comment 25 pierre-yves samyn 2022-05-16 09:32:14 UTC
Hi

Still reproduced on Version: 7.3.3.2 (x64) / LibreOffice Community
Build ID: d1d0ea68f081ee2800a922cac8f79445e4603348
CPU threads: 2; OS: Windows 6.1 Service Pack 1 Build 7601; UI render: Skia/Raster; VCL: win
Locale: fr-FR (fr_FR); UI: fr-FR
Calc: threaded

Regards
Pierre-Yves
Comment 26 QA Administrators 2024-05-16 03:16:29 UTC Comment hidden (obsolete)
Comment 27 s.p.helma 2024-05-16 07:12:50 UTC
I just tested the attached spreadsheet (https://bugs.documentfoundation.org/attachment.cgi?id=88142) and can confirm, that the bug still exists.

Version: 24.2.3.2 (X86_64) / LibreOffice Community
Build ID: 420(Build:2)
CPU threads: 4; OS: Linux 6.8; UI render: default; VCL: gtk3
Locale: en-GB (en_GB.UTF-8); UI: en-GB
Ubuntu package version: 4:24.2.3~rc2-0ubuntu0.22.04.1~lo1
Calc: threaded