1<!-- 2 Licensed to the Apache Software Foundation (ASF) under one 3 or more contributor license agreements. See the NOTICE file 4 distributed with this work for additional information 5 regarding copyright ownership. The ASF licenses this file 6 to you under the Apache License, Version 2.0 (the 7 "License"); you may not use this file except in compliance 8 with the License. You may obtain a copy of the License at 9 10 http://www.apache.org/licenses/LICENSE-2.0 11 12 Unless required by applicable law or agreed to in writing, 13 software distributed under the License is distributed on an 14 "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 KIND, either express or implied. See the License for the 16 specific language governing permissions and limitations 17 under the License. 18--> 19 20# Apache OpenOffice Calc — OpenFormula 1.4 Compliance and Modernization Audit — Final Report 21 22Scope: AUDIT ONLY. No production source code was modified. No dependencies introduced. No third-party formula engines. Reference = Apache OpenOffice's own implementation (main/sc, main/formula). ODF 1.4 Part 4 = OASIS Standard, 6 October 2025. Branch: `openformula` (created from repository default). 23 24## 1. Method and constraints 25 26- Source inspected: `main/sc/source/core/tool/{interpr1-6,compiler,parclass}.cxx`, `main/sc/inc/{interpre,compiler}.hxx`, `main/formula/inc/formula/{opcode.hxx,compiler.hrc,grammar.hxx}`, `main/formula/source/core/api/FormulaCompiler.cxx`, `main/formula/source/core/resource/core_resource.src`, `main/sc/source/ui/src/scfuncs.src`, `main/sc/source/filter/excel/xlformula.cxx`. 27- AOO implementation-defined / known-limitations docs: `odf_docs/ODF14-IMPLEMENTATION-DEFINED-PUBLIC.md`, `odf_docs/ODF14-KNOWN-LIMITATIONS-PUBLIC.md`. 28- Test inventories: `test/aoo-test/data/openformula-functions.txt`, `test/odf-validate/openformula-functions.txt`, `test/aoo-test/data/calcval-cases.tsv`, `test/odf-validate/{calcval-cases,calcval-cases14}.tsv`. 29- Constraint honored: a function was NOT classified as missing solely because an Excel interop table uses `ocNoName`; actual source (opcode, interpr dispatch, scfuncs, core_resource) was checked. 30- Limitation: the full ODF 1.4 Part 4 normative text was not available locally; requirements inventory and conformance are therefore partly derived from AOO's own implementation-defined docs and the ODF 1.2 baseline. Items requiring the spec text are marked [UNVERIFIED]. 31 32## 2. Deliverables produced (all in /home/pedro/projects/aoo/) 33 34| # | Deliverable | Content | 35|---|-------------|---------| 36| 1 | openformula-requirements.tsv | Machine-readable requirements inventory (47 entries) from ODF 1.4 Part 4 chapters 2-8 and Appendix A, with ReqID, section, description, mandatory/optional, conformance group, ODF version, suggested test. | 37| 2 | openformula-functions.tsv | Function inventory: every opcode/function from `compiler.hrc`/`core_resource.src` (~200 rows) with Function, StandardName, ODFVersion, Opcode, OpcodeValue, implementation source, compiler mapping, resource mapping, Status (FULL/PARTIAL/MISSING/MAPPING/UNVERIFIED), notes. Includes confirmed-missing IFNA and SKEWP. | 38| 3 | openformula-operators.tsv | Operator/grammar audit: all operators, precedence, associativity, arity, parser/compiler/evaluator files, ODF section, status, notes. | 39| 4 | openformula-semantics.md | Calculation semantics: conversions, empty cells, string vs numeric, error propagation, short-circuit, arrays, dates, complex numbers, precision, locale; discrepancy table. | 40| 5 | openformula-odf13-14-diff.md | ODF 1.3 vs 1.4 migration audit for EASTERSUNDAY, CONVERT, COUNTA, INDEX, IS*, NPER, PMT, year 1583. | 41| 6 | openformula-conformance.md | Conformance assessment: AOO claims NO Small/Medium/Large group (source: IMPLEMENTATION-DEFINED:134); coverage by group; unsupported optional vs actual failures. | 42| 7 | openformula-test-gap-analysis.md | Existing test audit: outdated ODF 1.2 inventories, missing function/semantic/parser/round-trip tests, false-confidence tests, proposed versioned inventory and generation strategy. | 43| 8 | openformula-modernization-plan.md | Prioritized P1-P4 plan, dependencies, complexity estimates, regression risks, definition of done. | 44| 9 | openformula-final-report.md | This report. | 45 46## 3. Actual implementation coverage 47 48### Confirmed present (FULL) — opcodes + implementation + scfuncs + core_resource mapping 49 50All ODF 1.2 baseline functions in `test/aoo-test/data/openformula-functions.txt` have opcodes and implementations EXCEPT IFNA, SKEWP and IFERROR (IFERROR added 2026-11-16, see section 4; all three are implemented now). Notable present functions (representative, full list in `openformula-functions.tsv`): 51 52- Logical: AND, OR, XOR, NOT, IF, CHOOSE, TRUE, FALSE, NA. 53- IS*: ISBLANK, ISTEXT, ISNONTEXT, ISLOGICAL, ISREF, ISNUMBER, ISFORMULA, ISNA, ISERR, ISERROR, ISEVEN, ISODD, TYPE, CELL, N, ERROR.TYPE. 54- Text: CONCATENATE, LEFT, RIGHT, MID, LEN, TRIM, UPPER, LOWER, PROPER, TEXT, VALUE, FIND, SEARCH, REPLACE, SUBSTITUTE, REPT, CHAR, CODE, UNICODE, UNICHAR, JIS, ASC, CLEAN, DOLLAR, FIXED, T. 55- Math/trig: ABS, SIGN, INT, TRUNC, ROUND, ROUNDUP, ROUNDDOWN, CEILING, FLOOR, MOD, GCD, LCM, POWER, SQRT, EXP, LN, LOG, LOG10, SIN/COS/TAN/..., PI, DEGREES, RADIANS. 56- Statistical: SUM, AVERAGE, COUNT, COUNTA, MIN, MAX, STDEV/VAR families, MEDIAN, MODE, RANK, PERCENTILE, LARGE/SMALL, SKEW, KURT, HARMEAN, GEOMEAN, AVEDEV, DEVSQ, etc. 57- Date/time: DATE, TIME, DATEVALUE, TIMEVALUE, YEAR/MONTH/DAY/HOUR/MINUTE/SECOND, WEEKDAY, ISOWEEKNUM, EASTERSUNDAY, DAYS, DAYS360, NOW, TODAY. 58- Financial: PV, FV, PMT, NPER, RATE, IPMT, PPMT, NPV, IRR, MIRR, ISPMT, SLN, DB, DDB, SYD, VDB, PDURATION, CUMIPMT, CUMPRINC, EFFECT, NOMINAL, DURATION, PRICE*, YIELD*, COUPD*, etc. 59- Lookup/reference: VLOOKUP, HLOOKUP, LOOKUP, MATCH, INDEX, OFFSET, INDIRECT, ADDRESS, ROW/COLUMN/ROWS/COLUMNS/SHEET/SHEETS, AREAS, CHOOSE, HYPERLINK, GETPIVOTDATA, DDE. 60- Database: DSUM, DCOUNT, DCOUNTA, DAVERAGE, DGET, DMAX, DMIN, DPRODUCT, DSTDEV*, DVAR*. 61- Matrix: MDETERM, MINVERSE, MMULT, TRANSPOSE, MUNIT, SUMPRODUCT, SUMSQ, SUMX2MY2, SUMX2PY2, SUMXMY2, MVALUE. 62- Bitwise: BITAND, BITOR, BITXOR, BITLSHIFT, BITRSHIFT (all present, see below). 63- Engineering/Complex: COMPLEX/IM* family, BIN/DEC/HEX/OCT conversions, CONVERT, DECIMAL, BASE, ARABIC, ROMAN. 64- Information: INFO, CELL, TYPE, ERROR.TYPE, FORMULA, ISBLANK/ISREF/ISFORMULA. 65 66### Confirmed missing (MISSING) 67 68| Function | ODF Version | Evidence | 69|----------|-------------|----------| 70| IFNA | ODF 1.3 | No opcode (`compiler.hrc` max = 408 = BITRSHIFT), no `ScIfNA` in any `interpr*.cxx`, no `scfuncs.src` entry, no `core_resource.src` entry. Only `main/sc/source/filter/excel/xlformula.cxx:404` `EXC_FUNCENTRY_ODF( ocNoName, 2, 2, 0, "IFNA" )` — an Excel-filter stub with `ocNoName` (no opcode). | 71| SKEWP | ODF 1.3 | No opcode/implementation/metadata. Only `xlformula.cxx:415` `EXC_FUNCENTRY_ODF( ocNoName, 1, MX, 0, "SKEWP" )`. `SKEW` (sample skewness, `SC_OPCODE_SCHIEFE=325`, `interpr3.cxx:793`) is present; SKEWP (population) is not. | 72| IFERROR | ODF 1.2 baseline list | No opcode, no `scfuncs.src` or `core_resource.src` entry. Checked 2026-11-16: `=IFERROR(7;5)` gives `#NAME?`. The Excel filters carry it only as `oox/source/xls/formulabase.cxx` row `{ 0, "IFERROR", 480, ... }` with no Calc function behind it. | 73 74### Partial implementations / semantic discrepancies 75 76| Function/Issue | Status | Detail | Source | 77|----------------|--------|--------|--------| 78| CONVERT `atm` | PARTIAL | AOO uses 101324.996583 Pa; ODF 1.4 table = 1.0132510E+5 Pa (rel diff 1e-6) | `odf_docs/ODF14-KNOWN-LIMITATIONS-PUBLIC.md:72`; `interpr2.cxx` ScConvert | 79| INDEX row-vector single-arg | DISCREPANCY | AOO returns column; ODF 1.4 requires error | `KNOWN-LIMITATIONS:71`; `interpr1.cxx` ScIndex | 80| COUNTA / COUNTBLANK empty cells | PARTIAL/UNVERIFIED | ODF 1.4 changed empty-cell semantics; AOO `ScCount2`/`ScCountEmptyCells` not verified against ODF 1.4 | `interpr1.cxx`; `KNOWN-LIMITATIONS` 6.13.6-6.13.8 | 81| BITAND/BITOR/BITXOR | PARTIAL | Exactly 2 params enforced (`MustHaveParamCount(...,2)`); ODF 1.4 parameter count to verify | `interpr1.cxx:1180` | 82| BITLSHIFT/BITRSHIFT | POTENTIAL BUG | Negative shift inverts direction (`<<` for RSHIFT, `>>` for LSHIFT) at `interpr1.cxx:1231-1234`; ODF 1.4 rule to verify | `interpr1.cxx:1229-1243` | 83| DATE pre-1583 | Documented impl-defined | `#VALUE!` before 15 Oct 1582; YEAR/MONTH/DAY proleptic Gregorian | `KNOWN-LIMITATIONS:74`; `IMPLEMENTATION-DEFINED:155`; `interpr2.cxx:273-277` (EASTERSUNDAY enforces 1583-9956) | 84 85### Incorrect function mappings (MAPPING) 86 87AOO writes non-standard names for some functions (ODF 1.4 strict mode should use standard names): 88 89| AOO-written name | Standard name | Opcode | Source | 90|------------------|---------------|--------|--------| 91| `ORG.OPENOFFICE.EASTERSUNDAY` (legacy read-alias; standard `EASTERSUNDAY` is written per core_resource.src) | EASTERSUNDAY | ocEasterSunday=380 | `compiler.cxx:2542`; `core_resource.src:333` | 92| `ORG.OPENOFFICE.CURRENT` | CURRENT | ocCurrent=72 | `core_resource.src:69` vs `:411` | 93| `ORG.OPENOFFICE.ERRORTYPE` | ERROR.TYPE | ocErrorType=151 | `core_resource.src:146` vs `:488` | 94| `ORG.OPENOFFICE.STYLE` | STYLE | ocStyle=368 | `core_resource.src:336` vs `:678` | 95| `ORG.OPENOFFICE.MULTIRANGE` | `~` (union) | ocMultiArea=288 | `core_resource.src:251` vs `:257` | 96| `COM.MICROSOFT.BAHTTEXT` | BAHTTEXT | ocBahtText=156 | `core_resource.src:345` vs `:687` | 97| `LEGACY.NORMSDIST` / `LEGACY.NORMSINV` / `LEGACY.FDIST` / `LEGACY.CHIDIST` / `LEGACY.CHIINV` / `LEGACY.FINV` / `LEGACY.CHITEST` / `LEGACY.TDIST` | NORMSDIST/NORMSINV/FDIST/CHIDIST/CHIINV/FINV/CHITEST/TDIST | various | `core_resource.src` ODFF vs non-ODFF columns | 98| `B` | BINOM.DIST.RANGE | ocB=235 | `compiler.cxx:2540` alias | 99 100### Parser and grammar discrepancies 101 102- Operator precedence/associativity structure present in `FormulaCompiler.cxx`: `UnionLine` -> `IntersectionLine` -> `RangeLine` -> `UnaryLine` (lines 1203-1237), matching OpenFormula (union lowest, then intersection, range, unary, binary). 103- Automatic intersection: `ocSpaces` converted to `ocIntersect` at `FormulaCompiler.cxx:830-831`. 104- Range list `(A1;A2)` converted to union `(A1~A2)` at `FormulaCompiler.cxx:914-922`. 105- `[UNVERIFIED]` Quoted labels as implicit intersection (ODF 1.4 §3.9) — not confirmed in source. 106- `[UNVERIFIED]` Formula length and nesting limits documented. 107 108## 4. Confirmed missing functions 109 1101. **IFNA** (ODF 1.3) — absent from opcode map, interpreter, `scfuncs.src`, `core_resource.src`; only Excel-filter `ocNoName` stub (`xlformula.cxx:404`). 1112. **SKEWP** (ODF 1.3) — absent from opcode map/interpreter/`scfuncs.src`/`core_resource.src`; only Excel-filter `ocNoName` stub (`xlformula.cxx:415`). Sample `SKEW` present. 112 1133. **IFERROR** (ODF 1.2 baseline list) — no opcode, interpreter, `scfuncs.src` or `core_resource.src` entry (added 2026-11-16). Implemented the same day as opcode 411 (6f13be1d67), with xls and xlsx support (ca287e3487). 114 115The earlier sentence here, that no other function in the ODF 1.2 baseline is missing from the opcode map, was wrong for IFERROR. A runtime check on 2026-11-16 also found DATEDIF, FINDB, REPLACEB, SEARCHB, BINOM.DIST.RANGE, LEGACY.TDIST and ERROR.TYPE (present as ERRORTYPE) not recognised under their ODF names; these are not audited further (see `openformula-conformance.md` section 2). 116 117## 5. Partial implementations 118 119CONVERT (`atm` unit), COUNTA/COUNTBLANK (ODF 1.4 empty-cell semantics unverified), BITAND/BITOR/BITXOR (exactly-2-params), BITLSHIFT/BITRSHIFT (negative-shift handling), INDEX (row-vector rule), all IS* functions (ODF 1.4 edge cases impl-defined). See `openformula-functions.tsv` Status column and `openformula-semantics.md`. 120 121## 6. Incorrect function mappings 122 123See section 3 table. The most significant for ODF 1.4 strict export: AOO's ODFF symbol map writes several `ORG.OPENOFFICE.*` and `LEGACY.*` names where ODF 1.4 standard names exist. `EASTERSUNDAY` itself is written as the standard name per `core_resource.src:333`; `ORG.OPENOFFICE.EASTERSUNDAY` (`compiler.cxx:2542`) is a legacy read-only alias. 124 125## 7. Calculation semantic discrepancies 126 127See `openformula-semantics.md` discrepancy table: 128 129- DATE pre-1583 (`#VALUE!` before 15 Oct 1582; ODF 1.4 requires support from 1583, earlier impl-defined) — documented. 130- CONVERT `atm` 1e-6 relative difference. 131- INDEX row-vector single-argument (returns column vs ODF 1.4 error). 132- Trailing empty parameter `NPER(r;p;pv;;)` error except IF — documented consistent. 133- BIT op negative-shift direction (possible inversion). 134- Short-circuit AND/OR unverified. 135 136## 8. ODF 1.4 migration gaps 137 138See `openformula-odf13-14-diff.md` gap table: 139 140- EASTERSUNDAY: FULL, standard name works; legacy alias documented — no gap. 141- CONVERT: `atm` unit mismatch — low gap. 142- COUNTA: empty-cell semantics unverified — medium gap. 143- INDEX: row-vector rule — high gap (behavior change, regression risk). 144- IS* / NPER / PMT: present, ODF 1.4 edge cases unverified — low/medium gap. 145- Year 1583: documented impl-defined, consistent — no gap. 146 147## 9. Conformance assessment (Small / Medium / Large) 148 149**[CONFIRMED] AOO claims NO Part 4 conformance group.** (`odf_docs/ODF14-IMPLEMENTATION-DEFINED-PUBLIC.md:134`.) Therefore no conformance level (Small/Medium/Large) can be claimed for AOO Calc. 150 151Coverage indicators by group (presence-based, NOT semantic certification): 152 153- Small: core logical/text/math/date/IS* functions present; IFNA/SKEWP missing (likely Medium/Large+). 154- Medium: arrays, statistics, lookups present; IFNA/SKEWP missing may block Medium if mandatory in ODF 1.4. 155- Large: financial, bitwise, complex, database present; IFNA/SKEWP missing. 156 157Cannot certify any group without checking every mandatory requirement against the full ODF 1.4 Part 4 normative text. Unsupported optional capabilities are documented as implementation-defined rather than claimed failures. 158 159## 10. Prioritized implementation plan (see openformula-modernization-plan.md) 160 161P1: implement IFNA and SKEWP (opcodes, interpreter, scfuncs, core_resource). 162P2: fix CONVERT `atm`, INDEX row-vector rule, BIT op param count / negative shift. 163P3: align export names (`ORG.OPENOFFICE.*` / `LEGACY.*` vs standard). 164P4: versioned test inventories (not in production build), semantic/parser/round-trip cases. 165 166Dependencies: single opcode-block allocation for IFNA+SKEWP; INDEX change needs corpus regression test before enabling. 167 168## 11. Estimated implementation complexity 169 170- IFNA: Low-Medium. SKEWP: Medium. CONVERT atm: Low. INDEX row-vector: Medium (high regression risk). BIT ops: Low-Medium. Naming alignment: Medium. Test inventories: Medium. Semantic/parser/round-trip tests: Medium-High. 171 172## 12. Regression risks 173 174- INDEX behavior change: existing workbooks relying on column-return legacy. 175- CONVERT `atm`: 1e-6 result change. 176- Opcode space extension for IFNA/SKEWP. 177- BIT op negative-shift fix changing prior results. 178- Export name changes breaking round-trip with older AOO (mitigated by keeping legacy aliases as read-only). 179 180## 13. Confirmed vs unverified 181 182**Confirmed (source file:line evidence):** IFNA missing (`xlformula.cxx:404`), SKEWP missing (`xlformula.cxx:415`), EASTERSUNDAY implemented (`interpr2.cxx:261`, `compiler.cxx:2542`, `core_resource.src:333`), BIT functions implemented (`interpr1.cxx:1142-1249`, `interpr4.cxx:3769-3773`, `core_resource.src:352-356`), CONVERT `atm` discrepancy (`KNOWN-LIMITATIONS:72`), INDEX row-vector discrepancy (`KNOWN-LIMITATIONS:71`), DATE pre-1583 (`KNOWN-LIMITATIONS:74`, `IMPLEMENTATION-DEFINED:155`), no Part 4 group claimed (`IMPLEMENTATION-DEFINED:134`), test inventories are ODF 1.2 and lack EASTERSUNDAY (`test/aoo-test/data/openformula-functions.txt`, `test/odf-validate/openformula-functions.txt`). 183 184**Unverified (require ODF 1.4 Part 4 spec text and/or runtime testing):** full per-group mandatory coverage, COUNTA empty-cell semantics, IS* edge cases, short-circuit AND/OR, array evaluation rules, quoted labels, formula length/nesting limits, numerical precision beyond 48-bit, negative-shift BIT rule, PMT/NPER ODF 1.4 conformity. 185 186## 14. Conclusion 187 188AOO Calc implements the large majority of the ODF 1.2 OpenFormula function set, all bitwise functions (BITAND/BITOR/BITXOR/BITLSHIFT/BITRSHIFT), and EASTERSUNDAY under the standard name (with a legacy `ORG.OPENOFFICE.EASTERSUNDAY` read-alias). Two ODF 1.3 standard functions are confirmed missing: IFNA and SKEWP. There are documented ODF 1.4 semantic discrepancies (CONVERT `atm`, INDEX row-vector, DATE pre-1583) and several AOO-extension export names that diverge from ODF 1.4 standard names. AOO claims no Small/Medium/Large Part 4 conformance group. The highest-impact, lowest-effort work is implementing IFNA and SKEWP and correcting CONVERT `atm`; the highest regression risk is the INDEX row-vector behavior change. 189 190End of report. 191