Bug 156357 - Cannot copy formula by copying cell when displaying with Show Formula
Summary: Cannot copy formula by copying cell when displaying with Show Formula
Status: VERIFIED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Calc (show other bugs)
Version:
(earliest affected)
7.5.3.2 release
Hardware: All All
: medium normal
Assignee: Heiko Tietze
URL:
Whiteboard: target:24.2.0 inReleaseNotes:24.2
Keywords:
: 159338 (view as bug list)
Depends on:
Blocks: Cell-Formula Cut-Copy
  Show dependency treegraph
 
Reported: 2023-07-18 14:18 UTC by Shinji Enoki
Modified: 2024-02-27 14:44 UTC (History)
4 users (show)

See Also:
Crash report or crash signature:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Shinji Enoki 2023-07-18 14:18:44 UTC
Description:
[View]-[Show Formula] in the menu and [LibreOffice Calc]-[View] in the option dialog and [Display] in Formulas appear to have the same function.
But it behaves differently when copying cells. If this is unintended, it's a bug.

Steps to Reproduce:
1.start Calc
2.Enter the formula "=123/3" in A1
3.Turn on the menu [View]-[Show formula]
4.Click cell A1 and press Ctrl-C to copy
5.Paste it somewhere in a text editor

The resulting "41" is pasted instead of the displayed formula itself

However, the formula will copy and paste if they follow these steps:
3.instead of step 3 above, 
select menu [Tools]-[Options], [LibreOffice Calc]-[View], check [Formula] in [View], and click [OK]
4.Click cell A1 and press Ctrl-C to copy
5.Paste it somewhere in a text editor

The formula "=123/3" is pasted

These two menu items seem to be on/off affecting each other. If these are the same function, the copy result should be the same.

If it's different functions, I don't think they should affect each other's on/off

Actual Results:
The resulting "41" is pasted instead of the displayed formula itself

Expected Results:
The formula "=123/3" is pasted


Reproducible: Always


User Profile Reset: No

Additional Info:
Reproduced in the following versions:

Version: 7.6.0.0.alpha1+ (X86_64) / LibreOffice Community
Build ID: 45826e60d5f1508d54b0f0a4d98b0e2ebe94a097
CPU threads: 4; OS: Linux 5.10; UI render: default; VCL: gtk3
Locale: ja-JP (ja_JP.UTF-8); UI: en-US
Calc: threaded

Version: 7.5.3.2 (X86_64) / LibreOffice Community
Build ID: 9f56dff12ba03b9acd7730a5a481eea045e468f3
CPU threads: 4; OS: Linux 5.10; UI render: default; VCL: gtk3
Locale: ja-JP (ja_JP.UTF-8); UI: en-US
Calc: threaded

