Bug 103830 - Form field names not update in python macro
Summary: Form field names not update in python macro
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Calc (show other bugs)
Version:
(earliest affected)
4.4.0.3 release
Hardware: All All
: medium normal
Assignee: Not Assigned
URL:
Whiteboard: target:5.4.0 target:5.3.2 target:5.2.7
Keywords: bibisected, bisected, regression
Depends on:
Blocks:
 
Reported: 2016-11-10 13:46 UTC by michael.letzgus
Modified: 2017-02-26 12:01 UTC (History)
5 users (show)

See Also:
Crash report or crash signature:


Attachments
Demo file (11.68 KB, application/vnd.oasis.opendocument.spreadsheet)
2016-11-12 10:46 UTC, michael.letzgus
Details
Demo python file (251 bytes, text/x-python)
2016-11-12 10:48 UTC, michael.letzgus
Details

Note You need to log in before you can comment on or make changes to this bug.
Description michael.letzgus 2016-11-10 13:46:22 UTC
Hi,

after changing names of form field elements to calc the new names are not available in python macros:

sheet.getDrawPage().getForms().getByIndex(0).getElementNames()

This call returns the original unchanged names, not the new ones.

After saving and reloading the document getElementNames() returns the correct names.


Michael
Comment 1 Joel Madero 2016-11-12 04:25:38 UTC
Please attach a sample with the macro in it and then set the bug to UNCONFIRMED. Thanks
Comment 2 michael.letzgus 2016-11-12 10:46:36 UTC
Created attachment 128689 [details]
Demo file
Comment 3 michael.letzgus 2016-11-12 10:48:08 UTC
Created attachment 128690 [details]
Demo python file

This file must be placed in

~/.config/libreoffice/4/user/Scripts/python/
Comment 4 michael.letzgus 2016-11-12 10:48:39 UTC
Testcase added
Comment 5 Buovjaga 2016-11-24 08:14:54 UTC
Repro with 5.3, but not with 3.5, so regression.

For testers/bibisecters:
View - Toolbars - Form design
Click button to set design mode On
Select TEST1 and TEST2 buttons and click the Control button to be able to edit their properties. Name is in General tab.

Win 7 Pro 64-bit Version: 5.3.0.0.alpha1+
Build ID: 172325bedf69bbc162f3c1948264451c90c105a3
CPU Threads: 4; OS Version: Windows 6.1; UI Render: default; Layout Engine: new; 
TinderBox: Win-x86@39, Branch:master, Time: 2016-11-21_05:26:40
Locale: fi-FI (fi_FI); Calc: group

LibreOffice 3.5.0rc3 
Build ID: 7e68ba2-a744ebf-1f241b7-c506db1-7d53735
Comment 6 Aron Budea 2016-12-25 06:40:18 UTC
Still works in 4.3.0.4, doesn't work in 4.4.0.3. Adjusting version field.
Comment 7 Aron Budea 2017-02-24 04:45:21 UTC
Bibisected using bibisect_win_44 repo.
		
# good: [8aa9fc9a0c92172593d6cd97662116a965db229d] source-hash-dea4a3b9d7182700abeb4dc756a24a9e8dea8474
git bisect good 8aa9fc9a0c92172593d6cd97662116a965db229d
# bad: [489ffd1df414698b6cea9ab03bf6f663b8b5af7e] source-hash-3f94c9e9ddfd807b449f3bb9b232cf2041fa12d2
git bisect bad 489ffd1df414698b6cea9ab03bf6f663b8b5af7e
# bad: [489ffd1df414698b6cea9ab03bf6f663b8b5af7e] source-hash-3f94c9e9ddfd807b449f3bb9b232cf2041fa12d2
git bisect bad 489ffd1df414698b6cea9ab03bf6f663b8b5af7e
# good: [897913acd244cb6a5d2f4c2da1d625d9b978edb6] source-hash-ac57362b23859591c088e36b7218f4a606dcf3bb
git bisect good 897913acd244cb6a5d2f4c2da1d625d9b978edb6
# good: [897913acd244cb6a5d2f4c2da1d625d9b978edb6] source-hash-ac57362b23859591c088e36b7218f4a606dcf3bb
git bisect good 897913acd244cb6a5d2f4c2da1d625d9b978edb6
# good: [860f6172be84c3d801e1e533ab3d12a28815cb4c] source-hash-80c11d648e88f3195f7e4fb465cd6902bcf46867
git bisect good 860f6172be84c3d801e1e533ab3d12a28815cb4c
# good: [860f6172be84c3d801e1e533ab3d12a28815cb4c] source-hash-80c11d648e88f3195f7e4fb465cd6902bcf46867
git bisect good 860f6172be84c3d801e1e533ab3d12a28815cb4c
# good: [fe0abc50dc1e45fd73635394f8df41e0dfc3eec8] source-hash-4e223fab04279c3583689e69fa1342966e81de36
git bisect good fe0abc50dc1e45fd73635394f8df41e0dfc3eec8
# bad: [247d0249eb9794ccedec0ca2e3309b8d970593cc] source-hash-1535f39388223de53e4b923c6f7bb71ee32c1858
git bisect bad 247d0249eb9794ccedec0ca2e3309b8d970593cc
# bad: [247d0249eb9794ccedec0ca2e3309b8d970593cc] source-hash-1535f39388223de53e4b923c6f7bb71ee32c1858
git bisect bad 247d0249eb9794ccedec0ca2e3309b8d970593cc
# good: [6cf25fb7af89cc58453d4bda5135e05ca220b1a4] source-hash-ddd549c7873404d0c09aca676a13660404b0bcd2
git bisect good 6cf25fb7af89cc58453d4bda5135e05ca220b1a4
# bad: [bfea3b2558107a049b038c756f63169782a2909c] source-hash-a9a9718bb1f64318429562ecdaa3d3763d9e2f4a
git bisect bad bfea3b2558107a049b038c756f63169782a2909c
# good: [ea9607c5d8d01daea4116f869c7a5b8be2d56c34] source-hash-f3798fa1584dd63b8547eec00c92584d906f6979
git bisect good ea9607c5d8d01daea4116f869c7a5b8be2d56c34
# good: [f3cf88475275189bc454cc1b84bf4c25af2e6182] source-hash-0fd046c571eb9a5a4597e374c453c2515a1388c3
git bisect good f3cf88475275189bc454cc1b84bf4c25af2e6182
# bad: [232925ac49ba4e65c39aa8a0c4c74026ffe23f9e] source-hash-e90ba3912747b67873344dea14e2a5821ec766c8
git bisect bad 232925ac49ba4e65c39aa8a0c4c74026ffe23f9e
# good: [11da988db49265ba4cc99af001d60c500f908a10] source-hash-16f18fb34b5cfae86a48e8e360d98b95d458ee85
git bisect good 11da988db49265ba4cc99af001d60c500f908a10
# first bad commit: [232925ac49ba4e65c39aa8a0c4c74026ffe23f9e] source-hash-e90ba3912747b67873344dea14e2a5821ec766c8

