Bug 87534 - HYPERLINK call in a name does not work
Summary: HYPERLINK call in a name does not work
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Calc (show other bugs)
Version:
(earliest affected)
Inherited From OOo
Hardware: x86-64 (AMD64) All
: medium minor
Assignee: Winfried Donkers (retired)
URL:
Whiteboard: target:4.5.0 target:4.4.2 target:4.3.7
Keywords:
Depends on:
Blocks:
 
Reported: 2014-12-20 19:03 UTC by rlk
Modified: 2015-02-12 19:12 UTC (History)
4 users (show)

See Also:
Crash report or crash signature:


Attachments
Demonstration that hyperlink in the form of a name does not work (12.64 KB, application/vnd.oasis.opendocument.spreadsheet)
2014-12-20 19:03 UTC, rlk
Details
various uses of STYLE, HYPERLINK and names (28.85 KB, application/vnd.oasis.opendocument.spreadsheet)
2015-01-14 07:01 UTC, Winfried Donkers (retired)
Details
various uses of STYLE, HYPERLINK and names (12.26 KB, application/vnd.oasis.opendocument.spreadsheet)
2015-01-15 09:51 UTC, Winfried Donkers (retired)
Details

Note You need to log in before you can comment on or make changes to this bug.
Description rlk 2014-12-20 19:03:33 UTC
Created attachment 111086 [details]
Demonstration that hyperlink in the form of a name does not work

Use of HYPERLINK() within a defined name does not work -- no link is there to be clicked on.

Compare cell A1 (which is a name defined as a call to HYPERLINK()) with cell c1 (which is a hyperlink at top level).  Note that C1 can be control-clicked; A1 can't.
Comment 1 rlk 2014-12-20 19:10:44 UTC
Also tested on 4.3.5.2 and 12/19 nightly.
Comment 2 m.a.riosv 2014-12-21 15:11:36 UTC
Hi @rlk, thanks for reporting.

It doesn't work in any version, neither OpenOffice.

I think it wasn't implemented to work in this way.

Please take a look: https://issues.oasis-open.org/browse/OFFICE-3435

May be better as request for enhancement, please if you are not agree reopen it.
Comment 3 rlk 2014-12-21 15:57:07 UTC
I'd prefer to call it a defect (from the user perspective).

I'm willing to call it "minor" severity, since there's a workaround always available (at least in this situation).  But from my perspective, it's a defect -- I can put anything else in a name and it works the same as it does in the actual formula.

While I'm not familiar with the innards of LibreOffice, the issue you refer to doesn't sound like it covers this situation one way or the other, and there's nothing in the documentation to indicate any limitation of this nature.
Comment 4 m.a.riosv 2014-12-21 17:11:36 UTC
Fine, it's your choice, but I changed the status to new as enhancement not as issue.