Version: 7.3.6.2 / LibreOffice Community
Build ID: c28ca90fd6e1a19e189fc16c05f8f8924961e12e
CPU threads: 4; OS: Linux 5.10; UI render: default; VCL: gtk3
Locale: ja-JP (ja_JP.UTF-8); UI: ja-JP
Calc: threaded
Comment 1 ady 2023-07-18 14:31:34 UTC
Also in recent LO Dev 24.2.
Comment 2 Eike Rathke 2023-07-18 16:07:01 UTC
The state of Tools->Options->Calc->View->Formulas [1] is sticky and not affected by View->Formulas or Ctrl+` shortcut [2]. i.e. if [1] is off always the value is copy-pasted, even when toggling [2], and if [1] is on always the formula is copy-pasted, also when toggling [2]. I really don't know if that is on purpose, but if it is then it should be documented. (I _can_ imagine it could come handy in certain scenarios, and [2] is only View ...).
Comment 3 ady 2023-07-18 17:50:15 UTC
I think that documentation should be improved in this regard. The current documentation seems to imply that these are equivalent (or at least it gives that impression to a common reader, perhaps unwillingly).

https://help.libreoffice.org/7.6/en-US/text/scalc/guide/formula_value.html?&DbPAR=SHARED

https://help.libreoffice.org/7.6/en-US/text/shared/optionen/01060100.html?&DbPAR=SHARED


When checking ON the menu View > Show Formula item, then also the Options entry gets immediately checked ON, but then [CTRL]+[C] acts as if the latter was OFF. This part seems somewhat inconsistent with comment 2. Is this behavior a bug, or intentional?

Perhaps better documentation + better tool-tips + some modification in the name of the Option is also needed(?).

Or maybe the current Options checkbox should rather be 2; one main checkbox and one sub-checkbox, with the second being equivalent to the current menu View > Show formula.
Comment 4 ady 2023-07-18 17:59:53 UTC
(In reply to ady from comment #3)

> When checking ON the menu View > Show Formula item, then also the Options
> entry gets immediately checked ON

To be clear, from the POV of how these _look_, they seem equivalent: setting either of them ON (or OFF) immediately sets the other ON (or OFF) too.

The resulting behavior, as reported here, is not actually the same.
Comment 5 Heiko Tietze 2023-07-24 10:35:21 UTC
a) both paste the value when formula is shown
b) both paste the formula when formula is shown
c) view > show formula and options > formula is labelled differently

My take is b) -> WYSIWYG.
Comment 6 Shinji Enoki 2023-07-25 11:23:46 UTC
(In reply to Heiko Tietze from comment #5)
> a) both paste the value when formula is shown
> b) both paste the formula when formula is shown
> c) view > show formula and options > formula is labelled differently
> 
> My take is b) -> WYSIWYG.

+1 to b) 

Since the formula is displayed, I think it is natural that it is copied
Comment 7 ady 2023-07-25 13:47:02 UTC
(In reply to Heiko Tietze from comment #5)
> c) view > show formula and options > formula is labelled differently

While it would seem intuitive for users to understand both settings as equivalent (i.e. option "b"), it is still not clear what was supposed to be the original intention of the two alternatives. Currently, they are labeled the same while they are not performing the same; so what was supposed to be the intention / use-case for each of the two actions?

IOW, is there a bug (i.e. they were supposed to be the same), or are we missing something (i.e. they were not intended to be the same)?
Comment 8 Heiko Tietze 2023-07-27 08:57:53 UTC
FID_TOGGLEFORMULA in sc/source/ui/view/tabvwsh3.cxx for the menu command and 
VOPT_FORMULAS in sc/inc/viewopti.hxx for the option

Both are closely entangled (and I don't see a reference when it was implemented). Restarting the application does the trick and you copy/paste the formula -- but switching back via the command still copy/pastes the formula and a restart is needed again. One solution is to commit the modifications properly. Likely per rDoc.SetViewOptions( aViewOpt );
Comment 9 ady 2023-08-04 16:16:44 UTC
May I ask... why is this now suddenly set as fixed? What "fixed" it? Is this a documentation-only issue? Is it a UI issue? An implementation error issue? A mix of these? Is there any commit or patch (or more than one) that "fixed" this bug 156357 somewhere?
Comment 10 Commit Notification 2023-08-18 07:21:44 UTC
Heiko Tietze committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/27fa859bb85ba7ac5b8cb22db5ae85750c7effba

Resolves tdf#156357 - Submit Show Formula to document

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.
Comment 11 Heiko Tietze 2023-08-18 07:22:58 UTC
(In reply to ady from comment #9)
> May I ask... why is this now suddenly set as fixed?
Mistakenly closed the ticket while the patch still was on review. No feedback within two weeks, let's have the user test it.
Comment 12 Heiko Tietze 2024-02-26 08:58:33 UTC
*** Bug 159338 has been marked as a duplicate of this bug. ***
Comment 13 Stéphane Guillou (stragu) 2024-02-27 14:25:53 UTC
Piotr added it to the release notes, with a gif: https://wiki.documentfoundation.org/index.php?title=ReleaseNotes%2F24.2&type=revision&diff=739956&oldid=739882

Verified in:

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

Thanks Heiko, it's great to be able to paste into Writer with Unformatted Text now.