Bibisected down to a range of 8 commits:
https://cgit.freedesktop.org/libreoffice/core/log/?qt=range&q=16f18fb34b5cfae86a48e8e360d98b95d458ee85..e90ba3912747b67873344dea14e2a5821ec766c8
Comment 8 Aron Budea 2017-02-24 04:46:55 UTC
Verified that the commit referenced below is causing this bug. Adding Cc: Noel Grandin.

https://cgit.freedesktop.org/libreoffice/core/commit/?id=5f15cc01b31ccaed0c6482a36556dece084ce302
author		Noel Grandin <noel@peralex.com>	2014-11-05 12:48:20 (GMT)
committer	Noel Grandin <noel@peralex.com>	2014-11-05 13:59:23 (GMT)

"new loplugin: use more efficient find() methods"

In particular this change:
http://opengrok.libreoffice.org/xref/core/forms/source/misc/InterfaceContainer.cxx#665
old: if (i != m_aMap.end())
new: if (i != m_aMap.end() && (*i).second != evt.Source)
Comment 9 Commit Notification 2017-02-24 08:12:06 UTC
Noel Grandin committed a patch related to this issue.
It has been pushed to "master":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=3a404ea870f1eed86f9765447ce0a364d39ae8f8

tdf#103830 Form field names not update in python macro

It will be available in 5.4.0.

The patch should be included in the daily builds available at
http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
http://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 10 Commit Notification 2017-02-24 08:19:44 UTC
Noel Grandin committed a patch related to this issue.
It has been pushed to "libreoffice-5-3":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=81e5ba515c66bc23520f3d9c06c54c63d927e467&h=libreoffice-5-3

tdf#103830 Form field names not update in python macro

It will be available in 5.3.2.

The patch should be included in the daily builds available at
http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
http://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 11 Commit Notification 2017-02-24 08:29:26 UTC
Noel Grandin committed a patch related to this issue.
It has been pushed to "libreoffice-5-2":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=858aa013061fb179e68c90a9dce6341a352b17c1&h=libreoffice-5-2

tdf#103830 Form field names not update in python macro

It will be available in 5.2.7.

The patch should be included in the daily builds available at
http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
http://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 12 Aron Budea 2017-02-24 08:55:13 UTC
Thanks for the very quick response with a fix, Noel!

I didn't understand the purpose of that additional clause at first, and the fix helped me understand.

I've got a question, though:

m_aMap is of type OInterfaceMap, which is of type std::unordered_multimap, so there could be multiple values for a key. Find returns an element, but then it might return the "wrong" element (same key, different value) and the correct one won't be found, since only one is checked.
Is that a real possibility here? (the equality check makes me think so)

Using std::unordered_multimap::equal_range to find entries with the same key, and iterating through them to find the one with the same source (if exists) could eliminate that possibility.
Comment 13 Noel Grandin 2017-02-24 09:26:10 UTC
Good spotting, better fix on the way
Comment 14 Commit Notification 2017-02-24 10:51:11 UTC
Noel Grandin committed a patch related to this issue.
It has been pushed to "master":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=e146741ec96292ef092c6eebfd7fe18fa5ca3cc0

better fix for tdf#103830

It will be available in 5.4.0.

The patch should be included in the daily builds available at
http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
http://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 15 Commit Notification 2017-02-24 12:55:40 UTC
Noel Grandin committed a patch related to this issue.
It has been pushed to "libreoffice-5-3":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=46885644fe87a6e9f86a79b7fd1eafbe3ea0e5a6&h=libreoffice-5-3

better fix for tdf#103830

It will be available in 5.3.2.

The patch should be included in the daily builds available at
http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
http://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 16 Commit Notification 2017-02-26 12:01:43 UTC
Noel Grandin committed a patch related to this issue.
It has been pushed to "libreoffice-5-2":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=1f3ce5a00b2a85374204f3f05433d3cfd3292fe7&h=libreoffice-5-2

better fix for tdf#103830

It will be available in 5.2.7.

The patch should be included in the daily builds available at
http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
http://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.