Bug 157287 - Cross-reference a formula does not work since 7.6x
Summary: Cross-reference a formula does not work since 7.6x
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Writer (show other bugs)
Version:
(earliest affected)
7.6.0.0 beta1+
Hardware: x86-64 (AMD64) All
: high major
Assignee: Matti Tyrväinen
URL:
Whiteboard: target:24.2.0 target:7.6.3
Keywords: bibisected, bisected, regression
: 157490 (view as bug list)
Depends on:
Blocks: Fields-Cross-Reference
  Show dependency treegraph
 
Reported: 2023-09-17 08:36 UTC by Frank Schoefisch
Modified: 2024-02-05 15:00 UTC (History)
8 users (show)

See Also:
Crash report or crash signature:


Attachments
Test/example file to demonstrate the described misbehaviour in 7.6.x (11.19 KB, application/vnd.oasis.opendocument.text)
2023-09-29 09:31 UTC, Frank Schoefisch
Details
Hotfix for 157287, unfixes 81720 without reverting refactoring and test (1.39 KB, patch)
2023-10-16 11:43 UTC, Matti Tyrväinen
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Frank Schoefisch 2023-09-17 08:36:18 UTC
Description:
Previously, it was possible to provide the formula in a table cell with a cross-reference and then retrieve this in the subsequent text. If the result of the formula changed, the cross-reference in the text also changed.
Now only cross-reference to the cell or formula is possible.
If a cross-reference is setup to a cell with a formula, the formula is deleted and the result value of the previous calculation is entered - the table cell then no longer calculates. If an attempt is made to fill the area of a cross-reference with a formula, the cross-reference is deleted.
For documents created with earlier versions, the cross-reference is deleted when the formula is recalculated.

Steps to Reproduce:
1.Create a table with 1 column, 3 rows, fill in values in row 1+2
2.create a formula in row 3 (<A3>) that adds values from row 1+2 (= <A1>+<A2>)
3.change values in <A1> and/or <A2>
4.create/set a cross-reference on the formula in cell A3 (content will be doubled, one as cross-reference field)
5.insert cross-reference field outside the table (using referenced text); value from <A3> is shown
6. change values in <A1> and/or <A2>

Actual Results:
In step 3, the value in <A3> changes (because of the formula).
In step 6, nothing changes in <A3> nor in the cross-reference outside the table.

Expected Results:
The formula in <A3> is working and cross referenced, so changes in <A1> and/or <A2> causing a recalc of <A3> which is shown in <A3> and outside the TAB in the cross-reference field    


Reproducible: Always


User Profile Reset: Yes

Additional Info:
Version: 7.6.1.2 (X86_64) / LibreOffice Community
Build ID: f5defcebd022c5bc36bbb79be232cb6926d8f674
CPU threads: 8; OS: Windows 10.0 Build 22621; UI render: Skia/Raster; VCL: win
Locale: de-DE (de_DE); UI: en-US
Calc: threaded
Comment 1 m_a_riosv 2023-09-18 15:35:59 UTC
Please attach a sample file to test.

I think it was already reported, but I can't find it now.
Comment 2 Frank Schoefisch 2023-09-29 09:31:44 UTC
Created attachment 189882 [details]
Test/example file to demonstrate the described misbehaviour in 7.6.x

with LO writer 7.5.x:
* change value #1 or #2 and the value in row 3 (sum formula) and in the cross-reference outside the table will change


with LO writer 7.6.x:
* change value #1 or #2 and the value in row 3 (sum) and in the cross-reference outside the table will NOT change
* setting/resetting the cross-ref in row 3 will double content and does not work correct
Comment 3 m_a_riosv 2023-09-29 17:28:42 UTC
Reproducible with
Version: 7.6.1.2 (X86_64) / LibreOffice Community
Build ID: f5defcebd022c5bc36bbb79be232cb6926d8f674
CPU threads: 16; OS: Windows 10.0 Build 22621; UI render: Skia/Vulkan; VCL: win
Locale: es-ES (es_ES); UI: en-US Calc: CL threaded
and master
Version: 24.2.0.0.alpha0+ (X86_64) / LibreOffice Community
Build ID: 5e9c8d21874eea8cb5adf2ecab1905295af2308f
CPU threads: 16; OS: Windows 10.0 Build 22621; UI render: Skia/Raster; VCL: win
Locale: es-ES (es_ES); UI: en-US Calc: CL threaded Jumbo

regression from
Version: 7.5.7.1 (X86_64) / LibreOffice Community
Build ID: 47eb0cf7efbacdee9b19ae25d6752381ede23126
CPU threads: 16; OS: Windows 10.0 Build 22621; UI render: Skia/Raster; VCL: win
Locale: es-ES (es_ES); UI: en-US Calc: CL threaded
Comment 4 Stéphane Guillou (stragu) 2023-10-13 14:48:23 UTC
Repro in:

