xref: /trunk/odf_docs/openformula-modernization-plan.md (revision 1354dfcdad4129e7cc561fdcfbb4f6c8958f0428) !
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# OpenFormula Modernization Plan — Apache OpenOffice Calc
21
22Written as an audit-only plan; later milestones did change production code, see the milestone reports. This plan is a prioritized roadmap derived from source evidence. Priority is by interoperability impact, not implementation convenience.
23
24Source-of-truth: `openformula-functions.tsv`, `openformula-operators.tsv`, `openformula-semantics.md`, `openformula-odf13-14-diff.md`, `openformula-conformance.md`, `openformula-test-gap-analysis.md`.
25
26## 1. Prioritized implementation plan
27
28### P1 — Interoperability-critical missing functions
29
30#### P1.1 IFNA (ODF 1.3, Large Group)
31
32Implemented in Milestone B.
33
34- `SC_OPCODE_IFNA=409`, `ScIfna()` in `interpr1.cxx`, dispatch in `interpr4.cxx:3451`, `scfuncs.src`, `core_resource.src:357`, `xlformula.cxx` stub replaced.
35- Status: Complete.
36
37#### P1.2 SKEWP (ODF 1.3, Medium Group)
38
39Implemented in Milestone B.
40
41- `SC_OPCODE_SKEWP=410`, `ScSkewP()` in `interpr3.cxx`, dispatch in `interpr4.cxx:3695`, `scfuncs.src`, `core_resource.src:358`, `xlformula.cxx` stub replaced.
42- Status: Complete.
43
44### P2 — Semantic discrepancies vs ODF 1.4
45
46#### P2.1 CONVERT `atm` unit value
47
48Corrected in Milestone C.
49
50- `atm` changed from 101324.996583 Pa to 101325.1 Pa per ODF 1.4 Table 24.
51- Files: `main/scaddins/source/analysis/analysishelper.cxx`.
52- Status: Complete.
53
54#### P2.2 INDEX row-vector single-argument
55
56Milestone A change reverted.
57
58- AOO returns the column (legacy); ODF 1.4 requires error for single-arg row vector.
59- Work: Regression-test against existing document corpus; consider compatibility option if needed.
60- Files: `main/sc/source/core/tool/interpr1.cxx` (ScIndex).
61- Status: Not changed. AOO keeps the legacy rule (returns the column), listed as a known deviation.
62
63#### P2.3 BITAND/BITOR/BITXOR variadic & BITLSHIFT/BITRSHIFT negative shift
64
65- Gap: `ScBitArithmeticOps` enforces exactly 2 params (`interpr1.cxx:1180`); `ScBitShiftOps` handles negative shift counts.
66- Work: Verify ODF 1.4 parameter count; confirm shift direction correctness.
67- Files: `main/sc/source/core/tool/interpr1.cxx`.
68- Status: UNVERIFIED — requires ODF 1.4 Part 4 spec text review.
69
70### P3 — Metadata / naming alignment
71
72#### P3.1 EASTERSUNDAY alias documentation
73
74- Behavior is correct under standard name `EASTERSUNDAY`; `ORG.OPENOFFICE.EASTERSUNDAY` is a legacy read-only alias (`compiler.cxx:2542`). Confirm standard name is written on export (`core_resource.src:333`); document alias.
75- Files: `main/sc/source/core/tool/compiler.cxx`, `main/formula/source/core/resource/core_resource.src`.
76
77#### P3.2 Other AOO-extension names written instead of standard
78
79- `ORG.OPENOFFICE.CURRENT` vs `CURRENT` (`core_resource.src:69` vs non-ODFF `:411`); `ORG.OPENOFFICE.ERRORTYPE` vs `ERROR.TYPE` (`:146` vs `:488`); `ORG.OPENOFFICE.STYLE` vs `STYLE` (`:336` vs `:678`); `ORG.OPENOFFICE.MULTIRANGE` vs `~` (`:251` vs `:257`); `COM.MICROSOFT.BAHTTEXT` vs `BAHTTEXT` (`:345` vs `:687`).
80- Work: Decide which names to write in strict ODF 1.4 mode vs extended; align export with ODF 1.4.
81
82### P4 — Test infrastructure (non-production build)
83
84#### P4.1 Versioned function inventories
85
86- Create `test/odf-validate/openformula-functions-1.4.txt` (and -1.3) from ODF 1.4 Part 4 chapter 6; keep current ODF 1.2 files as -1.2.
87- Wire `formulacheck.py` to select version.
88- Files: `test/odf-validate/`, `test/odf-validate/formulacheck.py`.
89
90#### P4.2 Semantic and parser test cases
91
92- Add calcval cases for COUNTA empty cells, DATE pre-1583, INDEX row-vector regression, BIT ops, short-circuit AND/OR, operator precedence.
93- Do NOT add to normal production build (per audit constraint).
94
95#### P4.3 Round-trip tests
96
97- Function-name export/import aliases; error cell value type (`office:value-type="error"` vs string).
98
99## 2. Dependencies between proposed changes
100
1011. COUNTA/COUNTBLANK change should be coordinated with any document-compatibility option; test against existing corpus before enabling. E.1 clarified fixtures/impl-defined `""` handling but did not change implementation.
1022. Test inventories depend on having the ODF 1.4 function list extracted; do P3.1 before P3.2/P3.3.
103
104## 3. Estimated implementation complexity
105
106| Item | Complexity | Rationale |
107|------|------------|-----------|
108| COUNTA/COUNTBLANK empty-cell semantics | Medium | Behavior change; regression risk medium; needs corpus testing. |
109| DATE out-of-constraint/pre-1583 behavior | Low | Document impl-defined/diagnostic behavior for inputs outside §6.10.2 constraints (e.g. Year < 1904); no code change needed. E.1 reclassified tests. |
110| INDEX row-vector regression testing | Medium | Corpus regression run; may need compatibility option. |
111| Test inventories | Medium | Requires ODF 1.4 Part 4 text extraction; tooling exists (formulacheck.py). |
112| Semantic/parser/round-trip tests | Medium-High | Many cases; runtime validation needed. |
113
114## 4. Regression risks
115
116| Risk | Area | Mitigation |
117|------|------|------------|
118| Existing documents rely on INDEX column-return legacy | INDEX (Milestone A) | Version-gate or document-compatibility option; corpus regression run. |
119| Changing COUNTA empty-cell semantics alters results | COUNTA/COUNTBLANK | Verify tolerance; document change; spot-check against existing documents. |
120| Export name changes break round-trip with older AOO | Symbol map | Keep legacy aliases as read-only (already done for EASTERSUNDAY); write standard names only in strict 1.4. |
121
122## 5. What must NOT change (per audit constraints)
123
124- No production source modifications in this phase.
125- No copying of LibreOffice implementation code.
126- No third-party formula engines.
127- Existing Calc functionality and legacy formula compatibility preserved.
128
129## 6. Definition of done for P1
130
131- COUNTA/COUNTBLANK: verify against ODF 1.4 §6.13.7/§6.13.8 (empty string non-blank for COUNTA; `""`-in-cell COUNTBLANK impl-defined); document semantic differences. E.1 test data/docs corrected.
132- DATE out-of-constraint/pre-1583: impl-defined/diagnostic per §6.10.2 constraints; E.1 reclassified `FN-016-DATE-pre1583` accordingly.
133- INDEX row-vector: regression-tested against document corpus.
134- Versioned test inventories created (not in production build).
135- All findings documented with file:line references (this audit's deliverables).
136
137## E.1 Test inventory corrections
138
139- Corrected Small Group Basic Limits tests: `SG-BL-001` uses a 1026-char formula expression (expected 513), `SG-BL-004` uses 7 genuinely nested IF levels.
140- Added `SG-SYN-001` (Criteria syntax §4.11.11) and documented `SG-SYN-009` named-expression harness dependency (`MYNAME`).
141- Updated COUNTA/COUNTBLANK and DATE out-of-constraint fixtures/classifications in `openformula-small-group-1.4.tsv`, `odf_docs/openformula-small-group-1.4-tests.tsv`, and `test/odf-validate/calcval-cases14.tsv`.
142- No runtime verification performed (no build; calcval macOS-only).
143