Bug 162088 - Bring database-range keywords / table structured references to ODF
Summary: Bring database-range keywords / table structured references to ODF
Status: NEW
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Calc (show other bugs)
Version:
(earliest affected)
unspecified
Hardware: All All
: medium enhancement
Assignee: Not Assigned
URL: https://issues.oasis-open.org/browse/...
Whiteboard:
Keywords:
Depends on:
Blocks: 162275
  Show dependency treegraph
 
Reported: 2024-07-18 13:00 UTC by Regina Henschel
Modified: 2024-11-13 10:25 UTC (History)
5 users (show)

See Also:
Crash report or crash signature:


Attachments
First thoughts about bringing it to ODF (45.97 KB, application/vnd.oasis.opendocument.text)
2024-07-24 11:51 UTC, Regina Henschel
Details
First thoughts about bringing it to ODF (43.94 KB, application/vnd.oasis.opendocument.text)
2024-07-26 17:36 UTC, Regina Henschel
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Regina Henschel 2024-07-18 13:00:44 UTC
LibreOffice has implemented the database keywords [[#Data]], [[#Headers]], [[#Totals]] and [[#All]]. They work in principle besides bug 162087.

But these keywords are not exported, if the file is saved in ODF format. Instead the referenced ranges are written out as absolute range addresses. Import/Export to xlsx could keep these keywords in principle, but I'm not sure whether all cases work correctly.

The request is to save these keywords in ODF format too. That requires not only to change the import and export code, but in addition to help to get it included in ODF. Currently ODF has no means to hold this information.

This feature becomes more important now, as the SORT function uses #Data as default in Excel and LibreOffice now has SORT function implemented.
Comment 1 m_a_riosv 2024-07-18 21:48:46 UTC
+1
Comment 2 Regina Henschel 2024-07-20 10:33:24 UTC
Eike, what do you mean by "table structured references"? Or is it only an additional term for to get better Bugzilla search results?
Comment 4 Eike Rathke 2024-07-23 10:11:21 UTC
The MS Open Specification "[MS-XLSX]: Excel (.xlsx) Extensions to the Office Open XML SpreadsheetML File Format" at https://learn.microsoft.com/en-us/openspecs/office_standards/ms-xlsx/3d025add-118d-4413-9856-ab65712ec1b0 lists the ABNF grammar used by formulas. Search for "structure-reference", the following block (modulo comments) is exactly what needs to be added to ODFF as well:

 structure-reference = [table-identifier] intra-table-reference
 table-identifier = [book-prefix] table-name
 table-name = name
 ;table-name is the name of the table the structure reference refers to. If it is missing, the formula containing the structure reference MUST be entered into a cell which belongs to a table and that table's name is used as the table-name. table-name MUST be the value of the displayName attribute of some table element ([ISO/IEC29500-1:2016] section 18.5.1.2). It MUST NOT be any other user-defined name.
 intra-table-reference = spaced-lbracket inner-reference spaced-rbracket / keyword / ("[" [simple-column-name] "]")
 inner-reference = keyword-list / ([keyword-list spaced-comma] column-range)
 keyword = "[#All]" / "[#Data]" / "[#Headers]" / "[#Totals]" / "[#This Row]"
 keyword-list = keyword / ("[#Headers]" spaced-comma "[#Data]") / ("[#Data]" spaced-comma "[#Totals]")
 column-range = column [":" column]
 column = simple-column-name / ("[" *space simple-column-name *space "]")
 simple-column-name = [any-nospace-column-character *any-column-character] any-nospace-column-character
 escape-column-character = tick / "[" / "]" / "#"
 tick = %x27
 unescaped-column-character = character   ; MUST NOT match escape-column-character or space
 any-column-character = any-nospace-column-character / space
 any-nospace-column-character = unescaped-column-character / (tick escape-column-character)
 spaced-comma = [space] comma [space]
 spaced-lbracket = "[" [space]
 spaced-rbracket = [space] "]"
Comment 5 Regina Henschel 2024-07-24 11:51:00 UTC
Created attachment 195468 [details]
First thoughts about bringing it to ODF

I have written down my first thought of how to bring it to ODF, for discussions.
Comment 6 Regina Henschel 2024-07-26 17:36:11 UTC
Created attachment 195542 [details]
First thoughts about bringing it to ODF

Updated version
Comment 7 Regina Henschel 2024-08-08 15:08:03 UTC
I have started an issue at Oasis.
Comment 8 gamgster 2024-11-12 18:39:28 UTC
(In reply to Eike Rathke from comment #4)
> The MS Open Specification "[MS-XLSX]: Excel (.xlsx) Extensions to the Office
> Open XML SpreadsheetML File Format" at
> https://learn.microsoft.com/en-us/openspecs/office_standards/ms-xlsx/
> 3d025add-118d-4413-9856-ab65712ec1b0 lists the ABNF grammar used by
> formulas. Search for "structure-reference", the following block (modulo
> comments) is exactly what needs to be added to ODFF as well:
> 
>  structure-reference = [table-identifier] intra-table-reference
>  table-identifier = [book-prefix] table-name
>  table-name = name
>  ;table-name is the name of the table the structure reference refers to. If
> it is missing, the formula containing the structure reference MUST be
> entered into a cell which belongs to a table and that table's name is used
> as the table-name. table-name MUST be the value of the displayName attribute
> of some table element ([ISO/IEC29500-1:2016] section 18.5.1.2). It MUST NOT
> be any other user-defined name.
>  intra-table-reference = spaced-lbracket inner-reference spaced-rbracket /
> keyword / ("[" [simple-column-name] "]")
>  inner-reference = keyword-list / ([keyword-list spaced-comma] column-range)
>  keyword = "[#All]" / "[#Data]" / "[#Headers]" / "[#Totals]" / "[#This Row]"
>  keyword-list = keyword / ("[#Headers]" spaced-comma "[#Data]") / ("[#Data]"
> spaced-comma "[#Totals]")
>  column-range = column [":" column]
>  column = simple-column-name / ("[" *space simple-column-name *space "]")
>  simple-column-name = [any-nospace-column-character *any-column-character]
> any-nospace-column-character
>  escape-column-character = tick / "[" / "]" / "#"
>  tick = %x27
>  unescaped-column-character = character   ; MUST NOT match
> escape-column-character or space
>  any-column-character = any-nospace-column-character / space
>  any-nospace-column-character = unescaped-column-character / (tick
> escape-column-character)
>  spaced-comma = [space] comma [space]
>  spaced-lbracket = "[" [space]
>  spaced-rbracket = [space] "]"

IDEA
   What if keywords were
      "[#All]" for "[#All]"
      "[#Data]" for [#Data]"
      "[#RowHeaders]" for "[#Headers]"
      "[#RowTotals]" for "[#Totals]"
      "[#This Row]" for "[#This row]"
      "@Row" for "@"
      "[#ColHeaders]" for <unavailable expression in MS Excel>
      "[#ColTotals]" for <unavailable expression in MS Excel>
      "[#This col]" for <unavailable expression in MS Excel>
      "@Col" for <unavailable expression in MS Excel>

This would be an improving of expressions to use a fully functional DatabaseRange (bidimensional: horizontal and vertical).
Comment 9 Eike Rathke 2024-11-13 10:25:12 UTC
(In reply to gamgster from comment #8)
>    What if keywords were
Makes no sense to define something different than Excel that can't be translated to Excel.