Bug 70883

Summary: "uno: copy" via the dispatcher does not work when a button has focus
Product: LibreOffice Reporter: pierre-yves samyn <pierre-yves.samyn>
Component: SpreadsheetAssignee: Not Assigned <libreoffice-bugs>
Status: NEW --- QA Contact:
Severity: normal    
Priority: medium CC: erack, fdbugs, lionel, markus.mohrhard, todventtu
Version: 4.0.4.2 releaseKeywords: bisected, regression
Hardware: Other   
OS: All   
Whiteboard: bibisected
i915 platform: i915 features:
Attachments: Spreadsheet with a macro

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 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

Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.