Skip to content

fix(formula): read a space before an ods function's parenthesis - #1198

Merged
andiwand merged 1 commit into
mainfrom
fix/formula-space-before-paren
Oct 10, 2026
Merged

andiwand merged 1 commit into
mainfrom
fix/formula-space-before-paren

Conversation

@andiwand

@andiwand andiwand commented Oct 10, 2026 •

Copy link
Copy Markdown
Member

OpenFormula (ODF 1.3 part 4, §5.14) says: "whitespace shall not separate a function name from its initial opening parenthesis". But LibreOffice 6.1 and 6.2 wrote formulas like of:=ROUND (([.C2]*[.C1]^2)/[.B4];2) (ruski.ods) and of:=PRODUCT ((…); 0.5) (Meine Buecher-last test2.ods). The parser refused them. So these cells got no computed result, and #1193 made them read their whole sheet. A structural edit would also refuse on them (#1196).

What LibreOffice does

A probe .fods through soffice --convert-to fods:

Formula Result
ROUND (2.567;2) 2.57, written back as ROUND(2.567;2)
ROUND (2.567;2) (two spaces) 2.57
ROUND<tab>(2.567;2) #NAME?
ROUND<line feed>(2.567;2) #NAME?

Change

The OpenFormula branch of the parser skips spaces after a function name when a ( follows. OpenFormula spells the intersection operator !, so no other reading is possible. A tab or a line break stays an error. The OOXML syntax stays strict, because a space is the intersection operator there. The writer writes ROUND(, as LibreOffice does when it saves.

Verification

  • FormulaCorpus.every_answer_is_the_result_the_file_caches: 15045 of 15160 formulas answered, before 14970. All 75 new answers equal the result the file caches.
  • The formula, SheetDependencies, odf, ooxml, Document and html tests pass (788 tests).

Reference output

Four private pages change: the document view and the affected sheet of ruski.ods and of Meine Buecher-last test2.ods. Their formula cells get exact data-odr-reads instead of the whole sheet. I will update the reference output once, after this PR and the print PR that follows have landed.

OpenFormula 5.14 forbids a space between a function name and its "(", but
LibreOffice writes and reads "ROUND (". The parser refused these formulas,
so they got no result, no exact reads and no structural edit. Skip spaces
there in the OpenFormula syntax only. A tab or a line break stays an error,
as in LibreOffice, and the OOXML syntax stays strict.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01S5yx1nDeVcNX3BxqK1WpJz
@andiwand
andiwand merged commit 15b229c into main Oct 10, 2026
25 checks passed
@andiwand
andiwand deleted the fix/formula-space-before-paren branch October 10, 2026 09:22
andiwand added a commit that referenced this pull request Oct 10, 2026
…paces

The output now prints a text page with a page frame whole (#1199), and reads
a space before an ods function's parenthesis (#1198).

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01S5yx1nDeVcNX3BxqK1WpJz
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant