Bug 138646 - The "Excel R1C1" formula syntax does not allow you to refer to a named range (single cell or cell range) by name
Summary: The "Excel R1C1" formula syntax does not allow you to refer to a named range ...
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Calc (show other bugs)
Version:
(earliest affected)
7.0.2.2 release
Hardware: All All
: medium normal
Assignee: Andreas Heinisch
URL:
Whiteboard: target:7.2.0 target:7.1.3
Keywords:
Depends on:
Blocks:
 
Reported: 2020-12-03 18:59 UTC by Igor
Modified: 2021-12-19 12:49 UTC (History)
3 users (show)

See Also:
Crash report or crash signature:


Attachments
Explains the error in detail (50.25 KB, application/vnd.oasis.opendocument.spreadsheet)
2020-12-03 19:03 UTC, Igor
Details
Explains the error in detail (52.68 KB, application/vnd.oasis.opendocument.spreadsheet)
2020-12-04 19:48 UTC, Igor
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Igor 2020-12-03 18:59:05 UTC
Description:
When I tried to access the named range when the formula syntax was "Excel R1C1" an exception was thrown. The example file is attached.
Here is the problem:

    getCellRangeByName("NamedRange1")

Steps to Reproduce:
1. Go to Tools, Options, LibreOffice Calc, Formula and select "Calc R1C1" in the Formula syntax dropdown menu.
2. Run the macro "Main" in the attached file.
3. Referring to a named range throws an error.

Actual Results:
Error #1 intercepted.

Expected Results:
No errors occured.
The error disappears when you select "Calc A1" in the Formula syntax dropdown menu.


Reproducible: Always


User Profile Reset: No



Additional Info:
The same thing happens on Windows 10 and Linux Ubuntu 18.04 LTS.
Comment 1 Igor 2020-12-03 19:03:16 UTC
Created attachment 167807 [details]
Explains the error in detail

Everything is clear
Comment 2 Igor 2020-12-04 19:48:48 UTC
Created attachment 167840 [details]
Explains the error in detail
Comment 3 himajin100000 2021-02-20 16:09:12 UTC
Confirmed.

RuntimeException is thrown when I use either of "Excel A1" or "Excel R1C1"

I put some SAL_INFO macros to see what's happening. Though I haven't looked the source closer,

https://opengrok.libreoffice.org/xref/core/sc/source/core/tool/address.cxx?r=1250aecd&fi=ConvertSingleRef#1149

SAL_INFO("sc.core", OUString(p)); showed $Sheet1.$A$1 for "Calc A1", 
SAL_INFO("sc.core", OUString(p)); showed Sheet1!$A$1 for both "Excel A1" and "Excel R1C1".

This can be problematic here, I guess.
https://opengrok.libreoffice.org/xref/core/sc/source/core/tool/address.cxx?r=1250aecd&fi=ConvertSingleRef#1185
Comment 6 himajin100000 2021-02-22 15:40:28 UTC
https://opengrok.libreoffice.org/xref/core/sc/source/core/tool/rangeutl.cxx?r=1da69081&fi=MakeRangeFromName#279

https://opengrok.libreoffice.org/xref/core/sc/inc/rangenam.hxx?r=b49dada8#129

we can see from the GetSymbol's definition that the default value for the optional second parameter is formula::FormulaGrammar::GRAM_DEFAULT. This may be the culprit.
Comment 7 Commit Notification 2021-03-29 18:18:59 UTC
Andreas Heinisch committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/1bdef3250fc57ea3f9b69a1f55ceb035329b6fa9

tdf#138646 - consider the document's address convention

It will be available in 7.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 8 Andreas Heinisch 2021-03-29 20:15:10 UTC
Credits go to himajin100000@gmail.com for the code pointers, too!
Comment 9 Commit Notification 2021-04-12 14:46:24 UTC
Andreas Heinisch committed a patch related to this issue.
It has been pushed to "libreoffice-7-1":

https://git.libreoffice.org/core/commit/08cfec4a6e27ebc078345c57a7a74b2dffeb5b41

tdf#138646 - consider the document's address convention

It will be available in 7.1.3.

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.