Changed to unconfirmed to let someone else verify the issue.
Comment 5 Robinson Tryon (qubit) 2015-01-03 16:42:56 UTC
Winfried: Thoughts?
Comment 6 Winfried Donkers (retired) 2015-01-05 16:10:16 UTC
(In reply to Robinson Tryon (qubit) from comment #5)
> Winfried: Thoughts?

Well, here are some of my thoughts:
I may fail to see the problem, so correct me if I'm wrong.
IMO the function HYPERLINK works as it should be (see http://docs.oasis-open.org/office/v1.2/cos01/OpenDocument-v1.2-cos01-part2.html#__RefHeading__1018226_715980110).

References to cells containing HYPERLINK function do not work as expected. It has not to do with named cells.
With the attachment, enter =C1 in cell A2 and the cell seems to contain a link, but it doesn't work as such.
The cells A1 and A2 show the result of the cell being referred to, but do not have the functionality the a cell containing a HYPERLINK function has.
I suggest that the title of this bug report be changed if you agree with my conclusion.

I haven't found out (yet) whether the ODF standard says that references like this are supposed to take over the behaviour as well as the result of the cell being referred to.

I agree that taking over the behaviour of the cell being referred to is more intuitive than the current situation.

At a first glance, changing this seems complicated: the formula compiler gives special functionality (act as hyperlink, see http://opengrok.libreoffice.org/xref/core/formula/source/core/api/FormulaCompiler.cxx#1207) to the cell containing the formula HYPERLINK. Cell A1 and A2 do not contain this function and to make the formula compiler give this special functionality to cells A1 and A2, it needs to interpret every reference first, with the result that cells with references are interpreted twice (first to check if the reference contains a cell with hyperlink functionality, secondly to calculate the result.). As the reference can be indirect (e.g. cell A2 referring to cell B2 which refers to cell C1), it is not a simple first interpret action.

Before I dig deeper, does my rambling seem correct/logical?
Comment 7 rlk 2015-01-06 13:04:12 UTC
I don't agree with your conclusion, because I'm not talking about references to cells containing hyperlinks.  I do not expect those cells to pick up the hyperlink "special functionality".  The best comparison is to another function that has this kind of special functionality, STYLE.

If I set C1 to =1+STYLE("heading") and A1 to =C1, then A1 gets C1's value, but not its style.  That's consistent with the behavior of HYPERLINK, and it's fine.

However, I can define a name "hdg" as STYLE("heading") and set C1 =1+hdg, and C1 is formatted as a heading.

What I cannot do, and what this bug's about, is define a name "jumptoa1" as HYPERLINK("#A1"), set C1 =1+jumptoa1, and then have C1 be a link.  So if I set C1 =1+hdg+jumptoa1, C1 gets the style from hdg but not the hyperlink from jumptoa1.  I have to explicitly set C1 to =1+hdg+HYPERLINK("#A1").  That's what I mean by "HYPERLINK call in a name does not work".  It isn't a matter of reference to a cell containing a hyperlink, it's a matter of it not working if the HYPERLINK call is in a name.  I make heavy use of names as (non-parameterizable) macros

If I set A1 =C1, it gets neither the hyperlink nor the style special functionality from C1.  That's fine and makes perfect sense.
Comment 8 Winfried Donkers (retired) 2015-01-06 15:33:50 UTC
(In reply to rlk from comment #7)
> I don't agree with your conclusion, because I'm not talking about references
> to cells containing hyperlinks.  I do not expect those cells to pick up the
> hyperlink "special functionality".  The best comparison is to another
> function that has this kind of special functionality, STYLE.
> [...]
> If I set A1 =C1, it gets neither the hyperlink nor the style special
> functionality from C1.  That's fine and makes perfect sense.

It is possible (even likely) that there is some difference in interpretation of our comments, with at least me using English as a foreign language. But agreement on the exact problem was and is what I'm aiming at and I'm glad with your comment.
I'm also a developer first and a Calc user second (and rarely use names).
As I see it, a name is a reference to something (e.g. a cell, a range or a formula). In the code, it seems to be handled as a reference, too (http://opengrok.libreoffice.org/xref/core/sc/source/core/tool/token.cxx#3051, link also meant for me to avoid another search for it). That's why I made no distinction between a cell containing a pure reference (=C1), or a cell containing a name (=hlink).

What suprises me, is that when I enter =C1 in cell A2 of attachment #111086 [details], The cell shows 'A link not in a name' as result, just as the result of C1. So cell A2 gets the result of the hyperlink function.
Note: my Calc is set to show the result of formulas/references in cells and not the references/formulas themselves.

And to get back to what I think you want, if cell with names (set to HYPERLINK functions) should get the result and the special functionality, cells with references to cells containing HYPERLINK function should just as well.

Do we agree? Or are more iterations needed ;-)
Comment 9 rlk 2015-01-06 15:42:48 UTC
No, we don't agree.

Go back to the behavior of styles in this context.  I'd like the behavior of HYPERLINK to mimic the behavior of STYLE in this regard.

If I assign the name "hdg" to the formula STYLE("heading"), then assigning either of these formulas to cell C1 results in that cell having the style "heading":

=1+STYLE("heading")

=1+hdg

However, if I assign cell A1 to have the formula

=C1

then A1 does not get C1's style.

With hyperlinks the behavior is different:

=1+HYPERLINK("#A1")

is not equivalent to assigning the name "hlink" to HYPERLINK("#A1") and

=1+hlink

The current behavior of styles is reasonable.  I would like the behavior of hyperlinks to match that of styles.
Comment 10 rlk 2015-01-08 01:20:43 UTC
Here's a slightly different way to think about it.

As you note, a name is a reference to something -- a cell, a range, or a formula.

If it's a reference to a formula, it should be a reference to the entire formula, including any style or hyperlink imposed by that formula.
Comment 11 Winfried Donkers (retired) 2015-01-09 09:41:13 UTC
Strangely, the code to enable the hyperlink-behaviour _is_ called when the HYPERLINK function is in a name. Apparently the connection with the appropriate cell is missing.
This must be fixable, so assigning myself to this bug.
Comment 12 Winfried Donkers (retired) 2015-01-14 07:01:06 UTC
Created attachment 112198 [details]
various uses of STYLE, HYPERLINK and names

As the problem may not be fixed soon, I have made a spreadsheet document with several different uses of the functions  STYLE, HYPERLINK and names demonstrating what works and what doesn't.

The difference between STYLE and HYPERLINK is simple: STYLE assigns a style to the cell during execution, therefore names with STYLE work as expected.
HYPERLINK only returns a string when executed (the text shown in the cell) and completely different code is used when the mouse moves over the cell (the function is not executed).

As a possible workaround for he time being, the use of HYPERLINK in cell D5 may be helpful.
Comment 13 rlk 2015-01-14 14:03:27 UTC
That's what I'm doing, but it results in things being a bit more complex than I'd like.
Comment 14 Winfried Donkers (retired) 2015-01-15 09:51:01 UTC
Created attachment 112282 [details]
various uses of STYLE, HYPERLINK and names

I've found the culprit and submitted a fix for review.
The attachment now indicates what will be the situation after the fix.

(As its a busy time now, with version 4.4.0 nearing release, review and putting it in the next version for 4.3 and 4,4 may take some time.)
Comment 15 Commit Notification 2015-02-12 19:05:20 UTC
Winfried Donkers committed a patch related to this issue.
It has been pushed to "master":

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

fdo#87534 fix HYPERLINK behaviour when used in names

It will be available in 4.5.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 16 Commit Notification 2015-02-12 19:08:59 UTC
Winfried Donkers committed a patch related to this issue.
It has been pushed to "libreoffice-4-4":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=8d210d109667cdf38bc5d35a596e06dc1f888104&h=libreoffice-4-4

fdo#87534 fix HYPERLINK behaviour when used in names

It will be available in 4.4.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 17 Commit Notification 2015-02-12 19:12:33 UTC
Winfried Donkers committed a patch related to this issue.
It has been pushed to "libreoffice-4-3":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=8e89b2673af9e135b74ad93b08737962d6fee3d8&h=libreoffice-4-3

fdo#87534 fix HYPERLINK behaviour when used in names

It will be available in 4.3.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.