Version: 7.6.3.0.0+ (X86_64) / LibreOffice Community
Build ID: ba808a28f5ea365eaf8fe5d9c7c91b417633d75f
CPU threads: 8; OS: Linux 5.15; UI render: default; VCL: gtk3
Locale: en-AU (en_AU.UTF-8); UI: en-US
Calc: threaded

as well as recent trunk build:

Version: 24.2.0.0.alpha0+ (X86_64) / LibreOffice Community
Build ID: e9374f74385d7dfe77d1902d3d82af20143bc775
CPU threads: 8; OS: Linux 5.15; UI render: default; VCL: gtk3
Locale: en-AU (en_AU.UTF-8); UI: en-US
Calc: threaded

So not a duplicate of bug 157394.
Comment 5 Stéphane Guillou (stragu) 2023-10-13 14:49:38 UTC
*** Bug 157490 has been marked as a duplicate of this bug. ***
Comment 6 Stéphane Guillou (stragu) 2023-10-13 15:19:03 UTC
Bibisected with linux-64-7.6 repository to first bad commit 31429d62c565e5064e09bf2349278bf0b571254b which points to core commit:

commit 384a80fc56e75e3d1ee18ffc303db85490716829
author	Matti Tyrväinen 	Mon Feb 13 21:04:56 2023 +0200
committer	Miklos Vajna 	Fri May 19 12:28:35 2023 +0200
tdf#81720 Don't expand Reference Marks
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/146941

Matti, can you please have a look?
Comment 7 Matti Tyrväinen 2023-10-16 11:43:10 UTC
Created attachment 190237 [details]
Hotfix for 157287, unfixes 81720 without reverting refactoring and test

> Matti, can you please have a look?

As a single-time contributor with no prior C++ experience, I'm afraid the most I can offer right now is this patch that will restore the old reference mark behavior without reverting the UpdateFieldContent refactor nor removing the test case for tdf#81720. Two steps forward, one-and-a-half steps back...
Comment 8 Stéphane Guillou (stragu) 2023-10-16 12:13:19 UTC
Thanks Matti.
Miklos, any opinion on this one?
Comment 9 Miklos Vajna 2023-10-16 12:31:39 UTC
The expand or not expand decision is hard to win, there will be always a situation where the old behavior was helping some use-case we forgot about. So restroing the old refmark behavior for now looks like a good idea. And the next person who wants to change this can now be aware of this catch, to do better. Thanks.
Comment 10 Stéphane Guillou (stragu) 2023-10-16 12:42:44 UTC
OK, thanks Miklos!
Matti, please submit the patch on gerrit and we can then reopen bug 81720 with a note. Thank you!
Comment 11 Matti Tyrväinen 2023-10-16 19:34:10 UTC
> The expand or not expand decision is hard to win, there will be always a situation where the old behavior was helping some use-case we forgot about. So restroing the old refmark behavior for now looks like a good idea. And the next person who wants to change this can now be aware of this catch, to do better. Thanks.

To clarify, the problem isn't whether the behavior helps a use-case, but whether it breaks existing functionality whose implementation depends on the old behavior. I feel this distinction between code changes' effect on UX, and their effect on other code, is worth stressing as their solutions differ. While both can be fixed by restoring the old behavior, implementation bugs can also be fixed by changing the implementation (eg. moving UpdateFieldContent into the object's scope) while workflow-breaking behavior changes would require changing the workflow.

The new behavior should actually help in this use-case, as expanding the refmark in the cell by typing also stops it from updating, but until someone reworks the implementation behind the functionality used here, I agree that reverting it is appropriate.

> Matti, please submit the patch on gerrit

Done: https://gerrit.libreoffice.org/c/core/+/158059

Apologies for spamming Jenkins, couldn't test locally due to bump in GCC's required version.
Comment 12 Miklos Vajna 2023-10-17 06:43:53 UTC Comment hidden (off-topic)
Comment 13 Buovjaga 2023-10-19 14:00:42 UTC
(In reply to Matti Tyrväinen from comment #11)
> Apologies for spamming Jenkins, couldn't test locally due to bump in GCC's
> required version.

If you use Debian or Ubuntu, see the note for how to get a newer GCC: https://wiki.documentfoundation.org/Development/BuildingOnLinux#Debian_and_Ubuntu
Comment 14 Xisco Faulí 2023-10-23 12:23:40 UTC
The patch has been reverted with 58e5e3208a4257a8d9f2e28d8e2d304677aa6980 and backported to libreoffice-7-6
Closing as RESOLVED FIXED
Comment 15 Commit Notification 2023-10-23 19:22:58 UTC
Xisco Fauli committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/bae0736bf0ec54828766c3d903e2a27458643395

tdf#157287: sw_core_txtnode: Add unittest

It will be available in 24.2.0.

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

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